Join() приватный Метод

private Join ( ToolStrip toolStripToDrag ) : void
toolStripToDrag ToolStrip
Результат void
Пример #1
0
        public static void Load( IPluginHost host, ToolStripPanel panel, ToolStripMenuItem pluginMenu )
        {
            PluginHost = host;
            Program.LoadedPlugins.Clear ( );
            var asm = typeof ( PluginLoader ).Assembly;

            var plugins = Settings.Instance.PluginSettings.GetPlugins ( host );
            var rows = panel.Rows.Length;
            foreach ( IPlugin plugin in plugins ) {
                var pluginInfo = Settings.Instance.PluginSettings.GetPluginInfo ( plugin );
                if ( pluginInfo.Enabled ) {
                    pluginInfo.LogDebug ( "Loading: {0}", pluginInfo.Name );
                    Program.LoadedPlugins.Add ( plugin );

                    plugin.Initialize ( host );

                    if ( !plugin.CreateToolButton ) {
                        continue;
                    }
                    var tsb = plugin.CreateToolStripButton ( );
                    var tsm = plugin.CreateToolStripMenuItem ( );
                    var group = plugin.Group.Or ( "[DEFAULT]" );

                    var added = false;
                    foreach ( var c in panel.Controls ) {
                        if ( c.Is<ToolStrip> ( ) && string.Compare ( ( (ToolStrip)c ).Name, group, true ) == 0 ) {
                            ( (ToolStrip)c ).Items.Add ( tsb );
                            added = true;
                            break;
                        }
                    }
                    if ( !added ) {
                        // need to create the toolstrip and add the item
                        var strip = new ToolStrip ( tsb ) {
                            Name = group,
                        };
                        panel.Join ( strip, rows );
                    }

                    // menu items
                    var parentMenu = default ( ToolStripMenuItem );
                    foreach ( ToolStripMenuItem mi in pluginMenu.DropDownItems ) {
                        if ( mi.Text == group ) {
                            parentMenu = (ToolStripMenuItem)mi;
                        }
                    }
                    if ( parentMenu == null ) {
                        parentMenu = new ToolStripMenuItem ( group );
                        pluginMenu.DropDownItems.Add ( parentMenu );
                    }

                    parentMenu.DropDownItems.Add ( tsm );

                    if ( pluginInfo.ExecuteOnLoad && pluginInfo.Enabled ) {
                        plugin.Execute ( host );
                    }
                }
            }
        }
Пример #2
0
        public static void ProcessConfigItem(WorkItem workItem, ToolStripPanel toolStripPanel, MenuItemElement menuItem)
        {
            if (menuItem.IsContainer)
            {

                ToolStrip toolStrip = menuItem.ToToolStrip();

                toolStrip.Size = new System.Drawing.Size(442, 25);
                toolStrip.Text = menuItem.Site;
                toolStrip.Name = menuItem.Site;
                toolStrip.ImageScalingSize = new System.Drawing.Size(32, 32);
                toolStripPanel.Join(toolStrip);

                workItem.UIExtensionSites.RegisterSite(menuItem.Site, toolStrip);

                workItem.RootWorkItem.Items.Add(toolStrip, menuItem.Site);
            }
            else
            {

                foreach (Control control in toolStripPanel.Controls)
                {

                    ToolStrip toolStrip = control as ToolStrip;
                    toolStrip.ImageScalingSize = new System.Drawing.Size(32, 32);

                    if (toolStrip != null)
                    {

                        if (toolStrip.Name == menuItem.Site)
                        {

                            ToolStripButton toolStripButton = menuItem.ToToolStripItem();
                            toolStripButton.ToolTipText = menuItem.CommandName;
                            toolStripButton.Name = menuItem.CommandName;
                            toolStripButton.Tag = menuItem.Icon;
                            toolStripButton.Image = menuItem.GetIcon(menuItem.Icon);
                            if (workItem.UIExtensionSites.Contains(menuItem.Site))
                            {

                                workItem.UIExtensionSites[menuItem.Site].Add<ToolStripButton>(toolStripButton);
                            }

                            if (!String.IsNullOrEmpty(menuItem.CommandName))
                                workItem.Commands[menuItem.CommandName].AddInvoker(toolStripButton, "Click");

                        }
                    }
                }
            }
        }
Пример #3
0
 private void Frm_Main_Load(object sender, EventArgs e)
 {
     ToolStripPanel tsp_Top = new ToolStripPanel();//创建ToolStripPanel对象
     ToolStripPanel tsp_Bottom = new ToolStripPanel();//创建ToolStripPanel对象
     ToolStripPanel tsp_Left = new ToolStripPanel();//创建ToolStripPanel对象
     ToolStripPanel tsp_right = new ToolStripPanel();//创建ToolStripPanel对象
     tsp_Top.Dock = DockStyle.Top;//设置停靠方式
     tsp_Bottom.Dock = DockStyle.Bottom;//设置停靠方式
     tsp_Left.Dock = DockStyle.Left;//设置停靠方式
     tsp_right.Dock = DockStyle.Right;//设置停靠方式
     Controls.Add(tsp_Top);//添加到控件集合
     Controls.Add(tsp_Bottom);//添加到控件集合
     Controls.Add(tsp_Left);//添加到控件集合
     Controls.Add(tsp_right);//添加到控件集合
     tsp_Bottom.Join(toolStrip1);//将指定的工具栏添加到面板
 }
Пример #4
0
        public System.Windows.Forms.ToolStrip GetToolStrip(string name, int index)
        {
            foreach (Control c in pToolBars.Controls)
            {
                System.Windows.Forms.ToolStrip ts = c as System.Windows.Forms.ToolStrip;
                if (ts != null && ts.Text == name)
                {
                    return(ts);
                }
            }
            System.Windows.Forms.ToolStrip newts = new System.Windows.Forms.ToolStrip();
            newts.Text       = name;
            newts.Tag        = index;
            newts.AllowMerge = true;

            pToolBars.Join(newts);

            SortItems(pToolBars);

            return(newts);
        }
Пример #5
0
        private static void ReadPanel(XmlNode panelNode, ToolStripPanel toolStripPanel, ICollection<ToolStrip> toolStrips)
        {
            if (toolStripPanel == null) {
                return;
            }
            var stripNodes = panelNode.SelectNodes("Strip");
            if (stripNodes == null) {
                return;
            }
            foreach (XmlNode node in stripNodes) {
                ToolStrip item = null;
                foreach (var strip2 in toolStrips) {
                    strip2.ImageScalingSize = new Size(IconSize, IconSize);
                    ResizeChildren(strip2.Items);

                    if (node.Attributes == null || strip2.Name != node.Attributes["name"].Value) {
                        continue;
                    }
                    item = strip2;
                    break;
                }
                if (item == null) {
                    continue;
                }
                toolStrips.Remove(item);

                var strArray = node.Attributes["location"].Value.Split(',');
                toolStripPanel.Join(item, int.Parse(strArray[0]), int.Parse(strArray[1]));

                item.Visible = bool.Parse(node.Attributes["visible"].Value);
                item.GripStyle = Locked ? ToolStripGripStyle.Hidden : ToolStripGripStyle.Visible;
            }
        }
Пример #6
0
        public void ProcessConfigItem(WorkItem workItem, ToolStripPanel toolStripPanel, List<Operation> operation)
        {
            IResourceService _resourceService = workItem.Services.Get<IResourceService>();
            if (operation == null) return;
            MenuItemElement menuItem = new MenuItemElement();

            Dictionary<string, string> locationList = new Dictionary<string, string>();
            foreach (object enumEntry in Enum.GetValues(typeof(LocationType)))
            {
                locationList.Add(DomainHelper.GetCode<LocationType>((LocationType)enumEntry), enumEntry.ToString());
            }

            var locationListSort = from dic in locationList
                                   orderby dic.Key descending
                                   select dic;

            Dictionary<string, string> enumList = locationListSort.ToDictionary(lt => lt.Key, lt => lt.Value);

            //this.MainToolStripPanel.BackgroundImage = ResourceManager. GetIcon("ICON_bar");
            //this.toolStrip1.BackgroundImage = GetIcon("ICON_bar");

            // 고정도구모음, 가변도구모음 ToolStrip 생성
            foreach (KeyValuePair<string, string> enumEntry in enumList)
            {
                string locationType = enumEntry.Value;
                if (locationType == LocationType.Screen.ToString()) continue;

                ToolStrip toolStrip = menuItem.ToToolStrip();
                //ToolStrip toolStrip = new ToolStrip();

                //toolStrip.Size = new System.Drawing.Size(442, 25);
                toolStrip.Text = locationType;
                toolStrip.Name = locationType;
                toolStrip.ImageScalingSize = new System.Drawing.Size(32, 32);
                toolStrip.MinimumSize = new Size(0, 40);
                //toolStrip.BackgroundImage = GetIcon("ICON_bar");
                toolStripPanel.Join(toolStrip);

                workItem.UIExtensionSites.RegisterSite(locationType, toolStrip);
                workItem.RootWorkItem.Items.Add(toolStrip, locationType);
            }

            _commandButtonService.InitShellCommandButtonLayout(toolStripPanel, operation, new Size(32, 32), true,
               ContentAlignment.MiddleLeft, TextImageRelation.ImageBeforeText, new Font("Tahoma", 8.25F, FontStyle.Regular), _resourceService);
        }
Пример #7
0
        void SortItems(ToolStripPanel panel)
        {
            if(panel == null)
                throw new ArgumentNullException("panel");

            ArrayList list = new ArrayList();
            foreach(object o in panel.Controls)
                list.Add(o);

            list.Sort(new ToolStripBarCustomIComparer());

            panel.Controls.Clear();
            foreach(object o in list)
            {
                panel.Join(o as System.Windows.Forms.ToolStrip);
            }
        }
Пример #8
0
        public static void ProcessConfigItem(WorkItem workItem, ToolStripPanel toolStripPanel, List<Operation> operation)
        {
            IResourceService _resourceService = workItem.Services.Get<IResourceService>();
            if (operation == null) return;
            MenuItemElement menuItem = new MenuItemElement();

            foreach (Operation op in operation)
            {
                if (op.ContainerYN)
                {

                    ToolStrip toolStrip = menuItem.ToToolStrip();
                    //ToolStrip toolStrip = new ToolStrip();

                    toolStrip.Size = new System.Drawing.Size(442, 25);
                    toolStrip.Text = op.LocationType.ToString();
                    toolStrip.Name = op.LocationType.ToString();
                    toolStrip.ImageScalingSize = new System.Drawing.Size(32, 32);
                    toolStripPanel.Join(toolStrip);

                    workItem.UIExtensionSites.RegisterSite(op.LocationType.ToString(), toolStrip);

                    workItem.RootWorkItem.Items.Add(toolStrip, op.LocationType.ToString());
                }
                else
                {

                    foreach (Control control in toolStripPanel.Controls)
                    {

                        ToolStrip toolStrip = control as ToolStrip;
                        toolStrip.ImageScalingSize = new System.Drawing.Size(32, 32);

                        if (toolStrip != null)
                        {

                            if (toolStrip.Name == op.LocationType.ToString())
                            {

                                //ToolStripButton toolStripButton = op.ToToolStripItem();
                                ToolStripButton toolStripButton = new ToolStripButton();
                                toolStripButton.ToolTipText = op.Name;
                                toolStripButton.Name = op.Name;
                                toolStripButton.Tag = op.NormalResId;
                                toolStripButton.Image = menuItem.GetIcon(op.NormalResId);
                                if (workItem.UIExtensionSites.Contains(op.LocationType.ToString()))
                                {

                                    workItem.UIExtensionSites[op.LocationType.ToString()].Add<ToolStripButton>(toolStripButton);
                                }

                                if (!String.IsNullOrEmpty(op.Name))
                                    workItem.Commands[op.Name].AddInvoker(toolStripButton, "Click");

                            }
                        }
                    }
                }
            }
        }
Пример #9
0
		void Initialize() {
			ClientSize = new Size(800, 600);
			Text = AppName;
			AllowDrop = true;
			IsMdiContainer = true;

			DockArea = new DockPanel {
				Dock = DockStyle.Fill,
				Theme = new VS2010Theme(),
				DockLeftPortion = 0.35,
				DockBottomPortion = 0.3,
				DocumentStyle = DocumentStyle.DockingMdi,
				ShowDocumentIcon = true,
				AllowEndUserDocking = false,
				AllowEndUserNestedDocking = false
			};
			Controls.Add(DockArea);

			Languages = new LanguageManager();
			Analyzer = new Analyzer(this);

			Modules = new ModuleManager(this);
			Modules.SelectionChanged += OnNodeSelected;
			Modules.History.Navigated += (sender, e) => UpdateHistoryButtons();

			Modules.Show(DockArea, DockState.Document); // Reduce flickering when first show document later
			Modules.Show(DockArea, DockState.DockLeft);

			toolStripPanel = new ToolStripPanel {
				Dock = DockStyle.Top
			};
			Controls.Add(toolStripPanel);

			mainStrip = new ToolStrip();
			toolStripPanel.Join(mainStrip);

			backBtn = new ToolStripButton(Resources.GetResource<Image>("Icons.back.png")) {
				ToolTipText = "Go Back",
				Enabled = false
			};
			backBtn.Click += (sender, e) => Modules.History.GoBack();
			mainStrip.Items.Add(backBtn);

			forwardBtn = new ToolStripButton(Resources.GetResource<Image>("Icons.forward.png")) {
				ToolTipText = "Go Forward",
				Enabled = false
			};
			forwardBtn.Click += (sender, e) => Modules.History.GoForward();
			mainStrip.Items.Add(forwardBtn);


			mainStrip.Items.Add(new ToolStripSeparator());
			var langCombo = new ToolStripComboBox();
			mainStrip.Items.Add(langCombo);

			langCombo.ComboBox.DataSource = Languages.Languages;
			Languages.PropertyChanged += (sender, e) => langCombo.ComboBox.SelectedItem = Languages.ActiveLanguage;
			Shown += (sender, e) => {
				langCombo.ComboBox.SelectedItem = Languages.ActiveLanguage;
				langCombo.ComboBox.SelectedValueChanged +=
					(s, ee) => Languages.ActiveLanguage = (ILanguage)langCombo.ComboBox.SelectedItem;
			};

			langCombo.ComboBox.DisplayMember = "Name";
			langCombo.ComboBox.DropDownStyle = ComboBoxStyle.DropDownList;

			PerformLayout();
		}