public async Task ShowWindowDialog()
        {
            // Arrange
            string server   = "develop";
            string port     = "4021";
            string userName = "******";
            Mock <ISettingsProvider> settingsProvider = new Mock <ISettingsProvider>();

            settingsProvider.Setup(x => x.RemoteServer).Returns(server);
            settingsProvider.Setup(x => x.RemotePort).Returns(port);
            settingsProvider.Setup(x => x.RemoteUserName).Returns(userName);
            var dlg = new ConnectWindow(settingsProvider.Object);

            // Act
            dlg.Show();
            IntPtr windowHandle = new WindowInteropHelper(dlg).Handle;

            using (var automation = new UIA3Automation())
            {
                var    window       = automation.FromHandle(windowHandle).AsWindow();
                Button cancelButton = window.FindFirstDescendant(cf => cf.ByName("CancelButton"))?.AsButton();

                // Assert
                TextBox txtServerName = window.FindFirstDescendant(cf => cf.ByAutomationId("txtServerName"))?.AsTextBox();
                TextBox txtPortNumber = window.FindFirstDescendant(cf => cf.ByAutomationId("txtPortNumber"))?.AsTextBox();
                TextBox txtUserName   = window.FindFirstDescendant(cf => cf.ByAutomationId("txtUserName"))?.AsTextBox();
                Assert.AreEqual(server, txtServerName?.Text);
                Assert.AreEqual(port, txtPortNumber?.Text);
                Assert.AreEqual(userName, txtUserName?.Text);
#if DEBUG
                await Task.Delay(5000).ConfigureAwait(false);
#endif
                cancelButton?.Invoke();
            }
        }
 private void ChangeLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (ConnectWindow.ShowModal(this, DefaultConnection, ref ServerAndPortOverride, ref UserNameOverride, Log))
     {
         UpdateServerLabel();
     }
 }
Example #3
0
        public static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ConnectWindow connectWindow = new ConnectWindow();

            Application.Run(connectWindow);

            if (connectWindow.IsConnected)
            {
                switch (connectWindow.Connector.ConnectType)
                {
                case ConnectType.TYPE_REMOTE_CONSOLE:
                    Application.Run(new RemoteConsoleWindow(connectWindow.Connector));
                    break;

                case ConnectType.TYPE_REMOTE_DESKTOP:
                    Application.Run(new RemoteDesktopWindow(connectWindow.Connector));
                    break;

                case ConnectType.TYPE_REMOTE_EXPLORER:
                    Application.Run(new RemoteExplorerWindow(connectWindow.Connector));
                    break;
                }
            }
        }
Example #4
0
 private void NetworkClient_Disconnected()
 {
     if (!Global.CurrentWindow.IsMain)
     {
         Global.CurrentWindow.CloseWindow();
         var wind = new ConnectWindow();
     }
 }
Example #5
0
        private void ConnectCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            Telemetry.Instance.Native?.TrackEvent("Main.Connect");

            var connectWindow = new ConnectWindow();

            connectWindow.DialogResult += (window, provider) => Connected(provider);
            ucConnectPopup.Show(connectWindow);
        }
Example #6
0
        private void ConnectCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            Telemetry.Instance.Native.TrackEvent("Main.Connect");
            var dialog = new ConnectWindow();

            if (dialog.ShowDialog() == true)
            {
                Connected(dialog.Client);
            }
        }
Example #7
0
 public static void WriteServerConnectSettings(ConnectWindow win)
 {
     Properties.QuickConnect.Default.address  = win.serverBox.Text;
     Properties.QuickConnect.Default.port     = int.Parse(win.portBox.Text);
     Properties.QuickConnect.Default.password = win.passwordBox.Text;
     Properties.QuickConnect.Default.nickName = win.nicknameBox.Text;
     Properties.QuickConnect.Default.userName = win.usernameBox.Text;
     Properties.QuickConnect.Default.realName = win.realnameBox.Text;
     Properties.QuickConnect.Default.altNick1 = win.altNickBox1.Text;
     Properties.QuickConnect.Default.altNick2 = win.altNickBox2.Text;
     Properties.QuickConnect.Default.Save();
 }
 void DisplayConnectionDialog()
 {
     this.connectDialog             = new ConnectWindow();
     this.connectDialog.DataContext = this;
     if (this.connectDialog.ShowDialog() == true)
     {
         this.serviceConnectionCompletionSource.SetResult(this.ServiceContext);
     }
     else
     {
         this.serviceConnectionCompletionSource.SetCanceled();
     }
 }
Example #9
0
        private void Connect(object sender, RoutedEventArgs e)
        {
            var connectionWindow = new ConnectWindow();

            if (connectionWindow.ShowDialog() == true)
            {
                DispatcherTimer timer = new DispatcherTimer();
                timer.Interval = TimeSpan.FromSeconds(2);
                timer.Tick    += async(sender2, e2) => await RetrieveSessions();

                timer.Start();
            }
        }
Example #10
0
 /// <summary>
 ///При загрузке окна сразу загружает окно авторизации на брокере
 ///Все настройки и запускает поток таймера для проверки подключения к брокеру.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     ListItemIoT.SelectionMode = SelectionMode.Multiple;
     UpdateStatus("No Connected", Brushes.Red);
     ConnectWindowToBroker = new ConnectWindow();
     ConnectWindowToBroker.ShowDialog();
     Task.Delay(15000);
     if (ConnectWindowToBroker.IsTrueAndConnectToBroker == true)
     {
         PersonStatus();
         UpdateControlForm();
         ArrayIoTConnection.TimerStartToUpdate();
     }
 }
Example #11
0
 /// <summary>
 /// Отправляет сообщение Брокеру, для управления Интернета Вещей.
 /// Если подключение было выполенено то можно продолжать управление Интернета Вещей, если нет-то
 /// появится окно предупреждения, и будет повторно открыто окно повторного подключения.
 /// </summary
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
 private void SendButton_Click(object sender, RoutedEventArgs e)
 {
     if (ConnectWindowToBroker.IsTrueAndConnectToBroker == true)
     {
         TalkToIoTtextBox.Text += "[" + DateTime.Now.ToString() + "]" + "  " + ConnectWindow.NewConnect.IDClient + ": " + SendMessageTextBox.Text + "\n";
         Analize.TrueWrite.RegularExForSendMessage(SendMessageTextBox.Text);
         SendMessageTextBox.Text = null;
         PersonStatus();
     }
     else
     {
         ConnectWindowToBroker.Dispose();
         var result = MessageBox.Show("Вы не подключены." + "\n" + "Подключитесь", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
         if (result == MessageBoxResult.OK)
         {
             ConnectWindowToBroker = new ConnectWindow();
             ConnectWindowToBroker.ShowDialog();
         }
     }
 }
Example #12
0
        public bool Connect()
        {
            ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;

            var connectionDialog = new ConnectWindow();

            connectionDialog.ShowDialog();

            if (connectionDialog.DialogResult == true)
            {
                CrmServiceClient         = connectionDialog.Presenter.CrmConnectionMgr.CrmSvc;
                OrganizationFriendlyName = connectionDialog.Presenter.CrmConnectionMgr.ConnectedOrgFriendlyName;
                OrganizationUniqueName   = connectionDialog.Presenter.CrmConnectionMgr.ConnectedOrgUniqueName;

                OrganizationServiceProxy = CrmServiceClient.OrganizationServiceProxy;

                return(true);
            }

            return(false);
        }
Example #13
0
        private async void ClientConnect_OnClick(object sender, RoutedEventArgs e)
        {
            if (ActiveServer == null || !ActiveServer.IsStarted)
            {
                MessageBox.Show(
                    "The local server must be started before making any new connection.", "Server not started",
                    MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            IPAddress address;
            ushort    port;

            try
            {
                if (!IPAddress.TryParse(ClientConnectAddressStr, out address))
                {
                    Task <IPAddress> t = new Task <IPAddress>(() => Dns.GetHostAddresses(ClientConnectAddressStr).First());
                    await            t;
                    address = t.Result;
                }

                if (address == null)
                {
                    throw new InvalidDataException("Cannot resolve the specified hostname, or its an invalid IP address.");
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(
                    "Cannot parse the destination address provided.\nIf the address is a domain name, it could be that the DNS servers cannot be reached.\n\n" +
                    exception.GetType().Name + "\n" + exception.Message, "Cannot get remote EndPoint",
                    MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            try
            {
                port = ushort.Parse(ClientConnectPortStr);
            }
            catch (Exception exception)
            {
                MessageBox.Show(
                    "Cannot parse the specified port number.\nIt must be in the range of 30 to 65535.\n" +
                    exception.GetType().Name + "\n" + exception.Message, "Cannot get remote EndPoint",
                    MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            try
            {
                ConnectWindow.ShowAndConnect(address, port, Netst.Settings.Volatile.PreferUdp);
                ClientConnectAddressStr = "";
            }
            catch (Exception exception)
            {
                MessageBox.Show(
                    "Cannot connect to the specified address.\n\n" +
                    exception.GetType().Name + "\n" + exception.Message, "Cannot get remote EndPoint",
                    MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
        }
Example #14
0
 public void ConnectWindowConstructorTest()
 {
     var target = new ConnectWindow();
     Assert.IsNotNull(target);
 }
Example #15
0
 public void InitializeComponentTest()
 {
     var target = new ConnectWindow();
     target.InitializeComponent();
     Assert.IsNotNull(target);
 }
Example #16
0
        private void File_Connect_Clicked(object sender, RoutedEventArgs e)
        {
            ConnectWindow win = new ConnectWindow();
            if (win.Prompt())
            {
                Status("Connecting to TWS using clientId " + win.ClientId + " ...");

                m_tws.connect(win.Host, win.Port, win.ClientId);
                if (m_tws.serverVersion > 0)
                {
                    TwsConnected();
                }
                else
                {
                    StatusError("Failed to connect to TWS server.");
                }
            }
        }
Example #17
0
        private void ConnectCommand_Executed(object sender, RoutedEventArgs e)
        {
            ConnectWindow logInWindow = new ConnectWindow(this);

            logInWindow.Show();
        }
Example #18
0
 private void MenuItem_Click(object sender, RoutedEventArgs e)
 {
     connectWindow = new ConnectWindow();
     connectWindow.ShowDialog();
     connectWindow.Owner = this;
     if (connectWindow.DialogResult != null && connectWindow.DialogResult.Value)
     {
         client.Start(Properties.Settings.Default.nickname);
     }
 }
Example #19
0
        public ConnectPresenter(ConnectWindow view)
        {
            View = view;

            AttachEvents();
        }
        public MainMenuScreen(MainWindow mainWindow)
            : base(mainWindow, "MainMenu")
        {
            theme = AssetManager.CreateDefaultGameTheme();
            theme.SetField("SmallFont", AssetManager.LoadFont("arial-bold-14"));
            theme.SetField("Font", AssetManager.LoadFont("arial-16"));
            theme.SetField("BigFont", AssetManager.LoadFont("arial-20"));

            popup         = new MessageWindow(GUISystem, theme, new UDim2(0.1f, 0, 0.3f, 0), "Alert!");
            popup.MinSize = new UDim2(0, 215, 0, 200);
            popup.MaxSize = new UDim2(1f, 0, 0, 275);

            connectWindow                   = new ConnectWindow(GUISystem, theme, new UDim2(1f, 0, 1f, 0));
            connectWindow.MinSize           = new UDim2(0, 375, 0, 200);
            connectWindow.MaxSize           = new UDim2(0, 700, 0, 200);
            connectWindow.OnConnectPressed += ConnectWindow_OnConnectPressed;

            GUIFrame title = new GUIFrame(new UDim2(0.5f, -260, 0.2f, -40), new UDim2(0, 520, 0, 80),
                                          new Image(GLoader.LoadTexture("Textures/title.png")));

            GUIFrame btnFrame = new GUIFrame(new UDim2(0.5f, -200, 0.5f, -50), new UDim2(0, 400, 0, 110), theme);

            btnFrame.Image = null;

            GUIButton connectBtn = new GUIButton(new UDim2(0, 0, 0, 0), new UDim2(1f, 0, 0, 30), "Connect to a Server",
                                                 TextAlign.Center, theme)
            {
                Parent = btnFrame
            };

            connectBtn.OnMouseClick += (btn, mbtn) =>
            {
                if (mbtn == MouseButton.Left)
                {
                    connectWindow.Visible = true;
                }
            };

            GUIButton controlsBtn = new GUIButton(new UDim2(0, 0, 0, 40), new UDim2(1f, 0, 0, 30), "View Controls",
                                                  TextAlign.Center, theme)
            {
                Parent = btnFrame
            };

            controlsBtn.OnMouseClick += (btn, mbtn) =>
            {
                if (mbtn == MouseButton.Left)
                {
                    Window.StaticGui.ToggleControlsWindow(true);
                }
            };

            GUIButton spBtn = new GUIButton(new UDim2(0, 0, 0, 80), new UDim2(1f, 0, 0, 30), "Start Singleplayer Test",
                                            TextAlign.Center, theme)
            {
                Parent = btnFrame
            };

            spBtn.OnMouseClick += (btn, mbtn) =>
            {
                if (mbtn == MouseButton.Left)
                {
                    Window.SwitchScreen("Singleplayer");
                }
            };

            GUIButton randomImageButton = new GUIButton(new UDim2(1f, -160, 1f, -40), new UDim2(0, 150, 0, 30),
                                                        "Random Image", theme);

            randomImageButton.OnMouseClick += (btn, mbtn) => { Window.StaticGui.ShowRandomBackgroundImage(); };

            GUIArea.AddTopLevel(title, randomImageButton, btnFrame);
            GUISystem.Add(connectWindow, popup);
            Windows.Add(connectWindow);
            Windows.Add(popup);
        }