コード例 #1
0
 private void SaveToolbarPositions(Window window)
 {
     this.Toolbars = new List <ToolbarSettingItem>();
     for (int i = 0; i < _toolTray.Children.Count; i++)
     {
         DefaultToolbar tb = _toolTray.Children[i] as DefaultToolbar;
         Toolbars.Add(new ToolbarSettingItem(tb));
     }
     Save();
 }
コード例 #2
0
        bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)
        {
            Page.Trace.Write(this.ID, "LoadPostData...");

            Toolbars.Clear();
            string[] toolbarsID = postCollection[UniqueID + "_toolbars"].Split(',');
            foreach (string toolbarID in toolbarsID)
            {
                if (toolbarID != string.Empty)
                {
                    //Toolbars.Add((Toolbar)Page.FindControl(toolbarID));

                    Control tool = Page.FindControl(toolbarID);
                    if (tool != null)
                    {
                        Toolbars.Add((Toolbar)tool);
                    }
                }
            }

            _toolbarsRenderedByOther = "";
            string containers = postCollection["Containers"];

            if (containers != null)
            {
                string[] containersID = containers.Split(',');
                foreach (string containerID in containersID)
                {
                    if (containerID != null && containerID != string.Empty && containerID != ID)
                    {
                        string toolbars = postCollection[containerID + "_toolbars"];
                        if (toolbars != null && toolbars != string.Empty)
                        {
                            toolbars = toolbars.TrimStart(',');
                            toolbars = toolbars.TrimEnd(',');

                            _toolbarsRenderedByOther += toolbars;
                            _toolbarsRenderedByOther += ",";
                        }
                    }
                }
            }
            _toolbarsRenderedByOther = _toolbarsRenderedByOther.TrimEnd(',');

            return(true);
        }
コード例 #3
0
ファイル: AuStripManager.cs プロジェクト: alexfordc/Au
        /// <summary>
        /// Opens XML file and creates toolbars/menus/submenus from XML tags.
        /// </summary>
        /// <param name="xmlFile">XML file containing menus/toolbars without user customizations.</param>
        /// <param name="xmlFileCustom">XML file containing user customizations. It will be created or updated when saving customizations.</param>
        /// <param name="tsRenderer"></param>
        public void BuildAll(string xmlFile, string xmlFileCustom, ToolStripRenderer tsRenderer = null)
        {
            Debug.Assert(_xStrips == null); if (_xStrips != null)
            {
                throw new InvalidOperationException();
            }

            _xmlFileDefault = xmlFile;
            _xmlFileCustom  = xmlFileCustom;
            try { _xStrips = AExtXml.LoadElem(xmlFile); }
            catch (Exception ex) { ADialog.ShowError("Failed to load file", ex.ToString()); throw; }
            XElement xCustom = null;

            if (AFile.ExistsAsFile(_xmlFileCustom))
            {
                try { xCustom = AExtXml.LoadElem(_xmlFileCustom); }
                catch (Exception e) { AOutput.Write("Failed to load file", _xmlFileCustom, e.Message); }
            }

            Size imageScalingSize = Au.Util.ADpi.SmallIconSize_;             //if high DPI, auto scale images

            //create top-level toolstrips (menu bar and toolbars), and call _AddChildItems to add items and create drop-down menus and submenus
            _inBuildAll = true;
            bool isMenu = true;

            foreach (var xe in _xStrips.Elements().ToArray())              //info: ToArray() because _MergeCustom replaces XML elements of custom toolbars
            {
                string name = xe.Name.LocalName;
                var    x    = xe;
                if (xCustom != null)
                {
                    _MergeCustom(xCustom, ref x, name, isMenu);
                }

                ToolStrip t;
                if (isMenu)
                {
                    t = MenuBar = new Util.AMenuStrip();
                }
                else
                {
                    var cts = new Util.AToolStrip();
                    Toolbars.Add(name, cts);
                    t = cts;
                    switch (name)
                    {
                    case "Custom1": _tsCustom1 = cts; break;

                    case "Custom2": _tsCustom2 = cts; break;
                    }
                }

                t.SuspendLayout();

                t.Tag  = x;
                t.Text = t.Name = name;
                //t.AllowItemReorder = true; //don't use, it's has bugs etc, we know better how to do it
                if (tsRenderer != null)
                {
                    t.Renderer = tsRenderer;
                }
                if (isMenu)
                {
                    t.Padding = new Padding();                     //remove menu bar paddings
                }
                else
                {
                }
                if (imageScalingSize.Height != 16)
                {
                    t.ImageScalingSize = imageScalingSize;                                               //info: all submenus will inherit it from menubar
                }
                _AddChildItems(x, t, isMenu);

                t.ResumeLayout(false);
                isMenu = false;
            }
            _inBuildAll = false;
        }