private void removeExtensionSetting_Click(object sender, RoutedEventArgs e)
        {
            Int32 selected_index = pathGrid.SelectedIndex;

            if (selected_index != -1)
            {
                SavedDataReader.DeleteCustomFileAssociation(selected_index);
            }
            ReloadCustomAssociations();
        }
 public SettingsWindow()
 {
     InitializeComponent();
     SavedDataReader.OpenMode mode = SavedDataReader.Mode;
     if (mode == SavedDataReader.OpenMode.current)
     {
         usePrHome.IsChecked = true;
     }
     else if (mode == SavedDataReader.OpenMode.lastUsed)
     {
         usePrev.IsChecked = true;
     }
     else
     {
         useCustomDirs.IsChecked = true;
         List <String> dirs = SavedDataReader.GetSavedStartingDirsFromXml().ToList();
         leftPathTextBox.Text  = dirs[0];
         rightPathTextBox.Text = dirs[1];
     }
     ReloadCustomAssociations();
 }
Esempio n. 3
0
        public static void InitilalDirs()
        {
            List <String> fileStartPaths = SavedDataReader.GetSavedStartingDirsFromXml().ToList();

            SavedDataReader.LoadUserDefinedFileAssociations();
            String leftPath = fileStartPaths[0];

            if (!Directory.Exists(leftPath))
            {
                leftPath = Directory.GetCurrentDirectory();
                SavedDataReader.SetSavedStartingDirsToXml(SavedDataReader.OpenMode.lastUsed, leftPath, Side.Left);
            }
            String rightPath = fileStartPaths[1];

            if (!Directory.Exists(rightPath))
            {
                rightPath = Directory.GetCurrentDirectory();
                SavedDataReader.SetSavedStartingDirsToXml(SavedDataReader.OpenMode.lastUsed, rightPath, Side.Right);
            }
            File_Containers.FileDualContainer.ChooseContainer(Side.Left).GoToDirectory(leftPath);
            File_Containers.FileDualContainer.ChooseContainer(Side.Right).GoToDirectory(rightPath);
        }
Esempio n. 4
0
        private void confirmButton_Click(object sender, RoutedEventArgs e)
        {
            String filetype = typeBox.Text;
            String handler  = handlerBox.Text;

            if (filetype == String.Empty || handler == String.Empty || Char.IsDigit(filetype[0]) || Char.IsDigit(handler[0]))
            {
                MessageBox.Show("File type or handler name cant starts with digit", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            Boolean isOverride = overrideCheckbox.IsChecked ?? false;

            if (filetype == String.Empty || handler == String.Empty)
            {
                MessageBox.Show("Type or handler value can't be empty", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            try
            {
                if (index != -1)
                {
                    SavedDataReader.EditCustomFileAssociation(index, filetype, handler, isOverride);
                }
                else
                {
                    SavedDataReader.SetCustomFileAssociation(filetype, handler, isOverride);
                }
                DialogResult = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Association can not be set: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                DialogResult = false;
                return;
            }
            this.Close();
        }
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     SavedDataReader.SetSavedStartingDirsToXml(SavedDataReader.OpenMode.lastUsed, File_Containers.FileDualContainer.ChooseContainer(FileOperator.Side.Left).StoredDirectory.Info.FullName, FileOperator.Side.Left);
     SavedDataReader.SetSavedStartingDirsToXml(SavedDataReader.OpenMode.lastUsed, File_Containers.FileDualContainer.ChooseContainer(FileOperator.Side.Right).StoredDirectory.Info.FullName, FileOperator.Side.Right);
     SavedDataReader.SaveUserDefinedFileAssociations();
 }
        private void ReloadCustomAssociations()
        {
            ObservableCollection <FileAssociation> fass = new ObservableCollection <FileAssociation> (SavedDataReader.GetCustomFileAssociation());

            pathGrid.ItemsSource = fass;
        }