public override void StartDrag(TreeViewItem draggedItem, List<int> draggedItemIDs)
		{
			if (!EditorApplication.isPlaying)
			{
				base.StartDrag(draggedItem, draggedItemIDs);
			}
		}
 public override void OnRowGUI(Rect rowRect, TreeViewItem node, int row, bool selected, bool focused)
 {
   Event current = Event.current;
   this.DoNodeGUI(rowRect, row, node, selected, focused, false);
   if ((UnityEngine.Object) this.m_Controller == (UnityEngine.Object) null)
     return;
   AudioMixerTreeViewNode audioNode = node as AudioMixerTreeViewNode;
   if (audioNode == null)
     return;
   bool visible = this.m_Controller.CurrentViewContainsGroup(audioNode.group.groupID);
   float num = 3f;
   Rect position = new Rect(rowRect.x + num, rowRect.y, 16f, 16f);
   Rect rect1 = new Rect(position.x + 1f, position.y + 1f, position.width - 2f, position.height - 2f);
   int userColorIndex = audioNode.group.userColorIndex;
   if (userColorIndex > 0)
     EditorGUI.DrawRect(new Rect(rowRect.x, rect1.y, 2f, rect1.height), AudioMixerColorCodes.GetColor(userColorIndex));
   EditorGUI.DrawRect(rect1, new Color(0.5f, 0.5f, 0.5f, 0.2f));
   if (visible)
     GUI.DrawTexture(position, (Texture) this.k_VisibleON);
   Rect rect2 = new Rect(2f, rowRect.y, rowRect.height, rowRect.height);
   if (current.type == EventType.MouseUp && current.button == 0 && (rect2.Contains(current.mousePosition) && this.NodeWasToggled != null))
     this.NodeWasToggled(audioNode, !visible);
   if (current.type != EventType.ContextClick || !position.Contains(current.mousePosition))
     return;
   this.OpenGroupContextMenu(audioNode, visible);
   current.Use();
 }
			protected override void DrawIconAndLabel(Rect rect, TreeViewItem itemRaw, string label, bool selected, bool focused, bool useBoldFont, bool isPinging)
			{
				FrameDebuggerTreeView.FDTreeViewItem fDTreeViewItem = (FrameDebuggerTreeView.FDTreeViewItem)itemRaw;
				float contentIndent = this.GetContentIndent(fDTreeViewItem);
				rect.x += contentIndent;
				rect.width -= contentIndent;
				string text;
				GUIContent content;
				GUIStyle gUIStyle;
				if (fDTreeViewItem.m_ChildEventCount > 0)
				{
					Rect position = rect;
					position.width -= 4f;
					text = fDTreeViewItem.m_ChildEventCount.ToString(CultureInfo.InvariantCulture);
					content = EditorGUIUtility.TempContent(text);
					gUIStyle = FrameDebuggerWindow.styles.rowTextRight;
					gUIStyle.Draw(position, content, false, false, false, false);
					rect.width -= gUIStyle.CalcSize(content).x + 8f;
				}
				if (fDTreeViewItem.id <= 0)
				{
					text = fDTreeViewItem.displayName;
				}
				else
				{
					text = FrameDebuggerWindow.s_FrameEventTypeNames[(int)fDTreeViewItem.m_FrameEvent.type] + fDTreeViewItem.displayName;
				}
				if (string.IsNullOrEmpty(text))
				{
					text = "<unknown scope>";
				}
				content = EditorGUIUtility.TempContent(text);
				gUIStyle = FrameDebuggerWindow.styles.rowText;
				gUIStyle.Draw(rect, content, false, false, false, selected && focused);
			}
        public TreeViewItemFactoryTests()
        {
            ViewContext viewContext = TestHelper.CreateViewContext();

            item = new TreeViewItem();
            factory = new TreeViewItemFactory(item, viewContext);
        }
 private void AddVisibleChildrenRecursive(BackendData.Foo source, TreeViewItem dest)
 {
   if (this.IsExpanded(source.id))
   {
     if (source.children == null || source.children.Count <= 0)
       return;
     dest.children = new List<TreeViewItem>(source.children.Count);
     for (int index = 0; index < source.children.Count; ++index)
     {
       BackendData.Foo child = source.children[index];
       dest.children.Add((TreeViewItem) new FooTreeViewItem(child.id, dest.depth + 1, dest, child.name, child));
       ++this.itemCounter;
       this.AddVisibleChildrenRecursive(child, dest.children[index]);
     }
   }
   else
   {
     if (!source.hasChildren)
       return;
     dest.children = new List<TreeViewItem>()
     {
       new TreeViewItem(-1, -1, (TreeViewItem) null, string.Empty)
     };
   }
 }
Example #6
0
        public void AddBranchAndChildren(TreeViewItem parent, ROMNode node)
        {
            string caption = node.GetROMObjectID();
            TreeViewItem current = null;
            if (parent != null)
            {
                current = new TreeViewItem();
                current.Header = caption;
                current.Tag = node;
                current.Name = "_" + node.GetROMGUID().Replace('-', '_');
                try
                {
                    treeCtrl.UnregisterName(current.Name);
                }
                catch { }
                treeCtrl.RegisterName(current.Name, current);
                parent.Items.Add(current);
            }

            ROMNode[] children = node.GetAllChildren(false);
            if (children != null) foreach (ROMNode child in children)
                {
                    AddBranchAndChildren(current, child);
                }
        }
			private void AddVisibleChildrenRecursive(TreeViewTest.BackendData.Foo source, TreeViewItem dest)
			{
				if (this.IsExpanded(source.id))
				{
					if (source.children != null && source.children.Count > 0)
					{
						dest.children = new List<TreeViewItem>(source.children.Count);
						for (int i = 0; i < source.children.Count; i++)
						{
							TreeViewTest.BackendData.Foo foo = source.children[i];
							dest.children[i] = new TreeViewTest.FooTreeViewItem(foo.id, dest.depth + 1, dest, foo.name, foo);
							this.itemCounter++;
							this.AddVisibleChildrenRecursive(foo, dest.children[i]);
						}
					}
				}
				else
				{
					if (source.hasChildren)
					{
						dest.children = new List<TreeViewItem>
						{
							new TreeViewItem(-1, -1, null, string.Empty)
						};
					}
				}
			}
 public override void StartDrag(TreeViewItem draggedItem, List<int> draggedItemIDs)
 {
     if (!SavedSearchFilters.IsSavedFilter(draggedItem.id) || (draggedItem.id != SavedSearchFilters.GetRootInstanceID()))
     {
         ProjectWindowUtil.StartDrag(draggedItem.id, draggedItemIDs);
     }
 }
		public override DragAndDropVisualMode DoDrag(TreeViewItem parentNode, TreeViewItem targetNode, bool perform, TreeViewDragging.DropPosition dragPos)
		{
			AudioMixerTreeViewDragging.DragData dragData = DragAndDrop.GetGenericData("AudioMixerDragging") as AudioMixerTreeViewDragging.DragData;
			if (dragData == null)
			{
				return DragAndDropVisualMode.None;
			}
			List<AudioMixerItem> draggedItems = dragData.m_DraggedItems;
			AudioMixerItem audioMixerItem = parentNode as AudioMixerItem;
			if (audioMixerItem != null && dragData != null)
			{
				List<AudioMixerGroupController> groupsToBeMoved = (
					from i in draggedItems
					select i.mixer.masterGroup).ToList<AudioMixerGroupController>();
				List<AudioMixerGroupController> allAudioGroupsSlow = audioMixerItem.mixer.GetAllAudioGroupsSlow();
				bool flag = AudioMixerController.WillModificationOfTopologyCauseFeedback(allAudioGroupsSlow, groupsToBeMoved, audioMixerItem.mixer.masterGroup, null);
				bool flag2 = this.ValidDrag(parentNode, draggedItems) && !flag;
				if (perform && flag2 && this.m_MixersDroppedOnMixerCallback != null)
				{
					this.m_MixersDroppedOnMixerCallback(this.GetAudioMixersFromItems(draggedItems), audioMixerItem.mixer);
				}
				return (!flag2) ? DragAndDropVisualMode.Rejected : DragAndDropVisualMode.Move;
			}
			return DragAndDropVisualMode.None;
		}
        public JsonResult Employees(TreeViewItem item)
        {
            var dataContext = new NorthwindEntities();
            if (!string.IsNullOrEmpty(item.Id))
            {
                var id = int.Parse(item.Id);
                var employees = from e in dataContext.Employees
                                where (e.ReportsTo == id)
                                select new
                                {
                                    id = e.EmployeeID,
                                    Name = e.FirstName + " " + e.LastName,
                                    hasChildren = e.Employees.Any()
                                };

                return Json(employees, JsonRequestBehavior.AllowGet);
            }
            else
            {
                return Json(dataContext.Employees.Where(e => e.ReportsTo == null).Select(e => new
                {
                    id = e.EmployeeID,
                    Name = e.FirstName + " " + e.LastName,
                    hasChildren = e.Employees.Any()
                }), JsonRequestBehavior.AllowGet);
            }
        }
 private TreeViewItem AddAnimatableObjectToHierarchy(GameObject root, EditorCurveBinding[] curveBindings, TreeViewItem parentNode, string path)
 {
     TreeViewItem item = new AddCurvesPopupObjectNode(parentNode, path, GetClassName(root, curveBindings[0])) {
         icon = AssetPreview.GetMiniThumbnail(AnimationUtility.GetAnimatedObject(root, curveBindings[0]))
     };
     List<TreeViewItem> visibleItems = new List<TreeViewItem>();
     List<EditorCurveBinding> list2 = new List<EditorCurveBinding>();
     for (int i = 0; i < curveBindings.Length; i++)
     {
         EditorCurveBinding binding = curveBindings[i];
         list2.Add(binding);
         if ((i == (curveBindings.Length - 1)) || (AnimationWindowUtility.GetPropertyGroupName(curveBindings[i + 1].propertyName) != AnimationWindowUtility.GetPropertyGroupName(binding.propertyName)))
         {
             TreeViewItem item2 = this.CreateNode(list2.ToArray(), item);
             if (item2 != null)
             {
                 visibleItems.Add(item2);
             }
             list2.Clear();
         }
     }
     visibleItems.Sort();
     TreeViewUtility.SetChildParentReferences(visibleItems, item);
     return item;
 }
 protected override void DrawIconAndLabel(Rect rect, TreeViewItem item, string label, bool selected, bool focused, bool useBoldFont, bool isPinging)
 {
   if (!isPinging)
   {
     float contentIndent = this.GetContentIndent(item);
     rect.x += contentIndent;
     rect.width -= contentIndent;
   }
   AudioMixerItem audioMixerItem = item as AudioMixerItem;
   if (audioMixerItem == null)
     return;
   GUIStyle guiStyle = !useBoldFont ? TreeViewGUI.s_Styles.lineStyle : TreeViewGUI.s_Styles.lineBoldStyle;
   guiStyle.padding.left = (int) ((double) this.k_IconWidth + (double) this.iconTotalPadding + (double) this.k_SpaceBetweenIconAndText);
   guiStyle.Draw(rect, label, false, false, selected, focused);
   audioMixerItem.UpdateSuspendedString(false);
   if ((double) audioMixerItem.labelWidth <= 0.0)
     audioMixerItem.labelWidth = guiStyle.CalcSize(GUIContent.Temp(label)).x;
   Rect position = rect;
   position.x += audioMixerItem.labelWidth + 8f;
   EditorGUI.BeginDisabledGroup(true);
   guiStyle.Draw(position, audioMixerItem.infoText, false, false, false, false);
   EditorGUI.EndDisabledGroup();
   if (this.iconOverlayGUI == null)
     return;
   Rect rect1 = rect;
   rect1.width = this.k_IconWidth + this.iconTotalPadding;
   this.iconOverlayGUI(item, rect1);
 }
        public TreeViewItemBuilderTests()
        {
            var viewContext = TestHelper.CreateViewContext();

            item = new TreeViewItem();
            builder = new TreeViewItemBuilder(item, viewContext);
        }
 public override DragAndDropVisualMode DoDrag(TreeViewItem parentItem, TreeViewItem targetItem, bool perform, TreeViewDragging.DropPosition dropPos)
 {
   HierarchyProperty property = new HierarchyProperty(HierarchyType.Assets);
   if (parentItem == null || !property.Find(parentItem.id, (int[]) null))
     property = (HierarchyProperty) null;
   return InternalEditorUtility.ProjectWindowDrag(property, perform);
 }
 protected override void DrawIconAndLabel(Rect rect, TreeViewItem item, string label, bool selected, bool focused, bool useBoldFont, bool isPinging)
 {
     if (!isPinging)
     {
         float contentIndent = this.GetContentIndent(item);
         rect.x += contentIndent;
         rect.width -= contentIndent;
     }
     AudioMixerItem item2 = item as AudioMixerItem;
     if (item2 != null)
     {
         GUIStyle style = !useBoldFont ? TreeViewGUI.s_Styles.lineStyle : TreeViewGUI.s_Styles.lineBoldStyle;
         style.padding.left = (int) ((base.k_IconWidth + base.iconTotalPadding) + base.k_SpaceBetweenIconAndText);
         style.Draw(rect, label, false, false, selected, focused);
         item2.UpdateSuspendedString(false);
         if (item2.labelWidth <= 0f)
         {
             item2.labelWidth = style.CalcSize(GUIContent.Temp(label)).x;
         }
         Rect position = rect;
         position.x += item2.labelWidth + 8f;
         EditorGUI.BeginDisabledGroup(true);
         style.Draw(position, item2.infoText, false, false, false, false);
         EditorGUI.EndDisabledGroup();
         if (base.iconOverlayGUI != null)
         {
             Rect rect3 = rect;
             rect3.width = base.k_IconWidth + base.iconTotalPadding;
             base.iconOverlayGUI(item, rect3);
         }
     }
 }
 public override void OnRowGUI(Rect rowRect, TreeViewItem node, int row, bool selected, bool focused)
 {
     this.DoItemGUI(rowRect, row, node, selected, focused, false);
     SketchUpNode node2 = node as SketchUpNode;
     Rect position = new Rect(2f, rowRect.y, rowRect.height, rowRect.height);
     node2.Enabled = GUI.Toggle(position, node2.Enabled, GUIContent.none, SketchUpImportDlg.Styles.styles.toggleStyle);
 }
 public override void StartDrag(TreeViewItem draggedNode, List<int> draggedItemIDs)
 {
   DragAndDrop.PrepareStartDrag();
   DragAndDrop.SetGenericData("FooDragging", (object) new TestDragging.FooDragData(this.GetItemsFromIDs((IEnumerable<int>) draggedItemIDs)));
   DragAndDrop.objectReferences = new UnityEngine.Object[0];
   DragAndDrop.StartDrag(draggedItemIDs.Count.ToString() + " Foo" + (draggedItemIDs.Count <= 1 ? (object) string.Empty : (object) "s"));
 }
 public override DragAndDropVisualMode DoDrag(TreeViewItem parentItem, TreeViewItem targetItem, bool perform, TreeViewDragging.DropPosition dropPos)
 {
     HierarchyProperty property = new HierarchyProperty(HierarchyType.GameObjects);
     if ((parentItem == null) || (targetItem == null))
     {
         return InternalEditorUtility.HierarchyWindowDrag(null, perform, InternalEditorUtility.HierarchyDropMode.kHierarchyDropUpon);
     }
     if (this.allowDragBetween)
     {
         if (((dropPos == TreeViewDragging.DropPosition.Above) || (targetItem == null)) || !property.Find(targetItem.id, null))
         {
             property = null;
         }
     }
     else if (((dropPos == TreeViewDragging.DropPosition.Above) || (parentItem == null)) || !property.Find(parentItem.id, null))
     {
         property = null;
     }
     InternalEditorUtility.HierarchyDropMode kHierarchyDragNormal = InternalEditorUtility.HierarchyDropMode.kHierarchyDragNormal;
     if (this.allowDragBetween)
     {
         kHierarchyDragNormal = (dropPos != TreeViewDragging.DropPosition.Upon) ? InternalEditorUtility.HierarchyDropMode.kHierarchyDropBetween : InternalEditorUtility.HierarchyDropMode.kHierarchyDropUpon;
     }
     if (((parentItem != null) && (parentItem == targetItem)) && (dropPos != TreeViewDragging.DropPosition.Above))
     {
         kHierarchyDragNormal |= InternalEditorUtility.HierarchyDropMode.kHierarchyDropAfterParent;
     }
     return InternalEditorUtility.HierarchyWindowDrag(property, perform, kHierarchyDragNormal);
 }
		public override DragAndDropVisualMode DoDrag(TreeViewItem parentItem, TreeViewItem targetItem, bool perform, TreeViewDragging.DropPosition dropPos)
		{
			HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.GameObjects);
			if (parentItem == null || targetItem == null)
			{
				return InternalEditorUtility.HierarchyWindowDrag(null, perform, InternalEditorUtility.HierarchyDropMode.kHierarchyDropUpon);
			}
			if (this.allowDragBetween)
			{
				if (dropPos == TreeViewDragging.DropPosition.Above || targetItem == null || !hierarchyProperty.Find(targetItem.id, null))
				{
					hierarchyProperty = null;
				}
			}
			else
			{
				if (dropPos == TreeViewDragging.DropPosition.Above || parentItem == null || !hierarchyProperty.Find(parentItem.id, null))
				{
					hierarchyProperty = null;
				}
			}
			InternalEditorUtility.HierarchyDropMode hierarchyDropMode = InternalEditorUtility.HierarchyDropMode.kHierarchyDragNormal;
			if (this.allowDragBetween)
			{
				hierarchyDropMode = ((dropPos != TreeViewDragging.DropPosition.Upon) ? InternalEditorUtility.HierarchyDropMode.kHierarchyDropBetween : InternalEditorUtility.HierarchyDropMode.kHierarchyDropUpon);
			}
			if (parentItem != null && parentItem == targetItem && dropPos != TreeViewDragging.DropPosition.Above)
			{
				hierarchyDropMode |= InternalEditorUtility.HierarchyDropMode.kHierarchyDropAfterParent;
			}
			return InternalEditorUtility.HierarchyWindowDrag(hierarchyProperty, perform, hierarchyDropMode);
		}
		public AnimationWindowHierarchyNode(int instanceID, int depth, TreeViewItem parent, Type animatableObjectType, string propertyName, string path, string displayName) : base(instanceID, depth, parent, displayName)
		{
			this.displayName = displayName;
			this.animatableObjectType = animatableObjectType;
			this.propertyName = propertyName;
			this.path = path;
		}
		public override bool DragElement(TreeViewItem targetItem, Rect targetItemRect, bool firstItem)
		{
			AudioMixerTreeViewDragging.DragData dragData = DragAndDrop.GetGenericData("AudioMixerDragging") as AudioMixerTreeViewDragging.DragData;
			if (dragData == null)
			{
				DragAndDrop.visualMode = DragAndDropVisualMode.None;
				return false;
			}
			bool flag = targetItem == null;
			if (flag && this.m_TreeView.GetTotalRect().Contains(Event.current.mousePosition))
			{
				if (this.m_DropData != null)
				{
					this.m_DropData.dropTargetControlID = 0;
					this.m_DropData.rowMarkerControlID = 0;
				}
				if (Event.current.type == EventType.DragPerform)
				{
					DragAndDrop.AcceptDrag();
					if (this.m_MixersDroppedOnMixerCallback != null)
					{
						this.m_MixersDroppedOnMixerCallback(this.GetAudioMixersFromItems(dragData.m_DraggedItems), null);
					}
				}
				DragAndDrop.visualMode = DragAndDropVisualMode.Move;
				Event.current.Use();
				return false;
			}
			return base.DragElement(targetItem, targetItemRect, firstItem);
		}
 public AudioMixerItem(int id, int depth, TreeViewItem parent, string displayName, AudioMixerController mixer, string infoText)
   : base(id, depth, parent, displayName)
 {
   this.mixer = mixer;
   this.infoText = infoText;
   this.UpdateSuspendedString(true);
 }
        private void CreateTreeView()
        {
            if (processInfo == null)
                return;

            foreach (FrameInfo frame in processInfo.Frames)
            {
                TreeViewItem tviFrame = new TreeViewItem { Header = string.Format("Frame {0} ({1} - {2})", frame.FrameNumber, frame.BeginTime, frame.EndTime) };

                foreach (ThreadInfo thread in frame.ThreadItems)
                {
                    TreeViewItem tviThread = new TreeViewItem { Header = string.Format("Thread {0}", thread.Id) };

                    foreach (MicroThreadInfo mt in thread.MicroThreadItems)
                    {
                        TreeViewItem tviMicroThread = new TreeViewItem { Header = string.Format("MicroThread {0} ({1} - {2})", mt.Id, mt.BeginTime, mt.EndTime) };
                        tviThread.Items.Add(tviMicroThread);
                    }

                    tviFrame.Items.Add(tviThread);
                }

                treeView.Items.Add(tviFrame);
            }
        }
 public override DragAndDropVisualMode DoDrag(TreeViewItem parentItem, TreeViewItem targetItem, bool perform, TreeViewDragging.DropPosition dropPos)
 {
     if (targetItem == null)
     {
         return DragAndDropVisualMode.None;
     }
     object genericData = DragAndDrop.GetGenericData(ProjectWindowUtil.k_DraggingFavoriteGenericData);
     if (genericData != null)
     {
         int instanceID = (int) genericData;
         if ((targetItem is SearchFilterTreeItem) && (parentItem is SearchFilterTreeItem))
         {
             bool flag = SavedSearchFilters.CanMoveSavedFilter(instanceID, parentItem.id, targetItem.id, dropPos == TreeViewDragging.DropPosition.Below);
             if (flag && perform)
             {
                 SavedSearchFilters.MoveSavedFilter(instanceID, parentItem.id, targetItem.id, dropPos == TreeViewDragging.DropPosition.Below);
                 int[] selectedIDs = new int[] { instanceID };
                 base.m_TreeView.SetSelection(selectedIDs, false);
                 base.m_TreeView.NotifyListenersThatSelectionChanged();
             }
             return (!flag ? DragAndDropVisualMode.None : DragAndDropVisualMode.Copy);
         }
         return DragAndDropVisualMode.None;
     }
     if ((targetItem is SearchFilterTreeItem) && (parentItem is SearchFilterTreeItem))
     {
         string str = DragAndDrop.GetGenericData(ProjectWindowUtil.k_IsFolderGenericData) as string;
         if (str != "isFolder")
         {
             return DragAndDropVisualMode.None;
         }
         if (perform)
         {
             Object[] objectReferences = DragAndDrop.objectReferences;
             if (objectReferences.Length > 0)
             {
                 string assetPath = AssetDatabase.GetAssetPath(objectReferences[0].GetInstanceID());
                 if (!string.IsNullOrEmpty(assetPath))
                 {
                     string name = new DirectoryInfo(assetPath).Name;
                     SearchFilter filter = new SearchFilter();
                     filter.folders = new string[] { assetPath };
                     bool addAsChild = targetItem == parentItem;
                     float listAreaGridSize = ProjectBrowserColumnOneTreeViewGUI.GetListAreaGridSize();
                     int num3 = SavedSearchFilters.AddSavedFilterAfterInstanceID(name, filter, listAreaGridSize, targetItem.id, addAsChild);
                     int[] numArray2 = new int[] { num3 };
                     base.m_TreeView.SetSelection(numArray2, false);
                     base.m_TreeView.NotifyListenersThatSelectionChanged();
                 }
                 else
                 {
                     Debug.Log("Could not get asset path from id " + objectReferences[0].GetInstanceID());
                 }
             }
         }
         return DragAndDropVisualMode.Copy;
     }
     return base.DoDrag(parentItem, targetItem, perform, dropPos);
 }
Example #25
0
        /// <summary>
        /// Defines a item.
        /// </summary>
        /// <returns></returns>
        public TreeViewItemBuilder Add()
        {
            TreeViewItem item = new TreeViewItem();

            container.Items.Add(item);

            return new TreeViewItemBuilder(item, viewContext);
        }
 public override bool IsRenamingItemAllowed(TreeViewItem item)
 {
     if (this.IsVisibleRootNode(item))
     {
         return false;
     }
     return base.IsRenamingItemAllowed(item);
 }
 protected override Texture GetIconForNode(TreeViewItem item)
 {
   if (item != null && (UnityEngine.Object) item.icon != (UnityEngine.Object) null)
     return (Texture) item.icon;
   if (item.id == TreeViewForAudioMixerGroup.kNoneItemID)
     return (Texture) this.k_AudioListenerIcon;
   return (Texture) this.k_AudioGroupIcon;
 }
 public override bool IsExpandable(TreeViewItem item)
 {
   if (!item.hasChildren)
     return false;
   if (item == this.m_RootItem)
     return this.rootIsCollapsable;
   return true;
 }
 /// <summary>
 /// Associate the parent TreeViewItem with the CheckBox.
 /// </summary>
 private void AssociateParentTreeViewItem()
 {
     _parent = TreeViewExtensions.GetParentItemsControl(this) as TreeViewItem;
     if (_parent != null)
     {
         TreeViewExtensions.SetAssociatedCheckBox(_parent, this);
     }
 }
		protected override Texture GetIconForNode(TreeViewItem item)
		{
			if (item != null)
			{
				return item.icon;
			}
			return null;
		}
 private void CheckBox_Checked(object sender, RoutedEventArgs e)
 {
     this.item = getTreeItem();
     tvChars.Items.Add(this.item);
 }
Example #32
0
        /// <summary>
        /// Saves any change to the Tag property of the destinationTvi.
        /// </summary>
        /// <param name="destinationTvi">The destination tvi.</param>
        /// <returns><c>True</c> if successful; otherwise, <c>false</c>.  In the event of a false return
        /// the changes have not been saved and the user will be notified.</returns>
        private bool SaveChangeBackToTvi(TreeViewItem destinationTvi)
        {
            MetaPropEntity mpe = (MetaPropEntity)destinationTvi.Tag;

            if (mpe.Value.GetType() == typeof(string))
            {
                mpe.Value     = GetTextBoxValue();
                mpe.IsUpdated = true;
            }
            else if (mpe.Value.GetType() == typeof(Guid))
            {
                Guid var_guid;

                if (Guid.TryParse(GetTextBoxValue(), out var_guid))
                {
                    mpe.Value     = var_guid;
                    mpe.IsUpdated = true;
                }
                else
                {
                    MessageBox.Show("The system cannot save the Guid as it appears to be invalid.", "Invalid Guid");
                    return(false);
                }
            }
            else if (mpe.Value.GetType() == typeof(Int32))
            {
                Int32 var_int32;

                if (Int32.TryParse(GetTextBoxValue(), out var_int32))
                {
                    mpe.Value     = var_int32;
                    mpe.IsUpdated = true;
                }
                else
                {
                    MessageBox.Show("The system cannot save the value as it appears to be invalid.  The value must be numeric between " + Int32.MinValue.ToString() + " and " + Int32.MaxValue.ToString() + ".", "Invalid Value");
                    return(false);
                }
            }
            else if (mpe.Value.GetType() == typeof(UInt32))
            {
                UInt32 var_uint32;

                if (UInt32.TryParse(GetTextBoxValue(), out var_uint32))
                {
                    mpe.Value     = var_uint32;
                    mpe.IsUpdated = true;
                }
                else
                {
                    MessageBox.Show("The system cannot save the value as it appears to be invalid.  The value must be numeric between " + UInt32.MinValue.ToString() + " and " + UInt32.MaxValue.ToString() + ".", "Invalid Value");
                    return(false);
                }
            }
            else if (mpe.Value.GetType() == typeof(Int64))
            {
                Int64 var_int64;

                if (Int64.TryParse(GetTextBoxValue(), out var_int64))
                {
                    mpe.Value     = var_int64;
                    mpe.IsUpdated = true;
                }
                else
                {
                    MessageBox.Show("The system cannot save the value as it appears to be invalid.  The value must be numeric between " + Int64.MinValue.ToString() + " and " + Int64.MaxValue.ToString() + ".", "Invalid Value");
                    return(false);
                }
            }
            else if (mpe.Value.GetType() == typeof(UInt64))
            {
                UInt64 var_uint64;

                if (UInt64.TryParse(GetTextBoxValue(), out var_uint64))
                {
                    mpe.Value     = var_uint64;
                    mpe.IsUpdated = true;
                }
                else
                {
                    MessageBox.Show("The system cannot save the value as it appears to be invalid.  The value must be numeric between " + UInt64.MinValue.ToString() + " and " + UInt64.MaxValue.ToString() + ".", "Invalid Value");
                    return(false);
                }
            }
            else if (mpe.Value.GetType() == typeof(DateTime))
            {
                DateTime?var_dt = GetDateTimeValue();

                if (!var_dt.HasValue)
                {
                    MessageBox.Show("You must select a date.", "Invalid Date");
                    return(false);
                }

                mpe.Value     = var_dt;
                mpe.IsUpdated = true;
            }
            else if (mpe.Value.GetType() == typeof(bool))
            {
                bool?var_bool = GetCheckBoxValue();

                if (!var_bool.HasValue)
                {
                    MessageBox.Show("A checkbox was expected but could not be located", "Invalid CheckBox");
                    return(false);
                }

                mpe.Value     = var_bool;
                mpe.IsUpdated = true;
            }
            else if (mpe.Value.GetType() == typeof(System.Collections.Generic.List <string>))
            {
                System.Collections.Generic.List <string> var_list = ParseListFromString(GetTextBoxValue());

                if (var_list.Count <= 0)
                {
                    if (MessageBox.Show("No tags were entered, it is going to be really hard to locate this resource if you do not specify some tags.\r\nWould you like to add tags?", "Tags Desired?",
                                        MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) == MessageBoxResult.Yes)
                    {
                        return(false); // this prevents the UI from changing
                    }
                }

                mpe.Value     = var_list;
                mpe.IsUpdated = true;
            }

            return(true);
        }
Example #33
0
        private void Search(bool continued = false)
        {
            const int SEARCHLIMIT = 100;

            List <KmlItem> list;

            // TODO DlgSearch.Search(): loading the list on every continuation isn't the best choice
            // but it's ok, because that is fast, only loading items into tree is slow
            list = GuiTabsManager.GetCurrent().TreeManager.Search(TextBoxInput.Text,
                                                                  CheckNodeTag.IsChecked == true, CheckNodeText.IsChecked == true,
                                                                  CheckAttribName.IsChecked == true, CheckAttribValue.IsChecked == true);

            _searchResults.Clear();
            _searchResults.AddRange(list);

            int          maxItemCount = SEARCHLIMIT;
            KmlNode      parentNode   = null;
            TreeViewItem parentItem   = null;

            if (continued)
            {
                _searchContinued++;
                maxItemCount = SEARCHLIMIT * (_searchContinued + 1);
                parentItem   = (TreeViewItem)Tree.Items[Tree.Items.Count - 1];
                parentNode   = list[maxItemCount - SEARCHLIMIT - 1].Parent;
            }
            else
            {
                _searchContinued = 0;
                Tree.Items.Clear();
            }
            for (int i = maxItemCount - SEARCHLIMIT; i < list.Count; i++)
            {
                KmlItem item = list[i];
                // if (Tree.Items.Count >= maxParentCount)
                if (i >= maxItemCount)
                {
                    TreeViewItem dummy = new TreeViewItem();
                    dummy.Header = "...";
                    TreeViewItem toBeContinued = new TreeViewItem();
                    toBeContinued.Header    = "... " + (list.Count - maxItemCount) + " more items ...";
                    toBeContinued.Expanded += ToBeContinued_Expanded;
                    toBeContinued.Items.Add(dummy);
                    Tree.Items.Add(toBeContinued);
                    return;
                }
                if (item is KmlNode || item is KmlAttrib)
                {
                    if (item.Parent != null && item.Parent != parentNode)
                    {
                        parentNode        = item.Parent;
                        parentItem        = new TreeViewItem();
                        parentItem.Header = item.Parent.PathToString(@"\");
                        Tree.Items.Add(parentItem);
                        parentItem.IsExpanded = true;
                    }
                    TreeViewItem node;
                    if (item is KmlNode)
                    {
                        node = new GuiTreeNode((KmlNode)item, true, true, true, false, true, false);
                    }
                    else
                    {
                        node             = new TreeViewItem();
                        node.DataContext = item;
                        node.Header      = item.ToString();
                    }
                    node.Margin = new Thickness(-16, 0, 0, 0);
                    if (parentNode == null)
                    {
                        Tree.Items.Add(node);
                    }
                    else
                    {
                        parentItem.Items.Add(node);
                    }
                    node.IsSelected = Tree.SelectedItem == null;
                }
            }
        }
        public void UpdateWin(string req)
        {
            ItemCanvas.Children.Clear();
            Filters.Items.Clear();
            items.Clear();
            filters.Clear();
            string           request          = req;
            NpgsqlConnection npgSqlConnection = new NpgsqlConnection(connectionString);

            npgSqlConnection.Open();
            NpgsqlCommand    npgSqlCommand = new NpgsqlCommand(request, npgSqlConnection);
            NpgsqlDataReader reader        = npgSqlCommand.ExecuteReader();
            int countMat = 0;

            while (reader.Read())
            {
                int var = reader.GetInt32(0);
                countMat++;
            }
            int countV = countMat / 4;
            int countG = countMat - countV * 4;

            reader.Close();
            npgSqlConnection.Close();
            npgSqlConnection.Open();
            npgSqlCommand = new NpgsqlCommand(request, npgSqlConnection);
            reader        = npgSqlCommand.ExecuteReader();
            while (reader.Read())
            {
                for (int i = 0; i < countV; i++)
                {
                    double nach = 10;
                    if (ItemCanvas.Children.Count == 0)
                    {
                        nach = 10;
                    }
                    else
                    {
                        nach = Canvas.GetTop(ItemCanvas.Children[ItemCanvas.Children.Count - 1]) + 110;
                        if (double.IsNaN(nach))
                        {
                            nach = Canvas.GetTop(ItemCanvas.Children[ItemCanvas.Children.Count - 2]) + 110;
                        }
                    }
                    for (int j = 0; j < 4; j++)
                    {
                        int    id      = reader.GetInt32(0);
                        string group   = reader.GetString(1);
                        string ingroup = reader.GetString(2);
                        string sourse  = reader.GetString(3);
                        int[]  sizes   = reader[4] as int[];
                        double price   = reader.GetDouble(5);
                        string name    = reader.GetString(6);
                        items.Add(id + "|" + group + "|" + ingroup + "|" + sourse + "|" + sizes[0] + "|" + sizes[1] + "|" + sizes[2] + "|" + price + "|" + name + "|");
                        if (filters.IndexOf(group + "|" + ingroup) == -1)
                        {
                            filters.Add(group + "|" + ingroup);
                        }
                        Canvas thisItem = new Canvas
                        {
                            Width      = ItemCanvas.ActualWidth / 4 - 10 * 4,
                            Height     = 100,
                            Background = Brushes.Bisque,
                            Tag        = id
                        };
                        ItemCanvas.Children.Add(thisItem);
                        thisItem.MouseUp += elementCanvas_MouseUp_1;
                        Canvas.SetTop(thisItem, nach);
                        if (j == 0)
                        {
                            Canvas.SetLeft(thisItem, (ItemCanvas.ActualWidth / 8 + ItemCanvas.ActualWidth / 4) / 2 - thisItem.Width / 2);
                        }
                        if (j == 1)
                        {
                            Canvas.SetLeft(thisItem, (ItemCanvas.ActualWidth / 4 + ItemCanvas.ActualWidth / 2) / 2 - thisItem.Width / 2 + 15);
                        }
                        if (j == 2)
                        {
                            Canvas.SetLeft(thisItem, ItemCanvas.ActualWidth - (ItemCanvas.ActualWidth / 4 + ItemCanvas.ActualWidth / 2) / 2 - thisItem.Width / 2 - 15);
                        }
                        if (j == 3)
                        {
                            Canvas.SetLeft(thisItem, ItemCanvas.ActualWidth - (ItemCanvas.ActualWidth / 8 + ItemCanvas.ActualWidth / 4) / 2 - thisItem.Width / 2);
                        }
                        Border imgMat = new Border
                        {
                            Height          = 60,
                            Width           = thisItem.Width - 20,
                            BorderThickness = new Thickness(2),
                            BorderBrush     = Brushes.Black
                        };
                        Image img = new Image
                        {
                            Stretch = Stretch.Fill
                        };
                        if (sourse != "")
                        {
                            var uri    = new Uri(AppDomain.CurrentDomain.BaseDirectory + sourse);
                            var bitmap = new BitmapImage(uri);
                            img.Source = bitmap;
                        }
                        imgMat.Child = img;
                        Canvas.SetTop(imgMat, 0);
                        Canvas.SetLeft(imgMat, 10);
                        thisItem.Children.Add(imgMat);
                        TextBlock namemat = new TextBlock
                        {
                            Text                = name,
                            FontSize            = 14,
                            TextWrapping        = TextWrapping.Wrap,
                            HorizontalAlignment = HorizontalAlignment.Center
                        };
                        namemat.Height = 50;
                        namemat.Width  = imgMat.Width;
                        double nach1 = Canvas.GetTop(thisItem.Children[thisItem.Children.Count - 1]);
                        if (double.IsNaN(nach1))
                        {
                            nach1 = Canvas.GetTop(thisItem.Children[thisItem.Children.Count - 2]);
                        }
                        Canvas.SetTop(namemat, nach1 + 60);
                        Canvas.SetLeft(namemat, thisItem.Width / 2 - namemat.Width / 2);
                        thisItem.Children.Add(namemat);
                        reader.Read();
                    }
                }
                double nach2 = 10;
                if (ItemCanvas.Children.Count == 0)
                {
                    nach2 = 10;
                }
                else
                {
                    nach2 = Canvas.GetTop(ItemCanvas.Children[ItemCanvas.Children.Count - 1]) + 110;
                    if (double.IsNaN(nach2))
                    {
                        nach2 = Canvas.GetTop(ItemCanvas.Children[ItemCanvas.Children.Count - 2]) + 110;
                    }
                }
                for (int j = 0; j < countG; j++)
                {
                    int    id      = reader.GetInt32(0);
                    string group   = reader.GetString(1);
                    string ingroup = reader.GetString(2);
                    string sourse  = reader.GetString(3);
                    int[]  sizes   = reader[4] as int[];
                    double price   = reader.GetDouble(5);
                    string name    = reader.GetString(6);
                    items.Add(id + "|" + group + "|" + ingroup + "|" + sourse + "|" + sizes[0] + "|" + sizes[1] + "|" + sizes[2] + "|" + price + "|" + name + "|");
                    if (filters.IndexOf(group + "|" + ingroup) == -1)
                    {
                        filters.Add(group + "|" + ingroup);
                    }
                    Canvas thisItem = new Canvas
                    {
                        Width      = ItemCanvas.ActualWidth / 4 - 10 * 4,
                        Height     = 100,
                        Background = Brushes.Bisque,
                        Tag        = id
                    };
                    ItemCanvas.Children.Add(thisItem);
                    thisItem.MouseUp += elementCanvas_MouseUp_1;
                    Canvas.SetTop(thisItem, nach2);
                    if (j == 0)
                    {
                        Canvas.SetLeft(thisItem, (ItemCanvas.ActualWidth / 8 + ItemCanvas.ActualWidth / 4) / 2 - thisItem.Width / 2);
                    }
                    if (j == 1)
                    {
                        Canvas.SetLeft(thisItem, (ItemCanvas.ActualWidth / 4 + ItemCanvas.ActualWidth / 2) / 2 - thisItem.Width / 2 + 15);
                    }
                    if (j == 2)
                    {
                        Canvas.SetLeft(thisItem, ItemCanvas.ActualWidth - (ItemCanvas.ActualWidth / 4 + ItemCanvas.ActualWidth / 2) / 2 - thisItem.Width / 2 - 15);
                    }
                    Border imgMat = new Border
                    {
                        Height          = 60,
                        Width           = thisItem.Width - 20,
                        BorderThickness = new Thickness(2),
                        BorderBrush     = Brushes.Black
                    };
                    Image img = new Image
                    {
                        Stretch = Stretch.Fill
                    };
                    if (sourse != "")
                    {
                        var uri    = new Uri(AppDomain.CurrentDomain.BaseDirectory + sourse);
                        var bitmap = new BitmapImage(uri);
                        img.Source   = bitmap;
                        imgMat.Child = img;
                    }
                    Canvas.SetTop(imgMat, 0);
                    Canvas.SetLeft(imgMat, 10);
                    thisItem.Children.Add(imgMat);
                    TextBlock namemat = new TextBlock
                    {
                        Text                = name,
                        FontSize            = 14,
                        TextWrapping        = TextWrapping.Wrap,
                        HorizontalAlignment = HorizontalAlignment.Center
                    };
                    namemat.Height = 50;;
                    namemat.Width  = imgMat.Width;
                    double nach1 = Canvas.GetTop(thisItem.Children[thisItem.Children.Count - 1]);
                    if (double.IsNaN(nach1))
                    {
                        nach1 = Canvas.GetTop(thisItem.Children[thisItem.Children.Count - 2]);
                    }
                    Canvas.SetTop(namemat, nach1 + 60);
                    Canvas.SetLeft(namemat, thisItem.Width / 2 - namemat.Width / 2);
                    thisItem.Children.Add(namemat);
                    reader.Read();
                }
            }
            double nach3 = 10;

            if (ItemCanvas.Children.Count == 0)
            {
                nach3 = 10;
            }
            else
            {
                nach3 = Canvas.GetTop(ItemCanvas.Children[ItemCanvas.Children.Count - 1]) + 110;
                if (double.IsNaN(nach3))
                {
                    nach3 = Canvas.GetTop(ItemCanvas.Children[ItemCanvas.Children.Count - 2]) + 110;
                }
            }
            if (nach3 > ItemCanvas.Height)
            {
                ItemCanvas.Height = nach3;
            }
            if (ItemCanvas.Height <= 380)
            {
                ItemCanvas.Height = 380;
            }

            for (int i = 0; i < filters.Count; i++)
            {
                string   str  = filters[i] as string;
                string[] str1 = str.Split('|');
                bool     nal  = false;
                for (int j = 0; j < Filters.Items.Count; j++)
                {
                    CheckBox tmpcb = Filters.Items[j] as CheckBox;
                    if (tmpcb.Tag.ToString() == str1[0])
                    {
                        nal = true;
                        bool         naling  = false;
                        TreeViewItem tmptree = tmpcb.Content as TreeViewItem;
                        for (int j1 = 0; j1 < tmptree.Items.Count; j1++)
                        {
                            CheckBox tmpcb1 = tmptree.Items[j1] as CheckBox;
                            if (tmpcb.Tag.ToString() == str1[1])
                            {
                                naling = true;
                            }
                        }
                        if (naling == false)
                        {
                            CheckBox head = new CheckBox();
                            head.Tag        = str;
                            head.Content    = str1[1];
                            head.Checked   += _ClickCB;
                            head.Unchecked += _ClickCB;
                            tmptree.Items.Add(head);
                        }
                    }
                }
                if (nal == false)
                {
                    CheckBox head = new CheckBox();
                    head.Tag = str1[0];
                    Filters.Items.Add(head);
                    head.Checked   += _ClickCB;
                    head.Unchecked += _ClickCB;
                    TreeViewItem treehead = new TreeViewItem();
                    treehead.Tag    = str1[0];
                    treehead.Header = str1[0];
                    head.Content    = treehead;
                    CheckBox head1 = new CheckBox();
                    head1.Tag        = str;
                    head1.Content    = str1[1];
                    head1.Checked   += _ClickCB;
                    head1.Unchecked += _ClickCB;
                    treehead.Items.Add(head1);
                }
            }
        }
Example #35
0
        private void FillTreeView(string sourceDir, string[] svgFiles, TreeViewItem treeItem)
        {
            if (svgFiles != null && svgFiles.Length != 0)
            {
                for (int i = 0; i < svgFiles.Length; i++)
                {
                    string svgFile = svgFiles[i];

                    TextBlock itemText = new TextBlock();
                    itemText.Text   = string.Format("({0:D3}) - {1}", i, IoPath.GetFileName(svgFile));
                    itemText.Margin = new Thickness(3, 0, 0, 0);

                    BulletDecorator fileItem = new BulletDecorator();
                    if (_fileThumbnail != null)
                    {
                        Image image = new Image();
                        image.Source = _fileThumbnail;
                        image.Height = 16;
                        image.Width  = 16;

                        fileItem.Bullet = image;
                    }
                    else
                    {
                        Ellipse bullet = new Ellipse();
                        bullet.Height          = 16;
                        bullet.Width           = 16;
                        bullet.Fill            = Brushes.Goldenrod;
                        bullet.Stroke          = Brushes.DarkGray;
                        bullet.StrokeThickness = 1;

                        fileItem.Bullet = bullet;
                    }
                    fileItem.Margin = new Thickness(0, 0, 10, 0);
                    fileItem.Child  = itemText;

                    TreeViewItem item = new TreeViewItem();
                    item.Tag        = svgFile;
                    item.Header     = fileItem;
                    item.Margin     = new Thickness(0);
                    item.Padding    = new Thickness(2);
                    item.FontSize   = 12;
                    item.FontWeight = FontWeights.Normal;

                    treeItem.Items.Add(item);
                }
            }

            if (string.IsNullOrWhiteSpace(sourceDir) || !Directory.Exists(sourceDir))
            {
                return;
            }

            if (_optionSettings.RecursiveSearch == false)
            {
                return;
            }

            string[] directories = Directory.GetDirectories(sourceDir);
            if (directories != null && directories.Length != 0)
            {
                for (int i = 0; i < directories.Length; i++)
                {
                    string directory = directories[i];
                    svgFiles = Directory.GetFiles(directory, SvgFilePattern, SearchOption.TopDirectoryOnly);
                    {
                        DirectoryInfo directoryInfo = new DirectoryInfo(directory);

                        TextBlock headerText = new TextBlock();
                        headerText.Text   = directoryInfo.Name;
                        headerText.Margin = new Thickness(3, 0, 0, 0);

                        BulletDecorator decorator = new BulletDecorator();
                        if (_folderClose != null)
                        {
                            Image image = new Image();
                            image.Source = _folderClose;

                            decorator.Bullet = image;
                        }
                        else
                        {
                            Ellipse bullet = new Ellipse();
                            bullet.Height          = 16;
                            bullet.Width           = 16;
                            bullet.Fill            = Brushes.Goldenrod;
                            bullet.Stroke          = Brushes.DarkGray;
                            bullet.StrokeThickness = 1;

                            decorator.Bullet = bullet;
                        }
                        decorator.Margin = new Thickness(0, 0, 10, 0);
                        decorator.Child  = headerText;

                        TreeViewItem categoryItem = new TreeViewItem();
                        categoryItem.Tag        = string.Empty;
                        categoryItem.Header     = decorator;
                        categoryItem.Margin     = new Thickness(0);
                        categoryItem.Padding    = new Thickness(3);
                        categoryItem.FontSize   = 14;
                        categoryItem.FontWeight = FontWeights.Bold;

                        treeItem.Items.Add(categoryItem);

                        FillTreeView(directory, svgFiles, categoryItem);

                        if (!categoryItem.HasItems)
                        {
                            treeItem.Items.Remove(categoryItem);
                        }
                    }
                }
            }
        }
 protected override bool CanMultiSelect(TreeViewItem item)
 {
     return(false);
 }
 private void Button_Click_5(object sender, RoutedEventArgs e)
 {
     if (lastCoinHeight == apiHeight)//高度一样就别刷了
     {
         return;
     }
     try
     {
         if (initCoins == false)
         {
             var json = api_getAllAssets();
             Tools.CoinTool.Load();
             Tools.CoinTool.ParseUtxoAsset(json.AsList());
             initCoins = true;
         }
     }
     catch (Exception err)
     {
         MessageBox.Show("InitCoins:" + err.Message);
     }
     try
     {
         myasset = new Tools.Asset();
         try
         {
             var json = api_getUTXO().AsList();
             myasset.ParseUTXO(json);
         }
         catch
         {
             //沒刷出來不要緊張
         }
         foreach (var nep5 in Tools.CoinTool.assetNep5)
         {
             var dec = rpc_getNep5Balance(nep5.Key);
             if (dec > 0)
             {
                 var nep5coin = new Tools.CoinType(nep5.Key, true);
                 nep5coin.Value = dec;
                 myasset.allcoins.Add(nep5coin);
             }
         }
         lastCoinHeight       = apiHeight;
         infoAssetHeight.Text = "Refresh:" + lastCoinHeight;
         //fill item
         treeCoins.Items.Clear();
         foreach (var cointype in myasset.allcoins)
         {
             TreeViewItem item = new TreeViewItem();
             item.Tag = cointype;
             if (cointype.NEP5)
             {
                 item.Header = "(NEP5)" + Tools.CoinTool.GetName(cointype.AssetID) + ":" + cointype.Value;
             }
             else
             {
                 item.Header = "(UTXO)" + Tools.CoinTool.GetName(cointype.AssetID) + ":" + cointype.Value;
                 foreach (var coin in cointype.coins)
                 {
                     TreeViewItem itemUtxo = new TreeViewItem();
                     itemUtxo.Tag    = coin;
                     itemUtxo.Header = coin.value + " <== " + coin.fromID + "[" + coin.fromN + "]";
                     item.Items.Add(itemUtxo);
                 }
             }
             treeCoins.Items.Add(item);
         }
     }
     catch (Exception err)
     {
         MessageBox.Show("GetBalance:" + err.Message);
     }
 }
Example #38
0
 public static void SetIsBroughtIntoViewWhenSelected(
     TreeViewItem treeViewItem, bool value)
 {
     treeViewItem.SetValue(IsBroughtIntoViewWhenSelectedProperty, value);
 }
        /// <summary>
        /// Recursively search for an item in this subtree.
        /// </summary>
        /// <param name="container">
        /// The parent ItemsControl. This can be a TreeView or a TreeViewItem.
        /// </param>
        /// <param name="item">
        /// The item to search for.
        /// </param>
        /// <returns>
        /// The TreeViewItem that contains the specified item.
        /// </returns>
        private TreeViewItem GetTreeViewItem(ItemsControl container, object item)
        {
            if (container != null)
            {
                if (container.DataContext == item)
                {
                    return(container as TreeViewItem);
                }

                // Expand the current container
                if (container is TreeViewItem && !((TreeViewItem)container).IsExpanded)
                {
                    container.SetValue(TreeViewItem.IsExpandedProperty, true);
                }

                // Try to generate the ItemsPresenter and the ItemsPanel.
                // by calling ApplyTemplate.  Note that in the
                // virtualizing case even if the item is marked
                // expanded we still need to do this step in order to
                // regenerate the visuals because they may have been virtualized away.

                container.ApplyTemplate();
                ItemsPresenter itemsPresenter =
                    (ItemsPresenter)container.Template.FindName("ItemsHost", container);
                if (itemsPresenter != null)
                {
                    itemsPresenter.ApplyTemplate();
                }
                else
                {
                    // The Tree template has not named the ItemsPresenter,
                    // so walk the descendents and find the child.
                    itemsPresenter = FindVisualChild <ItemsPresenter>(container);
                    if (itemsPresenter == null)
                    {
                        container.UpdateLayout();

                        itemsPresenter = FindVisualChild <ItemsPresenter>(container);
                    }
                }
                if (itemsPresenter == null)
                {
                    return(null);
                }

                Panel itemsHostPanel = (Panel)VisualTreeHelper.GetChild(itemsPresenter, 0);



                MyVirtualizingStackPanel virtualizingPanel =
                    itemsHostPanel as MyVirtualizingStackPanel;

                for (int i = 0, count = container.Items.Count; i < count; i++)
                {
                    TreeViewItem subContainer;
                    if (virtualizingPanel != null)
                    {
                        // Bring the item into view so
                        // that the container will be generated.
                        virtualizingPanel.BringIntoView(i);

                        subContainer =
                            (TreeViewItem)container.ItemContainerGenerator.
                            ContainerFromIndex(i);
                    }
                    else
                    {
                        subContainer =
                            (TreeViewItem)container.ItemContainerGenerator.
                            ContainerFromIndex(i);

                        // Bring the item into view to maintain the
                        // same behavior as with a virtualizing panel.
                        subContainer.BringIntoView();
                    }

                    if (subContainer != null)
                    {
                        // Search the next level for the object.
                        TreeViewItem resultContainer = GetTreeViewItem(subContainer, item);
                        if (resultContainer != null)
                        {
                            return(resultContainer);
                        }
                    }
                }
            }

            return(null);
        }
Example #40
0
 public static bool GetIsBroughtIntoViewWhenSelected(TreeViewItem treeViewItem)
 {
     return((bool)treeViewItem.GetValue(IsBroughtIntoViewWhenSelectedProperty));
 }
Example #41
0
 protected override bool CanRename(TreeViewItem item)
 {
     return(true);
 }
Example #42
0
        private async void FolderTreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            TreeViewItem viewItem = FolderTreeView.SelectedItem as TreeViewItem;

            await GetAllFileInFolder(viewItem);
        }
Example #43
0
        private void BindApproval()
        {
            treeApproval.Items.Clear();
            List <T_SYS_DICTIONARY> Dicts = Application.Current.Resources["SYS_DICTIONARY"] as List <T_SYS_DICTIONARY>;



            if (ListDicts == null)
            {
                return;
            }

            List <T_SYS_DICTIONARY> TopApproval    = new List <T_SYS_DICTIONARY>();
            List <T_SYS_DICTIONARY> SecondApproval = new List <T_SYS_DICTIONARY>();
            List <T_SYS_DICTIONARY> ThreeApproval  = new List <T_SYS_DICTIONARY>();
            var ents = from p in Dicts
                       where p.DICTIONCATEGORY == "TYPEAPPROVAL"
                       orderby p.ORDERNUMBER
                       select p;

            ListDicts = ents.Count() > 0 ? ents.ToList() : null;
            if (ListDicts != null)
            {
                foreach (T_SYS_DICTIONARY dict in ListDicts)
                {
                    if (dict.T_SYS_DICTIONARY2 == null)
                    {
                        TreeViewItem item = new TreeViewItem();
                        item.Header         = dict.DICTIONARYNAME;
                        item.HeaderTemplate = Application.Current.Resources["OrganizationItemStyle"] as DataTemplate;
                        item.Style          = Application.Current.Resources["TreeViewItemStyle"] as Style;
                        item.DataContext    = dict;
                        item.Tag            = dict;


                        if (lsApprovalTypeValues.Contains(dict.DICTIONARYVALUE.ToString()))
                        {
                            treeApproval.Items.Add(item);
                            TopApproval.Add(dict);
                        }
                    }
                }
                if (TopApproval.Count() > 0)
                {
                    foreach (var topApp in TopApproval)
                    {
                        //存在子记录的则添加子节点
                        List <T_SYS_DICTIONARY> lstDict = new List <T_SYS_DICTIONARY>();
                        var lsents = from ent in ListDicts
                                     where ent.T_SYS_DICTIONARY2 != null && ent.T_SYS_DICTIONARY2.DICTIONARYID == topApp.DICTIONARYID
                                     select ent;
                        if (lsents.Count() > 0)
                        {
                            lstDict = lsents.ToList();
                            TreeViewItem parentItem = GetApprovalParentItem(topApp.DICTIONARYID);

                            AddApprovalNode(lstDict, parentItem);
                        }
                    }
                }
            }
        }
Example #44
0
        public override void ShowDialog(PropertyValue propertyValue, IInputElement commandSource)
        {
            ReportIDDialog      dialogcontent = new ReportIDDialog();
            InArgument <string> propVal       = (InArgument <string>)propertyValue.Value;
            string CurrRepId = null;

            if (propVal != null)
            {
                CurrRepId = propVal.Expression.ToString();
            }

            var tree = dialogcontent.treeView1;

            tree.Items.Clear();

            DataTable TempTable = null;

            string sql =
                @"set nocount on;set transaction isolation level read uncommitted;
SELECT     Info_Report.Report_UN, Info_Report.StringName, Info_Report.HierLev0_ID, Info_Report.HierLev1_ID, Info_Report.HierLev2_ID, Info_Report.HierLev3_ID, 
                      Info_Report.PS_ID, Info_Report.User_ID, Info_Report.CreateDateTime, Info_Report.DispatchDateTime, Info_Report.DateTimeDialog, 
                      Dict_HierLev0.StringName AS Lev0, 
                      Dict_HierLev1.StringName AS Lev1, 
                      Dict_HierLev2.StringName AS Lev2, 
                      Dict_HierLev3.StringName AS Lev3, 
                      Dict_PS.StringName AS PSNAme
FROM         Info_Report LEFT JOIN
                      Dict_PS ON Info_Report.PS_ID = Dict_PS.PS_ID
                      LEFT OUTER JOIN Dict_HierLev2 ON Info_Report.HierLev2_ID = Dict_HierLev2.HierLev2_ID 
                      LEFT OUTER JOIN Dict_HierLev1 ON Info_Report.HierLev1_ID = Dict_HierLev1.HierLev1_ID AND Info_Report.HierLev1_ID = Dict_HierLev1.HierLev1_ID 
                      LEFT OUTER JOIN Dict_HierLev3 ON Info_Report.HierLev3_ID = Dict_HierLev3.HierLev3_ID AND Info_Report.HierLev3_ID = Dict_HierLev3.HierLev3_ID AND 
                      Dict_HierLev2.HierLev2_ID = Dict_HierLev3.HierLev2_ID 
                      LEFT OUTER JOIN Dict_HierLev0 ON Info_Report.HierLev0_ID = Dict_HierLev0.HierLev0_ID
ORDER BY  Info_Report.HierLev0_ID, Info_Report.HierLev1_ID, Info_Report.HierLev2_ID, 
Info_Report.HierLev3_ID, Info_Report.PS_ID";

            try
            {
                var serverData = ARM_Service.REP_Query_Report(sql, new List <QueryParameter>());
                TempTable = serverData.Key;
            }
            catch (Exception e)
            {
            }

            TreeViewItem Lev1    = null;
            TreeViewItem Lev2    = null;
            TreeViewItem Lev3    = null;
            TreeViewItem LevPs   = null;
            TreeViewItem lastlev = null;

            if (TempTable != null)
            {
                foreach (DataRow row in TempTable.Rows)
                {
                    var rClass = new RepClass
                    {
                        Report_UN     = row["Report_UN"].ToString(),
                        ReportName    = row["StringName"].ToString(),
                        HierLev1_Name = row["Lev1"] as string,
                        HierLev2_Name = row["Lev2"] as string,
                        HierLev3_Name = row["Lev3"] as string,
                        PS_Name       = row["PSNAme"] as string
                    };

                    if ((Lev1 == null) || (Lev1 != null && Lev1.Header != null &&
                                           Lev1.Header.ToString() != rClass.HierLev1_Name))
                    {
                        Lev1 = new TreeViewItem();
                        if (string.IsNullOrEmpty(rClass.HierLev1_Name))
                        {
                            Lev1.Header = rClass.ReportName;
                        }
                        else
                        {
                            Lev1.Header = rClass.HierLev1_Name;
                        }
                        Lev1.IsExpanded = true;
                        tree.Items.Add(Lev1);
                        lastlev = Lev1;
                    }

                    if ((Lev2 == null && !string.IsNullOrEmpty(rClass.HierLev2_Name)) ||
                        (Lev2 != null && Lev2.Header != null && Lev2.Header.ToString() != rClass.HierLev2_Name))
                    {
                        Lev2        = new TreeViewItem();
                        Lev2.Header = rClass.HierLev2_Name;
                        if (Lev1 != null)
                        {
                            Lev1.Items.Add(Lev2);
                        }
                        Lev2.IsExpanded = true;
                        lastlev         = Lev2;
                    }

                    if ((Lev3 == null && !string.IsNullOrEmpty(rClass.HierLev3_Name)) ||
                        (Lev3 != null && Lev3.Header != null && Lev3.Header.ToString() != rClass.HierLev3_Name))
                    {
                        Lev3 = new TreeViewItem
                        {
                            Header     = rClass.HierLev3_Name,
                            IsExpanded = true
                        };

                        if (Lev2 != null)
                        {
                            Lev2.Items.Add(Lev3);
                        }
                        lastlev = Lev3;
                    }

                    if ((LevPs == null && !string.IsNullOrEmpty(rClass.PS_Name)) ||
                        (LevPs != null && LevPs.Header != null && LevPs.Header.ToString() != rClass.PS_Name))
                    {
                        LevPs = new TreeViewItem
                        {
                            Header     = rClass.PS_Name,
                            IsExpanded = true
                        };

                        if (Lev3 != null)
                        {
                            Lev3.Items.Add(LevPs);
                        }

                        lastlev = LevPs;
                    }

                    if (lastlev != null)
                    {
                        var repLev = new TreeViewItem
                        {
                            Header = rClass.ReportName,
                            Tag    = rClass
                        };
                        lastlev.Items.Add(repLev);

                        if (CurrRepId == rClass.Report_UN)
                        {
                            repLev.IsSelected = true;
                        }
                    }
                }
            }

            if (dialogcontent.ShowOkCancel())
            {
                if (tree.SelectedItem != null)
                {
                    var selitem = tree.SelectedItem as TreeViewItem;
                    if (selitem != null && selitem.Tag != null)
                    {
                        var RClass = selitem.Tag as RepClass;
                        if (RClass != null)
                        {
                            var sel = RClass.Report_UN;
                            propertyValue.Value = new InArgument <string>(sel);
                        }
                    }
                }
            }
        }
Example #45
0
 public static void SetTreeViewItem(DependencyObject obj, TreeViewItem value)
 {
     obj.SetValue(TreeViewItemProperty, value);
 }
Example #46
0
        public void RebuildTree(IPanelDebug panelDebug)
        {
            if (!hierarchyHasChanged && m_CurrentPanelDebug == panelDebug)
            {
                return;
            }

            m_CurrentPanelDebug = panelDebug;
            m_Container.Clear();

            int nextId = 1;

            m_TreeRootItems.Clear();

            var visualTree = panelDebug?.visualTree;

            if (visualTree != null)
            {
                var rootItem = new TreeViewItem <VisualElement>(nextId++, visualTree);
                m_TreeRootItems.Add(rootItem);

                var childItems = new List <ITreeViewItem>();
                AddTreeItemsForElement(childItems, visualTree, ref nextId);

                rootItem.AddChildren(childItems);
            }

            Func <VisualElement> makeItem = () =>
            {
                var element = new VisualElement();
                element.name = "unity-treeview-item-content";
                element.RegisterCallback <MouseEnterEvent>((e) =>
                {
                    HighlightItemInTargetWindow(e.target as VisualElement);
                });
                element.RegisterCallback <MouseLeaveEvent>((e) =>
                {
                    UnhighlightItemInTargetWindow(e.target as VisualElement);
                });
                return(element);
            };

            // Clear selection which would otherwise persist via view data persistence.
            m_TreeView?.ClearSelection();

            m_TreeView = new TreeView(m_TreeRootItems, 20, makeItem, FillItem);
            m_TreeView.style.flexGrow     = 1;
            m_TreeView.onSelectionChange += items =>
            {
                if (m_SelectElementCallback == null)
                {
                    return;
                }

                if (!items.Any())
                {
                    m_SelectElementCallback(null);
                    return;
                }

                var item    = items.First() as TreeViewItem <VisualElement>;
                var element = item != null ? item.data : null;
                m_SelectElementCallback(element);
            };

            m_Container.Add(m_TreeView);

            hierarchyHasChanged = false;
            m_SearchBar.ClearSearch();
        }
Example #47
0
 public FrameDataTreeViewItem(FrameDataView frameDataView, int id, int depth, TreeViewItem parent) : base(id, depth, parent, null)
 {
     this.m_FrameDataView = frameDataView;
     this.m_Initialized   = false;
 }
        private TreeViewItem AddAnimatableObjectToHierarchy(GameObject root, EditorCurveBinding[] curveBindings, TreeViewItem parentNode, string path)
        {
            TreeViewItem item = new AddCurvesPopupObjectNode(parentNode, path, GetClassName(root, curveBindings[0]))
            {
                icon = AssetPreview.GetMiniThumbnail(AnimationUtility.GetAnimatedObject(root, curveBindings[0]))
            };
            List <TreeViewItem>       visibleItems = new List <TreeViewItem>();
            List <EditorCurveBinding> list2        = new List <EditorCurveBinding>();

            for (int i = 0; i < curveBindings.Length; i++)
            {
                EditorCurveBinding binding = curveBindings[i];
                list2.Add(binding);
                if ((i == (curveBindings.Length - 1)) || (AnimationWindowUtility.GetPropertyGroupName(curveBindings[i + 1].propertyName) != AnimationWindowUtility.GetPropertyGroupName(binding.propertyName)))
                {
                    TreeViewItem item2 = this.CreateNode(list2.ToArray(), item);
                    if (item2 != null)
                    {
                        visibleItems.Add(item2);
                    }
                    list2.Clear();
                }
            }
            visibleItems.Sort();
            TreeViewUtility.SetChildParentReferences(visibleItems, item);
            return(item);
        }
Example #49
0
        /// <summary>
        /// When a folder is expanded, find the sub folders/files
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Folder_Expanded(object sender, RoutedEventArgs e)
        {
            #region Initial Checks

            var item = (TreeViewItem)sender;

            // If the item only contains the dummy data
            if (item.Items.Count != 1 || item.Items[0] != null)
            {
                return;
            }

            // Clear dummy data
            item.Items.Clear();

            // Get full path
            var fullPath = (string)item.Tag;

            #endregion

            #region Get Folders

            // Create a blank list for directories
            var directories = new List <string>();

            // Try and get directories from the folder
            // ignoring any issues doing so
            try
            {
                var dirs = Directory.GetDirectories(fullPath);
                if (dirs.Length > 0)
                {
                    directories.AddRange(dirs);
                }
            }
            catch { }

            // For each directory...
            directories.ForEach(directoryPath =>
            {
                // Create directory item
                var subItem = new TreeViewItem()
                {
                    // Set header as folder name
                    Header = GetFileFolderName(directoryPath),
                    // Set tag as full path
                    Tag = directoryPath
                };

                // Add dummy item so we can expand folder
                subItem.Items.Add(null);

                // Handle expanding
                subItem.Expanded += Folder_Expanded;

                // Add this item to the parent
                item.Items.Add(subItem);
            });

            #endregion

            #region Get Files

            // Create a blank list for files
            var files = new List <string>();

            // Try and get files from the folder
            // ignoring any issues doing so
            try
            {
                var fs = Directory.GetFiles(fullPath);
                if (fs.Length > 0)
                {
                    files.AddRange(fs);
                }
            }
            catch { }

            // For each file...
            files.ForEach(filePath =>
            {
                // Create directory item
                var subItem = new TreeViewItem()
                {
                    // Set header as file name
                    Header = GetFileFolderName(filePath),
                    // Set tag as full path
                    Tag = filePath
                };

                // Add this item to the parent
                item.Items.Add(subItem);
            });

            #endregion
        }
Example #50
0
        bool RemoveAssetStoreFiles(TreeViewItem root, StringBuilder log)
        {
            AssetTreeItem node = root as AssetTreeItem;

            if (node != null && (node.enabled && !node.isMixedState))
            {
                if (!AssetDatabase.MoveAssetToTrash(node.fullPath))
                {
                    if (!AssetDatabase.DeleteAsset(node.fullPath))
                    {
                        if (Directory.Exists(node.fullPath))
                        {
                            Directory.Delete(node.fullPath, true);

                            if (Directory.Exists(node.fullPath))
                            {
                                Debug.LogError("Directory.Delete failed, giving up. (" + node.fullPath + ")");
                                return(false);
                            }
                            else
                            {
                                File.Delete(node.fullPath.Trim('/') + ".meta");
                            }
                        }
                        else if (File.Exists(node.fullPath))
                        {
                            File.Delete(node.fullPath);

                            if (File.Exists(node.fullPath))
                            {
                                Debug.LogError("File.Delete failed, giving up (" + node.fullPath + ")");
                                return(true);
                            }
                            else
                            {
                                File.Delete(node.fullPath + ".meta");
                            }
                        }
                    }
                }

                log.AppendLine("  - " + node.fullPath);

                return(true);
            }

            if (node.children != null)
            {
                bool success = true;

                foreach (var branch in node.children)
                {
                    if (!RemoveAssetStoreFiles(branch, log))
                    {
                        success = false;
                    }
                }

                return(success);
            }

            return(true);
        }
        private TreeViewItem AddGameObjectToHierarchy(GameObject gameObject, TreeViewItem parent)
        {
            string              path         = AnimationUtility.CalculateTransformPath(gameObject.transform, this.state.activeRootGameObject.transform);
            TreeViewItem        parentNode   = new AddCurvesPopupGameObjectNode(gameObject, parent, gameObject.name);
            List <TreeViewItem> visibleItems = new List <TreeViewItem>();

            if (parent == null)
            {
                base.m_RootItem = parentNode;
            }
            EditorCurveBinding[]      animatableBindings = AnimationUtility.GetAnimatableBindings(gameObject, this.state.activeRootGameObject);
            List <EditorCurveBinding> list2 = new List <EditorCurveBinding>();

            for (int i = 0; i < animatableBindings.Length; i++)
            {
                EditorCurveBinding item = animatableBindings[i];
                list2.Add(item);
                if (item.propertyName == "m_IsActive")
                {
                    if (item.path != string.Empty)
                    {
                        TreeViewItem item2 = this.CreateNode(list2.ToArray(), parentNode);
                        if (item2 != null)
                        {
                            visibleItems.Add(item2);
                        }
                        list2.Clear();
                    }
                    else
                    {
                        list2.Clear();
                    }
                }
                else
                {
                    bool flag  = i == (animatableBindings.Length - 1);
                    bool flag2 = false;
                    if (!flag)
                    {
                        flag2 = animatableBindings[i + 1].type != item.type;
                    }
                    if (AnimationWindowUtility.IsCurveCreated(this.state.activeAnimationClip, item))
                    {
                        list2.Remove(item);
                    }
                    if ((flag || flag2) && (list2.Count > 0))
                    {
                        visibleItems.Add(this.AddAnimatableObjectToHierarchy(this.state.activeRootGameObject, list2.ToArray(), parentNode, path));
                        list2.Clear();
                    }
                }
            }
            if (showEntireHierarchy)
            {
                for (int j = 0; j < gameObject.transform.childCount; j++)
                {
                    Transform    child = gameObject.transform.GetChild(j);
                    TreeViewItem item3 = this.AddGameObjectToHierarchy(child.gameObject, parentNode);
                    if (item3 != null)
                    {
                        visibleItems.Add(item3);
                    }
                }
            }
            TreeViewUtility.SetChildParentReferences(visibleItems, parentNode);
            return(parentNode);
        }
Example #52
0
 private void SelectionByKey(TreeViewItem itemSelected)
 {
     state.selectedIDs   = GetNewSelection(itemSelected, false, true);
     state.lastClickedID = itemSelected.id;
     NotifyListenersThatSelectionChanged();
 }
Example #53
0
        private void FolderExpanded(object sender, RoutedEventArgs e)
        {
            var item = (TreeViewItem)sender;

            if (item.Items.Count != 1 || item.Items[0] != null)
            {
                return;
            }
            item.Items.Clear();
            var fullPath = item.Tag.ToString();

            #region Get Folders
            var directories = new List <string>();

            try
            {
                var dirs = Directory.GetDirectories(fullPath);
                if (dirs.Length > 0)
                {
                    directories.AddRange(dirs);
                }
            }
            catch { }


            foreach (var directoryPath in directories)
            {
                var subItem = new TreeViewItem();
                subItem.Header = GetFileFolderName(directoryPath);
                subItem.Tag    = directoryPath;


                subItem.Items.Add(null);
                subItem.Expanded += FolderExpanded;
                item.Items.Add(subItem);
            }

            var files = new List <string>();

            try
            {
                var fs = Directory.GetFiles(fullPath);
                if (fs.Length > 0)
                {
                    files.AddRange(fs);
                }
            }
            catch { }


            foreach (var filePath in files)
            {
                var subItem = new TreeViewItem();
                subItem.Header = GetFileFolderName(filePath);
                subItem.Tag    = filePath;


                //add to parent
                item.Items.Add(subItem);
            }

            #endregion
        }
Example #54
0
        // 存储思路
        public void AddItemsToRoot(TreeViewItem root)
        {
            int toolsLength = providerData.Providers.Length;
            var id2IndexDic = providerData.ID2IndexDic = new Dictionary <int, int>(toolsLength);

            int id = root.id;

            for (int index = 0; index < toolsLength; index++)
            {
                var toolPath = providerData.Providers[index].ToolPath;

                // 获取直系父节点
                var toolPaths      = toolPath.Split("/");//解析路径
                int parentCount    = toolPaths.Length - 1;
                var lastParentNode = root;
                //寻找最后一个未被创建的
                int j = 0;
                for (; j < parentCount; j++)
                {
                    if (lastParentNode.children == null)
                    {
                        break;
                    }
                    else
                    {
                        string path = toolPaths[j];
                        foreach (var item in lastParentNode.children)
                        {
                            if (item.displayName == path)
                            {
                                lastParentNode = item;
                                break;
                            }
                        }
                    }
                }

                //补足空的父节点
                for (; j < parentCount; j++)
                {
                    var item = new TreeViewItem(++id, lastParentNode.depth + 1, toolPaths[j]);
                    lastParentNode.AddChild(item);
                    lastParentNode = item;
                }

                // 最少有一个可创建
                if (j > parentCount)
                {
                    //某个工具的节点可能是某个节点的父节点,被先创建了
                    int lastParentNodeId = lastParentNode.id;
                    if (id2IndexDic.ContainsKey(lastParentNodeId))
                    {
                        Debug.LogError($"{toolPath} 工具路径已存在!");
                    }
                    else
                    {
                        id2IndexDic.Add(lastParentNodeId, index);
                    }
                }
                else
                {
                    id2IndexDic.Add(++id, index);
                    lastParentNode.AddChild(new TreeViewItem(id, lastParentNode.depth + 1, toolPaths[j]));
                }
            }
        }
Example #55
0
        private void FillTreeView(string sourceDir)
        {
            if (!string.IsNullOrWhiteSpace(_sourceDir) && Directory.Exists(_sourceDir))
            {
                this.CloseFile();
            }
            _sourceDir = string.Empty;
            if (string.IsNullOrWhiteSpace(sourceDir) || !Directory.Exists(sourceDir))
            {
                return;
            }

            _sourceDir         = new string(sourceDir.ToCharArray());
            _isRecursiveSearch = _optionSettings.RecursiveSearch;

            string[] svgFiles = Directory.GetFiles(sourceDir, SvgFilePattern, SearchOption.TopDirectoryOnly);

            treeView.BeginInit();
            treeView.Items.Clear();

            DirectoryInfo directoryInfo = new DirectoryInfo(sourceDir);

            TextBlock headerText = new TextBlock();

            headerText.Text   = directoryInfo.Name;
            headerText.Margin = new Thickness(3, 0, 0, 0);

            BulletDecorator decorator = new BulletDecorator();

            if (_folderClose != null)
            {
                Image image = new Image();
                image.Source = _folderClose;

                decorator.Bullet = image;
            }
            else
            {
                Ellipse bullet = new Ellipse();
                bullet.Height          = 16;
                bullet.Width           = 16;
                bullet.Fill            = Brushes.Goldenrod;
                bullet.Stroke          = Brushes.DarkGray;
                bullet.StrokeThickness = 1;

                decorator.Bullet = bullet;
            }
            decorator.Margin = new Thickness(0, 0, 10, 0);
            decorator.Child  = headerText;

            TreeViewItem categoryItem = new TreeViewItem();

            categoryItem.Tag        = string.Empty;
            categoryItem.Header     = decorator;
            categoryItem.Margin     = new Thickness(0);
            categoryItem.Padding    = new Thickness(3);
            categoryItem.FontSize   = 14;
            categoryItem.FontWeight = FontWeights.Bold;

            treeView.Items.Add(categoryItem);

            FillTreeView(sourceDir, svgFiles, categoryItem);

            categoryItem.IsExpanded = true;

            treeView.EndInit();

            leftExpander.IsExpanded   = true;
            bottomExpander.IsExpanded = true;
        }
Example #56
0
 protected override bool CanMultiSelect(TreeViewItem item) => false;
Example #57
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            var t = new TreeViewItem();
        }
        private void TreeViewItem_Selected(object sender, RoutedEventArgs e)
        {
            TreeViewItem item = e.Source as TreeViewItem;

            (DataContext as ControlViewModel).RecordObserver.ObserveDirectory((item.Tag as DirectoryInfo).FullName);
        }
Example #59
0
        private void AddNode(ItemCollection itemCollection, Folder folder, Guid siteSettingID)
        {
            if (folder.PublicFolder == true && AdministrativeView == false && folder.Selected == false)
            {
                return;
            }

            TreeViewItem rootNode = new TreeViewItem();

            DockPanel treenodeDock = new DockPanel();

            DockPanel   folderTitleDock = new DockPanel();
            Image       img             = new Image();
            Uri         uri             = new Uri("/Sobiens.Connectors.WPF.Controls;component/Images/" + folder.IconName + ".GIF", UriKind.Relative);
            ImageSource imgSource       = new BitmapImage(uri);

            img.Source = imgSource;

            Label lbl = new Label();

            lbl.Content = folder.Title;

            folderTitleDock.Children.Add(img);
            folderTitleDock.Children.Add(lbl);

            if (ShowCheckBoxes == true)
            {
                CheckBox chkBox = new CheckBox();
                chkBox.Margin     = new Thickness(0, 0, 0, 0);
                chkBox.IsChecked  = false;
                chkBox.Content    = folderTitleDock;
                chkBox.IsChecked  = folder.Selected;
                chkBox.Tag        = folder;
                chkBox.Checked   += new RoutedEventHandler(chkBox_Checked);
                chkBox.Unchecked += new RoutedEventHandler(chkBox_Unchecked);
                treenodeDock.Children.Add(chkBox);
            }
            else
            {
                treenodeDock.Children.Add(folderTitleDock);
            }

            rootNode.Header = treenodeDock;
            //rootNode.Expanded += new RoutedEventHandler(rootNode_Expanded);
            rootNode.Tag = folder;
            itemCollection.Add(rootNode);
            if (folder.Folders.Count == 0)
            {
                AddLoadingNode(rootNode);
            }

            foreach (Folder subfolder in folder.Folders)
            {
                AddNode(rootNode.Items, subfolder, subfolder.SiteSettingID);
            }

            if (folder.Folders.Count > 0)
            {
                rootNode.IsExpanded = true;
            }
        }
Example #60
0
        private static void FillTreeView(TreeViewItem node, JToken tok, Stack <IndexContainer> s)
        {
            TreeViewItem n = node;

            if (tok.Type == JTokenType.Object)
            {
                if (tok.Parent != null)
                {
                    if (tok.Parent.Type == JTokenType.Property)
                    {
                        n = new TreeViewItem()
                        {
                            Header = $"{((JProperty)tok.Parent).Name} <{tok.Type}>"
                        };
                        node.Items.Add(n);
                    }
                    else
                    {
                        n = new TreeViewItem()
                        {
                            Header = $"[{s.Peek().Inc()}] <{tok.Type}>"
                        };
                        node.Items.Add(n);
                    }
                }
                s.Push(new IndexContainer());
                foreach (var p in tok.Children <JProperty>())
                {
                    FillTreeView(n, p.Value, s);
                }
                s.Pop();
            }
            else if (tok.Type == JTokenType.Array)
            {
                if (tok.Parent != null)
                {
                    if (tok.Parent.Type == JTokenType.Property)
                    {
                        n = new TreeViewItem()
                        {
                            Header = $"{((JProperty)tok.Parent).Name} <{tok.Type}>"
                        };
                        node.Items.Add(n);
                    }
                    else
                    {
                        n = new TreeViewItem()
                        {
                            Header = $"[{s.Peek().Inc()}] <{tok.Type}>"
                        };
                        node.Items.Add(n);
                    }
                }
                s.Push(new IndexContainer());
                foreach (var p in tok)
                {
                    FillTreeView(n, p, s);
                }
                s.Pop();
            }
            else
            {
                var value = JsonConvert.SerializeObject(((JValue)tok).Value);

                string name;
                if (tok.Parent.Type == JTokenType.Property)
                {
                    name = $"{((JProperty)tok.Parent).Name} : {value}";
                }
                else
                {
                    name = $"[{s.Peek().Inc()}] : {value}";
                }

                node.Items.Add(new TreeViewItem()
                {
                    Header = name
                });
            }
        }