SlideControl – A .NET Control with Slide Effects

The other day I was working on Parsley and noticed that I needed a simple user interface. For Parsley I devised a single main window interface with an additional live-video and rendering windows. As none of the predefined controls suited my visual needs, I came up with SlideControl, I slick container control with slide effects when switching between slides.

Here is what SlideControl looks like in Parsley.

Since I avoid UI programming whenever possible, doing UI programming with SlideControl had to be darn simple (well, at least not more complicated than using other controls).

Here is how to use SlideControl 1.0

SlickInterface.SlideControl is a container control that is placed on your Form and allows the addition of slides. A slide is a class that inherits from SlickInterface.Slide. Since SlickInterface.Slide itself is a UserControl you can use the designer to change its appearance.

Once your SlickInterface.SlideControl is in place and slides have been designed, they are added to the control

_a = new SlideA();
_b = new SlideB();
_c = new SlideC();

_slide_control.AddSlide(_a);
_slide_control.AddSlide(_b);
_slide_control.AddSlide(_c);

By default, the last added slide is the one shown. This can changed at any time by invoking

 _slide_control.Selected = _a;

Setting the SlickInterface.SlideControl.Selected property will not animate your slides. To switch between slides with animation use the ForwardTo and Backward methods.

_slide_control.ForwardTo<slideb>();

This will slide out the currently selected slide and set the new selected slide to the first instance of SlideB found in the container. Additionally, the previously selected slide is added to the backtracking-stack. To move backward to the previous slide, simply call

_slide_control.Backward();

The SlickInterface.SlideControl is accessible from within SlickInterface.Slide instances through the SlickInterface.Slide.SlideControl property.

this.SlideControl.ForwardTo<slidec>();

Slides may override the following two hooks invoked by SlickInterface.SlideControl

protected virtual void OnSlidingIn();
protected virtual void OnSlidingOut(CancelEventArgs args);

Whenever a slide change occurred, SlickInterface.SlideControl provides you with the SlideChanged event.

_slide_control.SlideChanged += new EventHandler<slickinterface.slidechangedargs>(Callback);

void Callback(object sender, SlickInterface.SlideChangedArgs e) {
  Console.WriteLine("Slide changed from {0} to {1}", e.Previous, e.Now);
}

Links

About these ads

2 thoughts on “SlideControl – A .NET Control with Slide Effects

  1. I have followed all the steps but for some reason the slides don’t appear. The sidechanged event is fired however but nothing is ever displayed in the slidercontrol.

    Any pointers?

  2. Downloaded Parsley and it doesn’t have any animation on that?! It just appears now sliding screens at all.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s