コード例 #1
0
ファイル: ProjectFolderView.cs プロジェクト: gitMaxim/duality
        public void FlashNode(NodeBase node)
        {
            if (node == null) return;

            this.flashNode = node;
            this.flashDuration = 0.0f;
            this.timerFlashItem.Enabled = true;

            this.folderView.EnsureVisible(this.folderView.FindNode(this.folderModel.GetPath(this.flashNode)));
        }
コード例 #2
0
        protected string GetInsertActionTargetBasePath(NodeBase baseNode)
        {
            string baseTargetPath = (baseNode != null) ? baseNode.NodePath : DualityApp.DataDirectory;
            if (!ContentProvider.IsDefaultContentPath(baseTargetPath))
            {
                if (File.Exists(baseTargetPath)) baseTargetPath = Path.GetDirectoryName(baseTargetPath);
                baseTargetPath = Path.GetFullPath(baseTargetPath);
            }

            return baseTargetPath;
        }
コード例 #3
0
        protected IContentRef CreateResource(Type type, NodeBase baseNode, string desiredName = null)
        {
            if (desiredName == null) desiredName = type.Name;

            string basePath = this.GetInsertActionTargetBasePath(baseNode);
            string nameExt = Resource.GetFileExtByType(type);
            string resPath = PathHelper.GetFreePath(Path.Combine(basePath, desiredName), nameExt);
            resPath = PathHelper.MakeFilePathRelative(resPath);

            Resource resInstance = type.GetTypeInfo().CreateInstanceOf() as Resource;
            resInstance.Save(resPath);

            // Schedule path for later selection - as soon as it actually exists.
            this.folderView.ClearSelection();
            this.ScheduleSelect(resPath, true);

            // Skip the global rename action for this path once, because there clearly aren't any referencs to a new Resource.
            this.SkipGlobalRenameEventFor(resPath);

            return resInstance.GetContentRef();
        }
コード例 #4
0
 public bool SelectNode(NodeBase node, bool select = true, bool exclusive = false)
 {
     if (node == null) return false;
     TreeNodeAdv viewNode = this.folderView.FindNode(this.folderModel.GetPath(node));
     if (viewNode != null)
     {
         if (exclusive) this.folderView.ClearSelection();
         viewNode.IsSelected = select;
         this.folderView.EnsureVisible(viewNode);
         this.folderView.Invalidate();
         return true;
     }
     return false;
 }
コード例 #5
0
        private void timerFlashItem_Tick(object sender, EventArgs e)
        {
            this.flashDuration += (this.timerFlashItem.Interval / 1000.0f);
            this.flashIntensity = 1.0f - (this.flashDuration % 0.33f) / 0.33f;
            this.folderView.Invalidate();

            if (this.flashDuration > 0.66f)
            {
                this.flashNode = null;
                this.flashIntensity = 0.0f;
                this.flashDuration = 0.0f;
                this.timerFlashItem.Enabled = false;
            }
        }
コード例 #6
0
 private void nodeTextBoxName_EditorShowing(object sender, CancelEventArgs e)
 {
     NodeBase node = this.folderView.SelectedNode != null ? this.folderView.SelectedNode.Tag as NodeBase : null;
     if (node == null || node.ReadOnly) e.Cancel = true;
     if (!e.Cancel)
     {
         this.lastEditedNode = node;
         this.folderView.ContextMenuStrip = null;
     }
 }
コード例 #7
0
ファイル: ProjectFolderView.cs プロジェクト: SirePi/duality
        protected IContentRef CreateResource(Type type, NodeBase baseNode, string desiredName = null)
        {
            if (desiredName == null) desiredName = type.Name;

            // Create a new Resource instance of the specified type
            Resource resInstance = type.GetTypeInfo().CreateInstanceOf() as Resource;

            // Gather all available user editing setup actions
            IEnumerable<IEditorAction> setupActions = DualityEditorApp.GetEditorActions(
                resInstance.GetType(),
                new[] { resInstance },
                DualityEditorApp.ActionContextSetupObjectForEditing);

            // Invoke all of them on the new Resource
            foreach (IEditorAction setupAction in setupActions)
            {
                setupAction.Perform(resInstance);
            }

            // Determine the actual name and path of our new Resource
            string basePath = this.GetInsertActionTargetBasePath(baseNode);
            string nameExt = Resource.GetFileExtByType(type);
            string resPath = PathHelper.GetFreePath(Path.Combine(basePath, desiredName), nameExt);
            resPath = PathHelper.MakeFilePathRelative(resPath);

            // Save the new Resource to make it persistent - it will show up in the Project View once it's there
            resInstance.Save(resPath);

            // Schedule path for later selection and rename - as soon as it actually exists.
            this.folderView.ClearSelection();
            this.ScheduleSelect(resPath, true);

            // Skip the global rename action for this path once, because there clearly aren't any referencs to a new Resource.
            this.SkipGlobalRenameEventFor(resPath);

            return resInstance.GetContentRef();
        }