Click here to Skip to main content
14,692,100 members
Home » Discussions » C#
   

C#

 
AnswerRe: Can not compare a file and same file stored in mysql - sha256 Pin
Eddy Vluggen30-Apr-20 7:34
professionalEddy Vluggen30-Apr-20 7:34 
QuestionCompare string time to timer time (noobie) Pin
Member 1481029228-Apr-20 6:36
MemberMember 1481029228-Apr-20 6:36 
AnswerRe: Compare string time to timer time (noobie) Pin
Gerry Schmitz28-Apr-20 7:48
mveGerry Schmitz28-Apr-20 7:48 
QuestionResize and move a drawn rectangle in win forms Pin
Member 1223285027-Apr-20 13:23
MemberMember 1223285027-Apr-20 13:23 
AnswerRe: Resize and move a drawn rectangle in win forms Pin
Luc Pattyn27-Apr-20 14:17
sitebuilderLuc Pattyn27-Apr-20 14:17 
GeneralRe: Resize and move a drawn rectangle in win forms Pin
Member 1223285027-Apr-20 20:38
MemberMember 1223285027-Apr-20 20:38 
GeneralRe: Resize and move a drawn rectangle in win forms Pin
Luc Pattyn28-Apr-20 5:50
sitebuilderLuc Pattyn28-Apr-20 5:50 
GeneralRe: Resize and move a drawn rectangle in win forms Pin
Member 1223285028-Apr-20 18:56
MemberMember 1223285028-Apr-20 18:56 
I followed your steps, of course without using a class, now the move function determines whether to draw a new rectangle or move it, but the moving action is not happening. Resizing we will back to it later:
public partial class Form3 : Form
{
    Rectangle rect;
    Point StartXY;
    Point EndXY;

    int x = 0;
    int y = 0;
    int height = 0;
    int width = 0;

    bool m_mouseDown = false;
    bool m_movingRect = false;


    Pen rectPen = new Pen(Color.Red, 1);

    public Form3()
    {
        InitializeComponent();
        this.DoubleBuffered = true;
    }

    private void pictureBox1_Paint(object sender, PaintEventArgs e)
    {
        Graphics gObj = e.Graphics;

        rect = new Rectangle(x, y, height, width);
        rectPen.DashStyle = DashStyle.Dash;
        gObj.DrawRectangle(rectPen, rect);
    }

    private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
    {
        m_mouseDown = true;

        // Moving rectangle
        if (rect.Contains(e.Location))
        {
            m_movingRect = true;
            Console.WriteLine("m_mouseDown");
        }

        StartXY = e.Location;
    }

    private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
    {
        if (rect.Contains(e.Location))
            this.Cursor = Cursors.SizeAll;
        else
            this.Cursor = Cursors.Default;

        if (m_mouseDown && rect.Contains(e.Location))
        {
            rect.X += e.X - StartXY.X;    // <---- it is calculated correctly but doesn't update rectangle position
            rect.Y += e.Y - StartXY.Y;


            StartXY = e.Location;
            Console.WriteLine("pictureBox1_MouseMove StartXY " + StartXY.X);
            Console.WriteLine("pictureBox1_MouseMove StartXY " + StartXY.Y);
            Console.WriteLine("pictureBox1_MouseMove rect " + rect.X);
            Console.WriteLine("pictureBox1_MouseMove rect " + rect.Y);
        }

        if (m_mouseDown && !rect.Contains(e.Location))
        {
            EndXY = e.Location;

            x = Math.Min(StartXY.X, EndXY.X);
            y = Math.Min(StartXY.Y, EndXY.Y);

            height = Math.Abs(StartXY.X - EndXY.X);
            width = Math.Abs(StartXY.Y - EndXY.Y);
            //Console.WriteLine("pictureBox1_MouseMove XXXX: " + " --- " + e.X.ToString());
            //Console.WriteLine("pictureBox1_MouseMove YYYY: " + " --- " + e.Y.ToString());
        }

        Invalidate(true);
    }

    private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
    {
        if (!m_movingRect)
        {
            EndXY = e.Location;
        }

        m_mouseDown = false;
        m_movingRect = false;

        Invalidate();
    }
}

GeneralRe: Resize and move a drawn rectangle in win forms Pin
Luc Pattyn29-Apr-20 3:30
sitebuilderLuc Pattyn29-Apr-20 3:30 
QuestionDate compare Pin
Carlos5827-Apr-20 11:42
MemberCarlos5827-Apr-20 11:42 
AnswerRe: Date compare Pin
Luc Pattyn27-Apr-20 12:00
sitebuilderLuc Pattyn27-Apr-20 12:00 
GeneralRe: Date compare Pin
Carlos5827-Apr-20 13:31
MemberCarlos5827-Apr-20 13:31 
GeneralRe: Date compare Pin
Luc Pattyn27-Apr-20 13:48
sitebuilderLuc Pattyn27-Apr-20 13:48 
GeneralRe: Date compare Pin
Carlos5828-Apr-20 3:19
MemberCarlos5828-Apr-20 3:19 
GeneralRe: Date compare Pin
Luc Pattyn28-Apr-20 3:24
sitebuilderLuc Pattyn28-Apr-20 3:24 
SuggestionRe: Date compare Pin
Richard Deeming28-Apr-20 1:40
mveRichard Deeming28-Apr-20 1:40 
AnswerRe: Date compare Pin
Carlos5828-Apr-20 3:23
MemberCarlos5828-Apr-20 3:23 
QuestionRename files in WinScp Directory using C# Pin
Sriram Valluri27-Apr-20 2:13
MemberSriram Valluri27-Apr-20 2:13 
AnswerRe: Rename files in WinScp Directory using C# Pin
ZurdoDev27-Apr-20 2:21
mveZurdoDev27-Apr-20 2:21 
GeneralRe: Rename files in WinScp Directory using C# Pin
Sriram Valluri27-Apr-20 3:15
MemberSriram Valluri27-Apr-20 3:15 
GeneralRe: Rename files in WinScp Directory using C# Pin
ZurdoDev27-Apr-20 3:27
mveZurdoDev27-Apr-20 3:27 
AnswerRe: Rename files in WinScp Directory using C# Pin
Jin Vincent Necesario27-Apr-20 3:36
professionalJin Vincent Necesario27-Apr-20 3:36 
GeneralRe: Rename files in WinScp Directory using C# Pin
Sriram Valluri27-Apr-20 9:07
MemberSriram Valluri27-Apr-20 9:07 
AnswerRe: Rename files in WinScp Directory using C# Pin
Luc Pattyn27-Apr-20 9:21
sitebuilderLuc Pattyn27-Apr-20 9:21 
GeneralRe: Rename files in WinScp Directory using C# Pin
Sriram Valluri27-Apr-20 22:21
MemberSriram Valluri27-Apr-20 22:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.