Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0 C#3.0 C# C#4.0
This is a demo project drawboard. I would like to make it so that all clients connected to one server see whatever I draw on that board. I have created a class called MyMouseEventArgs class.
I do not know how to proceed after that.
 
I have posted my code below:
if (isdrawing)
           {
               using (Graphics gr=this.CreateGraphics())
               {
                   gr.DrawLine(p, prev, e.Location);
                   cv.Coordinates.Add(prev);
                   prev = e.Location;
               }
           }
           p.Dispose();
       }
 
This is the function I am using to draw on the form.
 
This is my serialized class which I am going to pass.
[Serializable]
    class MyMouseEventArgs : EventArgs
    {
        public MyMouseEventArgs(MouseButtons button, int clicks, int x, int y, int delta)
        {
            _Button = button;
            _Clicks = clicks;
            _X = x;
            _Y = y;
            _Delta = delta;
        }
 
        private MouseButtons _Button;
        private int _Clicks;
        private int _Delta;
        private int _X;
        private int _Y;
 
        public MouseButtons Button { get { return _Button; } }
        public int Clicks { get { return _Clicks; } }
        public int Delta { get { return _Delta; } }
        public Point Location { get { return new Point(_X, _Y); } }
        public int X { get { return _X; } }
        public int Y { get { return _Y; } }
 
        public static implicit operator MyMouseEventArgs(MouseEventArgs e)
        {
            return new MyMouseEventArgs(e.Button, e.Clicks, e.X, e.Y, e.Delta);
        }
        public static implicit operator MouseEventArgs(MyMouseEventArgs e)
        {
            return new MouseEventArgs(e.Button, e.Clicks, e.X, e.Y, e.Delta);
        }
    }
Whenever the draw event occurs it has to draw on the client screens too.
I have little knowledge about the concept serialization.
 
If you help me I promise that I will give you the code for unlimited file transfer over LAN network (c#).
Posted 13-Nov-11 2:27am
Edited 13-Nov-11 5:07am
v5
Comments
Richard MacCutchan at 13-Nov-11 7:40am
   
Sorry but nobody is going to download your source; show the piece that does not work, explain what the problem is, and people will try to help you.
mohanrajkiller at 13-Nov-11 8:11am
   
i have given the code
Mehdi Gholam at 13-Nov-11 8:04am
   
EDIT -> moved update from OP's solution post
mohanrajkiller at 13-Nov-11 8:09am
   
sorry i am new to this forum :( what can i do to show on my client screen

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Here[^] are some links to help with serialisation; you may wish to use XML or implement your own structure to transport the information. I am assuming that you already have the client/server part working.
  Permalink  
Comments
mohanrajkiller at 13-Nov-11 9:01am
   
i have hardly a day time as i am totally confused
i need sytax for example if e is the object of my class how can i send them toward client and the code for deserialization :( i promise i will give you the code for unlimited data tranfe c# code project made by my friend
Richard MacCutchan at 13-Nov-11 9:42am
   
Why would I want some code from your friend in return for giving you the code for this problem?
 
If you don't have time to do this then I suggest you move on and find something that you can achieve. I'm afraid this site is here to help people who help themselves, not to do their work for them.
mohanrajkiller at 13-Nov-11 10:18am
   
i am sorry i have learned from you !
i feel guilty :(
mohanrajkiller at 13-Nov-11 10:40am
   
i have read that xml serialization how to send that as bytestream through network
Richard MacCutchan at 13-Nov-11 10:56am
   
Lots of ways, take a look at this.
mohanrajkiller at 13-Nov-11 11:27am
   
but in that page after xml serialization it is stored in computer how to transfer . thank you for guiding ::)
Richard MacCutchan at 13-Nov-11 12:27pm
   
Have you ever heard of sockets?
mohanrajkiller at 14-Nov-11 1:04am
   
yes it took some time to read in detail will i be able to connect upto 50 clients using that
Richard MacCutchan at 14-Nov-11 4:25am
   
In theory you can connect an unlimited number, it all depends on the speed of your hardware and the efficiency of your software.
mohanrajkiller at 14-Nov-11 7:43am
   
ok how can i differentiate server and client in socket!
Richard MacCutchan at 14-Nov-11 12:04pm
   
The server is at the other end! Come on, read the documentation and try and learn for yourself.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 13 Nov 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100