private void ServerDataGrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     if (ServerDataGrid.SelectedCells.Count > 0 && ServerDataGrid.SelectedCells[0].Column != null)
     {
         if (ServerDataGrid.SelectedCells[0].Column.Header is string header && ServerDataGrid.SelectedCells[0].Item is Server serverObject)
         {
             var id = serverObject.Index - 1;
             if (header == I18N.GetString(@"Server"))
             {
                 var config = _controller.GetCurrentConfiguration();
                 Console.WriteLine($@"config.checkSwitchAutoCloseAll:{config.checkSwitchAutoCloseAll}");
                 if (config.checkSwitchAutoCloseAll)
                 {
                     _controller.DisconnectAllConnections();
                 }
                 _controller.SelectServerIndex(id);
             }
             else if (header == I18N.GetString(@"Enable"))
             {
                 var server = ServerLogViewModel.ServersCollection[id];
                 server.Enable = !server.Enable;
                 _controller.Save();
             }
             else if (header == I18N.GetString(@"Group"))
             {
                 var currentServer = ServerLogViewModel.ServersCollection[id];
                 var group         = currentServer.Group;
                 if (!string.IsNullOrEmpty(group))
                 {
                     var enable = !currentServer.Enable;
                     foreach (var server in ServerLogViewModel.ServersCollection)
                     {
                         if (server.Group == group)
                         {
                             if (server.Enable != enable)
                             {
                                 server.Enable = enable;
                             }
                         }
                     }
                     _controller.Save();
                 }
             }
             else
             {
                 ServerDataGrid.SelectedCells.Clear();
                 ServerDataGrid.CurrentCell = new DataGridCellInfo(serverObject, ServerDataGrid.Columns[0]);
                 ServerDataGrid.SelectedCells.Add(ServerDataGrid.CurrentCell);
             }
         }
     }
 }
        private void AServerItem_Click(object sender, EventArgs e)
        {
            Configuration config = controller.GetCurrentConfiguration();

            Console.WriteLine("config.checkSwitchAutoCloseAll:" + config.checkSwitchAutoCloseAll);
            if (config.checkSwitchAutoCloseAll)
            {
                controller.DisconnectAllConnections();
            }
            MenuItem item = (MenuItem)sender;

            controller.SelectServerIndex((int)item.Tag);
        }
Пример #3
0
 private void DisconnectAllMenuItem_OnClick(object sender, RoutedEventArgs e)
 {
     _controller.DisconnectAllConnections();
     Server.GetForwardServerRef().Connections.CloseAll();
 }