예제 #1
0
        protected override void OnMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e)
        {
            if (e.OriginalSource is FrameworkElement)
            {
                FrameworkElement frameworkElement = (FrameworkElement)e.OriginalSource;
                if (frameworkElement.DataContext is Account)
                {
                    MostRecentAccountClick = (Account)frameworkElement.DataContext;
                }
            }

            base.OnMouseLeftButtonDown(e);
        }
        private void AddToAccountDB(string Name, string Key)
        {
            Account a = new Account();
            a.AccountName = Name;
            a.SecretKey = Key;

            CodeGenerator cg = new CodeGenerator(6, 30);
            string code = cg.computePin(a.SecretKey);

            if (code == null || code.Length != 6)
            {
                MessageBox.Show("The Secret Key you provided could not be validated. Please check your input and try again.", "Error", MessageBoxButton.OK);
                return;
            }
            else
            {
                _application.Database.Add(a);
                _application.Application_Closing(null, null);
            }

            NavigationService.GoBack();
        }