예제 #1
0
 public EditProfileWindow(SavedProfile selected_profile)
 {
     this.profile = selected_profile;
     InitializeComponent();
     this.profile_textBox.Text  = this.profile.ProfileName;
     this.username_textBox.Text = this.profile.UserName;
     this.host_textBox.Text     = this.profile.Host;
     this.password_textBox.Text = this.profile.Password;
     this.port_textBox.Text     = this.profile.Port.ToString();
 }
예제 #2
0
        private void Edit_Click(object sender, RoutedEventArgs e)
        {
            Button       button          = sender as Button;
            SavedProfile selectedProfile = button.DataContext as SavedProfile;

            Point             p         = button.PointToScreen(new Point());
            EditProfileWindow editPopup = new EditProfileWindow(selectedProfile);

            editPopup.Left = p.X;
            editPopup.Top  = p.Y + 25;
            editPopup.ShowDialog();
            listView.Items.Refresh();
        }
예제 #3
0
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            Button       button          = sender as Button;
            SavedProfile selectedProfile = button.DataContext as SavedProfile;

            MessageBoxResult result = MessageBox.Show("Are you sure you want to delete profile: " + selectedProfile.QuickName + " on " + selectedProfile.Port + "?", "Delete this profile?", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                SavedProfiles.Instance.Remove(selectedProfile.ProfileID);

                this.listView.ItemsSource = SavedProfiles.Instance.ListAll();
            }
        }
예제 #4
0
        public SavedProfile Add(string description, string userName, string host, string password, int port)
        {
            int maxID      = 0;
            var maxProfile = this.profiles.OrderByDescending(x => x.ProfileID).FirstOrDefault();

            if (maxProfile != null)
            {
                maxID = maxProfile.ProfileID + 1;
            }

            var newProfile = new SavedProfile()
            {
                ProfileID   = maxID,
                ProfileName = description,
                UserName    = userName,
                Host        = host,
                Password    = password,
                Port        = port
            };

            this.profiles.Add(newProfile);

            return(newProfile);
        }