Exemplo n.º 1
0
        public MainWindow()
        {
            ProgramManager.InitializeProgram();
            InitializeComponent();

            canvasContainer.Screen = ProgramManager.ActiveScreen.Screen;

            ProgramManager.propGrid = PropertyGrid;

            TransformationsRoutedEventHandler transforEventHandlers = new TransformationsRoutedEventHandler(canvasContainer.Screen);

            imgRender = new ImageRender(ProgramManager.screens, 0);

            AddHandler(CanvasContentControl.MoveRoutedEvent, new RoutedEventHandler(transforEventHandlers.MoveEvent));

            AddHandler(MoveScaleAdornerVisual.MoveScaleRoutedEvent, new RoutedEventHandler(transforEventHandlers.ScaleEvent));

            AddHandler(RotateAdornerVisual.RotateRoutedEvent, new RoutedEventHandler(transforEventHandlers.RotateEvent));

            AddHandler(CanvasContentControl.MoveRoutedFinishEvent, new RoutedEventHandler(transforEventHandlers.MoveFinishEvent));

            AddHandler(RotateAdornerVisual.RotateFinishRoutedEvent, new RoutedEventHandler(transforEventHandlers.RotateFinishEvent));

            AddHandler(MoveScaleAdornerVisual.MoveScaleFinishRoutedEvent, new RoutedEventHandler(transforEventHandlers.ScaleFinishEvent));

            telas = new ObservableCollection <IScreen>();
            telas = (ObservableCollection <IScreen>)ProgramManager.screens;
        }
        public void MyCanvas_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            DependencyObject     parent;
            CanvasContentControl _MovedElementCCC = e.Source as CanvasContentControl;

            _MovedElement = e.Source as UIElement;
            parent        = VisualTreeHelper.GetParent(_MovedElement);



            if (e.Source == _myCanvas)
            {
                //   Console.WriteLine("here71");
                //  e.Handled = true;
                if (ProgramManager.AddingScreen == false)
                {
                    ProgramManager.ActiveScreen.Screen.UnselectAll();
                }
                //   e.Handled = true;
            }
            else
            {
                // ProgramManager.ActiveControl.ActiveControl =null;

                if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
                {
                    if (ProgramManager.ActiveScreen.Screen.GetActiveExist())
                    {
                        if (_MovedElementCCC.IsActiveCCC)
                        {
                            _MovedElementCCC.IsActiveCCC = true;
                        }
                    }

                    _MovedElementCCC.IsSelectedCCC = !_MovedElementCCC.IsSelectedCCC;

                    e.Handled = true;
                }
                else if (Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt))
                {
                    if (_MovedElementCCC.IsSelectedCCC == true)
                    {
                        if (ProgramManager.ActiveScreen.Screen.ActiveElement != null)
                        {
                            ProgramManager.ActiveScreen.Screen.ActiveElement.CanvasContetControlInstance.IsActiveCCC = false;
                        }


                        ProgramManager.ActiveScreen.Screen.ActiveElement = (SimpleTextImageElement)_MovedElementCCC.IContentFather;
                        _MovedElementCCC.IsActiveCCC = true;
                        //   ProgramManager.uptadePropertyGrid(ProgramManager.ActiveScreen.Screen.ActiveElement.elementData);

                        // Console.WriteLine("heeeeeereeee");
                        InstersecElementManager.update();

                        e.Handled = true;
                    }
                    else
                    {
                        ProgramManager.ActiveScreen.Screen.UnselectAll();
                        _MovedElementCCC.IsSelectedCCC = true;
                        _MovedElementCCC.IsActiveCCC   = true;
                        ProgramManager.ActiveScreen.Screen.ActiveElement = (SimpleTextImageElement)_MovedElementCCC.IContentFather;
                        //   ProgramManager.uptadePropertyGrid(ProgramManager.ActiveScreen.Screen.ActiveElement.elementData);
                        e.Handled = true;
                    }
                }
                else if (_MovedElementCCC.IsSelectedCCC == false)
                {
                    ProgramManager.ActiveScreen.Screen.UnselectAll();
                    _MovedElementCCC.IsSelectedCCC = true;
                    _MovedElementCCC.IsActiveCCC   = true;
                    ProgramManager.ActiveScreen.Screen.ActiveElement = (SimpleTextImageElement)_MovedElementCCC.IContentFather;
                    e.Handled = true;
                }

                _isDown = true;
                _myCanvas.CaptureMouse();
            }

            //ProgramManager.ActiveControl.ActiveControl = _MovedElementCCC.IContentFather;
            //if (e.ClickCount == 2)
            //{
            //    Console.WriteLine($"here73  {_MovedElementCCC.IsSelectedCCC} {_MovedElementCCC.GetHashCode()}");
            //    _MovedElementCCC.IsSelectedCCC = !_MovedElementCCC.IsSelectedCCC;
            //    ProgramManager.ActiveControl.ActiveControl = null;
            //    e.Handled=true;


            //}
            //else
            //{
            //    _isDown = true;
            // _myCanvas.CaptureMouse();
            //}
            //}
            //  Console.WriteLine($" active elementeeeee {ProgramManager.ActiveScreen.Screen.ActiveElement.elementData.Name}");
            ProgramManager.uptadePropertyGrid();
        }