示例#1
0
        private void btnEditItemHierarchy_Click(object sender, EventArgs e)
        {
            try
            {
                flContainer.Visible = true;
                SelectedItemNode    =
                    this.ItemHierarchyList.Where(a => (a.Nodecode ?? "") == (string)treeView1.SelectedNode.Tag)
                    .ToList()
                    .FirstOrDefault();

                if (SelectedItemNode.TreeCode == SelectedItemNode.Nodecode &&
                    SelectedItemNode.NodeType == (int)EnumSave.Tree)
                {
                    SaveMode = (int)EnumSave.Tree;
                }
                else
                {
                    SaveMode = (int)EnumSave.Node;
                }

                switch (SaveMode)
                {
                case (int)EnumSave.Tree:
                    lblItemHierarchyDetails2.Text        = "Item Hierarchy Details(Edit)";
                    lblItemHierarchyDetails2.Visible     = true;
                    flowLtDefinesLevels.Visible          = true;
                    tbllayoutPanelItemHierarchy2.Visible = false;
                    panelDbAction.Visible = true;
                    FillTree();
                    flContainer.Top = panelScreenAction.Bottom + 10;
                    break;

                case (int)EnumSave.Node:
                    lblItemHierarchyDetails2.Text        = "Item Hierarchy Details(Edit)";
                    lblItemHierarchyDetails2.Visible     = true;
                    tbllayoutPanelItemHierarchy2.Visible = true;
                    panelDbAction.Visible = true;
                    FillNode();
                    flContainer.Top = panelScreenAction.Bottom + 10;
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Logger.Log(ex, Logger.LogingLevel.Error);
            }
        }
示例#2
0
        /**
        @brief Converts a string with 0-n lines of text into a list of ChecklistItems.
        The text in each line will be used as the ChecklistItem's titles.

        Lines that contain only whitespace will be ignored. Newline delimiter are \r and \n (in
        any order and combination).

        @param items The multiline text that will be converted to a list of ChecklistItems.
        @return A list of ChecklistItems with the Titles specified in items.
        **/
        public static List<ChecklistItem> FromText(string items)
        {
            string[] lines = items.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
            var indents = new Stack<ItemHierarchy>();
            var rootItem = new ItemHierarchy
            {
                indent = 0,
                item = new ChecklistItem()
                {
                    Items = new List<ChecklistItem>()
                }
            };
            indents.Push(rootItem);
            FromTextImpl(lines, 0, indents);
            return rootItem.item.Items;
        }
        internal void FillContentSpecific(ItemHierarchy hierarchy)
        {
            treeViewItems.Nodes.Clear();
            _selectedItem = null;
            List <Item> top = Configuration.Instance.GetItems(hierarchy);

            FillNodes(top, treeViewItems.Nodes);
            if (EnvironmentManager.Instance.MasterSite != null)
            {
                Item site = EnvironmentManager.Instance.GetSiteItem(EnvironmentManager.Instance.MasterSite);
                if (site != null)
                {
                    TreeNode tn = new TreeNode("Site-Hierarchy");
                    tn.ImageIndex = tn.SelectedImageIndex = VideoOS.Platform.UI.Util.FolderIconIx;
                    treeViewItems.Nodes.Add(tn);
                    FillNodes(new List <Item>()
                    {
                        site
                    }, tn.Nodes);
                }
            }
        }
        private void OnTest(object sender, EventArgs e)
        {
            treeView.Nodes.Clear();
            treeView.ImageList = VideoOS.Platform.UI.Util.ImageListClone;
            TreeNode tn = new TreeNode("Top");

            tn.ImageIndex = tn.SelectedImageIndex = 0;
            treeView.Nodes.Add(tn);
            ItemHierarchy ih = ItemHierarchy.UserDefined;

            List <Item> all        = Configuration.Instance.GetItems(ih);
            List <Item> scRelevant = new List <Item>();

            foreach (Item item in all)
            {
                if (item.FQID.Kind == Kind.View)
                {
                    scRelevant.Add(item);
                }
            }

            DumpItems(tn, null, scRelevant, 0, true, true, true, true, true);
        }
示例#5
0
 public ItemsController(ItemHierarchy hierarchy)
 {
     Hierarchy = hierarchy;
 }
示例#6
0
 private static void FromTextImpl(string[] lines, int startIndex, Stack<ItemHierarchy> indents)
 {
     for (int i = startIndex; i < lines.Length; ++i)
     {
         string line = lines[i];
         ItemHierarchy currentItem = indents.Peek();
         int currentIndent = currentItem.indent;
         int lineIndent = FindFirstNonWhitespace(line);
         if (lineIndent == currentIndent ||
             (indents.Count == 1 &&
             (currentItem.item.Items == null || currentItem.item.Items.Count == 0)))
         {
             // Same indentation depths, or there are no lines before this one:
             string trimmed = line.Trim();
             if (trimmed.Length > 0)
             {
                 if (currentItem.item.Items == null)
                 {
                     currentItem.item.Items = new List<ChecklistItem>();
                 }
                 currentItem.item.Items.Add(new ChecklistItem() { Title = trimmed });
             }
         }
         else if (lineIndent > currentIndent)
         {
             // Create child nodes:
             var newIndentItem = new ItemHierarchy()
             {
                 indent = lineIndent,
                 item = currentItem.item.Items[currentItem.item.Items.Count - 1]
             };
             indents.Push(newIndentItem);
             FromTextImpl(lines, i, indents);
             break;
         }
         else {
             // Indentation is less deep than previous line -
             // find the corresponding parent item this line should be
             // a child node of.
             ItemHierarchy newIndentItem;
             do
             {
                 if (indents.Count == 1)
                 {
                     newIndentItem = indents.Peek();
                 }
                 else
                 {
                     newIndentItem = indents.Pop();
                 }
             } while (indents.Count > 1);
             FromTextImpl(lines, i, indents);
             break;
         }
     }
 }
示例#7
0
        private void treeView1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                lblItemHierarchyDetails.Visible = true;
                // Root
                // Tree Root
                // Other node


                if (treeView1.SelectedNode.Tag == "Root")
                {
                    HideAllControls();
                    lblItemHierarchyDetails.Visible = true;
                    btnNewTree.Visible = true;
                }
                else
                {
                    SelectedItemNode = this.ItemHierarchyList.Where(a => (a.Nodecode ?? "") == (string)treeView1.SelectedNode.Tag).ToList().FirstOrDefault();
                    if (SelectedItemNode.TreeCode == SelectedItemNode.Nodecode && SelectedItemNode.NodeType == (int)EnumSave.Tree)
                    {
                        SaveMode = (int)EnumSave.Tree;
                    }
                    else
                    {
                        SaveMode = (int)EnumSave.Node;
                    }
                    HideAllControls();
                    lblItemHierarchyDetails.Visible      = true;
                    tbllayoutPanelItemHierarchy1.Visible = true;
                    panelScreenAction.Visible            = true;

                    lbltp1TreeCode.Text       = SelectedItemNode.TreeCode;
                    lbltp1TreeName.Text       = SelectedItemNode.TreeName;
                    lbltp1LevelName.Text      = SelectedItemNode.LevelName;
                    lbltp1ItemCodeName.Text   = SelectedItemNode.NodeName;
                    lbltp1NodeCode.Text       = SelectedItemNode.Nodecode;
                    lbltp1ParentNodeCode.Text = SelectedItemNode.ParentNodecode;
                    lbltp1NodeLevel.Text      = SelectedItemNode.LevelCode;
                    IsLastNode = (bool)SelectedItemNode.ISThisLastNode;
                    if (SaveMode != (int)EnumSave.Tree)
                    {
                        lbltp1ActiveSubNode.Text         = this.articleHierarchyManager.GetChildArticleNoCount(SelectedItemNode.Nodecode).ToString();
                        lbltp1ActiveArticles.Text        = this.articleHierarchyManager.GetActiveArticlesNoCount(SelectedItemNode.Nodecode).ToString();
                        lbltp1NodeHierarachy.Text        = this.articleHierarchyManager.GetArticleHierarchyString(SelectedItemNode.Nodecode, true).ToString();
                        lbltp1NodeHierarachy.UseMnemonic = false;
                    }
                    else
                    {
                        lbltp1ActiveSubNode.Text  = "NA";
                        lbltp1ActiveArticles.Text = "NA";
                        lbltp1NodeHierarachy.Text = "NA";
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Logger.Log(ex, Logger.LogingLevel.Error);
            }
        }
示例#8
0
 public UnitTest1()
 {
     Items = new ItemHierarchy();
 }