public void _coordsXValue_LostFocus(object sender, EventArgs e)
        {
            if (constant)
            {
                return;
            }
            if (!XTextChanged)
            {
                return;
            }
            XTextChanged = false;
            TextBox textBox = (TextBox)sender;
            int     x;

            if (!int.TryParse(textBox.Text, out x))
            {
                textBox.Text = Left.ToString();
                return;
            }
            x += parentTabPage.GetDesktopPanel().AutoScrollPosition.X;
            if (x < parentTabPage.GetDesktopPanel().AutoScrollPosition.X || x > parentTabPage.MaxX() - Size.Width)
            {
                textBox.Text = Left.ToString();
                return;
            }
            if (x != Location.X)
            {
                parentTabPage.SaveUndoAction(new ActionStack(this, 1, Location));
                Location = new Point(x, Location.Y);
                parentTabPage.GetDesktopPanel().Refresh();
            }
        }
Esempio n. 2
0
        private void VisualizeDrawing(string element)
        {
            if (element == "")
            {
                return;
            }
            string type = GetClearField(element, "type");

            switch (type)
            {
            case "bitmap":
            {
                InnerBitmap bitmap = new InnerBitmap(parentTabPage);
                int         x;
                Expression  e = new Expression(GetClearField(element, "x"));
                if (!int.TryParse(e.Evaluate().ToString().Split(',')[0], out x))
                {
                    x = parentTabPage.MaxX() / 2;
                }
                x += parentTabPage.GetDesktopPanel().AutoScrollPosition.X;
                int y;
                e = new Expression(GetClearField(element, "y"));
                if (!int.TryParse(e.Evaluate().ToString().Split(',')[0], out y))
                {
                    y = parentTabPage.MaxY() / 2;
                }
                y += parentTabPage.GetDesktopPanel().AutoScrollPosition.Y;
                float scale;
                if (!float.TryParse(GetClearField(element, "scale"), NumberStyles.Any, CultureInfo.InvariantCulture, out scale))
                {
                    scale = 1;
                }
                string imageName = GetClearField(element, "bitmap");
                if (imageName == "")
                {
                    imageName = bitmap.imageName.Split('.')[0];
                }
                bitmap.Apply(x, y, scale, imageName);
                bitmap.elementName = bitmap.imageName;
                parentTabPage.GetDesktopPanel().Controls.Add(bitmap);
                break;
            }

            default:

                break;
            }
        }
        private static void MoveControl(object container, MouseEventArgs e)
        {
            InnerControl obj = (InnerControl)container;

            if (obj.hidden || obj.constant)
            {
                return;
            }
            if (!moving && !scaling)
            {
                UpdateMousePosition(obj, e.Location);
                UpdateCursor(obj);
            }
            else if (moving)
            {
                Console.WriteLine(parent.aligment);
                int x    = (e.X - cursorOrigin.X) + obj.Left;
                int y    = (e.Y - cursorOrigin.Y) + obj.Top;
                int _x   = parent.GetDesktopPanel().AutoScrollPosition.X;
                int _y   = parent.GetDesktopPanel().AutoScrollPosition.Y;
                int maxx = parent.MaxX();
                int maxy = parent.MaxY();
                if (x + obj.Width > maxx || x - _x < 0)
                {
                    return;
                }
                if (y + obj.Height > maxy || y - _y < 0)
                {
                    return;
                }
                if (parent.aligment)
                {
                    controlAligment.TryToMove(obj, new Point(x, y));
                }
                else
                {
                    obj.Location = new Point(x, y);
                }
            }
            else if (scaling)
            {
                if (leftEdge)
                {
                    if (upperEdge)
                    {
                        /*int x = obj.Location.X - cursorOrigin.X + e.X;
                         * if (x < 0 || x > parent.X - obj.Size.Width)return;
                         * int y = obj.Location.Y - cursorOrigin.X + e.X;
                         * if (y < 0 || y > parent.Y - obj.Size.Y)return;
                         * obj.Location = new Point(x, y);
                         * obj.ResizeControl(obj.Width + cursorOrigin.X - e.X);*/
                    }
                    else if (bottomEdge)
                    {
                        /*int x = obj.Location.X - cursorOrigin.X + e.X;
                         * if (x < 0 || x > parent.X - obj.Size.Width) return;
                         * int y = obj.Location.Y;
                         * obj.Location = new Point(x, y);
                         * obj.ResizeControl(obj.Width + cursorOrigin.X - e.X);*/
                    }
                    else
                    {
                        //Не нужен
                    }
                }
                else if (rightEdge)
                {
                    if (upperEdge)
                    {
                        /*int x = obj.Location.X;
                         * int y = obj.Location.Y - cursorOrigin.Y + e.Y;
                         * if (y < 0 || y > parent.Y - obj.Size.Width) return;
                         * obj.Location = new Point(x, y);
                         * obj.ResizeControl(obj.Height + cursorOrigin.Y - e.Y);*/
                    }
                    else if (bottomEdge)
                    {
                        if (cursorLastPos != e.Location)
                        {
                            int x = e.X - cursorOrigin.X + startSize.Width;
                            int y = e.Y - cursorOrigin.Y + startSize.Height;
                            //Console.WriteLine("{0} - {1}", x, y);
                            obj.ResizeControl(longestSide, longestSide == 'x' ?x: y);
                            cursorLastPos = e.Location;
                        }
                    }
                    else
                    {
                        //Не нужен
                    }
                }
                else if (upperEdge || bottomEdge)
                {
                    //Не нужен
                }
                else
                {
                }
            }
        }