private void MenuItemOpen_Click(object sender, RoutedEventArgs e) { OpenDialogZIPFile = new OpenFileDialog(); OpenDialogZIPFile.Filter = "Compressed Files|*.zip;*.7z"; OpenDialogZIPFile.ShowDialog(); labelFileName.Content = OpenDialogZIPFile.FileName; ArchiveName = OpenDialogZIPFile.FileName; if (!ArchiveName.Equals("")) { time = new TimeSpan(0, 0, 0); cracker = new CreckerZIPPassword(); Func <string, bool, string> thread = new Func <string, bool, string>(cracker.GetPassword); timer = new DispatcherTimer(); timer.Tick += Timer_Tick; timer.Interval = new TimeSpan(0, 0, 1); timer.Start(); timer2 = new DispatcherTimer(); timer2.Tick += Timer2_Tick; timer2.Interval = new TimeSpan(0, 0, 0, 0, 100); timer2.Start(); asyncResult = thread.BeginInvoke(OpenDialogZIPFile.FileName, this.Threading.IsChecked, Callback, null); label1.Visibility = Visibility.Visible; label2.Visibility = Visibility.Visible; label3.Visibility = Visibility.Visible; label4.Visibility = Visibility.Visible; label5.Visibility = Visibility.Visible; labelCurrPassword.Visibility = Visibility.Visible; this.labelCorrPassword.Content = ""; this.labelCorrPassword.Visibility = Visibility.Hidden; this.label_password.Visibility = Visibility.Hidden; MenuOpen.IsEnabled = false; MenuOpenState.IsEnabled = false; MenuSave.IsEnabled = true; MenuSaveAs.IsEnabled = true; } }
private void MenuItemLoadState_Click(object sender, RoutedEventArgs e) { OpenFileDialog passwordFile = new OpenFileDialog(); passwordFile.Filter = "Password files|*.psw"; passwordFile.ShowDialog(); if (!passwordFile.FileName.Equals("")) { SaveDialogState = new SaveFileDialog(); // for quick save SaveDialogState.FileName = passwordFile.FileName; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(passwordFile.FileName); string password = ""; int hours = 0; int minutes = 0; int seconds = 0; foreach (XmlNode task in xmlDoc.DocumentElement.ChildNodes) { if (task.Name.Equals("fileName")) { ArchiveName = task.InnerText; labelFileName.Content = ArchiveName; } else if (task.Name.Equals("password")) { password = task.InnerText; } else if (task.Name.Equals("hours")) { hours = Convert.ToInt32(task.InnerText); } else if (task.Name.Equals("minutes")) { minutes = Convert.ToInt32(task.InnerText); } else if (task.Name.Equals("seconds")) { seconds = Convert.ToInt32(task.InnerText); } } FileInfo fi = new FileInfo(ArchiveName); if (!fi.Exists) { MessageBox.Show("Archive not found, please choose file"); OpenDialogZIPFile = new OpenFileDialog(); OpenDialogZIPFile.Filter = "Compressed Files|*.zip;*.7z"; OpenDialogZIPFile.ShowDialog(); labelFileName.Content = OpenDialogZIPFile.FileName; ArchiveName = OpenDialogZIPFile.FileName; } if (!string.IsNullOrEmpty(ArchiveName)) { time = new TimeSpan(hours, minutes, seconds); cracker = new CreckerZIPPassword(password); Func <string, bool, string> thread = new Func <string, bool, string>(cracker.GetPassword); timer = new DispatcherTimer(); timer.Tick += Timer_Tick; timer.Interval = new TimeSpan(0, 0, 1); timer.Start(); timer2 = new DispatcherTimer(); timer2.Tick += Timer2_Tick; timer2.Interval = new TimeSpan(0, 0, 0, 0, 100); timer2.Start(); asyncResult = thread.BeginInvoke(ArchiveName, this.Threading.IsChecked, Callback, null); label1.Visibility = Visibility.Visible; label2.Visibility = Visibility.Visible; label3.Visibility = Visibility.Visible; label4.Visibility = Visibility.Visible; label5.Visibility = Visibility.Visible; labelCurrPassword.Visibility = Visibility.Visible; this.labelCorrPassword.Content = ""; this.labelCorrPassword.Visibility = Visibility.Hidden; this.label_password.Visibility = Visibility.Hidden; MenuOpen.IsEnabled = false; MenuOpenState.IsEnabled = false; MenuSave.IsEnabled = true; MenuSaveAs.IsEnabled = true; } } }