コード例 #1
0
ファイル: LoginForm.xaml.cs プロジェクト: ewelike23/jmm
        public LoginForm()
        {
            InitializeComponent();

            btnLogin.Click += new RoutedEventHandler(btnLogin_Click);

            ThisUser = null;

            cboUsers.Items.Clear();

            List <JMMServerBinary.Contract_JMMUser> users = JMMServerVM.Instance.clientBinaryHTTP.GetAllUsers();

            foreach (JMMServerBinary.Contract_JMMUser user in users)
            {
                cboUsers.Items.Add(new JMMUserVM(user));
            }

            if (cboUsers.Items.Count > 0)
            {
                cboUsers.SelectedIndex = 0;
            }

            txtPassword.PasswordChanged += new RoutedEventHandler(txtPassword_PasswordChanged);
            this.Loaded += new RoutedEventHandler(LoginForm_Loaded);
        }
コード例 #2
0
        private void CommandBinding_DeleteUser(object sender, ExecutedRoutedEventArgs e)
        {
            object obj = e.Parameter;

            if (obj == null)
            {
                return;
            }

            try
            {
                if (obj.GetType() == typeof(JMMUserVM))
                {
                    JMMUserVM user = (JMMUserVM)obj;

                    MessageBoxResult res = MessageBox.Show(string.Format("Are you sure you want to delete the User: {0}", user.Username),
                                                           "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question);
                    if (res == MessageBoxResult.Yes)
                    {
                        if (user.JMMUserID.HasValue)
                        {
                            if (user.JMMUserID.Value == JMMServerVM.Instance.CurrentUser.JMMUserID.Value)
                            {
                                MessageBox.Show("Cannot delete currently logged in user", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                                return;
                            }
                        }

                        this.Cursor = Cursors.Wait;
                        string ret = JMMServerVM.Instance.clientBinaryHTTP.DeleteUser(user.JMMUserID.Value);
                        this.Cursor = Cursors.Arrow;
                        if (ret.Length > 0)
                        {
                            MessageBox.Show(ret, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        }

                        JMMServerVM.Instance.RefreshAllUsers();

                        if (lbUsers.Items.Count > 0)
                        {
                            lbUsers.SelectedIndex = 0;
                            lbUsers.Focus();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
コード例 #3
0
        public UserAdminControl()
        {
            InitializeComponent();

            IsUserSelected = false;
            SelectedUser   = null;

            this.Loaded += new RoutedEventHandler(UserAdminControl_Loaded);
            lbUsers.SelectionChanged += new SelectionChangedEventHandler(lbUsers_SelectionChanged);

            lbCategories.MouseDoubleClick += new MouseButtonEventHandler(lbCategories_MouseDoubleClick);

            btnNewUser.Click        += new RoutedEventHandler(btnNewUser_Click);
            btnSave.Click           += new RoutedEventHandler(btnSave_Click);
            btnChangePassword.Click += new RoutedEventHandler(btnChangePassword_Click);
        }
コード例 #4
0
        public UserAdminControl()
        {
            InitializeComponent();

            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(AppSettings.Culture);

            IsUserSelected = false;
            SelectedUser   = null;

            this.Loaded += new RoutedEventHandler(UserAdminControl_Loaded);
            lbUsers.SelectionChanged += new SelectionChangedEventHandler(lbUsers_SelectionChanged);

            lbTags.MouseDoubleClick += new MouseButtonEventHandler(lbTags_MouseDoubleClick);

            btnNewUser.Click        += new RoutedEventHandler(btnNewUser_Click);
            btnSave.Click           += new RoutedEventHandler(btnSave_Click);
            btnChangePassword.Click += new RoutedEventHandler(btnChangePassword_Click);
        }
コード例 #5
0
        void lbUsers_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lbUsers.Items.Count == 0)
            {
                IsUserSelected = false;
                SelectedUser   = null;
                return;
            }

            SelectedUser = lbUsers.SelectedItem as JMMUserVM;
            if (SelectedUser == null)
            {
                IsUserSelected = false;
            }
            else
            {
                IsUserSelected = true;
            }

            DisplayUser();
        }
コード例 #6
0
ファイル: LoginForm.xaml.cs プロジェクト: ewelike23/jmm
        void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            ThisUser = null;

            JMMUserVM user = cboUsers.SelectedItem as JMMUserVM;

            if (user != null)
            {
                JMMServerBinary.Contract_JMMUser retUser = JMMServerVM.Instance.clientBinaryHTTP.AuthenticateUser(user.Username, txtPassword.Password.Trim());
                if (retUser != null)
                {
                    ThisUser          = user;
                    this.DialogResult = true;
                    this.Close();
                }
                else
                {
                    txtPassword.Focus();
                    txtStatus.Text = "Incorrect Password";
                }
            }
        }
コード例 #7
0
 void btnNewUser_Click(object sender, RoutedEventArgs e)
 {
     SelectedUser = new JMMUserVM();
     DisplayUser();
 }
コード例 #8
0
        void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(txtUsername.Text.Trim()))
            {
                MessageBox.Show("Please enter a username", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                txtUsername.Focus();
                return;
            }
            string[] plexusers = txtPlexUsers.Text.Split(',');
            foreach (string n in plexusers)
            {
                foreach (JMMUserVM us in lbUsers.Items)
                {
                    if (us != lbUsers.SelectedItem)
                    {
                        if (!string.IsNullOrEmpty(us.PlexUsers))
                        {
                            string[] splexusers = us.PlexUsers.Split(',');
                            foreach (string m in splexusers)
                            {
                                if (n.Trim().ToLower() == m.Trim().ToLower())
                                {
                                    MessageBox.Show(string.Format("The Plex User '{0}' is already asigned to the JMM User '{1}'", n.Trim(), us.Username), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                                    txtPlexUsers.Focus();
                                    return;
                                }
                            }
                        }
                    }
                }
            }
            SelectedUser = lbUsers.SelectedItem as JMMUserVM;

            SelectedUser.Username              = txtUsername.Text.Trim();
            SelectedUser.HideTags              = txtTags.Text.Trim();
            SelectedUser.IsAdmin               = chkIsAdmin.IsChecked.Value ? 1 : 0;
            SelectedUser.IsAniDBUser           = chkIsAniDB.IsChecked.Value ? 1 : 0;
            SelectedUser.IsTraktUser           = chkIsTrakt.IsChecked.Value ? 1 : 0;
            SelectedUser.CanEditServerSettings = chkEditSettings.IsChecked.Value ? 1 : 0;
            SelectedUser.PlexUsers             = txtPlexUsers.Text.Trim();

            try
            {
                this.Cursor = Cursors.Wait;
                string ret = JMMServerVM.Instance.clientBinaryHTTP.SaveUser(SelectedUser.ToContract());
                this.Cursor = Cursors.Arrow;
                if (ret.Length > 0)
                {
                    MessageBox.Show(ret, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    txtUsername.Focus();
                }

                JMMServerVM.Instance.RefreshAllUsers();

                if (lbUsers.Items.Count > 0)
                {
                    lbUsers.SelectedIndex = 0;
                    lbUsers.Focus();
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
コード例 #9
0
 public void Init(JMMUserVM jmmUser)
 {
     JMMUser          = jmmUser;
     txtUsername.Text = JMMUser.Username;
 }