Beispiel #1
0
        void panel_MouseMove(object sender, MouseEventArgs e)
        {
            if (OpenForViewingOnly)
            {
                return;
            }

            if (lastMouseLocation != e.Location)
            {
                if (updateGroupFieldOutline)
                {
                    if (LassoFootprint == null)
                    {
                        LassoFootprint = new TemplateFootprint();
                    }

                    if (e.X < selectionStartLocation.X)
                    {
                        groupFieldOutline.X = e.X;
                        groupFieldOutline.Width = selectionStartLocation.X - e.X;
                    }
                    else
                    {
                        groupFieldOutline.X = selectionStartLocation.X;
                        groupFieldOutline.Width = e.X - selectionStartLocation.X;
                    }

                    if (e.Y < selectionStartLocation.Y)
                    {
                        groupFieldOutline.Y = e.Y;
                        groupFieldOutline.Height = selectionStartLocation.Y - e.Y;
                    }
                    else
                    {
                        groupFieldOutline.Y = selectionStartLocation.Y;
                        groupFieldOutline.Height = e.Y - selectionStartLocation.Y;
                    }

                    if (LassoFootprint != null && LassoFootprint.IsDisposed == false)
                    {
                        LassoFootprint.SizeTo(groupFieldOutline);
                    }
                }
            }

            lastMouseLocation = e.Location;
        }
Beispiel #2
0
        /// <summary>
        /// Handles the Drag Over event of the panel 
        /// </summary>
        /// <param name="sender">Object that fired the event</param>
        /// <param name="e">.NET supplied event parameters</param>
        private void PagePanel_DragOver(object sender, DragEventArgs e)
        {
            if (OpenForViewingOnly)
            {
                return;
            }

            if (e.Data.GetData("DragControl") != null)
            {
                bool dragControlIsSelected = false;
                e.Effect = DragDropEffects.Move;
                IFieldControl drgControl = (IFieldControl)e.Data.GetData("DragControl");
                Rectangle rec = new Rectangle(e.X - ((IDragable)drgControl).XOffset, e.Y - ((IDragable)drgControl).YOffset, ((Control)drgControl).Width, ((Control)drgControl).Height);
                rec = PagePanel.RectangleToClient(rec);
                ((Control)drgControl).Location = rec.Location;
                ((Control)drgControl).Size = rec.Size;

                SortedDictionary<IFieldControl, Point> selectedFieldControls = makeViewForm.mediator.SelectedFieldControls;
                DisposeControlTrackers();

                if (selectedFieldControls.Count != 0)
                {
                    foreach (KeyValuePair<IFieldControl, Point> kvp in selectedFieldControls)
                    {
                        if (((IFieldControl)kvp.Key).Field.UniqueId == ((IFieldControl)drgControl).Field.UniqueId)
                        {
                            dragControlIsSelected = true;
                            break;
                        }
                    }

                    if (dragControlIsSelected == false)
                    {
                        selectedFieldControls.Clear();
                    }
                }

                if (selectedFieldControls.Count == 0)
                {
                    if (drgControl is DragableLabel)
                    {
                        DragableLabel drgLabelControl = (DragableLabel)drgControl;
                        if (drgLabelControl.LabelFor != null)
                        {
                            Control ctrl = drgLabelControl.LabelFor;
                            ctrl.Top = rec.Top + drgLabelControl.VerticalDistanceToControl;
                            ctrl.Left = rec.Left + drgLabelControl.HorizontalDistanceToControl;
                        }
                    }

                    if (drgControl is DragableGroupBox)
                    {
                        DragableGroupBox drgGroupControl = (DragableGroupBox)drgControl;
                        foreach (Control childControl in (drgGroupControl.ChildControls))
                        {
                            if (childControl is IFieldControl)
                            {
                                childControl.Top = rec.Top + drgGroupControl.GetVerticalDistanceTo(childControl);
                                childControl.Left = rec.Left + drgGroupControl.GetHorizontalDistanceTo(childControl);
                            }
                        }
                    }
                }
                else
                {
                    if (drgControl is IDragable)
                    {
                        if (SelectedFieldsFootprint == null)
                        {
                            int minOver = int.MaxValue, minDown = int.MaxValue, maxOver = int.MinValue, maxDown = int.MinValue;

                            foreach (KeyValuePair<IFieldControl, Point> kvp in selectedFieldControls)
                            {
                                ((Control)kvp.Key).Visible = false;

                                int dim = ((Control)kvp.Key).Location.X;
                                if (minOver >= dim) minOver = dim;

                                dim = ((Control)kvp.Key).Location.Y;
                                if (minDown >= dim) minDown = dim;

                                dim = ((Control)kvp.Key).Location.X + ((Control)kvp.Key).Width;
                                if (maxOver <= dim) maxOver = dim;

                                dim = ((Control)kvp.Key).Location.Y + ((Control)kvp.Key).Height;
                                if (maxDown <= dim) maxDown = dim;
                            }

                            Size size = new Size(maxOver - minOver, maxDown - minDown);
                            Rectangle rectangle = new Rectangle(MousePosition, size);
                            rectangle = PagePanel.RectangleToClient(rectangle);

                            SelectedFieldsFootprint = new TemplateFootprint(rectangle);
                            _footprintMouseOffset = PagePanel.PointToClient(new Point(e.X - minOver,  e.Y - minDown));
                        }

                        Point point = PagePanel.PointToClient(new Point(e.X, e.Y));
                        point = CalcAcceptableFootprintLocation(point);
                        SelectedFieldsFootprint.Left = point.X;
                        SelectedFieldsFootprint.Top = point.Y;
                    }
                }
            }
            else if (e.Data.GetData("DraggedTemplateNode") != null)
            {
                e.Effect = DragDropEffects.Move;
                object ob = e.Data.GetData("DraggedTemplateNode");

                if (ob is TemplateNode)
                {
                    Template template = new Template(makeViewForm.mediator);
                    if (Template.GetTemplateLevel((TemplateNode)ob) == Enums.TemplateLevel.Field)
                    {
                        Size size = template.GetFieldFootprint((TemplateNode)ob);
                        Rectangle rectangle = new Rectangle(MousePosition, size);
                        rectangle = PagePanel.RectangleToClient(rectangle);
                        if (SelectedFieldsFootprint == null)
                        {
                            SelectedFieldsFootprint = new TemplateFootprint(rectangle);
                        }

                        Point point = PagePanel.PointToClient(new Point(e.X, e.Y));
                        SelectedFieldsFootprint.Left = point.X;
                        SelectedFieldsFootprint.Top = point.Y;
                    }
                }
            }
            else if (e.Data.GetData("DraggedTreeNode") != null)
            {
                e.Effect = DragDropEffects.Move;
            }
        }