示例#1
0
        public async Task Forward_Command()
        {
            var toBot = this.Fixture.CreateMessage();

            toBot.Text = "connect";

            var vstsService = new Mock <IVstsService>();
            var dialog      = new ConnectDialog("appid", "appscope", new Uri("https://someurl.com"), vstsService.Object);

            var container = new ContainerBuilder();

            container
            .RegisterModule <AttributedMetadataModule>();
            container
            .Register((c, x) => dialog)
            .As <IDialog <object> >();
            var build = container.Build();

            GlobalConfiguration.Configure(config => config.DependencyResolver = new AutofacWebApiDependencyResolver(build));

            var target = this.Fixture.RootDialog;

            await target.HandleCommandAsync(this.Fixture.DialogContext.Object, toBot);

            // TODO:
            this.Fixture.DialogContext
            .Verify(c => c.Forward <object, IMessageActivity>(dialog, target.ResumeAfterChildDialog, toBot, CancellationToken.None));
        }
示例#2
0
        public async Task Select_Project_NoProjects()
        {
            var account = "Account1";
            var profile = new Profile {
                Accounts = new List <string> {
                    account
                }, Token = new OAuthToken()
            };
            var projects = new List <TeamProjectReference>();

            var toBot = this.Fixture.CreateMessage();

            var target = new ConnectDialog("appId", "appScope", new Uri("http://authorize.url"), this.Fixture.AuthenticationService.Object, this.Fixture.VstsService.Object)
            {
                Account = account, Profile = profile
            };

            this.Fixture.VstsService.Setup(s => s.GetProjects(account, profile.Token)).ReturnsAsync(projects).Verifiable();

            await target.SelectProjectAsync(this.Fixture.DialogContext.Object, toBot);

            this.Fixture.VstsService.Verify();
            this.Fixture.DialogContext
            .Verify(c => c.PostAsync(It.IsAny <IMessageActivity>(), CancellationToken.None));
            this.Fixture.DialogContext.Verify(c => c.Done <IMessageActivity>(It.IsAny <IMessageActivity>()));
        }
示例#3
0
        public override bool ShowConnectionDialog(IConnectionInfo cxInfo, bool isNewConnection)
        {
            var dialog = new ConnectDialog(new ConnectionViewModel(cxInfo));
            var result = dialog.ShowDialog();

            return(result.HasValue && result.Value);
        }
 private void connectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var dialog = new ConnectDialog(_connectedServer, _connectedUser, _virtualProxy))
     {
         if (dialog.ShowDialog(this) == DialogResult.OK)
         {
             _connectedServer = dialog.ConnectedServer;
             _connectedUser   = dialog.ConnectedUser;
             _virtualProxy    = dialog.VirtualProxy;
             if (string.IsNullOrEmpty(_connectedServer) || _connectedServer == "local")
             {
                 CurrentLocation = Qlik.Engine.Location.FromUri(new Uri("ws://127.0.0.1:4848"));
                 CurrentLocation.AsDirectConnectionToPersonalEdition();
             }
             else
             {
                 CurrentLocation = Qlik.Engine.Location.FromUri(new Uri(_connectedServer));
                 if (string.IsNullOrEmpty(_connectedUser))
                 {
                     CurrentLocation.AsNtlmUserViaProxy();
                 }
                 else
                 {
                     CurrentLocation.AsStaticHeaderUserViaProxy(_connectedUser);
                 }
                 CurrentLocation.VirtualProxyPath = _virtualProxy;
             }
             Notify("Connected to " + CurrentLocation.ServerUri.OriginalString + CurrentLocation.VirtualProxyPath);
             SetModeToConencted();
         }
     }
 }
示例#5
0
        public async Task Select_Account()
        {
            var profile1 = new VstsProfile {
                Accounts = new List <string> {
                    "Account1", "Account2"
                }
            };
            var profile2 = new VstsProfile {
                Accounts = new List <string> {
                    "Account3", "Account4"
                }
            };
            var profiles = new List <VstsProfile> {
                profile1, profile2
            };

            var toBot = this.Fixture.CreateMessage();

            var target = new ConnectDialog(this.Fixture.VstsService.Object, this.Fixture.VstsApplicationRegistry.Object)
            {
                Profiles = profiles
            };

            await target.SelectAccountAsync(this.Fixture.DialogContext.Object, toBot);

            this.Fixture.DialogContext
            .Verify(c => c.PostAsync(
                        It.Is <IMessageActivity>(a => a.Attachments.First().Content is AccountsCard),
                        CancellationToken.None));
            this.Fixture.DialogContext.Verify(c => c.Wait <IMessageActivity>(target.AccountReceivedAsync));
        }
        private void connectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Get a host name from the user.
            string host = ConnectDialog.GetVncHost();

            // As long as they didn't click Cancel, try to connect
            if (host != null)
            {
                try {
                    rd.Connect(host, viewOnlyToolStripMenuItem.Checked, scaledViewToolStripMenuItem.Checked);
                } catch (VncProtocolException vex) {
                    MessageBox.Show(this,
                                    string.Format("Unable to connect to VNC host:\n\n{0}.\n\nCheck that a VNC host is running there.", vex.Message),
                                    string.Format("Unable to Connect to {0}", host),
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                } catch (Exception ex) {
                    MessageBox.Show(this,
                                    string.Format("Unable to connect to host.  Error was: {0}", ex.Message),
                                    string.Format("Unable to Connect to {0}", host),
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                }
            }
        }
示例#7
0
        public async Task Select_Account()
        {
            var profile1 = new Profile {
                Accounts = new List <string> {
                    "Account1", "Account2"
                }
            };
            var profile2 = new Profile {
                Accounts = new List <string> {
                    "Account3", "Account4"
                }
            };
            var profiles = new List <Profile> {
                profile1, profile2
            };

            var toBot = this.Fixture.CreateMessage();

            var target = new ConnectDialog("appId", "appScope", new Uri("http://authorize.url"), this.Fixture.AuthenticationService.Object, this.Fixture.VstsService.Object)
            {
                Profiles = profiles
            };

            await target.SelectAccountAsync(this.Fixture.DialogContext.Object, toBot);

            this.Fixture.DialogContext
            .Verify(c => c.PostAsync(It.IsAny <IMessageActivity>(), CancellationToken.None));
            this.Fixture.DialogContext.Verify(c => c.Wait <IMessageActivity>(target.AccountReceivedAsync));
        }
示例#8
0
        public async Task Select_Project()
        {
            var account = "Account1";
            var profile = new VstsProfile {
                Accounts = new List <string> {
                    account
                }, Token = new OAuthToken()
            };
            var projects = new List <TeamProjectReference> {
                new TeamProjectReference {
                    Name = "Project1"
                }
            };

            var toBot = this.Fixture.CreateMessage();

            var target = new ConnectDialog(this.Fixture.VstsService.Object, this.Fixture.VstsApplicationRegistry.Object)
            {
                Account = account, Profile = profile
            };

            this.Fixture.VstsService.Setup(s => s.GetProjects(account, profile.Token)).ReturnsAsync(projects).Verifiable();

            await target.SelectProjectAsync(this.Fixture.DialogContext.Object, toBot);

            this.Fixture.VstsService.Verify();
            this.Fixture.DialogContext
            .Verify(c => c.PostAsync(
                        It.Is <IMessageActivity>(a => a.Attachments.First().Content is ProjectsCard),
                        CancellationToken.None));
            this.Fixture.DialogContext.Verify(c => c.Wait <IMessageActivity>(target.ProjectReceivedAsync));

            target.TeamProjects.Should().Contain("Project1");
        }
示例#9
0
        private void Connect(object obj)
        {
            ConnectDialog dialog = new ConnectDialog();

            if (dialog.ShowDialog() == true)
            {
                InitializeClient(false);
            }
        }
示例#10
0
        private void _connectMenuItem_Click(object sender, EventArgs e)
        {
            ConnectDialog dlg = new ConnectDialog();

            dlg.PortName = Settings.Default.SerialPort;
            dlg.BaudRate = Settings.Default.SerialBaudRate;
            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                Program.ComService.Connect(dlg.PortName, dlg.BaudRate, dlg.Parity, dlg.DataBits, dlg.StopBits);
                Settings.Default.SerialPort     = dlg.PortName;
                Settings.Default.SerialBaudRate = dlg.BaudRate;
                Settings.Default.Save();
            }
        }
        public async Task LogOn()
        {
            var toBot = this.Fixture.CreateMessage();

            toBot.Text = "connect account teamproject";

            var target = new ConnectDialog(AppId, AppScope, new Uri(AuthorizeUrl), this.Fixture.VstsService.Object);

            await target.LogOnAsync(this.Fixture.DialogContext.Object, toBot);

            this.Fixture.UserData.Verify(ud => ud.SetValue("Pin", It.IsRegex(@"\d{5}")));
            this.Fixture.DialogContext.Verify(c => c.PostAsync(It.Is <IMessageActivity>(a => a.Attachments.First().Content is LogOnCard), CancellationToken.None));
            this.Fixture.DialogContext.Verify(c => c.Wait <IMessageActivity>(target.PinReceivedAsync));
        }
示例#12
0
        public static void DeployFile(string newCode)
        {
            if (String.IsNullOrEmpty(ConnectionString))
            {
                var connectDialog = new ConnectDialog();
                connectDialog.ShowDialog();
                ConnectionString = connectDialog.ConnectionString;

                if (String.IsNullOrEmpty(ConnectionString))
                {
                    return;
                }
            }

            var procedures    = ScriptDom.GetProcedures(newCode);
            var deployScripts = new List <string>();

            foreach (var procedure in procedures)
            {
                OutputPane.WriteMessage("Deploying {0}", procedure.ProcedureReference.Name.ToQuotedString());
                Deploy(BuildIfNotExistsStatements(procedure));
                Deploy(ChangeCreateToAlter(procedure, newCode));
                OutputPane.WriteMessage("Deploying {0}...Done", procedure.ProcedureReference.Name.ToQuotedString());
            }

            var functions = ScriptDom.GetFunctions(newCode);

            foreach (var function in functions)
            {
                OutputPane.WriteMessage("Deploying {0}", function.Name.ToQuotedString());
                if (function.ReturnType is SelectFunctionReturnType)
                {
                    Deploy(BuildIfNotExistsStatementsInlineFunction(function));
                }
                else
                {
                    Deploy(BuildIfNotExistsStatements(function));
                }

                Deploy(ChangeCreateToAlter(function, newCode));
                OutputPane.WriteMessage("Deploying {0}...Done", function.Name.ToQuotedString());
            }

            foreach (var statement in deployScripts)
            {
                Deploy(statement);
            }
            //Deploy();
        }
示例#13
0
        void BuildStore()
        {
            if (String.IsNullOrEmpty(ConnectionString))
            {
                var dialog = new ConnectDialog();
                dialog.ShowDialog();
                ConnectionString = dialog.ConnectionString;

                if (String.IsNullOrEmpty(ConnectionString))
                    return;
            }

            Store = new QueryCostStore(new PlanParser(new QueryCostDataGateway(ConnectionString)));
            ShowCosts = false; //caller flips it first time used
        }
示例#14
0
        public ScriptCoster(DTE dte)
        {
            if (String.IsNullOrEmpty(ConnectionString))
            {
                var dialog = new ConnectDialog();
                dialog.ShowDialog();
                ConnectionString = dialog.ConnectionString;

                if (String.IsNullOrEmpty(ConnectionString))
                {
                    return;
                }
            }

            Dte       = dte;
            Store     = new QueryCostStore(new PlanParser(new QueryCostDataGateway(ConnectionString)));
            ShowCosts = false; //caller flips it first time used
        }
示例#15
0
        public async Task LogOn()
        {
            var toBot = this.Fixture.CreateMessage();

            toBot.Text = "connect account teamproject";

            this.Fixture.VstsApplicationRegistry
            .Setup(registry => registry.GetVstsApplicationRegistration(It.IsAny <string>()))
            .Returns(new VstsApplication("id", "secret", "scope", new Uri("http://localhost/redirect"), new Mock <IAuthenticationServiceFactory>().Object));

            var target = new ConnectDialog(this.Fixture.VstsService.Object, this.Fixture.VstsApplicationRegistry.Object);

            await target.LogOnAsync(this.Fixture.DialogContext.Object, toBot);

            this.Fixture.UserData.Verify(ud => ud.SetValue("Pin", It.IsRegex(@"\d{5}")));
            this.Fixture.DialogContext.Verify(c => c.PostAsync(It.Is <IMessageActivity>(a => a.Attachments.First().Content is LogOnCard), CancellationToken.None));
            this.Fixture.DialogContext.Verify(c => c.Wait <IMessageActivity>(target.PinReceivedAsync));
        }
示例#16
0
        public async Task Handle_Received_Pin_Which_Is_Invalid()
        {
            var toBot = this.Fixture.CreateMessage();

            toBot.Text = "00000";

            var target = new ConnectDialog(this.Fixture.VstsService.Object, this.Fixture.VstsApplicationRegistry.Object)
            {
                Pin = "12345"
            };

            await target.PinReceivedAsync(this.Fixture.DialogContext.Object, this.Fixture.MakeAwaitable(toBot));

            this.Fixture.DialogContext
            .Verify(c => c.PostAsync(
                        It.Is <IMessageActivity>(a => a.Text.Equals("Sorry, I do not recognize the provided pin. Please try again.", StringComparison.OrdinalIgnoreCase)),
                        CancellationToken.None));
            this.Fixture.DialogContext.Verify(c => c.Wait <IMessageActivity>(target.PinReceivedAsync));
        }
示例#17
0
        public async Task Handle_Received_No_Pin()
        {
            var toBot = this.Fixture.CreateMessage();

            toBot.Text = null;

            var target = new ConnectDialog("appId", "appScope", new Uri("http://authorize.url"), this.Fixture.AuthenticationService.Object, this.Fixture.VstsService.Object)
            {
                Pin = "12345"
            };

            await target.PinReceivedAsync(this.Fixture.DialogContext.Object, this.Fixture.MakeAwaitable(toBot));

            this.Fixture.DialogContext
            .Verify(c => c.PostAsync(
                        It.Is <IMessageActivity>(a => a.Text.Equals("Sorry, I do not recognize the provided pin. Please try again.", StringComparison.OrdinalIgnoreCase)),
                        CancellationToken.None));
            this.Fixture.DialogContext.Verify(c => c.Wait <IMessageActivity>(target.PinReceivedAsync));
        }
示例#18
0
        public async Task Select_Account_NoAccounts()
        {
            var profile1 = new Profile();
            var profiles = new List <Profile> {
                profile1
            };

            var toBot = this.Fixture.CreateMessage();

            var target = new ConnectDialog("appId", "appScope", new Uri("http://authorize.url"), this.Fixture.AuthenticationService.Object, this.Fixture.VstsService.Object)
            {
                Profiles = profiles
            };

            await target.SelectAccountAsync(this.Fixture.DialogContext.Object, toBot);

            this.Fixture.DialogContext.Verify(c => c.PostAsync(It.IsAny <IMessageActivity>(), CancellationToken.None));
            this.Fixture.DialogContext.Verify(c => c.Done(It.IsAny <IMessageActivity>()));
        }
示例#19
0
        public async Task LogOn_NoUserData()
        {
            var toBot = this.Fixture.CreateMessage();

            toBot.Text = "connect account teamproject";

            UserData data;

            var target = new ConnectDialog("appId", "appScope", new Uri("http://authorize.url"), this.Fixture.AuthenticationService.Object, this.Fixture.VstsService.Object);

            this.Fixture.UserData
            .Setup(ud => ud.TryGetValue("userData", out data))
            .Returns(false);

            await target.LogOnAsync(this.Fixture.DialogContext.Object, toBot);

            this.Fixture.UserData.Verify(ud => ud.SetValue("userData", It.IsAny <UserData>()));
            this.Fixture.DialogContext.Verify(c => c.PostAsync(It.Is <IMessageActivity>(a => a.Attachments.First().Content is LogOnCard), CancellationToken.None));
            this.Fixture.DialogContext.Verify(c => c.Wait <IMessageActivity>(target.PinReceivedAsync));
        }
示例#20
0
        private void LoginDialog()
        {
            bool Continue = true;

            _LoginDialog = new ConnectDialog();
            while (Continue)
            {
                _LoginDialog.ShowDialog();
                switch (_LoginDialog.DialogResult)
                {
                case DialogResult.Cancel:
                    Continue = false;
                    return;

                case DialogResult.OK:
                    Continue = false;
                    GameFramework.Instance().Run(this, (IGameControl)this);
                    break;
                }
            }
        }
示例#21
0
        // runs only when not restored from state
        public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)
        {
            SettingsService.Instance.UseShellBackButton = true;

            // Ne rien mettre au dessus de ce code sinon Template10 fonctionne mal.
            NavigationService.Navigate(typeof(FavoritePage));
            if (RequestViewModel.config.Populated && RequestViewModel.config.ConnexionAuto == true)
            {
                // Tentative de connexion à Jeedom
                if (await RequestViewModel.Instance.PingJeedom() == null)
                {
                    //if (RequestViewModel.config.HostExt != "")
                    //    RequestViewModel.config.UseExtHost = true; // Todo: ????
                    var taskFactory = new TaskFactory(TaskScheduler.FromCurrentSynchronizationContext());
                    await taskFactory.StartNew(async() =>
                    {
                        await RequestViewModel.Instance.FirstLaunch();
                    });
                }
                else
                {
                    ConnectDialog.ShowConnectDialog();
                    return;
                }

                //Lancer le dispatchertimer
                var _dispatcher = new DispatcherTimer();
                _dispatcher.Interval = TimeSpan.FromSeconds(5);
                _dispatcher.Tick    += _dispatcher_Tick;
                _dispatcher.Start();
            }
            else
            {
                ConnectDialog.ShowConnectDialog();
            }

            await Task.CompletedTask;
        }
示例#22
0
        private void Start(object sender, RoutedEventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(_connectionString))
                {
                    var dialog = new ConnectDialog();
                    dialog.ShowDialog();
                    _connectionString = dialog.ConnectionString;

                    if (String.IsNullOrEmpty(_connectionString))
                    {
                        return;
                    }
                }

                Task.Run(() =>
                {
                    try
                    {
                        _reader = new ExtendedEventDataDataReader(_connectionString);
                        _reader.Start();
                    }
                    catch (Exception ex)
                    {
                        OutputPane.WriteMessageAndActivatePane("SSDTDevPack: CodeCoverage: Exception calling Start (Worker Thread): {0}", ex);
                    }
                });


                StartButton.IsEnabled = false;
                StopButton.IsEnabled  = true;
            }
            catch (Exception ex)
            {
                OutputPane.WriteMessageAndActivatePane("SSDTDevPack: CodeCoverage: Exception calling Start (UI Thread): {0}", ex);
            }
        }
示例#23
0
        private void HandleConnect(object sender, RoutedEventArgs e)
        {
            ConnectDialog dialog = new ConnectDialog();
            if (dialog.ShowDialog().GetValueOrDefault(false)) {
                ConnectionInfo info = dialog.ConnectionInfo;
                if (info != null) {
                    // get rid of the 'Welcome' tab -- has no effect if we've already removed it
                    _tabs.Items.Remove(_welcomeTab);

                    TabItem tab = new TabItem();
                    TextBlock headerText = new TextBlock();
                    headerText.Text = dialog.ConnectionName;
                    tab.Header = headerText;

                    QueryControl queryCtrl = new QueryControl();
                    queryCtrl.Controller = new QueryController(info);
                    tab.Content = queryCtrl;

                    _tabs.Items.Add(tab);
                    _tabs.SelectedItem = tab;
                }
            }
        }
        private void Start(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(_connectionString))
            {
                var dialog = new ConnectDialog();
                dialog.ShowDialog();
                _connectionString = dialog.ConnectionString;

                if (String.IsNullOrEmpty(_connectionString))
                {
                    return;
                }
            }

            Task.Run(() =>
            {
                _reader = new ExtendedEventDataDataReader(_connectionString);
                _reader.Start();
            });


            StartButton.IsEnabled = false;
            StopButton.IsEnabled  = true;
        }
示例#25
0
        private void configToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DBConnectForm f = new DBConnectForm();
            if (f.ShowDialog() == DialogResult.OK)
            {
                ConnectDialog d = new ConnectDialog();
                if (d.ShowDialog() == DialogResult.OK)
                {
                    // 1. 保存配置
                    Properties.Settings.Default.Subscriber = f.Connection.ServerInstance;
                    if (!f.Connection.LoginSecure)
                    {
                        Properties.Settings.Default.SqlLoginMode = true;
                        Properties.Settings.Default.SqlUserName = f.Connection.Login;
                        Properties.Settings.Default.SqlUserPassword = f.Connection.Password;
                    }

                    Properties.Settings.Default.Publisher = d.Publisher;
                    Properties.Settings.Default.Publication = d.Publication;
                    Properties.Settings.Default.PublicationDatabase = d.PublisherDB;
                    Properties.Settings.Default.WebSynchronizationUrl = d.WebSyncUrl;
                    Properties.Settings.Default.InternetLogin = d.InternetUserName;
                    Properties.Settings.Default.InternetPassword = d.InternetUserPassword;

                    Properties.Settings.Default.Save();
                    // 2.
                    MessageBox.Show("配置已经更改,需要重新同步数据!", "同步数据", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    showSyncDialog();

                }
            }
        }
示例#26
0
        private void Connect(object obj)
        {
            //if(true)
            var dialog = new ConnectDialog();

            if (dialog.ShowDialog() == true)
            {
                try
                {
                    var trustedCertitifcatesPath = Settings.Current.TrustedCertificatesPath;
                    var outputAudioDevice        = Settings.Current.OutputAudioDevice;
                    var inputAudioDevice         = Settings.Current.InputAudioDevice;
                    var bits            = Settings.Current.Bits;
                    var frequency       = Settings.Current.Frequency;
                    var excludedPlugins = Settings.Current.Plugins
                                          .Where(s => !s.Enabled)
                                          .Select(s => s.Name)
                                          .ToArray();
                    var path = AppDomain.CurrentDomain.BaseDirectory + "TrustedCertificates\\c.pfx";
                    //var path = "E:\\5th Semester\\CN Lab\\Project\\Abdullah Farooq\\c.pfx";
                    SecureString password    = new NetworkCredential("", "1234").SecurePassword;
                    var          initializer = new ClientInitializer
                    {
                        Nick        = dialog.Nick,
                        NickColor   = dialog.NickColor,
                        Certificate = new X509Certificate2(dialog.CertificatePath, dialog.CertificatePassword),
                        //Nick = "Server",
                        //          NickColor = Color.Red,

                        //Certificate = new X509Certificate2(path, password),
                        TrustedCertificatesPath = trustedCertitifcatesPath,

                        PluginsPath     = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, PluginsDirectoryName),
                        ExcludedPlugins = excludedPlugins
                    };

                    ClientModel.Init(initializer);

                    try
                    {
                        ClientModel.Player.SetOptions(outputAudioDevice);
                        ClientModel.Recorder.SetOptions(inputAudioDevice, new AudioQuality(1, bits, frequency));
                    }
                    catch (ModelException me)
                    {
                        ClientModel.Player.Dispose();
                        ClientModel.Recorder.Dispose();

                        if (me.Code != ErrorCode.AudioNotEnabled)
                        {
                            throw;
                        }
                        else
                        {
                            var msg = Localizer.Instance.Localize(AudioInitializationFailedKey);
                            MessageBox.Show(msg, ProgramName, MessageBoxButton.OK, MessageBoxImage.Warning);
                        }
                    }

                    var serverUri = Connection.CreateTcpchatUri(dialog.Address);
                    ClientModel.Client.Connect(serverUri);

                    dialog.SaveSettings();
                }
                catch (Exception e)
                {
                    SelectedRoom.AddSystemMessage(Localizer.Instance.Localize(ParamsErrorKey));

                    if (ClientModel.IsInited)
                    {
                        ClientModel.Reset();
                    }
                }
            }
        }
示例#27
0
    private void connectButton_Click(object sender, EventArgs e)
    {      
      resultsPage.Hide();
      ConnectDialog d = new ConnectDialog();
      d.Connection = connection;
      DialogResult r = d.ShowDialog();
      if (r == DialogResult.Cancel) return;
      try
      {
        connection = d.Connection;
        //LanguageServiceConnection.Current.Connection = this.connection;
        UpdateButtons();
      }
      catch (MySqlException)
      {
        MessageBox.Show(
@"Error establishing the database connection.
Check that the server is running, the database exist and the user credentials are valid.", "Error", MessageBoxButtons.OK);          
      }
    }
示例#28
0
        private void Connect(object obj)
        {
            var dialog = new ConnectDialog();

            if (dialog.ShowDialog() == true)
            {
                try
                {
                    var trustedCertitifcatesPath = Settings.Current.TrustedCertificatesPath;
                    var outputAudioDevice        = Settings.Current.OutputAudioDevice;
                    var inputAudioDevice         = Settings.Current.InputAudioDevice;
                    var bits            = Settings.Current.Bits;
                    var frequency       = Settings.Current.Frequency;
                    var excludedPlugins = Settings.Current.Plugins
                                          .Where(s => !s.Enabled)
                                          .Select(s => s.Name)
                                          .ToArray();

                    var initializer = new ClientInitializer
                    {
                        Nick                    = dialog.Nick,
                        NickColor               = dialog.NickColor,
                        Certificate             = new X509Certificate2(dialog.CertificatePath, dialog.CertificatePassword),
                        TrustedCertificatesPath = trustedCertitifcatesPath,

                        PluginsPath     = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, PluginsDirectoryName),
                        ExcludedPlugins = excludedPlugins
                    };

                    ClientModel.Init(initializer);

                    try
                    {
                        ClientModel.Player.SetOptions(outputAudioDevice);
                        ClientModel.Recorder.SetOptions(inputAudioDevice, new AudioQuality(1, bits, frequency));
                    }
                    catch (ModelException me)
                    {
                        ClientModel.Player.Dispose();
                        ClientModel.Recorder.Dispose();

                        if (me.Code != ErrorCode.AudioNotEnabled)
                        {
                            throw;
                        }
                        else
                        {
                            var msg = Localizer.Instance.Localize(AudioInitializationFailedKey);
                            MessageBox.Show(msg, ProgramName, MessageBoxButton.OK, MessageBoxImage.Warning);
                        }
                    }

                    var serverUri = Connection.CreateTcpchatUri(dialog.Address);
                    ClientModel.Client.Connect(serverUri);

                    dialog.SaveSettings();
                }
                catch (Exception e)
                {
                    var errorMessage = Localizer.Instance.Localize(ParamsErrorKey);
                    SelectedRoom.AddSystemMessage($"{errorMessage}\r\n{e.Message}");

                    if (ClientModel.IsInited)
                    {
                        ClientModel.Reset();
                    }
                }
            }
        }
示例#29
0
        private void Connect_Activated(object sender, EventArgs args)
        {
            ConnectDialog connectWindow = new ConnectDialog();

            connectWindow.Run();
        }
示例#30
0
 private void connectButton_Click(object sender, EventArgs e)
 {
     resultsPage.Hide();
     ConnectDialog d = new ConnectDialog();
     d.Connection = connection;
     DialogResult r = d.ShowDialog();
     if (r == DialogResult.Cancel) return;
     connection = d.Connection;
     UpdateButtons();
 }
        public async Task Connect_Missing_Context()
        {
            var target = new ConnectDialog(AppId, AppScope, new Uri(AuthorizeUrl), this.Fixture.VstsService.Object);

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await target.ConnectAsync(null, null));
        }
示例#32
0
        public async Task Connect_Missing_Awaitable()
        {
            var target = new ConnectDialog(this.Fixture.VstsService.Object, this.Fixture.VstsApplicationRegistry.Object);

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await target.ConnectAsync(this.Fixture.DialogContext.Object, null));
        }
示例#33
0
        public async Task Connect_Missing_Awaitable()
        {
            var target = new ConnectDialog("appId", "appScope", new Uri("http://authorize.url"), this.Fixture.AuthenticationService.Object, this.Fixture.VstsService.Object);

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await target.ConnectAsync(this.Fixture.DialogContext.Object, null));
        }