public Login(Serwer serwer)
 {
     InitializeComponent();
     this.serwer = serwer;
     this.obj = this;
     this.loginInStatus = false;
 }
 public MainWindow(Serwer serwer, string loginNick, CancellationTokenSource tokenSource)
 {
     InitializeComponent();
     this.obj = this;
     this.serwer = serwer;
     this.allContacts = new List<string>();
     this.loginNick = loginNick;
     Console.WriteLine(loginNick);
     this.Text = "Communicator - user " + this.loginNick;
     this.tokenSource = tokenSource;
 }
        static void Main()
        {
            //vps.tomys.pl:1234
            //192.168.0.28:1234
            Serwer serwer = new Serwer();

            serwer.showLoginWindow();
            while (serwer.work)
            {
            }
        }
        public ChatWindow(string nick, string loginNick, Serwer serwer, string allMessages, User user, CancellationTokenSource tokenSource)
        {
            InitializeComponent();
            this.obj = this;

            this.Text = "Chat with " + nick;
            this.nick = nick;
            this.allMessages = allMessages;
            this.serwer = serwer;
            this.loginNick = loginNick;
            Console.WriteLine(allMessages);
            this.setMessages(this.allMessages);
            this.user = user;
            this.tokenSource = tokenSource;
        }
        public User(string nick, string loginNick, Serwer serwer)
        {
            this.nick = nick;
            this.serwer = serwer;
            this.loginNick = loginNick;
            this.tokenSource = new CancellationTokenSource();
            var token = this.tokenSource.Token;

            this.chat = new ChatWindow(this.nick, this.loginNick, this.serwer, this.allMessages, this, tokenSource);
            this.showChat = true;

            var t = Task.Run(() =>
            {
                Application.Run(this.chat);
            }, token);
        }