示例#1
0
        private void StoreLayout()
        {
            Ambertation.Windows.Forms.Serializer.Global.ToFile(Helper.DataFolder.SimPeLayoutW);

            MyButtonItem.SetLayoutInformations(this);

            Helper.WindowsRegistry.Layout.PluginActionBoxExpanded  = this.tbPlugAction.IsExpanded;
            Helper.WindowsRegistry.Layout.DefaultActionBoxExpanded = this.tbDefaultAction.IsExpanded;
            Helper.WindowsRegistry.Layout.ToolActionBoxExpanded    = this.tbExtAction.IsExpanded;

            resourceViewManager1.StoreLayout();
        }
示例#2
0
        /// <summary>
        /// Reload the Layout from the Registry
        /// </summary>
        void ReloadLayout()
        {
            this.SuspendLayout();
            //store defaults
            if (defaultlayout == null)
            {
                defaultlayout = Ambertation.Windows.Forms.Serializer.Global.ToStream();
            }

            try
            {
                Ambertation.Windows.Forms.Serializer.Global.FromFile(Helper.DataFolder.SimPeLayout);
            }
            catch (Exception ex)
            {
                Helper.ExceptionMessage(ex);
            }

            resourceViewManager1.RestoreLayout();


            UpdateDockMenus();
            MyButtonItem.GetLayoutInformations(this);

            FixCheckedState(tbTools);
            FixCheckedState(toolBar1);

            foreach (ToolStripItem tsi in miWindow.DropDownItems)
            {
                ToolStripMenuItem tsmi = tsi as ToolStripMenuItem;
                if (tsmi == null)
                {
                    continue;
                }
                if (tsmi.Tag == null)
                {
                    continue;
                }

                Ambertation.Windows.Forms.DockPanel dp = tsmi.Tag as Ambertation.Windows.Forms.DockPanel;
                if (dp != null)
                {
                    tsmi.Checked = dp.IsOpen;
                }
            }
            this.ResumeLayout();
        }
示例#3
0
        static void GetLayoutInformations(Control b, ArrayList list)
        {
            foreach (Control c in b.Controls)
            {
                GetLayoutInformations(c, list);
            }

            ToolStrip tb = b as ToolStrip;

            if (tb != null)
            {
                foreach (object o in tb.Items)
                {
                    MyButtonItem mbi = o as MyButtonItem;
                    if (mbi != null)
                    {
                        //if (!mbi.HaveDock)
                        mbi.Visible = list.Contains(mbi.Name);
                    }
                }
            }
        }
示例#4
0
        static void SetLayoutInformations(Control b, ArrayList list)
        {
            foreach (Control c in b.Controls)
            {
                SetLayoutInformations(c, list);
            }

            ToolStrip tb = b as ToolStrip;

            if (tb != null)
            {
                foreach (object o in tb.Items)
                {
                    MyButtonItem mbi = o as MyButtonItem;
                    if (mbi != null)
                    {
                        if (mbi.Visible /*&& !mbi.HaveDock*/)
                        {
                            list.Add(mbi.Name);
                        }
                    }
                }
            }
        }
示例#5
0
        public static void BuildToolBar(ToolStrip tb, ToolStripItemCollection mi, System.Collections.ArrayList exclude)
        {
            System.Collections.Generic.List <ToolStripItemCollection> submenus = new System.Collections.Generic.List <ToolStripItemCollection>();
            System.Collections.Generic.List <ToolStripMenuItem>       items    = new System.Collections.Generic.List <ToolStripMenuItem>();
            System.Collections.Generic.List <ToolStripMenuItem>       starters = new System.Collections.Generic.List <ToolStripMenuItem>();

            for (int i = mi.Count - 1; i >= 0; i--)
            {
                ToolStripMenuItem tsmi = mi[i] as ToolStripMenuItem;
                if (tsmi == null)
                {
                    if (i < mi.Count - 1)
                    {
                        starters.Add(mi[i + 1] as ToolStripMenuItem);
                    }
                    continue;
                }
                if (tsmi.DropDownItems.Count > 0)
                {
                    submenus.Add(tsmi.DropDownItems);
                }
                else
                {
                    ToolStripMenuItem item = tsmi;
                    if (exclude.Contains(item))
                    {
                        continue;
                    }
                    if (item.Image == null)
                    {
                        items.Add(item);
                    }
                    else
                    {
                        items.Insert(0, item);
                    }
                }
            }

            System.Collections.Generic.List <int> groupindices = new System.Collections.Generic.List <int>();
            for (int i = 0; i < items.Count; i++)
            {
                ToolStripMenuItem item = items[i];
                ToolStripButton   bi   = new MyButtonItem(item);
                bool beggroup          = (i == 0 && tb.Items.Count > 0) || starters.Contains(item);;
                if (beggroup)
                {
                    groupindices.Add(i);
                }
                tb.Items.Add(bi);
            }

            //// RECHECK
            foreach (int i in groupindices)
            {
                ToolStripMenuItem bi = new ToolStripMenuItem("--");
                items.Insert(i, bi);
            }


            for (int i = 0; i < submenus.Count; i++)
            {
                BuildToolBar(tb, submenus[i], exclude);
            }
        }