protected override void OnMouseUp(MouseButtonEventArgs e)
        {
            //logger.Info("Entered");
            base.OnMouseUp(e);

            var window = (MainWindow)Window.GetWindow(this);

            if (DragModule == null)
            {
                return;
            }

            CanvasModule module = DragModule;

            Children.Remove(DragModule);

            if (window.TabControl.SelectedItem == null)
            {
                return;
            }

            // Modules are only allowed to be dropped on the workflow canvas
            // So if it's not being dropped there, let it fall out of scope
            var tabController = (TabControl)window.FindName("TabControl");
            var wfCanvas      = ((WorkflowScrollViewer)tabController.SelectedContent).ChildCanvas;

            if (VisualHelper.IsMouseOver(wfCanvas, this))
            {
                wfCanvas.Children.Add(module);
            }
            //logger.Info("Leaving");
        }
示例#2
0
        /// <summary>
        /// Sets the canvas module position relative to this canvas instance.
        /// </summary>
        /// <param name="module">The child module to move.</param>
        /// <param name="pos">The relative position.</param>
        public void SetCanvasModulePos(CanvasModule module, Point pos)
        {
            Rect viewport = VisualHelper.GetBoundingBox(this);
            Rect bbox     = VisualHelper.GetBoundingBox(module);

            if (bbox.BottomRight.Y + pos.Y > viewport.Bottom)
            {
                pos.Y = viewport.Bottom - bbox.Bottom;
            }

            if (bbox.BottomRight.X + pos.X > viewport.Right)
            {
                pos.X = viewport.Right - bbox.Right;
            }

            if (pos.Y < 0)
            {
                pos.Y = 0;
            }
            if (pos.X < 0)
            {
                pos.X = 0;
            }

            // logger.Trace($"Setting Module_Position ({pos.X},{pos.Y}) Module= {module.DisplayName}");
            SetLeft(module, pos.X);
            SetTop(module, pos.Y);
            SetZIndex(module, 1);
        }
示例#3
0
 private void OnConnectedModuleMove(CanvasModule module)
 {
     foreach (var connection in Connections)
     {
         if (connection.ContainsModuleVisual(module))
         {
             RedrawLine(connection);
         }
     }
 }
示例#4
0
        public void ReadXml(XmlReader reader)
        {
            if (reader.Name != "WorkflowCanvas")
            {
                reader.ReadToFollowing("WorkflowCanvas");
            }

            XmlInProgress = true;

            double zoom = double.Parse(reader.GetAttribute("Zoom"));

            // CanvasModules
            reader.ReadToDescendant("CanvasModules");

            var moduleParent = reader.ReadSubtree();

            moduleParent.MoveToContent();

            XElement xModules = XElement.ReadFrom(moduleParent) as XElement;

            int count = int.Parse(xModules.Attribute("Count").Value);

            foreach (var xCanvasModule in xModules.XPathSelectElements("//CanvasModule"))
            {
                logger.Trace("Loading canvas_module {0}", xCanvasModule.Attribute("Name").Value);
                CanvasModule module = new CanvasModule();
                module.ReadXml(xCanvasModule.CreateReader());
                Children.Add(module);
            }

            reader.Skip();
            // Connections
            if (reader.IsStartElement("Connections"))
            {
                count = int.Parse(reader.GetAttribute("Count"));
                if (count > 0)
                {
                    reader.ReadStartElement();
                    for (int i = 0; i < count; i++)
                    {
                        AddConnectionFromXml(Connection.ReadXml(reader));
                        reader.ReadEndElement();
                    }
                    reader.Skip();
                }
                else
                {
                    reader.Skip();
                }
            }
            ScaleTransform scale = LayoutTransform as ScaleTransform;

            scale.ScaleX = zoom;
            scale.ScaleY = zoom;
        }
示例#5
0
 public bool ContainsModuleVisual(CanvasModule canvasModule)
 {
     if (Start.Parent == canvasModule)
     {
         return(true);
     }
     else if (End.Parent == canvasModule)
     {
         return(true);
     }
     return(false);
 }
示例#6
0
        private void OnRemoveCanvasModule(CanvasModule module)
        {
            module.OnNodeStartConnectionLine -= StartConnection;

            // Safe to just disconnect all nodes on the module instead of the
            // connection, as it disconnects on both ends anyway.
            module.Module.Disconnect();

            // Check each connection entry and remove the one that doesn't have
            // active connections
            PruneDeadConnections();
            AdjustModuleDisplayNames();
        }
示例#7
0
        private void OnAddCanvasModule(CanvasModule module)
        {
            string dataDir = Properties.Settings.Default.data_folder;

            if (dataDir.Last() != System.IO.Path.DirectorySeparatorChar)
            {
                dataDir += System.IO.Path.DirectorySeparatorChar;
            }
            module.Module.DataDir = dataDir;
            ValidateDataFolder();

            module.WfCanvas = this;
            module.Scroller = Scroller;
            module.OnNodeStartConnectionLine += StartConnection;
            SetCanvasModulePos(module, Mouse.GetPosition(this));
            SetZIndex(module, 1);

            if (!XmlInProgress)
            {
                AdjustModuleDisplayNames();
            }
        }
 private void OnRemoveCanvasModule(CanvasModule module)
 {
     logger.Info("DragModule=null");
     DragModule = null;
 }
 private void OnAddCanvasModule(CanvasModule module)
 {
     DragModule = module;
     logger.Trace($"Setting DragModule={module.Module.DisplayName}");
     //logger.Info("DragModule={0}", module.DisplayName.Text);
 }
示例#10
0
 public RenderNode(CanvasModule parent, Ellipse shape, INode node)
 {
     Parent = parent;
     Visual = shape;
     Node   = node;
 }