|
|
Hi Colin,
Unfortunatley we got the money up front, which seemed like a good idea at the time because it was good money
I can convert most of the form fields to their windows equivalent with a find and replace and most of the form logic is well encapsulated. The only real problem is then I've got to position all the form fields, actucally that is a nightmare because theres over a 100 textboxes and groups of radio buttons etc etc.
Cheers.
|
|
|
|
|
If you get REALLY (and I mean REALLY) desperate, you could host your ASP.NET solution on each machine .
I'd look at it as a learning opportunity, and a chance to do a UI exactly how you want it .
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
Actually thats a very good idea, I remember hearing something about 'Cassini' and hosting asp.net runtime in a windows form.
Im just worried thats theres some big gotcha that will bring the whole idea to a halt.
Has anybody had any success with that approach.
Kentamanos wrote:
I'd look at it as a learning opportunity
LOL, its true, you do learn more on 'nightmare' projects, whatever doesn't kill me makes me stronger and all that
Thanks.
|
|
|
|
|
I am getting a weird problem with the tabpage here is a step by step account of how to reproduce my problem
1) add a tabcontrol and then a tabpage to a form
2) add a custom contorl to the tabpage (a normal control eg label will work as well but i am using a custom control)
3) add functionality that allows you to drag the control/label (i just use the controls mousedown to start DoDragDrop, and then use the drag_enter/move events of the tabpage to make it drag)
4) now set a background image, some big image say 1mb and 1024x768 and drag the contorl/label, you should see that it is slow to paint the control when dragging
HOW CAN I MAKE THE PAINTING SMOOTH?
I have tried double buffer overriding onpaintbackground etc.. but that is not the solution as if i add my control to a panel and then set the panels backgroundimage to a large image the painting is smooth!!!! So the panel does something to make painting smooth that the tabpage does not. The solution i have come across is detailed below however it has a weird problem which i will list below. For now use the following steps to produce my problem
Start a new project
1) inherit from tabpage and produce a custom tabpage class with the code below
public class MyTab : TabPage
{
public Image imagex;
public MyTab()
{
}
protected override void OnPaint(PaintEventArgs e)
{
if(imagex!=null)
{
e.Graphics.DrawImageUnscaled(imagex, 0, 0, imagex.Width, imagex.Height);
}
base.OnPaint (e);
}
protected override void OnPaintBackground(PaintEventArgs pevent)
{
base.OnPaintBackground (pevent);
}
}
2) add tabcontrol to form and add the inherited tabpage to it
3) add user control to tabpage then add functionality to drag the control
4) make an Image object in the and set it to a large image in the form class name it LARGE_IMAGE
e.g. Image LARGE_IMAGE = Image.FromFile(@"C:\image.jpg");
5) add 4 buttons to the form which the following in their click events
Button 1
========
tabpage.imagex = LARGE_IMAGE;
Button 2
========
tabpage.imagex = null;
Button 3
========
tabpage.BackGroundImage = LARGE_IMAGE;
Button 4
========
tabpage.BackGroundImage = null;
6) OK now that everythings ready we can begin the test! If you press Button 1 you will see that when you drag the control the image appears underneath it however the painting isnt very smooth but is smoother than in the first example above where you set the backgroundimage. Now if you press Button 2 so the tabpage.imagex is set to null. painting should be smooth again as no background is set. (Forget about the backimage getting erased and painting when u move the control i understand why that is happening that is not the Problem).
Now press Button 3 to set the tabpage's backgroundimage and drag the control around it is slow to paint now press button 4 to set the backgroundimage to null. OK THIS IS THE WEIRD PART, Press Button 1 and tabpage.imagex should paint SMOOTH!!!!! IT is fine now.
I cant understand why this happens? It only paints smooth after setting and unsetting the tabpage's backgroundimage. I have tried doing the following
tabpage.BackGroundImage = LARGE_IMAGE;
tabpage.BackGroundImage = null;
tabpage.imagex = LARGE_IMAGE;
in the constructor of the inherited tabpage but that does not make it smooth, i have added the 3 lines of code to a seperate button again to no change. It seems i have to add the code to different buttons only then will it work!!! WIERD.
Please please can anyone shed any light on this situation? I want smooth painting on the tabpage with out pressing mulitples buttons LOL
|
|
|
|
|
Maybe if you active the DoubleBuffer (one buffer for display the actual paint, and one buffer for the next paint), you paint'll be more smooth. You can activate this Style with:
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
The Control Style UserPaint, and WmPaint are need them for DoubleBuffer.
----
hxxbin
|
|
|
|
|
I'm trying to draw a rectangle around a button that is placed on a panel
with the code:
protected Graphics grfx = null;
private void DrawScanArea(Button aButton)
{
grfx = thePanel.CreateGraphics();
Pen pen = new Pen(Color.White, 5);
grfx.DrawRectangle(pen,aButton.ClientRectangle);
}
Why won't this work?
Thanks
Thomas
|
|
|
|
|
First, never store a Graphics object and always call Dipose on it when you're finished.
Second, using the ClientRectangle of the Button means that the rectangle will be within the Button , which maintains its own state. Drawing a rectangle within said bounds won't be visible. Instead you must inflate the rectangle (you can use Rectangle.Inflate ) by the size of the pen (5, in your example).
You'll also want to do this in the override for OnPaint in your Panel -derived class (or in the Paint event if from another - possibly container - class. Painting this rectangle once will work (if you take into account what I mentioned above) but once the surface requires repainting it won't show up (and only part of it - the invalidated part - will disappear if the whole surface doesn't need repainting). So, in DrawScanArea(Button button) instead set a value to signify that the border should be painted (like a non empty rectangle which you would have to store anyway) and in OnPaint check that state and draw the border if necessary.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Sorry but I realy don't seem to understand the OnPaint event or something, couse I don't get the rectangle to show.
I have a Main class, I've created my own panel class(MyPanel) and added it to the Main form.
On the panel I want to draw the rectangle.(The rectangle shall only be visable for a short period before it will be drawn at a different position)
If I in the MyPanel class add:
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
}
In my Main class i have:
private void DrawScanArea(Rectangle rect)
{
}
Should i create a System.Windows.Forms.PaintEventArgs in my Main class to call up the OnPaint(...) in the panel class?(well I can't since it is protected), so how will it be called up? I would asume it happens when I call the line: grfx.DrawRectangle(pen,rect); in DrawScanArea(Rectangle rect)
, or should the grfx.DrawRectangle(pen,rect);, be placed in the OnPaint(..) in MyPanel class?
My lack of understanding annoys me...
Thanks
Thomas
|
|
|
|
|
First, OnPaint is not an event, it's a method that corresponds to the Paint event. You override OnPaint in a class that derives from another control when you want to control the painting from within that class. You have the Paint event when you want to control the painting from another class. The base class (Control , actually) will call the virtual OnPaint method along with the PaintEventArgs . You should call the base class's OnPaint which will raise the Paint event and might even do other painting operations specific to the base control:
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (this.myStoredRect != Rectangle.Empty)
{
Pen pen = new Pen(Brushes.Black, 5f);
e.Graphics.DrawRectangle(pen, this.myStoredRect);
}
}
private void DrawScanArea(Rectangle rect)
{
this.myStoredRect = rect;
if (rect != Rectangle.Empty)
rect.Inflate(5, 5);
this.Refresh();
} So, call DrawScanArea(myButton.Bounds); when you want the rectangle drawn, or call DrawScanArea(Rectangle.Empty); when don't want the rectangle drawn.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thank you Heath for your respons and it
nearly works:
I added to my Main class:
private void DrawScanArea(MyButtonLib.MyButton btnRect)
{
Rectangle rect = new Rectangle(btnRect.Location, btnRect.Size);
ThePanel.StoredRect = rect;
ThePanel.StoredRect.Inflate(5, 5);
this.Refresh();
}
To my panel class:
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
base.OnPaint(e);
if (rStoredRect != Rectangle.Empty)
{
Pen pen = new Pen(Brushes.Blue, 5f);
e.Graphics.DrawRectangle(pen, rStoredRect);
}
}
The problem is that the button hides the rectangle(it paints the button over)
I've tryed to put the OnPaint(..) in my Main class, and the ofcourse the panel hids the rectangle.
I tryed to put it in my button class:
private Rectangle scnaRect = Rectangle.Empty;
public void DrawScanArea(Rectangle rect)
{
scnaRect = rect;
scnaRect.Inflate(5, 5);
this.Refresh();
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
base.OnPaint(e);
if (scnaRect != Rectangle.Empty)
{
Pen pen = new Pen(Brushes.Blue, 5f);
e.Graphics.DrawRectangle(pen, scnaRect);
}
}
But it won't draw the rectangel at all.
What to do?
Thanks
Thomas
|
|
|
|
|
It works if I in my button class insted:
public void DrawScanArea(Rectangle rect)
{
scnaRect = rect;
scnaRect.X = 0;
scnaRect.Y = 0;
this.Refresh();
}
but then it only show inside the button.
|
|
|
|
|
You're original response stated that you wanted the rectangle drawn around the button. If you would've stated your intentions correctly, I could have given you a good idea of what to do the first time. You also could've used a number of methods from the ControlPaint class in System.Windows.Forms , but for your needs as stated originally I knew this wouldn't work for you.
In any case, you must understand how painting works and how client coordinates are calculated. When you put the painting code in your main form (assuming your Panel wasn't docked), the coordinates where in the client-space of the form, not the panel. Client coordinates are calculated in terms of the container. A Form is a container, just as a Panel is a container. Also, if a Controls handles it's own painting, the painting effects of the container class are not easily made visible (there's a number of things that must be set correctly) because they have two different HDC s that are managed for each control.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Not exactly a C# question, but is there an algorithm that will sort points in a cyclic order? To elaborate the problem, I have a set of points describing the boundary of a closed region. But they are in random order. I want to sort them in such a way that interconnecting adjacent points in the array will recreate the boundary. For example, if (0,1),(1,1),(0,0),(1,0) are given, the result should be (0,1),(1,1),(1,0),(0,0).
|
|
|
|
|
If each pair is unique, then you shouldn't have too much problem with this. Once you pick your starting pair, find the next pair in which the first point corresponds to the last point of your starting pair and continue that way, optionally validating when all the points have been sorted that your last pair/last point corresponds with your first pair/first point. Unfortunately, this is an O(n*n!) operation. This could be improved if you also pre-sorted the remaining pairs according to their starting point as you enumerated them each time.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks, Heath.
I've been currently doing as you said, but it is inefficient, and wanted to know if there was a faster algorithm. To complicate matters, the list of points might contain disjoint region boundaries.
|
|
|
|
|
thanks for answering me for the previous question but as i didn't deal with SDKs before i don't know how to perform the task so again please, i have a task which needs to catch voice from microphone and deal with it as binary bits so i need a code sample that records or catches voice from mic
and thanks to all
|
|
|
|
|
Then now's your time to use an SDK. It's not rocket science. What do you think the .NET Framework SDK consists of? And SDK is nothing more than documentation, libraries, and tools. The Speech SDK contains ActiveX controls that are registered on the system than you can add to your toolbox in VS.NET and drag to your form to create COM interop assemblies. You must read the SDK documentation - however briefly - for information on which ActiveX controls to use and what methods and properties are available.
If you want to translate voice into text, this is not an easy thing to do and the Speech SDK is one of the de facto ways of doing this.
If all you want to do is record the microphone input to a WAV file, then you'll have to use the DirectX SDK, which you can download from http://msdn.microsoft.com/directx[^]. This is not something as easy as you think. Specifically, you'll want to read about the Capture class in the Microsoft.DirectX.DirectSound namespace. There's even an example called "CaptureSound" that does what you need.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I have web service with a windows client , sometimes when I call the web service this error happend:
Client found response content type of '', but expected 'text/xml'.
The request failed with the error message:
--
<HTML><HEAD><META HTTP-EQUIV="REFRESH" CONTENT="0" URL="http://myhost.com/WS.asmx"></HEAD><BODY>
</BODY></HTML>
It is happend by chance and I donn't no any reason, cause if I close my application and open it again and call methods with the same datait does not happend.Any idea?
Mazy
No sig. available now.
|
|
|
|
|
The web service isn't sending the Content-Type of the response, and I notice that it's <meta> tag is formatted incorrectly. URL is not a valid attribute, and the CONTENT attribute should also look like this:
<meta http-equiv="refresh" content="0;url=http://myhost.com/WS.asmx"> I'm guessing you don't have control over the WS. In any case, it appears that the WS is trying to redirect you to a new URL in a bad way. With WS's, they should actually send the 301 or similar HTTP status code. A web service proxy isn't required to understand HTML content like this, and it would be crazy to assume that one would.
If you have control over the WS, change this behavior. If you don't, contact the host/developer.
Finally, if the server is sending a 301 (or similar) in addition to the content of the page (which is odd, but possible), make sure you set your web proxy's AllowAutoRedirect to true (the default is false ).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath Stewart wrote:
If you have control over the WS, change this behavior
Actually I'm the developer of that WS , but I couldn't understand how should I change that behaviour. This behaviour sometimes happend and I don't know in what condition it happen. Do you know what cause this?
Heath Stewart wrote:
make sure you set your web proxy's AllowAutoRedirect to true
I don't have VS.NET now to test but I check the MSDN. Is that something that I should set in the client before the first call of it and its part of web service class?
Mazy
No sig. available now.
|
|
|
|
|
This should be set after you instantiate the client proxy and before you make your call.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks Heat. But what about first part you said. The part you said if I have access to the own WS , I change that behaviour.
Mazy
No sig. available now.
|
|
|
|
|
ASP.NET is trying to redirect the call to your WS for some reason. The weird part is that it's sending HTML to do so (hence the META HTTP-EQUIV="refresh", which is the same as the HTTP Refresh header). I honestly don't know what could be causing this. If the WS call needs to be redirected (and that's one of the problems), it should simply send the HTTP status codes accordingly - not content. Stopping the redirect would be your best option if you can figure out why it is trying to redirect.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi,
How would you go about designing a tool in C# that would let you run your search on multiple search engines and then bring back the results to you?
Any high-level ideas, hints?
Thanks...
|
|
|
|
|