void Output_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Grid g = sender as Grid;

            if (e.ClickCount == 1 && g != null)
            {
                if (_currentConnectionLine == null && g.Children.Count > 0)
                {
                    ConnectionInfo ci = new ConnectionInfo();
                    ActionControl  ac = FindParent <ActionControl>(g);
                    Line           el = new Line();
                    el.RenderTransform = _translateTransform;
                    Point p = g.TranslatePoint(new Point(g.ActualWidth / 2, g.ActualHeight), dragCanvas);
                    el.X1                  = p.X - _translateTransform.X;
                    el.Y1                  = p.Y - _translateTransform.Y;
                    p                      = e.GetPosition(dragCanvas);
                    el.X2                  = p.X - _translateTransform.X;
                    el.Y2                  = p.Y - _translateTransform.Y;
                    el.Stroke              = (g.Children[0] as Label).Foreground;
                    el.Cursor              = Cursors.Pen;
                    el.StrokeThickness     = 2.0;
                    _currentConnectionLine = el;
                    dragCanvas.Children.Insert(0, el);
                    DragCanvas.SetCanBeDragged(el, false);
                    ci.ConnectionLine     = el;
                    ci.StartActionControl = ac;
                    ci.StartConnector     = g;
                    _connectionInfo.Add(ci);
                    el.MouseEnter += new MouseEventHandler(el_MouseEnter);
                    el.MouseLeave += new MouseEventHandler(el_MouseLeave);
                    el.ContextMenu = itemContextMenu;

                    Label lb = new Label();
                    ci.Label      = lb;
                    lb.FontWeight = FontWeights.Bold;
                    lb.Background = new SolidColorBrush(Colors.LightGray);
                    if (_showConnectionLabels)
                    {
                        lb.Visibility = System.Windows.Visibility.Visible;
                    }
                    else
                    {
                        lb.Visibility = System.Windows.Visibility.Hidden;
                    }
                    lb.RenderTransform = _translateTransform;
                    dragCanvas.Children.Insert(0, lb);
                    DragCanvas.SetCanBeDragged(lb, false);
                    el.LayoutUpdated += new EventHandler(el_LayoutUpdated);
                    PositionConnectionLineLabel(ci);
                }
                else
                {
                    dragCanvas.Children.Remove(_currentConnectionLine);
                    ConnectionInfo ci = (from c in _connectionInfo where c.ConnectionLine == _currentConnectionLine select c).FirstOrDefault();
                    _connectionInfo.Remove(ci);
                    dragCanvas.Children.Remove(ci.Label);
                    _currentConnectionLine = null;
                }
            }
        }
        public void AddActionControl(ActionImplementation actImpl)
        {
            if (actImpl.Location.X == 0 && actImpl.Location.Y == 0)
            {
                actImpl.Location = new Point(-_translateTransform.X, -_translateTransform.Y);
            }
            ActionControl ac = new ActionControl();

            Canvas.SetLeft(ac, actImpl.Location.X);
            Canvas.SetTop(ac, actImpl.Location.Y);
            ac.ActionImplementation = actImpl;
            actImpl.UIActionControl = ac;
            dragCanvas.Children.Add(ac);
            ac.PreviewMouseRightButtonDown += UserControl_PreviewMouseRightButtonDown;
            DragCanvas.SetCanBeDragged(ac, false);

            ac.Equal.MouseDown        += new MouseButtonEventHandler(Output_MouseDown);
            ac.Smaller.MouseDown      += new MouseButtonEventHandler(Output_MouseDown);
            ac.SmallerEqual.MouseDown += new MouseButtonEventHandler(Output_MouseDown);
            ac.Larger.MouseDown       += new MouseButtonEventHandler(Output_MouseDown);
            ac.LargerEqual.MouseDown  += new MouseButtonEventHandler(Output_MouseDown);
            ac.NotEqual.MouseDown     += new MouseButtonEventHandler(Output_MouseDown);
            ac.EntryPoint.MouseDown   += new MouseButtonEventHandler(EntryPoint_MouseDown);
            ac.LayoutUpdated          += new EventHandler(ac_LayoutUpdated);
            ac.MouseEnter             += new MouseEventHandler(ac_MouseEnter);
            ac.MouseLeave             += new MouseEventHandler(ac_MouseLeave);

            ac.RenderTransform = _translateTransform;

            if (!(actImpl is ActionStart))
            {
                ac.ContextMenu = itemContextMenu;
            }
        }
Esempio n. 3
0
 public NImageCropper()
 {
     InitializeComponent();
     //this.Unloaded += new RoutedEventHandler(UcImageCropper_Unloaded);
     selectCanvForImg            = new SelectionCanvas();
     selectCanvForImg.CropImage += new RoutedEventHandler(selectCanvForImg_CropImage);
     dragCanvasForImg            = new DragCanvas();
 }
Esempio n. 4
0
        void AddFormatOptions()
        {
            dataRecodingControl             = new DataRecodingControl(dashboardHelper);
            dataRecodingControl.MouseEnter += new MouseEventHandler(dataRecodingControl_MouseEnter);
            dataRecodingControl.MouseLeave += new MouseEventHandler(dataRecodingControl_MouseLeave);
            dataRecodingControl.Loaded     += new RoutedEventHandler(dataRecodingControl_Loaded);
            MapContainer.Children.Add(dataRecodingControl);

            DragCanvas.SetCanBeDragged(dataRecodingControl, false);
        }
Esempio n. 5
0
        void AddSelectionCriteria()
        {
            dataFilteringControl             = new DataFilteringControl(dashboardHelper);
            dataFilteringControl.MouseEnter += new MouseEventHandler(selectionCriteriaControl_MouseEnter);
            dataFilteringControl.MouseLeave += new MouseEventHandler(selectionCriteriaControl_MouseLeave);
            dataFilteringControl.SelectionCriteriaChanged += new EventHandler(selectionCriteriaControl_SelectionCriteriaChanged);
            dataFilteringControl.Loaded += new RoutedEventHandler(dataFilteringControl_Loaded);
            MapContainer.Children.Add(dataFilteringControl);

            DragCanvas.SetCanBeDragged(dataFilteringControl, false);
        }
        private void addConnector(ActionImplementation a, ActionImplementation c, Grid g)
        {
            ConnectionInfo ci = new ConnectionInfo();

            ci.StartActionControl = a.UIActionControl;
            ci.StartConnector     = g;
            ci.EndActionControl   = c.UIActionControl;
            ci.EndConnector       = c.UIActionControl.EntryPoint;

            Line el = new Line();

            el.Cursor          = Cursors.Pen;
            el.RenderTransform = _translateTransform;
            Point p = g.TranslatePoint(new Point(g.ActualWidth / 2, g.ActualHeight), dragCanvas);

            el.X1              = p.X;
            el.Y1              = p.Y;
            p                  = c.UIActionControl.EntryPoint.TranslatePoint(new Point(c.UIActionControl.EntryPoint.ActualWidth / 2, c.UIActionControl.EntryPoint.ActualHeight), dragCanvas);
            el.X2              = p.X;
            el.Y2              = p.Y;
            el.Stroke          = (g.Children[0] as Label).Foreground;
            el.StrokeThickness = 2.0;
            dragCanvas.Children.Insert(0, el);
            DragCanvas.SetCanBeDragged(el, false);
            ci.ConnectionLine = el;
            _connectionInfo.Add(ci);
            el.MouseEnter += new MouseEventHandler(el_MouseEnter);
            el.MouseLeave += new MouseEventHandler(el_MouseLeave);
            el.ContextMenu = itemContextMenu;

            Label lb = new Label();

            ci.Label      = lb;
            lb.FontWeight = FontWeights.Bold;
            lb.Background = new SolidColorBrush(Colors.LightGray);
            if (_showConnectionLabels)
            {
                lb.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                lb.Visibility = System.Windows.Visibility.Hidden;
            }
            lb.RenderTransform = _translateTransform;
            dragCanvas.Children.Add(lb);
            DragCanvas.SetCanBeDragged(lb, false);
            el.LayoutUpdated += new EventHandler(el_LayoutUpdated);
            PositionConnectionLineLabel(ci);
        }
Esempio n. 7
0
        public TabItem Add(string id, string header)
        {
            var ellipse = new Ellipse {
                Fill = Brushes.Green, Width = 30.0, Height = 30.0
            };
            var canvas = new DragCanvas {
                Name = "canvas_" + id
            };
            var ti = new TabItem {
                Name = "tab_" + id, Header = header, Content = canvas
            };
            var tci = new TabCanvasItem(ti, canvas);

            mw.tcDraw.Items.Add(ti);
            tabs.Add(id, tci);
            return(ti);
        }
        /// <summary>
        /// Dragdrop operation for new module object starts from here
        /// </summary>
        /// <param name="module"></param>
        /// <param name="rootCanvas"></param>
        private void CreateModuleObject(BaseModule module)
        {
            //Canvas rootCanvas = (Canvas)FindName("RootCanvas");
            DragCanvas rootCanvas = (DragCanvas)FindName("RootCanvas");

            logger.Trace($"Creating module object of Type: {module.GetType()}");

            //New module creation starts from hee
            var newModule = ((App)App.Current).CreateModule(module.GetType());

            logger.Trace("Creating CanvasModule for module object {0}", newModule.DisplayName);

            var canvasModule = new CanvasModule(((BaseModule)newModule));

            rootCanvas.Children.Add(canvasModule);
            canvasModule.Parent2 = rootCanvas;
        }
Esempio n. 9
0
        internal string GenerateControlName(UIElement element, DragCanvas DgRoot)
        {
            if (DgRoot.FindName(element.ToString().Substring(5)) != null)
            {
                for (int i = 0; i < 100; i++)
                {
                    if (DgRoot.FindName(element.ToString().Substring(5) + i) != null)
                    {
                        continue;
                    }
                    else
                    {
                        return(element.ToString().Substring(5) + i);
                    }
                }
            }
            else
            {
                return(element.ToString().Substring(5));
            }

            return("");
        }
 private void AssociatedObject_TouchLeave(object sender, TouchEventArgs e)
 {
     if (DragOverlay == null)
     {
         var visual = e.OriginalSource as Visual;
         DragOverlay = (DragCanvas)UIElementDragBehavior.FindAncestor(typeof(DragCanvas), visual);
     }
     if (isTouchDown && DragOverlay != null)
     {
         TouchPoint touchPosition = e.GetTouchPoint(DragOverlay);
         if (touchPosition != null)
         {
             Point            initialPoint   = new Point(touchPosition.Position.X, touchPosition.Position.Y);
             FrameworkElement adornedElement = sender as FrameworkElement;
             if (initialPoint != null && adornedElement != null)
             {
                 ConstructGhostAdornerWithHandlers(initialPoint, adornedElement, e);
                 using (TableSubject subject = adornedElement.DataContext as TableSubject)
                     GlobalData.GetInstance().Logger?.AddEntry(entry: "Drag_Galaxy", subjectId: subject?.Id);
             }
         }
     }
     isTouchDown = false;
 }
Esempio n. 11
0
 private void workBench_OnLoaded(object sender, RoutedEventArgs e)
 {
     workBench = sender as DragCanvas;
     workBench.owningWorkspace = this;
 }
Esempio n. 12
0
 public CanvasManager(DragCanvas canvas)
 {
     Canvas = canvas;
 }
Esempio n. 13
0
 public CircuitItem(DragCanvas dc, T item)
 {
     this.item = item;
     Canvas    = new Canvas();
     dc.Children.Add(Canvas);
 }
Esempio n. 14
0
 private void Grid_MouseEnter_1(object sender, MouseEventArgs e)
 {
     DragCanvas.SetCanBeDragged(this, true);
 }
Esempio n. 15
0
 private void Grid_MouseLeave_1(object sender, MouseEventArgs e)
 {
     DragCanvas.SetCanBeDragged(this, false);
 }
Esempio n. 16
0
 public TabCanvasItem(TabItem tabItem, DragCanvas canvas)
 {
     TabItem = tabItem;
     Canvas  = canvas;
 }
Esempio n. 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GadgetManager" /> class.
 /// </summary>
 public GadgetManager(DragCanvas dragCanvas)
 {
     //    CompositionInitializer.SatisfyImports(this);
     this.gadgetParent = dragCanvas;
 }