/// <summary> /// Открыть файл /// </summary> /// <param name="filePath"></param> /// <param name="searchItemInSolution"></param> /// <param name="projFolder"></param> public Schematix.Windows.SchematixBaseWindow OpenNewWindow(string filePath, bool searchItemInSolution = true, ProjectFolder projFolder = null) { ProjectElementBase elem = null; //Ищем в решении файл (если необходимо) if (searchItemInSolution == true) { elem = SearchItemInSolution(filePath); } //Если файл не нашелся, создаем объект ProjectElementBase вручную if (elem == null) { elem = ProjectElementBase.CreateProjectElementByPath(filePath, projFolder); } return(OpenNewWindow(elem)); }
/// <summary> /// Открыть файл с исходным кодом и поставить курсор в нужную позицию /// </summary> /// <param name="filePath"></param> /// <param name="searchItemInSolution"></param> /// <param name="projFolder"></param> /// <param name="LineNumber"></param> public Schematix.Windows.Code.Code OpenSource(string filePath, bool searchItemInSolution = true, ProjectFolder projFolder = null, int LineNumber = 0, int position = 0) { ProjectElementBase elem = null; //Ищем в решении файл (если необходимо) if (searchItemInSolution == true) { elem = SearchItemInSolution(filePath); } //Если файл не нашелся, создаем объект ProjectElementBase вручную if (elem == null) { elem = ProjectElementBase.CreateProjectElementByPath(filePath, projFolder); } Schematix.Windows.SchematixBaseWindow window = null; Schematix.Windows.Code.Code codeWindow = null; mainWindow.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Background, new System.Windows.Threading.DispatcherOperationCallback(delegate { window = OpenNewWindow(elem); codeWindow = window as Schematix.Windows.Code.Code; if (LineNumber >= 0) { codeWindow.textEditor.Loaded += new System.Windows.RoutedEventHandler(delegate { codeWindow.SetPosition(LineNumber, position); }); } if (codeWindow.ProjectElement.Parent == null) { codeWindow.textEditor.IsReadOnly = true; } return(null); } ), null); return(codeWindow); }