示例#1
0
        void onDragDrop(object sender, DragEventArgs e)
        {
            if (!Helper.CanDragAndDrop(e))
            {
                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();
            }
            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();
                    element.SetDefaults();
                    _modelPanel.Model.CheckSeries();
                    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();
        }
示例#2
0
        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));
        }