Esempio n. 1
0
        public void ButtonDecrypt_full(object sender, RoutedEventArgs e)
        {
            if (File.Exists("obrazek.png") == true)
            {
                Window3 password = new Window3();
                bool    r1       = (bool)password.ShowDialog();
                if (r1 == true)
                {
                    //I get the password and I need to find the User_password via open alphabet on first lines.
                    //then I need to find the alphabet and generate alphabet file from this line
                    // and then I can run "almost" normal decryption :D
                    GenerateOpenAlphabet();
                    string User_message = PasswordFinder(password.password.Text);
                    //string Text = Decrypt();
                    char             uvozovky = '"';
                    MessageBoxResult r        = MessageBox.Show("The clear message is: " + uvozovky + User_message + uvozovky, "Do you want to save your message?", MessageBoxButton.YesNo);
                    if (r == MessageBoxResult.Yes)
                    {
                        Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                        dlg.FileName   = "encrypted";                   // Default file name
                        dlg.DefaultExt = ".txt";                        // Default file extension
                        dlg.Filter     = "Text documents (.txt)|*.txt"; // Filter files by extension

                        Nullable <bool> result = dlg.ShowDialog();

                        // Process save file dialog box results
                        if (result == true)
                        {
                            // Save document
                            string filename = dlg.FileName;
                            System.IO.File.WriteAllText(filename + ".txt", User_message);
                        }
                        if (result == false)
                        {
                            MessageBox.Show("I am sorry, but you didn´t choose the location", "Save-Error");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("I am sorry, but you didn´t input the password", "Password_Input-Error");
                }
            }
            else
            {
                MessageBox.Show("I am sorry, but there is no picture added", "No_picture_added-Error");
            }
        }
Esempio n. 2
0
        private void zatwierdz_Click(object sender, RoutedEventArgs e)
        {
            //otwieranie okna

            string imie       = podaj_imie.Text;
            string nazwisko   = podaj_nazwisko.Text;
            string adres      = podaj_adres.Text;
            string prawoJazdy = podaj_prawojazdy.Text;
            string dowód      = podaj_dowód.Text;

            Klient klient = new Klient(imie, nazwisko, dowód, prawoJazdy, adres);

            Klient.DodajKlienta(klient);

            Window3 okno3 = new Window3();

            okno3.ShowDialog();
        }
        private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            pDown   = e.GetPosition(canvas1);
            pDown.X = Math.Max(Math.Min(pDown.X, canvas1.RenderSize.Width), 0);
            pDown.Y = Math.Max(Math.Min(pDown.Y, canvas1.RenderSize.Height), 0);
            Ellipse el = new Ellipse();

            el.Visibility = System.Windows.Visibility.Visible;
            el.Width      = 5;
            el.Height     = 5;
            Point tl = new Point(pDown.X - 5, pDown.Y - 5);

            el.Margin = new Thickness(tl.X, tl.Y, 0, 0);
            el.Fill   = Brushes.Blue;
            textBox1.Clear();
            Point pNorm =
                new Point(Math.Round(pDown.X / canvas1.RenderSize.Width * 10000) / 10000, Math.Round(pDown.Y / canvas1.RenderSize.Height * 10000) / 10000);

            textBox1.AppendText(pNorm.ToString());
            canvas1.Children.Add(el);
            tracksData.currTrack.Add(new Point(pNorm.X, pNorm.Y));
            duringTrack       = true;
            button1.IsEnabled = true;
            if (firstInTrack)
            {
                tracksData.t = 0;
                tracksData.currTimes.Add(tracksData.t);
            }
            else
            {
                Window3 timeWin = new Window3(tracksData);
                timeWin.Owner = this;
                timeWin.ShowDialog();
            }
            firstInTrack = false;
        }
Esempio n. 4
0
        private void Encrypt_full_button(object sender, RoutedEventArgs e)
        {
            GenerateOpenAlphabet();
            Window3 password = new Window3();
            bool    r        = (bool)password.ShowDialog();

            if (r == true)
            {
                string passphrase = password.password.Text;
                for (int m = 10 - passphrase.Length; m > 0; m = m - 1)
                {
                    passphrase = passphrase + ']';
                }
                List <string> Passlist = new List <string>();
                Passlist = passphrase2passlist(passphrase);

                Userinput = UserText.Text;
                if (Userinput.Length < 251)
                {
                    if (Userinput.Length == 250)
                    {
                        //Nothing :)
                    }
                    else
                    {
                        for (int n = 250 - Userinput.Length; n > 0; n = n - 1)
                        {
                            Userinput = Userinput + ']';
                        }
                    }
                    char[] arr;
                    arr = Userinput.ToCharArray(0, Userinput.Length);
                    //is always 250 chars -->list of all positions :)
                    Positionnumber = 0;
                    for (int i = 0; i < Userinput.Length; i++)
                    {
                        char       Char       = arr[i];
                        List <int> RGBnumbers = RGBset(Char, 0);
                        RGBsettolister(RGBnumbers);
                        Positionnumber = Positionnumber + 1;
                    }
                    Editpicture_experimental(RGBsettolists, Passlist);
                    //create list of RGBnumbers
                }
                else
                {
                    MessageBox.Show("The input is longer than 250 chars, please, rewrite it", "Input is too large for me");
                }
                if (Saved == 1)
                {
                    MessageBox.Show("The process was succesfull", "Hurray, your words are now secret");
                    File.Delete("Aplhabet_open.txt");
                }
                else
                {
                    MessageBox.Show("Sorry, please, use the encrypt button again to save your picture", "You cancelled your save :(");
                }
            }
            else
            {
                MessageBox.Show("I am sorry, please, write your password and hit enter to proceed", "Password-input error");
            }
        }