void highlightRestriction(bool isDragging) { //!! behaviour scintillina -> we have to convert the positions for UTF char... :-(, waiting for a Scintillina expert ! int startPos = convertToRealPosition(restrictionsTextBox.Caret.Position, restrictionsTextBox.RawText); //Debug.WriteLine("calc={0} caret={1} selstart={2} indentpos={3} linestart={4}", startPos, restrictionsTextBox.Caret.Position, restrictionsTextBox.Selection.Start, restrictionsTextBox.Lines.Current.IndentPosition, restrictionsTextBox.Lines.Current.StartPosition); int endPos = 0; var restriction = getRestriction(ref startPos, ref endPos, restrictionsTextBox.Text); if (!isDragging) { if (restriction != null) { ModelPanel.SetMetaColumn(restriction); restriction.InitEditor(); } bool collapseCategories = (ModelPanel.RestrictionGrid.SelectedObject == null); ModelPanel.RestrictionGrid.SelectedObject = restriction; //Collapse Advanced categories if (collapseCategories && !collapseRestrictionCategoriesDone) { collapseRestrictionCategoriesDone = true; ModelPanel.CollapseCategories(ModelPanel.RestrictionGrid); } } if (restriction != null) { restrictionsTextBox.Selection.Start = convertToScintillaPosition(startPos, restrictionsTextBox.Text); restrictionsTextBox.Selection.End = convertToScintillaPosition(endPos, restrictionsTextBox.Text) + 1; restrictionsTextBox.Focus(); MenuItem item = new MenuItem("Smart copy..."); item.Click += new EventHandler(delegate(object sender2, EventArgs e2) { SmartCopyForm form = new SmartCopyForm("Smart copy of " + restriction.DisplayNameEl, restriction, restriction.Model.Report); form.ShowDialog(); if (form.IsReportModified) { ModelPanel.MainForm.IsModified = true; ModelPanel.MainForm.CannotRenderAnymore(); ModelToRestrictionText(); } }); restrictionsTextBox.ContextMenu = new System.Windows.Forms.ContextMenu(); restrictionsTextBox.ContextMenu.MenuItems.Add(item); } else { restrictionsTextBox.ContextMenu = null; } }
void highlightRestriction(bool isDragging) { int startPos = restrictionsTextBox.CurrentPosition; int endPos = 0; var restriction = getRestriction(ref startPos, ref endPos, restrictionsTextBox.Text); if (!isDragging) { if (restriction != null) { ModelPanel.SetMetaColumn(restriction); restriction.InitEditor(); } bool collapseCategories = (ModelPanel.RestrictionGrid.SelectedObject == null); ModelPanel.RestrictionGrid.SelectedObject = restriction; //Collapse Advanced categories if (collapseCategories && !collapseRestrictionCategoriesDone) { collapseRestrictionCategoriesDone = true; ModelPanel.CollapseCategories(ModelPanel.RestrictionGrid); } } if (restriction != null) { restrictionsTextBox.SelectionStart = startPos; restrictionsTextBox.SelectionEnd = endPos + 1; restrictionsTextBox.Focus(); MenuItem item = new MenuItem("Smart copy..."); item.Click += new EventHandler(delegate(object sender2, EventArgs e2) { SmartCopyForm form = new SmartCopyForm("Smart copy of " + restriction.DisplayNameEl, restriction, restriction.Model.Report); form.ShowDialog(); if (form.IsReportModified) { ModelPanel.MainForm.IsModified = true; ModelPanel.MainForm.CannotRenderAnymore(); ModelToRestrictionText(); } }); restrictionsTextBox.ContextMenu = new ContextMenu(); restrictionsTextBox.ContextMenu.MenuItems.Add(item); } else { restrictionsTextBox.ContextMenu = null; } }