Esempio n. 1
0
        /// <summary>
        /// Добавление элемента
        /// </summary>
        private void MenuItem_AddBackupItem_Click(object sender, RoutedEventArgs e)
        {
            AddBackupItemWindow addBackupItemWindow = new AddBackupItemWindow();

            addBackupItemWindow.ShowDialog();
            BackupItem backupItem = addBackupItemWindow.BackupItem;

            if (backupItem != null)
            {
                dataGridSourse.Add(backupItem);
                //dataGrid_BackupList.Items.Refresh();
            }
        }
Esempio n. 2
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (string.IsNullOrEmpty(biPath) == false || checkBox_Backup.IsChecked == true)
     {
         //BackupItem.IsEnabled = checkBox_Backup.IsChecked.Value;
         if (MessageBox.Show((string)localization["abiw_InfoSave"], this.Title, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
         {
             if (string.IsNullOrEmpty(biPath))
             {
                 e.Cancel = true;
                 MessageBox.Show((string)localization["abiw_InfoSaveWarning"], this.Title, MessageBoxButton.OK, MessageBoxImage.Warning);
             }
             else
             {
                 BackupItem = new BackupItem(checkBox_Backup.IsChecked.Value, biIsFile, biPath);
             }
         }
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Оболочка открытия файла
 /// </summary>
 private void OpenFileShell(string filepath)
 {
     try
     {
         dataGridSourse.Clear();
         using (FileStream fileStream = new FileStream(filepath, FileMode.Open, FileAccess.Read))
         {
             using (BinaryReader binaryReader = new BinaryReader(fileStream))
             {
                 int count = binaryReader.ReadInt32();
                 for (int i = 0; i < count; i++)
                 {
                     BackupItem backupItem = new BackupItem(binaryReader.ReadBoolean(),
                                                            binaryReader.ReadBoolean(), binaryReader.ReadString());
                     dataGridSourse.Add(backupItem);
                 }
             }
         }
         //using (StreamReader streamReader = new StreamReader(filepath, Encoding.UTF8, true))
         //{
         //    while (!streamReader.EndOfStream)
         //    {
         //        streamReader.ReadLine();
         //        BackupItem backupItem = new BackupItem
         //        {
         //            IsEnabled = Convert.ToBoolean(streamReader.ReadLine().Remove(0, 8)),
         //            Path = streamReader.ReadLine().Remove(0, 5),
         //            IsFile = Convert.ToBoolean(streamReader.ReadLine().Remove(0, 5))
         //        };
         //        dataGridSourse.Add(backupItem);
         //        streamReader.ReadLine();
         //    }
         //}
     }
     catch (Exception ex)
     {
         dataGridSourse.Clear();
         MessageBox.Show(ex.Message, Title, MessageBoxButton.OK, MessageBoxImage.Error);
     }
     //dataGrid_BackupList.Items.Refresh();
 }