/// <summary> /// constructor /// конструктор /// </summary> /// <param name="isTester">shows whether the method is called from the tester / вызывается ли метод из тестера </param> public ServerMasterUi(bool isTester) { InitializeComponent(); List <IServer> servers = ServerMaster.GetServers(); if (isTester) { servers = ServerMaster.GetServers(); if (servers == null || servers.Find(s => s.ServerType == ServerType.Tester) == null) { ServerMaster.CreateServer(ServerType.Tester, false); } Close(); servers = ServerMaster.GetServers(); servers.Find(s => s.ServerType == ServerType.Tester).ShowDialog(); } Title = OsLocalization.Market.TitleServerMasterUi; TabItem1.Header = OsLocalization.Market.TabItem1; TabItem2.Header = OsLocalization.Market.TabItem2; CheckBoxServerAutoOpen.Content = OsLocalization.Market.Label20; ServerMasterPainter painter = new ServerMasterPainter(HostSource, HostLog, CheckBoxServerAutoOpen); Closing += delegate(object sender, CancelEventArgs args) { painter.Dispose(); painter = null; }; }
/// <summary> /// constructor /// конструктор /// </summary> /// <param name="isTester">shows whether the method is called from the tester / вызывается ли метод из тестера </param> public ServerMasterUi(bool isTester) { InitializeComponent(); List <IServer> servers = ServerMaster.GetServers(); if (isTester) { servers = ServerMaster.GetServers(); if (servers == null || servers.Find(s => s.ServerType == ServerType.Tester) == null) { ServerMaster.CreateServer(ServerType.Tester, false); } Close(); servers = ServerMaster.GetServers(); servers.Find(s => s.ServerType == ServerType.Tester).ShowDialog(); } CreateSourceGrid(); RePaintSourceGrid(); CheckBoxServerAutoOpen.IsChecked = ServerMaster.NeadToConnectAuto; CheckBoxServerAutoOpen.Click += CheckBoxServerAutoOpen_Click; ServerMaster.Log.StartPaint(HostLog); for (int i = 0; servers != null && i < servers.Count; i++) { servers[i].ConnectStatusChangeEvent += ServerStatusChangeEvent; } Title = OsLocalization.Market.TitleServerMasterUi; TabItem1.Header = OsLocalization.Market.TabItem1; TabItem2.Header = OsLocalization.Market.TabItem2; CheckBoxServerAutoOpen.Content = OsLocalization.Market.Label20; ServerMaster.ServerCreateEvent += ServerMasterOnServerCreateEvent; Closing += delegate(object sender, CancelEventArgs args) { ServerMaster.ServerCreateEvent -= ServerMasterOnServerCreateEvent; for (int i = 0; servers != null && i < servers.Count; i++) { IServer serv = servers[i]; if (serv == null) { continue; } serv.ConnectStatusChangeEvent -= ServerStatusChangeEvent; } }; }
/// <summary> /// double click evet on the source table /// событие двойного клика на таблицу источников /// </summary> void _gridSources_DoubleClick(object sender, EventArgs e) { if (_gridSources.CurrentCell.RowIndex <= -1) { return; } ServerType type; Enum.TryParse(_gridSources.SelectedRows[0].Cells[0].Value.ToString(), out type); List <IServer> servers = ServerMaster.GetServers(); if (servers == null || servers.Find(serv => serv.ServerType == type) == null) { // need to create a server for the first time // нужно впервые создать сервер ServerMaster.CreateServer(type, true); servers = ServerMaster.GetServers(); if (servers == null) { // something went wrong / что-то пошло не так return; } else { // subscribe to the change status event / подписываемся на событие изменения статуса IServer myServ = servers.Find(serv => serv.ServerType == type); if (myServ != null) { myServ.ConnectStatusChangeEvent += ServerStatusChangeEvent; } } } IServer myServer = servers.Find(serv => serv.ServerType == type); if (myServer == null) { return; } myServer.ShowDialog(); }
/// <summary> /// конструктор /// </summary> /// <param name="isTester">вызывается ли метод из тестера</param> public ServerMasterUi(bool isTester) { InitializeComponent(); List <IServer> servers = ServerMaster.GetServers(); if (isTester) { servers = ServerMaster.GetServers(); if (servers == null || servers.Find(s => s.ServerType == ServerType.Tester) == null) { ServerMaster.CreateServer(ServerType.Tester, false); } Close(); servers = ServerMaster.GetServers(); servers.Find(s => s.ServerType == ServerType.Tester).ShowDialog(); } CreateSourceGrid(); RePaintSourceGrid(); CheckBoxServerAutoOpen.IsChecked = ServerMaster.NeadToConnectAuto; CheckBoxServerAutoOpen.Click += CheckBoxServerAutoOpen_Click; CheckBoxServerAutoOpen.ToolTip = "При включении, мастер серверов будет пытаться автоматически развернуть " + "\r" + "сервера которые у него запрашивают роботы(панели). По одному разу на каждый сервер. "; ServerMaster.Log.StartPaint(HostLog); for (int i = 0; servers != null && i < servers.Count; i++) { servers[i].ConnectStatusChangeEvent += ServerStatusChangeEvent; } }