コード例 #1
0
		private void toolSetController_ToolRemoved(object sender, ToolEventArgs e) {
			//listView.SuspendLayout();
			//ListViewItem item = FindItem(e.Tool);
			//listView.Items.Remove(item);
			//listView.ResumeLayout();
		}
コード例 #2
0
		private void toolSetController_ToolAdded(object sender, ToolEventArgs e) {
			// SaveChanges the list view: Move this to ToolSetListViewPresenter
			if (FindItem(e.Tool) != null)
				throw new NShapeException(string.Format("Tool {0} already exists.", e.Tool.Title));
			ToolStripItem item = CreateItem(e.Tool);
			// ToDo: Put the tool into the right group, seperrate groups by seperators
			//   if (!string.IsNullOrEmpty(e.Tool.Category)) {
			//      foreach (ListViewGroup group in listView.Groups) {
			//         if (group.Name.Equals(e.Tool.Category, StringComparison.InvariantCultureIgnoreCase)) {
			//            item.Group = group;
			//            break;
			//         }
			//      }
			//      if (item.Group == null) {
			//         ListViewGroup group = new ListViewGroup(e.Tool.Category, e.Tool.Category);
			//         listView.Groups.Add(group);
			//         item.Group = group;
			//      }
			//   }
			//   // Adjust the heading column in the list view
			//   if (listView.Columns[headerName] != null) {
			//      Graphics gfx = Graphics.FromHwnd(listView.Handle);
			//      if (gfx != null) {
			//         SizeF txtSize = gfx.MeasureString(e.Tool.Title, listView.Font);
			//         if (listView.Columns[headerName].Width < txtSize.Width + listView.SmallImageList.ImageSize.Width)
			//            listView.Columns[headerName].Width = (int)Math.Ceiling(txtSize.Width + listView.SmallImageList.ImageSize.Width);
			//         gfx.Dispose();
			//         gfx = null;
			//      }
			//   }
			// Add the item and select if default
			Items.Add(item);
		}
コード例 #3
0
		private void toolSetController_ToolChanged(object sender, ToolEventArgs e) {
			//if (listView != null && e.Tool is TemplateTool) {
			//   listView.BeginUpdate();
			//   ListViewItem item = FindItem(e.Tool);
			//   if (item != null) {
			//      TemplateTool tool = (TemplateTool)e.Tool;
			//      largeImageList.Images[item.ImageIndex] = tool.LargeIcon;
			//      smallImageList.Images[item.ImageIndex] = tool.SmallIcon;
			//   }
			//   listView.EndUpdate();
			//}
		}
コード例 #4
0
ファイル: MainForm.cs プロジェクト: LudovicT/NShape
 private void toolSetController_ToolSelected(object sender, ToolEventArgs e)
 {
     ToolStripButton button = FindToolStripButton(e.Tool);
     UncheckAllOtherButtons(button);
     button.Checked = true;
 }
コード例 #5
0
		private void toolSetController_ToolSelected(object sender, ToolEventArgs e) {
			ToolStripItem item = FindItem(e.Tool);
			if (item != null) item.Select();
		}
コード例 #6
0
ファイル: MainForm.cs プロジェクト: LudovicT/NShape
 private void toolSetController_ToolRemoved(object sender, ToolEventArgs e)
 {
     UpdateToolBoxStrip();
 }
コード例 #7
0
ファイル: MainForm.cs プロジェクト: LudovicT/NShape
 private void toolSetController_ToolChanged(object sender, ToolEventArgs e)
 {
     ToolStripButton button = FindToolStripButton(e.Tool);
     button.Image = toolSetController.SelectedTool.SmallIcon;
 }
コード例 #8
0
 private void toolBoxController_ToolSelected(object sender, ToolEventArgs e)
 {
     if (listView != null) {
         ListViewItem item = FindItem(e.Tool);
         if (item != null && listView.SelectedItems.IndexOf(item) < 0)
             item.Selected = true;
     }
 }
コード例 #9
0
 private void toolBoxController_ToolChanged(object sender, ToolEventArgs e)
 {
     if (listView != null && e.Tool is TemplateTool) {
         listView.BeginUpdate();
         ListViewItem item = FindItem(e.Tool);
         if (item != null) {
             TemplateTool tool = (TemplateTool)e.Tool;
             item.Text = tool.Title;
             largeImageList.Images[item.ImageIndex] = tool.LargeIcon;
             smallImageList.Images[item.ImageIndex] = tool.SmallIcon;
         }
         listView.EndUpdate();
     }
 }
コード例 #10
0
        private void toolBoxController_ToolAdded(object sender, ToolEventArgs e)
        {
            // SaveChanges the list view: Move this to ToolSetListViewPresenter
            if (listView == null) return;

            if (FindItem(e.Tool) != null)
                throw new NShapeException(string.Format("Tool {0} already exists.", e.Tool.Title));
            ListViewItem item = CreateItem(e.Tool);
            // Put the tool into the right group
            if (!string.IsNullOrEmpty(e.Tool.Category)) {
                foreach (ListViewGroup group in listView.Groups) {
                    if (group.Name.Equals(e.Tool.Category, StringComparison.InvariantCultureIgnoreCase)) {
                        item.Group = group;
                        break;
                    }
                }
                if (item.Group == null) {
                    ListViewGroup group = new ListViewGroup(e.Tool.Category, e.Tool.Category);
                    listView.Groups.Add(group);
                    item.Group = group;
                }
            }
            // Adjust the heading column in the list view
            if (listView.Columns[headerName] != null) {
                using (Graphics gfx = Graphics.FromHwnd(listView.Handle)) {
                    SizeF txtSize = gfx.MeasureString(e.Tool.Title, listView.Font);
                    int currItemWidth = (int)Math.Round(txtSize.Width + 2 + listView.SmallImageList.ImageSize.Width);
                    if (currItemWidth > largestItemWidth) {
                        largestItemWidth = currItemWidth;
                        listView.Columns[headerName].Width = largestItemWidth;
                    }
                }
            }
            // Add the item and select if default
            listView.Items.Add(item);
        }