Hey everyone. This is only my first week with C#, but I use actionscript a
lot in Flash, so I have a very basic understanding of programming, but bear
with me...
I am trying to create a "FadeClass" that I can use to fade windows in my
programs. I am using Visual C# 2008 Express right now.
This is my "Form1.cs" in it's current state:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class IntroBox : Form
{
public IntroBox()
{
InitializeComponent();
faderClass(this, "out", 2000);
System.Timers.Timer fadeTimer = new System.Timers.Timer();
fadeTimer.Elapsed += new ElapsedEventHandler(OnTimer);
fadeTimer.Interval = 50;
fadeTimer.Enabled = true;
fadeTimer.SynchronizingObject = this;
fadeTimer.Start();
}
private void OnTimer(Object source, ElapsedEventArgs e)
{
this.Opacity += 0.1;
}
}
}
That works. The program loads up and the first window fades in perfectly.
Here is my "faderClass.cs" which is what I'm trying to get working. I'm
trying to understand how to make the class know which window it needs to fade
(in Flash it was very easy). You can see what I've tried in the code, but to
no avail:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Timers;
namespace WindowsFormsApplication1
{
class faderClass
{
public void Main(****** target, String inOut, int fadeTime)
{
System.Timers.Timer fadeTimer = new System.Timers.Timer();
fadeTimer.Elapsed += new ElapsedEventHandler(OnTimer);
fadeTimer.Interval = 50;
fadeTimer.Enabled = true;
fadeTimer.SynchronizingObject = target;
fadeTimer.Start();
}
private void OnTimer(object source, ElapsedEventArgs e)
{
target.Opacity += 0.1;
}
}
}
As you can see, I'm lost in 2 places... First of all I don't know what to
put where the stars ****** are, and second, I want to be able to use the
"target" variable in the OnTimer ElapsedEventHandler. Basically I would want
to call the function like so:
faderClass(this, "in", 2000);
So my class knows what to fade (this), which way to fade it (in or out), and
how long it should take (2 seconds). Any and all help is MUCH appreciated.
Thanks!