예제 #1
0
파일: Triangle.cs 프로젝트: tyanbz/paint
 public void Draw(int startX, int startY, int endX, int endY, bool shift)
 {
     if (endX > startX)
     {
         int a = Convert.ToInt32(Math.Sqrt(Math.Pow(Math.Abs(endX - startX), 2) + Math.Pow(Math.Abs(endY - startY), 2)));
         int h = Convert.ToInt32(Math.Sqrt(Math.Pow(a, 2) - Math.Pow(startX - (endX - a), 2)));
         line.Draw(startX, startY, endX, endY, shift);
         if (endY > startY)
         {
             line.Draw(endX, endY, endX - a, startY + h, shift);
             line.Draw(endX - a, startY + h, startX, startY, shift);
         }
         else
         {
             line.Draw(endX, endY, endX - a, startY - h, shift);
             line.Draw(endX - a, startY - h, startX, startY, shift);
         }
     }
     else
     {
         int a = Convert.ToInt32(Math.Sqrt(Math.Pow(Math.Abs(endX - startX), 2) + Math.Pow(Math.Abs(endY - startY), 2)));
         int h = Convert.ToInt32(Math.Sqrt(Math.Pow(a, 2) - Math.Pow(startX - (endX + a), 2)));
         line.Draw(startX, startY, endX, endY, shift);
         if (endY > startY)
         {
             line.Draw(endX, endY, endX + a, startY + h, shift);
             line.Draw(endX + a, startY + h, startX, startY, shift);
         }
         else
         {
             line.Draw(endX, endY, endX + a, startY - h, shift);
             line.Draw(endX + a, startY - h, startX, startY, shift);
         }
     }
 }
예제 #2
0
        public MapProcessor(double _x, double _y, double _wd, double _ht)
        {
            rect = new Rectangle(_x, _y, _wd, _ht);
            DrawAnyObject painter = new DrawAnyObject();

            rect.Draw(painter);
        }
예제 #3
0
        public MapProcessor() //default
        {
            rect = new Rectangle(0, 0, 600, 600);
            DrawAnyObject painter = new DrawAnyObject();

            rect.Draw(painter);
        }
예제 #4
0
 public static void DrawCurrenFigure(IPaint screen)
 {
     if (currentFigure != null)
     {
         currentFigure.Draw(screen);
     }
 }
예제 #5
0
 private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
 {
     if (_mD)
     {
         _tmpbmp.Dispose();
         _tmpbmp   = (Bitmap)_bitmap.Clone();
         _graphics = Graphics.FromImage(_tmpbmp);
         _crntFigure.Draw(_graphics, _pen, _crntFigure.GetPoints(new Point[] { _prev, e.Location }, checkBox1.Checked));
         pictureBox1.Image = _tmpbmp;
     }
 }
예제 #6
0
파일: Square.cs 프로젝트: tyanbz/paint
 public void Draw(int startX, int startY, int endX, int endY, bool shift)
 {
     if (shift)
     {
         //квадрат
         int width = endX - startX;
         line.Draw(startX, startY, startX + width, startY, shift);
         line.Draw(startX, startY, startX, startY + width, shift);
         line.Draw(startX + width, startY, startX + width, startY + width, shift);
         line.Draw(startX, startY + width, startX + width, startY + width, shift);
     }
     else
     {
         line.Draw(startX, startY, endX, startY, shift);
         line.Draw(startX, startY, startX, endY, shift);
         line.Draw(endX, startY, endX, endY, shift);
         line.Draw(startX, endY, endX, endY, shift);
     }
 }
예제 #7
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            Frame frame = Window.Current.Content as Frame;

            if (frame.CanGoBack)
            {
                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
            }
            else
            {
                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
            }
            if (e.Parameter.ToString() != "")
            {
                figure = (Figure)e.Parameter;
            }
            figure.Draw(DrawFigureCanvas);
        }
예제 #8
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Random rnd = new Random();

            for (int i = 0; i < 10; i++)
            {
                IFigure circle    = Factory.DrawFigure("Circle");
                IFigure rectangle = Factory.DrawFigure("Rectangle");

                if (GetRandom(rnd) == 1)
                {
                    circle.Draw(e.Graphics, rnd.Next(100), rnd.Next(100), rnd.Next(100), rnd.Next(100));
                }
                else
                {
                    rectangle.Draw(e.Graphics, rnd.Next(100), rnd.Next(100), rnd.Next(100), rnd.Next(100));
                }
            }
        }
예제 #9
0
        public void Draw()
        {
            figure.Draw();
            DrawTextRec(GetFontDefault(), south,
                        new Rectangle(figure.Size().x, figure.Size().y + figure.Size().height, 100, 40),
                        20, 1, true, BLACK);
            DrawTextRec(GetFontDefault(), north,
                        new Rectangle(figure.Size().x, figure.Size().y - 20, 100, 40),
                        20, 1, true, BLACK);
            DrawTextRec(GetFontDefault(), west,
                        new Rectangle(figure.Size().x - 40, figure.Size().y, 100, 40),
                        20, 1, true, BLACK);
            DrawTextRec(GetFontDefault(), east,
                        new Rectangle(figure.Size().x + figure.Size().width, figure.Size().y, 100, 40),
                        20, 1, true, BLACK);

            if (selected)
            {
                ;
            }
        }
예제 #10
0
        private void PictureBox1_Paint(object sender, PaintEventArgs e)
        {
            Graphics graphics = e.Graphics;

            graphics.SmoothingMode = SmoothingMode.AntiAlias;
            graphics.Clear(Color.White);

            if (figures.Count() > 0)
            {
                foreach (IFigure figure in figures)
                {
                    figure.Draw(graphics);
                }
            }

            if (isDrawingInProgress)
            {
                if (tempFigure != null)
                {
                    tempFigure.Draw(graphics);
                }
            }
        }
예제 #11
0
파일: Circle.cs 프로젝트: tyanbz/paint
        public void Draw(int startX, int startY, int endX, int endY, bool shift)
        {
            try
            {
                int radius = Convert.ToInt32(Math.Sqrt(Math.Pow(endX - startX, 2) + Math.Pow(endY - startY, 2)));
                if (shift)
                {
                    int ax  = -radius + startX;
                    int ay  = startY;
                    int ay1 = startY;
                    for (int x = -radius; x <= radius; x++)
                    {
                        int yOTx = Convert.ToInt32(Math.Sqrt(Math.Abs(Math.Pow(radius, 2) - Math.Pow(x, 2))));
                        line.Draw(ax, ay, x + startX, yOTx + startY, shift);
                        line.Draw(ax, ay1, x + startX, -yOTx + startY, shift);
                        ax  = x + startX;
                        ay  = yOTx + startY;
                        ay1 = -yOTx + startY;
                    }
                }
                else
                {
                    double w = Math.Abs(endX - startX);
                    double h = Math.Abs(endY - startY);
                    double big, small;
                    bool   flagVertical = false;
                    if (w >= h)
                    {
                        big   = w;
                        small = h;
                    }
                    else
                    {
                        big          = h;
                        small        = w;
                        flagVertical = true;
                    }
                    int tmpX = 0, tmpY = 0;

                    for (int i = 0; i <= big; i++)
                    {
                        double x; double y;

                        if (flagVertical)
                        {
                            y = i;
                            x = Math.Sqrt((Math.Pow(small, 2) / Math.Pow(big, 2)) * (Math.Pow(big, 2) - Math.Pow(y, 2)));
                        }
                        else
                        {
                            x = i;
                            y = Math.Sqrt((Math.Pow(small, 2) / Math.Pow(big, 2)) * (Math.Pow(big, 2) - Math.Pow(x, 2)));
                        }


                        if (i == 0)
                        {
                            line.Draw(Convert.ToInt32(startX + x), Convert.ToInt32(startY + y), Convert.ToInt32(startX + x), Convert.ToInt32(startY + y), shift);
                            line.Draw(Convert.ToInt32(startX + x), Convert.ToInt32(startY - y), Convert.ToInt32(startX + x), Convert.ToInt32(startY - y), shift);
                            line.Draw(Convert.ToInt32(startX - x), Convert.ToInt32(startY - y), Convert.ToInt32(startX - x), Convert.ToInt32(startY - y), shift);
                            line.Draw(Convert.ToInt32(startX - x), Convert.ToInt32(startY + y), Convert.ToInt32(startX - x), Convert.ToInt32(startY + y), shift);



                            tmpX = Convert.ToInt32(x);
                            tmpY = Convert.ToInt32(y);
                        }
                        else
                        {
                            line.Draw((startX + tmpX), (startY + tmpY), Convert.ToInt32(startX + x), Convert.ToInt32(startY + y), shift);
                            line.Draw((startX + tmpX), (startY - tmpY), Convert.ToInt32(startX + x), Convert.ToInt32(startY - y), shift);
                            line.Draw((startX - tmpX), (startY - tmpY), Convert.ToInt32(startX - x), Convert.ToInt32(startY - y), shift);
                            line.Draw((startX - tmpX), (startY + tmpY), Convert.ToInt32(startX - x), Convert.ToInt32(startY + y), shift);
                            tmpX = Convert.ToInt32(x);
                            tmpY = Convert.ToInt32(y);
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
예제 #12
0
 public void BuildFigure(int startX, int startY, int endX, int endY, bool shift)
 {
     figure.Draw(startX, startY, endX, endY, shift);
 }
예제 #13
0
 public void Draw(IFigure figure)
 {
     figure.Draw();
 }