示例#1
0
 /// <summary>
 /// Refreshes project tree.
 /// </summary>
 public void Refresh()
 {
     if (TreeView != null)
     {
         TreeControlAdapter.Refresh(TreeView.Root);
     }
 }
示例#2
0
 protected override void Configure(out Sce.Atf.Controls.TreeControl treeControl,
                                   out TreeControlAdapter treeControlAdapter)
 {
     base.Configure(out treeControl, out treeControlAdapter);
     treeControl.ShowRoot  = true;
     treeControl.AllowDrop = true;
 }
示例#3
0
        private void Bind(ITypeDescriptorContext context, ISelectionContext selectionContext, object value, Func <object, ItemInfo, bool> getItemInfo)
        {
            splitContainer1.SuspendLayout();

            m_treeControl               = new TreeControl(TreeControl.Style.SimpleTree);
            m_treeControl.Dock          = DockStyle.Fill;
            m_treeControl.SelectionMode = SelectionMode.One;
            m_treeControl.ImageList     = ResourceUtil.GetImageList16();
            m_treeControl.Location      = new Point(comboBox1.Location.X, comboBox1.Location.Y + 2 * FontHeight);
            m_treeControl.Width         = upButton.Location.X - m_treeControl.Location.X - Margin.Right - Margin.Left;
            m_treeControl.Anchor        = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
            m_treeControl.Height        = splitContainer1.Panel1.Height - m_treeControl.Location.Y - (Margin.Bottom + Margin.Top);
            splitContainer1.Panel1.Controls.Add(m_treeControl);

            m_propertyGrid = new PropertyGrid();
            m_defaultContext.SelectionContext = selectionContext;
            m_propertyGrid.Bind(m_defaultContext);
            m_propertyGrid.Dock = DockStyle.Fill;
            splitContainer1.Panel2.Controls.Add(m_propertyGrid);

            splitContainer1.ResumeLayout();

            m_rootValue                            = value;
            m_collectionTreeView                   = new TreeView(context, value);
            m_collectionTreeView.GetItemInfo       = getItemInfo;
            m_treeControlAdapter                   = new TreeControlAdapter(m_treeControl);
            m_collectionTreeView.SelectionChanged += collectionTreeView_SelectionChanged;
            m_treeControl.ShowRoot                 = false;
            m_treeControlAdapter.TreeView          = m_collectionTreeView;
            m_context = context;
            UpdateAvailaibleTypes(new Path <object>(context.Instance));
        }
示例#4
0
        // Load hierarchical data from XML and display it in a TreeListControl
        void LoadHierarchicalXmlData()
        {
            var treeListControl = new TreeListControl();

            treeListControl.Dock            = DockStyle.Fill;
            treeListControl.ShowRoot        = false;
            treeListControl.LabelEditMode   = TreeControl.LabelEditModes.EditOnF2 | TreeControl.LabelEditModes.EditOnClick;
            treeListControl.NodeDataEdited += treeListControl_NodeDataEdited;
            Controls.Add(treeListControl);

            Assembly assembly    = Assembly.GetExecutingAssembly();
            string   startupPath = Path.GetDirectoryName(new Uri(assembly.GetName().CodeBase).LocalPath);
            var      xmlPath     = Path.Combine(startupPath, "CoolSUVs.xml");

            var treeView           = new TreeView(xmlPath, new DataEditorTheme(treeListControl.Font));
            var treeControlAdapter = new TreeControlAdapter(treeListControl);

            treeControlAdapter.TreeView = treeView;

            treeListControl.ItemRenderer = new TreeListItemRenderer(treeView);

            treeListControl.Columns.Add(new TreeListView.Column("MPG", 80));
            treeListControl.Columns.Add(new TreeListView.Column("Weight", 80));
            treeListControl.Columns.Add(new TreeListView.Column("Color", 80));
            treeListControl.Columns.Add(new TreeListView.Column("MSRP", 80));
            treeListControl.ExpandAll();
        }
示例#5
0
        protected override void Configure(out TreeControl treeControl, out TreeControlAdapter treeControlAdapter)
        {
            base.Configure(out treeControl, out treeControlAdapter);

            treeControl.ShowRoot      = false; // hide root node, because it's the project
            treeControl.Text          = Localizer.Localize("No Addon Loaded, Can't display Units");
            treeControl.Dock          = DockStyle.Fill;
            treeControl.AllowDrop     = true;
            treeControl.SelectionMode = SelectionMode.One;
        }
        protected override void Configure(out TreeControl treeControl, out TreeControlAdapter treeControlAdapter)
        {
            base.Configure(out treeControl, out treeControlAdapter);

            treeControl.ShowRoot      = false; // hide root node, because it's the project
            treeControl.Text          = Localizer.Localize("Dota 2 directory not set");
            treeControl.Dock          = DockStyle.Fill;
            treeControl.AllowDrop     = true;
            treeControl.SelectionMode = SelectionMode.One;
        }
示例#7
0
        /// <summary>
        /// Create and configure TreeControl</summary>
        /// <param name="treeControl">New TreeControl</param>
        /// <param name="treeControlAdapter">Adapter for TreeControl</param>
        protected override void Configure(out TreeControl treeControl, out TreeControlAdapter treeControlAdapter)
        {
            base.Configure(out treeControl, out treeControlAdapter);

            treeControl.ShowRoot = false; // UI node can't really be edited, so hide it
            treeControl.Text     = ("Add packages to the UI." + Environment.NewLine +
                                    "Add forms, shaders, textures, and fonts to packages." + Environment.NewLine +
                                    "Add sprites or text items to forms or sprites." + Environment.NewLine +
                                    "Drag shaders, textures, and fonts onto the reference slots of sprites and text items.").Localize();
            treeControl.AllowDrop     = true;
            treeControl.SelectionMode = SelectionMode.MultiExtended;
        }
示例#8
0
        public FolderViewer(MainForm mainForm, FileViewer fileViewer)
        {
            m_mainForm   = mainForm;
            m_fileViewer = fileViewer;

            m_treeControl               = new TreeControl();
            m_treeControl.Text          = "Folder Viewer";
            m_treeControl.ImageList     = ResourceUtil.GetImageList16();
            m_treeControl.SelectionMode = SelectionMode.One;
            m_treeControl.Dock          = DockStyle.Fill;
            m_treeControl.Width         = 256;

            m_treeControlAdapter             = new TreeControlAdapter(m_treeControl);
            m_fileTreeView                   = new FileTreeView();
            m_fileTreeView.SelectionChanged += new EventHandler(fileTreeView_SelectionChanged);
            m_treeControlAdapter.TreeView    = m_fileTreeView;
        }
        public DomExplorer(IControlHostService controlHostService)
        {
            m_controlHostService = controlHostService;

            m_treeControl                      = new TreeControl();
            m_treeControl.Dock                 = DockStyle.Fill;
            m_treeControl.AllowDrop            = true;
            m_treeControl.SelectionMode        = SelectionMode.MultiExtended;
            m_treeControl.ImageList            = ResourceUtil.GetImageList16();
            m_treeControl.NodeSelectedChanged += treeControl_NodeSelectedChanged;

            m_treeControlAdapter = new TreeControlAdapter(m_treeControl);
            m_treeView           = new TreeView();

            m_propertyGrid      = new Sce.Atf.Controls.PropertyEditing.PropertyGrid();
            m_propertyGrid.Dock = DockStyle.Fill;

            m_splitContainer      = new SplitContainer();
            m_splitContainer.Text = "Dom Explorer";
            m_splitContainer.Panel1.Controls.Add(m_treeControl);
            m_splitContainer.Panel2.Controls.Add(m_propertyGrid);
        }
示例#10
0
        void ICommandClient.DoCommand(object commandTag)
        {
            var target = TreeControlAdapter.LastHit;

            // If the command isn't one of our immediate commands, it
            // might belong to one of our sub providers.
            // Try to cast the targetted node to a command client and
            // execute from there
            if (!(commandTag is Command))
            {
                var targetClient = target.As <ICommandClient>();
                if (targetClient != null)
                {
                    targetClient.DoCommand(commandTag);
                }
                return;
            }

            IDocument gameDocument = null;
            string    filePath     = null;

            IGame game = target.As <IGame>();

            if (game == null)
            {
                GameReference gameRef = target.As <GameReference>();
                if (gameRef != null)
                {
                    game = gameRef.Target;
                }
            }

            if (game != null)
            {
                gameDocument = game.As <IDocument>();
            }

            switch ((Command)commandTag)
            {
            case Command.CreateNewSubGame:
                if (gameDocument != null)
                {
                    filePath = Util.GetFilePath(m_fileFilter,
                                                System.IO.Path.GetDirectoryName(gameDocument.Uri.LocalPath), true);
                    if (!string.IsNullOrEmpty(filePath))
                    {
                        try
                        {
                            if (!m_gameEditor.Info.IsCompatiblePath(filePath))
                            {
                                throw new Exception("Incompatible file type " + filePath);
                            }

                            Uri ur = new Uri(filePath);
                            if (m_gameDocumentRegistry.FindDocument(ur) != null)
                            {
                                throw new Exception(filePath + " is already open");
                            }
                            GameDocument subGame = GameDocument.OpenOrCreate(ur, m_schemaLoader);
                            subGame.Dirty = true;
                            GameReference gameRef = GameReference.CreateNew(subGame);

                            // try all implementation of IHierarchical until one works
                            var parent = game.AsAll <IHierarchical>();
                            foreach (var p in parent)
                            {
                                if (p.AddChild(gameRef))
                                {
                                    break;
                                }
                            }

                            // because we performing this operation outside of TransactionContext
                            // we must set Document Dirty flag.
                            gameDocument.Dirty = true;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(m_mainWindow.DialogOwner, ex.Message);
                        }
                    }
                }
                break;

            case Command.AddSubGame:
                if (gameDocument != null)
                {
                    filePath = Util.GetFilePath(m_fileFilter,
                                                System.IO.Path.GetDirectoryName(gameDocument.Uri.LocalPath),
                                                false);

                    if (!string.IsNullOrEmpty(filePath))
                    {
                        try
                        {
                            if (!m_gameEditor.Info.IsCompatiblePath(filePath))
                            {
                                throw new Exception("Incompatible file type " + filePath);
                            }

                            Uri ur = new Uri(filePath);
                            if (m_gameDocumentRegistry.FindDocument(ur) != null)
                            {
                                throw new Exception(filePath + " is already open");
                            }

                            GameReference gameRef = GameReference.CreateNew(ur);
                            gameRef.Resolve();

                            // try all implementation of IHierarchical until one works
                            var parent = game.AsAll <IHierarchical>();
                            foreach (var p in parent)
                            {
                                if (p.AddChild(gameRef))
                                {
                                    break;
                                }
                            }

                            // because we performing this operation outside of TransactionContext
                            // we must set Document Dirty flag.
                            gameDocument.Dirty = true;
                            RefreshLayerContext();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(m_mainWindow.DialogOwner, ex.Message);
                        }
                    }
                }
                break;

            case Command.Exclude:
            {
                GameReference gameRef = target.As <GameReference>();
                if (gameRef == null)
                {
                    break;
                }

                gameDocument = gameRef.DomNode.Parent.Cast <IDocument>();
                IGameDocument subDoc = gameRef.Target.Cast <IGameDocument>();

                bool exclue = true;
                bool save   = false;
                if (subDoc.Dirty)
                {
                    string       msg       = "Save changes\r\n" + subDoc.Uri.LocalPath;
                    DialogResult dlgResult =
                        MessageBox.Show(m_mainWindow.DialogOwner, msg, m_mainWindow.Text
                                        , MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

                    save   = dlgResult == DialogResult.Yes;
                    exclue = dlgResult != DialogResult.Cancel;
                }

                if (save)
                {
                    subDoc.Save(subDoc.Uri, m_schemaLoader);
                }

                if (exclue)
                {
                    gameRef.DomNode.RemoveFromParent();
                    // because we performing this operation outside of TransactionContext
                    // we must set Document Dirty flag.
                    gameDocument.Dirty = true;
                    UpdateGameObjectReferences();
                    RefreshLayerContext();
                }
            }
            break;

            case Command.Resolve:
            {
                bool          madeChange = false;
                GameReference gameRef    = target.As <GameReference>();
                if (gameRef != null)
                {
                    gameRef.Resolve();
                    madeChange = true;
                }
                else
                {
                    var resolveable = target.As <IResolveable>();
                    if (resolveable != null && !resolveable.IsResolved())
                    {
                        resolveable.Resolve();
                        madeChange = true;
                    }
                }

                if (madeChange)
                {
                    TreeControlAdapter.Refresh(target);
                    RefreshLayerContext();
                }
            }
            break;

            case Command.Unresolve:
            {
                try
                {
                    GameReference gameRef = target.As <GameReference>();
                    if (gameRef != null)
                    {
                        IGameDocument subDoc    = gameRef.Target.Cast <IGameDocument>();
                        bool          unresolve = true;
                        bool          save      = false;
                        if (subDoc.Dirty)
                        {
                            string       msg       = "Save changes\r\n" + subDoc.Uri.LocalPath;
                            DialogResult dlgResult =
                                MessageBox.Show(m_mainWindow.DialogOwner, msg, m_mainWindow.Text
                                                , MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

                            save      = dlgResult == DialogResult.Yes;
                            unresolve = dlgResult != DialogResult.Cancel;
                        }
                        //cando = gameRef != null && gameRef.Target != null;
                        if (save)
                        {
                            subDoc.Save(subDoc.Uri, m_schemaLoader);
                        }
                        if (unresolve)
                        {
                            gameRef.Unresolve();
                            UpdateGameObjectReferences();
                            RefreshLayerContext();
                        }
                        TreeControlAdapter.Refresh(gameRef);
                    }
                    else
                    {
                        var resolveable = target.As <IResolveable>();
                        if (resolveable != null && resolveable.IsResolved())
                        {
                            resolveable.Unresolve();
                            RefreshLayerContext();
                            TreeControlAdapter.Refresh(target);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(m_mainWindow.DialogOwner, ex.Message);
                }
            }
            break;

            case Command.CreateNewResolveable:
            {
                try
                {
                    var resolveable = target.As <IResolveable>();
                    if (resolveable != null && !resolveable.IsResolved() && resolveable.CanCreateNew())
                    {
                        resolveable.CreateAndResolve();
                        RefreshLayerContext();
                        TreeControlAdapter.Refresh(target);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(m_mainWindow.DialogOwner, ex.Message);
                }
            }
            break;

            case Command.SaveSubDoc:
            {
                try
                {
                    var resolveable = target.As <IResolveable>();
                    if (resolveable != null && resolveable.CanSave())
                    {
                        resolveable.Save(m_schemaLoader);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(m_mainWindow.DialogOwner, ex.Message);
                }
            }
            break;

            default:
                throw new ArgumentOutOfRangeException("commandTag");
            }
            m_designView.InvalidateViews();
            Refresh();
        }
示例#11
0
        /// <summary>
        /// Initializes the MEF component</summary>
        public void Initialize()
        {
            // tree control
            m_treeControl = new TreeControl();
            m_treeControl.SelectionMode  = SelectionMode.One;
            m_treeControl.Dock           = DockStyle.Fill;
            m_treeControl.AllowDrop      = true;
            m_treeControl.ImageList      = ResourceUtil.GetImageList16();
            m_treeControl.StateImageList = ResourceUtil.GetImageList16();
            m_treeControl.MouseUp       += treeControl_MouseUp;
            m_treeControlAdapter         = new TreeControlAdapter(m_treeControl);

            // list view
            m_listView             = new CustomListView();
            m_listView.View        = View.Details;
            m_listView.Dock        = DockStyle.Fill;
            m_listView.AllowDrop   = true;
            m_listView.LabelEdit   = false;
            m_listView.MouseDown  += ThumbnailControl_MouseDown;
            m_listView.MouseMove  += ThumbnailControl_MouseMove;
            m_listView.MouseUp    += ThumbnailControl_MouseUp;
            m_listView.MouseLeave += ThumbnailControl_MouseLeave;


            m_listViewAdapter = new ListViewAdapter(m_listView);

            // thumbnail control
            m_thumbnailControl                    = new ThumbnailControl();
            m_thumbnailControl.Dock               = DockStyle.Fill;
            m_thumbnailControl.AllowDrop          = true;
            m_thumbnailControl.BackColor          = SystemColors.Window;
            m_thumbnailControl.Selection.Changed += thumbnailControl_SelectionChanged;
            m_thumbnailControl.MouseDown         += ThumbnailControl_MouseDown;
            m_thumbnailControl.MouseMove         += ThumbnailControl_MouseMove;
            m_thumbnailControl.MouseUp           += ThumbnailControl_MouseUp;
            m_thumbnailControl.MouseLeave        += ThumbnailControl_MouseLeave;


            // split
            m_splitContainer             = new SplitContainer();
            m_splitContainer.Name        = "Resources".Localize();
            m_splitContainer.Orientation = Orientation.Vertical;
            m_splitContainer.Panel1.Controls.Add(m_treeControl);
            m_splitContainer.Panel2.Controls.Add(m_thumbnailControl);
            m_splitContainer.Panel2.Controls.Add(m_listView);
            m_splitContainer.SplitterDistance = 10;
            m_listView.Hide();

            Image resourceImage = ResourceUtil.GetImage16(Sce.Atf.Resources.ResourceImage);

            // on initialization, register our tree control with the hosting service
            m_controlHostService.RegisterControl(
                m_splitContainer,
                new ControlInfo(
                    "Resources".Localize(),
                    "Lists available resources".Localize(),
                    StandardControlGroup.Left,
                    resourceImage),
                this);


            m_thumbnailService.ThumbnailReady += ThumbnailManager_ThumbnailReady;
            Application.ApplicationExit       += delegate
            {
                foreach (var item in m_thumbnailControl.Items)
                {
                    if (item.Image != null)
                    {
                        item.Image.Dispose();
                    }
                }
                m_thumbnailControl.Items.Clear();
            };

            m_mainForm.Loaded += delegate
            {
                m_splitContainer.SplitterDistance = m_splitterDistance;
            };

            RegisterCommands();
            RegisterSettings();
        }
示例#12
0
        void ICommandClient.DoCommand(object commandTag)
        {
            IGame game = TreeControlAdapter.LastHit.As <IGame>();

            if (game == null)
            {
                GameReference gameRef = TreeControlAdapter.LastHit.As <GameReference>();
                game = gameRef.Target;
            }
            IDocument gameDocument = game.As <IDocument>();
            string    filePath     = null;

            switch ((Command)commandTag)
            {
            case Command.CreateNewSubGame:
                filePath = Util.GetFilePath(m_fileFilter,
                                            System.IO.Path.GetDirectoryName(gameDocument.Uri.LocalPath), true);
                if (!string.IsNullOrEmpty(filePath))
                {
                    try
                    {
                        if (!m_gameEditor.Info.IsCompatiblePath(filePath))
                        {
                            throw new Exception("Incompatible file type " + filePath);
                        }

                        Uri ur = new Uri(filePath);
                        if (m_gameDocumentRegistry.FindDocument(ur) != null)
                        {
                            throw new Exception(filePath + " is already open");
                        }
                        GameDocument subGame = GameDocument.OpenOrCreate(ur, m_schemaLoader);
                        subGame.Dirty = true;
                        GameReference gameRef = GameReference.CreateNew(subGame);
                        IHierarchical parent  = game.As <IHierarchical>();
                        parent.AddChild(gameRef);
                        // because we performing this operation outside of TransactionContext
                        // we must set Document Dirty flag.
                        gameDocument.Dirty = true;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(m_mainWindow.DialogOwner, ex.Message);
                    }
                }
                break;

            case Command.AddSubGame:

                filePath = Util.GetFilePath(m_fileFilter,
                                            System.IO.Path.GetDirectoryName(gameDocument.Uri.LocalPath),
                                            false);

                if (!string.IsNullOrEmpty(filePath))
                {
                    try
                    {
                        if (!m_gameEditor.Info.IsCompatiblePath(filePath))
                        {
                            throw new Exception("Incompatible file type " + filePath);
                        }

                        Uri ur = new Uri(filePath);
                        if (m_gameDocumentRegistry.FindDocument(ur) != null)
                        {
                            throw new Exception(filePath + " is already open");
                        }

                        GameReference gameRef = GameReference.CreateNew(ur);
                        gameRef.Resolve();
                        IHierarchical parent = game.As <IHierarchical>();
                        parent.AddChild(gameRef);

                        // because we performing this operation outside of TransactionContext
                        // we must set Document Dirty flag.
                        gameDocument.Dirty = true;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(m_mainWindow.DialogOwner, ex.Message);
                    }
                }
                break;

            case Command.Exclude:
            {
                GameReference gameRef = TreeControlAdapter.LastHit.As <GameReference>();
                gameDocument = gameRef.DomNode.Parent.Cast <IDocument>();
                GameDocument subDoc = gameRef.Target.Cast <GameDocument>();

                bool exclue = true;
                bool save   = false;
                if (subDoc.Dirty)
                {
                    string       msg       = "Save changes\r\n" + subDoc.Uri.LocalPath;
                    DialogResult dlgResult =
                        MessageBox.Show(m_mainWindow.DialogOwner, msg, m_mainWindow.Text
                                        , MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

                    save   = dlgResult == DialogResult.Yes;
                    exclue = dlgResult != DialogResult.Cancel;
                }

                if (save)
                {
                    subDoc.Save(subDoc.Uri, m_schemaLoader);
                }

                if (exclue)
                {
                    gameRef.DomNode.RemoveFromParent();
                    // because we performing this operation outside of TransactionContext
                    // we must set Document Dirty flag.
                    gameDocument.Dirty = true;
                }
            }
            break;

            case Command.Resolve:
            {
                GameReference gameRef = TreeControlAdapter.LastHit.As <GameReference>();
                gameRef.Resolve();
                TreeControlAdapter.Refresh(gameRef);
            }
            break;

            case Command.Unresolve:
            {
                try
                {
                    GameReference gameRef   = TreeControlAdapter.LastHit.As <GameReference>();
                    GameDocument  subDoc    = gameRef.Target.Cast <GameDocument>();
                    bool          unresolve = true;
                    bool          save      = false;
                    if (subDoc.Dirty)
                    {
                        string       msg       = "Save changes\r\n" + subDoc.Uri.LocalPath;
                        DialogResult dlgResult =
                            MessageBox.Show(m_mainWindow.DialogOwner, msg, m_mainWindow.Text
                                            , MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

                        save      = dlgResult == DialogResult.Yes;
                        unresolve = dlgResult != DialogResult.Cancel;
                    }
                    //cando = gameRef != null && gameRef.Target != null;
                    if (save)
                    {
                        subDoc.Save(subDoc.Uri, m_schemaLoader);
                    }
                    if (unresolve)
                    {
                        gameRef.Unresolve();
                    }
                    TreeControlAdapter.Refresh(gameRef);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(m_mainWindow.DialogOwner, ex.Message);
                }
            }
            break;

            default:
                throw new ArgumentOutOfRangeException("commandTag");
            }
            m_designView.InvalidateViews();
            Refresh();
        }