コード例 #1
0
 private void ExitApplication()
 {
     _isExit = true;
     Mw.Close();
     _notifyIcon.Dispose();
     _notifyIcon = null;
 }
コード例 #2
0
 public void MyInitializer()
 {
     tk          = new Tk();
     tw          = new Tw();
     mk          = new Mk();
     mw          = new Mw();
     nz          = new Nz();
     nw          = new Nw();
     d           = new D();
     oplossingen = new List <string>();
     antwoord    = "";
     VulKlimatogram();
 }
コード例 #3
0
 private void Mw_Closing(object sender, CancelEventArgs e)
 {
     if (!_isExit)
     {
         genContextMenu();
         e.Cancel = true;
         Mw.Hide();
         _notifyIcon.BalloonTipIcon  = System.Windows.Forms.ToolTipIcon.Info;
         _notifyIcon.BalloonTipText  = "This program has minimised to the tray. You can open it back up by double-clicking the icon.";
         _notifyIcon.BalloonTipTitle = "Program still running.";
         _notifyIcon.ShowBalloonTip(3000);
     }
 }
コード例 #4
0
        private void RemoveClient(PacketHeader header, Connection connection, string message)
        {
            currentPosition = -1;

            Dispatcher.BeginInvoke(new Action(() =>
            {
                PositionLabel.Text     = "Not in Queue...";
                CancelButton.IsEnabled = false;
                _notifyIcon.Text       = "Request for help.";
                Mw.Close();
            }));

            Connection.StopListening();
        }
コード例 #5
0
 private void ShowMainWindow()
 {
     if (Mw.IsVisible)
     {
         if (Mw.WindowState == WindowState.Minimized)
         {
             Mw.WindowState = WindowState.Normal;
         }
         Mw.Activate();
     }
     else
     {
         Mw.Show();
         SendForHelp();
         _notifyIcon.ContextMenuStrip.Items.RemoveAt(0);
     }
 }
コード例 #6
0
        // TODO: Add user list
        public static void OnUserConnect(IAsyncResult ar)
        {
            SausageConnection user;

            try
            {
                user = new SausageConnection(MainSocket.EndAccept(ar));
            }
            catch (SocketException ex)
            {
                Close();
                return;
            }
            catch (ObjectDisposedException ex)
            {
                return;
            }
            if (!Blacklisted.Any(x => x == user.Ip.Address))
            {
                UiCtx.Send(x => ConnectedUsers.Add(user));
                UiCtx.Send(x => Vm.ConnectedUsers = SortUsersList());
                UiCtx.Send(x => Vm.Messages.Add(new ServerMessage($"{user} has connected")));
                UiCtx.Send(x => Mw.AddTextToDebugBox($"User connected on {user.Ip}\n"));
                // global packet for all the users to know the user has joined
                PacketFormat GlobalPacket = new PacketFormat(PacketOption.UserConnected)
                {
                    Guid    = user.UserInfo.Guid,
                    NewName = user.UserInfo.Name
                };
                // local packet for the user (who joined) to get his GUID
                PacketFormat LocalPacket = new PacketFormat(PacketOption.GetGuid)
                {
                    Guid      = user.UserInfo.Guid,
                    UsersList = UsersDictionary.ToArray()
                };
                UsersDictionary.Add(user.UserInfo);
                user.SendAsync(LocalPacket);
                Log(GlobalPacket, user);
            }
            else
            {
                // doesn't log if the user is blacklisted
                user.Disconnect();
            }
            MainSocket.BeginAccept(OnUserConnect, null);
        }
コード例 #7
0
 private void dispatcherTimer_Tick(object sender, EventArgs e)
 {
     try
     {
         if (Connection.Listening(ConnectionType.TCP) == true || Connection.Listening(ConnectionType.UDP) == true)
         {
             NetworkComms.SendObject("KeepAlive", serverIP, serverPort, name);
         }
     }
     catch (Exception)
     {
         Mw.Close();
         dispatcherTimer.Stop();
         _notifyIcon.BalloonTipIcon  = System.Windows.Forms.ToolTipIcon.Info;
         _notifyIcon.BalloonTipText  = "Error connecting to server. Please try again later.";
         _notifyIcon.BalloonTipTitle = "Error connecting.";
         _notifyIcon.ShowBalloonTip(3000);
         _notifyIcon.Text       = "Error connecting.";
         PositionLabel.Text     = "Not in Queue...";
         CancelButton.IsEnabled = false;
     }
 }