Exemplo n.º 1
0
        private void RemoveServerToTreeView(SettingsServer settingsServer)
        {
            var    servers = (ObservableCollection <Server>)TV.ItemsSource;
            Server server  = servers.FirstOrDefault(s => s.Url.EqualsIgnoreCase(settingsServer.Url));

            servers.Remove(server);
        }
Exemplo n.º 2
0
        private void TreeViewDelete_Click(object sender, RoutedEventArgs e)
        {
            var item = TV.SelectedItem as TreeItem;

            if (item != null)
            {
                if (this.ShowConfirm("Delete " + item.GetType().Name + " '" + item.DisplayName + "'?") == MessageBoxResult.No)
                {
                    return;
                }

                var server = item as Server;
                if (server != null)
                {
                    var settingsServer = new SettingsServer {
                        Url = server.Url
                    };
                    RemoveServerToTreeView(settingsServer);
                    Settings.RemoveServer(settingsServer);
                    Settings.SerializeToConfiguration();
                }
                else if (item.Delete())
                {
                    if (item.Parent != null)
                    {
                        item.Parent.Reload();
                    }
                }
            }
        }
Exemplo n.º 3
0
        public Connect(SettingsServer server)
        {
            if (server == null)
            {
                throw new ArgumentNullException(nameof(server));
            }

            DataContext = server;
            InitializeComponent();
        }
Exemplo n.º 4
0
        private void AddServerToTreeView(SettingsServer settingsServer)
        {
            var server = new Server();

            server.DisplayName = settingsServer.Url;
            server.Cookie      = settingsServer.Cookie;

            var servers = (ObservableCollection <Server>)TV.ItemsSource;

            servers.Add(server);
        }
Exemplo n.º 5
0
        private void Connect_Click(object sender, RoutedEventArgs e)
        {
            var server = new SettingsServer();
            var dlg    = new Connect(server);

            dlg.Owner = this;
            if (dlg.ShowDialog().GetValueOrDefault())
            {
                Settings.AddServer(server);
                Settings.SerializeToConfiguration();
                AddServerToTreeView(server);
            }
        }
Exemplo n.º 6
0
        public bool AddServer(SettingsServer server)
        {
            if (server == null)
            {
                throw new ArgumentNullException(nameof(server));
            }

            SettingsServer existing = GetServer(server.Url);

            if (existing != null)
            {
                return(false);
            }

            _servers.Add(server);
            return(true);
        }
Exemplo n.º 7
0
        public bool RemoveServer(SettingsServer server)
        {
            if (server == null)
            {
                throw new ArgumentNullException(nameof(server));
            }

            SettingsServer existing = GetServer(server.Url);

            if (existing == null)
            {
                return(false);
            }

            bool b = _servers.Remove(existing);

            return(b);
        }