udpclient problem ...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • yvz@zahav.net.il

    udpclient problem ...

    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 : "TaskbarNotifie r"

    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.ReadLin e();
    if(name == "") break;
    byte[] sdata = Encoding.ASCII. GetBytes(name);
    udpc.Send(sdata ,sdata.Length);
    byte[] rdata = udpc.Receive(re f ep);
    string job = Encoding.ASCII. GetString(rdata );
    Console.WriteLi ne(job);
    shwin() ; // this
    function call the main function in Class#2



    }



    public void shwin()
    {
    taskbarNotifier 1.CloseClickabl e= true ;
    taskbarNotifier 1.TitleClickabl e= false;
    taskbarNotifier 1.ContentClicka ble=true;
    taskbarNotifier 1.EnableSelecti onRectangle=tru e;
    taskbarNotifier 1.KeepVisibleOn MousOver=true;
    taskbarNotifier 1.ReShowOnMouse Over=true;
    taskbarNotifier 1.Sho(Title,Con tent
    ,MsgNumber,Int3 2.Parse(DelaySh owing),Int32.Pa rse(DelayStayin g),Int32.Parse( DelayHiding));

    }


    here is the code from class#2 :

    [DllImport("user 32.dll")]
    private static extern Boolean ShowWindow(IntP tr hWnd,Int32
    nCmdShow);
    public void Show(string strTitle, string strContent,stri ng
    strMsgNumber, int nTimeToShow, int nTimeToStay, int nTimeToHide)
    {
    WorkAreaRectang le = Screen.GetWorki ngArea(WorkArea Rectangle);
    titleText = strTitle;
    contentText = strContent;
    MsgNumberText = strMsgNumber;
    nVisibleEvents = nTimeToStay;
    CalculateMouseR ectangles();

    // We calculate the pixel increment and the timer value for the
    showing animation
    int nEvents;
    if (nTimeToShow 10)
    {
    nEvents = Math.Min((nTime ToShow / 10), BackgroundBitma p.Height);
    nShowEvents = nTimeToShow / nEvents;
    nIncrementShow = BackgroundBitma p.Height / nEvents;
    }
    else
    {
    nShowEvents = 10;
    nIncrementShow = BackgroundBitma p.Height;
    }

    // We calculate the pixel increment and the timer value for the
    hiding animation
    if( nTimeToHide 10)
    {
    nEvents = Math.Min((nTime ToHide / 10), BackgroundBitma p.Height);
    nHideEvents = nTimeToHide / nEvents;
    nIncrementHide = BackgroundBitma p.Height / nEvents;
    }
    else
    {
    nHideEvents = 10;
    nIncrementHide = BackgroundBitma p.Height;
    }

    switch (taskbarState)
    {
    case TaskbarStates.h idden:
    taskbarState = TaskbarStates.a ppearing;
    SetBounds(WorkA reaRectangle.Ri ght-BackgroundBitma p.Width-17,
    WorkAreaRectang le.Bottom-1, BackgroundBitma p.Width, 0);
    timer.Interval = nShowEvents;
    timer.Start();
    // We Show the popup without stealing focus
    ShowWindow(this .Handle, 4);
    break;

    case TaskbarStates.a ppearing:
    Refresh();
    break;

    case TaskbarStates.v isible:
    timer.Stop();
    timer.Interval = nVisibleEvents;
    timer.Start();
    Refresh();
    break;

    case TaskbarStates.d isappearing:
    timer.Stop();
    taskbarState = TaskbarStates.v isible;
    SetBounds(WorkA reaRectangle.Ri ght-BackgroundBitma p.Width-17,
    WorkAreaRectang le.Bottom-BackgroundBitma p.Height-1,
    BackgroundBitma p.Width, BackgroundBitma p.Height);
    timer.Interval = nVisibleEvents;
    timer.Start();
    Refresh();
    break;
    }
    }

Working...