|
Here's a general (very general) approach I've found helpful for a similar application:
1. Implement a MyControl base class that has features common to all of your controls: Coordinates, size, color, text, enabled, style, etc...
2. Add a DrawOn (Graphics g) method in this base class that draws a basic control. This will be overridden by your derived control classes that want to display the control differently.
3. In the form your user is designing on, have a List<MyControl> member that has all the controls the user has added so far, in the order they've added them. (If you want to serialize forms, use ArrayList instead because generics can't be serialized by default.)
4. In your form's OnPaint handler, iterate through your MyControl list, calling the DrawOn method for each control.
5. In the form's mouse-move handler, set the new coordinates of all selected controls, and invalidate their previous and current positions.
That's it. A bit simplistic, but that's what makes this approach easy to use.
|
|
|
|
|
thanks it help me alot but i have problem with creating tools i mean toolbox
like button controls, image controls etc...
Abdul Rahaman Hamidy
Senior Student Student in Computer Science
Kabul, Afghanistan
Software Developer
|
|
|
|
|
You can use a toolstrip with the control names. When the user clicks a control name, create a new instance of that control and add it to the List of controls.
You can also show a properties dialog for each control type so the user can customize the control by filling in its properties.
|
|
|
|
|
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
|
|
|
|
|
How to convert the .HTML file (Text and Images) into .pdf file using C#
Thanks in advance
|
|
|
|
|
|
If your boss can afford it, tell him to buy TxTextControl .NET. AFAIK, in the standard version it can handle html and rtf. In the professional, it adds support for doc and docx. All these formats can be exported to PDF.
Check it out here: http://www.textcontrol.com/products/dotnet/[^]
|
|
|
|
|
|
Dear experts,
first in short my problem which I want to solve.
I want to check by a tool the adherence to a process. In concrete this means, that I have some type of a model how the process should be followed and I want to check this now.
An simple example:
Let's assume I have 3 process entities: a) Requirements b) Implementation c) Final test. The workflow is now as follows: If Requirements change, the Implementation must be updated and finally the Tests must be made. And much more combinations are possible...
The information on the versions of req, impl. and tests ist stored in some meta-info-files (e.g. xml.files or databases)
Solution:
I don't know how to start here. What I wanted to implement were some rules or workflows. E.g. If the req. have been updated there must be at least some xml-information which references this version of req. and ......
My first approach ended with endless for loops and if-statements; totally unmaintainable.
Questions:
1.
I "feel" that my topic has to do with workflow-programming. Is this right?
2.
Is there any beginners information available?
3.
I read about WWF. Is this the right starting poing?
4.
I also read about some "rule based engines". Is this similiar to workflows?
Kind regards
|
|
|
|
|
Tomerland wrote: I "feel" that my topic has to do with workflow-programming. Is this right?
Interesting question, however it bring up another question. Since you have far more information about your applications requirements than people reading your post in an internet forum, why wouldn't it make more sense for you to study what workflow is[^] to answer that question rather than asking people in an internet forum?
led mike
|
|
|
|
|
hi,
can come one please guide me how to dock the first column in datagridview.so that when the number of columns increases and scroll is there the first column in visible even if we scroll to the last column.
modified on Monday, August 11, 2008 6:59 AM
|
|
|
|
|
sailesh_gupta wrote: treat this as urgent
Be careful what you wish for...
|
|
|
|
|
NO NO NO
This is a Datagrid , you cannot do that. and before you type something make sure its correct(English)
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
|
I have made an Outlook 2003 add-in in VS 2005 using VSTO 2005. Now i want to use the same add in to Outlook 2002. How i can do this i need some hint or u can advice what should i do??????
wasim khan
|
|
|
|
|
Google[^]
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
hi 4 all,
can i handle an exception without using try catch blocks,
becouse i have been asked this qustion in an interview and i answered with NO .
if " yes " i can PLEASE explain it for me!!!!
|
|
|
|
|
mrcooll wrote: can i handle an exception without using try catch blocks,
Yes, there's an event that gets fired at the top level of an app if an uncaught exception hits that level. But, that's not really a great way to handle exceptions, because it's so far from the source, that it's hard to recover.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
did u mean the
void Application_Error(object sender, EventArgs e)
{ // Code that runs when an unhandled error occurs Server.Transfer("HandleError.aspx");
}
in web application ?
becouse i dont know what r u talking about in windows app!!
|
|
|
|
|
No, there's an event in a windows app. I forget the details, but I know I implemented it in my windows app for any uncaught exceptions.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
In windows application you can hook up to AppDomain.UnhandledException and Application.ThreadException events.
Using this any handled exception can be handled centrally.
|
|
|
|
|
Beat me to it.
Simon
|
|
|
|
|
|
Cool - two people who could be bothered to look it up
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|