Beispiel #1
0
        public void SetNodeText(ICustomPaint theObject, TreeNode theNode)
        {
            if (theObject is TextField)
            {
                TextField txtField = (TextField)theObject;
                string    theText  = txtField.Text.Length > 25 ? txtField.Text.Substring(0, 25) + "..." : txtField.Text;
                theNode.Name = txtField.Name;
                theNode.Text = "Text field [" + theText + "]";
            }
            else if (theObject is daReport.PictureBox)
            {
                theNode.Text = "Picture";
            }
            else if (theObject is daReport.ChartBox)
            {
                ChartBox chartBox = (ChartBox)theObject;
                theNode.Text = "Chart [" + chartBox.Name + "]";
            }
            else if (theObject is daReport.StyledTable)
            {
                StyledTable styledTable = (StyledTable)theObject;

                if (styledTable.DataSource != null)
                {
                    theNode.Text = "Styled table [" + styledTable.DataSource + "]";
                }
                else
                {
                    theNode.Text = "Styled table";
                }
            }
        }
Beispiel #2
0
        private void CalculateStretchOffsets(int mouseX, int mouseY, ref int xOffset, ref int yOffset, RESIZE_BORDER border)
        {
            ICustomPaint theObject = moveReferenceObject;

            switch (border)
            {
            case RESIZE_BORDER.TOP:
                yOffset = mouseY - theObject.Y;
                xOffset = 0;
                break;

            case RESIZE_BORDER.BOTTOM:
                yOffset = mouseY - (theObject.Y + theObject.Height);
                xOffset = 0;
                break;

            case RESIZE_BORDER.LEFT:
                yOffset = 0;
                xOffset = mouseX - theObject.X;
                break;

            case RESIZE_BORDER.RIGHT:
                yOffset = 0;
                xOffset = mouseX - (theObject.X + theObject.Width);
                break;

            default:
                yOffset = 0;
                xOffset = 0;
                break;
            }
        }
Beispiel #3
0
        public void DesignPane_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            if (e.Control)
            {
                this.mControlPressed = true;
            }

            if (selectedObjects.Count > 0)
            {
                for (int i = 0; i < selectedObjects.Count; i++)
                {
                    ICustomPaint theObject = (ICustomPaint)selectedObjects[i];

                    if (e.KeyCode == Keys.Down && e.Modifiers == Keys.Control)
                    {
                        trackerImage.Dispose();
                        trackerImage = (Bitmap)drawingImage.Clone();
                        MoveSelection(theObject, theObject.X, theObject.Y + 1);
                        PaintImage(trackerImage);
                        shouldRepaint = true;
                    }
                    else if (e.KeyCode == Keys.Up && e.Modifiers == Keys.Control)
                    {
                        trackerImage.Dispose();
                        trackerImage = (Bitmap)drawingImage.Clone();
                        MoveSelection(theObject, theObject.X, theObject.Y - 1);
                        PaintImage(trackerImage);
                        shouldRepaint = true;
                    }
                    else if (e.KeyCode == Keys.Left && e.Modifiers == Keys.Control)
                    {
                        trackerImage.Dispose();
                        trackerImage = (Bitmap)drawingImage.Clone();
                        MoveSelection(theObject, theObject.X - 1, theObject.Y);
                        PaintImage(trackerImage);
                        shouldRepaint = true;
                    }
                    else if (e.KeyCode == Keys.Right && e.Modifiers == Keys.Control)
                    {
                        trackerImage.Dispose();
                        trackerImage = (Bitmap)drawingImage.Clone();
                        MoveSelection(theObject, theObject.X + 1, theObject.Y);
                        PaintImage(trackerImage);
                        shouldRepaint = true;
                    }
                    else
                    {
                        return;
                    }
                }

                if (OnMoving != null)
                {
                    OnMoving((ICustomPaint)selectedObjects[selectedObjects.Count - 1]);
                }
            }
        }
Beispiel #4
0
        private void MoveSelection(ICustomPaint theElement, int xOrigin, int yOrigin)
        {
            if (theElement.HorizontalAlignment == ICustomPaint.HorizontalAlignmentTypes.None)
            {
                theElement.X = xOrigin;
            }

            if (theElement.VerticalAlignment == ICustomPaint.VerticalAlignmentTypes.None)
            {
                theElement.Y = yOrigin;
            }

            selectionRectangle = new TrackerRectangle(theElement.GetRegion(), theElement.HorizontalAlignment, theElement.VerticalAlignment);
            selectionRectangle.DrawSelectionTrackers((Bitmap)trackerImage);
        }
Beispiel #5
0
 public XButton(ICustomPaint obj, string title, RectangleF coord)
 {
     Obj    = obj;
     Width  = (int)coord.Width;
     Height = (int)coord.Height;
     Left   = (int)coord.X;
     Top    = (int)coord.Y;
     Title  = title;
     Colors = new Hashtable();
     Colors.Add(Act.Default, Color.FromArgb(0, 127, 255));
     Colors.Add(Act.Up, Color.FromArgb(0, 255, 255));
     Colors.Add(Act.Down, Color.FromArgb(0, 0, 0));
     Offsets.Add(Act.Default, new PointF(0, 0));
     Offsets.Add(Act.Up, new PointF(0, 0));
     Offsets.Add(Act.Down, new PointF(-2, -2));
     CurAct = Act.Default;
 }
Beispiel #6
0
        public void SelectObject(ICustomPaint theSelection)
        {
            if (theSelection != null)
            {
                selectedObject     = theSelection;
                selectionRectangle = new TrackerRectangle(theSelection.GetRegion(), theSelection.HorizontalAlignment, theSelection.VerticalAlignment);

                trackerImage = (Bitmap)drawingImage.Clone();
                selectionRectangle.DrawSelectionTrackers((Bitmap)trackerImage);
                PaintImage(trackerImage);
            }
            else
            {
                selectedObject     = null;
                selectionRectangle = null;
                PaintImage(drawingImage);
            }
        }
Beispiel #7
0
        private void PaintSelection(Graphics g)
        {
            if (selectionRectangle == null)
            {
                return;
            }

            trackerImage.Dispose();
            trackerImage = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height);

            foreach (ICustomPaint CurrentObject in this.selectedObjects)
            {
                ICustomPaint obj = (ICustomPaint)CurrentObject;
                selectionRectangle = new TrackerRectangle(obj.GetRegion(), obj.HorizontalAlignment, obj.VerticalAlignment);
                selectionRectangle.DrawSelectionTrackers((Bitmap)trackerImage);
            }

            PaintImage(trackerImage);
        }
Beispiel #8
0
        public void UpdateSelection(ICustomPaint theSelection, int action)
        {
            if (theSelection != null)
            {
                if (action == 0)
                {
                    selectionRectangle = new TrackerRectangle(theSelection.GetRegion(), theSelection.HorizontalAlignment, theSelection.VerticalAlignment);

                    trackerImage = (Bitmap)drawingImage.Clone();
                    selectionRectangle.DrawSelectionTrackers((Bitmap)trackerImage);
                    PaintImage(trackerImage);
                    selectedObjects.Clear();
                    selectedObjects.Add(theSelection);
                }
                else if (action == 1)
                {
                    selectionRectangle = new TrackerRectangle(theSelection.GetRegion(), theSelection.HorizontalAlignment, theSelection.VerticalAlignment);

                    selectionRectangle.DrawSelectionTrackers((Bitmap)trackerImage);
                    PaintImage(trackerImage);
                    selectedObjects.Add(theSelection);
                }
                else if (action == 2)
                {
                    selectedObjects.Remove(theSelection);
                    DoPaint();
                }
            }
            else
            {
                selectedObjects.Clear();
                selectionRectangle = null;
                trackerImage       = (Bitmap)drawingImage.Clone();
                PaintImage(drawingImage);
            }
        }
Beispiel #9
0
        public void DesignPane_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (mouseDown)
            {
                if (mMouseMode == MOUSE_MODE.SELECTED)
                {
                    if (mBorder != RESIZE_BORDER.NONE)
                    {
                        int xOffset = 0;
                        int yOffset = 0;
                        CalculateStretchOffsets(e.X, e.Y, ref xOffset, ref yOffset, mBorder);

                        trackerImage.Dispose();
                        trackerImage = (Bitmap)drawingImage.Clone();

                        for (int i = 0; i < selectedObjects.Count; i++)
                        {
                            ICustomPaint theObject = (ICustomPaint)selectedObjects[i];

                            switch (mBorder)
                            {
                            case RESIZE_BORDER.TOP:
                                if (theObject.Height - yOffset >= 0)
                                {
                                    if (theObject.VerticalAlignment == ICustomPaint.VerticalAlignmentTypes.None)
                                    {
                                        theObject.Height -= yOffset;
                                        theObject.Y      += yOffset;
                                    }
                                    else if (theObject.VerticalAlignment == ICustomPaint.VerticalAlignmentTypes.Bottom || selectedObject.VerticalAlignment == ICustomPaint.VerticalAlignmentTypes.Middle)
                                    {
                                        theObject.Y += yOffset;
                                    }
                                }
                                break;

                            case RESIZE_BORDER.RIGHT:
                                if (theObject.Width + xOffset >= 0)
                                {
                                    theObject.Width += xOffset;
                                }
                                break;

                            case RESIZE_BORDER.BOTTOM:
                                if (theObject.Height + yOffset >= 0)
                                {
                                    theObject.Height += yOffset;
                                }
                                break;

                            case RESIZE_BORDER.LEFT:
                                if (theObject.Width - xOffset >= 0)
                                {
                                    if (theObject.HorizontalAlignment == ICustomPaint.HorizontalAlignmentTypes.None)
                                    {
                                        theObject.Width -= xOffset;
                                        theObject.X     += xOffset;
                                    }
                                    else if (theObject.HorizontalAlignment == ICustomPaint.HorizontalAlignmentTypes.Right || theObject.HorizontalAlignment == ICustomPaint.HorizontalAlignmentTypes.Center)
                                    {
                                        theObject.X += xOffset;
                                    }
                                }
                                break;
                            }

                            TrackerRectangle selRectangle = new TrackerRectangle(theObject.GetRegion(), theObject.HorizontalAlignment, theObject.VerticalAlignment);
                            selRectangle.DrawSelectionTrackers((Bitmap)trackerImage);
                        }


                        PaintImage(trackerImage);
                        shouldRepaint = true;
                    }
                    else
                    {
                        if (Math.Abs(e.X - ptStart.X) > 0 || Math.Abs(e.Y - ptStart.Y) > 0)
                        {
                            trackerImage.Dispose();
                            trackerImage = (Bitmap)drawingImage.Clone();

                            for (int i = 0; i < selectedObjects.Count; i++)
                            {
                                ICustomPaint theObject = (ICustomPaint)selectedObjects[i];
                                MoveSelection(theObject, theObject.X + e.X - ptStart.X, theObject.Y + e.Y - ptStart.Y);
                            }

                            PaintImage(trackerImage);
                            ptStart       = new Point(e.X, e.Y);
                            shouldRepaint = true;
                        }
                    }

                    if (OnMoving != null && selectedObjects.Count > 0)
                    {
                        OnMoving((ICustomPaint)selectedObjects[selectedObjects.Count - 1]);
                    }
                }
            }
            else
            {
                if (selectedObjects.Count > 0)
                {
                    for (int i = 0; i < selectedObjects.Count; i++)
                    {
                        ICustomPaint theObject = (ICustomPaint)selectedObjects[i];
                        Rectangle    theArea   = theObject.GetRegion();
                        theArea.Offset(-TrackerRectangle.m_nOffset, -TrackerRectangle.m_nOffset);
                        theArea.Inflate(2 * TrackerRectangle.m_nOffset, 2 * TrackerRectangle.m_nOffset);

                        if (theArea.Contains(e.X, e.Y))
                        {
                            TrackerRectangle tmp = new TrackerRectangle(theObject.GetRegion(), theObject.HorizontalAlignment, theObject.VerticalAlignment);
                            int nResult          = 0;
                            this.Cursor         = tmp.CursorCheck(new Point(e.X, e.Y), ref nResult);
                            this.mBorder        = (RESIZE_BORDER)nResult;
                            moveReferenceObject = (ICustomPaint)selectedObjects[i];
                            return;
                        }
                    }
                }
                this.Cursor = Cursors.Default;
            }
        }