コード例 #1
0
        private void LoadButton_Click(object sender, RoutedEventArgs e)
        {
            NotArtist.Figures.Clear();
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Files(*.bin)|*.bin";
            ofd.Title  = "Открыть";
            ofd.ShowDialog();
            if (ofd.FileName != "")
            {
                Stream          file         = (FileStream)ofd.OpenFile();
                BinaryFormatter deserializer = new BinaryFormatter();
                NotArtist.Figures = (List <Figure>)deserializer.Deserialize(file);
                file.Close();
                Invalidate();
            }
            NotArtist.ConditionsCanvas.Clear();
            NotArtist.ConditionNumber = 0;
            NotArtist.AddCondition();
            gotoPastCondition.IsEnabled   = false;
            gotoSecondCondition.IsEnabled = false;
            saveConditionNumber           = NotArtist.ConditionNumber;
            isSave             = true;
            SaveButton.Content = "Save";
            PropToolBarPanel.Children.Clear();
        }
コード例 #2
0
 public void SldMouseUp(object sender, MouseButtonEventArgs e)
 {
     NotArtist.AddCondition();
     gotoPastCondition.IsEnabled   = true;
     gotoSecondCondition.IsEnabled = false;
     SaveButton.Content            = "Save*";
 }
コード例 #3
0
        private void MyCanvas_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (ClickOnCanvas)
            {
                NotArtist.SelectedTool.MouseUp(e.GetPosition(MyCanvas));

                if (NotArtist.SelectedTool != NotArtist.ToolsList["Allotment"] & NotArtist.SelectedTool != NotArtist.ToolsList["Zoom"] & NotArtist.SelectedTool != NotArtist.ToolsList["Hand"])
                {
                    NotArtist.AddCondition();
                    gotoPastCondition.IsEnabled   = true;
                    gotoSecondCondition.IsEnabled = false;
                    SaveButton.Content            = "Save*";
                }
                if (NotArtist.SelectedTool == NotArtist.ToolsList["Zoom"])
                {
                    MyCanvas.LayoutTransform = new ScaleTransform(NotArtist.ScaleRateX, NotArtist.ScaleRateY);
                    ScrollViewerCanvas.ScrollToVerticalOffset(NotArtist.DistanceToPointY * NotArtist.ScaleRateY);
                    ScrollViewerCanvas.ScrollToHorizontalOffset(NotArtist.DistanceToPointX * NotArtist.ScaleRateX);
                }
                if (NotArtist.SelectedTool == NotArtist.HandTool)
                {
                    NotArtist.SelectedTool = NotArtist.ToolsList["Allotment"];
                }
                ClickOnCanvas = false;
                Invalidate();
            }
        }
コード例 #4
0
 public MainWindow()
 {
     InitializeComponent();
     Instance = this;
     MyCanvas.Children.Add(NotArtist.FigureHost);
     ButtonsGenerations.Generation();
     NotArtist.AddCondition();
 }
コード例 #5
0
        private void MyCanvas_KeyDown(object sender, KeyEventArgs e)
        {
            base.OnKeyDown(e);
            if (e.Key == Key.C)
            {
                BufList.Clear();
                for (int i = 0, k = NotArtist.Figures.Count; i < k; i++)
                {
                    if (NotArtist.Figures[i].Select)
                    {
                        BufList.Add(NotArtist.Figures[i]);
                    }
                }
            }

            if (e.Key == Key.V)
            {
                int pointsCount = 0;
                var v           = new Vector();
                foreach (var figure in BufList)
                {
                    foreach (var point in figure.coordinates)
                    {
                        pointsCount++;
                        v.X += point.X;
                        v.Y += point.Y;
                    }
                }
                v.X = v.X / pointsCount;
                v.Y = v.Y / pointsCount;
                v  -= (Vector)Mouse.GetPosition(MyCanvas);

                for (var i = 0; i < BufList.Count; i++)
                {
                    var cloneObj = BufList[i].Clone();
                    for (var j = 0; j < cloneObj.coordinates.Count; j++)
                    {
                        cloneObj.coordinates[j] -= v;
                    }
                    NotArtist.Figures.Add(cloneObj);
                }

                for (int i = 0, k = NotArtist.Figures.Count; i < k; i++)
                {
                    if (NotArtist.Figures[i].Select)
                    {
                        NotArtist.Figures[i].UnSelected();
                    }
                }
                PropToolBarPanel.Children.Clear();
                NotArtist.AddCondition();
                gotoPastCondition.IsEnabled   = true;
                gotoSecondCondition.IsEnabled = false;
                SaveButton.Content            = "Save*";
                Invalidate();
            }
        }
コード例 #6
0
 public void CleanMyCanvas(object sender, RoutedEventArgs e)
 {
     NotArtist.FigureHost.Children.Clear();
     NotArtist.Figures.Clear();
     NotArtist.ConditionNumber = 0;
     NotArtist.ConditionsCanvas.Clear();
     NotArtist.AddCondition();
     gotoPastCondition.IsEnabled   = false;
     gotoSecondCondition.IsEnabled = false;
     SaveButton.Content            = "Save";
 }
コード例 #7
0
 public void ChangeDash(object sender, RoutedEventArgs e)
 {
     foreach (Figure figure in NotArtist.Figures)
     {
         if (figure.Select)
         {
             figure.ChangePen(NotArtist.TransformDashProp[(sender as Button).Content.ToString()], (sender as System.Windows.Controls.Button).Content.ToString());
         }
     }
     NotArtist.AddCondition();
     gotoPastCondition.IsEnabled   = true;
     gotoSecondCondition.IsEnabled = false;
     SaveButton.Content            = "Save*";
     Invalidate();
 }
コード例 #8
0
 public void changeRoundY(object sender, RoutedPropertyChangedEventArgs <double> e)
 {
     foreach (Figure figure in NotArtist.Figures)
     {
         if (figure.Select)
         {
             figure.ChangeRoundY(e.NewValue);
         }
     }
     NotArtist.AddCondition();
     gotoPastCondition.IsEnabled   = true;
     gotoSecondCondition.IsEnabled = false;
     SaveButton.Content            = "Save*";
     Invalidate();
 }
コード例 #9
0
ファイル: MainWindow.xaml.cs プロジェクト: Syzygia/Graff
 private void MainCanvasMouseUp(object sender, MouseButtonEventArgs e)
 {
     if (NotArtist.SelectedTool != NotArtist.Tools[6])
     {
         NotArtist.AddCondition();
     }
     NotArtist.SelectedTool.MouseUp(e.GetPosition(MainCanvas));
     if (NotArtist.SelectedTool == NotArtist.Tools[6])
     {
         MainCanvas.LayoutTransform = new ScaleTransform(NotArtist.ScaleRate, NotArtist.ScaleRate);
         ScrollViewerCanvas.ScrollToVerticalOffset(NotArtist.DistanceToPointY * NotArtist.ScaleRate);
         ScrollViewerCanvas.ScrollToHorizontalOffset(NotArtist.DistanceToPointX * NotArtist.ScaleRate);
     }
     Invalidate();
 }
コード例 #10
0
 public void ClearSelectedFigure(object sender, RoutedEventArgs e)
 {
     foreach (Figure figure in NotArtist.Figures.ToArray())
     {
         if (figure.Select)
         {
             NotArtist.Figures.Remove(figure);
         }
     }
     PropToolBarPanel.Children.Clear();
     NotArtist.AddCondition();
     gotoPastCondition.IsEnabled   = true;
     gotoSecondCondition.IsEnabled = false;
     SaveButton.Content            = "Save*";
     Invalidate();
 }
コード例 #11
0
 private void gotoSecondCondition_Click(object sender, RoutedEventArgs e)
 {
     NotArtist.gotoSecondCondition();
     if (NotArtist.ConditionNumber == NotArtist.ConditionsCanvas.Count)
     {
         gotoSecondCondition.IsEnabled = false;
     }
     gotoPastCondition.IsEnabled = true;
     Invalidate();
     if (isSave && (saveConditionNumber == NotArtist.ConditionNumber))
     {
         SaveButton.Content = "Save";
     }
     else
     {
         SaveButton.Content = "Save*";
     }
 }
コード例 #12
0
        public void DecZIndex(object sender, RoutedEventArgs e)
        {
            var i = 0;

            foreach (Figure figure in NotArtist.Figures.ToArray())
            {
                if ((!figure.Equals(NotArtist.Figures[0])) && (figure.Select))
                {
                    var buf = NotArtist.Figures[i];
                    NotArtist.Figures[i]     = NotArtist.Figures[i - 1];
                    NotArtist.Figures[i - 1] = buf;
                }
                i++;
            }
            NotArtist.AddCondition();
            gotoPastCondition.IsEnabled   = true;
            gotoSecondCondition.IsEnabled = false;
            SaveButton.Content            = "Save*";
            Invalidate();
        }
コード例 #13
0
ファイル: MainWindow.xaml.cs プロジェクト: Syzygia/Graff
        public MainWindow()
        {
            appWindow = this;
            InitializeComponent();
            pathBox.Text = AppDomain.CurrentDomain.BaseDirectory;
            NotArtist.AddCondition();
            MainCanvas.Children.Add(NotArtist.FgtHost);
            for (int i = 0; i < NotArtist.Tools.Count - 1; i++)//Creating Tool button
            {
                string      st  = "../icons/" + NotArtist.Tools[i].GetType().Name + ".png";
                ImageBrush  img = new ImageBrush();
                BitmapImage bi3 = new BitmapImage();
                bi3.BeginInit();
                bi3.UriSource = new Uri(st, UriKind.Relative);
                bi3.EndInit();
                img.ImageSource = bi3;
                Button btn = new Button();
                Panel.Children.Add(btn);
                btn.BorderBrush = Brushes.Black;
                btn.Name        = "btn" + i;
                btn.Height      = 30;
                btn.Width       = 40;
                btn.SetValue(Grid.RowProperty, 1);
                btn.SetValue(Grid.ColumnProperty, i);
                btn.Background          = img;
                btn.Content             = "";
                btn.Tag                 = i;
                btn.HorizontalAlignment = HorizontalAlignment.Left;
                btn.Click              += new RoutedEventHandler(Tool_Click);
            }
            Brush[] colors =                //palitte
            {
                Brushes.Crimson, Brushes.Maroon,    Brushes.DeepPink, Brushes.DarkOrange, Brushes.Yellow, Brushes.Fuchsia, Brushes.BlueViolet, Brushes.Indigo, Brushes.Lime, Brushes.Teal,
                Brushes.Aqua,    Brushes.LightCyan, Brushes.Blue,     Brushes.Navy,       Brushes.Ivory,  Brushes.Black,
            };
            int j = 0;

            foreach (var brush in colors)    //button of palette (fill color)
            {
                Button newButton = new Button()
                {
                    Width      = 20,
                    Height     = 20,
                    Background = brush,
                    Tag        = brush
                };
                newButton.SetValue(Grid.RowProperty, j);
                newButton.SetValue(Grid.ColumnProperty, 1);
                j++;
                newButton.Click += new RoutedEventHandler(ButtonFill_Click);
                Palette.Children.Add(newButton);
            }
            j = 0;
            foreach (var brush in colors)     //button of palette (line collor)
            {
                Button newButton = new Button()
                {
                    Width      = 20,
                    Height     = 20,
                    Background = brush,
                    Tag        = brush
                };
                newButton.SetValue(Grid.ColumnProperty, 0);
                newButton.SetValue(Grid.RowProperty, j);
                j++;
                newButton.Click += new RoutedEventHandler(ButtonLine_Click);
                Palette.Children.Add(newButton);
            }
        }
コード例 #14
0
ファイル: MainWindow.xaml.cs プロジェクト: Syzygia/Graff
 private void GotoFuture(object sender, RoutedEventArgs e)
 {
     NotArtist.GotoSecondCondition();
     Invalidate();
 }
コード例 #15
0
ファイル: MainWindow.xaml.cs プロジェクト: Syzygia/Graff
        private void Goto_Past(object sender, RoutedEventArgs e)
        {
            NotArtist.GotoPastCondition();

            Invalidate();
        }