示例#1
0
 private void ButtonFindNext2_Click(object sender, RoutedEventArgs e)
 {
     textSearcher.Searcher.MatchCase    = CheckBoxMatchCase2.IsChecked == true;
     textSearcher.Searcher.SearchUp     = CheckBoxSearchUp2.IsChecked == true;
     textSearcher.Searcher.SearchedText = ComboboxQuickSource.Text;
     curSearchResult = textSearcher.GetNextSearchResult();
     if (curSearchResult != null)
     {
         Schematix.Windows.Code.Code window = core.OpenNewWindow(curSearchResult.Code.Path) as Schematix.Windows.Code.Code;
         if (window != null)
         {
             if (window.textEditor.IsLoaded == false)
             {
                 window.textEditor.Loaded += new RoutedEventHandler(delegate { window.textEditor.Select(curSearchResult.Segment.StartOffset, curSearchResult.Segment.Length); });
             }
             else
             {
                 window.textEditor.Select(curSearchResult.Segment.StartOffset, curSearchResult.Segment.Length);
             }
             textSearcher.Searcher.Text         = window.textEditor.Text;
             textSearcher.Searcher.StartOffset += curSearchResult.Segment.Length;
         }
     }
     else
     {
         textSearcher.Searcher.StartOffset = 0;
         UpdateSearchType2();
     }
 }
示例#2
0
        public TextSearcher(SchematixCore core, Schematix.Windows.Code.Code code)
        {
            this.core = core;

            searcher           = new SimpleSearcher(string.Empty, string.Empty, 0);
            solutionFiles      = new List <SearchSource>();
            curProjFiles       = new List <SearchSource>();
            allOpenedDocuments = new List <SearchSource>();
        }
示例#3
0
        private void Find_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            textSearcher.Searcher.SearchedText = SearchBox.Text;

            SearchResult curSearchResult = textSearcher.GetNextSearchResult();

            if (curSearchResult != null)
            {
                Schematix.Windows.Code.Code window = core.OpenNewWindow(curSearchResult.Code.Path) as Schematix.Windows.Code.Code;
                if (window != null)
                {
                    if (window.textEditor.IsLoaded == false)
                    {
                        window.textEditor.Loaded += new RoutedEventHandler(delegate
                        {
                            window.textEditor.Select(curSearchResult.Segment.StartOffset, curSearchResult.Segment.Length);
                            window.IsActive = false;
                            SearchBox.Focus();
                        });
                    }
                    else
                    {
                        window.textEditor.Select(curSearchResult.Segment.StartOffset, curSearchResult.Segment.Length);
                        window.IsActive = false;
                        SearchBox.Focus();
                    }
                }
            }
            else
            {
                MessageBox.Show("Nothing was found, Try again");
                textSearcher.Searcher.StartOffset  = 0;
                textSearcher.Searcher.SearchedText = SearchBox.Text;
                if (RadioButtonCurrentFileSearch.IsChecked == true)
                {
                    textSearcher.Reset(SearchType.CurrentDocument);
                }
                if (RadioButtonCurrentProjectSearch.IsChecked == true)
                {
                    textSearcher.Reset(SearchType.CurrentProject);
                }
                if (RadioButtonEntireSolutionSearchSearch.IsChecked == true)
                {
                    textSearcher.Reset(SearchType.EntireSolution);
                }
            }
        }
示例#4
0
 private void ButtonReplace2_Click(object sender, RoutedEventArgs e)
 {
     if ((curSearchResult != null) && (curSearchResult.Segment.Length != 0))
     {
         if ((core.MainWindow.CurrentActiveWindow != null) && (core.MainWindow.CurrentActiveWindow is Schematix.Windows.Code.Code))
         {
             Schematix.Windows.Code.Code window = core.MainWindow.CurrentActiveWindow as Schematix.Windows.Code.Code;
             StringBuilder res = new StringBuilder();
             res.Append(window.textEditor.Text.Substring(0, curSearchResult.Segment.StartOffset));
             res.Append(ComboboxQuickReplace.Text);
             res.Append(window.textEditor.Text.Substring(curSearchResult.Segment.EndOffset));
             window.textEditor.Text             = res.ToString();
             textSearcher.Searcher.Text         = window.textEditor.Text;
             textSearcher.Searcher.StartOffset += ComboboxQuickReplace.Text.Length;
         }
     }
 }
示例#5
0
 private void ButtonReplaceAll2_Click(object sender, RoutedEventArgs e)
 {
     UpdateSearchType2();
     textSearcher.Searcher.MatchCase    = CheckBoxMatchCase2.IsChecked == true;
     textSearcher.Searcher.SearchUp     = CheckBoxSearchUp2.IsChecked == true;
     textSearcher.Searcher.SearchedText = ComboboxQuickSource.Text;
     while (true)
     {
         curSearchResult = textSearcher.GetNextSearchResult();
         if ((curSearchResult != null) && (curSearchResult.Code != null))
         {
             Schematix.Windows.Code.Code window = core.OpenNewWindow(curSearchResult.Code.Path) as Schematix.Windows.Code.Code;
             if (window != null)
             {
                 if (window.textEditor.IsLoaded == false)
                 {
                     window.textEditor.Loaded += new RoutedEventHandler(delegate {
                         StringBuilder res = new StringBuilder();
                         res.Append(window.textEditor.Text.Substring(0, curSearchResult.Segment.StartOffset));
                         res.Append(ComboboxQuickReplace.Text);
                         res.Append(window.textEditor.Text.Substring(curSearchResult.Segment.EndOffset));
                         window.textEditor.Text             = res.ToString();
                         textSearcher.Searcher.Text         = window.textEditor.Text;
                         textSearcher.Searcher.StartOffset += ComboboxQuickReplace.Text.Length;
                     });
                 }
                 else
                 {
                     StringBuilder res = new StringBuilder();
                     res.Append(window.textEditor.Text.Substring(0, curSearchResult.Segment.StartOffset));
                     res.Append(ComboboxQuickReplace.Text);
                     res.Append(window.textEditor.Text.Substring(curSearchResult.Segment.EndOffset));
                     window.textEditor.Text             = res.ToString();
                     textSearcher.Searcher.Text         = window.textEditor.Text;
                     textSearcher.Searcher.StartOffset += ComboboxQuickReplace.Text.Length;
                 }
             }
         }
         else
         {
             break;
         }
     }
 }
示例#6
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);
        }
        public override void OnActivateChild(Schematix.Windows.SchematixBaseWindow form)
        {
            //if (form == ActiveForm)
            //    return;

            ActiveForm = form;
            if (form == null)
            {
                toolBox.SelectContent("null");
                return;
            }

            if (form is Schematix.Windows.Code.Code)
            {
                Schematix.Windows.Code.Code c = form as Schematix.Windows.Code.Code;
                if ((c.textEditor.SyntaxHighlighting != null) && (c.textEditor.SyntaxHighlighting.Name.Equals("VHDL")))
                {
                    toolBox.SelectContent("VHDLTextTemplates");
                }
                if ((c.textEditor.SyntaxHighlighting != null) && (c.textEditor.SyntaxHighlighting.Name.Equals("Verilog")))
                {
                    toolBox.SelectContent("VerilogTextTemplates");
                }
                return;
            }

            if (form is Schematix.Windows.EntityDrawning.EntityDrawning)
            {
                toolBox.SelectContent("EntityDrawning");
                return;
            }

            if (form is Schematix.Windows.FSM.FSM)
            {
                toolBox.SelectContent("FSM");
                return;
            }

            if (form is Schematix.Windows.Schema.Schema)
            {
                if ((SchematixCore.Core == null) || (SchematixCore.Core.CurrentSelectedProject == null))
                {
                    toolBox.SelectContent("none");
                    return;
                }

                List <Schematix.ProjectExplorer.EDR_File> Files = SchematixCore.Core.CurrentSelectedProject.GetProjectElements <Schematix.ProjectExplorer.EDR_File>();
                List <string> SchemaFiles = new List <string>();
                foreach (Schematix.ProjectExplorer.EDR_File f in Files)
                {
                    SchemaFiles.Add(f.Path);
                }

                toolBox.SelectedType = "Schema";
                ToolBoxWindow.ExpanderData exp = new ToolBoxWindow.ExpanderData();
                exp.IconPath       = "EntityDrawning.jpg";
                exp.TypeOfElements = "EntityDrawning";
                exp.Description    = "Entity Drawning elements avaliable in this project";
                exp.Caption        = "EntityDrawning Items";
                foreach (string file in SchemaFiles)
                {
                    ToolBoxWindow.ToolBoxItem item = new ToolBoxWindow.ToolBoxItem(exp);
                    item.Caption     = System.IO.Path.GetFileName(file);
                    item.Command     = file;
                    item.Description = "Insert " + file + " entity drawning file";
                    item.IconPath    = "EntityDrawning.jpg";
                    exp.Items.Add(item);
                }
                exp.CreateExpander();
                List <ToolBoxWindow.ExpanderData> expanders = new List <ToolBoxWindow.ExpanderData>();
                expanders.Add(exp);
                toolBox.LoadExpanders(expanders);
                return;
            }
            toolBox.SelectContent("none");
        }
示例#8
0
 public TextSearcher(Schematix.Windows.Code.Code code)
     : this(SchematixCore.Core, code)
 {
 }
示例#9
0
 public SearchReplaceUserControl(SchematixCore core, Schematix.Windows.Code.Code code)
 {
     this.core    = core;
     textSearcher = new TextSearcher();
     InitializeComponent();
 }
示例#10
0
 public SearchReplaceUserControl(Schematix.Windows.Code.Code code)
     : this(SchematixCore.Core, code)
 {
 }