Exemple #1
0
 private void MainWindow_ItemDropEvent(object sender, ItemDropEventArgs args)
 {
     if (args.ItemSource == Cause.Stencil && (args.Source as INode).Key.ToString() == "Basic Shapes")
     {
         args.Cancel = true;
     }
 }
Exemple #2
0
        // Mehtod to create relation between drag and dropped nodes
        private void OnItemDrop(object obj)
        {
            ItemDropEventArgs args = obj as ItemDropEventArgs;

            if (!(args.Target is SfDiagram))
            {
                foreach (object targetElement in args.Target as IEnumerable <object> )
                {
                    if (targetElement is CustomNode)
                    {
                        if ((args.Source as CustomNode).ParentId == null)
                        {
                            (args.Source as CustomNode).Id       = "Node" + (Nodes as ObservableCollection <CustomNode>).Count.ToString();
                            (args.Source as CustomNode).ID       = (args.Source as CustomNode).Id;
                            (args.Source as CustomNode).ParentId = (targetElement as CustomNode).Id;

                            CreateConnector((args.Source as CustomNode).ParentId, (args.Source as CustomNode).Id);
                            LayoutManager.Layout.UpdateLayout();
                        }
                    }
                }
            }

            else if (args.Target is SfDiagram)
            {
                if ((args.Source as CustomNode).ParentId == null)
                {
                    (args.Source as CustomNode).Id       = "Node" + (Nodes as ObservableCollection <CustomNode>).Count.ToString();
                    (args.Source as CustomNode).ID       = (args.Source as CustomNode).Id;
                    (args.Source as CustomNode).ParentId = "";
                    LayoutManager.Layout.UpdateLayout();
                }
            }
        }
        /// <summary>
        /// The method will be invoked when node is dropped on to another node.
        /// </summary>
        /// <param name="obj">Item dropped event argument</param>
        private void OnItemDroped(object obj)
        {
            ItemDropEventArgs args = obj as ItemDropEventArgs;

            if (args != null)
            {
                if (!(args.Target is SfDiagram))
                {
                    foreach (object targetElement in args.Target as IEnumerable <object> )
                    {
                        if (targetElement is NodeViewModel)
                        {
                            NodeViewModel sourcenode = args.Source as NodeViewModel;
                            NodeViewModel targetnode = targetElement as NodeViewModel;
                            if (sourcenode.Content is MindmapDataItem && targetnode.Content is MindmapDataItem &&
                                (sourcenode.Content as MindmapDataItem).ParentId != (targetnode.Content as MindmapDataItem).Id &&
                                (sourcenode.Content as MindmapDataItem).Id != "0")
                            {
                                //Change the parent id of the source node to target node's id.
                                (sourcenode.Content as MindmapDataItem).Parent = (targetnode.Content as MindmapDataItem);
                                //Update the layout to re-render the UI
                                LayoutManager.Layout.UpdateLayout();
                            }
                        }
                    }
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// The method will be invoked when node is dropped on to another node.
        /// </summary>
        /// <param name="obj">Item dropped event argument</param>
        private void OnItemDropped(object obj)
        {
            ItemDropEventArgs args = obj as ItemDropEventArgs;

            if (args != null)
            {
                if (!(args.Target is SfDiagram))
                {
                    foreach (object targetElement in args.Target as IEnumerable <object> )
                    {
                        if (targetElement is NodeViewModel)
                        {
                            //Newl dropped node
                            NodeViewModel sourcenode = args.Source as NodeViewModel;
                            //Existing node
                            NodeViewModel targetnode = targetElement as NodeViewModel;
                            //Update the new node's offset x and y values
                            sourcenode.OffsetX = targetnode.OffsetX;
                            sourcenode.OffsetY = targetnode.OffsetY + 130;
                            //Create connection from exiting node to new node
                            ConnectorViewModel connectorVM = new ConnectorViewModel()
                            {
                                SourceNode = targetnode,
                                TargetNode = sourcenode
                            };
                            (Connectors as ObservableCollection <ConnectorViewModel>).Add(connectorVM);
                        }
                    }
                }
            }
        }
Exemple #5
0
 private void MainWindow_ItemDropEvent(object sender, ItemDropEventArgs args)
 {
     if (args.Source is PortsGateViewModel)
     {
         //Showing dynamic ports panel after node dropped into diagram.
         InputBox.Visibility = Visibility.Visible;
     }
 }
 //Method to execute ItemDropEvent.
 private void MainWindow_ItemDropEvent(object sender, ItemDropEventArgs args)
 {
     if (args.Source is INode)
     {
         INode item = args.Source as INode;
         //Getting position of dropped node.
         double offsetX = item.OffsetX;
         double offsetY = item.OffsetY;
     }
 }
Exemple #7
0
 private void MainWindow_ItemDropEvent(object sender, ItemDropEventArgs args)
 {
     if (args.Target is IEnumerable <object> && !(args.Target is GroupViewModel) && (args.Target as IEnumerable <object>).ElementAt(0) is NodeViewModel)
     {
         var sourcenode = args.Source as NodeViewModel;
         foreach (var grp in Diagram.Groups as GroupCollection)
         {
             (grp.Nodes as NodeCollection).Add(sourcenode);
         }
     }
 }
Exemple #8
0
 private void MainWindow_DragOver(object sender, ItemDropEventArgs args)
 {
     if (args.Source is TemplatedNodeViewModel && (args.Source as TemplatedNodeViewModel).Name.Equals("Input"))
     {
         (args.Source as TemplatedNodeViewModel).ContentTemplate = App.Current.Resources["Input"] as DataTemplate;
         (args.Source as TemplatedNodeViewModel).Content         = (args.Source as TemplatedNodeViewModel).CustomContent;
     }
     else if (args.Source is TemplatedNodeViewModel && (args.Source as TemplatedNodeViewModel).Name.Equals("Timer"))
     {
         (args.Source as TemplatedNodeViewModel).ContentTemplate = App.Current.Resources["Timer"] as DataTemplate;
         (args.Source as TemplatedNodeViewModel).Content         = (args.Source as TemplatedNodeViewModel).CustomContent;
     }
 }
Exemple #9
0
        void tileView_ItemDrop(object sender, ItemDropEventArgs e)
        {
            var newStatus  = (TaskStatus)e.GroupColumnValue;
            var prevStatus = (TaskStatus)e.PrevGroupColumnValue;

            if (!prevStatus.Equals(newStatus))
            {
                tileView.BeginDataUpdate();
                RemoveEmptyItem(newStatus);
                AddEmptyItem(prevStatus);
                tileView.EndDataUpdate();
            }
        }
        public void OnDragOverCommand(object parameter)
        {
            ItemDropEventArgs args = parameter as ItemDropEventArgs;

            if (args != null)
            {
                if (args.Source is NodeViewModel && ((args.Source as NodeViewModel).Shape == null) && ((args.Source as NodeViewModel).ContentTemplate) == null)
                {
                    string itemName = (args.Source as NodeViewModel).Name;
                    (args.Source as NodeViewModel).ContentTemplate = nodeTemplatePath;
                    UpdateShapeSize(itemName, args.Source as NodeViewModel);
                }
            }
        }
Exemple #11
0
        public void OnDragOverCommand(object parameter)
        {
            ItemDropEventArgs args = parameter as ItemDropEventArgs;

            if (args != null)
            {
                string itemName = args.Source is NodeViewModel ? (args.Source as NodeViewModel).Name : null;
                if (args.Source is INode && ((args.Source as INode).Shape == null && (args.Source as INode).ContentTemplate == null))
                {
                    (args.Source as INode).ContentTemplate = nodeTemplatePath;
                    this.UpdateShapeSize(itemName, args.Source as INode);
                }
            }
        }
Exemple #12
0
        private void MainWindow_DragEnter(object sender, ItemDropEventArgs args)
        {
            // args.Source have the data which is dragged for drop.
            if (args.Source is DataObject)
            {
                object       dataObject   = (args.Source as DataObject).GetData(typeof(DragObject <TreeViewNode>));
                TreeViewNode treeViewItem = (dataObject as DragObject <TreeViewNode>).Source;
                // Based on the TreeView Item you can add different types of Node.

                if (treeViewItem.Level.ToString() == "0")
                {
                    args.Source = new NodeViewModel()
                    {
                        UnitHeight  = 40,
                        UnitWidth   = 120,
                        Shape       = this.Resources["Rectangle"],
                        ShapeStyle  = this.Resources["Level1NodeStyle"] as Style,
                        Annotations = new AnnotationCollection()
                        {
                            new AnnotationEditorViewModel()
                            {
                                Content = treeViewItem.Content.ToString(),
                                Offset  = new Point(0, 0),
                                Margin  = new Thickness(23, 10, 0, 0),
                            },
                        },
                    };
                }
                else
                {
                    args.Source = new NodeViewModel()
                    {
                        UnitHeight  = 40,
                        UnitWidth   = 120,
                        Shape       = this.Resources["Ellipse"],
                        ShapeStyle  = this.Resources["OtherLevelNodeStyle"] as Style,
                        Annotations = new AnnotationCollection()
                        {
                            new AnnotationEditorViewModel()
                            {
                                Content = treeViewItem.Content.ToString(),
                            },
                        },
                    };
                }
            }
        }
        private void tileView_ItemDrop(object sender, ItemDropEventArgs e)
        {
            var newStatus  = e.GroupColumnValue;
            var prevStatus = e.PrevGroupColumnValue;

            if (!prevStatus.Equals(newStatus))
            {
                tileView.BeginDataUpdate();
                var rowtest = dataSet.ViewTable.FirstOrDefault(x => x.GroupTitle == prevStatus.ToString());
                if (rowtest == null)
                {
                    DataRowView objprev = tileView.GetRow(e.RowHandle) as DataRowView;
                    if (objprev == null)
                    {
                        return;
                    }
                    DataSet.ViewTableRow rowprev = objprev.Row as DataSet.ViewTableRow;
                    if (rowprev == null)
                    {
                        return;
                    }
                    string   prevtitle = prevStatus as string;
                    DateTime dateprev  = DateTime.ParseExact(prevtitle, "ddd(dd.MM)", new CultureInfo("de-DE"));
                    rowprev.GroupTitle = prevtitle;
                    dataSet.ViewTable.AddViewTableRow(rowprev.DayofWeek, rowprev.GroupTitle, "", "", rowprev.DueDate, rowprev.EndDate, "category", 0, "", "");
                }

                DataRowView obj = tileView.GetRow(e.RowHandle) as DataRowView;
                if (obj == null)
                {
                    return;
                }
                DataSet.ViewTableRow row = obj.Row as DataSet.ViewTableRow;
                if (row == null)
                {
                    return;
                }

                string   title = newStatus as string;
                DateTime date  = DateTime.ParseExact(title, "ddd(dd.MM)", new CultureInfo("de-DE"));
                row.DueDate    = date;
                row.DayofWeek  = (int)date.DayOfWeek;
                row.GroupTitle = title;

                tileView.EndDataUpdate();
            }
        }
Exemple #14
0
        // TODO: Fix issue where the player can dodge the falling item by dashing or moving fast using wings.

        public void OnItemDrop(object sender, ItemDropEventArgs e)
        {
            // Check if the player is picking up an item (E.g. from /chooseclass).
            if (e.ID != 400)
            {
                return;
            }

            e.Handled = true;

            TSPlayer tSPlayer = e.Player;
            Player   player   = tSPlayer.TPlayer;

            string itemName = TShock.Utils.GetItemById(e.Type).Name;

            int  index = Item.NewItem(player.position, new Vector2(32, 48), e.Type, e.Stacks);
            Item item  = Main.item[index];

            var data = Plugin.Instance.item_data;

            if (data.BlockExists(itemName))
            {
                Block block = data.GetBlock(itemName);

                int.TryParse(block.GetValue(Parameters[Damage].TrimEnd(':', '0')), out item.damage);
                int.TryParse(block.GetValue(Parameters[Crit].TrimEnd(':', '0')), out item.crit);
                float.TryParse(block.GetValue(Parameters[KB].TrimEnd(':', '0')), out item.knockBack);
                byte.TryParse(block.GetValue(Parameters[Prefix].TrimEnd(':', '0')), out item.prefix);
                int.TryParse(block.GetValue(Parameters[ReuseDelay].TrimEnd(':', '0')), out item.reuseDelay);
                int.TryParse(block.GetValue(Parameters[Shoot].TrimEnd(':', '0')), out item.shoot);
                float.TryParse(block.GetValue(Parameters[ShootSpeed].TrimEnd(':', '0')), out item.shootSpeed);
                int.TryParse(block.GetValue(Parameters[UseAmmo].TrimEnd(':', '0')), out item.useAmmo);
                int.TryParse(block.GetValue(Parameters[UseTime].TrimEnd(':', '0')), out item.useTime);
                int.TryParse(block.GetValue(Parameters[Width].TrimEnd(':', '0')), out item.width);
                int.TryParse(block.GetValue(Parameters[Height].TrimEnd(':', '0')), out item.height);
                bool.TryParse(block.GetValue(Parameters[AutoReuse].TrimEnd(':', '0')), out item.autoReuse);
                int.TryParse(block.GetValue(Parameters[Ammo].TrimEnd(':', '0')), out item.ammo);
                float.TryParse(block.GetValue(Parameters[Scale].TrimEnd(':', '0')), out item.scale);

                TSPlayer.All.SendData(PacketTypes.TweakItem, "", index, 255, 63);
            }
        }
Exemple #15
0
        void tileView_ItemDrop(object sender, ItemDropEventArgs e)
        {
            var    task       = tileView.GetRow(e.RowHandle) as TaskRecord;
            String taskId     = this.taskIdAndIndexes[Convert.ToInt32(task.Id.ToString())]; //  task id
            var    newStatus  = (TaskStatus)e.GroupColumnValue;
            var    prevStatus = (TaskStatus)e.PrevGroupColumnValue;

            if (!prevStatus.Equals(newStatus))
            {
                tileView.BeginDataUpdate();
                RemoveEmptyItem(newStatus);
                AddEmptyItem(prevStatus);
                tileView.EndDataUpdate();
            }
            int status = (int)newStatus;

            //  更新数据库状态
            CustomAppointmentService.UpdateStatus(taskId, status);
            //  更新数据源状态
            this.updateAppointmentStatus(taskId, status);
        }
Exemple #16
0
        //Method to execute DropCommand.
        private void OnDropCommand(object args)
        {
            ItemDropEventArgs parameter = args as ItemDropEventArgs;

            if (parameter.Source is NodeViewModel && parameter.ItemSource == Cause.Stencil)
            {
                if (!(parameter.Target is SfDiagram))
                {
                    foreach (object targetElement in parameter.Target as IEnumerable <object> )
                    {
                        //Adding memeber node to the group element where it is dropped
                        if (targetElement is GroupViewModel)
                        {
                            NodeViewModel sourceNode = parameter.Source as NodeViewModel;
                            sourceNode.OffsetX = (targetElement as GroupViewModel).OffsetX;
                            sourceNode.OffsetY = ((targetElement as GroupViewModel).Info as IGroupInfo).Bounds.Bottom + 10;
                            ((targetElement as GroupViewModel).Nodes as NodeCollection).Add(sourceNode);
                        }
                    }
                }
            }
        }
Exemple #17
0
 private void Graph_ItemDropEvent(object sender, ItemDropEventArgs args)
 {
     if (args.ItemSource == Cause.Stencil)
     {
         (args.Source as INodeVM).Style = App.Current.Resources["SubtleEffectAccent1Style"] as Style;
         (SelectedItems as SelectorVM).NodeGallaryName = "SubtleEffectAccent1";
         (args.Source as INodeVM).NodeGallaryName      = (SelectedItems as SelectorVM).NodeGallaryName;
         //GroupTransactions group = new GroupTransactions();
         //group.ContinuousUndoRedo = ContinuousUndoRedo.End;
         //this.HistoryManager.EndComposite(this.HistoryManager, group);
     }
     if (this.DrawingTool == DrawingTool.Connector)
     {
         if (this.Tool == Tool.ContinuesDraw | this.Tool == Tool.DrawOnce)
         {
             if (args.Source is NodeVM)
             {
                 (args.Source as NodeVM).IsSelected = false;
             }
         }
     }
 }
Exemple #18
0
        // Listen for when a person drops their items. If the person was over the house when it dropped its items, add the food to this.food
        //  and let WorldController know that the food count has changed. Otherwise, create a new pickup at the person's position
        //  and let WorldController know that a new Item has been created.

        private void P_DroppedItem(Person person, ItemDropEventArgs e)
        {
            // Search the inventory list to see if the item already exists in storage.
            Item storedItem = Inventory.Find(p => p.Type == e.Type);

            if (storedItem == null) // If not, create a new item in storage.
            {
                Inventory.Add(new Item(0, 0, e.Type, e.Count));
                OnUpdateElement(ChangeType.NewElement, e.Type.ToString(), e.Count);
            }
            else // otherwise add it to the item that already exists.
            {
                storedItem.AddAmount(e.Count);
                OnUpdateElement(ChangeType.UpdateElement, e.Type.ToString(), e.Count);
            }


            if (!e.InHouse)
            {
                Item pickup = new Item((int)person.Position.X, (int)person.Position.Y, e.Type, e.Count);
                OnAddGameObject(pickup);
            }
        }
Exemple #19
0
        private static bool OnItemDrop(short id, Vector2 pos, Vector2 vel, short stacks, byte prefix, bool noDelay, short type)
        {
            if (ItemDrop == null)
                return false;

            var args = new ItemDropEventArgs
            {
                ID = id,
                Position = pos,
                Velocity = vel,
                Stacks = stacks,
                Prefix = prefix,
                NoDelay = noDelay,
                Type = type,
            };
            ItemDrop.Invoke(null, args);
            return args.Handled;
        }
Exemple #20
0
        public void OnDragEnterCommand(object parameter)
        {
            nodeTemplatePath = null;
            ItemDropEventArgs args     = parameter as ItemDropEventArgs;
            string            itemName = args.Source is NodeViewModel ? (args.Source as NodeViewModel).Name : null;

            if (args.Source is INode && (args.Source as INode).ContentTemplate != null)
            {
                if (itemName != null)
                {
                    switch (itemName)
                    {
                    case "PC":

                        nodeTemplatePath = resourceDictionary["PCNode"] as DataTemplate;
                        break;

                    case "VirtualPC":

                        nodeTemplatePath = resourceDictionary["VirtualPCNode"] as DataTemplate;
                        break;

                    case "Terminal":

                        nodeTemplatePath = resourceDictionary["TerminalNode"] as DataTemplate;
                        break;

                    case "Wavelength":

                        nodeTemplatePath = resourceDictionary["WavelengthNode"] as DataTemplate;
                        break;

                    case "DataPipe":

                        nodeTemplatePath = resourceDictionary["DataPipeNode"] as DataTemplate;
                        break;

                    case "SlateDevice":

                        nodeTemplatePath = resourceDictionary["SlateDivceNode"] as DataTemplate;
                        break;

                    case "TabletDevice":

                        nodeTemplatePath = resourceDictionary["TabletDeviceNode"] as DataTemplate;
                        break;

                    case "Laptop":

                        nodeTemplatePath = resourceDictionary["LaptopNode"] as DataTemplate;
                        break;

                    case "PDA":

                        nodeTemplatePath = resourceDictionary["PDANode"] as DataTemplate;
                        break;

                    case "CRTMoniter":

                        nodeTemplatePath = resourceDictionary["CRTMoniterNode"] as DataTemplate;
                        break;

                    case "LCDMoniter":

                        nodeTemplatePath = resourceDictionary["LCDMoniterNode"] as DataTemplate;
                        break;

                    case "Connector":

                        nodeTemplatePath = resourceDictionary["DynamicConnectorNode"] as DataTemplate;
                        break;

                    case "Wireless":

                        nodeTemplatePath = resourceDictionary["WirelessNode"] as DataTemplate;
                        break;

                    case "RingNetwork":

                        nodeTemplatePath = resourceDictionary["RingNetworkNode"] as DataTemplate;
                        break;

                    case "Ethernet":

                        nodeTemplatePath = resourceDictionary["EthernetNode"] as DataTemplate;
                        break;

                    case "Server":

                        nodeTemplatePath = resourceDictionary["ServerNode"] as DataTemplate;
                        break;

                    case "Mainframe":

                        nodeTemplatePath = resourceDictionary["MainframeNode"] as DataTemplate;
                        break;

                    case "Router":

                        nodeTemplatePath = resourceDictionary["RouterNode"] as DataTemplate;
                        break;

                    case "Switch":

                        nodeTemplatePath = resourceDictionary["SwitchNode"] as DataTemplate;
                        break;

                    case "Firewall":

                        nodeTemplatePath = resourceDictionary["FirewallNode"] as DataTemplate;
                        break;

                    case "CommLink":

                        nodeTemplatePath = resourceDictionary["CommLinkNode"] as DataTemplate;
                        break;

                    case "SuperComputer":

                        nodeTemplatePath = resourceDictionary["SuperComputerNode"] as DataTemplate;
                        break;

                    case "Printer":

                        nodeTemplatePath = resourceDictionary["PrinterNode"] as DataTemplate;
                        break;

                    case "VirtualServer":

                        nodeTemplatePath = resourceDictionary["ServerNode"] as DataTemplate;
                        break;

                    case "Plotter":

                        nodeTemplatePath = resourceDictionary["PlotterNode"] as DataTemplate;
                        break;

                    case "Scanner":

                        nodeTemplatePath = resourceDictionary["ScannerNode"] as DataTemplate;
                        break;

                    case "Copier":

                        nodeTemplatePath = resourceDictionary["CopierNode"] as DataTemplate;
                        break;

                    case "Fax":

                        nodeTemplatePath = resourceDictionary["FaxNode"] as DataTemplate;
                        break;

                    case "MultiFunction":

                        nodeTemplatePath = resourceDictionary["MultiFunctionNode"] as DataTemplate;
                        break;

                    case "Projector":

                        nodeTemplatePath = resourceDictionary["ProjectorNode"] as DataTemplate;
                        break;

                    case "ProjectorScreen":

                        nodeTemplatePath = resourceDictionary["ProjectorScreenNode"] as DataTemplate;
                        break;

                    case "Bridge":

                        nodeTemplatePath = resourceDictionary["BridgeNode"] as DataTemplate;
                        break;

                    case "Hub":

                        nodeTemplatePath = resourceDictionary["HubNode"] as DataTemplate;
                        break;

                    case "Modem":

                        nodeTemplatePath = resourceDictionary["ModemNode"] as DataTemplate;
                        break;

                    case "Telephone":

                        nodeTemplatePath = resourceDictionary["TelephoneNode"] as DataTemplate;
                        break;

                    case "CellPhone":

                        nodeTemplatePath = resourceDictionary["CellPhoneNode"] as DataTemplate;
                        break;

                    case "SmartPhone":

                        nodeTemplatePath = resourceDictionary["SmartPhoneNode"] as DataTemplate;
                        break;

                    case "VideoPhone":

                        nodeTemplatePath = resourceDictionary["VideoPhoneNode"] as DataTemplate;
                        break;

                    case "DigitalCamera":

                        nodeTemplatePath = resourceDictionary["DigitalCameraNode"] as DataTemplate;
                        break;

                    case "VideoCamera":

                        nodeTemplatePath = resourceDictionary["VideoCameraNode"] as DataTemplate;
                        break;

                    case "ExternalMediaDevice":

                        nodeTemplatePath = resourceDictionary["ExternalMediaDeviceNode"] as DataTemplate;
                        break;

                    case "User":

                        nodeTemplatePath = resourceDictionary["UserNode"] as DataTemplate;
                        break;
                    }
                }
            }
        }