Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- using FiguresLib;
- namespace Abstractus
- {
- /// <summary>
- /// Логика взаимодействия для Creator.xaml
- /// </summary>
- public partial class Creator : Window
- {
- public string typeFigure;
- public Creator()
- {
- var timer = new System.Timers.Timer();
- timer.Interval = 500;
- timer.Elapsed += OnTimeElapsed;
- timer.Start();
- InitializeComponent();
- StartSettings();
- Polsun.Value = 70;
- }
- public void ChoiceFigure(object sender, string typeFigure)
- {
- Button button = sender as Button;
- button.Effect = new System.Windows.Media.Effects.DropShadowEffect() { BlurRadius = 30, ShadowDepth = 0, Color = new Color { A = 100, B = 211, G = 0, R = 148 } };
- if (typeFigure == "circle")
- {
- Triangle_button.Effect = new System.Windows.Media.Effects.DropShadowEffect() { BlurRadius = 0, ShadowDepth = 0 };
- Square_button.Effect = new System.Windows.Media.Effects.DropShadowEffect() { BlurRadius = 0, ShadowDepth = 0 };
- }
- else if (typeFigure == "triangle")
- {
- Circle_button.Effect = new System.Windows.Media.Effects.DropShadowEffect() { BlurRadius = 0, ShadowDepth = 0 };
- Square_button.Effect = new System.Windows.Media.Effects.DropShadowEffect() { BlurRadius = 0, ShadowDepth = 0 };
- }
- else
- {
- Triangle_button.Effect = new System.Windows.Media.Effects.DropShadowEffect() { BlurRadius = 0, ShadowDepth = 0 };
- Circle_button.Effect = new System.Windows.Media.Effects.DropShadowEffect() { BlurRadius = 0, ShadowDepth = 0 };
- }
- }
- private void OnTimeElapsed(object sender, System.Timers.ElapsedEventArgs e)
- {
- TextHint.Dispatcher.Invoke(() =>
- {
- if (Triangle_button.AllowDrop == false && Square_button.AllowDrop == false && Circle_button.AllowDrop == false)
- {
- TextHint.Foreground = Brushes.RosyBrown;
- TextHint.Text = "Выберите фигуру, чтобы начать рисовать";
- }
- else if (Color_comboBox.SelectedIndex == -1) { TextHint.Foreground = Brushes.Coral; TextHint.Text = "Выберите цвет фигуры, чтобы начать рисовать"; }
- else { TextHint.Foreground = Brushes.OliveDrab; TextHint.Text = "Рисуйте!"; }
- });
- }
- private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- }
- private void ComboBox_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
- {
- }
- private void Button_Click_Triangle(object sender, RoutedEventArgs e)
- {
- <<<<<<< HEAD
- Triangle_button.AllowDrop = true;
- Square_button.AllowDrop = false;
- Circle_button.AllowDrop = false;
- //Square_button.IsEnabled = false;
- //Hexa_button.IsEnabled = false;
- //Octa_button.IsEnabled = false;
- //Triangle_button.IsEnabled = true;
- typeFigure = "Triangle";
- Triangle_button.Background = Brushes.Red;
- Square_button.Background = Brushes.White;
- Circle_button.Background = Brushes.White;
- =======
- string typefigure = "triangle";
- ChoiceFigure(sender, typefigure);
- >>>>>>> 73a877980900c1fd2503075fcea0f95f9c1e0cd2
- }
- private void Button_Click_Square(object sender, RoutedEventArgs e)
- {
- <<<<<<< HEAD
- Triangle_button.AllowDrop = false;
- Square_button.AllowDrop = true;
- Circle_button.AllowDrop = false;
- //Square_button.IsEnabled = true;
- //Hexa_button.IsEnabled = false;
- //Octa_button.IsEnabled = false;
- //Triangle_button.IsEnabled = false;
- typeFigure = "Square";
- Square_button.Background = Brushes.Red;
- Triangle_button.Background = Brushes.White;
- Circle_button.Background = Brushes.White;
- =======
- string typefigure = "square";
- ChoiceFigure(sender, typefigure);
- >>>>>>> 73a877980900c1fd2503075fcea0f95f9c1e0cd2
- }
- private void Button_Click_Circle(object sender, RoutedEventArgs e)
- {
- <<<<<<< HEAD
- Triangle_button.AllowDrop = false;
- Square_button.AllowDrop = false;
- Circle_button.AllowDrop = false;
- //Square_button.IsEnabled = false;
- //Hexa_button.IsEnabled = true;
- //Octa_button.IsEnabled = false;
- //Triangle_button.IsEnabled = false;
- typeFigure = "Hexa";
- Circle_button.Background = Brushes.White;
- Square_button.Background = Brushes.White;
- Triangle_button.Background = Brushes.White;
- }
- private void Button_Click_Octa(object sender, RoutedEventArgs e)
- {
- Triangle_button.AllowDrop = false;
- Square_button.AllowDrop = false;
- Circle_button.AllowDrop = true;
- //Square_button.IsEnabled = false;
- //Hexa_button.IsEnabled = false;
- //Octa_button.IsEnabled = true;
- //Triangle_button.IsEnabled = false;
- typeFigure = "Octa";
- Circle_button.Background = Brushes.Red;
- Square_button.Background = Brushes.White;
- Triangle_button.Background = Brushes.White;
- =======
- string typefigure = "circle";
- ChoiceFigure(sender, typefigure);
- >>>>>>> 73a877980900c1fd2503075fcea0f95f9c1e0cd2
- }
- private void StartSettings()
- {
- Canvas.SetZIndex(Settings_Canvas, 10);
- Canvas.SetZIndex(LeftRect, 2);
- Canvas.SetZIndex(RightRect, 2);
- Canvas.SetZIndex(UpRect, 2);
- Canvas.SetZIndex(DownRect, 2);
- Canvas.SetZIndex(PaintField_Canvas, 0);
- Canvas.SetZIndex(TextHint, 3);
- }
- private void AddFigure_button_Click(object sender, RoutedEventArgs e)
- {
- string selectButton;
- //foreach(Button button in Settings_Canvas.Children)
- //{
- // if(button.Background == Brushes.Red)
- // {
- // selectButton = button.Name;
- // }
- //}
- while (true)
- {
- Polygon triangle = new Polygon();
- Point point1 = new Point();
- point1.X = Mouse.GetPosition(this).X;
- point1.Y = Mouse.GetPosition(this).Y;
- Point point2 = new Point();
- point2.X = Mouse.GetPosition((this)).X - 25;
- point2.Y = Mouse.GetPosition(this).Y + 25 * Math.Sqrt(3);
- Point point3 = new Point();
- point3.X = Mouse.GetPosition((this)).X + 25;
- point3.Y = Mouse.GetPosition(this).Y + 25 * Math.Sqrt(3);
- PointCollection points = new PointCollection() { point1, point2, point3 };
- triangle.Points = points;
- triangle.Fill = Brushes.AliceBlue;
- triangle.Stroke = Brushes.Blue;
- if (Mouse.MouseDownEvent != null)
- {
- Settings_Canvas.Children.Add(triangle);
- }
- }
- //if (typeFigure == "Triangle")
- //{
- //}
- //else if(typeFigure == "Square")
- //{
- //}
- //else if(typeFigure == "Hexa")
- //{
- //}
- //else if(typeFigure == "Octa")
- //{
- //}
- }
- private void PaintField_Canvas_OnMouseMove(object sender, MouseEventArgs e)
- {
- if (e.MouseDevice.LeftButton == MouseButtonState.Pressed)
- {
- //PaintField_Canvas.Children.Add(new Line
- //{
- // X1 = e.GetPosition(PaintField_Canvas).X,
- // Y1 = e.GetPosition(PaintField_Canvas).Y,
- // X2 = e.GetPosition(PaintField_Canvas).X + 1,
- // Y2 = e.GetPosition(PaintField_Canvas).Y + 1,
- // StrokeStartLineCap = PenLineCap.Round,
- // StrokeEndLineCap = PenLineCap.Round,
- // StrokeThickness = 1,
- // Stroke = Brushes.Black
- //});
- //Ellipse el = new Ellipse();
- // el.Fill = Brushes.Black;
- // el.Width = 200;
- // el.Height = 200;
- // el.VerticalAlignment = VerticalAlignment.Center;
- // PaintField_Canvas.Children.Add(el);
- // el.Visibility = Visibility.Visible;
- }
- }
- private void PaintField_Canvas_MouseLeftButtonDown(object sender, MouseEventArgs e)
- {
- //Point mousePos = e.GetPosition(this);
- MyPoint mousePos = new MyPoint(e.GetPosition(this.PaintField_Canvas).X, e.GetPosition(this.PaintField_Canvas).Y);
- if (Circle_button.AllowDrop)
- {
- var circle = new Circle(mousePos,new Color() { A = 200, R = 0, G = 128, B = 128} , (int)Polsun.Value);
- Ellipse newEl = new Ellipse();
- newEl.Fill = new SolidColorBrush(circle.color);
- newEl.Width = circle.size;
- newEl.Height = circle.size;
- newEl.Margin = new Thickness(circle.mousePos.X - newEl.Width / 2, circle.mousePos.Y - newEl.Width / 2, 0, 0);
- PaintField_Canvas.Children.Add(newEl);
- Canvas.SetZIndex(newEl, 1);
- }
- else if(Square_button.AllowDrop)
- {
- var square = new Square(mousePos, new Color() { A = 128, R = 255, G = 128, B = 0 }, (int)Polsun.Value);
- Rectangle newEl = new Rectangle();
- newEl.Fill = new SolidColorBrush(square.color);
- newEl.Width = square.size;
- newEl.Height = square.size;
- newEl.Margin = new Thickness(square.mousePos.X - newEl.Width / 2, mousePos.Y - newEl.Width / 2, 0, 0);
- PaintField_Canvas.Children.Add(newEl);
- Canvas.SetZIndex(newEl, 1);
- }
- else if(Triangle_button.AllowDrop)
- {
- var triangle = new Triangle(mousePos, new Color() { A = 128, R = 128, G = 255, B = 0 }, (int)Polsun.Value);
- Polyline newEl = new Polyline();
- newEl.Fill = new SolidColorBrush(triangle.color);
- newEl.Margin = new Thickness(triangle.mousePos.X, mousePos.Y, 0, 0);
- newEl.Points = new PointCollection() { new Point(triangle.point1.X, triangle.point1.Y), new Point(triangle.point2.X, triangle.point2.Y), new Point(triangle.point3.X, triangle.point3.Y) };
- PaintField_Canvas.Children.Add(newEl);
- Canvas.SetZIndex(newEl, 1);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement