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;
            }
        }
Beispiel #3
0
        void btn_MouseDown(object sender, MouseEventArgs e)
        {
            Button button = (Button)sender;

            //set property grid
            ElementGrid.PropertyValueChanged -= Grid_PropertyValueChanged;
            ReportElement element = null;

            if (button.Tag != null)
            {
                element = button.Tag as ReportElement;
            }
            if (element != null)
            {
                element.InitEditor();
                bool collapseCategories = (ElementGrid.SelectedObject == null);

                ElementGrid.SelectedObject = button.Tag;

                //Collapse Advanced categories
                if (collapseCategories && !collapseElementCategoriesDone)
                {
                    CollapseCategories(ElementGrid);
                    collapseElementCategoriesDone = true;
                }
            }

            ElementGrid.PropertyValueChanged += Grid_PropertyValueChanged;

            if (e != null)
            {
                DragDropEffects dde1 = DoDragDrop(sender, DragDropEffects.Move);
            }

            if (button.Parent != null)
            {
                SelectedButton = button;
                redrawButtons();
            }

            //select meta element in TreeView
            if (element != null)
            {
                SetMetaColumn(elementTreeView.Nodes, element);
            }

            if (e != null && e.Button == MouseButtons.Right)
            {
                ContextMenuStrip  menu = new ContextMenuStrip();
                ToolStripMenuItem item = new ToolStripMenuItem("Remove");
                item.Click += new EventHandler(delegate(object sender2, EventArgs e2)
                {
                    removeElementFromPanel(button, false);
                });
                if (!Model.IsSubModel)
                {
                    menu.Items.Add(item);
                }

                item        = new ToolStripMenuItem("Copy");
                item.Click += new EventHandler(delegate(object sender2, EventArgs e2)
                {
                    copyElementFromPanel(button);
                });
                if (!Model.IsSubModel)
                {
                    menu.Items.Add(item);
                }

                item        = new ToolStripMenuItem("Prompt at run-time");
                item.Click += new EventHandler(delegate(object sender2, EventArgs e2)
                {
                    if (element.MetaColumn.IsAggregate == true)
                    {
                        aggregateRestrictionsPanel.AddRestriction(element.MetaColumn, true);
                    }
                    else
                    {
                        restrictionsPanel.AddRestriction(element.MetaColumn, true);
                    }
                });
                menu.Items.Add(item);

                if (!Model.IsSubModel)
                {
                    menu.Items.Add(new ToolStripSeparator());
                    item        = new ToolStripMenuItem("Remove all elements");
                    item.Click += new EventHandler(delegate(object sender2, EventArgs e2)
                    {
                        removeElementFromPanel(button, true);
                    });
                    menu.Items.Add(item);

                    item        = new ToolStripMenuItem("Clear all Sort orders");
                    item.Click += new EventHandler(delegate(object sender2, EventArgs e2)
                    {
                        ElementPanel panel = (ElementPanel)button.Parent;
                        foreach (var control in panel.Controls)
                        {
                            ReportElement el = ((Button)control).Tag as ReportElement;
                            if (el != null)
                            {
                                el.SortOrder = ReportElement.kNoSortKeyword;
                            }
                        }
                        btn_MouseDown(button, null);
                        MainForm.IsModified = true;
                    });
                    menu.Items.Add(item);

                    menu.Items.Add(new ToolStripSeparator());
                    item        = new ToolStripMenuItem("Smart copy...");
                    item.Click += new EventHandler(delegate(object sender2, EventArgs e2)
                    {
                        SmartCopyForm form = new SmartCopyForm("Smart copy of " + element.DisplayNameEl, element, Model.Report);
                        form.ShowDialog();
                        if (form.IsReportModified)
                        {
                            MainForm.IsModified = true;
                            MainForm.CannotRenderAnymore();
                            ElementsToPanels();
                        }
                    });
                    menu.Items.Add(item);
                }
                //Display context menu
                menu.Show(button, e.Location);
            }
        }