/// <include file='doc\VsWindowPane.uex' path='docs/doc[@for="VsWindowPane.IVsToolboxUser.ItemPicked"]/*' /> /// <devdoc> /// This happens when a user double-clicks a toolbox item. We add the /// item to the center of the form. /// </devdoc> void IVsToolboxUser.ItemPicked(NativeMethods.IOleDataObject pDO) { if (toolboxService == null) { toolboxService = (IToolboxService)GetService((typeof(IToolboxService))); } if (toolboxService != null) { ToolboxItem item = toolboxService.DeserializeToolboxItem(pDO, DesignerHost); if (item != null) { if (OnToolPicked(item)) { toolboxService.SelectedToolboxItemUsed(); } } } if (toolboxUser == null) { toolboxUser = (IVsToolboxUser)GetService(typeof(IVsToolboxUser)); } if (toolboxUser != null) { toolboxUser.ItemPicked(pDO); } }
/// <include file='doc\VsWindowPane.uex' path='docs/doc[@for="VsWindowPane.ClosePane"]/*' /> /// <devdoc> /// Called by Visual Studio when it wants to close this pane. The pane may be /// later re-opened by another call to CreatePaneWindow. /// </devdoc> public virtual int ClosePane() { OnWindowPaneClose(); if (menuService != null) { menuService.Dispose(); menuService = null; } if (helpService != null) { helpService.Dispose(); helpService = null; } if (vsBroadcastEventCookie != 0 && vsShell != null) { vsShell.UnadviseBroadcastMessages(vsBroadcastEventCookie); vsShell = null; vsBroadcastEventCookie = 0; } toolboxService = null; host = null; hostChecked = false; return(NativeMethods.S_OK); }
/// <include file='doc\VsWindowPane.uex' path='docs/doc[@for="VsWindowPane.IVsToolboxUser.IsSupported"]/*' /> /// <devdoc> /// </devdoc> int IVsToolboxUser.IsSupported(NativeMethods.IOleDataObject pDO) { int supported = NativeMethods.S_FALSE; if (toolboxService == null) { toolboxService = (IToolboxService)GetService(typeof(IToolboxService)); } if (toolboxService != null && toolboxService.IsSupported(pDO, DesignerHost)) { supported = NativeMethods.S_OK; } if (toolboxUser == null) { toolboxUser = (IVsToolboxUser)GetService(typeof(IVsToolboxUser)); } if (toolboxUser != null) { if (toolboxUser.IsSupported(pDO) == NativeMethods.S_OK) { supported = NativeMethods.S_OK; } } return(supported); }
private void OnDesignerLoaded(object sender, DesignerLoadedEventArgs e) { IToolboxService ts = (IToolboxService)e.DesignerHost.GetService(typeof(IToolboxService)); // Add a custom control. ts.AddToolboxItem(new ToolboxItem(typeof(MyGaugeControl))); }
private void Toolbox_MouseDoubleClick(object sender, EventArgs e) { IDesignerHost host = this.serviceContainer.GetService(typeof(IDesignerHost)) as IDesignerHost; IToolboxService tb = this.serviceContainer.GetService(typeof(IToolboxService)) as IToolboxService; ((IToolboxUser)(DocumentDesigner)host.GetDesigner(host.RootComponent)).ToolPicked(tb.GetSelectedToolboxItem()); }
protected override void OnDragDrop(DragEventArgs de) { base.OnDragDrop(de); IToolboxService it = (IToolboxService)this.GetService(typeof(IToolboxService)); it.SetSelectedToolboxItem(null); }
private static void AddCustomControl(IToolboxService ts) { ToolboxItem newItem = new ToolboxItem(typeof(CustomChartDesigner.CustomXRChart)); newItem.DisplayName = "Custom Chart"; ts.AddToolboxItem(newItem); }
/// <summary> /// Handles the Drag event which raises a DoDragDrop event used by the /// DesignSurface to drag items from the Toolbox to the DesignSurface. /// If the currently selected item is the pointer item then the drag drop /// operation is not started. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnItemDrag(object sender, ItemDragEventArgs e) { if (e.Button == MouseButtons.Left && e.Item.GetType() == typeof(ListViewItem)) { ToolboxItem lItem = (e.Item as ListViewItem).Tag as ToolboxItem; if (lItem.TypeName != NameConsts.Pointer) { mIsDragging = true; IToolboxService lToolboxService = mToolboxService as IToolboxService; object lDataObject = lToolboxService.SerializeToolboxItem(lItem); DrawingTool lTool = lItem.CreateComponents().FirstOrDefault() as DrawingTool; lTool.CreatePersistence(); Rectangle lRect = lTool.SurroundingRect; using (DragImage image = new DragImage(lTool.DefaultImage, lRect.Width / 2, lRect.Height / 2)) { DoDragDrop(lDataObject, DragDropEffects.All); } mIsDragging = false; } } }
/// <summary> /// Initialize the workflow designer loader /// </summary> protected override void Initialize() { base.Initialize(); //add any necessary services IDesignerLoaderHost host = LoaderHost; if (host != null) { //add the custom MenuCommandService host.AddService( typeof(IMenuCommandService), new WorkflowMenuService(host)); //add the TypeProvider host.AddService( typeof(ITypeProvider), _typeProvider, true); //add the toolbox service _toolboxService = new WorkflowToolboxService(host); host.AddService( typeof(IToolboxService), _toolboxService); //add the property value UI service host.AddService( typeof(IPropertyValueUIService), new WorkflowPropertyValueService()); //add the event binding service host.AddService( typeof(IEventBindingService), new WorkflowEventBindingService(host)); } }
private void UpdateToolboxItem(IDesignerHost host) { if (host == null) { throw new ArgumentNullException(); } // Now get a hold of the toolbox service and add an icon for our user control. The // toolbox service will automatically maintain this icon as long as our file lives. // IToolboxService tbx = (IToolboxService)GetService(typeof(IToolboxService)); if (tbx != null) { fullClassName = host.RootComponentClassName; if (this.toolboxItem != null) { tbx.RemoveToolboxItem(this.toolboxItem); } this.toolboxItem = new UserControlToolboxItem(fullClassName); try { tbx.AddLinkedToolboxItem(toolboxItem, SR.GetString(SR.UserControlTab), host); } catch (Exception ex) { Debug.Fail("Failed to add toolbox item", ex.ToString()); } } }
private void r_DesignerLoaded(object sender, DevExpress.XtraReports.UserDesigner.DesignerLoadedEventArgs e) { IToolboxService ts = e.DesignerHost.GetService(typeof(IToolboxService)) as IToolboxService; RemoveStandardItem(ts); AddCustomControl(ts); }
void rpt_DesignerLoaded(object sender, DesignerLoadedEventArgs e) { _DesignerHost = e.DesignerHost; if (_DataSource == null) { _DataSource = xrDesignPanel1.Report.DataSource; } IToolboxService ts = (IToolboxService)e.DesignerHost .GetService(typeof(IToolboxService)); ts.AddToolboxItem(new ToolboxItem(typeof(xrFunction))); ts.AddToolboxItem(new ToolboxItem(typeof(xrPictureVar))); IMenuCommandService ms = (IMenuCommandService)e.DesignerHost .GetService(typeof(IMenuCommandService)); MenuCommand fileOpenCommand = ms.FindCommand(UICommands.OpenFile); ms.RemoveCommand(fileOpenCommand); ms.AddCommand(new MenuCommand(new EventHandler(OnOpenFile), UICommands.OpenFile)); MenuCommand CloseCommand = ms.FindCommand(UICommands.Closing); if (CloseCommand != null) { ms.RemoveCommand(CloseCommand); } ms.AddCommand(new MenuCommand(new EventHandler(OnCloseFile), UICommands.Closing)); }
/// <devdoc> /// Saves any checked / unchecked changes made in the dialog to the given toolbox /// service. /// </devdoc> public void SaveChanges(IToolboxService toolboxSvc) { string currentCategory = toolboxSvc.SelectedCategory; foreach (ToolboxListViewItem item in controlList.Items) { if (item.InitiallyChecked != item.Checked) { if (item.InitiallyChecked) { // Item was initially checked, but it's no longer checked. // Remove it from the toolbox. // foreach (ToolboxItem tbxItem in toolboxSvc.GetToolboxItems()) { if (tbxItem.Equals(item.Item)) { toolboxSvc.RemoveToolboxItem(tbxItem); } } } else { // Item was not initially checked, but it is now. // Add it to the toolbox. // toolboxSvc.AddToolboxItem(item.Item, currentCategory); } } // Now, update the item so it reflects reality. // item.InitiallyChecked = item.Checked; } }
// Adds a "Text" data format creator to the toolbox that creates // a textbox from a text fragment pasted to the toolbox. private void AddTextTextBoxCreator() { ts = (IToolboxService)GetService(typeof(IToolboxService)); if (ts != null) { ToolboxItemCreatorCallback textCreator = new ToolboxItemCreatorCallback(this.CreateTextBoxForText); try { ts.AddCreator( textCreator, "Text", (IDesignerHost)GetService(typeof(IDesignerHost))); creatorAdded = true; } catch (Exception ex) { MessageBox.Show( ex.ToString(), "Exception Information"); } } }
private void list_MouseDown(object sender, MouseEventArgs e) { ListBox lbSender = sender as ListBox; Rectangle lastSelectedBounds = lbSender.GetItemRectangle(this.selectedIndex); this.selectedIndex = lbSender.IndexFromPoint(e.X, e.Y); lbSender.SelectedIndex = this.selectedIndex; lbSender.Invalidate(lastSelectedBounds); lbSender.Invalidate(lbSender.GetItemRectangle(this.selectedIndex)); if (this.selectedIndex != 0) { if (e.Clicks == 2) { IToolboxUser tbu = this.host.GetDesigner(this.host.RootComponent) as IToolboxUser; if (tbu != null) { tbu.ToolPicked((ToolboxItem)lbSender.Items[this.selectedIndex]); } } else if (e.Clicks < 2) { ToolboxItem tbi = lbSender.Items[this.selectedIndex] as ToolboxItem; IToolboxService tbs = ((IServiceProvider)this.host).GetService(typeof(IToolboxService)) as IToolboxService; DataObject d = tbs.SerializeToolboxItem(tbi) as DataObject; try { lbSender.DoDragDrop(d, DragDropEffects.Copy); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); } } } }
// ToolPicked is called when the user double-clicks on a toolbox item. // The document designer should create a component for the specified tool. // Only tools that are enabled in the toolbox will be passed to this method. // // I create the component in the parent container of the primary selection. // If not available I create it in the rootcomponent (this essentially :-) ) // protected virtual void ToolPicked(ToolboxItem tool) { ISelectionService selectionSvc = GetService(typeof(ISelectionService)) as ISelectionService; IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; if (selectionSvc != null && host != null) { IDesigner designer = host.GetDesigner((IComponent)selectionSvc.PrimarySelection); if (designer is ParentControlDesigner) { ParentControlDesigner.InvokeCreateTool((ParentControlDesigner)designer, tool); } else { this.CreateTool(tool); } } else { this.CreateTool(tool); } IToolboxService tbServ = this.GetService(typeof(IToolboxService)) as IToolboxService; tbServ.SelectedToolboxItemUsed(); }
void report_DesignerLoaded(object sender, DesignerLoadedEventArgs e) { ToolboxItem item = new ToolboxItem(typeof(CustomControl)); IToolboxService ts = e.DesignerHost.GetService(typeof(IToolboxService)) as IToolboxService; ts.AddToolboxItem(item); }
public StartupPackage(IOutput output, IInspectorTool inspectorTool, IStatusBarDataModelService statusBarService, IToolboxService toolboxService) { _output = output; _inspectorTool = inspectorTool; _statusBarService = statusBarService; _toolboxService = toolboxService; }
private void list_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { try { ListBox lbSender = sender as ListBox; Rectangle lastSelectedBounds = lbSender.GetItemRectangle(0); try { lastSelectedBounds = lbSender.GetItemRectangle(selectedIndex); } catch (Exception ex) { ex.ToString(); } selectedIndex = lbSender.IndexFromPoint(e.X, e.Y); // change our selection lbSender.SelectedIndex = selectedIndex; lbSender.Invalidate(lastSelectedBounds); // clear highlight from last selection lbSender.Invalidate(lbSender.GetItemRectangle(selectedIndex)); // highlight new one if (selectedIndex != 0) { SelectItemChangedFunction((System.Drawing.Design.ToolboxItem)(lbSender.Items[selectedIndex])); if (e.Clicks == 2) { CreateToolboxItemFunction(); IDesignerHost idh = (IDesignerHost)this.DesignerHost.GetService(typeof(IDesignerHost)); IToolboxUser tbu = idh.GetDesigner(idh.RootComponent as IComponent) as IToolboxUser; if (tbu != null) { tbu.ToolPicked((System.Drawing.Design.ToolboxItem)(lbSender.Items[selectedIndex])); } } else if (e.Clicks < 2) { System.Drawing.Design.ToolboxItem tbi = lbSender.Items[selectedIndex] as System.Drawing.Design.ToolboxItem; IToolboxService tbs = this; // The IToolboxService serializes ToolboxItems by packaging them in DataObjects. DataObject d = tbs.SerializeToolboxItem(tbi) as DataObject; try { lbSender.DoDragDrop(d, DragDropEffects.Copy); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } catch (Exception ex) { ex.ToString(); } }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param> /// <param name="progress">A provider for progress updates.</param> /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns> protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { _tbxService = (IToolboxService)(await GetServiceAsync(typeof(IToolboxService))); IEnumerable <string> devexpressPaths = Directory.GetDirectories(@"C:\Windows\Microsoft.NET\assembly\GAC_MSIL") .Where(dir => Path.GetFileName(dir).StartsWith("DevExpress")) .ToArray(); foreach (var devexpressPath in devexpressPaths) { foreach (var file in GetDllPath(devexpressPath)) { Assembly assembly = Assembly.LoadFile(file); foreach (ToolboxItem item in ToolboxService.GetToolboxItems(assembly, null, false)) { _items.Add(item); } } } ; IEnumerable <string> GetDllPath(string path) { foreach (var dllPath in Directory.GetFiles(path).Where(f => Path.GetExtension(f) == ".dll")) { yield return(dllPath); } foreach (var childPath in Directory.GetDirectories(path)) { foreach (var dllPath in GetDllPath(childPath)) { yield return(dllPath); } } } //_items.Clear(); //foreach (var file in Directory.GetFiles(@"D:\Program Files (x86)\DevExpress 13.2\Components\Bin\Framework")) //{ // if (Path.GetExtension(file) == ".dll") // { // Assembly assembly = Assembly.LoadFile(file); // foreach (ToolboxItem item in ToolboxService.GetToolboxItems(assembly, null, false)) // { // //if (item.Filter.Cast<ToolboxItemFilterAttribute>().Any(f => f.FilterString.StartsWith("DevExpress"))) // //{ // _items.Add(item); // //} // } // } //} // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread. await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); }
///<summary>Load an assembly's controls</summary> public CustomComponentsSideTab(SideBarControl sideTab, string name, IToolboxService toolboxService) : base(sideTab, name, toolboxService) { this.DisplayName = StringParser.Parse(this.Name); ScanProjectAssemblies(); ProjectService.BuildFinished += RescanProjectAssemblies; ProjectService.SolutionLoaded += RescanProjectAssemblies; ProjectService.ProjectItemAdded += ProjectItemAdded; }
///// <summary> ///// 给出设计界面 ///// </summary> //public void Design() //{ // //初始化报表设计界面 // if (m_frm == null) // { // m_frm = new XRDesignForm(); // //m_frm.ShowInTaskbar = false; // m_frm.WindowState = FormWindowState.Maximized; // if (AUTOSAVE) // { // m_frm.ReportStateChanged += new ReportStateEventHandler(m_frm_ReportStateChanged); // m_frm.Closing += new System.ComponentModel.CancelEventHandler(m_frm_Closing); // } // m_frm.TextChanged += new EventHandler(m_frm_TextChanged); // } // m_frm.FileName = _fileName; // CurrentReport.DataSource = _ds; // if ((m_NewControls != null) && (m_NewControls.Count > 0)) // CurrentReport.DesignerLoaded += new DesignerLoadedEventHandler(CurrentReport_DesignerLoaded); // m_frm.OpenReport(_currentReport); // m_frm.ShowDialog(); //} private void CurrentReport_DesignerLoaded(object sender, DesignerLoadedEventArgs e) { IToolboxService ts = (IToolboxService)e.DesignerHost.GetService(typeof(IToolboxService)); foreach (Type type in m_NewControls) { ts.AddToolboxItem(new ToolboxItem(type)); } }
private void OnDesignerLoadComplete(object sender, EventArgs e) { IDesignerHost host = (IDesignerHost)sender; TypeDescriptor.AddAttributes(host.GetDesigner(host.RootComponent), new Attribute[] { new ToolboxItemFilterAttribute(MultiverseInterfaceStudioFilterName, ToolboxItemFilterType.Require) }); IToolboxService toolboxService = (IToolboxService)GetService(typeof(IToolboxService)); toolboxService.Refresh(); }
private void listBar1_MouseDown(object sender, MouseEventArgs e) { ListBarItem selected = thisMouseTrack.GetValue(listBar1) as ListBarItem; if (selected == null) { return; } else { deselectAll(); selected.Selected = true; selectedIndex = listBar1.SelectedGroup.Items.IndexOf(selected); //deselectAll(); } if (selectedIndex != 0) { // If this is a double-click, then the user wants to add the selected component // to the default location on the designer, with the default size. We call // ToolPicked on the current designer (as a IToolboxUser) to place the tool. // The IToolboxService calls SelectedToolboxItemUsed(), which calls this control's // SelectPointer() method. // if (e.Clicks == 2) { IToolboxUser tbu = host.GetDesigner(host.RootComponent) as IToolboxUser; if (tbu != null) { //tbu.ToolPicked((ToolboxItem)(lbSender.Items[selectedIndex])); tbu.ToolPicked((ToolboxItem)(listBar1.SelectedGroup.SelectedItem.Tag)); } SelectPointer(); } // Otherwise this is either a single click or a drag. Either way, we do the same // thing: start a drag--if this is just a single click, then the drag will // abort as soon as there's a MouseUp event. // else if (e.Clicks < 2) { //ToolboxItem tbi = lbSender.Items[selectedIndex] as ToolboxItem; ToolboxItem tbi = listBar1.SelectedGroup.SelectedItem.Tag as ToolboxItem; IToolboxService tbs = ((IServiceContainer)host).GetService(typeof(IToolboxService)) as IToolboxService; // The IToolboxService serializes ToolboxItems by packaging them in DataObjects. DataObject d = tbs.SerializeToolboxItem(tbi) as DataObject; try { (sender as Control).DoDragDrop(d, DragDropEffects.Copy); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void OnToolboxInitialized(object sender, EventArgs e) { AssemblyName assemblyName = AssemblyName.GetAssemblyName(String.Format("{0}\\{1}", Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf("\\")), "PackagesToLoad\\Microsoft.MultiverseInterfaceStudio.FrameXmlEditor.dll")); IToolboxService toolboxService = (IToolboxService)GetService(typeof(IToolboxService)); foreach (ToolboxItem item in ToolboxService.GetToolboxItems(assemblyName)) { toolboxService.AddToolboxItem(item, toolboxTabName); } }
private static void RemoveStandardItem(IToolboxService ts) { ToolboxItemCollection items = ts.GetToolboxItems(); ToolboxItem standardItem = items.OfType <ToolboxItem>().FirstOrDefault(x => x.DisplayName == "Label"); if (standardItem != null) { ts.RemoveToolboxItem(standardItem); } }
protected SideTabDesigner(SideBarControl sideBar, string name, IToolboxService toolboxService) : base(sideBar, name) { this.DisplayName = StringParser.Parse(name); this.toolboxService = toolboxService; this.CanSaved = false; AddDefaultItem(); this.ChosenItemChanged += SelectedTabItemChanged; }
/// <include file='doc\CompositionDesigner.uex' path='docs/doc[@for="ComponentDocumentDesigner.IToolboxUser.ToolPicked"]/*' /> /// <internalonly/> /// <devdoc> /// <para>Creates the specified tool.</para> /// </devdoc> void IToolboxUser.ToolPicked(ToolboxItem tool) { compositionUI.CreateComponentFromTool(tool); IToolboxService toolboxService = (IToolboxService)GetService(typeof(IToolboxService)); if (toolboxService != null) { toolboxService.SelectedToolboxItemUsed(); } }
private static void RemoveStandardItem(IToolboxService ts) { ToolboxItemCollection items = ts.GetToolboxItems(); ToolboxItem standardItem = items.OfType <ToolboxItem>().FirstOrDefault(x => String.Equals(x.DisplayName, "Chart")); if (standardItem != null) { ts.RemoveToolboxItem(standardItem); } }
/// <summary> /// Removes all the toolbox items installed by this package (those which came from this /// assembly). /// </summary> void RemoveToolboxItems() { Assembly a = typeof(PackageWinformsToolbox).Assembly; IToolboxService tbxService = (IToolboxService)GetService(typeof(IToolboxService)); foreach (ToolboxItem item in ToolboxService.GetToolboxItems(a, newCodeBase: null)) { tbxService.RemoveToolboxItem(item); } }
///<summary>Load an assembly's controls</summary> public SideTabDesigner(SideBarControl sideBar, Category category, IToolboxService toolboxService) : this(sideBar, category.Name, toolboxService) { foreach (ToolComponent component in category.ToolComponents) { if (component.IsEnabled) { ToolboxItem toolboxItem = new ToolboxItem(); toolboxItem.TypeName = component.FullName; toolboxItem.Bitmap = ToolboxProvider.ComponentLibraryLoader.GetIcon(component); toolboxItem.DisplayName = component.Name; Assembly asm = component.LoadAssembly(); toolboxItem.AssemblyName = asm.GetName(); this.Items.Add(new SideTabItemDesigner(toolboxItem)); } } }
public ToolboxViewModel(IShell shell, IToolboxService toolboxService) { DisplayName = "Toolbox"; _items = new BindableCollection<ToolboxItemViewModel>(); var groupedItems = CollectionViewSource.GetDefaultView(_items); groupedItems.GroupDescriptions.Add(new PropertyGroupDescription("Category")); _toolboxService = toolboxService; if (DesignerProperties.GetIsInDesignMode(new DependencyObject())) return; shell.ActiveDocumentChanged += (sender, e) => RefreshToolboxItems(shell); RefreshToolboxItems(shell); }
internal void SetCursor() { if (this.toolboxService == null) { this.toolboxService = (IToolboxService) this.GetService(typeof(IToolboxService)); } if ((this.toolboxService == null) || !this.toolboxService.SetCursor()) { base.OnSetCursor(); } }
/// <summary> /// Called by the framework when the designer is being initialized with the designed control /// </summary> /// <param name="component"></param> public override void Initialize(IComponent component) { base.Initialize(component); if (Control is TreeView) { try { m_oSelectionService = (ISelectionService) GetService(typeof (ISelectionService)); } catch { } try { m_oSelectionService.SelectionChanged += new EventHandler(this.OnSelectionServiceChanged); } catch { } try { m_oDesignerHost = (IDesignerHost) GetService(typeof (IDesignerHost)); } catch { } try { m_oMenuService = (IMenuCommandService) GetService(typeof (IMenuCommandService)); } catch { } try { m_oDesignerSerializationService = (IDesignerSerializationService) GetService(typeof (IDesignerSerializationService)); } catch { } try { m_oToolboxService = (IToolboxService) GetService(typeof (IToolboxService)); } catch { } try { m_oUIService = (IUIService) GetService(typeof (IUIService)); } catch { } try { m_oComponentChangeService = (IComponentChangeService) GetService(typeof (IComponentChangeService)); } catch { } m_oTreeView = (TreeView) Control; m_oTreeView.m_bFocus = true; m_oTreeView.ClearAllSelection(); m_oTreeView.DesignerHost = m_oDesignerHost; m_oTreeView.IsDesignMode = true; if (m_bFirstTime == true) { OnComponentCreated(m_oTreeView); m_bFirstTime = false; } try { m_oComponentAddedHandler = new ComponentEventHandler(this.OnComponentAdded); } catch { } try { m_oComponentRemovingHandler = new ComponentEventHandler(this.OnComponentRemoving); } catch { } try { m_oComponentChangeService.ComponentAdded += m_oComponentAddedHandler; } catch { } try { m_oComponentChangeService.ComponentRemoving += m_oComponentRemovingHandler; } catch { } try { m_oNodeParentChanged = new EventHandler(this.OnNodeParentChanged); } catch { } try { m_oOldCmdCopy = m_oMenuService.FindCommand(StandardCommands.Copy); } catch { } try { m_oOldCmdPaste = m_oMenuService.FindCommand(StandardCommands.Paste); } catch { } try { m_oOldCmdCut = m_oMenuService.FindCommand(StandardCommands.Cut); } catch { } try { m_oOldBringFront = m_oMenuService.FindCommand(StandardCommands.BringToFront); } catch { } try { m_oOldSendBack = m_oMenuService.FindCommand(StandardCommands.SendToBack); } catch { } try { m_oOldAlignGrid = m_oMenuService.FindCommand(StandardCommands.AlignToGrid); } catch { } try { m_oOldLockControls = m_oMenuService.FindCommand(StandardCommands.LockControls); } catch { } try { m_oOldDelete = m_oMenuService.FindCommand(StandardCommands.Delete); } catch { } try { m_oNewCmdCopy = new MenuCommand(new EventHandler(this.OnMenuCopy), StandardCommands.Copy); } catch { } try { m_oNewCmdPaste = new MenuCommand(new EventHandler(this.OnMenuPaste), StandardCommands.Paste); } catch { } if (TreeViewDesigner.MenuAdded == false) { try { m_oMenuService.RemoveCommand(m_oOldCmdCopy); } catch { } try { m_oMenuService.RemoveCommand(m_oOldCmdPaste); } catch { } try { m_oMenuService.AddCommand(m_oNewCmdCopy); } catch { } try { m_oMenuService.AddCommand(m_oNewCmdPaste); } catch { } TreeViewDesigner.MenuAdded = true; } m_oTreeView.Invalidate(); #region action menus #region node menu m_oActionMenuNode = new ActionMenuNative(); m_oActionMenuNode.Width = 170; m_oActionMenuNode.Title = "Node Action Menu"; ActionMenuGroup oMenuGroup = m_oActionMenuNode.AddMenuGroup("Editing"); oMenuGroup.Expanded = true; m_oActionMenuNode.AddMenuItem(oMenuGroup, "Add Node"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Delete Node"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Add Panel"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "-"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Clear Content"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Delete TreeView"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "-"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Copy"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Paste"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "-"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Properties"); oMenuGroup = m_oActionMenuNode.AddMenuGroup("Arranging"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Expand"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Collapse"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Top"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Bottom"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Up"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Down"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Left"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Right"); oMenuGroup = m_oActionMenuNode.AddMenuGroup("Color Schemes"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Default"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Forest"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Gold"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Ocean"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Rose"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Silver"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Sky"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Sunset"); m_oActionMenuNode.AddMenuItem(oMenuGroup, "Wood"); m_oActionMenuNode.ItemClick += new ActionMenuNative.ItemClickEventHandler(this.OnActionMenuNodeItemClicked); #endregion #region TreeView menu m_oActionMenuTreeView = new ActionMenuNative(); m_oActionMenuTreeView.Width = 170; m_oActionMenuTreeView.Title = "TreeView Action Menu"; oMenuGroup = m_oActionMenuTreeView.AddMenuGroup("Editing"); oMenuGroup.Expanded = true; m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Add Node"); m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Color Scheme Picker..."); m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "-"); m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Clear Content"); m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Delete TreeView"); m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "-"); m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Copy"); m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Paste"); m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "-"); m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Properties"); oMenuGroup = m_oActionMenuTreeView.AddMenuGroup("Arranging"); m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Expand All"); m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Collapse All"); oMenuGroup = m_oActionMenuTreeView.AddMenuGroup("Layout"); m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Bring to Front"); m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Send to Back"); m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Align to Grid"); m_oActionMenuTreeView.AddMenuItem(oMenuGroup, "Lock Controls"); m_oActionMenuTreeView.ItemClick += new ActionMenuNative.ItemClickEventHandler(this.OnActionMenuTreeViewItemClicked); #endregion #endregion // enable the drag drop operations m_oTreeView.AllowDrop = true; this.EnableDragDrop(true); m_oTreeView.CollapseAll(); m_oSelector.SelectionService = m_oSelectionService; m_oSelector.TreeView = m_oTreeView; } }
private void PopulateToolbox (IToolboxService toolbox) { toolbox.AddToolboxItem (new ToolboxItem (typeof (MyButton))); toolbox.AddToolboxItem (new ToolboxItem (typeof (MyPanel))); }
protected override void OnDragEnter(DragEventArgs de) { bool flag = false; DropSourceBehavior.BehaviorDataObject obj2 = null; DropSourceBehavior.BehaviorDataObject data = de.Data as DropSourceBehavior.BehaviorDataObject; if (data != null) { obj2 = data; obj2.Target = base.Component; de.Effect = (Control.ModifierKeys == Keys.Control) ? DragDropEffects.Copy : DragDropEffects.Move; flag = !data.Source.Equals(base.Component); } IMenuCommandService service = (IMenuCommandService) this.GetService(typeof(IMenuCommandService)); if (service != null) { MenuCommand command = service.FindCommand(StandardCommands.TabOrder); if ((command != null) && command.Checked) { de.Effect = DragDropEffects.None; return; } } object[] array = null; if ((obj2 != null) && (obj2.DragComponents != null)) { array = new object[obj2.DragComponents.Count]; obj2.DragComponents.CopyTo(array, 0); } else { array = this.GetOleDragHandler().GetDraggingObjects(de); } Control controlForComponent = null; IDesignerHost host = (IDesignerHost) this.GetService(typeof(IDesignerHost)); if (host != null) { DocumentDesigner designer = host.GetDesigner(host.RootComponent) as DocumentDesigner; if ((designer != null) && !designer.CanDropComponents(de)) { de.Effect = DragDropEffects.None; return; } } if (array != null) { if (data == null) { flag = true; } for (int i = 0; i < array.Length; i++) { IComponent component = array[i] as IComponent; if ((host != null) && (component != null)) { if (flag) { InheritanceAttribute attribute = (InheritanceAttribute) TypeDescriptor.GetAttributes(component)[typeof(InheritanceAttribute)]; if (((attribute != null) && !attribute.Equals(InheritanceAttribute.NotInherited)) && !attribute.Equals(InheritanceAttribute.InheritedReadOnly)) { de.Effect = DragDropEffects.None; return; } } if (host.GetDesigner(component) is IOleDragClient) { controlForComponent = ((IOleDragClient) this).GetControlForComponent(array[i]); } Control control2 = array[i] as Control; if ((controlForComponent == null) && (control2 != null)) { controlForComponent = control2; } if (controlForComponent != null) { if ((this.InheritanceAttribute == InheritanceAttribute.InheritedReadOnly) && (controlForComponent.Parent != this.Control)) { de.Effect = DragDropEffects.None; return; } if (!((IOleDragClient) this).IsDropOk(component)) { de.Effect = DragDropEffects.None; return; } } } } if (data == null) { this.PerformDragEnter(de, host); } } if (this.toolboxService == null) { this.toolboxService = (IToolboxService) this.GetService(typeof(IToolboxService)); } if ((this.toolboxService != null) && (array == null)) { this.mouseDragTool = this.toolboxService.DeserializeToolboxItem(de.Data, host); if (((this.mouseDragTool != null) && (base.BehaviorService != null)) && base.BehaviorService.UseSnapLines) { if (this.toolboxItemSnapLineBehavior == null) { this.toolboxItemSnapLineBehavior = new ToolboxItemSnapLineBehavior(base.Component.Site, base.BehaviorService, this, this.AllowGenericDragBox); } if (!this.toolboxItemSnapLineBehavior.IsPushed) { base.BehaviorService.PushBehavior(this.toolboxItemSnapLineBehavior); this.toolboxItemSnapLineBehavior.IsPushed = true; } } if (this.mouseDragTool != null) { this.PerformDragEnter(de, host); } if (this.toolboxItemSnapLineBehavior != null) { this.toolboxItemSnapLineBehavior.OnBeginDrag(); } } }
private void SetAppropriateCursor(Cursor cursor) { if (cursor == Cursors.Default) { if (this.toolboxSvc == null) { this.toolboxSvc = (IToolboxService) this.serviceProvider.GetService(typeof(IToolboxService)); } if ((this.toolboxSvc != null) && this.toolboxSvc.SetCursor()) { cursor = new Cursor(System.Design.NativeMethods.GetCursor()); } } this.adornerWindow.Cursor = cursor; }
protected virtual void OnSetCursor() { if (this.toolboxService == null) { this.toolboxService = (IToolboxService) this.GetService(typeof(IToolboxService)); } if ((this.toolboxService == null) || !this.toolboxService.SetCursor()) { Cursor.Current = Cursors.Default; } }
//**** //**** //**** IDisposable Implementation //**** //**** /// Disposes of the DesignContainer. This cleans up any objects we may be holding /// and removes any services that we created. public void Dispose() { // Dispose the loader before destroying the designer. Otherwise, the // act of destroying all the components on the designer surface will // be reflected in the loader, deleting the user's file. if (designerLoader != null) { try { designerLoader.Flush(); } catch (Exception e1) { Debug.Fail("Designer loader '" + designerLoader.GetType().Name + "' threw during Flush: " + e1.ToString()); e1 = null; } try { designerLoader.Dispose(); } catch (Exception e2) { Debug.Fail("Designer loader '" + designerLoader.GetType().Name + "' threw during Dispose: " + e2.ToString()); e2 = null; } designerLoader = null; } // Unload the document. UnloadDocument(); // No services after this! serviceContainer = null; // Now tear down all of our services. if (menuEditorService != null) { IDisposable d = menuEditorService as IDisposable; if (d != null) d.Dispose(); menuEditorService = null ; } if (selectionService != null) { IDisposable d = selectionService as IDisposable; if (d != null) d.Dispose(); selectionService = null; } if (menuCommandService != null) { IDisposable d = menuCommandService as IDisposable; if (d != null) d.Dispose(); menuCommandService = null; } if (toolboxService != null) { IDisposable d = toolboxService as IDisposable; if (d != null) d.Dispose(); toolboxService = null; } if (helpService != null) { IDisposable d = helpService as IDisposable; if (d != null) d.Dispose(); helpService = null; } if (referenceService != null) { IDisposable d = referenceService as IDisposable; if (d != null) d.Dispose(); referenceService = null; } // Destroy our document window. if (documentWindow != null) { documentWindow.Dispose(); documentWindow = null; } }
/// Creates some of the more infrequently used services private object OnCreateService(IServiceContainer container, Type serviceType) { // Create SelectionService if (serviceType == typeof(ISelectionService)) { if (selectionService == null) { selectionService = new SampleSelectionService(this); } return selectionService; } if (serviceType == typeof(ITypeDescriptorFilterService)) { return new SampleTypeDescriptorFilterService(this); } if (serviceType == typeof(IToolboxService)) { if (toolboxService == null) { toolboxService = new SampleToolboxService(this); } return toolboxService; } if (serviceType == typeof(IMenuCommandService)) { if (menuCommandService == null) { menuCommandService = new SampleMenuCommandService(this); } return menuCommandService; } // UNIMPLEMENTED // if (serviceType == typeof(IHelpService)) { // if (helpService == null) { // helpService = new SampleHelpService(this); // } // return helpService; // } // // if (serviceType == typeof(IReferenceService)) { // if (referenceService == null) { // referenceService = new SampleReferenceService(this, true); // } // return referenceService; // } // // if (serviceType == typeof(IPropertyValueUIService)) { // return new SamplePropertyValueUIService(); // } // // if (serviceType == typeof(IMenuEditorService)) { // if (menuEditorService == null) { // menuEditorService = new SampleMenuEditorService(this); // } // return menuEditorService; // } if (serviceType == typeof(IDesignerSerializationService)) { if (serializationService == null) { serializationService = new SampleDesignerSerializationService(this); } return serializationService; } Debug.Fail("Service type " + serviceType.FullName + " requested but we don't support it"); return null; }
protected override void OnDragEnter(DragEventArgs de) { if (!this.TabOrderActive) { base.SuspendLayout(); if (this.toolboxService == null) { this.toolboxService = (IToolboxService) this.GetService(typeof(IToolboxService)); } OleDragDropHandler oleDragHandler = this.GetOleDragHandler(); object[] draggingObjects = oleDragHandler.GetDraggingObjects(de); if ((this.toolboxService != null) && (draggingObjects == null)) { this.mouseDragTool = this.toolboxService.DeserializeToolboxItem(de.Data, (IDesignerHost) this.GetService(typeof(IDesignerHost))); } if (this.mouseDragTool != null) { if ((de.AllowedEffect & DragDropEffects.Move) != DragDropEffects.None) { de.Effect = DragDropEffects.Move; } else { de.Effect = DragDropEffects.Copy; } } else { oleDragHandler.DoOleDragEnter(de); } } }
protected override void OnMouseDragBegin(int x, int y) { Control control = this.Control; if (!this.InheritanceAttribute.Equals(InheritanceAttribute.InheritedReadOnly)) { if (this.toolboxService == null) { this.toolboxService = (IToolboxService) this.GetService(typeof(IToolboxService)); } if (this.toolboxService != null) { this.mouseDragTool = this.toolboxService.GetSelectedToolboxItem((IDesignerHost) this.GetService(typeof(IDesignerHost))); } } control.Capture = true; System.Design.NativeMethods.RECT rect = new System.Design.NativeMethods.RECT(); System.Design.NativeMethods.GetWindowRect(control.Handle, ref rect); Rectangle.FromLTRB(rect.left, rect.top, rect.right, rect.bottom); this.mouseDragFrame = (this.mouseDragTool == null) ? FrameStyle.Dashed : FrameStyle.Thick; this.mouseDragBase = new Point(x, y); ISelectionService service = (ISelectionService) this.GetService(typeof(ISelectionService)); if (service != null) { service.SetSelectedComponents(new object[] { base.Component }, SelectionTypes.Click); } IEventHandlerService service2 = (IEventHandlerService) this.GetService(typeof(IEventHandlerService)); if ((service2 != null) && (this.escapeHandler == null)) { this.escapeHandler = new EscapeHandler(this); service2.PushHandler(this.escapeHandler); } this.adornerWindowToScreenOffset = base.BehaviorService.AdornerWindowToScreen(); }
protected virtual void OnSetCursor() { if (this.Control.Dock != DockStyle.None) { Cursor.Current = Cursors.Default; } else { if (this.toolboxSvc == null) { this.toolboxSvc = (IToolboxService) this.GetService(typeof(IToolboxService)); } if ((this.toolboxSvc == null) || !this.toolboxSvc.SetCursor()) { if (!this.locationChecked) { this.locationChecked = true; try { this.hasLocation = TypeDescriptor.GetProperties(base.Component)["Location"] != null; } catch { } } if (!this.hasLocation) { Cursor.Current = Cursors.Default; } else if (this.Locked) { Cursor.Current = Cursors.Default; } else { Cursor.Current = Cursors.SizeAll; } } } }
protected virtual void WndProc(ref Message m) { IMouseHandler handler = null; if ((m.Msg == 0x84) && !this.inHitTest) { this.inHitTest = true; Point point = new Point((short) System.Design.NativeMethods.Util.LOWORD((int) ((long) m.LParam)), (short) System.Design.NativeMethods.Util.HIWORD((int) ((long) m.LParam))); try { this.liveRegion = this.GetHitTest(point); } catch (Exception exception) { this.liveRegion = false; if (System.Windows.Forms.ClientUtils.IsCriticalException(exception)) { throw; } } this.inHitTest = false; } bool flag = m.Msg == 0x7b; if (this.liveRegion && (this.IsMouseMessage(m.Msg) || flag)) { if (m.Msg == 0x7b) { inContextMenu = true; } try { this.DefWndProc(ref m); } finally { if (m.Msg == 0x7b) { inContextMenu = false; } if (m.Msg == 0x202) { this.OnMouseDragEnd(true); } } return; } int x = 0; int y = 0; if ((((m.Msg >= 0x200) && (m.Msg <= 0x20a)) || ((m.Msg >= 160) && (m.Msg <= 0xa9))) || (m.Msg == 0x20)) { if (this.eventSvc == null) { this.eventSvc = (IEventHandlerService) this.GetService(typeof(IEventHandlerService)); } if (this.eventSvc != null) { handler = (IMouseHandler) this.eventSvc.GetHandler(typeof(IMouseHandler)); } } if ((m.Msg >= 0x200) && (m.Msg <= 0x20a)) { System.Design.NativeMethods.POINT pt = new System.Design.NativeMethods.POINT { x = System.Design.NativeMethods.Util.SignedLOWORD((int) ((long) m.LParam)), y = System.Design.NativeMethods.Util.SignedHIWORD((int) ((long) m.LParam)) }; System.Design.NativeMethods.MapWindowPoints(m.HWnd, IntPtr.Zero, pt, 1); x = pt.x; y = pt.y; } else if ((m.Msg >= 160) && (m.Msg <= 0xa9)) { x = System.Design.NativeMethods.Util.SignedLOWORD((int) ((long) m.LParam)); y = System.Design.NativeMethods.Util.SignedHIWORD((int) ((long) m.LParam)); } MouseButtons none = MouseButtons.None; switch (m.Msg) { case 0x1f: this.OnMouseDragEnd(true); this.DefWndProc(ref m); return; case 0x20: goto Label_0A82; case 0x3d: if (-4 == ((int) ((long) m.LParam))) { Guid refiid = new Guid("{618736E0-3C3D-11CF-810C-00AA00389B71}"); try { IAccessible accessibilityObject = this.AccessibilityObject; if (accessibilityObject == null) { m.Result = IntPtr.Zero; } else { IntPtr iUnknownForObject = Marshal.GetIUnknownForObject(accessibilityObject); try { m.Result = System.Design.UnsafeNativeMethods.LresultFromObject(ref refiid, m.WParam, iUnknownForObject); } finally { Marshal.Release(iUnknownForObject); } } return; } catch (Exception exception2) { throw exception2; } } this.DefWndProc(ref m); return; case 15: if (OleDragDropHandler.FreezePainting) { System.Design.NativeMethods.ValidateRect(m.HWnd, IntPtr.Zero); return; } if (this.Control != null) { System.Design.NativeMethods.RECT rc = new System.Design.NativeMethods.RECT(); IntPtr hrgn = System.Design.NativeMethods.CreateRectRgn(0, 0, 0, 0); System.Design.NativeMethods.GetUpdateRgn(m.HWnd, hrgn, false); System.Design.NativeMethods.GetUpdateRect(m.HWnd, ref rc, false); Region region = Region.FromHrgn(hrgn); Rectangle empty = Rectangle.Empty; try { if (this.thrownException == null) { this.DefWndProc(ref m); } using (Graphics graphics2 = Graphics.FromHwnd(m.HWnd)) { if (m.HWnd != this.Control.Handle) { System.Design.NativeMethods.POINT point3 = new System.Design.NativeMethods.POINT { x = 0, y = 0 }; System.Design.NativeMethods.MapWindowPoints(m.HWnd, this.Control.Handle, point3, 1); graphics2.TranslateTransform((float) -point3.x, (float) -point3.y); System.Design.NativeMethods.MapWindowPoints(m.HWnd, this.Control.Handle, ref rc, 2); } empty = new Rectangle(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top); using (PaintEventArgs args2 = new PaintEventArgs(graphics2, empty)) { graphics2.Clip = region; if (this.thrownException == null) { this.OnPaintAdornments(args2); } else { System.Design.UnsafeNativeMethods.PAINTSTRUCT lpPaint = new System.Design.UnsafeNativeMethods.PAINTSTRUCT(); System.Design.UnsafeNativeMethods.BeginPaint(m.HWnd, ref lpPaint); this.PaintException(args2, this.thrownException); System.Design.UnsafeNativeMethods.EndPaint(m.HWnd, ref lpPaint); } } } } finally { region.Dispose(); System.Design.NativeMethods.DeleteObject(hrgn); } if (this.OverlayService == null) { return; } empty.Location = this.Control.PointToScreen(empty.Location); this.OverlayService.InvalidateOverlays(empty); } return; case 5: if (this.thrownException != null) { this.Control.Invalidate(); } this.DefWndProc(ref m); return; case 7: if ((this.host != null) && (this.host.RootComponent != null)) { IRootDesigner designer = this.host.GetDesigner(this.host.RootComponent) as IRootDesigner; if (designer == null) { return; } ViewTechnology[] supportedTechnologies = designer.SupportedTechnologies; if (supportedTechnologies.Length <= 0) { return; } System.Windows.Forms.Control view = designer.GetView(supportedTechnologies[0]) as System.Windows.Forms.Control; if (view == null) { return; } view.Focus(); } return; case 1: this.DefWndProc(ref m); if (m.HWnd == this.Control.Handle) { this.OnCreateHandle(); } return; case 0x85: case 0x86: if (m.Msg != 0x86) { if (this.thrownException == null) { this.DefWndProc(ref m); } break; } this.DefWndProc(ref m); break; case 0x7b: if (!inContextMenu) { x = System.Design.NativeMethods.Util.SignedLOWORD((int) ((long) m.LParam)); y = System.Design.NativeMethods.Util.SignedHIWORD((int) ((long) m.LParam)); ToolStripKeyboardHandlingService service2 = (ToolStripKeyboardHandlingService) this.GetService(typeof(ToolStripKeyboardHandlingService)); bool flag2 = false; if (service2 != null) { flag2 = service2.OnContextMenu(x, y); } if (flag2) { return; } if ((x == -1) && (y == -1)) { Point position = Cursor.Position; x = position.X; y = position.Y; } this.OnContextMenu(x, y); } return; case 160: case 0x200: if ((((int) ((long) m.WParam)) & 1) != 0) { none = MouseButtons.Left; } else if ((((int) ((long) m.WParam)) & 2) != 0) { none = MouseButtons.Right; this.toolPassThrough = false; } else { this.toolPassThrough = false; } if ((this.lastMoveScreenX != x) || (this.lastMoveScreenY != y)) { if (this.toolPassThrough) { System.Design.NativeMethods.SendMessage(this.Control.Parent.Handle, m.Msg, m.WParam, (IntPtr) this.GetParentPointFromLparam(m.LParam)); return; } if (handler != null) { handler.OnMouseMove(base.Component, x, y); } else if (none == MouseButtons.Left) { this.OnMouseDragMove(x, y); } } this.lastMoveScreenX = x; this.lastMoveScreenY = y; if (m.Msg == 0x200) { this.BaseWndProc(ref m); } return; case 0xa1: case 0xa4: case 0x201: case 0x204: if ((m.Msg == 0xa4) || (m.Msg == 0x204)) { none = MouseButtons.Right; } else { none = MouseButtons.Left; } System.Design.NativeMethods.SendMessage(this.Control.Handle, 7, 0, 0); if ((none == MouseButtons.Left) && this.IsDoubleClick(x, y)) { if (handler != null) { handler.OnMouseDoubleClick(base.Component); return; } this.OnMouseDoubleClick(); return; } this.toolPassThrough = false; if (!this.EnableDragRect && (none == MouseButtons.Left)) { if (this.toolboxSvc == null) { this.toolboxSvc = (IToolboxService) this.GetService(typeof(IToolboxService)); } if ((this.toolboxSvc != null) && (this.toolboxSvc.GetSelectedToolboxItem((IDesignerHost) this.GetService(typeof(IDesignerHost))) != null)) { this.toolPassThrough = true; } } else { this.toolPassThrough = false; } if (this.toolPassThrough) { System.Design.NativeMethods.SendMessage(this.Control.Parent.Handle, m.Msg, m.WParam, (IntPtr) this.GetParentPointFromLparam(m.LParam)); return; } if (handler != null) { handler.OnMouseDown(base.Component, none, x, y); } else if (none == MouseButtons.Left) { this.OnMouseDragBegin(x, y); } else if (none == MouseButtons.Right) { ISelectionService service = (ISelectionService) this.GetService(typeof(ISelectionService)); if (service != null) { service.SetSelectedComponents(new object[] { base.Component }, SelectionTypes.Click); } } this.lastMoveScreenX = x; this.lastMoveScreenY = y; return; case 0xa2: case 0xa5: case 0x202: case 0x205: if ((m.Msg == 0xa5) || (m.Msg == 0x205)) { none = MouseButtons.Right; } else { none = MouseButtons.Left; } if (handler != null) { handler.OnMouseUp(base.Component, none); } else { if (this.toolPassThrough) { System.Design.NativeMethods.SendMessage(this.Control.Parent.Handle, m.Msg, m.WParam, (IntPtr) this.GetParentPointFromLparam(m.LParam)); this.toolPassThrough = false; return; } if (none == MouseButtons.Left) { this.OnMouseDragEnd(false); } } this.toolPassThrough = false; this.BaseWndProc(ref m); return; case 0xa3: case 0xa6: case 0x203: case 0x206: if ((m.Msg == 0xa6) || (m.Msg == 0x206)) { none = MouseButtons.Right; } else { none = MouseButtons.Left; } if (none == MouseButtons.Left) { if (handler != null) { handler.OnMouseDoubleClick(base.Component); return; } this.OnMouseDoubleClick(); } return; case 0xa7: case 0xa8: case 0xa9: case 0x207: case 520: case 0x209: case 0x20a: case 0x2a0: case 0x2a2: return; case 0x2a1: if (handler == null) { this.OnMouseHover(); return; } handler.OnMouseHover(base.Component); return; case 0x2a3: this.OnMouseLeave(); this.BaseWndProc(ref m); return; case 0x318: { using (Graphics graphics = Graphics.FromHdc(m.WParam)) { using (PaintEventArgs args = new PaintEventArgs(graphics, this.Control.ClientRectangle)) { this.DefWndProc(ref m); this.OnPaintAdornments(args); } return; } } default: if (m.Msg == System.Design.NativeMethods.WM_MOUSEENTER) { this.OnMouseEnter(); this.BaseWndProc(ref m); } else if ((m.Msg < 0x100) || (m.Msg > 0x108)) { this.DefWndProc(ref m); } return; } if (((this.OverlayService == null) || (this.Control == null)) || (!(this.Control.Size != this.Control.ClientSize) || (this.Control.Parent == null))) { return; } Rectangle rectangle2 = new Rectangle(this.Control.Parent.PointToScreen(this.Control.Location), this.Control.Size); Rectangle rectangle3 = new Rectangle(this.Control.PointToScreen(Point.Empty), this.Control.ClientSize); using (Region region2 = new Region(rectangle2)) { region2.Exclude(rectangle3); this.OverlayService.InvalidateOverlays(region2); return; } Label_0A82: if (this.liveRegion) { this.DefWndProc(ref m); } else if (handler != null) { handler.OnSetCursor(base.Component); } else { this.OnSetCursor(); } }
public void Dispose() { IDisposable d; if (this.designerLoader != null) { try { this.designerLoader.Flush(); } catch (Exception e1) { Debug.Fail("Designer loader '" + this.designerLoader.GetType().Name + "' threw during Flush: " + e1.ToString()); e1 = null; } try { this.designerLoader.Dispose(); } catch (Exception e2) { Debug.Fail("Designer loader '" + this.designerLoader.GetType().Name + "' threw during Dispose: " + e2.ToString()); e2 = null; } this.designerLoader = null; } this.UnloadDocument(); this.serviceContainer = null; if (this.menuEditorService != null) { d = this.menuEditorService as IDisposable; if (d != null) { d.Dispose(); } this.menuEditorService = null; } if (this.selectionService != null) { d = this.selectionService as IDisposable; if (d != null) { d.Dispose(); } this.selectionService = null; } if (this.menuCommandService != null) { d = this.menuCommandService as IDisposable; if (d != null) { d.Dispose(); } this.menuCommandService = null; } if (this.toolboxService != null) { d = this.toolboxService as IDisposable; if (d != null) { d.Dispose(); } this.toolboxService = null; } if (this.helpService != null) { d = this.helpService as IDisposable; if (d != null) { d.Dispose(); } this.helpService = null; } if (this.referenceService != null) { d = this.referenceService as IDisposable; if (d != null) { d.Dispose(); } this.referenceService = null; } if (this.documentWindow != null) { this.documentWindow.Dispose(); this.documentWindow = null; } }
private void PopulateToolbox(IToolboxService toolbox) { toolbox.AddToolboxItem(new ToolboxItem(typeof(Button))); toolbox.AddToolboxItem(new ToolboxItem(typeof(ListView))); toolbox.AddToolboxItem(new ToolboxItem(typeof(TreeView))); toolbox.AddToolboxItem(new ToolboxItem(typeof(TextBox))); toolbox.AddToolboxItem(new ToolboxItem(typeof(Label))); toolbox.AddToolboxItem(new ToolboxItem(typeof(TabControl))); toolbox.AddToolboxItem(new ToolboxItem(typeof(OpenFileDialog))); toolbox.AddToolboxItem(new ToolboxItem(typeof(CheckBox))); toolbox.AddToolboxItem(new ToolboxItem(typeof(ComboBox))); toolbox.AddToolboxItem(new ToolboxItem(typeof(GroupBox))); toolbox.AddToolboxItem(new ToolboxItem(typeof(ImageList))); toolbox.AddToolboxItem(new ToolboxItem(typeof(Panel))); toolbox.AddToolboxItem(new ToolboxItem(typeof(ProgressBar))); toolbox.AddToolboxItem(new ToolboxItem(typeof(ToolBar))); toolbox.AddToolboxItem(new ToolboxItem(typeof(ToolTip))); toolbox.AddToolboxItem(new ToolboxItem(typeof(StatusBar))); }
protected override void OnMouseDown(MouseEventArgs e) { if ((this.glyphManager == null) || !this.glyphManager.OnMouseDown(e)) { base.OnMouseDown(e); if (!this.TabOrderActive) { if (this.toolboxService == null) { this.toolboxService = (IToolboxService) this.GetService(typeof(IToolboxService)); } this.FocusDesigner(); if ((e.Button == MouseButtons.Left) && (this.toolboxService != null)) { ToolboxItem selectedToolboxItem = this.toolboxService.GetSelectedToolboxItem((IDesignerHost) this.GetService(typeof(IDesignerHost))); if (selectedToolboxItem != null) { this.mouseDropLocation = new Point(e.X, e.Y); try { this.CreateComponentFromTool(selectedToolboxItem); this.toolboxService.SelectedToolboxItemUsed(); } catch (Exception exception) { this.DisplayError(exception); if (System.Windows.Forms.ClientUtils.IsCriticalException(exception)) { throw; } } this.mouseDropLocation = InvalidPoint; return; } } if (e.Button == MouseButtons.Left) { this.mouseDragStart = new Point(e.X, e.Y); base.Capture = true; Cursor.Clip = base.RectangleToScreen(base.ClientRectangle); } else { try { ISelectionService service = (ISelectionService) this.GetService(typeof(ISelectionService)); bool enabled = System.ComponentModel.CompModSwitches.CommonDesignerServices.Enabled; if (service != null) { service.SetSelectedComponents(new object[] { this.mainDesigner.Component }); } } catch (Exception exception2) { if (System.Windows.Forms.ClientUtils.IsCriticalException(exception2)) { throw; } } } } } }
protected override void OnSetCursor() { if (this.toolboxService == null) { this.toolboxService = (IToolboxService) this.GetService(typeof(IToolboxService)); } if (((this.toolboxService == null) || !this.toolboxService.SetCursor()) || this.InheritanceAttribute.Equals(System.ComponentModel.InheritanceAttribute.InheritedReadOnly)) { Cursor.Current = Cursors.Default; } }
private object OnCreateService(IServiceContainer container, System.Type serviceType) { if (serviceType == typeof(ISelectionService)) { if (this.selectionService == null) { this.selectionService = new SampleSelectionService(this); } return this.selectionService; } if (serviceType == typeof(IDesignerSerializationService)) { if (this.designerSerialService == null) { this.designerSerialService = new DesignerSerializationService(this); } return this.designerSerialService; } if (serviceType == typeof(ITypeDescriptorFilterService)) { return new SampleTypeDescriptorFilterService(this); } if (serviceType == typeof(IToolboxService)) { if (this.toolboxService == null) { this.toolboxService = new SampleToolboxService(this); } return this.toolboxService; } if (serviceType == typeof(IMenuCommandService)) { if (this.menuCommandService == null) { this.menuCommandService = new SampleMenuCommandService(this); } return this.menuCommandService; } Debug.Fail("Service type " + serviceType.FullName + " requested but we don't support it"); return null; }
SetupDialogControlsSideTab(SideBarControl sideBar, Category category, IToolboxService toolboxService) : base(sideBar, category, toolboxService) { }
private void OnRefreshToolbox(object sender, EventArgs e) { toolboxService = (IToolboxService)GetService(typeof(IToolboxService)); IVsToolbox vsToolbox = GetService(typeof(IVsToolbox)) as IVsToolbox; if (toolboxService == null || vsToolbox == null) { return; } PetriNetEditorToolboxProvider toolboxProvider = new PetriNetEditorToolboxProvider(); var itemList = toolboxProvider.GetToolboxItemList(); if (itemList == null || itemList.Count == 0) { return; } string toolboxCategoryName = PetriNetEditorToolboxProvider.ToolboxCategoryName; //Remove target tab and all controls under it. foreach (ToolboxItem oldItem in toolboxService.GetToolboxItems(toolboxCategoryName)) { toolboxService.RemoveToolboxItem(oldItem); } vsToolbox.RemoveTab(PetriNetEditorToolboxProvider.ToolboxCategoryName); foreach (ToolboxItem item in itemList) { toolboxService.AddToolboxItem(item, toolboxCategoryName); } toolboxService.SelectedCategory = toolboxCategoryName; toolboxService.Refresh(); }