Translate() public method

public Translate ( float dx, float dy ) : bool
dx float
dy float
return bool
コード例 #1
0
        public Window(double x, double y, double width, double height, string lable)
        {
            m_X      = x;
            m_Y      = y;
            m_width  = width;
            m_height = height;
            Affine transform = GetTransform();

            transform.Translate(x, y);
            SetTransform(transform);
            caption                  = new TextWidget(lable, 0, height - 15, 7);
            caption.TextColor        = new RGBA_Bytes(255, 255, 255);
            closeButton              = new ButtonWidget(width - 15, height - 15, "X", 7, 1, 1, 5);
            closeButton.ButtonClick += CloseEvent;
            AddChild(caption);
            AddChild(closeButton);

            TextPadding  = 1;
            BorderWidth  = 2;
            BorderRadius = 5;

            double totalExtra = BorderWidth + TextPadding;

            m_Bounds.Left   = x - totalExtra;
            m_Bounds.Bottom = y - totalExtra;
            m_Bounds.Right  = x + width + totalExtra;
            m_Bounds.Top    = y + height + totalExtra;
        }
コード例 #2
0
        public ButtonWidget(double x, double y, string lable,
                            double textHeight, double textPadding, double borderWidth, double borderRadius)
        {
            m_X = x;
            m_Y = y;
            Affine transform = GetTransform();

            transform.Translate(x, y);
            SetTransform(transform);
            m_ButtonText = new TextWidget(lable, 0, 0, textHeight);
            AddChild(m_ButtonText);

            TextPadding  = textPadding;
            BorderWidth  = borderWidth;
            BorderRadius = borderRadius;

            double totalExtra = BorderWidth + TextPadding;

            m_Bounds.Left   = x - totalExtra;
            m_Bounds.Bottom = y - totalExtra;
            m_Bounds.Right  = x + m_ButtonText.Width + totalExtra;
            m_Bounds.Top    = y + m_ButtonText.Height + totalExtra;
        }
コード例 #3
0
        override public void OnMouseMove(MouseEventArgs mouseEvent)
        {
            double x = mouseEvent.X;
            double y = mouseEvent.Y;

            if (mouseEvent.Button == MouseButtons.Left && IsOverTitleBar(x, y))
            {
                double dx         = mouseX - x;
                double dy         = mouseY - y;
                double totalExtra = BorderWidth + TextPadding;
                Affine transform  = GetTransform();
                transform.Translate(-dx, -dy);
                SetTransform(transform);
                m_Bounds.Left     -= dx;
                m_Bounds.Right    -= dx;
                m_Bounds.Top      -= dy;
                m_Bounds.Bottom   -= dy;
                mouseEvent.Handled = true;
            }
            mouseX = x;
            mouseY = y;
            Invalidate();
        }
コード例 #4
0
    public virtual bool TranslateTransform(int dx, int dy)
    {
        // Get the current transform
        XFORM oldTransform = GetWorldTransform();

        // Put it into an Affine so that we can change it
        Affine anAffine = new Affine();
        anAffine.fMatrix = oldTransform;
        anAffine.Translate((float)dx, (float)dy);

        // Set it back on the graph port
        bool result = SetWorldTransform(anAffine.fMatrix);

        return result;
    }