public async void startClient() { int connectionCase = networkingClientClass.makeConnection(); didItConnect = false; switch (connectionCase) { case -3: await this.Dispatcher.BeginInvoke(new Action(async() => await this.ShowMessageAsync("Max attemps reached", "It seems that you have reached the maximum amount of tries. Restart the server to try again !"))); break; case -2: await this.Dispatcher.BeginInvoke(new Action(async() => await this.ShowMessageAsync("Failed", "It seems that you have connected to an invalid server !"))); break; case -1: await this.Dispatcher.BeginInvoke(new Action(async() => await this.ShowMessageAsync("Password Incorrect", "Please check your password ! Attempts remained : " + networkingClientClass.attempts))); break; case 0: { await this.Dispatcher.BeginInvoke(new Action(async() => await this.ShowMessageAsync("Password Correct", "You are connected"))); Dispatcher.Invoke(() => statusControl.Content = "Status : online"); didItConnect = true; taskManagerTab.Dispatcher.Invoke(new Action(() => taskManagerTab.IsEnabled = true)); commandsTab.Dispatcher.Invoke(new Action(() => commandsTab.IsEnabled = true)); shutDownComputer.Dispatcher.Invoke(new Action(() => shutDownComputer.IsEnabled = true)); restartComputer.Dispatcher.Invoke(new Action(() => restartComputer.IsEnabled = true)); screenShotButton.Dispatcher.Invoke(new Action(() => screenShotButton.IsEnabled = true)); sendFileButton.Dispatcher.Invoke(new Action(() => sendFileButton.IsEnabled = true)); chatAvalible = true; Thread startThisShiterino = new Thread(networkingClientClass.startMonitoring); startThisShiterino.Start(); } break; case 1: await this.Dispatcher.BeginInvoke(new Action(async() => await this.ShowMessageAsync("Connection problem", "Connection inexistent"))); break; case 2: await this.Dispatcher.BeginInvoke(new Action(async() => await this.ShowMessageAsync("Connection problem", "That's not an IP adress"))); break; case 3: await this.Dispatcher.BeginInvoke(new Action(async() => await this.ShowMessageAsync("Connection problem", "Connection time out"))); break; case 4: await this.Dispatcher.BeginInvoke(new Action(async() => await this.ShowMessageAsync("Connection problem", "That's not an IP adress"))); break; } Dispatcher.Invoke(new Action(() => { connectPage1 connect1 = new connectPage1(this, didItConnect, false); connectWindow.Navigate(connect1); DoubleAnimation da = new DoubleAnimation(); da.From = 0; da.To = 1; da.Duration = new Duration(TimeSpan.FromMilliseconds(350)); ThicknessAnimation animation = new ThicknessAnimation(); Thickness marginFrom = new Thickness(); marginFrom.Left = 30; Thickness marginTo = new Thickness(); marginTo.Left = 0; animation.From = marginFrom; animation.To = marginTo; animation.Duration = new Duration(TimeSpan.FromMilliseconds(350)); connect1.BeginAnimation(Page.OpacityProperty, da); connect1.BeginAnimation(Page.MarginProperty, animation); })); }
private void startServerButton_Click(object sender, RoutedEventArgs e) { if (portTextBox.Text != "") { mainWindowClass.serverPort = Int32.Parse(portTextBox.Text); mainWindowClass.serverPassword = passwordTextBox.Password; if (mainWindowClass.serverPassword == "") { mainWindowClass.serverPassword = "******"; } bool serverStatus = mainWindowClass.startServer(); connectPage1 connect1 = new connectPage1(mainWindowClass, false, false); if (serverStatus) { connect1.serverButton.Content = "Stop Server"; connect1.serverPortLabel.Content = "Server port : " + mainWindowClass.serverPort.ToString(); connect1.connectButton.IsEnabled = false; if (mainWindowClass.serverBootUp) { mainWindowClass.keepServerOnAfterClient = true; string appLocation = System.Reflection.Assembly.GetEntryAssembly().Location; string startUpLocation = Environment.GetFolderPath(Environment.SpecialFolder.Startup); using (StreamWriter writer = new StreamWriter(startUpLocation + "\\" + "MonitorComputer" + ".url")) { writer.WriteLine("[InternetShortcut]"); writer.WriteLine("URL=file:///" + appLocation); writer.WriteLine("IconIndex=0"); string icon = appLocation.Replace('\\', '/'); writer.WriteLine("IconFile=" + icon); writer.Flush(); } mainWindowClass.instaSaveSettings(); } DoubleAnimation da = new DoubleAnimation(); da.From = 0; da.To = 1; da.Duration = new Duration(TimeSpan.FromMilliseconds(350)); ThicknessAnimation animation = new ThicknessAnimation(); Thickness marginFrom = new Thickness(); marginFrom.Left = 30; Thickness marginTo = new Thickness(); marginTo.Left = 0; animation.From = marginFrom; animation.To = marginTo; animation.Duration = new Duration(TimeSpan.FromMilliseconds(350)); connect1.BeginAnimation(Page.OpacityProperty, da); connect1.BeginAnimation(Page.MarginProperty, animation); this.NavigationService.Navigate(connect1); } } else { fieldNotComplete(); } }
private void backButton_Click(object sender, RoutedEventArgs e) { DoubleAnimation da = new DoubleAnimation(); da.From = 0; da.To = 1; da.Duration = new Duration(TimeSpan.FromMilliseconds(350)); ThicknessAnimation animation = new ThicknessAnimation(); Thickness marginFrom = new Thickness(); marginFrom.Left = 30; Thickness marginTo = new Thickness(); marginTo.Left = 0; animation.From = marginFrom; animation.To = marginTo; animation.Duration = new Duration(TimeSpan.FromMilliseconds(350)); connectPage1 connect1 = new connectPage1(mainWindowClass, false, false); this.NavigationService.Navigate(connect1); connect1.BeginAnimation(Page.OpacityProperty, da); connect1.BeginAnimation(Page.MarginProperty, animation); }