Ejemplo n.º 1
0
        private void Paint_Load(object sender, EventArgs e)
        {
            m_filenames = new StringDictionary();
            arraylines  = new object[] { 0, 1, 2, 3, 4 };

            m_pictureboxup        = new PictureBox();
            m_pictureboxup.Size   = new System.Drawing.Size(20, 20);
            m_pictureboxup.Click += OnClickPictureBoxUp;

            m_pictureboxdown        = new PictureBox();
            m_pictureboxdown.Click += OnClickPictureBoxDown;
            m_pictureboxdown.Size   = new System.Drawing.Size(20, 20);

            m_ComboBox.Size                  = new System.Drawing.Size(55, 25);
            m_ComboBox.DrawMode              = DrawMode.OwnerDrawFixed;
            m_ComboBox.DropDownStyle         = ComboBoxStyle.DropDownList;
            m_ComboBox.FormattingEnabled     = true;
            m_ComboBox.DrawItem             += OnDrawItem;
            m_ComboBox.SelectedIndexChanged += OnSelectChange;
            m_ComboBox.Items.AddRange(arraylines);
            m_ComboBox.SelectedIndex = 0;

            ToolStripControlHost combo = new ToolStripControlHost(m_ComboBox);

            toolBar.Items.Add(combo);
            toolBar.Items[8].Name = "Combo";

            NumericUpDown m_numeric = new NumericUpDown();

            m_numeric.ValueChanged += OnValueChanged;
            m_numeric.Minimum       = 1;
            ToolStripControlHost m_toolhost = new ToolStripControlHost(m_numeric);

            toolBar.Items.Add(m_toolhost);
            toolBar.Items[9].Name     = "Numeric";
            toolBar.Items[9].Margin   = new Padding(1, 10, 1, 0);
            toolBar.Items[9].AutoSize = false;
            toolBar.Items[9].Size     = new Size(55, 21);

            Button m_buttonfont = new Button();

            m_buttonfont.Text   = "Шрифт";
            m_buttonfont.Click += OnClickButtonFont;
            ToolStripControlHost m_toolbutton = new ToolStripControlHost(m_buttonfont);

            toolBar.Items.Add(m_toolbutton);
            toolBar.Items[10].Name   = "FontTool";
            toolBar.Items[10].Size   = new System.Drawing.Size(55, 21);
            toolBar.Items[10].Margin = new System.Windows.Forms.Padding(1, 5, 1, 0);

            m_bitmap           = new BitmapForma();
            m_bitmap.MdiParent = this;
            m_bitmap.Show();
            m_bitmap.Name     = "1New";
            m_bitmap.Location = new Point(toolBar.Width, 0);
            WindowsItem.DropDownItems.Add("1 Новый").Name = "1New";
            (WindowsItem.DropDownItems[0] as ToolStripMenuItem).Checked = true;
            m_filenames.Add(m_bitmap.Name, "New");
            WindowsItem.DropDownItemClicked += WinDropDownItemClick;

            var imageup   = new Bitmap(m_pictureboxup.Width, m_pictureboxup.Height);
            var imagedown = new Bitmap(m_pictureboxdown.Width, m_pictureboxdown.Height);

            m_pictureboxup.Image   = imageup;
            m_pictureboxdown.Image = imagedown;
            using (var graphics = Graphics.FromImage(imageup)){
                graphics.Clear(Color.Black);
            }
            using (var graphics = Graphics.FromImage(imagedown))
            {
                graphics.Clear(Color.White);
            }
            ToolsClass.MainPict    = Color.Black;
            ToolsClass.AnotherPict = Color.White;
            ToolStripControlHost pictureup = new ToolStripControlHost(m_pictureboxup);

            toolBar.Items.Add(pictureup);
            toolBar.Items[11].Margin = new Padding(10, 10, 0, 0);
            toolBar.Items[11].Name   = "Pictureup";
            ToolStripControlHost picturedown = new ToolStripControlHost(m_pictureboxdown);

            toolBar.Items.Add(picturedown);
            toolBar.Items[12].Name   = "Picturedown";
            toolBar.Items[12].Margin = new Padding(-5, 15, 0, 0);

            chsizebt        = new Button();
            chsizebt.Size   = new System.Drawing.Size(55, 21);
            chsizebt.Text   = "Размер";
            chsizebt.Click += OnClickButtonChangeSize;
            ToolStripControlHost butsize = new ToolStripControlHost(chsizebt);

            toolBar.Items.Add(butsize);
            toolBar.Items[13].Margin = new System.Windows.Forms.Padding(1, 5, 1, 0);

            tool             = new PencilTool(m_bitmap.Controls[0] as PictureBox);
            m_bitmap.tool    = tool;
            m_timer          = new Timer();
            m_timer.Interval = 1000;
            m_timer.Tick    += OnTimer;

            LayoutMdi(MdiLayout.Cascade);
        }