Пример #1
0
        /// <summary>
        /// Открыть новое окно
        /// </summary>
        /// <param name="projectElement"></param>
        public Schematix.Windows.SchematixBaseWindow OpenNewWindow(ProjectElementBase projectElement)
        {
            try
            {
                if (projectElement == null)
                {
                    return(null);
                }

                if ((System.IO.File.Exists(projectElement.Path) == false) && ((System.IO.Directory.Exists(projectElement.Path) == false)))
                {
                    var DialogResult = System.Windows.MessageBox.Show(string.Format("Could not find file {0}. Remove it from prject?", projectElement.Path), "File not found", System.Windows.MessageBoxButton.YesNo);
                    if (DialogResult == System.Windows.MessageBoxResult.Yes)
                    {
                        (projectElement.Parent as ProjectFolder).RemoveElement(projectElement);
                        SaveSolution();
                        UpdateExplorerPanel();
                    }
                    return(null);
                }

                Schematix.Windows.SchematixBaseWindow window = null;

                mainWindow.Dispatcher.Invoke(
                    System.Windows.Threading.DispatcherPriority.Background, new System.Windows.Threading.DispatcherOperationCallback(delegate
                {
                    foreach (Schematix.Windows.SchematixBaseWindow v in OpenedWindows())
                    {
                        if ((v.ProjectElement == projectElement) || (v.ProjectElement.Path == projectElement.Path))
                        {
                            window     = v;
                            v.IsActive = true;
                            return(null);
                        }
                    }
                    window = projectElement.CreateNewWindow();
                    return(null);
                }
                                                                                                                                     ), null);
                if (window != null)
                {
                    OpenNewWindow(window);
                }
                return(window);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Пример #2
0
        /// <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));
        }
Пример #3
0
        /// <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);
        }
        /// <summary>
        /// Создание объекта Header для элемента TreeView
        /// </summary>
        /// <param name="elem"></param>
        /// <returns></returns>
        private object CreateHeader(ProjectElementBase elem)
        {
            StackPanel panel = new StackPanel();

            panel.Orientation = Orientation.Horizontal;
            BitmapImage b_img = new BitmapImage(new Uri(elem.Icon, UriKind.Relative));
            Image       img   = new Image()
            {
                Source = b_img, Width = 16, Height = 16,
            };
            TextBlock text = new TextBlock()
            {
                Text = elem.Caption
            };

            text.Tag = elem;
            elem.Tag = panel;

            panel.Children.Add(img);
            panel.Children.Add(text);

            return(panel);
        }