|
I'm using VS2008/.Net 3.5:
I didn't like the way the binding image was stretched to fill the graphic panel, so I made the following modifications:
In StartStep.cs , replace the original OnPaint() method with the code below:
protected override void OnPaint(PaintEventArgs e)
{
Rectangle rect;
Rectangle iconRect;
RectangleF titleRect;
RectangleF subtitleRect;
base.OnPaint(e);
Graphics graphics = e.Graphics;
rect = LeftRectangle;
GetTextBounds(out titleRect, out subtitleRect);
Rectangle gradientRect = new Rectangle(rect.Location, rect.Size);
Rectangle bindingRect = new Rectangle(0, 0, 0, 0);
if (bindingImage != null)
{
bindingRect.Size = new Size(bindingImage.Size.Width, bindingImage.Size.Height);
if (bindingRect.Width != rect.Width)
{
float pct = (float)rect.Width / (float)bindingRect.Width;
bindingRect.Size = new Size(rect.Width, (int)(bindingRect.Height * pct));
}
gradientRect.Location = new Point(gradientRect.X, gradientRect.Y + bindingRect.Height - 1);
gradientRect.Size = new Size(gradientRect.Width, gradientRect.Height - bindingRect.Height);
}
using (Brush brush = new LinearGradientBrush(gradientRect, leftPair.BackColor1, leftPair.BackColor2, leftPair.Gradient))
{
graphics.FillRectangle(brush, gradientRect);
}
if (bindingImage != null)
{
graphics.DrawImage(bindingImage, bindingRect);
}
if (iconImage != null)
{
iconRect = IconRectangle;
iconRect.Inflate(-1, -1);
graphics.DrawImage(iconImage, iconRect);
}
DrawText(graphics, titleRect, title, titleAppearence);
DrawText(graphics, subtitleRect, subtitle, subtitleAppearence);
}
In IntermediateStep.cs , LicenseStep.cs , and FinalStep.cs , replace the original OnPaint() with this one:
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics graphics = e.Graphics;
Rectangle rect = HeaderRectangle;
Rectangle rectangle;
RectangleF titleRect;
RectangleF subtitleRect;
Rectangle gradientRect = new Rectangle(rect.Location, rect.Size);
Rectangle bindingRect = new Rectangle(0, 0, 0, 0);
GetTextBounds(out titleRect, out subtitleRect);
if (bindingImage != null)
{
bindingRect.Size = new Size(bindingImage.Size.Width, bindingImage.Size.Height);
if (bindingRect.Height != rect.Height)
{
float pct = (float)rect.Height / (float)bindingRect.Height;
bindingRect.Size = new Size((int)((float)bindingRect.Width * pct), rect.Height);
bindingRect.Location = new Point(gradientRect.Width - bindingRect.Width, 0);
}
gradientRect.Location = new Point(gradientRect.X, gradientRect.Y);
gradientRect.Size = new Size(gradientRect.Width - bindingRect.Width, gradientRect.Height);
}
headerPair = new ColorPair(Color.White, Color.DarkSlateBlue, 180);
using (Brush brush = new LinearGradientBrush(gradientRect, headerPair.BackColor1, headerPair.BackColor2, headerPair.Gradient))
{
graphics.FillRectangle(brush, gradientRect);
}
if (bindingImage != null)
{
graphics.DrawImage(bindingImage, bindingRect);
}
titleAppearence.TextShadowColor = Color.Transparent;
titleAppearence.TextColor = Color.White;
subtitleAppearence.TextColor = Color.White;
subtitleAppearence.TextShadowColor = Color.Transparent;
DrawText(graphics, titleRect, title, titleAppearence);
DrawText(graphics, subtitleRect, subtitle, subtitleAppearence);
}
The code above resizes the bindingImage to fit inside the graphic panel, while maintaining the original aspect ratio of the image. It further changes the gradient rectangle so that it ends where the bindingImage starts, thus providing a reasonable transition from the gradient to the image. Of course, this only really looks good if the bindingImage has a single-color background, but you can also just set the gradient colors to be the same (essentially eliminating the gradient).
Other things I had to do:
0) I had to comment out all the pragma s because I kept getting compile errors.
1) I had to comment out the set functionality in the LeftPair property because I kept getting the serialization n compiler error.
2) I had to hard-code my gradient colors because the designer refused to keep the settings I made.
3) When I tried to set the bindingImage for the intermediate step page, I was getting an error from the IDE saying the setting already existed. All I did was click on it - I never got to the point where I could change the setting.
4) When I try to add a handler for normal form events, the method templates aren't being added to the application - anywhere.
IMHO, this could would be better if there were templates created to create the form and it's child pages. I think that would simplify the code and enable us to better isolate deficiencies.
I also think you would have been better served to create a StepBase class and put all the common stuff in it, such as the graphic panel, the binding image, and the gradient color pair stuff, just to name a few of the items.
Personal note to the author:
You seemed to have put a lot of work into the code, but you stopped far short of coming up with something viable. There is absolutely no reason for me to have to hard-code stuff into the control itself to make changes, especially with the effort you put into making the control compatible with the IDE designer. Further, you seem to have abandoned the code, forcing your users to try to figure out what the hell your code does. There is no documentation, and pitifully few comments, thus making the code a royal bitch to maintain. It now falls on someone else to take your c ode and recreate it in their own image, and hopefully post a new article with code that actually works.
"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." - Jason Jystad, 10/26/2001
|
|
|
|
|
if you want to provide a grafical design then provide it as a template, as I am finding it a pain to remove the default gradient etc...
if you be nice to start with a blank slate
|
|
|
|
|
I ended up hard coding the gradient I wanted. The code in this article is only half done.
"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." - Jason Jystad, 10/26/2001
|
|
|
|
|
I was just saying it would be nice to have a blank canvas to start from and not have to remove someone else's design first, if the author wants to include some designs then it should be included as a template that can be selected on the properties window
|
|
|
|
|
The author has abandoned the article. You'll get no satisfaction from him. I stand by my claim that the code is only half done.
"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." - Jason Jystad, 10/26/2001
|
|
|
|
|
you are right, it is very buggy and awkward to use at times.
but I have not been able find a free replacement that will work under 3.5 as of yet
|
|
|
|
|
Well, I've started a complete rewrite. It's gonna take a while because I've never done a designer-integrated control before. IMHO, that's where most of the problems lie in the existing code, so designer integration may have to wait or even be abandoned because backward compatibility will be an issue, not to mention forward compatibility.
I'm leaning toward the control-as-a-template idea, and am designing the base classes that provide the basic/common functionality. When the programmer creates a control from the template, he'll be able to make normal changes n the designer, but special settings may be restricted to being manually added - I simply don't know yet.
Anyway, I'll post an article when it's ready.
"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." - Jason Jystad, 10/26/2001
|
|
|
|
|
Help why do I get this error??????
"No overload for 'wizardControl1_NextButtonClick' matches delegate 'WizardBase.GenericCancelEventHandler<WizardBase.WizardControl>"
on this line of code
<code>this.wizardControl1.NextButtonClick += new WizardBase.GenericCancelEventHandler<WizardBase.WizardControl>(this.wizardControl1_NextButtonClick);</code>
|
|
|
|
|
I HAVE THA SAME ERROR. Can some one help?
|
|
|
|
|
help me please... same error occurs..
|
|
|
|
|
reply reference.(2page)
thanks!
================================================================
Re: NextButtonClick Event [modified] MadStudent 7:21 29 Feb '08
================================================================
|
|
|
|
|
No answer to this question until now? I have the same error. Please help.
|
|
|
|
|
try this:
private void wizardControl1_NextButtonClick(object sender, GenericCancelEventArgs<WizardBase.WizardControl> tArgs)
Regards,
Lenny
|
|
|
|
|
do this
private void wizardControl1_NextButtonClick(object sender, EventArgs e)
|
|
|
|
|
You've provided absolutely no explanatory text, there's almost no comments in the code, and that 2nd comment is exasperated by the fact that you're not responding to questions/bug reports.
|
|
|
|
|
Hello,
It's a nice control but why is not it possible to design step at design time? They look different at runtime and design time.
To be more precise, I need to click 'next step' from the smart tag to design next step, selecting instance of WizardBase.IntermidiateStep from dropdown box of properties window doesn't change to next step in designer.
|
|
|
|
|
When i click in the next button i get this error:
Message="The step must be well formed, so there cannot be a Finishstep without a Startstep."
Source="WizardBase"
any idea?
|
|
|
|
|
I had the same problem. I had to comment out some code to make it work again. Set a breakpoint on the error and comment out the code that causes the error. It's some kind of check but leaving it out doesn't hurt the functionality.
|
|
|
|
|
I am trying to direct the wizard to optional pages depending on whether or not a checkbox is checked on page 1 (index 0).
private void wizardControl1_NextButtonClick(object sender, WizardBase.GenericCancelEventArgs<WizardBase.WizardControl> tArgs)
{
if (checkBox1.Checked != true)
{
wizardControl1.CurrentStepIndex=2;
}
}
If the checkbox is checked, pressing the Next button moves to the next page as expected, however, if the checkbox is unchecked, the above code runs. I assume that setting the CurrentStepIndex - 2 should move focus to the third page - and there is a third - but instead of that, I get the following error...
Error Message: The step must be well formed, so there cannot be a Finishstep without a Startstep.uasi
|
|
|
|
|
I'm having the same problem, but nobody seems to care
|
|
|
|
|
Hi,
we added shortcuts and tootips to the wizard. It seems to work fine intially. Later on, i found that there is an issue.
Usually, the tooltip does not show up on the first step, when i go to the 2nd or 3rd step. It start working ; and once it start working, it works even on the first step.
The shortcut also work strangely, some time it works and sometime it does not. It may work on one step and would not work on the other step.
Are you aware of these issues ? what am i suppose to do. My project is almost finish and i need these features i.e. shortcuts and tooltips for sure. Please provide me with an update or something. Thanks,
Regards,
Osman
|
|
|
|
|
I went to put together a basic wizard form. I'd read the issue already mentioned that people had had errors about serialization with the LeftPair, but found myself wanting to change that value. I'd built the project and had used only a DLL reference to the resulting DLL and still had the same issue previously mentioned. I tried bringing it into the same solution, still no go. I can't modify that value or the data fails to save. I tried playing with Serialization attributes and figuring out what the true cause was, finally threw up my hands saying, the point of using a pre-built wizard control was to save time, not use it up. So I put that aside and looked at some other things.
I quickly noticed having changed the subtitle text to be more than one line that for the first line the shadow was on target, but the following line it rendered with a different offset. Back and forth it went every other line. I debugged and found that it was using floating math for each line independently. So one line would offset the shadow to 31.75 and the next to 31.19 causing a full pixel rounding difference on each line. To fix this, it needs to pre-compute a fixed size offset that all lines will use to get the text to render consistently.
I also noticed an odd coding pattern:
int Property
{
get { return base.Property; }
set
{
base.Property = value;
base.Property = 0;
}
}
I believe the author was a user of ReSharper (a good thing), and didn't want to see the warning about the lack of use of value, but wanted to force the property to a fixed value so didn't want to use the value provided. Elsewhere the author used the ReSharper "exclude warning" pragmas to accomplish the same thing, so I wonder why not here as well rather than double assignment.
Later I closed and re-opened my form, and boom, exception on load about reference to the DLL. Try to load the form again, it works. It was an intermittent issue. It sounded a lot like the one earlier post regarding having changed the sub-title.
All in all, the implementation looks really nice, but it just doesn't feel finished yet. There are too many little points I would feel the need to debug to put this into an application I would use and attempt to maintain. I wish this implementation the best, but am personally not ready to use it in its current state.
|
|
|
|
|
One more thing I thinkg would be great would be to put the Localizable attribute to the Title, Subtitle, etc members. I've just spent half an hours translating my form to realize it didn't keep the changes everywhere...
Anyway, I post this as a warning to anyone using this code. Don't forget to add the Localizable attribute if you're to work in multiple languages!
|
|
|
|
|
I love this example and am trying to design a multi-pane control based using this control as an example of the right way to do things. However... I am not understanding the following code...
protected override void OnSet(int index, object oldValue, object newValue)
{
GenericChangeEventArgs<T> e = new GenericChangeEventArgs<T>((T)oldValue, (T)newValue);
if (Changing != null)
{
Changing(index, e);
if (e.Cancel)
{
return;
}
}
base.OnSet(index, oldValue, newValue);
}
What does If (Changing != null) really do. If I translate this to VB.Net I get
Protected Overloads Overrides Sub OnSet(ByVal index As Integer, ByVal oldValue As Object, ByVal newValue As Object)
Dim e As New GenericChangeEventArgs(Of T)(DirectCast(oldValue, T), DirectCast(newValue, T))
If Changing IsNot Nothing Then
RaiseEvent Changing(index, e)
If e.Cancel Then Exit Sub
End If
MyBase.OnSet(index, oldValue, newValue)
End Sub ' (ByVal index As Integer, ByVal oldValue As Object, ByVal newValue As Object)
Where the line "If Changing IsNot Nothing Then" generates a compiler error...
Error 1 'Public Event Changing(index As Integer, e As GenericChangeEventArgs(Of T))' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event. C:\My Projects\VB.Net\etc\ezWizard\ezWizard\Collection\GenericCollection.vb 347 10 ezWizard
I would greatly appriciate any help anyone could give me. Anyone understand C# and VB.Net?
Keith Alan Yerian
|
|
|
|
|
That's common use, when there are no event handler associated with an event, the event is null and will throw a NullReferenceException if you remove this check. VB.NET does this automatically in the RaiseEvent shortcut.
|
|
|
|
|