示例#1
0
        public void DefaulPropertiesAndFunctionsShouldWork()
        {
            var tree = new ItemTree();

            Assert.IsNotNull(tree.Items);
            tree.Items = new List <ItemList>();
        }
示例#2
0
        /// <summary>
        /// 创建词库树
        /// </summary>
        /// <param name="words">敏感词组</param>
        /// <returns></returns>
        private List <ItemTree> CreateTree(string[] words)
        {
            List <ItemTree> tree = null;

            if (words != null && words.Length > 0)
            {
                tree = new List <ItemTree>();

                foreach (var item in words)
                {
                    if (!string.IsNullOrEmpty(item))
                    {
                        char cha = item[0];

                        ItemTree node = tree.Find(e => e.Item == cha);
                        if (node != null)
                        {
                            AddChildTree(node, item);
                        }
                        else
                        {
                            tree.Add(CreateSingleTree(item));
                        }
                    }
                }
            }

            return(tree);
        }
示例#3
0
 private void LoadTree()
 {
     ItemTree.Nodes.Clear();
     ItemTree.BeginUpdate();
     LoadItem(root, ItemTree.Nodes);
     ItemTree.EndUpdate();
 }
示例#4
0
        public static int FindByPath(ItemTree tree, StringStore strings, string path, char delimiter = '\\')
        {
            String8    path8      = String8.Convert(path, new byte[String8.GetLength(path)]);
            String8Set pathSplit8 = path8.Split(delimiter, new int[String8Set.GetLength(path8, delimiter)]);

            return(tree.FindByPath(0, pathSplit8, strings));
        }
示例#5
0
        private void AddControlRecursivly(VisualItem aRoot)
        {
            VisualItem visualItem = aRoot;
            ItemTree   item       = aRoot.Item;

            if (!visualItem.IsFiltered)
            {
                return;
            }
            Control control = fParams.container;
            Type    type;

            if (fStringToType.TryGetValue(item.type, out type))
            {
                AddControl(aRoot, type);
            }

            //Add children
            if (visualItem.subitems != null)
            {
                foreach (VisualItem subItem in visualItem.subitems)
                {
                    AddControlRecursivly(subItem);
                }
            }
        }
示例#6
0
        private bool ApplyFilterRecursively(VisualItem root)
        {
            VisualItem visualItem = root;
            ItemTree   item       = root.Item;

            if (fParams.filter == null || String.IsNullOrEmpty(fParams.filter.IncludeName) || String.IsNullOrWhiteSpace(fParams.filter.IncludeName))
            {
                visualItem.IsFiltered = true;
            }
            else
            {
                if (item.type == "menu" || item.type == "root")
                {
                    visualItem.IsFiltered = true;
                }
                else
                if (item.displayname != null)
                {
                    visualItem.IsFiltered = item.displayname.ToLower().Contains(fParams.filter.IncludeName.ToLower());
                }
            }

            if (item.subitems != null)
            {
                bool isFiltered = false;
                foreach (VisualItem subItem in visualItem.subitems)
                {
                    isFiltered |= ApplyFilterRecursively(subItem);
                }

                //if at least one of the childs is visible then the parent is visible as well.
                visualItem.IsFiltered = isFiltered;
            }
            return(visualItem.IsFiltered);
        }
示例#7
0
        public static void BuildQualifiedNames(Dictionary <string, ItemTree> aQualifiedNames, ItemTree item, ItemTree parent)
        {
            ItemTree currentParent = parent == null || parent.type == "root" ? null : parent;

            if (currentParent == null)
            {
                item.FullName = item.name;
            }
            else
            {
                item.FullName = String.Format("{0}{1}{2}", currentParent.FullName, QualifiedNameSeperator, item.name);
            }

            if (item.subitems != null)
            {
                foreach (ItemTree subItem in item.subitems)
                {
                    BuildQualifiedNames(aQualifiedNames, subItem, item);
                }
            }

            if (item.FullName != null && item.type != "menu")
            {
                aQualifiedNames.Add(item.FullName, item);
            }
        }
示例#8
0
        private bool MatchesDetailed(ItemTree declaredMembers, StringStore strings, IMemberDatabase db, int symbolIndex)
        {
            if (!Matches(declaredMembers, strings, symbolIndex))
            {
                return(false);
            }

            if (Type != SymbolType.Any && db.GetMemberType(symbolIndex) != Type)
            {
                return(false);
            }
            if (!Modifiers.Matches(db.GetMemberModifiers(symbolIndex)))
            {
                return(false);
            }

            // ISSUE: Need a way to specify you want the empty params overload of a method (other than full match)
            // NOTE: Parameters8 was a copy gotten from StringStore to make this comparison fast (rather than a byte-by-byte comparison)
            // NOTE: Case insensitive comparison because StringStore lookup was case-insensitive, so Parameters8 casing isn't specific
            // NOTE: Need String8 rather than just checking Range.Contains because IMemberDatabase doesn't offer returning the identifier
            if ((IsFullSuffix || !this.ParametersIdentifiers.IsEmpty()) && db.GetMemberParameters(symbolIndex).CompareTo(Parameters8, true) != 0)
            {
                return(false);
            }

            return(true);
        }
示例#9
0
        private bool Matches(ItemTree declaredMembers, StringStore strings, int symbolIndex)
        {
            int candidateNameIdentifier = declaredMembers.GetNameIdentifier(symbolIndex);

            if (!SymbolNameSuffixIdentifiers.Contains(candidateNameIdentifier))
            {
                return(false);
            }

            if (this.IgnoreCase == true)
            {
                return(true);
            }
            else
            {
                String8 candidateName8 = strings[candidateNameIdentifier];
                if (this.IsFullSuffix)
                {
                    return(this.SymbolNameSuffix.CompareTo(candidateName8, false) == 0);
                }
                else
                {
                    return(this.SymbolNameSuffix.CompareAsPrefixTo(candidateName8, false) == 0);
                }
            }
        }
        /*--------------------------------------------------------------------------------------------*/
        private bool IsItemTreeActive(ItemTree pTree)
        {
            IBaseItem baseItem = pTree.Item.Item;

            return(baseItem.IsVisible && baseItem.IsEnabled &&
                   baseItem.IsAncestryVisible && baseItem.IsAncestryEnabled);
        }
示例#11
0
        private void ProcessEvents(VisualItem aVisualItem)
        {
            Control  t     = aVisualItem.controlsGroup.control;
            Control  p     = aVisualItem.controlsGroup.parentContainer;
            Control  l     = aVisualItem.controlsGroup.label;
            ItemTree aItem = aVisualItem.Item;

            switch (aItem.type)
            {
            case "menu":
                (l as Control).DoubleClick += Menu_DoubleClick;
                break;

            case "bool":
                (t as CheckBox).MouseClick += CheckBox_MouseClick;
                (p as Control).MouseClick  += CheckBox_MouseClick;
                (l as Control).MouseClick  += CheckBox_MouseClick;
                break;

            case "text":
                (t as TextBox).TextChanged += MenuSettings_TextChanged;
                (t as TextBox).Leave       += TextBox_Leave;
                (t as TextBox).Enter       += TextBox_Enter;
                break;

            case "number":
                (t as TextBox).TextChanged += MenuSettings_NumberChanged;
                (t as TextBox).Leave       += TextBox_Leave;
                (t as TextBox).Enter       += TextBox_Enter;
                break;

            case "integral":
                (t as TextBox).TextChanged += MenuSettings_IntegralChanged;
                (t as TextBox).Leave       += TextBox_Leave;
                (t as TextBox).Enter       += TextBox_Enter;
                break;

            case "combo":
                (t as ComboBox).SelectedIndexChanged += c_SelectedIndexChanged;
                (t as ComboBox).MouseDoubleClick     += Combo_MouseDoubleClick;

                break;

            case "image":
                (t as TextBox).TextChanged      += MenuSettings_TextChanged;
                (t as TextBox).MouseDoubleClick += MenuSettings_MouseDoubleClick;
                (t as TextBox).MouseLeave       += MenuSettings_MouseLeave;
                (t as TextBox).MouseHover       += MenuSettings_MouseHover;
                break;

            case "color":
                (t as ColorControl).KeyDown     += ColorControl_KeyDown;
                (t as ColorControl).TextChanged += ColorControl_TextChanged;
                (t as Control).DoubleClick      += MenuSettings_Click;
                (p as Control).Click            += MenuSettings_Click;
                (l as Control).Click            += MenuSettings_Click;
                break;
            }
        }
示例#12
0
 /// <summary>
 /// 权限分配
 /// </summary>
 /// <param name="Role"></param>
 /// <returns></returns>
 public ActionResult PowerSet(Guid ID)
 {
     if (Request.HttpMethod.ToUpper() == MethodType.GET)
     {
         ViewBag.ID = ID;
         return(View());
     }
     else
     {
         var           role      = Manager.Get(ID);
         string        sPowerStr = role.sPowerIds;
         List <string> sMenuIds  = new List <string>();
         List <string> sBtnIds   = new List <string>();
         if (sPowerStr != null && sPowerStr.Contains("|"))
         {
             sMenuIds = sPowerStr.Split('|')[0].Split(',').ToList();
             sBtnIds  = sPowerStr.Split('|')[1].Split(',').ToList();
         }
         var ListTree = new List <ItemTree>();
         //组织菜单数据
         foreach (var item in (IEnumerable <dynamic>)Session[SessionType.MENU])
         {
             var tree = new ItemTree()
             {
                 id         = item.ID.ToString(),
                 pid        = item.sParentId,
                 text       = item.sName,
                 iconCls    = item.sIcon,
                 attributes = item.iType, //1表示菜单 2 表示按钮
             };
             if (sMenuIds.Contains(item.ID.ToString()))
             {
                 tree.selected = true;
             }
             ListTree.Add(tree);
         }
         //组织按钮数据
         foreach (var item in (IEnumerable <dynamic>)Session[SessionType.BTN])
         {
             var tree = new ItemTree()
             {
                 id         = item.ID.ToString(),
                 pid        = item.sParentId,
                 text       = item.sName,
                 iconCls    = item.sIcon,
                 attributes = item.iType, //1表示菜单 2 表示按钮
             };
             if (sBtnIds.Contains(item.ID.ToString()))
             {
                 tree.selected = true;
             }
             ListTree.Add(tree);
         }
         var treeString = JsonHelper.GetTreeData(ListTree);
         return(Content(treeString));
     }
 }
示例#13
0
 public static void BuildQualifiedNames(ItemTree aRoot, out Dictionary <string, ItemTree> aQualifiedNames)
 {
     aQualifiedNames = null;
     if (aRoot.type == "root")
     {
         aQualifiedNames = new Dictionary <string, ItemTree>(StringComparer.OrdinalIgnoreCase);
         BuildQualifiedNames(aQualifiedNames, aRoot, null);
     }
 }
示例#14
0
        void SortByMultipleColumns(IList <TreeViewItem> rows)
        {
            var sortedColumns = multiColumnHeader.state.sortedColumns;

            if (sortedColumns.Length == 0)
            {
                return;
            }

            var columnAscending = new bool[sortedColumns.Length];

            for (var i = 0; i < sortedColumns.Length; i++)
            {
                columnAscending[i] = multiColumnHeader.IsSortedAscending(sortedColumns[i]);
            }

            var root  = new ItemTree(null, m_Desc);
            var stack = new Stack <ItemTree>();

            stack.Push(root);
            foreach (var row in rows)
            {
                var r = row as IssueTableItem;
                if (r == null)
                {
                    continue;
                }

                var activeParentDepth = stack.Peek().Depth;

                while (row.depth <= activeParentDepth)
                {
                    stack.Pop();
                    activeParentDepth = stack.Peek().Depth;
                }

                if (row.depth > activeParentDepth)
                {
                    var t = new ItemTree(r, m_Desc);
                    stack.Peek().AddChild(t);
                    stack.Push(t);
                }
            }

            root.Sort(sortedColumns, columnAscending);

            // convert back to rows
            var newRows = new List <TreeViewItem>(rows.Count);

            root.ToList(newRows);
            rows.Clear();
            foreach (var treeViewItem in newRows)
            {
                rows.Add(treeViewItem);
            }
        }
示例#15
0
        private void ReArrange(VisualItem aVisualItem)
        {
            if (!aVisualItem.IsFiltered || aVisualItem.Item.type == "root")
            {
                if (aVisualItem.controlsGroup != null)
                {
                    aVisualItem.controlsGroup.Visible = false;
                }
                return;
            }


            aVisualItem.controlsGroup.Visible = true;

            ItemTree          aItem = aVisualItem.Item;
            DataViewPlacement p     = fParams.placement;
            bool isMenu             = aItem.type == "menu";
            //Create parent container
            ItemControlsGroup group  = aVisualItem.controlsGroup;
            Control           parent = aVisualItem.controlsGroup.parentContainer;

            parent.Width  = p.TitleMaxWidth + p.TitleSpacing + p.ControlMaxWidth + p.ControlSpacing + p.DefaultButtonWidth;
            parent.Height = p.LineSpacing;
            aVisualItem.PanelBackgroundColor = isMenu ? Color.DarkBlue : fCurrentRow % 2 == 0 ? Color.White : Color.LightGray;
            parent.BackColor = aVisualItem.PanelBackgroundColor;

            fCurrentPanelPosition.X  = p.HorizontalMArgin * fNesting;
            parent.Location          = fCurrentPanelPosition;
            fCurrentPanelPosition.Y += p.LineSpacing;
            Point            controlPosition = new Point(0, (p.LineSpacing - p.LineHeight) / 2);
            LabelSingleClick label           = group.label;

            label.Width       = p.TitleMaxWidth;
            label.Height      = p.LineHeight;
            label.Location    = controlPosition;
            controlPosition.X = p.TitleMaxWidth + p.TitleSpacing;
            Control control = group.control;

            control.Location   = controlPosition;
            control.Height     = p.LineHeight;
            control.Width      = p.ControlMaxWidth;
            controlPosition.X += p.ControlMaxWidth + p.ControlSpacing;

            //Add a default button
            if (!isMenu)
            {
                Button button = group.defaultButton;
                button.Width    = p.DefaultButtonWidth;
                button.Height   = p.LineHeight;
                button.Location = controlPosition;
                fCurrentRow++;
            }
        }
示例#16
0
        void SortByMultipleColumns(IList <TreeViewItem> rows)
        {
            int[] sortedColumns = multiColumnHeader.state.sortedColumns;
            if (sortedColumns.Length == 0)
            {
                return;
            }

            bool[] columnAscending = new bool[sortedColumns.Length];
            for (int i = 0; i < sortedColumns.Length; i++)
            {
                columnAscending[i] = multiColumnHeader.IsSortedAscending(sortedColumns[i]);
            }

            ItemTree         root  = new ItemTree(null);
            Stack <ItemTree> stack = new Stack <ItemTree>();

            stack.Push(root);
            foreach (TreeViewItem row in rows)
            {
                ConformObjectTreeViewItem r = row as ConformObjectTreeViewItem;
                if (r == null)
                {
                    continue;
                }
                int activeParentDepth = stack.Peek().Depth;

                while (row.depth <= activeParentDepth)
                {
                    stack.Pop();
                    activeParentDepth = stack.Peek().Depth;
                }

                if (row.depth > activeParentDepth)
                {
                    ItemTree t = new ItemTree(r);
                    stack.Peek().AddChild(t);
                    stack.Push(t);
                }
            }

            root.Sort(sortedColumns, columnAscending);

            // convert back to rows
            List <TreeViewItem> newRows = new List <TreeViewItem>(rows.Count);

            root.ToList(newRows);
            rows.Clear();
            foreach (TreeViewItem treeViewItem in newRows)
            {
                rows.Add(treeViewItem);
            }
        }
示例#17
0
        private Font GetLabelFont(VisualItem aVisualItem)
        {
            if (aVisualItem.Item.type == "menu")
            {
                return(fMenuLabel);
            }

            ItemTree item = aVisualItem.Item;
            object   val  = GetValue(aVisualItem.Item);

            return(item.defaultvalue != null && val != null && !item.defaultvalue.Equals(val)
                ? fLabelBold : fLabelNormal);
        }
示例#18
0
        /// <summary>
        /// 词库初始化
        /// </summary>
        private void Init()
        {
            if (Words == null)
            {
                Words = new[] { "" }
            }
            ;

            Library = new ItemTree()
            {
                Item = 'R', IsEnd = false, Child = CreateTree(Words)
            };
        }
示例#19
0
        private void AddControl(VisualItem aVisualItem, Type aType)
        {
            ItemTree aItem = aVisualItem.Item;

            bool isMenu = aItem.type == "menu";
            bool isBool = aItem.type == "bool";
            //Create parent container
            ItemControlsGroup group  = new ItemControlsGroup();
            Control           parent = group.parentContainer = new Control();

            fParams.container.Controls.Add(parent);
            parent.Tag = aVisualItem;

            //Add label describing the entry

            LabelSingleClick label = group.label = new LabelSingleClick(!isBool);

            label.Font = GetLabelFont(aVisualItem);
            label.Text = aItem.displayname;
            label.Tag  = aVisualItem;
            parent.Controls.Add(label);

            //Add the  control itself
            Control control = group.control = Activator.CreateInstance(aType) as Control;

            parent.Controls.Add(control);
            control.Tag = aVisualItem;

            //Add reference from the menu item to the control holding the values.
            aVisualItem.controlsGroup = group;

            //Add a default button
            if (!isMenu)
            {
                Button button = group.defaultButton = new Button();
                parent.Controls.Add(button);
                button.Text      = "Default";
                button.Click    += button_Click;
                button.Tag       = aVisualItem;
                button.FlatStyle = FlatStyle.Popup;
                button.BackColor = System.Drawing.SystemColors.Control;
                fCurrentRow++;
            }

            MouseEnterLeave l = new MouseEnterLeave(parent);

            l.MouseEnter += l_MouseEnter;
            l.MouseLeave += panel_MouseLeave;
            ProceeControl(aVisualItem);
        }
示例#20
0
        private void ReArrangeRecurseivly(VisualItem aRoot)
        {
            VisualItem visualItem = aRoot;
            ItemTree   item       = aRoot.Item;

            ReArrange(visualItem);
            if (visualItem.subitems != null && (visualItem.Expanded == true || (fParams.filter != null && fParams.filter.IsEmpty() == false)))
            {
                foreach (VisualItem subItem in visualItem.subitems)
                {
                    ReArrangeRecurseivly(subItem);
                }
            }
        }
        public MergedMembersDatabase(StringStore sharedStore = null)
        {
            this.StringStore = sharedStore;
            if (this.StringStore == null)
            {
                this.StringStore = new StringStore();
            }

            this.MergedMembers = new ItemTree();
            this.MergedMemberSourcePackageIdentifier = new PartialArray <int>();
            this.MergedMemberSourcePackageIdentifier.Add(0);

            this.MergedMemberDuplicateCount = new PartialArray <int>();
            this.MergedMemberDuplicateCount.Add(0);
        }
示例#22
0
        private void RefreshControlValue(VisualItem aVisualItem)
        {
            ItemTree item = aVisualItem.Item;

            if (aVisualItem.controlsGroup != null)
            {
                Control aControl = aVisualItem.controlsGroup.control;
                object  val      = GetValue(item);
                switch (item.type)
                {
                case "bool":
                    bool _val = false;
                    if (val != null)
                    {
                        _val = (bool)val;
                    }
                    (aControl as CheckBox).Checked = _val;
                    break;

                case "text":

                    (aControl as TextBox).Text = (val != null ? (string)val : "");
                    break;

                case "number":
                    (aControl as TextBox).Text = (val != null ? ToDoubleString(((double)val)) : "");
                    break;

                case "integral":
                    (aControl as TextBox).Text = (val != null ? val.ToString() : "");
                    break;

                case "combo":
                    (aControl as ComboBox).SelectedItem = val;
                    break;

                case "image":
                    (aControl as TextBox).Text = (val != null ? val as string : "");
                    break;

                case "color":
                    (aControl as ColorControl).color = (val != null ? (Color)val : Color.Empty);

                    break;
                }
                CheckLabelColor(aVisualItem);
            }
        }
        public void InitTreeAndPath()
        {
            int    RoleId = Constant.UserRoleId;
            string UserId = Method.GetLogonUserId(Session, User.Identity.Name);

            string        webroot      = Constant.WebRoot;
            string        TreeViewRoot = webroot + "/TestItemMenu/Index";
            ItemTreeDbSet tr           = new ItemTreeDbSet(TreeViewRoot);
            ItemTree      tree         = tr.GetData(TreeViewRoot, UserId, 0, mIsShowReport: 1, mIsShowUnsignForm: 0);

            ViewData["ItemTree"] = tree;

            IList <FnGetItemParentListById_Result> parentlist = tr.GetParentList(ViewBag.id);

            ViewData["parentlist"] = parentlist;
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateProjection(ProjectionState pProj)
        {
            ICursorState cursor         = pProj.Cursor;
            CursorType   cursorType     = cursor.Type;
            bool         allowSelect    = (cursor.IsInputAvailable && pProj.IsActive);
            Vector3?     cursorWorldPos = (allowSelect ? cursor.GetWorldPosition() : (Vector3?)null);
            ItemTree     nearestTree    = new ItemTree();
            float        nearestDist    = float.MaxValue;

            foreach (ItemTree itemTree in vAllItems)
            {
                itemTree.Item.UpdateWithCursor(cursorType, cursorWorldPos);

                if (!allowSelect)
                {
                    continue;
                }

                float itemDist = itemTree.Item.GetHighlightDistance(cursorType);

                if (itemDist >= nearestDist)
                {
                    continue;
                }

                nearestTree = itemTree;
                nearestDist = itemDist;
            }

            foreach (ItemTree itemTree in vAllItems)
            {
                BaseItemState item = itemTree.Item;
                item.SetAsNearestItem(cursorType, (item == nearestTree.Item));
            }

            if (nearestTree.Panel == null || nearestTree.Item.MaxHighlightProgress <= 0)
            {
                pProj.SetNearestPanelTransform(null);
                pProj.NearestItemHighlightProgress = 0;
                return;
            }

            GameObject panelObj = (GameObject)nearestTree.Panel.ItemPanel.DisplayContainer;

            pProj.SetNearestPanelTransform(panelObj.transform);
            pProj.NearestItemHighlightProgress = nearestTree.Item.GetHighlightProgress(cursorType);
        }
示例#25
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public HoverboardState(ItemPanel[] pItemPanels, HovercursorSetup pHovercusorSetup,
                               InteractionSettings pInterSett, Transform pBaseTx)
        {
            vInteractSett    = pInterSett;
            vHovercusorSetup = pHovercusorSetup;
            vBaseTx          = pBaseTx;
            vProjectionMap   = new ListMap <CursorType, ProjectionState>(EnumIntKeyComparer.CursorType);

            ////

            var panels   = new List <PanelState>();
            var allItems = new List <ItemTree>();

            foreach (ItemPanel itemPanel in pItemPanels)
            {
                var panel = new PanelState(itemPanel, vInteractSett);
                panel.InteractionPlane = new PlaneData("Hoverboard.Panel-" + panels.Count,
                                                       ((GameObject)panel.ItemPanel.DisplayContainer).transform, Vector3.up);
                panels.Add(panel);

                foreach (LayoutState layout in panel.FullLayouts)
                {
                    layout.ItemLayout.SetRadioSiblingsFunc(GetRadioSiblings);

                    foreach (BaseItemState item in layout.FullItems)
                    {
                        var tree = new ItemTree {
                            Panel  = panel,
                            Layout = layout,
                            Item   = item
                        };

                        allItems.Add(tree);
                    }
                }
            }

            vAllItems    = allItems.ToArray();
            vActiveItems = new List <ItemTree>();
            vActiveCursorInteractions = new ReadList <IBaseItemInteractionState>();
            vActiveCursorPlanes       = new ReadList <PlaneData>();

            FullPanels        = panels.ToArray();
            Panels            = new ReadOnlyCollection <IHoverboardPanelState>(FullPanels);
            ActiveCursorTypes = new ReadOnlyCollection <CursorType>(vInteractSett.Cursors);
        }
示例#26
0
        private void CreateVisualItemTree(VisualItem rootVisualItem)
        {
            ItemTree item = rootVisualItem.Item;

            if (item.subitems != null)
            {
                rootVisualItem.subitems = new VisualItem[item.subitems.Count()];
                int i = 0;
                foreach (ItemTree subItem in item.subitems)
                {
                    VisualItem visualItem = new VisualItem();
                    rootVisualItem.subitems[i++] = visualItem;
                    visualItem.Item       = subItem;
                    visualItem.IsFiltered = true;
                    CreateVisualItemTree(visualItem);
                }
            }
        }
示例#27
0
        /// <summary>
        /// 附加分支子树
        /// </summary>
        /// <param name="childTree">子树</param>
        /// <param name="word">单个敏感词</param>
        private void AddChildTree(ItemTree childTree, string word)
        {
            //移动 游标
            ItemTree p = childTree;

            for (int i = 1; i < word.Length; i++)
            {
                char            cha   = word[i];
                List <ItemTree> child = p.Child;

                if (child == null)
                {
                    ItemTree node = new ItemTree()
                    {
                        Item = cha, IsEnd = false, Child = null
                    };
                    p.Child = new List <ItemTree>()
                    {
                        node
                    };
                    p = node;
                }
                else
                {
                    ItemTree node = child.Find(e => e.Item == cha);
                    if (node == null)
                    {
                        node = new ItemTree()
                        {
                            Item = cha, IsEnd = false, Child = null
                        };
                        child.Add(node);
                        p = node;
                    }
                    else
                    {
                        p = node;
                    }
                }
            }
            p.IsEnd = true;
        }
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		public HoverboardState(ItemPanel[] pItemPanels, HovercursorSetup pHovercusorSetup,
													InteractionSettings pInterSett, Transform pBaseTx) {
			vInteractSett = pInterSett;
			vHovercusorSetup = pHovercusorSetup;
			vBaseTx = pBaseTx;
			vProjectionMap = new ListMap<CursorType, ProjectionState>(EnumIntKeyComparer.CursorType);

			////

			var panels = new List<PanelState>();
			var allItems = new List<ItemTree>();

			foreach ( ItemPanel itemPanel in pItemPanels ) {
				var panel = new PanelState(itemPanel, vInteractSett);
				panel.InteractionPlane = new PlaneData("Hoverboard.Panel-"+panels.Count, 
					((GameObject)panel.ItemPanel.DisplayContainer).transform, Vector3.up);
				panels.Add(panel);

				foreach ( LayoutState layout in panel.FullLayouts ) {
					layout.ItemLayout.SetRadioSiblingsFunc(GetRadioSiblings);

					foreach ( BaseItemState item in layout.FullItems ) {
						var tree = new ItemTree {
							Panel = panel,
							Layout = layout,
							Item = item
						};

						allItems.Add(tree);
					}
				}
			}

			vAllItems = allItems.ToArray();
			vActiveItems = new List<ItemTree>();
			vActiveCursorInteractions = new ReadList<IBaseItemInteractionState>();
			vActiveCursorPlanes = new ReadList<PlaneData>();

			FullPanels = panels.ToArray();
			Panels = new ReadOnlyCollection<IHoverboardPanelState>(FullPanels);
			ActiveCursorTypes = new ReadOnlyCollection<CursorType>(vInteractSett.Cursors);
		}
示例#29
0
        public Visualizer( D3D10Wrapper d3d, EffectManager effectManager )
        {
            rootItemTree = new ItemTree( "root" );

            this.d3d = d3d;
            
            streamState = new VisualizerStreamState();
            textureVertexBuffer = new DynamicVertexBuffer( VertexPosition4fColor4f.SizeInBytes, 6 );
            var stream = textureVertexBuffer.MapForWriteDiscard();
            stream.Write( new Vector4f( 0, 0, 0, 1 ) );
            stream.Write( new Vector4f( 0, 1, 0, 1 ) );
            stream.Write( new Vector4f( 1, 0, 0, 1 ) );
            stream.Write( new Vector4f( 1, 1, 0, 1 ) );
            stream.Write( new Vector4f( 0, 1, 0, 1 ) );
            stream.Write( new Vector4f( 0, 0, 0, 1 ) );

            stream.Write( new Vector4f( 0, 1, 0, 1 ) );
            stream.Write( new Vector4f( 0, 0, 0, 1 ) );
            stream.Write( new Vector4f( 1, 0, 0, 1 ) );
            stream.Write( new Vector4f( 1, 1, 0, 1 ) );
            stream.Write( new Vector4f( 1, 1, 0, 1 ) );
            stream.Write( new Vector4f( 1, 0, 0, 1 ) );
            textureVertexBuffer.Unmap();

            effect = effectManager[ "visualizer.fx" ];

            opaquePass = effectManager[ "visualizer.fx", "renderOpaque", "p0" ];
            opaquePassLayout = new InputLayout( d3d.Device, opaquePass.Description.Signature, VertexPosition4fColor4f.InputElements );

            alphaPass = effectManager[ "visualizer.fx", "renderAlpha", "p0" ];
            alphaPassLayout = new InputLayout( d3d.Device, alphaPass.Description.Signature, VertexPosition4fColor4f.InputElements );

            additivePass = effectManager[ "visualizer.fx", "renderAdditive", "p0" ];
            additivePassLayout = new InputLayout( d3d.Device, additivePass.Description.Signature, VertexPosition4fColor4f.InputElements );
            
            opaqueTexturePass = effect.GetTechniqueByName( "renderTexOpaque" ).GetPassByName( "p0" );
            opaqueTexturePassLayout = new InputLayout( d3d.Device, opaqueTexturePass.Description.Signature, VertexPosition4fTexture4f.InputElements );

            alphaTexturePass = effect.GetTechniqueByName( "renderTexAlpha" ).GetPassByName( "p0" );
            alphaTexturePassLayout = new InputLayout( d3d.Device, alphaTexturePass.Description.Signature, VertexPosition4fTexture4f.InputElements );
        }
示例#30
0
        private static void PrepareControl(VisualItem aVIsualItem)
        {
            Control  label         = aVIsualItem.controlsGroup.label;
            Control  actualControl = aVIsualItem.controlsGroup.control;
            ItemTree aItem         = aVIsualItem.Item;

            switch (aItem.type)
            {
            case "combo":
                string[] values = aItem.values.Split(';');
                foreach (string v in values)
                {
                    (actualControl as ComboBox).Items.Add(v);
                }
                break;

            case "menu":
                (label as Label).ForeColor = Color.LawnGreen;
                break;
            }
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public HoverboardState(ItemPanel[] pItemPanels, HovercursorSetup pHovercusorSetup,
                               InteractionSettings pInterSett, Transform pBaseTx)
        {
            vInteractSett    = pInterSett;
            vHovercusorSetup = pHovercusorSetup;
            vBaseTx          = pBaseTx;
            vProjectionMap   = new Dictionary <CursorType, ProjectionState>();

            ////

            var panels   = new List <PanelState>();
            var allItems = new List <ItemTree>();

            foreach (ItemPanel itemPanel in pItemPanels)
            {
                var panel = new PanelState(itemPanel, vInteractSett);
                panel.InteractionPlane = new PlaneData("Hoverboard.Panel-" + panels.Count,
                                                       ((GameObject)panel.ItemPanel.DisplayContainer).transform, Vector3.up);
                panels.Add(panel);

                foreach (GridState grid in panel.Grids)
                {
                    foreach (BaseItemState item in grid.Items)
                    {
                        var tree = new ItemTree {
                            Panel = panel,
                            Grid  = grid,
                            Item  = item
                        };

                        allItems.Add(tree);
                    }
                }
            }

            Panels            = panels.ToArray();
            vAllItems         = allItems.ToArray();
            ActiveCursorTypes = new CursorType[0];
        }
示例#32
0
        private async void btnAnalyze_Click(object sender, EventArgs e)
        {
            root           = new TreeItem();
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                await root.LoadFromSentence(txtBox.Text);

                txtSubject.Text    = root.Children[0].Children[0].NounPhrase.toReadableString();
                txtVerbPhrase.Text = root.Children[0].Children[0].VerbPhrase.toReadableString();
                QuestionAndAnswer qa = root.Children[0].Children[0].GetQuestionAndAnswer();
                txtQuestion.Text = qa.Question;
                txtAnswer.Text   = qa.Answer;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error analyzing text", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            LoadTree();
            Cursor.Current = Cursors.Default;
            ItemTree.ExpandAll();
        }
		/*--------------------------------------------------------------------------------------------*/
		private bool IsItemTreeActive(ItemTree pTree) {
			IBaseItem baseItem = pTree.Item.Item;
			return (baseItem.IsVisible && baseItem.IsEnabled && 
				baseItem.IsAncestryVisible && baseItem.IsAncestryEnabled);
		}
		/*--------------------------------------------------------------------------------------------*/
		private void UpdateProjection(ProjectionState pProj) {
			ICursorState cursor = pProj.Cursor;
			CursorType cursorType = cursor.Type;
			bool allowSelect = (cursor.IsInputAvailable && pProj.IsActive);
			Vector3? cursorWorldPos = (allowSelect ? cursor.GetWorldPosition() : (Vector3?)null);
			ItemTree nearestTree = new ItemTree();
			float nearestDist = float.MaxValue;

			foreach ( ItemTree itemTree in vActiveItems ) {
				itemTree.Item.UpdateWithCursor(cursorType, cursorWorldPos);

				if ( !allowSelect ) {
					continue;
				}

				float itemDist = itemTree.Item.GetHighlightDistance(cursorType);

				if ( itemDist >= nearestDist ) {
					continue;
				}

				nearestTree = itemTree;
				nearestDist = itemDist;
			}

			foreach ( ItemTree itemTree in vAllItems ) {
				BaseItemState item = itemTree.Item;
				item.SetAsNearestItem(cursorType, (item == nearestTree.Item));
			}

			if ( nearestTree.Panel == null || nearestTree.Item.MaxHighlightProgress <= 0 ) {
				pProj.SetNearestPanelTransform(null);
				pProj.NearestItemHighlightProgress = 0;
				return;
			}

			GameObject panelObj = (GameObject)nearestTree.Panel.ItemPanel.DisplayContainer;
			pProj.SetNearestPanelTransform(panelObj.transform);
			pProj.NearestItemHighlightProgress = nearestTree.Item.GetHighlightProgress(cursorType);
		}