예제 #1
0
        void Core.IBuild.Build()
        {
            if (Ctrl.Current.Entries.Count > 1)
            {
                // 複数選択の場合
                treeView.BeginUpdate();
                _selectedNodes.Clear();
                Core.IEntry[] entries = new Core.IEntry[Ctrl.Current.Entries.Count];
                Ctrl.Current.Entries.CopyTo(entries, 0);
                foreach (Core.IEntry entry in entries)
                {
                    TreeNode node = TreeNodeBuilder.Find(this.Root, entry.Path);
                    if (node != null)
                    {
                        _selectedNodes.Add(node);
                    }
                }
                treeView.EndUpdate();
            }
            else
            {
                // 単数選択または選択無しの場合
                TreeNode    selected1 = null;
                Core.IEntry selEntry  = Core.Document.Current.SelectedEntry;
                if (selEntry != null)
                {
                    selected1 = TreeNodeBuilder.Find(this.Root, selEntry.Path);
                }

                TreeNode selected2 = _selectedNodes.Value;
                while (selected2 != null)
                {
                    if (selected2.Tag is TreeNodeBuilder)
                    {
                        break;
                    }
                    selected2 = selected2.Parent;
                }

                if (selected1 != selected2)
                {
                    if (selected1 != null)
                    {
                        _selectedNodes.Value = selected1;
                        selected1.EnsureVisible();
                    }
                    else
                    {
                        _selectedNodes.Value = null;
                        SelectNode(null, false);
                    }
                }
            }
        }
예제 #2
0
        private void treeView_AfterExpand(object sender, TreeViewEventArgs e)
        {
            TreeNodeBuilder builder = e.Node.Tag as TreeNodeBuilder;

            if (builder != null)
            {
                treeView.BeginUpdate();
                Core.Builder.Build(builder);
                treeView.EndUpdate();
            }
        }
예제 #3
0
        void SelectNode(TreeNode target, bool append)
        {
            // Ctrl.Current.Self の設定
            Ctrl.Current.Self = (target == null) ? null : target.Tag;
            if (Ctrl.Current.Self is TreeNodeBuilder)
            {
                Ctrl.Current.Self = ((TreeNodeBuilder)Ctrl.Current.Self).Tag;
            }

            // プロパティグリッドの設定
            this.propertyGrid.SelectedObject = Ctrl.Current.Self;

            // 選択された TreeNodeBuilder の探索
            TreeNodeBuilder selected = null;

            for (TreeNode node = target; node != null; node = node.Parent)
            {
                selected = node.Tag as TreeNodeBuilder;
                if (selected != null)
                {
                    break;
                }
            }

            // SelectedEntries の設定
            Core.Document doc = Core.Document.Current;
            if (append)
            {
                Core.IEntry entry = (selected == null) ? null : selected.Tag as Core.IEntry;
                if (entry == null)
                {
                    doc.SelectedEntry = null;
                }
                else
                {
                    doc.SelectedEntries.Add(entry);
                }
                Ctrl.Current.Driver.Abort(); // 現在のオペレーションをアボート
            }
            else
            {
                Core.IEntry before = doc.SelectedEntry;
                doc.SelectedEntry =
                    (selected == null) ? null : selected.Tag as Core.IEntry;
                if (before != doc.SelectedEntry)
                {
                    // 選択エントリが変わったときは、現在のオペレーションをアボート
                    Ctrl.Current.Driver.Abort();
                }
            }

            _docviews.Invalidate();
        }
예제 #4
0
        public static TreeNode Find(TreeNodeBuilder root, int[] path)
        {
            TreeNode        found = null;
            TreeNodeBuilder it    = root;

            foreach (int id in path)
            {
                found = it.Find(id);
                if (found == null)
                {
                    return(null);
                }
                it = (TreeNodeBuilder)found.Tag;
            }
            return(found);
        }
예제 #5
0
 public static TreeNode Find( TreeNodeBuilder root, int[] path )
 {
     TreeNode found = null;
       TreeNodeBuilder it = root;
       foreach ( int id in path ) {
     found = it.Find( id );
     if ( found == null ) return null;
     it = (TreeNodeBuilder)found.Tag;
       }
       return found;
 }
예제 #6
0
        public void Build()
        {
            Core.IBreath src = this.Tag;
            _node.Text = src.ToString();
            Core.IEntry entry = src as Core.IEntry;

            // entry
            if (entry != null)
            {
                ISceneDecorator deco  = DecoratorFactory.GetEntryDecorator(entry);
                string          image = (entry.Enabled && entry.IsVisible()) ? "entry.png" : "entry_gray.png";
                _node.ImageKey         = image;
                _node.SelectedImageKey = image;
            }

            // scene
            if (entry != null)
            {
                TreeNode node = this.Find("scene");
                if (node == null)
                {
                    node = _node.Nodes.Insert(
                        0, "scene", "描画情報", "scene.png", "scene.png"
                        );
                }
                ISceneDecorator elm = entry.GetElement <ISceneDecorator>();
                node.Tag = elm;
                node.Nodes.Clear();
                string icon = "decoration.png";
                foreach (IDecoration d in elm.Decorations)
                {
                    string   name = d.GetType().Name;
                    TreeNode dec  = node.Nodes.Add(name, name, icon, icon);
                    dec.Tag = d;
                }
            }

            // entity
            if (entry != null)
            {
                TreeNode node = this.Find("entity");
                if (entry.Entity != null)
                {
                    string name = entry.Entity.GetType().Name;
                    if (node == null)
                    {
                        node = _node.Nodes.Insert(
                            1, "entity", name, "entity.png", "entity.png");
                    }
                    else if (node.Text != name)
                    {
                        node.Text = name;
                    }
                    node.Tag = entry.Entity;
                }
                else if (node != null)
                {
                    _node.Nodes.Remove(node);
                }
            }

            // 不要な TreeNode を削除
            {
                List <TreeNode> removing = new List <TreeNode>();
                foreach (TreeNode node in _node.Nodes)
                {
                    if (node.Name == "scene")
                    {
                        continue;
                    }
                    if (node.Name == "entity")
                    {
                        continue;
                    }
                    TreeNodeBuilder tnb = (TreeNodeBuilder)node.Tag;
                    Core.IEntry     e   = tnb.Tag as Core.IEntry;
                    if (e == null || !this.SubEntries.Contains(e.ID))
                    {
                        removing.Add(node);
                    }
                }
                foreach (TreeNode node in removing)
                {
                    _node.Nodes.Remove(node);
                }
            }
        }