Exemplo n.º 1
0
        private void MyCanvas_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (ClikOnCanvas)
            {
                TreeTop.ToolNow.MouseUp(e.GetPosition(MyCanvas));

                if (!(TreeTop.ToolNow is AllotmentTool) & !(TreeTop.ToolNow is ZoomTool) & !(TreeTop.ToolNow is HandTool))
                {
                    TreeTop.AddState();
                    gotoPastCondition.IsEnabled   = true;
                    gotoSecondCondition.IsEnabled = false;
                }
                if (TreeTop.ToolNow is ZoomTool)
                {
                    MyCanvas.LayoutTransform = new ScaleTransform(TreeTop.ScaleRateX, TreeTop.ScaleRateY);
                    ScrollViewerCanvas.ScrollToVerticalOffset(TreeTop.DistanceToPointY * TreeTop.ScaleRateY);
                    ScrollViewerCanvas.ScrollToHorizontalOffset(TreeTop.DistanceToPointX * TreeTop.ScaleRateX);
                }
                if (TreeTop.ToolNow is HandForFigureTool)
                {
                    TreeTop.ToolNow = TreeTop.TransformTools["Allotment"];
                }
                ClikOnCanvas = false;
                Invalidate();
            }
        }
Exemplo n.º 2
0
 public MainWindow()
 {
     InitializeComponent();
     Instance = this;
     MyCanvas.Children.Add(Paint.TreeTop.FigureHost);
     ButtonGeneration.Generation();
     TreeTop.AddState();
 }
Exemplo n.º 3
0
 public void CleanMyCanvas(object sender, RoutedEventArgs e)
 {
     TreeTop.FigureHost.Children.Clear();
     TreeTop.Figures.Clear();
     TreeTop.ConditionNumber = 0;
     TreeTop.StatesCanvas.Clear();
     TreeTop.AddState();
     gotoPastCondition.IsEnabled   = false;
     gotoSecondCondition.IsEnabled = false;
 }
Exemplo n.º 4
0
 public void ChangeDash(object sender, RoutedEventArgs e)
 {
     foreach (Figure figure in TreeTop.Figures)
     {
         if (figure.Selected == true)
         {
             figure.ChangePen(TreeTop.TransformDashProp[(sender as System.Windows.Controls.Button).Content.ToString()], (sender as System.Windows.Controls.Button).Content.ToString());
         }
     }
     TreeTop.AddState();
     gotoPastCondition.IsEnabled   = true;
     gotoSecondCondition.IsEnabled = false;
     Invalidate();
 }
Exemplo n.º 5
0
 public void ClearSelectedFigure(object sender, RoutedEventArgs e)
 {
     foreach (Figure figure in TreeTop.Figures.ToArray())
     {
         if (figure.Selected == true)
         {
             TreeTop.Figures.Remove(figure);
         }
     }
     PropToolBarPanel.Children.Clear();
     TreeTop.AddState();
     gotoPastCondition.IsEnabled   = true;
     gotoSecondCondition.IsEnabled = false;
     Invalidate();
 }
Exemplo n.º 6
0
        private void LoadButton_Click(object sender, RoutedEventArgs e)
        {
            if (TreeTop.Figures.Count != 0)
            {
                DialogResult dialogResult = System.Windows.Forms.MessageBox.Show("Сохранить текущее изображение?", "", MessageBoxButtons.YesNo);
                if (dialogResult == System.Windows.Forms.DialogResult.Yes)
                {
                    SaveFileDialog sfd = new SaveFileDialog
                    {
                        Title           = "Сохранить как",
                        OverwritePrompt = true,
                        CheckPathExists = true,
                        Filter          = "Files(*.bin)|*.bin"
                    };
                    sfd.ShowDialog();
                    if (sfd.FileName != "")
                    {
                        FileStream      file = (FileStream)sfd.OpenFile();
                        BinaryFormatter bin  = new BinaryFormatter();
                        bin.Serialize(file, TreeTop.Figures);
                        file.Close();
                    }
                }
            }
            TreeTop.Figures.Clear();
            OpenFileDialog ofd = new OpenFileDialog
            {
                Filter = "Files(*.bin)|*.bin",
                Title  = "Открыть"
            };

            ofd.ShowDialog();
            if (ofd.FileName != "")
            {
                Stream          file         = (FileStream)ofd.OpenFile();
                BinaryFormatter deserializer = new BinaryFormatter();
                TreeTop.Figures = (List <Figure>)deserializer.Deserialize(file);
                file.Close();
                Invalidate();
            }
            TreeTop.StatesCanvas.Clear();
            TreeTop.ConditionNumber = 0;
            TreeTop.AddState();
            gotoPastCondition.IsEnabled   = false;
            gotoSecondCondition.IsEnabled = false;
        }
Exemplo n.º 7
0
 public void SldMouseUp(object sender, MouseButtonEventArgs e)
 {
     TreeTop.AddState();
     gotoPastCondition.IsEnabled   = true;
     gotoSecondCondition.IsEnabled = false;
 }