Inheritance: MemoryNode
Example #1
0
        /// <summary>
        /// 把node节点内的navpoint按层次加入treenode。ps:树节点图像0:文件夹1:打开的文件夹2:文件
        /// </summary>
        /// <param name="node">navpoint节点</param>
        /// <param name="treeNode">将navpoint节点加入treepoint</param>
        /// <param name="filePath">contant内链接文件的路径</param>
        private void AddNavPoint(XmlNode node, ItemNode treeNode, string filePath, XmlNamespaceManager nsmgr)
        {
            XmlNode     navText       = node["navLabel"]["text"];
            XmlNode     navContent    = node["content"];
            string      text          = navText.InnerText;
            string      url           = getFileURL(filePath, navContent.Attributes["src"].Value);
            XmlNodeList childNavNodes = node.SelectNodes("ncx:navPoint", nsmgr);

            if (childNavNodes.Count > 0)
            {
                if (navText != null && navContent != null)
                {
                    if (!string.IsNullOrEmpty(url))
                    {
                        ItemNode currentTreeNode = new ItemNode(text, url, ItemNode.CollepsedIcon);
                        treeNode.Nodes.Add(currentTreeNode);
                        foreach (XmlNode n in childNavNodes)
                        {
                            AddNavPoint(n, currentTreeNode, filePath, nsmgr);
                        }
                    }
                }
            }
            else
            {
                if (navText != null && navContent != null)
                {
                    if (!string.IsNullOrEmpty(url))
                    {
                        treeNode.Nodes.Add(new ItemNode(text, url, ItemNode.PageIcon));
                    }
                }
            }
        }
        void uploadfile()
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect      = true;
            ofd.Filter           = PCPath.FilterAllFiles;
            ofd.InitialDirectory = PCPath.Mycomputer;
            DialogResult result = ofd.ShowDialog();

            if (result != DialogResult.OK | result != DialogResult.Yes)
            {
                return;
            }
            List <IItemNode> items = new List <IItemNode>();
            IItemNode        root  = ItemNode.GetNodeFromDiskPath(System.IO.Path.GetDirectoryName(ofd.FileNames[0]));

            foreach (string s in ofd.SafeFileNames)
            {
                IItemNode n = new ItemNode();
                n.Info.Name = s;
                root.AddChild(n);
                FileInfo info = new FileInfo(n.GetFullPathString());
                n.Info.Size    = info.Length;
                n.Info.DateMod = info.LastWriteTime;
                items.Add(n);
            }
            Setting_UI.reflection_eventtocore.ExplorerAndManagerFile.TransferItems(items, root, managerehistory_itemnodes.NodeWorking(), false);
        }
Example #3
0
    public override void SetupPorts()
    {
        ItemNode node = myNode as ItemNode;

        for (int i = 0; i < node.inputs.Count; i++)
        {
            inputPorts.Add(
                Instantiate(inputPortPrefab, inputParent).GetComponent <NodePortGfx>()
                .Setup(
                    this,
                    NodePortGfx.PortType.itemInput,
                    -1
                    )
                );
        }

        for (int i = 0; i < node.outputs.Count; i++)
        {
            outputPorts.Add(
                Instantiate(outputPortPrefab, outputParent).GetComponent <NodePortGfx>()
                .Setup(
                    this,
                    NodePortGfx.PortType.itemOutput,
                    -1
                    )
                );
        }

        AddPort(true);
        AddPort(false);
    }
Example #4
0
    public void AddItem(Item item)
    {
        var      itemContainer = GetNode("Side/Items/ItemScroller/ItemPanel/ItemContainer");
        ItemNode itemNode      = (ItemNode)itemScene.Instance();

        itemNode.item = item;
        TextureRect itemSprite = (TextureRect)itemNode.GetNode("ItemBox/ItemLabel/Sprite");
        var         spriteName = item.GetSprite();

        if (sprites.ContainsKey(spriteName))
        {
            itemSprite.SetTexture(sprites[spriteName]);
        }
        else
        {
            itemSprite.SetTexture(sprites["unknown"]);
        }
        Label itemName = (Label)itemNode.GetNode("ItemBox/ItemLabel/Name");

        itemName.SetText(item.GetName());
        Label itemQuantity = (Label)itemNode.GetNode("ItemBox/ItemLabel/Amount");

        itemQuantity.SetText("x" + item.GetQuantity());
        itemContainer.AddChild(itemNode);
    }
Example #5
0
 public void RemoveItem(ItemNode source, int amount)
 {
     if (source.GetProfile().stackable)
     {
         for (int i = 0; i < Items.Count; i++)
         {
             if (Items[i].Compare(source))
             {
                 Items[i].stack -= amount;
                 if (Items[i].stack <= 0)
                 {
                     Items.RemoveAt(i);
                 }
                 return;
             }
         }
     }
     else
     {
         for (int i = 0; i < amount; i++)
         {
             for (int j = 0; j < Items.Count; j++)
             {
                 if (Items[j].Compare(source))
                 {
                     Items.RemoveAt(j);
                     break;
                 }
             }
         }
     }
 }
Example #6
0
        private void AssignIndices(ItemNode sourceNode)
        {
            int fieldIndex      = this.relation.Heading.Count;
            int itemIndex       = 0;
            int enumeratorIndex = 0;

            foreach (ItemNode itemNode in this.EnumerateAllNodes(sourceNode).Where(n => n.HasFlag(NodeFlags.Item)).Cast <ItemNode>())
            {
                itemNode.ItemIndex = itemIndex++;
            }

            ListNode lastListNode = null;

            foreach (ListNode listNode in this.EnumerateAllNodes(sourceNode).Where(n => n.HasFlag(NodeFlags.List)).Cast <ListNode>())
            {
                listNode.EnumeratorIndex = enumeratorIndex++;

                if (!listNode.HasFlag(NodeFlags.Source) && listNode.FieldIndex == null)
                {
                    listNode.FieldIndex = fieldIndex++;
                    listNode.Flags     |= NodeFlags.Field;
                }

                if (lastListNode != null && !lastListNode.Metadata.MemberOf.Equals(listNode.Metadata.MemberOf.Parent?.MemberOf))
                {
                    listNode.Flags |= NodeFlags.Product;
                }

                lastListNode = listNode;
            }
        }
Example #7
0
        private GroupNode GetDropGroup(DragEventArgs e)
        {
            if (!e.Data.GetDataPresent(typeof(ItemNode)))
            {
                return(null);
            }

            Point    pt   = this.PointToClient(new Point(e.X, e.Y));
            TreeNode node = this.GetNodeAt(pt);

            while (!(node is GroupNode) && node != null)
            {
                node = node.Parent;
            }
            if (node == null)
            {
                return(null);
            }

            ItemNode item = e.Data.GetData(typeof(ItemNode)) as ItemNode;

            if (item.Parent == node)
            {
                return(null);
            }

            return((GroupNode)node);
        }
Example #8
0
    public void Add(ActivateableItems newItem)
    {
        ItemNode newNode = new ItemNode(newItem);


        if (root == null)
        {
            root       = newNode;
            root.Index = 0;
        }

        else
        {
            ItemNode currentNode = root;
            while (currentNode.nextNode != null)
            {
                currentNode = currentNode.nextNode;
            }

            currentNode.nextNode = newNode;
            newNode.Index        = currentNode.Index + 1;
        }


        HeldItems++;
    }
Example #9
0
        private void uploadFileToHereToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect      = true;
            ofd.Filter           = PCPath.FilterAllFiles;
            ofd.InitialDirectory = PCPath.Mycomputer;

            DialogResult result = ofd.ShowDialog();

            if (result == DialogResult.OK | result == DialogResult.Yes)
            {
                List <IItemNode> list_item_from = new List <IItemNode>();

                string    root     = Path.GetDirectoryName(ofd.FileNames[0]);
                IItemNode rootnode = ItemNode.GetNodeFromDiskPath(root);
                foreach (string a in ofd.SafeFileNames)
                {
                    FileInfo  info = new FileInfo(root + "\\" + a);
                    IItemNode n    = new ItemNode();
                    n.Info.Name = a;
                    n.Info.Size = info.Length;
                    rootnode.AddChild(n);
                    list_item_from.Add(n);
                }
                Setting_UI.reflection_eventtocore.ExplorerAndManagerFile.TransferItems(list_item_from, rootnode,
                                                                                       ((UC_LVitem)tabControl1.SelectedTab.Controls[0]).managerhistory_itemnodes.NodeWorking(), false);
            }
        }
Example #10
0
        protected override void OnAfterLabelEdit(NodeLabelEditEventArgs e)
        {
            base.OnAfterLabelEdit(e);

            if (e.Node.GetType() == typeof(ItemNode) &&
                e.Label != null && e.Label != e.Node.Text)
            {
                ItemNode itemNode = e.Node as ItemNode;

                if (e.Label == itemNode.Item.JID.User)
                {
                    itemNode.Item.Nickname = null;
                }
                else
                {
                    itemNode.Item.Nickname = e.Label;
                }

                RosterIQ riq = new RosterIQ(this.m_client.Document);
                riq.Type = IQType.set;
                riq.Instruction.AddChild(itemNode.Item);

                this.m_client.Write(riq);
            }
        }
Example #11
0
    public void Remove(int index)
    {
        if (HeldItems >= 1)
        {
            if (index != 0)
            {
                ItemNode currentNode = root;

                /*
                 * while (currentNode.Index < index - 1)
                 * {
                 *  currentNode = currentNode.nextNode;
                 * }
                 *
                 * currentNode.nextNode = currentNode.nextNode.nextNode;
                 *
                 * while (currentNode != null)
                 * {
                 *  currentNode = currentNode.nextNode;
                 *  currentNode.Index -= 1;
                 * }
                 */


                while (currentNode.Index < index)
                {
                    currentNode = currentNode.nextNode;
                }

                PreviousNode(index).nextNode = currentNode.nextNode;
                ActivateableItems itemToDelete = currentNode.storedItem;
                itemToDelete.DestroyItem();
                currentNode = currentNode.nextNode;



                while (currentNode != null)
                {
                    currentNode.Index--;
                    currentNode = currentNode.nextNode;
                }
            }

            else
            {
                root.storedItem.DestroyItem();
                root = root.nextNode;
                ItemNode currentNode = root;

                while (currentNode != null)
                {
                    currentNode.Index -= 1;
                    currentNode        = currentNode.nextNode;
                }
            }


            HeldItems--;
        }
    }
Example #12
0
        private void uploadFolderToHereToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            fbd.RootFolder          = Environment.SpecialFolder.MyComputer;
            fbd.ShowNewFolderButton = true;
            DialogResult result = fbd.ShowDialog(MainForm);

            if (result == DialogResult.OK | result == DialogResult.Yes)
            {
                List <IItemNode> list_item_from = new List <IItemNode>();
                IItemNode        node           = ItemNode.GetNodeFromDiskPath(fbd.SelectedPath.TrimEnd('\\'));
                list_item_from.Add(node);

                IItemNode rootto = managerhistory_itemnodes.NodeWorking();
                if (LV_item.SelectedItems.Count == 1)
                {
                    IItemNode find = FindNodeLV(LV_item.SelectedItems[0]);
                    if (find != null && find.Info.Size <= 0)
                    {
                        rootto = find;
                    }
                }
                Setting_UI.reflection_eventtocore.ExplorerAndManagerFile.TransferItems(list_item_from, node.Parent, rootto, false);
            }
        }
Example #13
0
        public void DrawConnection(Color _color, Vector2 point1, Vector2 point2, ItemNode node, ItemNode neighboor, bool hiden)
        {
            float angle    = 0;
            float distance = 0;

            //angle = (float)(Math.Atan2(point2.Y- point1.Y, point2.X - point1.X) *(180f/Math.PI));
            angle    = (float)(Math.Atan2(point2.Y - point1.Y, point2.X - point1.X));
            distance = (float)Math.Sqrt(Math.Pow(point2.X - point1.X, 2) + Math.Pow(point2.Y - point1.Y, 2));
            ItemConnection BG = new ItemConnection(angle, distance, 10)
            {
                color  = Color.DarkSlateGray,
                Hidden = hiden
            };

            ItemConnection connection = new ItemConnection(angle, distance, 6)
            {
                color = _color,
            };

            BG.basePos             = new Vector2(point1.X + SKILL_SIZE * 0.5f, point1.Y + SKILL_SIZE * 0.5f);
            connection.basePos     = new Vector2(point1.X + SKILL_SIZE * 0.5f, point1.Y + SKILL_SIZE * 0.5f);
            connection.nodeID      = node.GetId;
            connection.neighboorID = neighboor.GetId;
            BG.bg = true;
            allConnection.Add(connection);
        }
Example #14
0
        }             // end CompareWork

        private ItemNode CompareFile(string file, string leftPath, string rightPath)
        {
            bool isExistLeft  = File.Exists(leftPath);
            bool isExistRight = File.Exists(rightPath);
            var  node         = new ItemNode(file);

            if (isExistLeft && isExistRight)
            {
                bool isSame = false;
                if (Utility.GetMD5HashFromFile(leftPath) == Utility.GetMD5HashFromFile(rightPath))
                {
                    isSame = true;
                } // end if
                node.SetProperty(isSame, false, false, _itemMap);
            }
            else if (isExistLeft && !isExistRight)
            {
                node.SetProperty(false, false, true, _itemMap);
            }
            else if (!isExistLeft && isExistRight)
            {
                node.SetProperty(false, true, false, _itemMap);
            }
            else
            {
                node.SetProperty(false, true, true, _itemMap);
            } // end if
            _itemMap.Add(file, node);
            return(node);
        } // end CompareFile
Example #15
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string          item     = "";
            List <ItemNode> item_arr = new List <ItemNode>();

            for (int i = 0; i < LV_item.SelectedItems.Count; i++)
            {
                ItemNode find = FindNodeLV(LV_item.SelectedItems[i]);
                if (find != null)
                {
                    item_arr.Add(find);
                    item += find.Info.Name + "\r\n";
                }
            }
            DeleteConfirmForm f = new DeleteConfirmForm();

            f.TB.Text = item;
            f.ShowDialog(this);
            if (f.Delete)
            {
                DeleteItems items = new DeleteItems()
                {
                    Items = item_arr, PernamentDelete = f.CB_pernament.Checked
                };
                Setting_UI.reflection_eventtocore.ExplorerAndManagerFile.DeletePath(items);
            }
        }
Example #16
0
    /// <summary>
    /// load the information of the items from the .csv files to the binary tree
    /// </summary>
    public static void LoadItemsFromFile()
    {
        string filePath = Path.Combine(Application.persistentDataPath, itemsTreeFile);

        if (File.Exists(filePath))
        {
            string[] Nodes = File.ReadAllLines(filePath);

            foreach (var nodeData in Nodes)
            {
                string[] node         = nodeData.Split(',');
                string   nodeName     = node[0];
                string   nodePrice    = node[1];
                string   nodeStock    = node[2];
                string   nodeDiscount = node[3];

                if (GameManager.Instance.ItemsTreeRoot.SearchTree(nodeName) == null)
                {
                    ItemNode        newItem = new ItemNode(nodeName, float.Parse(nodePrice), int.Parse(nodeStock), float.Parse(nodeDiscount));
                    Node <ItemNode> newNode = new Node <ItemNode>(newItem);
                    GameManager.Instance.ItemsTreeRoot.RootTree.Left = GameManager.Instance.ItemsTreeRoot.AddToTree(GameManager.Instance.ItemsTreeRoot.RootTree.Left, newNode);
                }
                else
                {
                    continue;
                }
            }
        }
        else
        {
            var textFile = Resources.Load <TextAsset>("BinaryTreeData");
            File.AppendAllText(filePath, textFile.ToString());
            LoadItemsFromFile();
        }
    }
Example #17
0
        private Expression GetItemNameExpression(ItemNode itemNode)
        {
            Expression nameExpression;

            if (itemNode.HasFlag(NodeFlags.Source))
            {
                nameExpression = Expression.Property(Expression.Property(this.args.Source, nameof(IField.Identity)), nameof(FieldIdentity.Name));
            }
            else if (itemNode.List != null)
            {
                Expression enumerator = this.GetEnumeratorExpression(itemNode.List);
                Expression list       = this.GetFieldExpression(itemNode.List);
                Expression listName   = Expression.Property(Expression.Property(list, nameof(IField.Identity)), nameof(FieldIdentity.Name));
                Expression itemName   = Expression.Constant(itemNode.Metadata.Identity.Notation.Path(itemNode.List.Metadata.Identity.Name, itemNode.Metadata.Identity.Name));
                Expression combined   = this.GetNotationCombine(listName, itemName);
                Expression index      = Expression.Property(enumerator, nameof(IndexedEnumerator <object> .Index));
                Expression indexed    = this.GetNotationIndex(combined, index);

                nameExpression = indexed;
            }
            else
            {
                throw new InvalidOperationException();
            }

            return(nameExpression);
        }
Example #18
0
        private Expression GetAssignItemNameExpression(ItemNode itemNode)
        {
            Expression itemName = this.GetItemNameExpression(itemNode);
            Expression variable = this.args.ItemVars[itemNode.ItemIndex] = Expression.Parameter(typeof(string), "itemName" + itemNode.ItemIndex);

            return(Expression.Assign(variable, itemName));
        }
Example #19
0
        private void OnClickNode(UIMouseEvent evt, UIElement listeningElement, ItemNode node)
        {
            int points = 0;

            if (node.IsAscend)
            {
                points = m_itemSource.GetAscendPoints;
            }
            else
            {
                points = m_itemSource.GetEvolutionPoints;
            }
            switch (node.CanAddLevel(points))
            {
            case ItemReason.CanUpgrade:
                m_itemSource.SpendPoints(node.GetRequiredPoints, node.IsAscend);
                node.AddLevel();

                UpdateToolTip(node);
                UpdateValue();
                Main.PlaySound(SoundID.CoinPickup);
                break;

            default:
                Main.PlaySound(SoundID.MenuClose);
                break;
            }
        }
Example #20
0
        private void OpenItemLV()
        {
            if (LV_item.SelectedItems.Count != 1)
            {
                return;
            }
            ItemNode find = FindNodeLV(LV_item.SelectedItems[0]);

            if (find != null)
            {
                if (find.Info.Size > 0)                                    //file
                {
                    if (find.GetRoot.RootType.Type != CloudType.LocalDisk) //cloud
                    {
                        MessageBox.Show("Not support now.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    }
                    else//disk
                    {
                        System.Diagnostics.Process.Start(find.GetFullPathString());
                    }
                }
                else//folder
                {
                    managerhistory_itemnodes.Next(find);
                    ExplorerCurrentNode();
                }
            }
        }
Example #21
0
 private void OnRightClickNode(UIMouseEvent evt, UIElement listeningElement, ItemNode node)
 {
     for (int i = 0; i < 5; i++)
     {
         OnClickNode(evt, listeningElement, node);
     }
 }
Example #22
0
        protected override void OnDragDrop(DragEventArgs drgevent)
        {
            base.OnDragDrop(drgevent);

            GroupNode group = this.GetDropGroup(drgevent);

            if (group == null)
            {
                return;
            }

            ItemNode  item   = drgevent.Data.GetData(typeof(ItemNode)) as ItemNode;
            GroupNode parent = (GroupNode)item.Parent;
            Item      i      = (Item)item.Item.CloneNode(true, m_client.Document);

            String parentGroupName = this.Client.SupportNestedGroups ? parent.FullPath : parent.GroupName;

            i.RemoveGroup(parentGroupName);

            String groupName = this.Client.SupportNestedGroups ? group.FullPath : group.GroupName;

            if (groupName != this.Unfiled)
            {
                i.AddGroup(groupName);
            }

            m_roster.Modify(i);
        }
Example #23
0
 public override void _Ready()
 {
     itemNode = (ItemNode)GetNode("../../");
     normal   = GD.Load <Theme>("res://ui/optiontheme.tres");
     hover    = GD.Load <Theme>("res://ui/optionthemehover.tres");
     pressed  = GD.Load <Theme>("res://ui/optionthemepressed.tres");
 }
Example #24
0
 public bool AddItem(ItemNode source)
 {
     if (source.GetProfile().stackable)
     {
         for (int i = 0; i < Items.Count; i++)
         {
             if (Items[i].Compare(source))
             {
                 Items[i].stack += source.stack;
                 return(true);
             }
         }
         if (Items.Count >= Size)
         {
             return(false);
         }
         Items.Add(source);
     }
     else
     {
         if (Items.Count >= Size)
         {
             return(false);
         }
         Items.Add(source);
     }
     return(true);
 }
Example #25
0
    void Finding()
    {
        findingCount++;
        //Debug.Log("Finding");
        // 랜덤 아이템 선택
        targetItemNodeIndex = UnityEngine.Random.Range(0, pathNodeManager.itemNodes.Count);

        // TODO:해당 위치에 캐릭터가 존재하면 다시 선택하도록 수정
        if (pathNodeManager.ItemOccupancyList[targetItemNodeIndex] != null)
        {
            //if (refindingCount > 100)
            //{
            //    SetTarget(pathNodeManager.exitNode);
            //    state = AiState.Exit;
            //}
            //else
            state = AiState.Discard;
            return;
        }

        SetTarget(pathNodeManager.itemNodes[targetItemNodeIndex]);
        targetItemNode = targetNode as ItemNode;
        // 아이템 점유
        pathNodeManager.ItemOccupancyList[targetItemNodeIndex] = this;

        state = AiState.Finded;
    }
Example #26
0
        private void AssignLists(IEnumerable <ItemNode> itemNodes)
        {
            ItemNode source = itemNodes.First(n => n.HasFlag(NodeFlags.Source));

            foreach (ItemNode itemNode in itemNodes.Where(n => !n.HasFlag(NodeFlags.Source)))
            {
                ItemNode   parentItem = source.Metadata.MemberOf.Equals(itemNode.Metadata.Parent.MemberOf) ? source : itemNodes.FirstOrDefault(n => n.Metadata == itemNode.Metadata.Parent.MemberOf);
                MemberNode listMember = parentItem.FindNode(itemNode.Metadata.Parent);
                MemberNode listParent = parentItem.FindNode(listMember.Metadata.Parent) ?? parentItem;

                ListNode listNode = new ListNode()
                {
                    Metadata   = listMember.Metadata,
                    FieldIndex = listMember.FieldIndex,
                    Flags      = NodeFlags.List,
                    Item       = itemNode,
                };

                if (listMember.HasFlag(NodeFlags.Source))
                {
                    listNode.Flags     |= NodeFlags.Source;
                    listNode.FieldIndex = null;
                }
                else if (listMember.HasFlag(NodeFlags.Field))
                {
                    listNode.Flags |= NodeFlags.Field;
                }

                listParent.Members.Remove(listMember);
                listParent.Members.Add(listNode);

                itemNode.List = listNode;
            }
        }
Example #27
0
        public ProjectItem Adapt(ItemNode from)
        {
            if (from == null || from.Item.Value == null || from.Item.Value.ContainingProject == null)
            {
                return(null);
            }

            var item         = from.Item.Value;
            var itemType     = (string)item.Properties.Item("ItemType").Value;
            var itemFullPath = new FileInfo(item.FileNames[1]).FullName;

            var projectName = item.ContainingProject.FullName;
            var projectDir  = Path.GetDirectoryName(projectName);
            var project     = ProjectCollection.GlobalProjectCollection.GetLoadedProjects(projectName).FirstOrDefault();

            if (project != null)
            {
                return(project.ItemsIgnoringCondition
                       .Where(i => i.ItemType == itemType)
                       .Select(i => new { Item = i, FullPath = new FileInfo(Path.Combine(projectDir, i.EvaluatedInclude)).FullName })
                       .Where(i => i.FullPath == itemFullPath)
                       .Select(i => i.Item)
                       .FirstOrDefault());
            }

            return(null);
        }
Example #28
0
    private void UpdateItemUI()
    {
        if (itemsArray.Retrieve(currentSelectedItem) != null)
        {
            ActivateableItems itemOnCurrentSpot = itemsArray.Retrieve(currentSelectedItem);

            if (itemOnCurrentSpot.transform.parent != Camera.main.transform)
            {
                itemOnCurrentSpot.transform.SetParent(Camera.main.transform);
            }

            itemOnCurrentSpot.MoveToActive(position0Items);
        }

        //Set extra items as inactive

        ItemNode currentNode = itemsArray.root;

        while (currentNode != null)
        {
            if (currentNode.Index != currentSelectedItem)
            {
                currentNode.storedItem.Deactivate();
            }
            currentNode = currentNode.nextNode;
        }
    }
Example #29
0
    //Quicksort related

    private ItemNode[] DynArrayToArray()
    {
        ItemNode currentNode = itemsArray.root;

        ItemNode[] itemarray = new ItemNode[itemsArray.HeldItems];

        for (int i = 0; i < itemsArray.HeldItems; i++)
        {
            itemarray[i] = currentNode;
            currentNode  = currentNode.nextNode;
        }


        Debug.Log("Disorganized list");

        for (int i = 0; i < itemsArray.HeldItems; i++)
        {
            Debug.Log($"{itemarray[i].storedItem.potionType}");
        }


        QuickSort(itemarray, 0, itemarray.Length - 1);

        Debug.Log("Just organized list");

        for (int i = 0; i < itemsArray.HeldItems; i++)
        {
            Debug.Log($"{itemarray[i].storedItem.potionType}");
        }


        return(itemarray);
    }
        /// <summary>
        /// Handles the exclude from project command.
        /// </summary>
        /// <returns></returns>
        internal override int ExcludeFromProject()
        {
            Debug.Assert(this.ProjectMgr != null, "The project item " + this.ToString() + " has not been initialised correctly. It has a null ProjectMgr");
            if (!ProjectMgr.QueryEditProjectFile(false) ||
                !ProjectMgr.Tracker.CanRemoveItems(new[] { Url }, new[] { VSQUERYREMOVEFILEFLAGS.VSQUERYREMOVEFILEFLAGS_NoFlags }))
            {
                return(VSConstants.E_FAIL);
            }

            ResetNodeProperties();
            ItemNode.RemoveFromProjectFile();
            if (!File.Exists(Url) || IsLinkFile)
            {
                ProjectMgr.OnItemDeleted(this);
                Parent.RemoveChild(this);
            }
            else
            {
                ItemNode = new AllFilesProjectElement(Url, ItemNode.ItemTypeName, ProjectMgr);
                if (!ProjectMgr.IsShowingAllFiles)
                {
                    IsVisible = false;
                    ProjectMgr.OnInvalidateItems(Parent);
                }
                ProjectMgr.ReDrawNode(this, UIHierarchyElement.Icon);
                ProjectMgr.OnPropertyChanged(this, (int)__VSHPROPID.VSHPROPID_IsNonMemberItem, 0);
            }
            ((IVsUIShell)GetService(typeof(SVsUIShell))).RefreshPropertyBrowser(0);
            return(VSConstants.S_OK);
        }
 public ShadowFileNode(ItemList items, ItemNode parent, uint itemId, string path)
     : base(items, parent, itemId, Constants.ItemNodeType.PhysicalFile, path)
 {
     //buildItem.Include for linked files OnAddFile is different from the one after save,
     //so it is better to keep canonical names too and associate 'Include' value with unique canonical name
     buildItem = Items.Project.ProjectProxy.GetBuildItem(this);
     //Admit 'Include' values for files with the same name in different folders are different-there will be no override
     Items.Project.ProjectProxy.IncludeToCanonical[buildItem.Include] = path;
 }
Example #32
0
 public ItemProperties(ItemNode item)
 {
     this.node = item.HierarchyNode;
     this.item = item.HierarchyNode.ExtensibilityObject as ProjectItem;
     this.msBuild = item.HierarchyNode.VsHierarchy as IVsBuildPropertyStorage;
     if (System.Diagnostics.Debugger.IsAttached)
         debugString = string.Join(Environment.NewLine, GetDynamicMemberNames()
             .Select(name => name + "=" + GetValue(name)));
 }
 protected ShadowFolderNode(ItemList items, ItemNode parent, uint itemId, Constants.ItemNodeType type, string path)
     : base(items, parent, itemId, type, path)
 {
     uint child = items.Project.GetNodeChild(itemId);
     while (child != VSConstants.VSITEMID_NIL)
     {
         CreateChildNode(child);
         child = items.Project.GetNodeSibling(child);
     }
     MapChildren();
 }
Example #34
0
 /// <summary>
 /// Constructs a new item node
 /// </summary>
 /// <param name="itemId">Thie node's item ID</param>
 /// <param name="parent">The node's parent</param>
 public ItemNode(int itemId, ItemNode parent)
 {
     this.parent = parent;
     children = new Dictionary<int, ItemNode>();
     totalOccurrences = 0;
     this.itemId = itemId;
     thirtySecondIntervals = new Dictionary<int, int>();
     IsSelfPenalized = false;
 }
Example #35
0
 /// <summary>
 /// Recursively resets the isSelfPenalized flag (for pruning the tree) in all nodes of the tree
 /// </summary>
 /// <param name="root">The root item node</param>
 private void ResetAllPenalizeValues(ItemNode root)
 {
     root.IsSelfPenalized = false;
     foreach (ItemNode child in root.children.Values)
     {
         ResetAllPenalizeValues(child);
     }
 }
Example #36
0
 public ItemLinkedListEnumerator(ItemLinkedList linkedList)
 {
     this.linkedList			= linkedList;
     startingNode			= new ItemNode(null);//linkedList.HeaderNode;
     startingNode.NextNode = linkedList.HeaderNode;
     currentNode				= startingNode;
     //currentNode.NextNode	= linkedList.HeaderNode;
 }
 public ExcludedFolderNode(ItemList items, ItemNode parent, string path)
     : base(items, parent, Constants.ItemNodeType.ExcludedFolder, path)
 {
 }
Example #38
0
        /// <summary>
        /// TODO: Documentation ProcessRosterItem
        /// </summary>
        /// <param name="ri"></param>
        private void ProcessRosterItem(Item ri)
        {
            bool remove = ri.Subscription == Subscription.remove;

            LinkedList nodelist = m_items[ri.JID.ToString()] as LinkedList;

            if (nodelist == null)
            {
                // First time through.
                if (!remove)
                {
                    nodelist = new LinkedList();
                    m_items.Add(ri.JID.ToString(), nodelist);
                }
            }
            else
            {
                // update to an existing item. remove all of them, and start over.
                foreach (ItemNode i in nodelist)
                    this.RemoveItemNode(i);

                nodelist.Clear();

                if (remove)
                    m_items.Remove(ri.JID.ToString());
            }

            if (remove)
                return;

            if (this.ExcludeRosterItem(ri))
                return;

            // add the new ones back
            Hashtable ghash = new Hashtable();
            Group[] groups = ri.GetGroups();

            foreach (Group g in groups)
            {
                if (String.IsNullOrEmpty(g.GroupName))
                    g.GroupName = this.Unfiled;
            }

            if (groups.Length == 0)
            {
                groups = new Group[] { new Group(ri.OwnerDocument) };
                groups[0].GroupName = this.Unfiled;
            }

            foreach (Group g in groups)
            {
                // might have the same group twice.
                if (ghash.Contains(g.GroupName))
                    continue;

                ghash.Add(g.GroupName, g);

                if (this.Client.SupportNestedGroups)
                {
                    IEnumerable<String> groupies = this.ConstructNestedGroupList(g.GroupName);
                    Boolean useContinue = false;

                    foreach (String groupie in groupies)
                    {
                        if (this.m_excludedGroups.ContainsKey(groupie))
                        {
                            useContinue = true;
                            break;
                        }
                    }

                    if (useContinue)
                        continue;
                }
                else
                {
                    if (this.m_excludedGroups.ContainsKey(g.GroupName))
                        continue;
                }

                ItemNode i = new ItemNode(ri);
                i.ChangePresence(m_pres[ri.JID]);
                nodelist.Add(i);

                GroupNode gn = this.AddGroupNode(g);
                gn.Nodes.Add(i);
            }
        }
Example #39
0
 public virtual void Reset()
 {
     currentNode				= startingNode;
 }
Example #40
0
 /// <summary>
 /// Includes the file represented by the Excluded Node into the project
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 internal int IncludeFileItem(ItemNode node)
 {
     var path = node.Path;
     var parent = ensure_included(node.Parent);
     // It is necessary to re-acquire the node, because the ensure_included might'of recreated it
     this[path].Delete();
     return Project.ProjectProxy.AddFileItem(parent, path);
 }
Example #41
0
 /// <summary>
 /// Constructs a new instance of ChampionItemBuilds
 /// </summary>
 public ChampionItemBuilds()
 {
     RootObjectNode = new ItemNode(0, null);
     totalItemsBuilt = new Dictionary<int, int>();
 }
Example #42
0
 /// <summary>
 /// Registers the itemNode in the ItemList internal lists/dictionaries
 /// </summary>
 /// <param name="itemNode"></param>
 internal void Register(ItemNode itemNode)
 {
     itemMap.Add(itemNode.ItemId, itemNode);
     // from the standpoint of IVsHierarchy rename is handled by the F# project
     // as remove/add, therefore item path is never changed during item lifetime
     // and can considered to be immutable
     itemKeyMap.Add(itemNode.Path, itemNode);
 }
Example #43
0
        /// <summary>
        /// Includes all files in the Excluded folder in the project 
        /// </summary>
        /// <param name="node">Excluded Node representing the folder</param>
        /// <returns></returns>
        internal int IncludeFolderItem(ItemNode node)
        {
            var path = node.Path;

            ensure_included(node);

            // It is necessary to re-acquire the node, because the ensure_included recreated it
            var folder_node = this[path];

            foreach (var child in new List<ItemNode>(folder_node))
            {
                switch (child.Type)
                {
                    case Constants.ItemNodeType.ExcludedFile:
                        child.Delete();
                        ErrorHandler.ThrowOnFailure(Project.ProjectProxy.AddFileItem(folder_node.ItemId, child.Path));
                        break;
                    case Constants.ItemNodeType.ExcludedFolder:
                        IncludeFolderItem(child);
                        break;
                    default:
                        break;
                }
            }

            return VSConstants.S_OK;
        }
Example #44
0
 private uint ensure_included(ItemNode node)
 {
     if (node.Type == Constants.ItemNodeType.ExcludedFolder)
     {
         // 1. save the path for future use after the node is deleted. The node will still be around
         //      even though it is deleted, so I could've accessed it as node.Path when I would have needed it
         //      but it feels weird - accessing object fields after it has been deleted
         var path = node.Path;
         // 2. make sure the parent is ok
         ensure_included(node.Parent);
         // 3. delete the node with all its children. It is necessary to re-acquire the node, because
         //      the ensure_included might'of recreated it
         this[path].Delete();
         // 4. re-add the node as the 'real' one
         var result = Project.ProjectProxy.AddFolderItem(path);
         // 5. re-add children nodes
         this[path].SetShowAll(true);
         return result;
     }
     else
         return node.ItemId;
 }
Example #45
0
 /// <summary>
 /// Initalizes a new instance of the itemlist
 /// </summary>
 /// <param name="project"></param>
 public ItemList(ProjectManager project)
 {
     this.Project = project;
     root_hierarchy = (IVsHierarchy)project;
     root = CreateNode(VSConstants.VSITEMID_ROOT);
 }
        protected override void OnDragDrop(DragEventArgs e)
        {
            base.OnDragDrop(e);
            if (dragDropTreeNode != null)
            {
                ItemNode node = null;
                if (e.Data.GetDataPresent(typeof(TypeNode)))
                    node = (TypeNode)e.Data.GetData(typeof(TypeNode));
                else if(e.Data.GetDataPresent(typeof(PackageNode)))
                    node = (PackageNode)e.Data.GetData(typeof(PackageNode));
                else if (e.Data.GetDataPresent(typeof(DiagramNode)))
                    node = (DiagramNode)e.Data.GetData(typeof(DiagramNode));

                if (node != null && node != dragDropTreeNode)
                {
                    IProjectItemNode item = node as IProjectItemNode;
                    try
                    {
                        ContainerNode container = null;

                        if (dragDropTreeNode is ContainerNode)
                            container = (ContainerNode)dragDropTreeNode;
                        else if (dragDropTreeNode.Parent is ContainerNode)
                            container = (ContainerNode)dragDropTreeNode.Parent;

                        if (container != null && container != node.Parent && container.PackageBase.ProjectInfo == item.ProjectItem.ProjectInfo)
                        {
                            item.ProjectItem.Package.Move(item.ProjectItem, container.PackageBase);
                            node.Remove();//从原父节点移除被拖得节点  
                            container.Nodes.Add(node);//添加被拖得节点到新节点下面  
                            if (!container.IsExpanded)
                                container.Expand();//展开节点
                            SelectedNode = node;
                        }
                        else
                        {
                            //TODO may be need to Copy the node to another project.
                        }
                    }
                    catch (Exception exc)
                    {
                        Client.ShowInfo(exc.Message);
                    }
                }
                //取消被放置的节点高亮显示  
                dragDropTreeNode.BackColor = GetNormalBackColor();
                dragDropTreeNode.ForeColor = GetNormalForeColor(); 
                dragDropTreeNode = null;
            }
        }
 public ShadowFileNode(ItemList items, ItemNode parent, uint itemId, string path)
     : base(items, parent, itemId, Constants.ItemNodeType.PhysicalFile, path)
 {
 }
 public ExcludedFolderNode(ItemList items, ItemNode parent, string path)
     : base(items, parent, Constants.ItemNodeType.ExcludedFile, path)
 {
     SetShowAll(true);
 }
Example #49
0
 /// <summary>
 /// Determines whether or not this item already exist in the given ItemNode's path (detects duplicate items in a build path)
 /// </summary>
 /// <param name="leafNode">The leaf node of the item path to check</param>
 /// <param name="itemId">The item ID to check for existence</param>
 /// <returns>Whether or not the item exists</returns>
 private bool ItemAlreadyInPath(ItemNode leafNode, int itemId)
 {
     while (leafNode != RootObjectNode)
     {
         if (leafNode.itemId == itemId)
         {
             return true;
         }
         leafNode = leafNode.parent;
     }
     return false;
 }
Example #50
0
 /// <summary>
 /// Recursively merges this node (and all children) with another node
 /// </summary>
 /// <param name="other">The node to merge with</param>
 public void RecursiveMerge(ItemNode other)
 {
     Debug.Assert(itemId == other.itemId);
     totalWins += other.totalWins;
     totalOccurrences += other.totalOccurrences;
     totalBuildTime += other.totalBuildTime;
     foreach (var kvp in other.thirtySecondIntervals)
     {
         thirtySecondIntervals.GetOrAddDefault(kvp.Key);
         thirtySecondIntervals[kvp.Key] += kvp.Value;
     }
     foreach (var kvp in other.children)
     {
         if (children.ContainsKey(kvp.Key))
         {
             children[kvp.Key].RecursiveMerge(kvp.Value);
         }
         else
         {
             children[kvp.Key] = kvp.Value;
             children[kvp.Key].parent = this;
         }
     }
 }
Example #51
0
        /// <summary>
        /// TODO: Documentation RemoveItemNode
        /// </summary>
        /// <param name="itemNode"></param>
        private void RemoveItemNode(ItemNode itemNode)
        {
            GroupNode groupNode = itemNode.Parent as GroupNode;
            itemNode.Remove();

            this.RemoveGroupNode(groupNode);
        }
Example #52
0
        private void m_roster_OnRosterItem(object sender, jabber.protocol.iq.Item ri)
        {
            bool remove = (ri.Subscription == Subscription.remove);

            LinkedList nodelist = (LinkedList)m_items[ri.JID.ToString()];
            if (nodelist == null)
            {
                // First time through.
                if (!remove)
                {
                    nodelist = new LinkedList();
                    m_items.Add(ri.JID.ToString(), nodelist);
                }
            }
            else
            {
                // update to an existing item.  remove all of them, and start over.
                foreach (ItemNode i in nodelist)
                {
                    GroupNode gn = i.Parent as GroupNode;
                    i.Remove();
                    if ((gn != null) && (gn.Nodes.Count == 0))
                    {
                        m_groups.Remove(gn.GroupName);
                        gn.Remove();
                    }
                }
                nodelist.Clear();
                if (remove)
                    m_items.Remove(ri.JID.ToString());
            }

            if (remove)
                return;

            // add the new ones back
            Hashtable ghash = new Hashtable();
            Group[] groups = ri.GetGroups();
            for (int i=groups.Length-1; i>=0; i--)
            {
                if (groups[i].GroupName == "")
                    groups[i].GroupName = UNFILED;
            }

            if (groups.Length == 0)
            {
                groups = new Group[] { new Group(ri.OwnerDocument) };
                groups[0].GroupName = UNFILED;
            }

            foreach (Group g in groups)
            {
                GroupNode gn = AddGroupNode(g);
                // might have the same group twice.
                if (ghash.Contains(g.GroupName))
                    continue;
                ghash.Add(g.GroupName, g);

                ItemNode i = new ItemNode(ri);
                i.ChangePresence(m_pres[ri.JID]);
                nodelist.Add(i);
                gn.Nodes.Add(i);
            }
        }
Example #53
0
        public int Add(object value)
        {
            if(_HeaderNode == null)
            {
                _HeaderNode = new ItemNode(value);
            }
            else
            {
                ItemNode item = HeaderNode;
                while(item.NextNode != null)
                {
                    item = item.NextNode;
                }

                ItemNode newItem = new ItemNode(value);
                item.NextNode = newItem;
            }
            _Count++;
            return _Count;
        }
Example #54
0
		public ItemProperties (ItemNode item)
		{
			this.item = item.HierarchyNode.GetExtenderObject () as ProjectItem;
			node = item.HierarchyNode;
			msBuild = item.HierarchyNode.GetRoot ().HierarchyIdentity.Hierarchy as IVsBuildPropertyStorage;
		}
Example #55
0
            public virtual bool MoveNext()
            {
                bool moveSuccessful = false;

                currentNode = currentNode.NextNode;

                if (currentNode!=null/* && currentNode != linkedList.HeaderNode*/)
                    moveSuccessful = true;

                return moveSuccessful;
            }
Example #56
0
            /// <summary>
            /// Adds or updates a child to this node with the specified item ID
            /// </summary>
            /// <param name="itemId">The child's item id</param>
            /// <param name="timeInSec">The child's build time, in seconds</param>
            /// <param name="wonGame">Whether or not the child node won the game</param>
            /// <returns></returns>
            public ItemNode AddChild(int itemId, int timeInSec, bool wonGame)
            {
                ItemNode child;
                if (children.ContainsKey(itemId))
                {
                    child = children[itemId];
                    if (children[itemId].parent != this)
                    {
                        Debug.Assert(children[itemId].parent == this);
                    }
                }
                else
                {
                    child = new ItemNode(itemId, this);
                    children[itemId] = child;
                    if (children[itemId].parent != this)
                    {
                        Debug.Assert(children[itemId].parent == this);
                    }
                }

                child.totalOccurrences++;
                if (wonGame)
                {
                    child.totalWins++;
                }
                int thirtySecondBucket = timeInSec / 30;
                child.totalBuildTime += timeInSec;
                child.thirtySecondIntervals.GetOrAddDefault(thirtySecondBucket);
                child.thirtySecondIntervals[thirtySecondBucket]++;
                return child;
            }
 public PhysicalFolderNode(ItemList items, ItemNode parent, uint itemId, string path)
     : base(items, parent, itemId, Constants.ItemNodeType.PhysicalFolder, path)
 {
 }
 protected override void OnDragLeave(EventArgs e)
 {
     base.OnDragLeave(e);
     if (dragDropTreeNode != null) //在按下{ESC},取消被放置的节点高亮显示  
     {
         dragDropTreeNode.BackColor = GetNormalBackColor();
         dragDropTreeNode.ForeColor = GetNormalForeColor();
         dragDropTreeNode = null;
     }
 }
        protected override void OnDragOver(DragEventArgs e)
        {
            base.OnDragOver(e);
            try
            {
                //当光标悬停在 TreeView 控件上时,展开该控件中的 TreeNode  
                Point p = PointToClient(Control.MousePosition);
                TreeNode node = GetNodeAt(p);
                if (node != null)
                {
                    ExpandNode(node);

                    Project project = null;
                    if (node is ContainerNode)
                        project = (node as ContainerNode).PackageBase.ProjectInfo;
                    else if (node is IProjectItemNode)
                        project = (node as IProjectItemNode).ProjectItem.ProjectInfo;

                    //设置拖放标签Effect状态  
                    if (project != null && node != SelectedNode) //当控件移动到空白处时,设置不可用。  
                    {
                        if ((e.AllowedEffect & DragDropEffects.Move) != 0)
                            e.Effect = DragDropEffects.Move;
                        if(IsChildNode(node))
                            e.Effect = DragDropEffects.None;
                        else if (e.Data.GetDataPresent(typeof(PackageNode)))
                        {
                            var n = (PackageNode)e.Data.GetData(typeof(PackageNode));
                            if (project != n.ProjectItem.ProjectInfo)//判断是否相同Project  
                                e.Effect = DragDropEffects.None;
                        }
                        else if (e.Data.GetDataPresent(typeof(TypeNode)))
                        {
                            var n = (TypeNode)e.Data.GetData(typeof(TypeNode));
                            if (project != n.ProjectItem.ProjectInfo)//判断是否相同Project
                                e.Effect = DragDropEffects.None;
                        }
                        else if (e.Data.GetDataPresent(typeof(DiagramNode)))
                        {
                            var n = (DiagramNode)e.Data.GetData(typeof(DiagramNode));
                            if (project != n.ProjectItem.ProjectInfo)//判断是否相同Project
                                e.Effect = DragDropEffects.None;
                        }
                    }
                    else
                        e.Effect = DragDropEffects.None;
                }
                else
                    e.Effect = DragDropEffects.None;

                //设置拖放目标TreeNode的背景色  
                if (e.Effect == DragDropEffects.None)
                {
                    if (dragDropTreeNode != null) //取消被放置的节点高亮显示  
                    {
                        dragDropTreeNode.BackColor = GetNormalBackColor();
                        dragDropTreeNode.ForeColor = GetNormalForeColor();
                        dragDropTreeNode = null;
                    }
                }
                else if (node != null)
                {
                    if (dragDropTreeNode == null)
                    {
                        dragDropTreeNode = node as ItemNode;//设置为新的节点  
                        dragDropTreeNode.BackColor = GetTrackingBackColor();
                        dragDropTreeNode.ForeColor = GetTrackingForeColor();
                    }
                    else if (dragDropTreeNode != node)
                    {
                        dragDropTreeNode.BackColor = GetNormalBackColor();//取消上一个被放置的节点高亮显示  
                        dragDropTreeNode.ForeColor = GetNormalForeColor();
                        dragDropTreeNode = node as ItemNode;//设置为新的节点  
                        dragDropTreeNode.BackColor = GetTrackingBackColor();
                        dragDropTreeNode.ForeColor = GetTrackingForeColor();
                    }
                }
            }
            catch (Exception exc)
            {
                Client.ShowInfo(exc.Message);
            }
        }
 public SubprojectNode(ItemList items, ItemNode parent, uint itemId, string path)
     : base(items, parent, itemId, Constants.ItemNodeType.SubProject, path)
 {
 }