private void ExitApplication() { _isExit = true; Mw.Close(); _notifyIcon.Dispose(); _notifyIcon = null; }
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(); }
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); } }
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(); }
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); } }
// 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); }
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; } }