예제 #1
0
        private void GotSelection()
        {
            OnLosesSelection(this, new EventArgs());

            if (isSelected == false)
            {
                SuspendLayout();

                Size             = new Size(Width + 14, Height + 14);
                Location         = new Point(Left - 7, Top - 7);
                control.Location = new Point(7, 7);

                isSelected = true;

                ResumeLayout();

                if (control is PictureControl || control is GroupBox)
                {
                    SendToBack();
                }
                else
                {
                    BringToFront();
                }

                if (control is PictureControl)
                {
                    PictureControl picControl = (PictureControl)control;
                    picControl.Redraw();
                }

                if (SelectionChanged != null)
                {
                    SelectionChanged(xmlNode);
                }
            }
        }
예제 #2
0
        private void AddBackgroundBitmaps(DesignerForm newDialog, XmlNodeList bitmaps)
        {
            PictureControl pictureCtrl = null;
            ArrayList allPictureControls = new ArrayList();

            foreach (XmlNode bitmap in bitmaps)
            {
                try
                {
                    string binaryId = GetTextFromXmlElement(bitmap);

                    Bitmap bmp = null;
                    try
                    {
                        using (Stream imageStream = GetBinaryStream(binaryId))
                        {
                            bmp = new Bitmap(imageStream);
                        }
                    }
                    catch
                    {
                    }

                    pictureCtrl = new PictureControl(bmp, allPictureControls);
                    allPictureControls.Add(pictureCtrl);

                    SetControlAttributes(pictureCtrl, bitmap);

                    newDialog.AddControl(bitmap, pictureCtrl);
                }
                catch
                {
                }
            }

            if (pictureCtrl != null)
            {
                pictureCtrl.Draw();
            }
        }
예제 #3
0
        protected void OnMove(Point currentPoint)
        {
            if (isMoving)
            {
                bool needsRedraw = false;
                if (Math.Abs(currentPoint.X - isPositionPoint.X) >= snapToGrid)
                {
                    if (snapToGrid <= 1)
                    {
                        Left = Left + currentPoint.X - isPositionPoint.X;
                        isPositionPoint.X = currentPoint.X;
                    }
                    else
                    {
                        Left = (((Left + 7 + currentPoint.X - isPositionPoint.X) / snapToGrid) * snapToGrid) - 7;
                        isPositionPoint.X = currentPoint.X - ((Left + 7 + currentPoint.X - isPositionPoint.X) % snapToGrid);
                    }
                    needsRedraw = true;
                }

                if (snapToGrid <= 1 || Math.Abs(currentPoint.Y - isPositionPoint.Y) >= snapToGrid)
                {
                    if (snapToGrid <= 1)
                    {
                        Top = Top + currentPoint.Y - isPositionPoint.Y;
                        isPositionPoint.Y = currentPoint.Y;
                    }
                    else
                    {
                        Top = (((Top + 7 + currentPoint.Y - isPositionPoint.Y) / snapToGrid) * snapToGrid) - 7;
                        isPositionPoint.Y = currentPoint.Y - ((Top + 7 + currentPoint.Y - isPositionPoint.Y) % snapToGrid);
                    }
                    needsRedraw = true;
                }

                if (needsRedraw && control is PictureControl)
                {
                    PictureControl picControl = (PictureControl)control;
                    picControl.Redraw();
                }
            }
            else if (sizingDirection != SizingDirection.None)
            {
                Point snapToGridPoint = new Point(currentPoint.X, currentPoint.Y);
                bool  needsRedraw     = false;
                if (snapToGrid <= 1 || Math.Abs(currentPoint.X - isPositionPoint.X) >= snapToGrid)
                {
                    snapToGridPoint.X = currentPoint.X;
                    needsRedraw       = true;
                }

                if (snapToGrid <= 1 || Math.Abs(currentPoint.Y - isPositionPoint.Y) >= snapToGrid)
                {
                    snapToGridPoint.Y = currentPoint.Y;
                    needsRedraw       = true;
                }

                if (needsRedraw)
                {
                    ResizeControl(snapToGridPoint);
                    isPositionPoint = snapToGridPoint;

                    if (control is PictureControl)
                    {
                        PictureControl picControl = (PictureControl)control;
                        picControl.Redraw();
                    }
                }
            }
            else
            {
                CheckCursor(currentPoint);
            }
        }