// Метод: Загрузка списка подключений (окно: Connection List) ----------------------------------------------------- private void LoadAllConnections() { string connName = XmlClass.GetSelectedConnectionName(); if (connName == "") { Action ac = () => { ConnectionListPanel.ButtonSelectedConnectionCheck.IsEnabled = false; }; Dispatcher.Invoke(ac); } else { Action ac = () => { ConnectionListPanel.ButtonSelectedConnectionCheck.IsEnabled = true; }; Dispatcher.Invoke(ac); } Action action = () => { ArrayList Connectionslist = XmlClass.ReadAllConnectionsName(); for (int i = 0; i < Connectionslist.Count; i++) { ConnectionRB CRB = new ConnectionRB(); CRB.FontFamily = new FontFamily("Roboto Condensed"); CRB.Foreground = new SolidColorBrush((Color)Application.Current.FindResource("Dark-003")); CRB.Deleted += CRB_Deleted;; CRB.Checked += CRB_Checked;; CRB.Content = Connectionslist[i].ToString(); ConnectionListPanel.stpConnectionList.Children.Add(CRB); if (CRB.Content.ToString() == connName) { CRB.IsChecked = true; } } Loader = null; if (ConnectionListPanel.stpConnectionList.Children.Count > 0) { ShowMessage("Выберите подключение или создайте новое подключение.", "Blue-004"); } else { ShowMessage("Cоздайте новое подключение.", "Red-001"); } }; Dispatcher.Invoke(action); }
// Метод: Удаление подключения (окно: Connection List) ------------------------------------------------------------ private void DeleteConnection(object sender) { Action action = () => { ConnectionRB CRB = sender as ConnectionRB; bool isCheck = (bool)CRB.IsChecked; StackPanel sp = CRB.Parent as StackPanel; sp.Children.Remove(CRB); XmlClass.DeleteConnection(CRB.Content.ToString()); if (isCheck && sp.Children.Count >= 1)// если удален выбранный и есть еще { XmlClass.DeSelectAllConnections(); ConnectionRB crb = sp.Children[sp.Children.Count - 1] as ConnectionRB; crb.IsChecked = true; } Loader = null; }; Dispatcher.Invoke(action); }