Exemplo n.º 1
0
        public void SaveAsXml(Stream stream)
        {
            XmlWriter xmlOut = XmlWriter.Create(stream, new XmlWriterSettings()
            {
                Encoding = Encoding.Unicode, Indent = true
            });

            xmlOut.WriteComment("测试");
            ArrayList list = _toolbarManager.GetControls();

            int count = list.Count;

            xmlOut.WriteStartElement("ToolBars");
            for (int i = 0; i < count; i++)
            {
                xmlOut.WriteStartElement("ToolBar");
                Control           c         = list[i] as Control;
                ToolBarDockHolder refHolder = _toolbarManager.GetHolder(c);
                string            style     = refHolder.DockStyle.ToString();
                Point             point     = new Point(0, 0);

                if (style.ToLower() != "none")
                {
                    point = refHolder.PreferredDockedLocation;
                }
                else
                {
                    point = refHolder.FloatForm.Location;
                }

                int width  = refHolder.Width;
                int height = refHolder.Height;

                xmlOut.WriteAttributeString("name", c.Text);
                xmlOut.WriteAttributeString("x", point.X + "");
                if (style.ToLower() != "none")
                {
                    xmlOut.WriteAttributeString("y", point.Y / height * height + "");
                }
                else
                {
                    xmlOut.WriteAttributeString("y", point.Y + "");
                }
                xmlOut.WriteAttributeString("type", style);
                xmlOut.WriteEndElement();
            }
            xmlOut.WriteEndElement();
            xmlOut.Close();
        }
Exemplo n.º 2
0
        private void InitializeUserControls()
        {
            transportToolStrip.Size = transportToolStrip.Size;
            //_toolBarManager.AddControl(transportToolStrip);
            ToolBarDockHolder holder = _toolBarManager.AddControl(transportToolStrip, DockStyle.Bottom);

            //
            // _imageList
            //
            this._imageList = new System.Windows.Forms.ImageList();//this.components);
            //this._imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("_imageList.ImageStream")));
            this._imageList.TransparentColor = System.Drawing.Color.Transparent;
            this._imageList.ImageSize        = new Size(64, 64);
            this._imageList.Images.Add(Bitmap.FromFile(@"..\..\images\icons\go-down.png"));
            this._imageList.Images.Add(Bitmap.FromFile(@"..\..\images\icons\go-first.png"));
            this._imageList.Images.Add(Bitmap.FromFile(@"..\..\images\icons\go-previous.png"));
            //this._imageList.Images.SetKeyName(1, "");
            //this._imageList.Images.SetKeyName(2, "");
            //this._imageList.Images.SetKeyName(3, "");
            //this._imageList.Images.SetKeyName(4, "");
            //this._imageList.Images.SetKeyName(5, "");
            //this._imageList.Images.SetKeyName(6, "");
            //this._imageList.Images.SetKeyName(7, "");
            //this._imageList.Images.SetKeyName(8, "");
            //this._imageList.Images.SetKeyName(9, "");
            //this._imageList.Images.SetKeyName(10, "");
            //this._imageList.Images.SetKeyName(11, "");
            //this._imageList.Images.SetKeyName(12, "");

            this._toolBar4    = new System.Windows.Forms.ToolBar();
            this._richTextBox = new System.Windows.Forms.RichTextBox();
            this._button1     = new ToolBarButton();
            //this._button1.Text = "A";
            this._button1.ImageIndex = 0;
            this._button2            = new ToolBarButton();
            this._button2.ImageIndex = 1;
            //this._button2.Text = "B";
            this._button3            = new ToolBarButton();
            this._button3.ImageIndex = 2;
            //this._button3.Text = "C";
            this._toolBar4.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
            this._toolBar4.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
                this._button1, this._button2, this._button3
            });
            this._toolBar4.Divider        = false;
            this._toolBar4.Dock           = System.Windows.Forms.DockStyle.None;
            this._toolBar4.DropDownArrows = true;
            this._toolBar4.ImageList      = this._imageList;
            this._toolBar4.Location       = new System.Drawing.Point(0, 0);
            this._toolBar4.Name           = "_toolBar4";
            this._toolBar4.ShowToolTips   = true;
            this._toolBar4.Size           = new System.Drawing.Size(100, 26);
            this._toolBar4.TabIndex       = 3;
//            this.Controls.Add(this._toolBar4);
            _toolBar4.Text = "Built in code using ToolBar and ToolBarButton";



            _toolBarManager.AddControl(_toolBar4, DockStyle.Left);

            transportToolBar.Text = "Built in designer using ToolBar and ToolBarButton";
            _toolBarManager.AddControl(transportToolBar, DockStyle.Right);
        }
Exemplo n.º 3
0
        // On "View->Image Tool bar" menu item click
        private void imageBarViewItem_Click(object sender, System.EventArgs e)
        {
            ToolBarDockHolder holder = toolBarManager.GetHolder(imageToolBar);

            toolBarManager.ShowControl(imageToolBar, !holder.Visible);
        }