示例#1
0
 private void chooseConnection(object sender, RoutedEventArgs e)
 {
     if (connectionListBox.SelectedItem is ListBoxItem item)
     {
         string key = item.Content.ToString();
         chosenConnection = connections[key];
     }
 }
示例#2
0
        private void addConnectionToJson(object sender, RoutedEventArgs e)
        {
            Options current    = GetOptionsFromJson();
            var     connection = new CloudConnection
            {
                AccessKeyId     = accessKeyText.Text,
                BucketName      = bucketNameText.Text,
                SecretAccessKey = secretAccessText.Text,
                ServiceUrl      = serviceUrlText.Text
            };

            current.CloudConnections.Add(connection);
            string optionsJson = JsonConvert.SerializeObject(current);

            File.WriteAllText("./settings.json", optionsJson);
            addConnection(connection);
        }
示例#3
0
        private void addConnection(CloudConnection con)
        {
            if (connections.Count == 0)
            {
                connectionListBox.Items.Clear();
            }
            var key        = $"{con.ServiceUrl}";
            var protoIndex = key.LastIndexOf("://");

            if (protoIndex != -1)
            {
                key = key.Insert(protoIndex + 3, $"{con.BucketName}.");
            }
            if (connections.TryAdd(key, con))
            {
                connectionListBox.Items.Add(new ListBoxItem {
                    Content = key
                });
            }
        }