Exemplo n.º 1
0
        /*
         * Отрисовка прямоугольника
         */
        private void Draw_rectangle(object sender, RoutedEventArgs e)
        {
            RectangleGeometry     rectangle = new RectangleGeometry();
            Window_Draw_rectangle dlg       = new Window_Draw_rectangle();

            if (dlg.ShowDialog() == true)
            {
                rectangle.Rect = new Rect(Convert.ToInt32(dlg.x_begin.Text),
                                          Convert.ToInt32(dlg.y_begin.Text),
                                          Convert.ToInt32(dlg.width_textbox.Text),
                                          Convert.ToInt32(dlg.height_textbox.Text));
                Path    myPath    = new Path();
                Cololrs dlg_color = new Cololrs();
                if (dlg_color.ShowDialog() == true)
                {
                    Color_Fill dlg_color_fill = new Color_Fill();
                    //Цвет линии
                    myPath.Stroke = new SolidColorBrush(dlg_color.SelectedColor);
                    if (dlg_color_fill.ShowDialog() == true)
                    {
                        rectangle.Rect = new Rect(Convert.ToInt32(dlg.x_begin.Text),
                                                  Convert.ToInt32(dlg.y_begin.Text),
                                                  Convert.ToInt32(dlg.width_textbox.Text),
                                                  Convert.ToInt32(dlg.height_textbox.Text));
                        //цвет заливки
                        myPath.Fill = new SolidColorBrush
                                          (dlg_color_fill.SelectedColorFill);
                        myPath.Data = rectangle;
                        //добавление в canvas
                        canvas.Children.Add(myPath);
                    }
                }

                //толщина линии
                if (checkBox_StrokeThickness_0.IsChecked == true)
                {
                    myPath.StrokeThickness = 0;
                }
                else if (checkBox_StrokeThickness_1.IsChecked == true)
                {
                    myPath.StrokeThickness = 1;
                }
                else if (checkBox_StrokeThickness_2.IsChecked == true)
                {
                    myPath.StrokeThickness = 2;
                }
                else if (checkBox_StrokeThickness_3.IsChecked == true)
                {
                    myPath.StrokeThickness = 3;
                }
                else if (checkBox_StrokeThickness_4.IsChecked == true)
                {
                    myPath.StrokeThickness = 4;
                }
                else if (checkBox_StrokeThickness_5.IsChecked == true)
                {
                    myPath.StrokeThickness = 5;
                }
            }
        }
Exemplo n.º 2
0
        /*
         * Отрисовка круга
         */
        private void Draw_elipse(object sender, RoutedEventArgs e)
        {
            EllipseGeometry    myEllipseGeometry = new EllipseGeometry();
            Window_Draw_circle dlg = new Window_Draw_circle();

            if (dlg.ShowDialog() == true)
            {
                Color_Fill dlg_color_fill = new Color_Fill();
                myEllipseGeometry.Center = new Point(Convert.ToInt32
                                                         (dlg.x1_begin.Text), Convert.ToInt32(dlg.y1_begin.Text));
                myEllipseGeometry.RadiusX = Convert.ToInt32(dlg.x1_center.Text);
                myEllipseGeometry.RadiusY = Convert.ToInt32(dlg.y1_center.Text);
                Path    myPath    = new Path();
                Cololrs dlg_color = new Cololrs();
                if (dlg_color.ShowDialog() == true)
                {
                    //Цвет линии
                    myPath.Stroke = new System.Windows.Media.SolidColorBrush(
                        dlg_color.SelectedColor);
                    if (dlg_color_fill.ShowDialog() == true)
                    {
                        //координаты центра
                        myEllipseGeometry.Center = new Point(Convert.ToInt32
                                                                 (dlg.x1_begin.Text), Convert.ToInt32(dlg.y1_begin.Text));
                        //радиус x
                        myEllipseGeometry.RadiusX = Convert.ToInt32
                                                        (dlg.x1_center.Text);
                        //радиус y
                        myEllipseGeometry.RadiusY = Convert.ToInt32
                                                        (dlg.y1_center.Text);
                        myPath.Data = myEllipseGeometry;
                        //цвет заливки
                        myPath.Fill = new SolidColorBrush
                                          (dlg_color_fill.SelectedColorFill);
                        myPath.Data = myEllipseGeometry;
                        //добавление в canvas
                        canvas.Children.Add(myPath);
                    }
                }

                //толщина линии
                if (checkBox_StrokeThickness_0.IsChecked == true)
                {
                    myPath.StrokeThickness = 0;
                }
                else if (checkBox_StrokeThickness_1.IsChecked == true)
                {
                    myPath.StrokeThickness = 1;
                }
                else if (checkBox_StrokeThickness_2.IsChecked == true)
                {
                    myPath.StrokeThickness = 2;
                }
                else if (checkBox_StrokeThickness_3.IsChecked == true)
                {
                    myPath.StrokeThickness = 3;
                }
                else if (checkBox_StrokeThickness_4.IsChecked == true)
                {
                    myPath.StrokeThickness = 4;
                }
                else if (checkBox_StrokeThickness_5.IsChecked == true)
                {
                    myPath.StrokeThickness = 5;
                }
            }
        }