public AuthWindow()
 {
     InitializeComponent();
     authWindowViewModel = new AuthWindowViewModel();
     DataContext         = authWindowViewModel;
     Title = "Авторизация";
 }
예제 #2
0
        public AuthView()
        {
            _viewModel  = new AuthWindowViewModel();
            DataContext = _viewModel;

            InitializeComponent();
            this.AttachDevTools();
        }
예제 #3
0
        public AuthWindowView()
        {
            InitializeComponent();

            var viewModel = new AuthWindowViewModel();

            DataContext = viewModel;

            viewModel.CloseRequested += (sender, e) =>
            {
                Token = e.Token;
                Close();
            };
        }
        public AuthWindow()
        {
            InitializeComponent();

            // Инициализация AuthWindowViewModel
            var viewModel = new AuthWindowViewModel()
            {
                CodebaseUrl = AuthConfigHelper.LastCodebaseUrl,
                Username    = AuthConfigHelper.LastUsername
            };

            // берём сохранённый пароль из конфига
            if (!string.IsNullOrEmpty(AuthConfigHelper.SavedPassword))
            {
                viewModel.IsPasswordSaving = true;
                txtPassword.Password       = AuthConfigHelper.SavedPassword;
            }

            DataContext = viewModel;
        }
예제 #5
0
        public AuthWindow(AuthWindowViewModel vm)
        {
            this.DataContext = vm;
            InitializeComponent();
            ProcessUtil.StartUrl(vm.Model.AuthURI);
            var stream = Observable.FromEventPattern <KeyEventArgs>(Code, "KeyDown")
                         .Where(x => x.EventArgs.Key == Key.Enter && Code.Text.Length == 7)
                         .ObserveOn(SynchronizationContext.Current)
                         .Subscribe(async _ =>
            {
                NotifText.Text = "Connect...";
                var isAuth     = await vm.Model.AuthorizeAsync();
                if (isAuth)
                {
                    this.Close(); NotifText.Text = "Success";
                }
                else
                {
                    NotifText.Text = "Failed (´・ω・`)";
                }
            });

            this.Closing += (a, e) => stream.Dispose();
        }
예제 #6
0
        public async Task InitializeAsync()
        {
            for (var i = 0; i < 10; i++)
            {
                Debug.WriteLine("わああ");
            }
            if (File.Exists(KEY_FILEPATH))
            {
                using var fs = File.OpenRead(KEY_FILEPATH);
                var keys = await MessagePackSerializer.DeserializeAsync <KeyModel>(fs);

                this.Token = Tokens.Create(ConsumerKey, ConsumerSecret, keys.AccessToken, keys.AccessSecret);
                this.Publish();
            }
            else
            {
                var model = new AuthModel(this);
                await model.InitializeAsync();

                var vm      = new AuthWindowViewModel(model);
                var authWin = new AuthWindow(vm);
                authWin.ShowDialog();
            }
        }
예제 #7
0
 public AuthWindow(ApiClient apiClient)
 {
     InitializeComponent();
     DataContext  = new AuthWindowViewModel(new LoginViewModel(apiClient, Close), new RegisterViewModel(apiClient));
     IsAuthorized = false;
 }
예제 #8
0
        public AuthWindow()
        {
            InitializeComponent();

            vm = this.DataContext as AuthWindowViewModel;
        }