public void Find(string word = null) { if (word != null) { TB_Input.Text = word; } Initialize(false); if (TB_Input.Text.Length <= 0) { return; } switch (Mode) { case MODE_CURRENT: ITabItem currenttab = parent.MainTabControl.SelectedItem; if (currenttab is FuncBlockViewModel) { FuncBlockViewModel fbvmodel = (FuncBlockViewModel)currenttab; Find(fbvmodel); } break; case MODE_ALL: ProjectModel pmodel = parent.ProjectModel; Find(pmodel.LibFuncBlock); foreach (FuncBlockViewModel fbvmodel in pmodel.FuncBlocks) { Find(fbvmodel); } break; } PropertyChanged(this, new PropertyChangedEventArgs("Items")); }
public TextReplaceElement ( TextReplaceWindow _tpwindow, FuncBlockViewModel _fbvmodel, int _textoffset, string _word ) { tpwindow = _tpwindow; fbvmodel = _fbvmodel; fbvmodel.TextChanged += OnTextChanged; Offset = _textoffset; word = _word; string text = fbvmodel.Code; int start = textoffset - 1; int end = textoffset + word.Length; while (start >= 0 && text[start] != '\n' && text[start] != '\r') { start--; } while (end < text.Length && text[end] != '\n' && text[end] != '\r') { end++; } Line = text.Substring(start + 1, end - start - 1); lineoffset = textoffset - start - 1; }
private void Find(FuncBlockViewModel fbvmodel) { string text = fbvmodel.Code; string word = TB_Input.Text; RegexOptions opt = RegexOptions.None; opt |= RegexOptions.Singleline; if (IgnoreCase) { opt |= RegexOptions.IgnoreCase; } if (!IsRegex) { foreach (string slabel in SPECIALLABELS) { word = word.Replace(slabel, "\\" + slabel); } } Match match = Regex.Match(text, word, opt); while (match != null && match.Success) { items.Add(new TextReplaceElement(this, fbvmodel, match.Index, match.Value)); match = match.NextMatch(); } }
public void Initialize() { pmodel = new ProjectModel("效果展示"); ldvmodel = new LadderDiagramViewModel("效果展示", pmodel); lnvmodel = ldvmodel.GetNetworks().First(); ldvmodel.LadderMode = LadderMode.Demo; ldvmodel.Visibility = Visibility.Hidden; GD_Main.Children.Add(ldvmodel); LDDemoViewModel ldmodel = new LDDemoViewModel(); LDWEQDemoViewModel ldweqmodel = new LDWEQDemoViewModel(); SMOVDemoViewModel smovmodel = new SMOVDemoViewModel(); lnvmodel.LadderCanvas.Children.Add(ldmodel); lnvmodel.LadderCanvas.Children.Add(ldweqmodel); lnvmodel.LadderCanvas.Children.Add(smovmodel); lnvmodel.CommentAreaExpander.IsEnabled = false; lnvmodel.ladderExpander.IsEnabled = false; lnvmodel.LadderCanvas.IsEnabled = false; ldvmodel.CommentAreaExpander.IsEnabled = false; ldvmodel.ladderExpander.IsEnabled = false; ldvmodel.IsCommentMode = true; fbvmodel = new FuncBlockViewModel("效果展示", null); fbvmodel.Code = "void Func(WORD* w1, WORD* w2, WORD* w3)\n{\n\tw3[0] = w1[0] + w2[0];\n}\n"; fbvmodel.CodeTextBox.IsReadOnly = true; GD_Main.Children.Add(fbvmodel); fbvmodel.Visibility = Visibility.Hidden; }
private BackTraceElement GetElement(int bpaddr) { BaseViewModel bvmodel = BreakPointManager.GetBVModel(bpaddr); if (bvmodel != null) { LadderNetworkViewModel lnvmodel = ifacade.ProjectModel.GetNetwork(bvmodel); if (lnvmodel == null) { return(null); } LadderDiagramViewModel ldvmodel = lnvmodel.LDVModel; SimuBrpoElement brpo = new SimuBrpoElement(); brpo.LDVModel = ldvmodel; brpo.LNVModel = lnvmodel; brpo.BVModel = bvmodel; return(new BackTraceElement(BackTraceType.Diagram, brpo)); } FuncBlock fblock = BreakPointManager.GetFBlock(bpaddr); if (fblock != null) { FuncBlockViewModel fbvmodel = ifacade.ProjectModel.GetFuncBlock(fblock); if (fbvmodel == null) { return(null); } FuncBrpoElement brpo = new FuncBrpoElement(); brpo.FBVModel = fbvmodel; brpo.FBlock = fblock; return(new BackTraceElement(BackTraceType.FuncBlock, brpo)); } return(new BackTraceElement(BackTraceType.External)); }
/// <summary> /// 查找 /// </summary> private void Find() { Initialize(); if (TB_Input.Text.Length <= 0) { return; } switch (Mode) { // 当前文本 case MODE_CURRENT: ITabItem currenttab = parent.MainTabControl.SelectedItem; if (currenttab is FuncBlockViewModel) { FuncBlockViewModel fbvmodel = (FuncBlockViewModel)currenttab; Find(fbvmodel); } break; // 所有文本 case MODE_ALL: ProjectModel pmodel = parent.ProjectModel; Find(pmodel.LibFuncBlock); foreach (FuncBlockViewModel fbvmodel in pmodel.FuncBlocks) { Find(fbvmodel); } break; } PropertyChanged(this, new PropertyChangedEventArgs("Items")); }
public void ShowItem(ITabItem item) { //bool isnew = false; LayoutDocument ldoc = null; if (item is FuncBlockViewModel) { FuncBlockViewModel fbvmodel = (FuncBlockViewModel)item; fbvmodel.CodeTextBox.Focus(); } if (item.IsFloat) { LayoutFloatingWindowControl fwctrl = item.FloatControl; fwctrl.Focus(); return; } if (!TabItemCollection.Contains(item)) { TabItemCollection.Add(item); item.FloatClosed += OnTabFloatClosed; ldoc = new LayoutDocument(); ldoc.Title = item.TabHeader; if (item is LadderDiagramViewModel) { IEnumerable <MainTabDiagramItem> fit = DiagramCollection.Where( (MainTabDiagramItem _mtditem) => { return(_mtditem.LDVM_ladder == item); }); MainTabDiagramItem mtditem = null; if (fit.Count() == 0) { mtditem = new MainTabDiagramItem((IProgram)item, ViewMode); DiagramCollection.Add(mtditem); } else { mtditem = fit.First(); } ldoc.Content = mtditem; } else { ldoc.Content = item; } ldoc.IsActiveChanged += OnActiveChanged; Children.Add(ldoc); _lDocDict.Add(item, ldoc); //isnew = true; } else { ldoc = _lDocDict[item]; } int ldocid = Children.IndexOf(ldoc); SelectedItem = item; SelectedContentIndex = ldocid; }
public TextFindElement ( TextFindWindow _tfwindow, FuncBlockViewModel _fbvmodel, int _textoffset, string _word ) : base(null, _fbvmodel, _textoffset, _word) { tfwindow = _tfwindow; }
public ErrorReportElement_FB ( int _status, string _message, FuncBlockViewModel _fbvmodel, int _line, int _column ) { Status = _status; Message = _message; fbvmodel = _fbvmodel; Line = _line; Column = _column; PropertyChanged(this, new PropertyChangedEventArgs("Message")); PropertyChanged(this, new PropertyChangedEventArgs("Program")); PropertyChanged(this, new PropertyChangedEventArgs("Point")); }
private void DG_FList_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e) { if (!parent.MainWindow.LAErrorList.IsFloat && !parent.MainWindow.LAErrorList.IsDock) { LayoutSetting.AddDefaultDockWidthAnchorable( Properties.Resources.MainWindow_Error_List, parent.MainWindow.LAErrorList.AutoHideWidth.ToString()); LayoutSetting.AddDefaultDockHeighAnchorable( Properties.Resources.MainWindow_Error_List, parent.MainWindow.LAErrorList.AutoHideHeight.ToString()); parent.MainWindow.LAErrorList.ToggleAutoHide(); } if (DG_FList.SelectedIndex < 0) { return; } ErrorReportElement_FB ele = (ErrorReportElement_FB)DG_FList.SelectedItem; FuncBlockViewModel fbvmodel = ele.FBVModel; int line = ele.Line; int column = ele.Column; parent.NavigateToFuncBlock(fbvmodel, line, column); }
private void DG_List_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (!parent.MainWindow.LAReplace.IsFloat && !parent.MainWindow.LAReplace.IsDock) { LayoutSetting.AddDefaultDockWidthAnchorable( Properties.Resources.MainWindow_Replace, parent.MainWindow.LAReplace.AutoHideWidth.ToString()); LayoutSetting.AddDefaultDockHeighAnchorable( Properties.Resources.MainWindow_Replace, parent.MainWindow.LAReplace.AutoHideHeight.ToString()); parent.MainWindow.LAReplace.ToggleAutoHide(); } if (DG_List.SelectedIndex < 0) { return; } TextReplaceElement element = null; if (e.AddedItems.Count > 0) { element = (TextReplaceElement)(e.AddedItems[0]); } else if (e.RemovedItems.Count > 0) { element = (TextReplaceElement)(e.RemovedItems[0]); } else { return; } FuncBlockViewModel fbvmodel = element.FBVModel; int offset = element.Offset; int count = element.Word.Length; parent.NavigateToFuncBlock(fbvmodel, offset); fbvmodel.SetOffset(offset, count); }
public void Dispose() { tpwindow = null; fbvmodel.TextChanged -= OnTextChanged; fbvmodel = null; }