Changeset 918 for branches/eraser6/Eraser/ToolBar.cs
- Timestamp:
- 4/29/2009 8:09:16 AM (4 years ago)
- File:
-
- 1 edited
-
branches/eraser6/Eraser/ToolBar.cs (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/Eraser/ToolBar.cs
r910 r918 40 40 41 41 //Initialize the toolbar item list 42 items = new List<ToolBarItem>();42 Items = new ToolbarItemCollection(this); 43 43 44 44 //Hook mouse move events to show the currently selected item … … 62 62 //See if the click was on any item's arrow. 63 63 Rectangle mouse_rect = new Rectangle(e.Location, new Size(1, 1)); 64 foreach (ToolBarItem i in items)64 foreach (ToolBarItem i in Items) 65 65 { 66 66 if (i.Menu != null && mouse_rect.IntersectsWith(i.MenuRect)) … … 95 95 int x = 0; 96 96 97 foreach (ToolBarItem i in items)97 foreach (ToolBarItem i in Items) 98 98 { 99 99 { … … 172 172 /// Stores the items in the Tool Bar. 173 173 /// </summary> 174 private List<ToolBarItem> items; 175 176 /// <summary> 177 /// Accesses or modifies the items in the tool bar. 178 /// </summary> 179 /// <param name="index">Index of item.</param> 180 /// <returns>ToolBarItem describing the item at index i.</returns> 181 public ToolBarItem this[int index] 182 { 183 get 184 { 185 return items[index]; 186 } 187 188 set 189 { 190 items[index] = value; 191 Redraw(); 192 } 193 } 194 195 public ICollection<ToolBarItem> Items 196 { 197 get { return items; } 174 public ToolbarItemCollection Items 175 { 176 get; 177 set; 198 178 } 199 179 } … … 204 184 /// Tool bar item text. 205 185 /// </summary> 206 [Description("Tool bar item text")]186 [Description("Toolbar item text")] 207 187 public string Text 208 188 { 209 189 get { return text; } 210 set { text = value; } 190 set 191 { 192 text = value; 193 if (Window != null) 194 Window.Redraw(); 195 } 211 196 } 212 197 … … 218 203 { 219 204 get { return bitmap; } 220 set { bitmap = value; } 205 set 206 { 207 bitmap = value; 208 if (Window != null) 209 Window.Redraw(); 210 } 221 211 } 222 212 … … 227 217 { 228 218 get { return menu; } 229 set { menu = value; } 219 set 220 { 221 menu = value; 222 if (Window != null) 223 Window.Redraw(); 224 } 230 225 } 231 226 … … 250 245 251 246 /// <summary> 247 /// The owning window of this item. 248 /// </summary> 249 internal ToolBar Window; 250 251 /// <summary> 252 252 /// Stores the rectangle of this item. 253 253 /// </summary> 254 internal Rectangle Rectangle = new Rectangle();254 internal Rectangle Rectangle; 255 255 256 256 /// <summary> … … 269 269 internal Rectangle MenuRect; 270 270 } 271 272 public class ToolbarItemCollection : ICollection<ToolBarItem>, IList<ToolBarItem>, 273 IEnumerable<ToolBarItem> 274 { 275 /// <summary> 276 /// Constructor. 277 /// </summary> 278 /// <param name="win">The owning toolbar window.</param> 279 internal ToolbarItemCollection(ToolBar win) 280 { 281 window = win; 282 } 283 284 #region ICollection<ToolBarItem> Members 285 public void Add(ToolBarItem item) 286 { 287 if (item.Window != null) 288 throw new ArgumentException("The item being added already is owned by " + 289 "another ToolBar control. Remove the item from the other control " + 290 "before inserting it into this one."); 291 292 item.Window = window; 293 list.Add(item); 294 window.Redraw(); 295 } 296 297 public void Clear() 298 { 299 foreach (ToolBarItem item in list) 300 item.Window = null; 301 list.Clear(); 302 window.Redraw(); 303 } 304 305 public bool Contains(ToolBarItem item) 306 { 307 return list.Contains(item); 308 } 309 310 public void CopyTo(ToolBarItem[] array, int arrayIndex) 311 { 312 list.CopyTo(array, arrayIndex); 313 } 314 315 public int Count 316 { 317 get { return list.Count; } 318 } 319 320 public bool IsReadOnly 321 { 322 get { return false; } 323 } 324 325 public bool Remove(ToolBarItem item) 326 { 327 item.Window = null; 328 bool result = list.Remove(item); 329 window.Redraw(); 330 return result; 331 } 332 #endregion 333 334 #region IEnumerable<ToolBarItem> Members 335 public IEnumerator<ToolBarItem> GetEnumerator() 336 { 337 return list.GetEnumerator(); 338 } 339 #endregion 340 341 #region IEnumerable Members 342 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() 343 { 344 return list.GetEnumerator(); 345 } 346 #endregion 347 348 #region IList<ToolBarItem> Members 349 public int IndexOf(ToolBarItem item) 350 { 351 return list.IndexOf(item); 352 } 353 354 public void Insert(int index, ToolBarItem item) 355 { 356 throw new NotImplementedException(); 357 } 358 359 public void RemoveAt(int index) 360 { 361 throw new NotImplementedException(); 362 } 363 364 public ToolBarItem this[int index] 365 { 366 get 367 { 368 throw new NotImplementedException(); 369 } 370 set 371 { 372 throw new NotImplementedException(); 373 } 374 } 375 #endregion 376 377 /// <summary> 378 /// The window owning the items in this list. 379 /// </summary> 380 private ToolBar window; 381 382 /// <summary> 383 /// The list storing the toolbar items. 384 /// </summary> 385 private List<ToolBarItem> list = new List<ToolBarItem>(); 386 } 271 387 }
Note: See TracChangeset
for help on using the changeset viewer.
