Example #1
0
        static void AddNewObject(DrawingCanvas drawingCanvas, FaceElement element)
        {
            HelperFunctions.UnselectAll(drawingCanvas);

            element.IsSelected = true;
            drawingCanvas.ElementsList.Add(element);
        }
Example #2
0
        private void lstViewVdl_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListViewItem selecteditem = (ListViewItem)lstViewVdl.SelectedItem;
            FaceElement  f            = null;

            for (int i = 0; i < drawingSurface.Count; i++)
            {
                if (drawingSurface[i].Info == (string)lstViewVdl.Tag)
                {
                    f         = drawingSurface[i];
                    f.Meaning = Autoprofile.Properties.Resources.ResourceManager.GetString("Vdl" + lstViewVdl.SelectedIndex);
                }
            }

            if (f != null)
            {
                Image selectedImage = (Image)selecteditem.Content;
                f.Fill = new ImageBrush(selectedImage.Source);
                HelperFunctions.UnselectAll(drawingSurface);
                f.IsSelected = true;
            }
            else
            {
                AddNewObject(drawingSurface, new FaceElement(120, 120, 230, 210, 2, Colors.Blue, new ImageBrush(((Image)selecteditem.Content).Source), (string)lstViewVdl.Tag, Autoprofile.Properties.Resources.ResourceManager.GetString("Vdl" + lstViewVdl.SelectedIndex)));
            }

            if (drawingSurface.Count == 5)
            {
                OKBtn.IsEnabled = true;
            }
        }
Example #3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            FaceElement f      = null;
            string      result = null;

            for (int i = 0; i < drawingSurface.Count; i++)
            {
                f      = drawingSurface[i];
                result = result + f.Meaning + "\n" + "\n";
            }
            Autoprofile.Analysis_Window window = new Autoprofile.Analysis_Window();
            Run txtrun = new Run();

            txtrun.Text = result;
            window.report.Inlines.Add(txtrun);
            window.Owner = this;
            window.ShowDialog();
        }
Example #4
0
        private void DrawingCanvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (!drawingSurface.IsMouseCaptured)
            {
                drawingSurface.Cursor = HelperFunctions.DefaultCursor;
                selectMode            = SelectionMode.None;
                return;
            }

            if (resizedObject != null)
            {
                resizedObject = null;
            }

            drawingSurface.ReleaseMouseCapture();
            drawingSurface.Cursor = HelperFunctions.DefaultCursor;
            selectMode            = SelectionMode.None;
        }
Example #5
0
        private void Canvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (!Canvas.IsMouseCaptured)
            {
                Canvas.Cursor = HelperFunctions.DefaultCursor;
                selectMode    = SelectionMode.None;
                return;
            }

            if (resizedObject != null)
            {
                resizedObject = null;
            }

            Canvas.ReleaseMouseCapture();
            Canvas.Cursor       = HelperFunctions.DefaultCursor;
            selectMode          = SelectionMode.None;
            btnOK.IsEnabled     = true;
            btnCancel.IsEnabled = true;
            cropBtn.IsEnabled   = false;
        }
Example #6
0
        private void DrawingCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Point ptClicked = e.GetPosition(drawingSurface);

            selectMode = SelectionMode.None;
            FaceElement o;
            FaceElement movedObject = null;
            int         handleNumber;

            // Test for resizing (only if control is selected, cursor is on the handle)
            for (int i = drawingSurface.ElementsList.Count - 1; i >= 0; i--)
            {
                o = drawingSurface[i];

                if (o.IsSelected)
                {
                    handleNumber = o.MakeHitTest(ptClicked);

                    if (handleNumber > 0)
                    {
                        selectMode = SelectionMode.Resize;

                        // keep resized object in class member
                        resizedObject       = o;
                        resizedObjectHandle = handleNumber;

                        // Since we want to resize only one object, unselect all other objects
                        HelperFunctions.UnselectAll(drawingSurface);
                        o.IsSelected = true;

                        break;
                    }
                }
            }

            // Test for move (cursor is on the object)
            if (selectMode == SelectionMode.None)
            {
                for (int i = drawingSurface.ElementsList.Count - 1; i >= 0; i--)
                {
                    o = drawingSurface[i];

                    if (o.MakeHitTest(ptClicked) == 0)
                    {
                        movedObject = o;
                        break;
                    }
                }

                if (movedObject != null)
                {
                    selectMode = SelectionMode.Move;

                    // Unselect all if Ctrl is not pressed and clicked object is not selected yet
                    if (!movedObject.IsSelected)
                    {
                        HelperFunctions.UnselectAll(drawingSurface);
                    }

                    // Select clicked object
                    movedObject.IsSelected = true;

                    // Set move cursor
                    drawingSurface.Cursor = Cursors.SizeAll;
                }
            }

            lastPoint = ptClicked;

            // Capture mouse until MouseUp event is received
            drawingSurface.CaptureMouse();
        }
Example #7
0
        private void Canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Point ptClicked = e.GetPosition(Canvas);

            selectMode = SelectionMode.None;
            FaceElement o;
            FaceElement movedObject = null;
            int         handleNumber;

            if (cropBtn.IsChecked == true)
            {
                AddNewObject(Canvas, new FaceElement(ptClicked.X, ptClicked.Y, ptClicked.X + 1, ptClicked.Y + 1, 2, Colors.Blue, null));
                cropBtn.IsChecked = false;
            }

            // Test for resizing (only if control is selected, cursor is on the handle)
            for (int i = Canvas.ElementsList.Count - 1; i >= 0; i--)
            {
                o = Canvas[i];

                if (o.IsSelected)
                {
                    handleNumber = o.MakeHitTest(ptClicked);

                    if (handleNumber > 0)
                    {
                        selectMode = SelectionMode.Resize;

                        // keep resized object in class member
                        resizedObject       = o;
                        resizedObjectHandle = handleNumber;

                        o.IsSelected = true;

                        break;
                    }
                }
            }

            // Test for move (cursor is on the object)
            if (selectMode == SelectionMode.None)
            {
                for (int i = Canvas.ElementsList.Count - 1; i >= 0; i--)
                {
                    o = Canvas[i];

                    if (o.MakeHitTest(ptClicked) == 0)
                    {
                        movedObject = o;
                        break;
                    }
                }

                if (movedObject != null)
                {
                    selectMode = SelectionMode.Move;

                    // Select clicked object
                    movedObject.IsSelected = true;

                    // Set move cursor
                    Canvas.Cursor = Cursors.SizeAll;
                }
            }

            lastPoint = ptClicked;

            // Capture mouse until MouseUp event is received
            Canvas.CaptureMouse();
        }
Example #8
0
 static void AddNewObject(DrawingCanvas drawingCanvas, FaceElement element)
 {
     element.IsSelected = true;
     drawingCanvas.ElementsList.Add(element);
     drawingCanvas.CaptureMouse();
 }