PKStudio.Helpers.EditorsFormsController.ShowEditor C# (CSharp) Method

ShowEditor() public method

Ru: Открывает редактор для объекта. Если такой уже открыт, то показывает его En: If object editor has been shown, opens it. I it has not been shown , creates it
public ShowEditor ( object obj ) : void
obj object
return void
        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);
        }

Usage Example

Esempio n. 1
0
        void OnEditEvent(object sender, PKStudio.Forms.BaseForms.ObjectEventArgs e)
        {
            if (e.Object is ComponentWrapper)
            {
                ComponentWrapper comp = (ComponentWrapper)e.Object;
                OpenComponentEditor(comp);
            }
            else if (e.Object is PortingKitWrapper.SearchResultsHolder.SearchComponentDescriptor)
            {
                PortingKitWrapper.SearchResultsHolder.SearchComponentDescriptor compDesc = (PortingKitWrapper.SearchResultsHolder.SearchComponentDescriptor)e.Object;

                if (compDesc.File != null)
                {
                    if ((compDesc.Parent.Parent == null))   //En: have received file and library that contains it. Ru: получены файл и библиотека его содержащая
                    {
                        mLibrariesExplorer.SetSelectedComponent(compDesc.Parent.Component, compDesc.File);
                        mLibrariesExplorer.Show(dockPanel1);
                    }
                    else //En: Library have Parent - it's Project. Ru: У Library есть Parent - проект
                    {
                        mSolutionExplorer.SetSelectedComponent(compDesc.File);
                        mSolutionExplorer.Show(dockPanel1);
                    }
                    if (compDesc.Line != null)
                    {
                        PKStudio.Helpers.EditorsFormsController.EditFileDescriptor desc = new EditorsFormsController.EditFileDescriptor();
                        desc.Path = compDesc.File.FullPath;
                        desc.Line = compDesc.Line.Num;
                        mEditorsController.ShowEditor(desc);
                    }
                }
                if (compDesc.Component != null)
                {
                    if (compDesc.Parent != null)
                    {
                        mSolutionExplorer.SetSelectedComponent(compDesc.Parent.Component, compDesc.Component);
                        mSolutionExplorer.Show(dockPanel1);
                    }
                    else
                    {
                        OpenComponentEditor(compDesc.Component);
                    }
                }
            }
            else
            {
                mEditorsController.ShowEditor(e.Object);
                //mLibrariesExplorer.SetSelectedComponent(e.Object);
            }
        }