Exemplo n.º 1
0
        /// <include file='doc\DesignerPackage.uex' path='docs/doc[@for="DesignerPackage.ResetDefaults"]/*' />
        /// <devdoc>
        ///     Resets the default tools on the toolbox for this package.
        /// </devdoc>
        public override void ResetDefaults(int pkgFlags)
        {
            ToolboxService ts = GetService(typeof(IToolboxService)) as ToolboxService;

            Debug.Assert(ts != null || !CompModSwitches.CommonDesignerServices.Enabled, "ToolboxService not found");

            switch (pkgFlags)
            {
            case __PKGRESETFLAGS.PKGRF_TOOLBOXITEMS:
                // this instructs the toolbox to add the default items

                if (ts != null)
                {
                    ts.ResetDefaultToolboxItems();
                }
                break;

            case __PKGRESETFLAGS.PKGRF_TOOLBOXSETUP:
                // this instructs the toolbox to update out of date items

                if (ts != null)
                {
                    ts.UpgradeToolboxItems();
                }
                break;
            }
        }
        private static ToolboxItem GetCachedToolboxItem(System.Type itemType)
        {
            ToolboxItem toolboxItem = null;

            if (CachedToolboxItems == null)
            {
                CachedToolboxItems = new Dictionary <System.Type, ToolboxItem>();
            }
            else if (CachedToolboxItems.ContainsKey(itemType))
            {
                return(CachedToolboxItems[itemType]);
            }
            if (toolboxItem == null)
            {
                toolboxItem = ToolboxService.GetToolboxItem(itemType);
                if (toolboxItem == null)
                {
                    toolboxItem = new ToolboxItem(itemType);
                }
            }
            CachedToolboxItems[itemType] = toolboxItem;
            if ((CustomToolStripItemCount > 0) && ((CustomToolStripItemCount * 2) < CachedToolboxItems.Count))
            {
                CachedToolboxItems.Clear();
            }
            return(toolboxItem);
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
        /// <include file='doc\DesignerPackage.uex' path='docs/doc[@for="DesignerPackage.OnCreateService"]/*' />
        /// <devdoc>
        ///     Demand creates the requested service.
        /// </devdoc>
        private object OnCreateService(IServiceContainer container, Type serviceType)
        {
            if (serviceType == typeof(IVSMDPropertyBrowser))
            {
                return(new PropertyBrowserService());
            }
            if (serviceType == typeof(IToolboxService))
            {
                if (toolboxService == null)
                {
                    toolboxService = new ToolboxService();
                }
                return(toolboxService);
            }
            if (serviceType == typeof(IVSMDDesignerService))
            {
                return(new DesignerService());
            }
            if (serviceType == typeof(DocumentManager) || serviceType == typeof(IDesignerEventService))
            {
                if (documentManager == null)
                {
                    documentManager = new ShellDocumentManager(this);
                }
                return(documentManager);
            }
            if (serviceType == typeof(ITypeResolutionServiceProvider))
            {
                if (typeLoaderService == null)
                {
                    typeLoaderService = new ShellTypeLoaderService(this);
                }
                return(typeLoaderService);
            }
            if (serviceType == typeof(ILicenseManagerService))
            {
                if (licenseManagerService == null)
                {
                    licenseManagerService = new ShellLicenseManagerService(this);
                }
                return(licenseManagerService);
            }
            if (serviceType == typeof(IAssemblyEnumerationService))
            {
                return(new AssemblyEnumerationService(this));
            }

            if (serviceType == typeof(IHelpService))
            {
                return(new HelpService(this));
            }

            Debug.Fail("Container requested a service we didn't say we could provide");
            return(null);
        }
Exemplo n.º 5
0
        public void SetToolBox(ToolboxService toolboxService)
        {
            if (toolboxService == _lastToolboxService)
                return;

            toolBoxTreeView.Nodes.Clear();
            if (toolBoxTreeView.ImageList != null)
            {
                toolBoxTreeView.ImageList.Dispose();
            }

            toolBoxTreeView.ImageList = new ImageList()
            {
                ColorDepth = ColorDepth.Depth32Bit,
                ImageSize = new Size(16,16),
            };

            toolBoxTreeView.ImageList.Images.Add(_folderImage);
            toolBoxTreeView.ImageList.Images.Add(_pointer);

            if (toolboxService != null)
            {
                toolboxService.SelectedItemChanged += toolboxService_SelectedItemChanged;

                foreach (string category in toolboxService.CategoryNames)
                {
                    TreeNode rootNode = new TreeNode(category);
                    rootNode.Nodes.Add(new TreeNode("Pointer") { ImageIndex = 1, SelectedImageIndex = 1 });

                    foreach (ToolboxItem item in toolboxService.GetToolboxItems(category))
                    {
                        toolBoxTreeView.ImageList.Images.Add(item.Bitmap);
                        rootNode.Nodes.Add(new TreeNode(item.DisplayName)
                        {
                            ToolTipText = string.Format("{0}\r\n{1} v{2}\r\n\r\n{3}", item.TypeName, item.AssemblyName, item.Version, item.Description),
                            Tag = item,
                            ImageIndex = toolBoxTreeView.ImageList.Images.Count - 1,
                            SelectedImageIndex = toolBoxTreeView.ImageList.Images.Count - 1,
                        });
                    }

                    toolBoxTreeView.Nodes.Add(rootNode);
                    if (category == toolboxService.SelectedCategory)
                        rootNode.Expand();
                }

                label1.Visible = toolBoxTreeView.Nodes.Count == 0;
            }
            else
            {
                label1.Visible = true;
            }

            _lastToolboxService = toolboxService;
        }
Exemplo n.º 6
0
        public FormToolBox(ToolboxService toolboxService)
        {
            InitializeComponent();

            Icon               = global::QueryDesigner.Properties.Resources.Tool;
            ToolboxList        = new Hashtable();
            _toolboxService    = toolboxService;
            CloseButtonVisible = false;
            ReloadSideTabs();
            _toolboxService.SelectedItemUsed += new EventHandler(_toolboxService_SelectedItemUsed);
        }
        /// <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);
            }
        }
Exemplo n.º 8
0
        /// <include file='doc\DesignerPackage.uex' path='docs/doc[@for="DesignerPackage.Close"]/*' />
        /// <devdoc>
        ///     Overrides Close to clean up our editor factory.
        /// </devdoc>
        public override void Close()
        {
            SystemEvents.DisplaySettingsChanged -= new EventHandler(this.OnSystemSettingChanged);
            SystemEvents.InstalledFontsChanged  -= new EventHandler(this.OnSystemSettingChanged);
            SystemEvents.UserPreferenceChanged  -= new UserPreferenceChangedEventHandler(this.OnUserPreferenceChanged);

            if (editorFactory != null)
            {
                try {
                    editorFactory.Dispose();
                }
                catch (Exception e) {
                    Debug.Fail(e.ToString());
                }
                editorFactory = null;
            }

            if (documentManager != null)
            {
                documentManager.Dispose();
                documentManager = null;
            }

            if (typeLoaderService != null)
            {
                typeLoaderService.Dispose();
                typeLoaderService = null;
            }

            if (licenseManagerService != null)
            {
                licenseManagerService.Dispose();
                licenseManagerService = null;
            }

            if (toolboxService != null)
            {
                toolboxService.Dispose();
                toolboxService = null;
            }

            #if PERFEVENTS
            if (performanceEvent != IntPtr.Zero)
            {
                NativeMethods.CloseHandle(performanceEvent);
                performanceEvent = IntPtr.Zero;
            }
            #endif

            base.Close();
        }
        //</Snippet10>

        /////////////////////////////////////////////////////////////////////////////
        // Overriden Package Implementation

        // ...
        protected override void Initialize()
        {
            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture,
                                          "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            // Add our command handlers for menu (commands must exist in the .vsct file)
            OleMenuCommandService mcs =
                GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (null != mcs)
            {
                // Create the command for the menu item.
                CommandID menuCommandID = new CommandID(
                    GuidList.guidItemConfigurationCmdSet,
                    (int)PkgCmdIDList.cmdidMyCommand);
                MenuCommand menuItem = new MenuCommand(MenuItemCallback, menuCommandID);
                mcs.AddCommand(menuItem);
            }

            //<Snippet12>
            // Use the toolbox service to get a list of all toolbox items in
            // this assembly.
            ToolboxItemList = new ArrayList(
                ToolboxService.GetToolboxItems(this.GetType().Assembly, ""));
            if (null == ToolboxItemList)
            {
                throw new ApplicationException(
                          "Unable to generate a toolbox item listing for " +
                          this.GetType().FullName);
            }

            // Update the display name of each toolbox item in the list.
            Assembly thisAssembly = this.GetType().Assembly;

            foreach (ToolboxItem item in ToolboxItemList)
            {
                Type underlyingType         = thisAssembly.GetType(item.TypeName);
                AttributeCollection attribs =
                    TypeDescriptor.GetAttributes(underlyingType);
                DisplayNameAttribute displayName =
                    attribs[typeof(DisplayNameAttribute)] as DisplayNameAttribute;
                if (displayName != null && !displayName.IsDefaultAttribute())
                {
                    item.DisplayName = displayName.DisplayName;
                }
            }
            //</Snippet12>
        }
        /// <summary>
        /// Installs all the toolbox items defined in this assembly.
        /// </summary>
        void InstallToolboxItems()
        {
            // For demonstration purposes, this assembly includes toolbox items and loads them from itself.
            // It is of course possible to load toolbox items from a different assembly by either:
            // a)  loading the assembly yourself and calling ToolboxService.GetToolboxItems
            // b)  calling AssemblyName.GetAssemblyName("...") and then ToolboxService.GetToolboxItems(assemblyName)
            Assembly a = typeof(PackageWinformsToolbox).Assembly;

            IToolboxService tbxService = (IToolboxService)GetService(typeof(IToolboxService));

            foreach (ToolboxItem item in ToolboxService.GetToolboxItems(a, newCodeBase: null))
            {
                // This tab name can be whatever you would like it to be.
                tbxService.AddToolboxItem(item, "MyOwnTab");
            }
        }
Exemplo n.º 11
0
        private void UpgradeToolBoxItems()
        {
            var tbxService = (IToolboxService)GetService(typeof(IToolboxService));

            ModifyToolboxItems(module => {
                var assembly     = Assembly.LoadFile(module.AssemblyPath);
                var toolboxItems = ToolboxService.GetToolboxItems(assembly, null).Cast <ToolboxItem>().ToArray();
                foreach (var item in toolboxItems)
                {
                    tbxService.RemoveToolboxItem(item);
                    this.DTE2().StatusBar.Text =
                        $"{item.DisplayName} removed from the toolbox category Xpand.{module.Platform}";
                }

                return(toolboxItems.FirstOrDefault());
            });
            InstallToolBoxItems();
        }
Exemplo n.º 12
0
        private void SetupDesigner()
        {
            try
            {
                var snapshot = _language.CreateSourceSnapshot(AssociatedFile.GetContentsAsString()) as NetSourceSnapshot;
                _includeBaseType = !string.IsNullOrEmpty(snapshot.Types[0].ValueType);
                _namespace       = snapshot.Namespaces.Length == 0 ? string.Empty : snapshot.Namespaces[0].Name;

                _serviceContainer.AddService(typeof(INameCreationService), new NameCreationService());
                _surface = _codeReader.Deserialize(_surfaceManager, _serviceContainer, AssociatedFile);

                _viewControl      = _surface.View as Control;
                _viewControl.Dock = DockStyle.Fill;
                this.Control      = _viewControl;

                _designerHost = _surface.GetService <IDesignerHost>();

                var selectionService = _surface.GetService <ISelectionService>();
                selectionService.SelectionChanged += selectionService_SelectionChanged;

                var changeService = _designerHost.GetService <IComponentChangeService>();
                changeService.OnComponentChanging(_designerHost.RootComponent, TypeDescriptor.GetProperties(_designerHost.RootComponent)["Controls"]);
                changeService.ComponentChanging += changeService_ComponentChanging;
                changeService.ComponentAdded    += changeService_ComponentsChanged;
                changeService.ComponentRemoved  += changeService_ComponentsChanged;

                _serviceContainer.AddService(typeof(IMenuCommandService), new Services.MenuCommandService(_extensionHost, _designerHost));
                _serviceContainer.AddService(typeof(IEventBindingService), new Services.EventBindingService(_designerHost));
                _toolboxService = new Services.FormsToolBoxService((ParentExtension as FormsDesignerExtension).ToolBoxBuilder);
                _toolboxService.SelectedItemChanged += toolBoxService_SelectedItemChanged;
                _toolboxService.SelectedItemUsed    += toolBoxService_SelectedItemUsed;
                _serviceContainer.AddService(typeof(IToolboxService), _toolboxService);
            }
            catch (BuildException ex)
            {
                _errorControl.SetBuildErrors(ex.Result.Errors);
                this.Control = _errorControl;
            }
            catch (Exception ex)
            {
                _errorControl.SetException(ex);
                this.Control = _errorControl;
            }
        }
        private void OnDialogDisposed(object sender, EventArgs e)
        {
            updateNeeded = true;

            if (entriesDirty)
            {
                SaveEntries();
                entriesDirty = false;
            }

            // This releases all of the assemblies we loaded.
            //
            ToolboxService.ClearEnumeratedElements();

            // This is not really needed because a new page will be created next time,
            // but I feel safer with it here.
            //
            dlg = null;
        }
Exemplo n.º 14
0
        private void InitDockForm()
        {
            FormProperties formProperties = new FormProperties();

            formProperties.Show(dockPanel, DockState.DockRight);
            PadContentCollection.Add(formProperties);
            FormsDesignerViewContent formsDVC = WorkbenchSingleton.Workbench.ActiveContent as FormsDesignerViewContent;

            if (formsDVC != null)
            {
                ToolboxService toolboxService = formsDVC.DesignSurface.GetService(typeof(IToolboxService)) as ToolboxService;
                FormToolBox    formTool       = new FormToolBox(toolboxService);
                formTool.Show(dockPanel, DockState.DockLeft);
                formTool.DockPanel.DockLeftPortion = 0.15;
                formTool.AutoHidePortion           = 0.15;
                PadContentCollection.Add(formTool);
            }
            dockPanel.Documents.First().DockHandler.Activate();
        }
        protected override bool LoadView()
        {
            var ret = false;

            var isDocDataDirty = 0;

            // Save IsDocDataDirty flag here to be set back later.
            // This is because loading-view can cause the flag to be set since a new diagram could potentially created.
            DocData.IsDocDataDirty(out isDocDataDirty);
            IsLoading = true;
            try
            {
                var uri = Utils.FileName2Uri(DocData.FileName);
                _context = PackageManager.Package.DocumentFrameMgr.EditingContextManager.GetNewOrExistingContext(uri);
                Debug.Assert(_context != null, "_context should not be null");

                // Set DSL Diagram instance and values.
                // Note: the code should be executed before we suspend rule notification. The diagram shapes will not created correctly if we don't.

                // When document is reloaded, a new diagram will be created; so we always need to check for the new view diagram every time LoadView is called.
                var currentDiagram = GetNewOrExistingViewDiagram();
                if (Diagram != currentDiagram)
                {
                    Diagram = currentDiagram;
                }

                // Ensure that cache _xRef is cleared.
                _xRef = null;

                // The only case where diagram is null at this point is that VS tries to open diagram that doesn't exist in our model.
                // One of the possibilities: the user creates multiple diagrams, open the diagrams in VS, then close the project without saving the document.
                // When the project is reopened in the same VS, VS remembers any opened windows and will try to reopen it.
                // In this case, we should close the frame.
                if (Diagram == null)
                {
                    // Return false will force the window frame to be closed.
                    return(false);
                }

                if (Diagram is EntityDesignerDiagram entityDiagram && entityDiagram.ModelElement.EditingContext is null)
                {
                    // The editing context is null. This will cause downstream calls to throw exceptions.
                    // It is unknown why this happens sometimes, but seems to have something to do with designers being open on project load.
                    // Solution: Close the frame.
                    return(false);
                }

                ApplyLayoutInformationFromModelDiagram();

                Debug.Assert(DocData.Store.RuleManager.IsRuleSuspended == false, "The rule notification should not be suspended.");
                DocData.Store.RuleManager.SuspendRuleNotification();

                // We don't call base.LoadView() because the code assumes there is only 1 diagram (will assert otherwise),
                // and will always choose the first diagram.
                if (BaseLoadView())
                {
                    // Normally our toolbox items get populated only when the window is activated, but
                    // in certain circumstances we may switch the mode of our designer (normal/safe-mode/etc)
                    // when the window is already active. This is an expensive operation so we only need it when
                    // we reload the active document.
                    var escherDocData = DocData as MicrosoftDataEntityDesignDocData;
                    if (escherDocData != null &&
                        escherDocData.IsHandlingDocumentReloaded)
                    {
                        ToolboxService.Refresh();
                    }
                    ret = true;
                }

                // Listen to Diagram Title change event so we can update our window caption with the information.
                var entityDesignerDiagram = Diagram as EntityDesignerDiagram;
                Debug.Assert(entityDesignerDiagram != null, "The diagram is not the type of EntityDesignerDiagram");
                if (entityDesignerDiagram != null)
                {
                    entityDesignerDiagram.OnDiagramTitleChanged += OnDiagramTitleChanged;
                }
                UpdateWindowFrameCaption();
            }
            finally
            {
                // After Diagram is set, DSL code enabled DSL Undo Manager, so the code below is to disable it.
                if (DocData.Store.UndoManager.UndoState == DslModeling.UndoState.Enabled)
                {
                    DocData.Store.UndoManager.UndoState = DslModeling.UndoState.Disabled;
                }

                if (DocData.Store.RuleManager.IsRuleSuspended)
                {
                    DocData.Store.RuleManager.ResumeRuleNotification();
                }
                DocData.SetDocDataDirty(isDocDataDirty);
                IsLoading = false;
            }
            return(ret);
        }
Exemplo n.º 16
0
        public Toolbox(ToolboxService toolboxService, IPadWindow container)
        {
            this.toolboxService = toolboxService;
            this.container      = container;

            #region Toolbar
            DockItemToolbar toolbar = container.GetToolbar(PositionType.Top);

            filterEntry              = new SearchEntry();
            filterEntry.Ready        = true;
            filterEntry.HasFrame     = true;
            filterEntry.WidthRequest = 150;
            filterEntry.Changed     += new EventHandler(filterTextChanged);
            filterEntry.Show();

            toolbar.Add(filterEntry, true);

            catToggleButton             = new ToggleButton();
            catToggleButton.Image       = new Image(Ide.Gui.Stock.GroupByCategory, IconSize.Menu);
            catToggleButton.Toggled    += new EventHandler(toggleCategorisation);
            catToggleButton.TooltipText = GettextCatalog.GetString("Show categories");
            toolbar.Add(catToggleButton);

            compactModeToggleButton             = new ToggleButton();
            compactModeToggleButton.Image       = new ImageView(ImageService.GetIcon("md-compact-display", IconSize.Menu));
            compactModeToggleButton.Toggled    += new EventHandler(ToggleCompactMode);
            compactModeToggleButton.TooltipText = GettextCatalog.GetString("Use compact display");
            toolbar.Add(compactModeToggleButton);

            toolboxAddButton = new Button(new Gtk.Image(Ide.Gui.Stock.Add, IconSize.Menu));
            toolbar.Add(toolboxAddButton);
            toolboxAddButton.TooltipText = GettextCatalog.GetString("Add toolbox items");
            toolboxAddButton.Clicked    += new EventHandler(toolboxAddButton_Clicked);
            toolbar.ShowAll();

            #endregion

            toolboxWidget = new ToolboxWidget();
            toolboxWidget.SelectedItemChanged += delegate {
                selectedNode = this.toolboxWidget.SelectedItem != null ? this.toolboxWidget.SelectedItem.Tag as ItemToolboxNode : null;
                toolboxService.SelectItem(selectedNode);
            };
            this.toolboxWidget.DragBegin += delegate(object sender, Gtk.DragBeginArgs e) {
                if (this.toolboxWidget.SelectedItem != null)
                {
                    this.toolboxWidget.HideTooltipWindow();
                    toolboxService.DragSelectedItem(this.toolboxWidget, e.Context);
                }
            };
            this.toolboxWidget.ActivateSelectedItem += delegate {
                toolboxService.UseSelectedItem();
            };

            fontChanger = new MonoDevelop.Ide.Gui.PadFontChanger(toolboxWidget, toolboxWidget.SetCustomFont, toolboxWidget.QueueResize);

            this.toolboxWidget.DoPopupMenu = ShowPopup;

            scrolledWindow = new MonoDevelop.Components.CompactScrolledWindow();
            base.PackEnd(scrolledWindow, true, true, 0);
            base.FocusChain = new Gtk.Widget [] { scrolledWindow };

            //Initialise self
            scrolledWindow.ShadowType       = ShadowType.None;
            scrolledWindow.VscrollbarPolicy = PolicyType.Automatic;
            scrolledWindow.HscrollbarPolicy = PolicyType.Never;
            scrolledWindow.WidthRequest     = 150;
            scrolledWindow.Add(this.toolboxWidget);

            //update view when toolbox service updated
            toolboxService.ToolboxContentsChanged += delegate { Refresh(); };
            toolboxService.ToolboxConsumerChanged += delegate { Refresh(); };
            Refresh();

            //set initial state
            this.toolboxWidget.ShowCategories = catToggleButton.Active = true;
            compactModeToggleButton.Active    = MonoDevelop.Core.PropertyService.Get("ToolboxIsInCompactMode", false);
            this.toolboxWidget.IsListMode     = !compactModeToggleButton.Active;
            this.ShowAll();
        }
Exemplo n.º 17
0
        public Toolbox(ServiceContainer parentServices)
        {
            this.parentServices = parentServices;

            //we need this service, so create it if not present
            toolboxService = parentServices.GetService(typeof(IToolboxService)) as ToolboxService;
            if (toolboxService == null)
            {
                toolboxService = new ToolboxService();
                parentServices.AddService(typeof(IToolboxService), toolboxService);
            }

            #region Toolbar
            toolbar = new Toolbar();
            toolbar.ToolbarStyle = ToolbarStyle.Icons;
            toolbar.IconSize     = IconSize.SmallToolbar;
            base.PackStart(toolbar, false, false, 0);

            filterToggleButton            = new ToggleToolButton();
            filterToggleButton.IconWidget = new Image(Stock.MissingImage, IconSize.SmallToolbar);
            filterToggleButton.Toggled   += new EventHandler(toggleFiltering);
            toolbar.Insert(filterToggleButton, 0);

            catToggleButton            = new ToggleToolButton();
            catToggleButton.IconWidget = new Image(Stock.MissingImage, IconSize.SmallToolbar);
            catToggleButton.Toggled   += new EventHandler(toggleCategorisation);
            toolbar.Insert(catToggleButton, 1);

            SeparatorToolItem sep = new SeparatorToolItem();
            toolbar.Insert(sep, 2);

            filterEntry = new Entry();
            filterEntry.WidthRequest = 150;
            filterEntry.Changed     += new EventHandler(filterTextChanged);

            #endregion

            scrolledWindow = new ScrolledWindow();
            base.PackEnd(scrolledWindow, true, true, 0);


            //Initialise model

            store = new ToolboxStore();

            //initialise view
            nodeView = new NodeView(store);
            nodeView.Selection.Mode = SelectionMode.Single;
            nodeView.HeadersVisible = false;

            //cell renderers
            CellRendererPixbuf pixbufRenderer = new CellRendererPixbuf();
            CellRendererText   textRenderer   = new CellRendererText();
            textRenderer.Ellipsize = Pango.EllipsizeMode.End;

            //Main column with text, icons
            TreeViewColumn col = new TreeViewColumn();

            col.PackStart(pixbufRenderer, false);
            col.SetAttributes(pixbufRenderer,
                              "pixbuf", ToolboxStore.Columns.Icon,
                              "visible", ToolboxStore.Columns.IconVisible,
                              "cell-background-gdk", ToolboxStore.Columns.BackgroundColour);

            col.PackEnd(textRenderer, true);
            col.SetAttributes(textRenderer,
                              "text", ToolboxStore.Columns.Label,
                              "weight", ToolboxStore.Columns.FontWeight,
                              "cell-background-gdk", ToolboxStore.Columns.BackgroundColour);

            nodeView.AppendColumn(col);

            //Initialise self
            scrolledWindow.VscrollbarPolicy = PolicyType.Automatic;
            scrolledWindow.HscrollbarPolicy = PolicyType.Never;
            scrolledWindow.WidthRequest     = 150;
            scrolledWindow.AddWithViewport(nodeView);

            //selection events
            nodeView.NodeSelection.Changed += OnSelectionChanged;
            nodeView.RowActivated          += OnRowActivated;

            //update view when toolbox service updated
            toolboxService.ToolboxChanged += new EventHandler(tbsChanged);
            Refresh();

            //track expanded state of nodes
            nodeView.RowCollapsed += new RowCollapsedHandler(whenRowCollapsed);
            nodeView.RowExpanded  += new RowExpandedHandler(whenRowExpanded);

            //set initial state
            filterToggleButton.Active = false;
            catToggleButton.Active    = true;
        }
Exemplo n.º 18
0
        public Toolbox(ServiceContainer parentServices)
        {
            this.parentServices = parentServices;

            //we need this service, so create it if not present
            toolboxService = parentServices.GetService (typeof (IToolboxService)) as ToolboxService;
            if (toolboxService == null) {
                toolboxService = new ToolboxService ();
                parentServices.AddService (typeof (IToolboxService), toolboxService);
            }

            #region Toolbar
            toolbar = new Toolbar ();
            toolbar.ToolbarStyle = ToolbarStyle.Icons;
            toolbar.IconSize = IconSize.SmallToolbar;
            base.PackStart (toolbar, false, false, 0);

            filterToggleButton = new ToggleToolButton ();
            filterToggleButton.IconWidget = new Image (Stock.MissingImage, IconSize.SmallToolbar);
            filterToggleButton.Toggled += new EventHandler (toggleFiltering);
            toolbar.Insert (filterToggleButton, 0);

            catToggleButton = new ToggleToolButton ();
            catToggleButton.IconWidget = new Image (Stock.MissingImage, IconSize.SmallToolbar);
            catToggleButton.Toggled += new EventHandler (toggleCategorisation);
            toolbar.Insert (catToggleButton, 1);

            SeparatorToolItem sep = new SeparatorToolItem();
            toolbar.Insert (sep, 2);

            filterEntry = new Entry();
            filterEntry.WidthRequest = 150;
            filterEntry.Changed += new EventHandler (filterTextChanged);

            #endregion

            scrolledWindow = new ScrolledWindow ();
            base.PackEnd (scrolledWindow, true, true, 0);

            //Initialise model

            store = new ToolboxStore ();

            //initialise view
            nodeView = new NodeView (store);
            nodeView.Selection.Mode = SelectionMode.Single;
            nodeView.HeadersVisible = false;

            //cell renderers
            CellRendererPixbuf pixbufRenderer = new CellRendererPixbuf ();
            CellRendererText textRenderer = new CellRendererText ();
            textRenderer.Ellipsize = Pango.EllipsizeMode.End;

            //Main column with text, icons
            TreeViewColumn col = new TreeViewColumn ();

            col.PackStart (pixbufRenderer, false);
            col.SetAttributes (pixbufRenderer,
                                  "pixbuf", ToolboxStore.Columns.Icon,
                                  "visible", ToolboxStore.Columns.IconVisible,
                                  "cell-background-gdk", ToolboxStore.Columns.BackgroundColour);

            col.PackEnd (textRenderer, true);
            col.SetAttributes (textRenderer,
                                  "text", ToolboxStore.Columns.Label,
                                  "weight", ToolboxStore.Columns.FontWeight,
                                  "cell-background-gdk", ToolboxStore.Columns.BackgroundColour);

            nodeView.AppendColumn (col);

            //Initialise self
            scrolledWindow.VscrollbarPolicy = PolicyType.Automatic;
            scrolledWindow.HscrollbarPolicy = PolicyType.Never;
            scrolledWindow.WidthRequest = 150;
            scrolledWindow.AddWithViewport (nodeView);

            //selection events
            nodeView.NodeSelection.Changed += OnSelectionChanged;
            nodeView.RowActivated  += OnRowActivated;

            //update view when toolbox service updated
            toolboxService.ToolboxChanged += new EventHandler (tbsChanged);
            Refresh ();

            //track expanded state of nodes
            nodeView.RowCollapsed += new RowCollapsedHandler (whenRowCollapsed);
            nodeView.RowExpanded += new RowExpandedHandler (whenRowExpanded);

            //set initial state
            filterToggleButton.Active = false;
            catToggleButton.Active = true;
        }
        /// <devdoc>
        ///     Loads up the actual assembly names from the SDK and compares them to our entries, updating our list
        ///     as needed.  If the list was updated this sets entriesDirty.
        /// </devdoc>
        private void UpdateEntries()
        {
            IAssemblyEnumerationService assemblyEnum = (IAssemblyEnumerationService)GetService(typeof(IAssemblyEnumerationService));

            if (assemblyEnum == null)
            {
                Debug.Fail("No assembly enumerator, so we cannot load the component list");
                return;
            }

            // First, build a hash of all assembly entries we've loaded from disk.
            //
            Hashtable loadedEntries = new Hashtable(assemblyEntries.Count);

            foreach (AssemblyEntry entry in assemblyEntries)
            {
                loadedEntries[entry.Name.FullName] = entry;
            }

            int       oldCount      = assemblyEntries.Count;
            int       addedCount    = 0;
            ArrayList failedEntries = null;

            assemblyEntries.Clear();

            // Now enumerate entries.  Dynamically add new ones as needed.
            //
            foreach (AssemblyName name in assemblyEnum.GetAssemblyNames())
            {
                AssemblyEntry storedEntry   = (AssemblyEntry)loadedEntries[name.FullName];
                DateTime      lastWriteTime = File.GetLastWriteTime(NativeMethods.GetLocalPath(name.EscapedCodeBase));

                if (storedEntry != null && storedEntry.LastWriteTime == lastWriteTime)
                {
                    assemblyEntries.Add(storedEntry);
                }
                else
                {
                    // New doohickie.  Add it.
                    addedCount++;
                    ToolboxService.ToolboxElement[] elements;

                    try {
                        elements = ToolboxService.EnumerateToolboxElements(name.CodeBase, null);
                    }
                    catch {
                        elements = new ToolboxService.ToolboxElement[0];
                        if (failedEntries == null)
                        {
                            failedEntries = new ArrayList();
                        }

                        failedEntries.Add(NativeMethods.GetLocalPath(name.EscapedCodeBase));
                    }

                    AssemblyEntry newEntry = new AssemblyEntry();

                    newEntry.Name          = name;
                    newEntry.LastWriteTime = lastWriteTime;

                    newEntry.Items = new ToolboxItem[elements.Length];
                    for (int i = 0; i < elements.Length; i++)
                    {
                        newEntry.Items[i] = elements[i].Item;
                    }
                    assemblyEntries.Add(newEntry);
                    entriesDirty = true;
                }
            }

            // When all is said and done, if we haven't dirtied, check to make sure
            // we didn't remove anything.
            //
            if (!entriesDirty && oldCount != assemblyEntries.Count - addedCount)
            {
                entriesDirty = true;
            }

            // Now, if we had failures, display them to the user.
            //
            if (failedEntries != null)
            {
                IUIService uis = (IUIService)GetService(typeof(IUIService));
                if (uis != null)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (string e in failedEntries)
                    {
                        sb.Append("\r\n");
                        sb.Append(Path.GetFileName(e));
                    }

                    Exception ex = new Exception(SR.GetString(SR.AddRemoveComponentsSdkErrors, sb.ToString()));
                    ex.HelpLink = SR.AddRemoveComponentsSdkErrors;
                    uis.ShowError(ex);
                }
            }
        }
Exemplo n.º 20
0
 static IEnumerable <ToolboxItem> EnumerateToolboxItems(Assembly assembly)
 {
     return(ToolboxService.GetToolboxItems(assembly, null).Cast <ToolboxItem>());
 }
            /// <devdoc>
            ///     Adds all the toolbox items found in the given file.  This will display an error if the
            ///     file does not contain an assembly.
            /// </devdoc>
            private void AddItems(string fileName)
            {
                if (File.Exists(fileName))
                {
                    Exception displayException = null;

                    try {
                        Cursor oldCursor = Cursor.Current;
                        Cursor.Current = Cursors.WaitCursor;

                        ToolboxListViewItem firstItem = null;
                        IComparer           comparer  = controlList.ListViewItemSorter;
                        controlList.ListViewItemSorter = null;

                        controlList.SelectedItems.Clear();

                        try {
                            ToolboxService.ToolboxElement[] elements = ToolboxService.EnumerateToolboxElements(fileName, null);

                            foreach (ToolboxService.ToolboxElement element in elements)
                            {
                                ToolboxListViewItem existingItem = null;

                                foreach (ToolboxListViewItem i in controlList.Items)
                                {
                                    if (i.Item.Equals(element.Item))
                                    {
                                        existingItem = i;
                                        break;
                                    }
                                }

                                if (existingItem == null)
                                {
                                    ToolboxListViewItem item = new ToolboxListViewItem(element.Item);
                                    item.Checked = true;
                                    controlList.Items.Add(item);
                                    existingItem = item;
                                }

                                if (firstItem == null)
                                {
                                    firstItem = existingItem;
                                }

                                existingItem.Selected = true;
                            }
                        }
                        finally {
                            controlList.ListViewItemSorter = comparer;
                            Cursor.Current = oldCursor;
                        }

                        if (firstItem != null)
                        {
                            int index = controlList.Items.IndexOf(firstItem);
                            if (index != -1)
                            {
                                controlList.EnsureVisible(index);
                            }
                        }
                        else
                        {
                            displayException = new Exception(SR.GetString(SR.AddRemoveComponentsNoComponents, fileName));
                        }
                    }
                    catch (BadImageFormatException) {
                        displayException          = new Exception(SR.GetString(SR.AddRemoveComponentsBadModule, fileName));
                        displayException.HelpLink = SR.AddRemoveComponentsBadModule;
                    }
                    catch (ReflectionTypeLoadException) {
                        displayException          = new Exception(SR.GetString(SR.AddRemoveComponentsTypeLoadFailed, fileName));
                        displayException.HelpLink = SR.AddRemoveComponentsTypeLoadFailed;
                    }
                    catch (Exception ex) {
                        displayException = ex;
                    }

                    if (displayException != null)
                    {
                        IUIService uis = (IUIService)parentPage.GetService(typeof(IUIService));
                        if (uis != null)
                        {
                            uis.ShowError(displayException);
                        }
                        else
                        {
                            MessageBox.Show(this, displayException.ToString());
                        }
                    }
                }
            }
Exemplo n.º 22
0
 public ToolboxController(ToolboxService toolboxService)
 {
     _toolboxService = toolboxService;
 }
        private void SetupDesigner()
        {
            try
            {
                var snapshot = _language.CreateSourceSnapshot(AssociatedFile.GetContentsAsString()) as NetSourceSnapshot;
                _includeBaseType = !string.IsNullOrEmpty(snapshot.Types[0].ValueType);
                _namespace = snapshot.Namespaces.Length == 0 ? string.Empty : snapshot.Namespaces[0].Name;

                _serviceContainer.AddService(typeof(INameCreationService), new NameCreationService());
                _surface = _codeReader.Deserialize(_surfaceManager, _serviceContainer, AssociatedFile);

                _viewControl = _surface.View as Control;
                _viewControl.Dock = DockStyle.Fill;
                this.Control = _viewControl;

                _designerHost = _surface.GetService<IDesignerHost>();

                var selectionService = _surface.GetService<ISelectionService>();
                selectionService.SelectionChanged += selectionService_SelectionChanged;

                var changeService = _designerHost.GetService<IComponentChangeService>();
                changeService.OnComponentChanging(_designerHost.RootComponent, TypeDescriptor.GetProperties(_designerHost.RootComponent)["Controls"]);
                changeService.ComponentChanging += changeService_ComponentChanging;
                changeService.ComponentAdded += changeService_ComponentsChanged;
                changeService.ComponentRemoved += changeService_ComponentsChanged;

                _serviceContainer.AddService(typeof(IMenuCommandService), new Services.MenuCommandService(_extensionHost, _designerHost));
                _serviceContainer.AddService(typeof(IEventBindingService), new Services.EventBindingService(_designerHost));
                _toolboxService = new Services.FormsToolBoxService((ParentExtension as FormsDesignerExtension).ToolBoxBuilder);
                _toolboxService.SelectedItemChanged += toolBoxService_SelectedItemChanged;
                _toolboxService.SelectedItemUsed += toolBoxService_SelectedItemUsed;
                _serviceContainer.AddService(typeof(IToolboxService), _toolboxService);
            }
            catch (BuildException ex)
            {
                _errorControl.SetBuildErrors(ex.Result.Errors);
                this.Control = _errorControl;
            }
            catch (Exception ex)
            {
                _errorControl.SetException(ex);
                this.Control = _errorControl;
            }
        }
Exemplo n.º 24
0
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent ()
		{
			this.components = new System.ComponentModel.Container ();
			this._propertyGrid = new System.Windows.Forms.PropertyGrid ();
			this.splitter1 = new System.Windows.Forms.Splitter ();
			this.panel1 = new System.Windows.Forms.Panel ();
			this.splitter2 = new System.Windows.Forms.Splitter ();
			this.lblSelectedComponent = new System.Windows.Forms.Label ();
			this._panelDesignerView = new System.Windows.Forms.Panel ();
			this._toolbox = new ToolboxService ();
			this.panel1.SuspendLayout ();
			this.SuspendLayout ();
			// 
			// _propertyGrid
			// 
			this._propertyGrid.Dock = System.Windows.Forms.DockStyle.Bottom;
			this._propertyGrid.LineColor = System.Drawing.SystemColors.ScrollBar;
			this._propertyGrid.Location = new System.Drawing.Point (0, 142);
			this._propertyGrid.Name = "_propertyGrid";
			this._propertyGrid.Size = new System.Drawing.Size (224, 312);
			this._propertyGrid.TabIndex = 0;
			// 
			// splitter1
			// 
			this.splitter1.Dock = System.Windows.Forms.DockStyle.Right;
			this.splitter1.Location = new System.Drawing.Point (588, 0);
			this.splitter1.Name = "splitter1";
			this.splitter1.Size = new System.Drawing.Size (4, 478);
			this.splitter1.TabIndex = 1;
			this.splitter1.TabStop = false;
			// 
			// panel1
			// 
			this.panel1.Controls.Add (this._toolbox);
			this.panel1.Controls.Add (this.splitter2);
			this.panel1.Controls.Add (this._propertyGrid);
			this.panel1.Controls.Add (this.lblSelectedComponent);
			this.panel1.Dock = System.Windows.Forms.DockStyle.Right;
			this.panel1.Location = new System.Drawing.Point (592, 0);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size (224, 478);
			this.panel1.TabIndex = 2;
			// 
			// splitter2
			// 
			this.splitter2.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.splitter2.Location = new System.Drawing.Point (0, 138);
			this.splitter2.Name = "splitter2";
			this.splitter2.Size = new System.Drawing.Size (224, 4);
			this.splitter2.TabIndex = 1;
			this.splitter2.TabStop = false;
			// 
			// lblSelectedComponent
			// 
			this.lblSelectedComponent.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.lblSelectedComponent.Location = new System.Drawing.Point (0, 454);
			this.lblSelectedComponent.Name = "lblSelectedComponent";
			this.lblSelectedComponent.Size = new System.Drawing.Size (224, 24);
			this.lblSelectedComponent.TabIndex = 3;
			this.lblSelectedComponent.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// _panelDesignerView
			// 
			this._panelDesignerView.Dock = System.Windows.Forms.DockStyle.Fill;
			this._panelDesignerView.Location = new System.Drawing.Point (0, 0);
			this._panelDesignerView.Name = "_panelDesignerView";
			this._panelDesignerView.Size = new System.Drawing.Size (588, 478);
			this._panelDesignerView.TabIndex = 3;
			// 
			// _toolbox
			// 
			this._toolbox.BackColor = System.Drawing.SystemColors.Control;
			this._toolbox.BorderStyle = System.Windows.Forms.BorderStyle.None;
			this._toolbox.Dock = System.Windows.Forms.DockStyle.Fill;
			this._toolbox.Font = new System.Drawing.Font ("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
			this._toolbox.IntegralHeight = false;
			this._toolbox.ItemHeight = 16;
			this._toolbox.Location = new System.Drawing.Point (0, 0);
			this._toolbox.Name = "_toolbox";
			this._toolbox.SelectedCategory = null;
			this._toolbox.Size = new System.Drawing.Size (224, 138);
			this._toolbox.Sorted = true;
			this._toolbox.TabIndex = 2;
			this._toolbox.DoubleClick += new EventHandler (this.Toolbox_MouseDoubleClick);
			// 
			// frmMain
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size (5, 14);
			this.ClientSize = new System.Drawing.Size (816, 478);
			this.Controls.Add (this._panelDesignerView);
			this.Controls.Add (this.splitter1);
			this.Controls.Add (this.panel1);
			this.Font = new System.Drawing.Font ("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
			this.Name = "frmMain";
			this.Text = "THIS IS JUST FOR TESTING PURPOSES! - Middle-click for dragging a container control";
			this.panel1.ResumeLayout (false);
			this.ResumeLayout (false);

		}
Exemplo n.º 25
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.components           = new System.ComponentModel.Container();
     this._propertyGrid        = new System.Windows.Forms.PropertyGrid();
     this.splitter1            = new System.Windows.Forms.Splitter();
     this.panel1               = new System.Windows.Forms.Panel();
     this.splitter2            = new System.Windows.Forms.Splitter();
     this.lblSelectedComponent = new System.Windows.Forms.Label();
     this._panelDesignerView   = new System.Windows.Forms.Panel();
     this._toolbox             = new ToolboxService();
     this.panel1.SuspendLayout();
     this.SuspendLayout();
     //
     // _propertyGrid
     //
     this._propertyGrid.Dock      = System.Windows.Forms.DockStyle.Bottom;
     this._propertyGrid.LineColor = System.Drawing.SystemColors.ScrollBar;
     this._propertyGrid.Location  = new System.Drawing.Point(0, 142);
     this._propertyGrid.Name      = "_propertyGrid";
     this._propertyGrid.Size      = new System.Drawing.Size(224, 312);
     this._propertyGrid.TabIndex  = 0;
     //
     // splitter1
     //
     this.splitter1.Dock     = System.Windows.Forms.DockStyle.Right;
     this.splitter1.Location = new System.Drawing.Point(588, 0);
     this.splitter1.Name     = "splitter1";
     this.splitter1.Size     = new System.Drawing.Size(4, 478);
     this.splitter1.TabIndex = 1;
     this.splitter1.TabStop  = false;
     //
     // panel1
     //
     this.panel1.Controls.Add(this._toolbox);
     this.panel1.Controls.Add(this.splitter2);
     this.panel1.Controls.Add(this._propertyGrid);
     this.panel1.Controls.Add(this.lblSelectedComponent);
     this.panel1.Dock     = System.Windows.Forms.DockStyle.Right;
     this.panel1.Location = new System.Drawing.Point(592, 0);
     this.panel1.Name     = "panel1";
     this.panel1.Size     = new System.Drawing.Size(224, 478);
     this.panel1.TabIndex = 2;
     //
     // splitter2
     //
     this.splitter2.Dock     = System.Windows.Forms.DockStyle.Bottom;
     this.splitter2.Location = new System.Drawing.Point(0, 138);
     this.splitter2.Name     = "splitter2";
     this.splitter2.Size     = new System.Drawing.Size(224, 4);
     this.splitter2.TabIndex = 1;
     this.splitter2.TabStop  = false;
     //
     // lblSelectedComponent
     //
     this.lblSelectedComponent.Dock      = System.Windows.Forms.DockStyle.Bottom;
     this.lblSelectedComponent.Location  = new System.Drawing.Point(0, 454);
     this.lblSelectedComponent.Name      = "lblSelectedComponent";
     this.lblSelectedComponent.Size      = new System.Drawing.Size(224, 24);
     this.lblSelectedComponent.TabIndex  = 3;
     this.lblSelectedComponent.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
     //
     // _panelDesignerView
     //
     this._panelDesignerView.Dock     = System.Windows.Forms.DockStyle.Fill;
     this._panelDesignerView.Location = new System.Drawing.Point(0, 0);
     this._panelDesignerView.Name     = "_panelDesignerView";
     this._panelDesignerView.Size     = new System.Drawing.Size(588, 478);
     this._panelDesignerView.TabIndex = 3;
     //
     // _toolbox
     //
     this._toolbox.BackColor        = System.Drawing.SystemColors.Control;
     this._toolbox.BorderStyle      = System.Windows.Forms.BorderStyle.None;
     this._toolbox.Dock             = System.Windows.Forms.DockStyle.Fill;
     this._toolbox.Font             = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this._toolbox.IntegralHeight   = false;
     this._toolbox.ItemHeight       = 16;
     this._toolbox.Location         = new System.Drawing.Point(0, 0);
     this._toolbox.Name             = "_toolbox";
     this._toolbox.SelectedCategory = null;
     this._toolbox.Size             = new System.Drawing.Size(224, 138);
     this._toolbox.Sorted           = true;
     this._toolbox.TabIndex         = 2;
     this._toolbox.DoubleClick     += new EventHandler(this.Toolbox_MouseDoubleClick);
     //
     // frmMain
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
     this.ClientSize        = new System.Drawing.Size(816, 478);
     this.Controls.Add(this._panelDesignerView);
     this.Controls.Add(this.splitter1);
     this.Controls.Add(this.panel1);
     this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.Name = "frmMain";
     this.Text = "THIS IS JUST FOR TESTING PURPOSES! - Middle-click for dragging a container control";
     this.panel1.ResumeLayout(false);
     this.ResumeLayout(false);
 }
Exemplo n.º 26
0
        public MacToolbox(ToolboxService toolboxService, IPadWindow container)
        {
            Orientation          = NSUserInterfaceLayoutOrientation.Vertical;
            Alignment            = NSLayoutAttribute.Leading;
            Spacing              = 0;
            Distribution         = NSStackViewDistribution.Fill;
            AccessibilityElement = false;
            this.toolboxService  = toolboxService;
            this.container       = container;

            #region Toolbar

            groupByCategoryImage = ImageService.GetIcon(Stock.GroupByCategory, Gtk.IconSize.Menu);
            var compactImage = ImageService.GetIcon(Stock.CompactDisplay, Gtk.IconSize.Menu);
            var addImage     = ImageService.GetIcon(Stock.Add, Gtk.IconSize.Menu);

            horizontalStackView = NativeViewHelper.CreateHorizontalStackView(IconsSpacing);
            AddArrangedSubview(horizontalStackView);

            horizontalStackView.LeftAnchor.ConstraintEqualToAnchor(LeftAnchor, 0).Active   = true;
            horizontalStackView.RightAnchor.ConstraintEqualToAnchor(RightAnchor, 0).Active = true;

            horizontalStackView.EdgeInsets = new NSEdgeInsets(7, 7, 7, 7);

            //Horizontal container
            filterEntry = new NativeViews.SearchTextField();
            filterEntry.AccessibilityTitle = GettextCatalog.GetString("Search Toolbox");
            filterEntry.AccessibilityHelp  = GettextCatalog.GetString("Enter a term to search for it in the toolbox");
            filterEntry.Activated         += FilterTextChanged;
            filterEntry.Focused           += FilterEntry_Focused;

            horizontalStackView.AddArrangedSubview(filterEntry);
            AddWidgetToFocusChain(filterEntry);

            filterEntry.SetContentCompressionResistancePriority((int)NSLayoutPriority.DefaultLow, NSLayoutConstraintOrientation.Horizontal);
            filterEntry.SetContentHuggingPriorityForOrientation((int)NSLayoutPriority.DefaultLow, NSLayoutConstraintOrientation.Horizontal);

            catToggleButton       = new NativeViews.ToggleButton();
            catToggleButton.Image = groupByCategoryImage.ToNSImage();
            catToggleButton.AccessibilityTitle = GettextCatalog.GetString("Show categories");
            catToggleButton.ToolTip            = GettextCatalog.GetString("Show categories");
            catToggleButton.AccessibilityHelp  = GettextCatalog.GetString("Toggle to show categories");
            catToggleButton.Activated         += ToggleCategorisation;
            catToggleButton.Focused           += CatToggleButton_Focused;

            horizontalStackView.AddArrangedSubview(catToggleButton);
            AddWidgetToFocusChain(catToggleButton);

            catToggleButton.SetContentCompressionResistancePriority((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);
            catToggleButton.SetContentHuggingPriorityForOrientation((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);

            compactModeToggleButton                    = new NativeViews.ToggleButton();
            compactModeToggleButton.Image              = compactImage.ToNSImage();
            compactModeToggleButton.ToolTip            = GettextCatalog.GetString("Use compact display");
            compactModeToggleButton.AccessibilityTitle = GettextCatalog.GetString("Compact Layout");
            compactModeToggleButton.AccessibilityHelp  = GettextCatalog.GetString("Toggle for toolbox to use compact layout");
            compactModeToggleButton.Activated         += ToggleCompactMode;
            compactModeToggleButton.Focused           += CompactModeToggleButton_Focused;

            horizontalStackView.AddArrangedSubview(compactModeToggleButton);
            AddWidgetToFocusChain(compactModeToggleButton);

            compactModeToggleButton.SetContentCompressionResistancePriority((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);
            compactModeToggleButton.SetContentHuggingPriorityForOrientation((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);

            toolboxAddButton       = new NativeViews.ClickedButton();
            toolboxAddButton.Image = addImage.ToNSImage();
            toolboxAddButton.AccessibilityTitle = GettextCatalog.GetString("Add toolbox items");
            toolboxAddButton.AccessibilityHelp  = GettextCatalog.GetString("Add toolbox items");
            toolboxAddButton.ToolTip            = GettextCatalog.GetString("Add toolbox items");
            toolboxAddButton.Activated         += ToolboxAddButton_Clicked;
            toolboxAddButton.Focused           += ToolboxAddButton_Focused;

            horizontalStackView.AddArrangedSubview(toolboxAddButton);
            AddWidgetToFocusChain(toolboxAddButton);

            toolboxAddButton.SetContentCompressionResistancePriority((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);
            toolboxAddButton.SetContentHuggingPriorityForOrientation((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);

            #endregion

            toolboxWidget = new MacToolboxWidget(container)
            {
                AccessibilityTitle = GettextCatalog.GetString("Toolbox Toolbar"),
            };
            AddWidgetToFocusChain(toolboxWidget);

            var scrollView = new NSScrollView()
            {
                HasVerticalScroller   = true,
                HasHorizontalScroller = false,
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            scrollView.WantsLayer   = true;
            scrollView.DocumentView = toolboxWidget;
            AddArrangedSubview(scrollView);

            //update view when toolbox service updated
            toolboxService.ToolboxContentsChanged += ToolboxService_ToolboxContentsChanged;
            toolboxService.ToolboxConsumerChanged += ToolboxService_ToolboxConsumerChanged;

            filterEntry.Changed += FilterEntry_Changed;

            toolboxWidget.DragBegin            += ToolboxWidget_DragBegin;
            toolboxWidget.MouseDownActivated   += ToolboxWidget_MouseDownActivated;
            toolboxWidget.ActivateSelectedItem += ToolboxWidget_ActivateSelectedItem;
            toolboxWidget.MenuOpened           += ToolboxWidget_MenuOpened;
            toolboxWidget.RegionCollapsed      += FilterTextChanged;

            //set initial state
            toolboxWidget.ShowCategories   = catToggleButton.Active = true;
            compactModeToggleButton.Active = MonoDevelop.Core.PropertyService.Get("ToolboxIsInCompactMode", false);
            toolboxWidget.IsListMode       = !compactModeToggleButton.Active;
        }
Exemplo n.º 27
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.propertyGrid = new System.Windows.Forms.PropertyGrid();
     this.splitter1 = new System.Windows.Forms.Splitter();
     this.panel1 = new System.Windows.Forms.Panel();
     this.lstToolbox = new Hosting.ToolboxService();
     this.splitter2 = new System.Windows.Forms.Splitter();
     this.lblSelectedComponent = new System.Windows.Forms.Label();
     this.pnlViewHost = new System.Windows.Forms.Panel();
     this.mainMenu1 = new System.Windows.Forms.MainMenu();
     this.menuItem1 = new System.Windows.Forms.MenuItem();
     this.mnuDelete = new System.Windows.Forms.MenuItem();
     this.panel1.SuspendLayout();
     this.SuspendLayout();
     //
     // propertyGrid
     //
     this.propertyGrid.CommandsVisibleIfAvailable = true;
     this.propertyGrid.Dock = System.Windows.Forms.DockStyle.Bottom;
     this.propertyGrid.LargeButtons = false;
     this.propertyGrid.LineColor = System.Drawing.SystemColors.ScrollBar;
     this.propertyGrid.Location = new System.Drawing.Point(0, 203);
     this.propertyGrid.Name = "propertyGrid";
     this.propertyGrid.Size = new System.Drawing.Size(224, 312);
     this.propertyGrid.TabIndex = 0;
     this.propertyGrid.Text = "propertyGrid1";
     this.propertyGrid.ViewBackColor = System.Drawing.SystemColors.Window;
     this.propertyGrid.ViewForeColor = System.Drawing.SystemColors.WindowText;
     //
     // splitter1
     //
     this.splitter1.Dock = System.Windows.Forms.DockStyle.Right;
     this.splitter1.Location = new System.Drawing.Point(596, 0);
     this.splitter1.Name = "splitter1";
     this.splitter1.Size = new System.Drawing.Size(4, 539);
     this.splitter1.TabIndex = 1;
     this.splitter1.TabStop = false;
     //
     // panel1
     //
     this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                          this.lstToolbox,
                                                                          this.splitter2,
                                                                          this.propertyGrid,
                                                                          this.lblSelectedComponent});
     this.panel1.Dock = System.Windows.Forms.DockStyle.Right;
     this.panel1.Location = new System.Drawing.Point(600, 0);
     this.panel1.Name = "panel1";
     this.panel1.Size = new System.Drawing.Size(224, 539);
     this.panel1.TabIndex = 2;
     //
     // lstToolbox
     //
     this.lstToolbox.BackColor = System.Drawing.SystemColors.Control;
     this.lstToolbox.BorderStyle = System.Windows.Forms.BorderStyle.None;
     this.lstToolbox.Dock = System.Windows.Forms.DockStyle.Fill;
     this.lstToolbox.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
     this.lstToolbox.IntegralHeight = false;
     this.lstToolbox.ItemHeight = 16;
     this.lstToolbox.Name = "lstToolbox";
     this.lstToolbox.SelectedCategory = null;
     this.lstToolbox.Size = new System.Drawing.Size(224, 199);
     this.lstToolbox.Sorted = true;
     this.lstToolbox.TabIndex = 2;
     //
     // splitter2
     //
     this.splitter2.Dock = System.Windows.Forms.DockStyle.Bottom;
     this.splitter2.Location = new System.Drawing.Point(0, 199);
     this.splitter2.Name = "splitter2";
     this.splitter2.Size = new System.Drawing.Size(224, 4);
     this.splitter2.TabIndex = 1;
     this.splitter2.TabStop = false;
     //
     // lblSelectedComponent
     //
     this.lblSelectedComponent.Dock = System.Windows.Forms.DockStyle.Bottom;
     this.lblSelectedComponent.Location = new System.Drawing.Point(0, 515);
     this.lblSelectedComponent.Name = "lblSelectedComponent";
     this.lblSelectedComponent.Size = new System.Drawing.Size(224, 24);
     this.lblSelectedComponent.TabIndex = 3;
     this.lblSelectedComponent.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
     //
     // pnlViewHost
     //
     this.pnlViewHost.BackColor = System.Drawing.SystemColors.Window;
     this.pnlViewHost.Dock = System.Windows.Forms.DockStyle.Fill;
     this.pnlViewHost.Name = "pnlViewHost";
     this.pnlViewHost.Size = new System.Drawing.Size(596, 539);
     this.pnlViewHost.TabIndex = 3;
     //
     // mainMenu1
     //
     this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                                                               this.menuItem1});
     //
     // menuItem1
     //
     this.menuItem1.Index = 0;
     this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                                                               this.mnuDelete});
     this.menuItem1.Text = "&Edit";
     //
     // mnuDelete
     //
     this.mnuDelete.Index = 0;
     this.mnuDelete.Shortcut = System.Windows.Forms.Shortcut.Del;
     this.mnuDelete.Text = "&Delete";
     this.mnuDelete.Click += new System.EventHandler(this.mnuDelete_Click);
     //
     // frmMain
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
     this.ClientSize = new System.Drawing.Size(824, 539);
     this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                   this.pnlViewHost,
                                                                   this.splitter1,
                                                                   this.panel1});
     this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
     this.Menu = this.mainMenu1;
     this.Name = "frmMain";
     this.Text = "Designer Hosting Sample";
     this.panel1.ResumeLayout(false);
     this.ResumeLayout(false);
 }
Exemplo n.º 28
0
        public MacToolbox(ToolboxService toolboxService, IPadWindow container)
        {
            WantsLayer = true;

            keyViewLoopDelegate = new KeyViewLoopDelegate();

            verticalStackView = new UnfocusableStackView()
            {
                Orientation          = NSUserInterfaceLayoutOrientation.Vertical,
                Alignment            = NSLayoutAttribute.Leading,
                Spacing              = 0,
                Distribution         = NSStackViewDistribution.Fill,
                AccessibilityElement = false,
                WantsLayer           = true
            };
            AddSubview(verticalStackView);

            this.toolboxService = toolboxService;
            this.container      = container;

            #region Toolbar

            groupByCategoryImage = ImageService.GetIcon(Stock.GroupByCategory, Gtk.IconSize.Menu);
            var compactImage = ImageService.GetIcon(Stock.CompactDisplay, Gtk.IconSize.Menu);
            var addImage     = ImageService.GetIcon(Stock.Add, Gtk.IconSize.Menu);

            horizontalStackView = NativeViewHelper.CreateHorizontalStackView(IconsSpacing);
            verticalStackView.AddArrangedSubview(horizontalStackView);

            horizontalStackView.LeftAnchor.ConstraintEqualToAnchor(verticalStackView.LeftAnchor, 0).Active   = true;
            horizontalStackView.RightAnchor.ConstraintEqualToAnchor(verticalStackView.RightAnchor, 0).Active = true;

            horizontalStackView.EdgeInsets = new NSEdgeInsets(7, 7, 7, 7);

            //Horizontal container
            filterEntry = new NativeViews.SearchTextField();
            filterEntry.AccessibilityTitle = GettextCatalog.GetString("Search Toolbox");
            filterEntry.AccessibilityHelp  = GettextCatalog.GetString("Enter a term to search for it in the toolbox");
            filterEntry.Activated         += FilterTextChanged;

            horizontalStackView.AddArrangedSubview(filterEntry);

            filterEntry.SetContentCompressionResistancePriority((int)NSLayoutPriority.DefaultLow, NSLayoutConstraintOrientation.Horizontal);
            filterEntry.SetContentHuggingPriorityForOrientation((int)NSLayoutPriority.DefaultLow, NSLayoutConstraintOrientation.Horizontal);

            catToggleButton       = new NativeViews.ToggleButton();
            catToggleButton.Image = groupByCategoryImage.ToNSImage();
            catToggleButton.AccessibilityTitle = GettextCatalog.GetString("Show categories");
            catToggleButton.ToolTip            = GettextCatalog.GetString("Show categories");
            catToggleButton.AccessibilityHelp  = GettextCatalog.GetString("Toggle to show categories");
            catToggleButton.Activated         += ToggleCategorisation;

            horizontalStackView.AddArrangedSubview(catToggleButton);

            catToggleButton.SetContentCompressionResistancePriority((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);
            catToggleButton.SetContentHuggingPriorityForOrientation((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);

            compactModeToggleButton                    = new NativeViews.ToggleButton();
            compactModeToggleButton.Image              = compactImage.ToNSImage();
            compactModeToggleButton.ToolTip            = GettextCatalog.GetString("Use compact display");
            compactModeToggleButton.AccessibilityTitle = GettextCatalog.GetString("Compact Layout");
            compactModeToggleButton.AccessibilityHelp  = GettextCatalog.GetString("Toggle for toolbox to use compact layout");
            compactModeToggleButton.Activated         += ToggleCompactMode;

            horizontalStackView.AddArrangedSubview(compactModeToggleButton);

            compactModeToggleButton.SetContentCompressionResistancePriority((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);
            compactModeToggleButton.SetContentHuggingPriorityForOrientation((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);

            toolboxAddButton       = new NativeViews.ClickedButton();
            toolboxAddButton.Image = addImage.ToNSImage();
            toolboxAddButton.AccessibilityTitle = GettextCatalog.GetString("Add toolbox items");
            toolboxAddButton.AccessibilityHelp  = GettextCatalog.GetString("Add toolbox items");
            toolboxAddButton.ToolTip            = GettextCatalog.GetString("Add toolbox items");
            toolboxAddButton.Activated         += ToolboxAddButton_Clicked;

            horizontalStackView.AddArrangedSubview(toolboxAddButton);

            toolboxAddButton.SetContentCompressionResistancePriority((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);
            toolboxAddButton.SetContentHuggingPriorityForOrientation((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);

            #endregion

            toolboxWidget = new MacToolboxWidget()
            {
                AccessibilityTitle = GettextCatalog.GetString("Toolbox Toolbar"),
            };

            var scrollView = new UnfocusableScrollview()
            {
                HasVerticalScroller   = true,
                HasHorizontalScroller = false,
                DocumentView          = toolboxWidget
            };
            verticalStackView.AddArrangedSubview(scrollView);

            //update view when toolbox service updated
            toolboxService.ToolboxContentsChanged += ToolboxService_ToolboxContentsChanged;
            toolboxService.ToolboxConsumerChanged += ToolboxService_ToolboxConsumerChanged;

            toolboxWidget.DragBegin            += ToolboxWidget_DragBegin;
            toolboxWidget.ActivateSelectedItem += ToolboxWidget_ActivateSelectedItem;
            toolboxWidget.MenuOpened           += ToolboxWidget_MenuOpened;
            toolboxWidget.RegionCollapsed      += FilterTextChanged;

            toolboxWidget.KeyDownPressed += ToolboxWidget_KeyDownPressed;

            //set initial state
            toolboxWidget.ShowCategories   = catToggleButton.Active = true;
            compactModeToggleButton.Active = MonoDevelop.Core.PropertyService.Get("ToolboxIsInCompactMode", false);
            toolboxWidget.IsListMode       = !compactModeToggleButton.Active;

            //custom message
            var cell = new VerticalAlignmentTextCell(NSTextBlockVerticalAlignment.Middle)
            {
                Font            = NativeViewHelper.GetSystemFont(false, (int)NSFont.SmallSystemFontSize),
                LineBreakMode   = NSLineBreakMode.ByWordWrapping,
                Alignment       = NSTextAlignment.Center,
                Editable        = false,
                Bordered        = false,
                Bezeled         = false,
                DrawsBackground = false,
                Selectable      = false
            };

            messageTextField = new NSTextField {
                Cell       = cell,
                WantsLayer = true,
                Hidden     = true
            };
            AddSubview(messageTextField);

            keyViewLoopDelegate.AddViews(filterEntry, catToggleButton, compactModeToggleButton, toolboxAddButton, toolboxWidget);
            keyViewLoopDelegate.RecalculeNextResponderChain();
        }
Exemplo n.º 29
0
        public void SetToolBox(ToolboxService toolboxService)
        {
            if (toolboxService == _lastToolboxService)
            {
                return;
            }

            toolBoxTreeView.Nodes.Clear();
            if (toolBoxTreeView.ImageList != null)
            {
                toolBoxTreeView.ImageList.Dispose();
            }

            toolBoxTreeView.ImageList = new ImageList()
            {
                ColorDepth = ColorDepth.Depth32Bit,
                ImageSize  = new Size(16, 16),
            };

            toolBoxTreeView.ImageList.Images.Add(_folderImage);
            toolBoxTreeView.ImageList.Images.Add(_pointer);

            if (toolboxService != null)
            {
                toolboxService.SelectedItemChanged += toolboxService_SelectedItemChanged;

                foreach (string category in toolboxService.CategoryNames)
                {
                    TreeNode rootNode = new TreeNode(category);
                    rootNode.Nodes.Add(new TreeNode("Pointer")
                    {
                        ImageIndex = 1, SelectedImageIndex = 1
                    });

                    foreach (ToolboxItem item in toolboxService.GetToolboxItems(category))
                    {
                        toolBoxTreeView.ImageList.Images.Add(item.Bitmap);
                        rootNode.Nodes.Add(new TreeNode(item.DisplayName)
                        {
                            ToolTipText        = string.Format("{0}\r\n{1} v{2}\r\n\r\n{3}", item.TypeName, item.AssemblyName, item.Version, item.Description),
                            Tag                = item,
                            ImageIndex         = toolBoxTreeView.ImageList.Images.Count - 1,
                            SelectedImageIndex = toolBoxTreeView.ImageList.Images.Count - 1,
                        });
                    }

                    toolBoxTreeView.Nodes.Add(rootNode);
                    if (category == toolboxService.SelectedCategory)
                    {
                        rootNode.Expand();
                    }
                }

                label1.Visible = toolBoxTreeView.Nodes.Count == 0;
            }
            else
            {
                label1.Visible = true;
            }

            _lastToolboxService = toolboxService;
        }