Ejemplo n.º 1
0
        private async void OnClosing(object sender, CancelEventArgs cancelEventArgs)
        {
            var languageSelection = (ILateBindable)LanguageSelection.DataContext;

            languageSelection.AcceptChanges();
            var subtitleLanguagesSelection = (ILateBindable)SubtitleLanguagesSelection.DataContext;

            subtitleLanguagesSelection.AcceptChanges();

            // ReSharper disable PossibleNullReferenceException
            MovieDirectorySelection.GetBindingExpression(DirectorySelectUserControl.TextProperty).UpdateSource();
            TvShowDirectorySelection.GetBindingExpression(DirectorySelectUserControl.TextProperty).UpdateSource();
            UserNameTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            PasswordTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            PortTextBox.GetBindingExpression(NumericUpDown.ValueProperty).UpdateSource();
            // ReSharper restore PossibleNullReferenceException

            await _engine.SaveSettings(_configurableEngine.SettingName, _configurableEngine.SerializeSettings());

            if (_downloader != null)
            {
                await _engine.SaveSettings(_downloader.SettingName, _downloader.SerializeSettings());
            }

            await AddDirectories(_engine.MovieDirectory, _initialMovieDir);
            await AddDirectories(_engine.TvShowDirectory, _initialTvShowDir);
        }
Ejemplo n.º 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //This  Binding Expression instance triggers the ErrorValidationTemplate to show , since Update source trigger in the textbox that uses that ErrorTemplate is specified as explicit
            BindingExpression be = UserNameTextBox.GetBindingExpression(TextBox.TextProperty);

            be.UpdateSource();
            string username = UserNameTextBox.Text;

            if (!String.IsNullOrEmpty(username))
            {
                LoginProgress.Visibility = Visibility.Visible;
                Thread connectT = new Thread(() =>
                {
                    try
                    {
                        connection.Start().Wait();
                        if (connection.State == Microsoft.AspNet.SignalR.Client.ConnectionState.Connected)
                        {
                            Application.Current.Dispatcher.BeginInvoke(
                                new Action(() =>
                            {
                                chatwindow = new Chat(username);
                                this.Close();
                                chatwindow.ShowDialog();
                            })
                                );
                        }
                        else
                        {
                            MessageBox.Show("Connection Failed");
                            Dispatcher.BeginInvoke(new Action(() => this.Close()));
                        }
                    }

                    catch (Exception)
                    {
                        MessageBox.Show("Connection Failed");
                        Dispatcher.BeginInvoke(new Action(() => this.Close()));
                    }
                });

                connectT.SetApartmentState(ApartmentState.STA);
                connectT.Start();
            }
            else
            {
            }
        }