Click here to Skip to main content
15,887,683 members
Home / Discussions / C#
   

C#

 
GeneralRe: How You Check Data In DataSet? Pin
Christian Graus21-Jun-09 0:35
protectorChristian Graus21-Jun-09 0:35 
GeneralRe: How You Check Data In DataSet? Pin
noamtzu21-Jun-09 0:44
noamtzu21-Jun-09 0:44 
GeneralRe: How You Check Data In DataSet? Pin
Rajesh R Subramanian21-Jun-09 6:03
professionalRajesh R Subramanian21-Jun-09 6:03 
GeneralRe: How You Check Data In DataSet? Pin
EliottA22-Jun-09 2:49
EliottA22-Jun-09 2:49 
QuestionStrange Dataset problem! [modified] Pin
Muammar©20-Jun-09 22:39
Muammar©20-Jun-09 22:39 
AnswerRe: Strange Dataset problem! Pin
Mycroft Holmes20-Jun-09 23:15
professionalMycroft Holmes20-Jun-09 23:15 
AnswerSolved! Pin
Muammar©20-Jun-09 23:24
Muammar©20-Jun-09 23:24 
QuestionGDI+, problem with Invalidate() method Pin
cppwxwidgetsss20-Jun-09 21:16
cppwxwidgetsss20-Jun-09 21:16 
Hi,
I have a form that is designed by GDI+, it has some buttons(images)
I want to change the button when the mouse is over the button
so I handled the MouseMove event with the OnMouseMove and I calculated if the mouse is in the button region , after that if it was, I call the method Invalidate() so that the button should be repainted but the problem is that the Program runs very slowly, and you can see the mouse movement in slow motion, when I comment the Invaliate() method in the code, everything is good, I also checked the code with an empty method of OnPaint() so that the problem is not because of OnPaint() but Invalidate()
by the way i am using the Double Buffred Form
I am confused
somebody help me
thank you
P.S:
here is the whole code:
From1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace paintImage
{
    enum ButtonState
    {
        NotSelected,
        Blue,
        Green

    }
    public partial class Form1 : Form
    {
        ButtonState Language = ButtonState.NotSelected;
        private bool MouseOutLanguageTraining = false;
        private bool LanguageTraining = false;
        private bool MouseOnLangugeTraining = false;
        Rectangle LanguageButtonPosition = new Rectangle(774, 617, 218, 42);
        //private Point MouseClickPosition;
        //private readonly Brush TextBrush = Brushes.White;
        //private readonly Font ButtonFont = new Font("alefba", 18,FontStyle.Bold);
        
        readonly Image piccy;
        readonly Image ButtonSelectedBlue;
        readonly Image ButtonSelectedGreen;
        readonly Image ButtonNotSelected;

        private readonly Point[] piccyBounds;
        private readonly Point[] LanguageButtonBounds;
        public Form1()
        {
            InitializeComponent();
            piccy = Image.FromFile(@"C:\pics\page12.png");
            ButtonNotSelected = Image.FromFile(@"C:\Pics\Button Not Selected.png");
            ButtonSelectedBlue = Image.FromFile(@"C:\pics\Button Selected Blue.png");
            ButtonSelectedGreen = Image.FromFile(@"C:\pics\Button Selected Green.png");
            AutoScrollMinSize = piccy.Size;
            piccyBounds = new Point[3];
            LanguageButtonBounds = new Point[3];
            
            const int resolutionX = 1024; //the x dimension of the display resolution
            const int resolutionY = 768; //the y dimension of the display resolution

           
            piccyBounds[0] = new Point(0, 0);
            piccyBounds[1] = new Point(resolutionX, 0);
            piccyBounds[2] = new Point(0, resolutionY);

            LanguageButtonBounds[0] = new Point(744, 617);
            LanguageButtonBounds[1] = new Point(992, 617);
            LanguageButtonBounds[2] = new Point(744, 659);

        }

        protected override void OnPaint(PaintEventArgs e)
        {


            //this.Show();
            //this.BringToFront();
            Graphics dc = e.Graphics;
            base.OnPaint(e);
            //dc.TranslateTransform(AutoScrollPosition.X, AutoScrollPosition.Y);
            //dc.TranslateTransform(AutoScrollPosition.X, AutoScrollPosition.Y);
            dc.DrawImage(piccy, piccyBounds);

            if (LanguageTraining && (Language != ButtonState.Blue))
            {
                //dc.FillRectangle(Brushes.White, new Rectangle(744, 617, 248, 42));
                dc.DrawImage(ButtonSelectedBlue, LanguageButtonBounds);
                LanguageTraining = false;
                //base.OnPaint(e);
                //return;
            }
            else if (MouseOnLangugeTraining && (Language != ButtonState.Green))
            {
                dc.DrawImage(ButtonSelectedGreen, LanguageButtonBounds);
                MouseOnLangugeTraining = false;
            }
            else if (MouseOutLanguageTraining && (Language != ButtonState.NotSelected))
            {
                dc.DrawImage(ButtonNotSelected, LanguageButtonBounds);
                MouseOutLanguageTraining = false;
            }
            //dc.DrawString("Language Training", ButtonFont, TextBrush, new Point(755, 625));
        }

        protected override void OnKeyUp(KeyEventArgs e)
        {
            base.OnKeyUp(e);
            if (e.KeyCode == Keys.Escape)
                this.Close();
        }
   
        protected override void OnMouseClick(MouseEventArgs e)
        {
            base.OnMouseClick(e);
            Point mouseLocation = Control.MousePosition;
            if (mouseLocation.X > 755 && mouseLocation.X < 992 && mouseLocation.Y > 625 && mouseLocation.Y < 659)
            {
                Invalidate();
                LanguageTraining = true; //means that only language training button should be repainted
            }
        }
        
   
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            Point mouseLocation = Control.MousePosition;
            if (mouseLocation.X > 755 && mouseLocation.X < 992 && mouseLocation.Y > 625 && mouseLocation.Y < 659)
            {
                MouseOnLangugeTraining = true;
                Invalidate();

            }
            else if (mouseLocation.X < 755 || mouseLocation.X > 992 || mouseLocation.Y < 625 || mouseLocation.Y > 659)
            {
                MouseOutLanguageTraining = true;
                Invalidate(LanguageButtonPosition);
            }
        }
           private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}



From1.designer.cs
using System.Drawing;
namespace paintImage
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            piccy.Dispose();
            ButtonSelectedBlue.Dispose();
            ButtonNotSelected.Dispose();
            ButtonSelectedGreen.Dispose();
            
            //TextZabanSara.Dispose();
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.BackColor = System.Drawing.Color.Silver;
            this.ClientSize = new System.Drawing.Size(1024, 768);
            this.DoubleBuffered = true;
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.Name = "Form1";
            this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
            this.Text = "Form1";
            this.TransparencyKey = System.Drawing.Color.Transparent;
            this.Load += new System.EventHandler(this.Form1_Load);
            this.ResumeLayout(false);

        }

        #endregion
    }
}

AnswerRe: GDI+, problem with Invalidate() method Pin
Christian Graus21-Jun-09 0:37
protectorChristian Graus21-Jun-09 0:37 
AnswerRe: GDI+, problem with Invalidate() method Pin
OriginalGriff21-Jun-09 0:50
mveOriginalGriff21-Jun-09 0:50 
Questionautocomplete selection Pin
Iain Wiseman20-Jun-09 19:33
Iain Wiseman20-Jun-09 19:33 
AnswerRe: autocomplete selection Pin
dan!sh 20-Jun-09 21:42
professional dan!sh 20-Jun-09 21:42 
GeneralRe: autocomplete selection Pin
Iain Wiseman20-Jun-09 22:43
Iain Wiseman20-Jun-09 22:43 
GeneralRe: autocomplete selection Pin
dan!sh 20-Jun-09 23:19
professional dan!sh 20-Jun-09 23:19 
GeneralRe: autocomplete selection Pin
Iain Wiseman21-Jun-09 11:17
Iain Wiseman21-Jun-09 11:17 
QuestionGet PropertyGrid to update? Pin
FocusedWolf20-Jun-09 19:01
FocusedWolf20-Jun-09 19:01 
AnswerRe: Get PropertyGrid to update? Pin
dan!sh 20-Jun-09 23:55
professional dan!sh 20-Jun-09 23:55 
GeneralRe: Get PropertyGrid to update? Pin
FocusedWolf21-Jun-09 9:09
FocusedWolf21-Jun-09 9:09 
GeneralRe: Get PropertyGrid to update? Pin
FocusedWolf21-Jun-09 9:16
FocusedWolf21-Jun-09 9:16 
GeneralRe: Get PropertyGrid to update? Pin
dan!sh 21-Jun-09 16:46
professional dan!sh 21-Jun-09 16:46 
GeneralRe: Get PropertyGrid to update? Pin
FocusedWolf21-Jun-09 19:08
FocusedWolf21-Jun-09 19:08 
GeneralFocus losing in propertygrid Pin
VB 8.07-Jul-09 23:41
VB 8.07-Jul-09 23:41 
QuestionDatagridview combobox in column header Pin
desir10220-Jun-09 13:39
desir10220-Jun-09 13:39 
AnswerRe: Datagridview combobox in column header Pin
MarkB77720-Jun-09 17:40
MarkB77720-Jun-09 17:40 
AnswerRe: Datagridview combobox in column header Pin
Manas Bhardwaj20-Jun-09 21:33
professionalManas Bhardwaj20-Jun-09 21:33 

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.