Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
OriginalGriff21-Dec-18 23:23
mveOriginalGriff21-Dec-18 23:23 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
_Q12_21-Dec-18 23:28
_Q12_21-Dec-18 23:28 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
_Q12_21-Dec-18 23:28
_Q12_21-Dec-18 23:28 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
OriginalGriff21-Dec-18 23:52
mveOriginalGriff21-Dec-18 23:52 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
_Q12_22-Dec-18 4:37
_Q12_22-Dec-18 4:37 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
OriginalGriff22-Dec-18 4:51
mveOriginalGriff22-Dec-18 4:51 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
_Q12_22-Dec-18 5:43
_Q12_22-Dec-18 5:43 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
_Q12_22-Dec-18 6:08
_Q12_22-Dec-18 6:08 
This is the working code so far. I will experiment with it further and I will update with new problems on the way. Also, you update it too if you feel you can help it more.
I was thinking on using refractor and actually look inside original mouse move event to see how they did it there, and copy it into my class... but is planned for the future.
Now, i am happy. It's some work to do but i get the transparency of the objects !
//Class
    public class Human
    {
        private string _Name = "none";
        public string Name { get { return _Name; } set { _Name = value; } }
        public Point Location { get; set; }
        public Size Size { get; set; }

        public void Paint(Graphics g)
        {
            g.DrawString(Name, new Font("Arial", 9), new SolidBrush(Color.Black), Location.X, Location.Y - 15);
            g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(Location.X, Location.Y, Size.Width, Size.Height));
        }

        public bool Contains(Point point)
        {
            if (point.X >= Location.X & point.X <= Location.X + Size.Width &
                 point.Y >= Location.Y & point.Y <= Location.Y + Size.Height)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

    }



    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            DoubleBuffered = true; //from the Invalidate() in MouseMove
//i wish i didnt use DoubleBuffered, but it does its job for the moment. 
            female.Name = "Alina";
            female.Location = new Point(20, 20);
            female.Size = new Size(30, 30);

           //female.MouseEnter += new EventHandler(female_MouseEnter);
        }

        Human female = new Human();
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            female.Paint(e.Graphics);
        }

        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            if (female.Contains(e.Location))
            {
                female.Name = "Gaga";
            }
            else
            {
                female.Name = "Alina";
            }
            Invalidate();
        }

    }

GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
_Q12_22-Dec-18 6:16
_Q12_22-Dec-18 6:16 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
OriginalGriff22-Dec-18 6:19
mveOriginalGriff22-Dec-18 6:19 
GeneralRe: Properties does not change in custom MouseEnter event incomplete implementation. Pin
_Q12_22-Dec-18 6:41
_Q12_22-Dec-18 6:41 
Questionhow to hide a column in excel through C# Pin
Member 1204584621-Dec-18 0:39
Member 1204584621-Dec-18 0:39 
AnswerRe: how to hide a column in excel through C# Pin
jschell23-Dec-18 7:49
jschell23-Dec-18 7:49 
QuestionENUM value in method Pin
Member 1409081521-Dec-18 0:16
Member 1409081521-Dec-18 0:16 
AnswerRe: ENUM value in method Pin
OriginalGriff21-Dec-18 0:32
mveOriginalGriff21-Dec-18 0:32 
GeneralRe: ENUM value in method Pin
Member 1409081521-Dec-18 0:50
Member 1409081521-Dec-18 0:50 
GeneralRe: ENUM value in method Pin
OriginalGriff21-Dec-18 1:01
mveOriginalGriff21-Dec-18 1:01 
GeneralRe: ENUM value in method Pin
Richard Deeming21-Dec-18 1:13
mveRichard Deeming21-Dec-18 1:13 
QuestionKill execute function Pin
MatrixRatrix20-Dec-18 5:50
MatrixRatrix20-Dec-18 5:50 
AnswerRe: Kill execute function Pin
Richard Deeming20-Dec-18 6:01
mveRichard Deeming20-Dec-18 6:01 
GeneralRe: Kill execute function Pin
MatrixRatrix20-Dec-18 7:09
MatrixRatrix20-Dec-18 7:09 
GeneralRe: Kill execute function Pin
Richard Deeming20-Dec-18 8:09
mveRichard Deeming20-Dec-18 8:09 
GeneralRe: Kill execute function Pin
OriginalGriff20-Dec-18 8:20
mveOriginalGriff20-Dec-18 8:20 
AnswerRe: Kill execute function Pin
OriginalGriff20-Dec-18 6:06
mveOriginalGriff20-Dec-18 6:06 
Questionc# listview Update problem Pin
MatrixRatrix20-Dec-18 2:29
MatrixRatrix20-Dec-18 2:29 

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.