Esempio n. 1
0
 void SearchNodeFind(DataTreeNodeX node, Action <DataTreeNodeX> done)
 {
     foreach (var child in node.Nodes)
     {
         NavigateChild(child as DataTreeNodeX, done, SearchNodeFind);
     }
 }
Esempio n. 2
0
        void SetModel(IDataModel value)
        {
            if (model != null)
            {
                model.Node                        = null;
                model.PropertyChanged            -= OnModelPropertyChanged;
                model.ExpandRequested            -= ExpandRequested;
                model.CollapseRequested          -= CollapseRequested;
                model.Children.CollectionChanged -= OnChildrenUpdated;
            }
            model      = value;
            model.Node = this;
            model.Refresh(true);

            model.PropertyChanged            += OnModelPropertyChanged;
            model.ExpandRequested            += ExpandRequested;
            model.CollapseRequested          += CollapseRequested;
            model.Children.CollectionChanged += OnChildrenUpdated;

            Text      = model.Text;
            ForeColor = model.ForeColor;
            foreach (var child in model.Children)
            {
                var childNode = new DataTreeNodeX(child);
                Nodes.Add(childNode);
            }
            ImageIndex = model.HasIcon ? 0 : -1;

            if (TreeView != null)
            {
                TreeView.Invalidate();
            }
        }
Esempio n. 3
0
        void NavigateChild(DataTreeNodeX node, Action <DataTreeNodeX> done, Action <DataTreeNodeX, Action <DataTreeNodeX> > search)
        {
            if (node == null || node.TreeView == null)
            {
                return;
            }

            Func <object, NavigationState> predicate;

            if (!navPath.TryGetValue(node.Model.GetType(), out predicate))
            {
                return;
            }

            switch (predicate(node.Model))
            {
            case NavigationState.Next:
                return;

            case NavigationState.In:
                break;

            case NavigationState.Done:
                node.TreeView.Invoke(new Action(() => {
                    done(node);
                }));
                return;
            }

            if (node.Model is LazyModel)
            {
                var op = ((LazyModel)node.Model).Load();
                if (op != null)
                {
                    op.Completed += (sender, e) => search(node, done);
                    op.Begin();
                }
                else
                {
                    search(node, done);
                }
            }
            else
            {
                search(node, done);
            }
        }
Esempio n. 4
0
        void SearchNodeGoto(DataTreeNodeX node, Action <DataTreeNodeX> done)
        {
            if (node.TreeView != null)
            {
                if (node.TreeView.InvokeRequired)
                {
                    node.TreeView.Invoke(new Action(() => node.Expand()));
                }
                else
                {
                    node.Expand();
                }
            }

            foreach (var child in node.Nodes)
            {
                NavigateChild(child as DataTreeNodeX, done, SearchNodeGoto);
            }
        }
Esempio n. 5
0
		void SetModel(IDataModel value) {
			if (model != null) {
				model.Node = null;
				model.PropertyChanged -= OnModelPropertyChanged;
				model.ExpandRequested -= ExpandRequested;
				model.CollapseRequested -= CollapseRequested;
				model.Children.CollectionChanged -= OnChildrenUpdated;
			}
			model = value;
			model.Node = this;
			model.Refresh(true);

			model.PropertyChanged += OnModelPropertyChanged;
			model.ExpandRequested += ExpandRequested;
			model.CollapseRequested += CollapseRequested;
			model.Children.CollectionChanged += OnChildrenUpdated;

			Text = model.Text;
			ForeColor = model.ForeColor;
			foreach (var child in model.Children) {
				var childNode = new DataTreeNodeX(child);
				Nodes.Add(childNode);
			}
			ImageIndex = model.HasIcon ? 0 : -1;

			if (TreeView != null)
				TreeView.Invalidate();
		}
Esempio n. 6
0
		void UpdateViewContainer(DataTreeNodeX node, IView view, DockContent container) {
			if (string.IsNullOrEmpty(view.ViewControl.Text))
				container.Text = node.Text;
			else
				container.Text = view.ViewControl.Text;

			if (view.Icon != null)
				container.Icon = view.Icon;
			else {
				var bmp = new Bitmap(16, 16);
				using (var g = Graphics.FromImage(bmp))
					node.DrawIcon(g, new Rectangle(0, 0, 16, 16));
				container.Icon = IconCreator.CreateIcon(bmp, 16);
			}
		}