hi !! im a beginner in C# .... here is my problem ...
i have 2 classes :
1. start an udpclient listener : "Form1"
2. display a Taskbar Notifier windows : "TaskbarNotifier"
i need 2 diaplay the window from class # 2 when the updclient
receiveing data ...
i try everyting (including start in new thread )but no success ....
please help ...
here is the code from class#1 :
UdpClient udpc = new UdpClient("10.0.0.1",2055);
IPEndPoint ep = null;
while(true)
{
Console.Write("Name: ");
string name = Console.ReadLine();
if(name == "") break;
byte[] sdata = Encoding.ASCII.GetBytes(name);
udpc.Send(sdata,sdata.Length);
byte[] rdata = udpc.Receive(ref ep);
string job = Encoding.ASCII.GetString(rdata);
Console.WriteLine(job);
shwin() ; // this
function call the main function in Class#2
}
public void shwin()
{
taskbarNotifier1.CloseClickable= true ;
taskbarNotifier1.TitleClickable= false;
taskbarNotifier1.ContentClickable=true;
taskbarNotifier1.EnableSelectionRectangle=true;
taskbarNotifier1.KeepVisibleOnMousOver=true;
taskbarNotifier1.ReShowOnMouseOver=true;
taskbarNotifier1.Sho(Title,Content
,MsgNumber,Int32.Parse(DelayShowing),Int32.Parse(D elayStaying),Int32.Parse(DelayHiding));
}
here is the code from class#2 :
[DllImport("user32.dll")]
private static extern Boolean ShowWindow(IntPtr hWnd,Int32
nCmdShow);
public void Show(string strTitle, string strContent,string
strMsgNumber, int nTimeToShow, int nTimeToStay, int nTimeToHide)
{
WorkAreaRectangle = Screen.GetWorkingArea(WorkAreaRectangle);
titleText = strTitle;
contentText = strContent;
MsgNumberText = strMsgNumber;
nVisibleEvents = nTimeToStay;
CalculateMouseRectangles();
// We calculate the pixel increment and the timer value for the
showing animation
int nEvents;
if (nTimeToShow 10)
{
nEvents = Math.Min((nTimeToShow / 10), BackgroundBitmap.Height);
nShowEvents = nTimeToShow / nEvents;
nIncrementShow = BackgroundBitmap.Height / nEvents;
}
else
{
nShowEvents = 10;
nIncrementShow = BackgroundBitmap.Height;
}
// We calculate the pixel increment and the timer value for the
hiding animation
if( nTimeToHide 10)
{
nEvents = Math.Min((nTimeToHide / 10), BackgroundBitmap.Height);
nHideEvents = nTimeToHide / nEvents;
nIncrementHide = BackgroundBitmap.Height / nEvents;
}
else
{
nHideEvents = 10;
nIncrementHide = BackgroundBitmap.Height;
}
switch (taskbarState)
{
case TaskbarStates.hidden:
taskbarState = TaskbarStates.appearing;
SetBounds(WorkAreaRectangle.Right-BackgroundBitmap.Width-17,
WorkAreaRectangle.Bottom-1, BackgroundBitmap.Width, 0);
timer.Interval = nShowEvents;
timer.Start();
// We Show the popup without stealing focus
ShowWindow(this.Handle, 4);
break;
case TaskbarStates.appearing:
Refresh();
break;
case TaskbarStates.visible:
timer.Stop();
timer.Interval = nVisibleEvents;
timer.Start();
Refresh();
break;
case TaskbarStates.disappearing:
timer.Stop();
taskbarState = TaskbarStates.visible;
SetBounds(WorkAreaRectangle.Right-BackgroundBitmap.Width-17,
WorkAreaRectangle.Bottom-BackgroundBitmap.Height-1,
BackgroundBitmap.Width, BackgroundBitmap.Height);
timer.Interval = nVisibleEvents;
timer.Start();
Refresh();
break;
}
}