public ModelPanel() { RowPanel = new ElementPanel(this, PivotPosition.Row); DataPanel = new ElementPanel(this, PivotPosition.Data); PagePanel = new ElementPanel(this, PivotPosition.Page); ColumnPanel = new ElementPanel(this, PivotPosition.Column); PanelList = new List<ElementPanel>() { PagePanel, ColumnPanel, RowPanel, DataPanel }; InitializeComponent(); aggregateRestrictionsPanel.IsAggregate = true; ModelGrid.Dock = DockStyle.Fill; ModelGrid.PropertyValueChanged += Grid_PropertyValueChanged; ModelGrid.ToolbarVisible = false; ModelGrid.HelpVisible = false; ModelGrid.PropertySort = PropertySort.Categorized; modelSourceSplitContainer.Panel1.Controls.Add(ModelGrid); ElementGrid.Dock = DockStyle.Fill; ElementGrid.PropertyValueChanged += Grid_PropertyValueChanged; ElementGrid.ToolbarVisible = false; ElementGrid.PropertySort = PropertySort.Categorized; elementsContainer.Panel2.Controls.Add(ElementGrid); foreach (var panel in PanelList) elementsContainer.Panel1.Controls.Add(panel); RestrictionGrid.Dock = DockStyle.Fill; RestrictionGrid.PropertyValueChanged += Grid_PropertyValueChanged; RestrictionGrid.SelectedObjectsChanged += new EventHandler(RestrictionGrid_SelectedObjectsChanged); RestrictionGrid.ToolbarVisible = false; RestrictionGrid.PropertySort = PropertySort.Categorized; restrictionsContainer.Panel2.Controls.Add(RestrictionGrid); }
void onDragDrop(object sender, DragEventArgs e) { if (!Helper.CanDragAndDrop(e)) { return; } if (_modelPanel.Model.IsSubModel) { return; } Button button = null; if (e.Data.GetDataPresent(typeof(TreeNode))) { TreeNode elementNode = (TreeNode)e.Data.GetData(typeof(TreeNode)); button = _modelPanel.AddElement(this, (MetaColumn)elementNode.Tag, true); _modelPanel.MainForm.IsModified = true; _modelPanel.MainForm.CannotRenderAnymore(); _modelPanel.UpdateLINQModel(); } if (e.Data.GetDataPresent(typeof(Button))) { button = (Button)e.Data.GetData(typeof(Button)); } if (button != null) { ElementPanel source = null; if (button.Parent != this) { //Button comes from another panel ReportElement element = (ReportElement)button.Tag; source = (ElementPanel)button.Parent; source.Controls.Remove(button); element.PivotPosition = Position; element.InitEditor(); source.RedrawPanel(); Controls.Add(button); _modelPanel.MainForm.IsModified = true; _modelPanel.MainForm.CannotRenderAnymore(); _modelPanel.PanelsToElements(); } //Set new position int index = getIndexFocus(e); if (index != -1 && Controls[index] != button) { Controls.SetChildIndex(button, index); _modelPanel.MainForm.IsModified = true; _modelPanel.MainForm.CannotRenderAnymore(); _modelPanel.PanelsToElements(); } RedrawPanel(); button.Focus(); } _modelPanel.Model.CheckSortOrders(); }
public Button AddElement(ElementPanel panel, MetaColumn column, bool selectButton) { ReportElement element = ReportElement.Create(); element.Source = Model.Source; element.Format = ""; element.Model = Model; element.MetaColumnGUID = column.GUID; element.Name = column.Name; element.PivotPosition = panel.Position; element.SetDefaults(); Model.Elements.Add(element); return(AddElement(panel, element, selectButton)); }
public Button AddElement(ElementPanel panel, ReportElement element, bool selectButton) { Button button = new Button() { Text = element.DisplayNameEl }; button.Tag = element; //Add tool tip var toolTip = new ToolTip(); toolTip.SetToolTip(button, element.DisplayNameEl); button.MouseDown += new MouseEventHandler(btn_MouseDown); panel.Controls.Add(button); if (selectButton) btn_MouseDown(button, null); panel.ResizeControls(); return button; }
public ModelPanel() { RowPanel = new ElementPanel(this, PivotPosition.Row); DataPanel = new ElementPanel(this, PivotPosition.Data); PagePanel = new ElementPanel(this, PivotPosition.Page); ColumnPanel = new ElementPanel(this, PivotPosition.Column); PanelList = new List <ElementPanel>() { PagePanel, ColumnPanel, RowPanel, DataPanel }; InitializeComponent(); aggregateRestrictionsPanel.IsAggregate = true; ModelGrid.Dock = DockStyle.Fill; ModelGrid.PropertyValueChanged += Grid_PropertyValueChanged; ModelGrid.ToolbarVisible = false; ModelGrid.HelpVisible = true; ModelGrid.PropertySort = PropertySort.Categorized; ModelGrid.LineColor = SystemColors.ControlLight; modelSourceSplitContainer.Panel1.Controls.Add(ModelGrid); PropertyGridHelper.AddResetMenu(ModelGrid); ElementGrid.Dock = DockStyle.Fill; ElementGrid.PropertyValueChanged += Grid_PropertyValueChanged; ElementGrid.ToolbarVisible = false; ElementGrid.PropertySort = PropertySort.Categorized; ElementGrid.LineColor = SystemColors.ControlLight; elementsContainer.Panel2.Controls.Add(ElementGrid); foreach (var panel in PanelList) { elementsContainer.Panel1.Controls.Add(panel); } PropertyGridHelper.AddResetMenu(ElementGrid); RestrictionGrid.Dock = DockStyle.Fill; RestrictionGrid.PropertyValueChanged += Grid_PropertyValueChanged; RestrictionGrid.SelectedObjectsChanged += new EventHandler(RestrictionGrid_SelectedObjectsChanged); RestrictionGrid.ToolbarVisible = false; RestrictionGrid.PropertySort = PropertySort.Categorized; RestrictionGrid.LineColor = SystemColors.ControlLight; restrictionsContainer.Panel2.Controls.Add(RestrictionGrid); PropertyGridHelper.AddResetMenu(RestrictionGrid); elementTreeView.MouseUp += elementTreeView_MouseUp; }
void copyElementFromPanel(Button elementButton) { ReportElement element = elementButton.Tag as ReportElement; if (element != null) { ElementPanel panel = (ElementPanel)elementButton.Parent; ReportElement element2 = (ReportElement)Helper.Clone(element); Model.Elements.Add(element2); Model.InitReferences(); element2.DisplayName = element2.DisplayNameEl + " - Copy"; ElementsToPanels(); Button button = (Button)panel.Controls[panel.Controls.Count - 1]; MainForm.CannotRenderAnymore(); btn_MouseDown(button, null); MainForm.IsModified = true; } }
public Button AddElement(ElementPanel panel, ReportElement element, bool selectButton) { Button button = new Button() { Text = element.DisplayNameEl }; button.Tag = element; button.MouseDown += new MouseEventHandler(btn_MouseDown); panel.Controls.Add(button); if (selectButton) { btn_MouseDown(button, null); } panel.ResizeControls(); return(button); }
void removeElementFromPanel(Button elementButton, bool all) { ElementPanel panel = (ElementPanel)elementButton.Parent; if (all) { panel.Controls.Clear(); } else { panel.Controls.Remove(elementButton); } MainForm.CannotRenderAnymore(); PanelsToElements(); SelectedButton = null; ElementGrid.SelectedObject = null; panel.RedrawPanel(); MainForm.IsModified = true; }
void addElement(bool replaceSelected) { if (elementTreeView.SelectedNode != null && elementTreeView.SelectedNode.Tag is MetaColumn) { //If an element is already selected, try to insert the new one just after... ElementPanel panel = RowPanel; if (SelectedButton != null && SelectedButton.Parent is ElementPanel) { panel = SelectedButton.Parent as ElementPanel; } int newIndex = -1; ReportElement element = null; if (SelectedButton != null && SelectedButton.Tag is ReportElement && panel.Controls.Contains(SelectedButton)) { element = SelectedButton.Tag as ReportElement; if (element.PivotPosition == PivotPosition.Data) { panel = DataPanel; } if (element.PivotPosition == PivotPosition.Column) { panel = ColumnPanel; } if (element.PivotPosition == PivotPosition.Page) { panel = PagePanel; } newIndex = panel.Controls.GetChildIndex(SelectedButton) + 1; if (replaceSelected) { panel.Controls.Remove(SelectedButton); Model.Elements.Remove(element); newIndex--; } } //For aggregate force data panel if (!replaceSelected && ((MetaColumn)elementTreeView.SelectedNode.Tag).IsAggregate) { panel = DataPanel; } Button button = AddElement(panel, (MetaColumn)elementTreeView.SelectedNode.Tag, true); //move position to the next button if (newIndex != -1) { panel.Controls.SetChildIndex(button, newIndex); } if (replaceSelected && element != null) { //copy interesting properties ReportElement newElement = button.Tag as ReportElement; newElement.AggregateFunction = element.AggregateFunction; newElement.CalculationOption = element.CalculationOption; newElement.Nvd3Serie = element.Nvd3Serie; newElement.ChartJSSerie = element.ChartJSSerie; newElement.PlotlySerie = element.PlotlySerie; newElement.SerieDefinition = element.SerieDefinition; newElement.SerieSortOrder = element.SerieSortOrder; newElement.SerieSortType = element.SerieSortType; newElement.TotalAggregateFunction = element.TotalAggregateFunction; newElement.ShowTotal = element.ShowTotal; newElement.SortOrder = element.SortOrder; newElement.XAxisType = element.XAxisType; newElement.YAxisType = element.YAxisType; } MainForm.IsModified = true; MainForm.CannotRenderAnymore(); PanelsToElements(); panel.RedrawPanel(); button.Focus(); UpdateLINQModel(); } }
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); } }
public Button AddElement(ElementPanel panel, MetaColumn column, bool selectButton) { ReportElement element = ReportElement.Create(); element.Source = Model.Source; element.Format = ""; element.Model = Model; element.MetaColumnGUID = column.GUID; element.Name = column.Name; element.PivotPosition = panel.Position; element.SetDefaults(); Model.Elements.Add(element); return AddElement(panel, element, selectButton); }
public Button AddElement(ElementPanel panel, ReportElement element, bool selectButton) { Button button = new Button() { Text = element.DisplayNameEl }; button.Tag = element; button.MouseDown += new MouseEventHandler(btn_MouseDown); panel.Controls.Add(button); if (selectButton) btn_MouseDown(button, null); panel.ResizeControls(); return button; }