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

C#

 
GeneralRe: To get hostname/IP Adress of data-recieving server Pin
Ahuja.bangalore11-Aug-08 20:53
Ahuja.bangalore11-Aug-08 20:53 
Questionhow to design form designer Pin
Abdul Rahman Hamidy11-Aug-08 2:28
Abdul Rahman Hamidy11-Aug-08 2:28 
AnswerRe: how to design form designer Pin
scottgp11-Aug-08 2:32
professionalscottgp11-Aug-08 2:32 
AnswerRe: how to design form designer Pin
Giorgi Dalakishvili11-Aug-08 2:40
mentorGiorgi Dalakishvili11-Aug-08 2:40 
AnswerRe: how to design form designer Pin
Alan Balkany11-Aug-08 4:17
Alan Balkany11-Aug-08 4:17 
GeneralRe: how to design form designer Pin
Abdul Rahman Hamidy11-Aug-08 22:08
Abdul Rahman Hamidy11-Aug-08 22:08 
GeneralRe: how to design form designer Pin
Alan Balkany12-Aug-08 3:19
Alan Balkany12-Aug-08 3:19 
QuestionCompact Framework. Dragging a control at runtime causes a smear of the control across the screen. Paint Problem? Pin
gembob11-Aug-08 2:25
gembob11-Aug-08 2:25 
Hi,

I've a .net Compact Framework 2.0 VS C# Project.

On it I have a control (a picture box) which at runtime I can drag left and right on my screen within set co-ordinates.

I update the picture with one of two images which are embedded images)

However, when I do drag this control at runtime, there is a delay in the refresh, so what I am getting is a smear of controls across the screen momentarily while I'm moving the control. I want the control to move seamlessly like that on the iPhone.

I've included my code below.

I've googled this problem and came across the following. http://www.pcreview.co.uk/forums/thread-1301356.php I've attempted to implement this but am not sure if the programmer intends on dragging the panel about the screen, or if the panel is refreshing the form itself. Either way, my implementation of this code has a permanent spear of my control across the screen, and also the background of the form has become invisible

I understand Double buffering isn't available in .net CF. I don't have the experience myself to implement an alternative to double buffering. I've tried adding a pixel count to the code, to stop the control from being drawn unless a the control has moved a certain amout of pixels, this make the control movement jumpy and I still have a smear as the control moves.

If anyone has any idea how to reduce this effect I'd greatly appreciate it

best Regards

Gemma


//Variables


private Boolean dragInProgress = false;

int MouseDownX = 0;

int MouseDownY = 0;

int pixelcount = 0;

Point temp = new Point();

int percentage_light;

Bitmap lights_on, lights_off;



//Embedded images are loaded when the form loads

private void Form1_Load(object sender, EventArgs e)

{

lights_on = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("DeviceApplication1.images.light_intensity_slider_h.png"));

lights_off = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("DeviceApplication1.images.light_intensity_slider.png"));

}



#region Button Slider bit

private void picCameraDimmer_MouseDown(object sender, MouseEventArgs e)

{

if (!this.dragInProgress)

{

this.dragInProgress = true;

this.MouseDownX = e.X;

this.MouseDownY = e.Y;

}

return;

}

private void picCameraDimmer_MouseMove(object sender, MouseEventArgs e)

{

pixelcount += 1;

if (dragInProgress)

{

temp.X = this.picCameraDimmer.Location.X + (e.X - MouseDownX);

temp.Y = 168; // Set the x co-ordinate so button can't move sideways

this.picCameraDimmer.Location = temp;

int x_size = Convert.ToInt16(temp.X);


percentage_light = (int)((x_size - 33) / 3.91);


if (temp.X < 36) // Set button to it OFF Location

{

temp.X = 36;

this.picCameraDimmer.Location = temp;

picCameraDimmer.Image = lights_off;

picCameraLight.Size = new System.Drawing.Size(5, 5);

}

else if (temp.X >= (36) && temp.X <= (428)) // Button is between its OFF and MAX points

{

picCameraLight.Size = new System.Drawing.Size(x_size, 5);

picCameraDimmer.Image = lights_on;

this.picCameraDimmer.Location = temp;

Invalidate();


}

else if (temp.X > 428) // Set button to its MAX location

{

temp.X = 428;

this.picCameraDimmer.Location = temp;

picCameraDimmer.Image = lights_on;

picCameraLight.Size = new System.Drawing.Size(428, 5);

}

return;

}

}

private void picCameraDimmer_MouseUp(object sender, MouseEventArgs e)

{


if (e.Button == MouseButtons.Left)

{

this.dragInProgress = false;

if (temp.X == 36) // Button is at its OFF location

{

// Send 0 for light intensity

// s_data[4] = (byte)(0);

// sound.Play();



}

else if (temp.X == 428) // Button is at its MAX location

{

// s_data[4] = 100;

// sound.Play();

}

else if (temp.X > 36 && temp.X < 428) // Button is between OFF and MAX points

{

this.picCameraDimmer.Location = temp;

// s_data[4] = (byte)(percentage_light);

}

}

return;

}

#endregion
QuestionConvert HTML file to PDF Pin
selvakkumar11-Aug-08 1:47
selvakkumar11-Aug-08 1:47 
AnswerRe: Convert HTML file to PDF Pin
Giorgi Dalakishvili11-Aug-08 1:52
mentorGiorgi Dalakishvili11-Aug-08 1:52 
AnswerRe: Convert HTML file to PDF Pin
blackjack215011-Aug-08 3:13
blackjack215011-Aug-08 3:13 
AnswerRe: Convert HTML file to PDF Pin
vikas amin11-Aug-08 5:17
vikas amin11-Aug-08 5:17 
QuestionSome type of Workflow - Programming? Pin
Tomerland11-Aug-08 1:46
Tomerland11-Aug-08 1:46 
QuestionRe: Some type of Workflow - Programming? Pin
led mike11-Aug-08 4:48
led mike11-Aug-08 4:48 
Questiondockin of column -Data Grid View in C# [modified] Pin
sailesh_gupta11-Aug-08 0:53
sailesh_gupta11-Aug-08 0:53 
GeneralRe: dockin of column -Data Grid View in C# Pin
c242311-Aug-08 0:58
c242311-Aug-08 0:58 
AnswerRe: dockin of column -Data Grid View in C# Pin
Vimalsoft(Pty) Ltd11-Aug-08 1:36
professionalVimalsoft(Pty) Ltd11-Aug-08 1:36 
AnswerRe: dockin of column -Data Grid View in C# Pin
Wendelius11-Aug-08 8:46
mentorWendelius11-Aug-08 8:46 
QuestionHow i can Customize my Outlook2003 add into Outlook 2002 Pin
wasimsharp10-Aug-08 23:07
wasimsharp10-Aug-08 23:07 
AnswerRe: How i can Customize my Outlook2003 add into Outlook 2002 Pin
Thomas Stockwell11-Aug-08 1:26
professionalThomas Stockwell11-Aug-08 1:26 
QuestionSilly Qustion About try catch finally blocks!!!!! Pin
mrcooll10-Aug-08 22:32
mrcooll10-Aug-08 22:32 
AnswerRe: Silly Qustion About try catch finally blocks!!!!! Pin
Christian Graus10-Aug-08 22:47
protectorChristian Graus10-Aug-08 22:47 
GeneralRe: Silly Qustion About try catch finally blocks!!!!! Pin
mrcooll10-Aug-08 23:01
mrcooll10-Aug-08 23:01 
GeneralRe: Silly Qustion About try catch finally blocks!!!!! Pin
Christian Graus10-Aug-08 23:02
protectorChristian Graus10-Aug-08 23:02 
GeneralRe: Silly Qustion About try catch finally blocks!!!!! Pin
Manas Bhardwaj10-Aug-08 23:22
professionalManas Bhardwaj10-Aug-08 23:22 

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.