Exemplo n.º 1
0
        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);
            }));
        }
Exemplo n.º 2
0
 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();
     }
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public MainWindow()
        {
            InitializeComponent();
            try
            {
                ((Control)this.taskManagerTab).IsEnabled = false;
                ((Control)this.commandsTab).IsEnabled    = false;
                encryptionClass       = new encryption(this);
                networkingClientClass = new NetworkingClient(this, encryptionClass);
                networkingServerClass = new NetworkingServer(this, encryptionClass);
                string[] settings = System.IO.File.ReadAllLines(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "computerMonitorSettings.txt"));
                foreach (string line in settings)
                {
                    string stringSave = line.Substring(0, line.IndexOf("="));

                    switch (stringSave)
                    {
                    case "home_ip":
                        homeIp = line.Substring(line.IndexOf("=") + 1); break;

                    case "home_port":
                        homePort = line.Substring(line.IndexOf("=") + 1); break;

                    case "home_password":
                        homePassword = line.Substring(line.IndexOf("=") + 1); break;

                    case "home_set":
                        homeSet = line.Substring(line.IndexOf("=") + 1); break;

                    case "last_ip":
                        ipToConnect = line.Substring(line.IndexOf("=") + 1); break;

                    case "last_port":
                        portToConnect = Int32.Parse(line.Substring(line.IndexOf("=") + 1)); break;

                    case "last_password":
                        passwordToConnect = line.Substring(line.IndexOf("=") + 1); break;

                    case "saveFolder":
                        saveFolder = line.Substring(line.IndexOf("=") + 1); break;

                    case "serverPort":
                        serverPort = Int32.Parse(line.Substring(line.IndexOf("=") + 1)); break;

                    case "serverPassword":
                        serverPassword = line.Substring(line.IndexOf("=") + 1); break;

                    case "startup":
                    {
                        string aux = line.Substring(line.IndexOf("=") + 1);
                        if (aux == "True")
                        {
                            serverBootUp = true;
                        }
                        else
                        {
                            serverBootUp = false;
                        }
                    }; break;
                    }
                }
            }
            catch (Exception)
            {
                Thread newUserMessage = new Thread(newUser);
                newUserMessage.Start();
            }
            if (serverBootUp == true)
            {
                keepServerOnAfterClient = true;
                startServer();
            }
            connectPage1Class = new connectPage1(this, false, false);
            connectWindow.Navigate(connectPage1Class);
        }