|
Hi Steve,
1.
are you and "Member 7455306" one and the same? there is another ECG thread on this page! It is getting confusing...
2.
I can't tell for sure what is right or wrong in the code shown as there are a lot of magic constants which may or may not be OK.
3.
the x your code is using is probably ranging from 1 to ecgDisplay.Width+1 inclusive, so you are not having it point into the first column (x=0), and it is pointing in two columns that are beyond the ecgDisplay (width, and width+1).
4.
if and when x wraps back to 1, there will emerge a backward line from px=width+1 to x=1 which is probably the thing you see and don't like.
5.
a potential problem: if ECGArray would be partially filled, i.e. contain fewer than ECGArray.Length actual values, the remainder would be zero, and also get plotted.
6.
I find your erasure strategy a bit weird; instead of
e.Graphics.DrawRectangle(blackpen, 0, 0, x + 1, ecgDisplay.Height);
I would go along this line (the hor coordinate may be off by 1):
e.Graphics.DrawLine(blackpen, x+1, 0, x + 1, ecgDisplay.Height-1);
That's it for now.
|
|
|
|
|
this is on mobile app
panel4 = visible and doc = fill
panel4.controls.clear = done before this
Button dynamicButton = new Button();<br />
dynamicButton.Name = "dynamicButton" + i.ToString();<br />
dynamicButton.Width = 75;<br />
dynamicButton.Height = 23;<br />
dynamicButton.Left = left;<br />
dynamicButton.Top = 10 + (dynamicButton.Height * i) + (10 * i);<br />
dynamicButton.Text = valuename.ToString();<br />
dynamicButton.Click += new EventHandler(Button_Click);
panel4.Controls.Add(dynamicButton);
but the controls won't show up what i'am doing wrong
thanks
|
|
|
|
|
I suggest you check the value of left .
Also not sure what i would be, so Top too could be wrong.
|
|
|
|
|
panel4.Controls.Clear();<br />
Application.DoEvents();<br />
int i = 0;<br />
int left = 9;<br />
waarb = @"Comm\ConnMgr";<br />
RegKey = Registry.LocalMachine.OpenSubKey(waarb);<br />
<br />
if (RegKey != null)<br />
{<br />
foreach (string valuename in RegKey.GetSubKeyNames()) <br />
{<br />
Button dynamicButton = new Button();<br />
dynamicButton.Name = "dynamicButton" + i.ToString();<br />
dynamicButton.Width = 75;<br />
dynamicButton.Height = 23;<br />
dynamicButton.Left = left;<br />
dynamicButton.Top = 10 + (dynamicButton.Height * i) + (10 * i);<br />
dynamicButton.Text = valuename.ToString();<br />
dynamicButton.Click += new EventHandler(Button_Click);
panel4.Controls.Add(dynamicButton);<br />
Application.DoEvents();<br />
i++;<br />
}<br />
RegKey.Flush();<br />
RegKey.Close();<br />
}<br />
Application.DoEvents();<br />
}
|
|
|
|
|
Hi,
1.
if you were to use PRE tags instead of CODE tags, formatting would have been preserved resulting in better readability.
2.
My (non-mobile) system doesn't have a registry key HKLM\Comm.
If yours doesn't either, no buttons would show.
3.
I see several Applications.DoEvents() , and they in general are evil. As I don't know where the code shown resides, I can't start to explain how dangerous they could be.
4.
I have no idea why you call RegKey.Flush(); on a key that was opened for reading.
5.
if #2 doesn't solve your immediate problem, I suggest you debug, i.e. look at intermediate values, by adding log statements and/or single-stepping.
|
|
|
|
|
1 true
2 on my first post it says "this is on mobile"
3 t'is was put in for a last solution
4 t'is was a code block that i copyed from somwher else
5 all the things you say are things nothing to do with the problem
if i do a control count on the panel they are there , but don't show
yes i have use visibel, enable,show,... nothing seems to help
and it's late in the morning "don't turn around the cookingpan"
just tested
if i use the form itself for the controls no problem
controls.add(..) works
panel4.controls.add(..) don't work
modified on Monday, September 20, 2010 11:26 PM
|
|
|
|
|
Make sure that panel4 is actually visible and the topmost control on the view stack (zorder is appropriate).
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
Try to get rid of your Application.DoEvent() first.
It's better to surround the creation of your controls by SuspendLayout() /ResumeLayout() .
panel4.Controls.Clear();
int i = 0;
int left = 9;
waarb = @"Comm\ConnMgr";
RegKey = Registry.LocalMachine.OpenSubKey(waarb);
if (RegKey != null)
{
Button dynamicButton = null;
this.SuspendLayout();
foreach (string valuename in RegKey.GetSubKeyNames())
{
dynamicButton = new Button();
dynamicButton.Name = "dynamicButton" + i.ToString();
dynamicButton.Width = 75;
dynamicButton.Height = 23;
dynamicButton.Left = left;
dynamicButton.Top = 10 + (dynamicButton.Height + 10) * i;
dynamicButton.Text = valuename.ToString();
dynamicButton.Click += new EventHandler(Button_Click);
panel4.Controls.Add(dynamicButton);
i++;
}
this.ResumeLayout();
RegKey.Flush();
RegKey.Close();
}
Then debug your application :
Put a spy on the panel4 object.
See the Controls property of panel4. What's in there ? Does the Count property seem correct (i.e. it has the same as the number of keys in the registry).
Then put a beakpoint in your loop. For each button created, check its properties ; maybe there's one you didn't think of and that has to be set.
|
|
|
|
|
Hello everyone,
Could someone please assist with the following problem?
I have an ecgMachine class that handles (or will) the drawing of an ECG graph onto a picture box.
I have my main form, with a picture box called ecgDisplay on it.
When the simulation starts, depending on the patient data loaded (from a file) the timer starts, and every n miliseconds I need to draw/update the picturebox.
Now my problem is this as I am still confused.
Do I a) create and pass in a picturebox object from the form to the ecg class,
or B) get an ecg object into the main form and handle drawing in there?
Any advice would be great, and to just clarify, the following is a function that will be used to actualy draw the ecg...
(ecgDisplay = the pictureBox)..
private void drawEcg()
{
const int scaleX = 40;
const int scaleY = 40;
Point ecgDisplayTopLeft = new Point(0, 0);
Point ecgDisplayTopLeftMinus1 = new Point(-1, 0);
int halfX = ecgDisplay.Width / 2;
int halfY = ecgDisplay.Height / 2;
Size size = new Size(halfX + 20, ecgDisplay.Height);
Graphics g = ecgDisplay.CreateGraphics();
g.TranslateTransform(halfX, halfY);
g.ScaleTransform(scaleX, scaleY);
g.Clear(Color.Black);
g.ResetClip();
float lastY = (float)Math.Sin(0);
float y = lastY;
Pen p = new Pen(Color.White, 0.01F);
float stepX = 1F / scaleX;
for (float x = 0; x < 10; x += stepX)
{
}
}
Thank you
Steve
|
|
|
|
|
Hi Steve,
I have several comments:
1.
PictureBox is a pretty stupid Control capable of showing an existing image. As soon as something more complex is required (such as scaling the picture AND painting a capture rectangle on top of it), it becomes a real pain.
As you are not taking advantage of the few actual PictureBox capabilities, you'd better not use one at all. A simple Panel also can be drawn upon.
2.
Whatever Control you choose, in WinForms all drawing should occur in the Paint handler, and CreateGraphics is to be avoided. You may want and read this little article[^].
3.
You may also be interested in this thread[^], where something similar is going on. I will add messages in that thread later on.
[ADDED]
And I forgot to answer some questions:
you do not pass the PictureBox (or any other GUI thing) to the ECG class; the ECG class represents an ECG, and is not interested in your current way of viewing an ECG. You may choose a different view later on, which would cause the ECG class to need changes.
The correct way would be to provide the new data (an ECG object) to your viewer, which is either your current app's Form, or some specialized Control, maybe an instance of some EcgViewer class, which could derive from UserControl. If your viewer isn't a specialized viewer, then it would not understand ECG objects, and what you pass from one to the other has to be dumbed down, maybe just a Bitmap could do. Or you could create an Interface, that is a contract between producers (such as ECG) and consumers (such as your viewer).
If your data is dynamic (i.e. rather than passing a full ECG or a full image, you pass a life something), then your app fits the requirements mentioned in the link I provided.
[/ADDED]
|
|
|
|
|
I have been reading up on WPF for two weeks now (Specifically using the MVVM pattern) and I am having a very tough time grasping it. Maybe it is the complete abstract nature of the literature that makes it confusing, but I am not sure. I have been retooling a Winforms application in WPF and I am running into the total monotony of wrapping all of my data elements. Am I missing something here? From what I have read by data wrapper (Model) is a wrap for every field in the database that I am going to work with. And I have to write my own save methods, delete methods, etc... ?
Isn't this what the Winforms dataset object does? I have seen some writing about the INotifyProperty interface, but I have not found a good explanation of it or rather a good example.
I am not a formally trained programmer, so some of the more esoteric topics elude me so please forgive my ignorance on this matter.
Cheers, EA
|
|
|
|
|
Design patterns that relate to the presentation of data - MVC/MVP/MVVM - are about understanding what behavior to put in which classes so as to make your application simpler, more reliable and easier to maintain / extend.
I recommend that you google "Separation of Concerns" to get some further insight into the value of making sure any given class is focused on implementing a well defined part of the behavior of your application. This may help you understand what the MVVM books are trying to get at.
Although MVVM and the other patterns separate out the 'model' they are not asking for "unnecessary wrapping." More, they are indicating that partitioning the code that knows how to get data into and out of a database from the code that cares about what the user is trying to do with that data is a valuable thing to do.
Take a look at Linq-to-Sql, and/or the Entity Framework. Both can be used to implement the model - they provide comprehensive implementations of the CRUD operations. So you should not have to write any wrappers, nor implement your own Save, Delete, etc. methods. Guessing at what you're reading, I imagine that the book(s) is/are suggesting that you create a model that encapsulates ("abstracts away" - or - hides the details behind a simple API / interface) the work required to do the database I/O, exposing a simple API to the controller / View Model. Even if you choose to stick with DataSets, looking at how Linq-to-Sql and the Entity Framework do things will probably be instructive and useful.
HTH,
Chris
PS
Regarding INotifyPropertyChanged - it is an interface that indicates that the class implements a PropertyChanged event. Other classes can subscribe to the event to be notified when (and what) properties change. This is often used in data binding - which is a whole other topic of interest and value when building user interfaces. I recommend, when you're reading about INotifyPropertyChanged , that you also read about IEditableObject and IBindingList - which are also common in binding data objects to UI elements.
|
|
|
|
|
Very helpful, thank you. I think this is the first time I have seen someone state explicitly that a dataset can be considered a model. While I will likely not use a dataset, it helps to put into perspective that a model is just a representation of data and does not have to be a lengthy wrapper.
Thank you for the response, very insightful.
|
|
|
|
|
"Isn't this what the Winforms dataset object does?"
Yes, but then all your business objects are datasets / datatables. That might work for you, but in my experience when your number of database objects grows to a certain size, you can only remember the details of each one to a certain degree. I would much rather have my strongly typed classes with my methods than hundreds of datatables. Once you write the code to load and save objects, you can treat them as black boxes. With datatables, you might find yourself coming back to the code asking "what columns are in this table again?". Writing wrapper classes is busy work, no doubt, but it's easy work that makes work easier once it's done and verified.
INotifyPropertyChanged is pretty simple. In your set methods for properties, test if the value has actually changed and if it has, raise PropertyChanged, naming the parameter that was changed. .Net often uses this property name and some reflection to update UI elements, you're free to handle it on your own too for whatever purpose. You might want to build a simple base class for all your wrapper objects that includes a function for property changed testing and raises the appropriate event.
|
|
|
|
|
Apologies if this is the wrong forum but I don't know in which forum it belongs. I have a question on the technology of SOAP.
To what extent is the integrity of comms on the SOAP protocol guaranteed? In other words, let's say I'm writing a C# app that calls a webservice on SOAP. If I receive a response I can sleep easy that everything was fine and the webservice did what it said it would do. But, if I do not receive a response at all (timeout), how much do I actually know about what happened on the webservice side?
So I made a call to the webservice saying "transfer so many million dollars from account one to account two" but I never receive a response (for whatever reason - could be that my connection was broken). Am I correct in saying that there is no way I would now know whether or not the transfer was successful? Or is there some fancy aspect of the SOAP protocol that I don't know of?
|
|
|
|
|
If you want a more guaranteed mechanism, and you must use SOAP, I would consider using SOAP over Message Queue. Take a look at this[^] article for more information.
|
|
|
|
|
|
I have some image and some point collection that represent some part of the image.
I need to look for all the rectangle that appear in the image according to the point collection.
What is the best way to do it ?
|
|
|
|
|
A rectangle can be made from any two points where X != X && Y != Y so you need to determine how you want to identify a rectangle.
|
|
|
|
|
Hi all,
I want to use process.start function with "sc delete servicename" command
How can I do this??
|
|
|
|
|
I find it,I have dealed with it since morning,
string argu = "/C sc delete SistemName";
System.Diagnostics.Process.Start("cmd", argu);
good works..
|
|
|
|
|
One way to do it is to specify the delete servicename as the Arguments in a ProcessStartInfo instance.
|
|
|
|
|
Im trying to make it so I can see the red through the other picture box like a opacity, this is what I mean, click on this link http://img194.imageshack.us/f/capturemzd.jpg/[^] I want it to be like transparent but not see the background, I want it so I can see the other red picture box
|
|
|
|
|
So you want to show what's underneath without using opacity?
The only way I can think of to achieve this is to create a copy of the the underlying image, overlay that image copy over the topmost image, and clip it where the two rectangles don't overlay each other.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
I heared there was like these squares and circles in VB or something that you can just put on, but i can't find this feature in C# would you know where to get them?
|
|
|
|
|