Пример #1
0
        private void AssingControlEvents()
        {
            // zmiana 'DrawingMode'
            drawNormalBtn.Click += new EventHandler((ob, e) => this.DrawableMode = new NormalMode());
            drawLineBtn.Click   += new EventHandler((ob, e) => this.DrawableMode = new LineMode());
            drawRectBtn.Click   += new EventHandler((ob, e) => this.DrawableMode = new RectangleMode());
            drawElipseBtn.Click += new EventHandler((ob, e) => this.DrawableMode = new ElipseMode());

            // czyszczenie panelu
            clearPanelBtn.Click += new EventHandler((ob, e) => {
                Console.WriteLine("Czyszcze panel !");
                DrawablePanel.Invalidate();
                InitializeGraphics();
            });

            // zmiana wielkosci czcionki
            fontSizeCb.SelectedIndexChanged += new EventHandler((ob, e) => {
                this.penSize = this.fontSizeCb.SelectedIndex + 1;
                InitializePen();
            });

            // zmiana koloru pedzla
            colorBtn.Click += new EventHandler((ob, e) => {
                colorDialog1.ShowDialog();
                selectedColor      = colorDialog1.Color;
                colorBtn.BackColor = selectedColor;
                InitializePen();
            });

            // zmiana indeksu tabControl
            tabControl1.SelectedIndexChanged += new EventHandler((ob, e) => {
                if (!drawableBitmaps.ContainsKey(tabControl1.SelectedIndex))
                {
                    AssingDrawingEvents();
                    InitializeGraphics();
                }
            });
        }
Пример #2
0
 private void DrawFigure()
 {
     DrawableMode.draw(DrawableBitmap, pen, p1Location, p2Location);
     DrawablePanel.CreateGraphics().DrawImageUnscaled(DrawableBitmap, new Point(0, 0));
 }
Пример #3
0
 private void InitializeGraphics()
 {
     DrawableBitmap = new Bitmap(DrawablePanel.Width - 5, DrawablePanel.Height - 5, DrawablePanel.CreateGraphics());
     Graphics.FromImage(DrawableBitmap).Clear(Color.White);
 }