예제 #1
0
        private SourceFileEditor OpenTextEditor(string Path)
        {
            bool exist = false;

            foreach (DockContent item in DockPanel.Contents)
            {
                if (item.GetType() == typeof(PKStudio.Forms.Editors.SourceFileEditor))
                {
                    PKStudio.Forms.Editors.SourceFileEditor editor = (PKStudio.Forms.Editors.SourceFileEditor)item;

                    if (editor.EditingFilePath == Path)
                    {
                        editor.Show();
                        return(editor);
                    }
                }
            }

            if (!exist)
            {
                SFE = new Forms.Editors.SourceFileEditor();
                SFE.OpenContainingFolderEvent += new EventHandler <Forms.BaseForms.PathEventArgs>(OpenContainingFolderEvent);
                if (SFE.SetFile(Path))
                {
                    SFE.Show(DockPanel, DockState.Document);
                }
                return(SFE);
            }
            return(null);
        }
예제 #2
0
        /// <summary>
        /// Ru: Открывает редактор для объекта. Если такой уже открыт, то показывает его
        /// En: If object editor has been shown, opens it. I it has not been shown , creates it
        /// </summary>
        /// <param name="obj"></param>
        public void ShowEditor(object obj)
        {
            IEventComponent component = null;

            if (obj is LibraryWrapper)
            {
                LibraryWrapper library = (LibraryWrapper)obj;
                component = ShowLibraryEditorByGuid(library.Guid);
            }
            else if (obj is FeatureWrapper)
            {
                FeatureWrapper feature = (FeatureWrapper)obj;
                component = ShowFeatureEditorByGuid(feature.Guid);
            }
            else if (obj is LibraryCategoryWrapper)
            {
                LibraryCategoryWrapper libcat = (LibraryCategoryWrapper)obj;
                component = ShowLibraryCategoryEditorByGuid(libcat.Guid);
            }
            else if (obj is ComponentWrapper)
            {
                ComponentWrapper comp = (ComponentWrapper)obj;
                switch (comp.ComponentType)
                {
                case ComponentTypeWrapper.Library:
                    component = ShowLibraryEditorByGuid(comp.Guid);
                    break;

                case ComponentTypeWrapper.Feature:
                    component = ShowFeatureEditorByGuid(comp.Guid);
                    break;

                case ComponentTypeWrapper.LibraryCategory:
                    component = ShowLibraryCategoryEditorByGuid(comp.Guid);
                    break;

                default:
                    break;
                }
            }
            else if (obj is BuildFileWrapper)//En: Need to open file editor Ru: Нужно отрыть редактор файлов
            {
                BuildFileWrapper file = (BuildFileWrapper)obj;
                if (!string.IsNullOrEmpty(file.FullPath) && (File.Exists(file.FullPath)))
                {
                    OpenTextEditor(file.FullPath);
                }
            }
            else if (obj is EditFileDescriptor)
            {
                EditFileDescriptor file   = (EditFileDescriptor)obj;
                SourceFileEditor   editor = OpenTextEditor(file.Path);
                if (editor != null)
                {
                    editor.GotoLine(file.Line - 1);
                }
            }
            OnShowEditor(component);
        }
예제 #3
0
        /// <summary>
        /// Ru: Загружает формы для редактирования из списка
        /// En: Loads edit forms from list from file
        /// </summary>
        public void LoadEditorFormsState()
        {
            //Загрузка редакторов
            OpenedDocumentsList modlist = new OpenedDocumentsList();

            if (File.Exists(Application.StartupPath + "\\" + FileName))
            {
                modlist = modlist.Deserialize(Application.StartupPath + "\\" + FileName);
                foreach (string path in modlist.Files)
                {
                    SFE = new Forms.Editors.SourceFileEditor();
                    SFE.OpenContainingFolderEvent += new EventHandler <Forms.BaseForms.PathEventArgs>(OpenContainingFolderEvent);
                    SFE.SetFile(path);
                    SFE.Show(DockPanel, DockState.Document);
                }
                foreach (ComponentWrapper comp in modlist.Components)
                {
                    this.ShowEditor(comp);
                }
            }
        }