Пример #1
0
        private void MenuItem_FileProperty_Click(object sender, RoutedEventArgs e)
        {
            // Get file path
            JFile  file     = (sender as MenuItem).DataContext as JFile;
            string filePath = App.GetParentFolderPath(file.Parent) + file.FileName;

            SystemInterpService.ShowFileProperties(filePath);
        }
Пример #2
0
        private void MenuItem_FolderProperty_Click(object sender, RoutedEventArgs e)
        {
            // Get folder path
            JFolder folder     = (sender as MenuItem).DataContext as JFolder;
            string  folderPath = App.GetParentFolderPath(folder);

            SystemInterpService.ShowFileProperties(folderPath);
        }
Пример #3
0
        private void OnTreeViewItemPreviewKeyDown(object sender, KeyEventArgs e)
        {
            Key key = (e.Key == Key.System ? e.SystemKey : e.Key);

            // Enter key for quick search
            if (key == Key.Enter)
            {
                // If SHIFT is pressed, then open file location if file, otherwise ignore
                if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    // Make sure some node is selected and that represents a file
                    JFile file = DirectoryView.SelectedItem as JFile;
                    if (file != null)
                    {
                        OpenFolderForInspection(file.Parent);
                        e.Handled = true;
                    }
                }
                // If ALT is pressed, then open property window
                else if ((Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt)
                {
                    // Open as a file
                    JFile file = DirectoryView.SelectedItem as JFile;
                    if (file != null)
                    {
                        SystemInterpService.ShowFileProperties(App.GetParentFolderPath(file.Parent) + file.FileName);
                        e.Handled = true;
                    }
                    // Open as a folder
                    JFolder folder = DirectoryView.SelectedItem as JFolder;
                    if (folder != null)
                    {
                        SystemInterpService.ShowFileProperties(App.GetParentFolderPath(folder));
                        e.Handled = true;
                    }
                }
                // Open as is
                else
                {
                    // Open as a file
                    JFile file = DirectoryView.SelectedItem as JFile;
                    if (file != null)
                    {
                        OpenFileForEditing(file);
                        e.Handled = true;
                    }
                    // Open as a folder
                    JFolder folder = DirectoryView.SelectedItem as JFolder;
                    if (folder != null)
                    {
                        OpenFolderForInspection(folder);
                        e.Handled = true;
                    }
                }
            }
        }
Пример #4
0
        private void SearchKeywordBox_KeyDown(object sender, KeyEventArgs e)
        {
            // http://stackoverflow.com/questions/3099472/previewkeydown-is-not-seeing-alt-modifiers
            Key key = (e.Key == Key.System ? e.SystemKey : e.Key);

            // Enter key for quick search
            if (key == Key.Enter)
            {
                // Application short cut
                if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
                {
                    // Theoratically we can search in index list and open any file with .exe extension (pending implementation) but applications in app home has priority (and doesn't need a suffix)
                    // Pending ignoring upper/lower case

                    // Check file exit
                    string AppPath = AppDomain.CurrentDomain.BaseDirectory + "\\" + App.AppHome + "\\" + SearchKeywordBox.Text;
                    if (!File.Exists(AppPath))
                    {
                        AppPath += ".exe";
                        if (!File.Exists(AppPath))
                        {
                            AppPath = null;
                        }
                    }

                    if (AppPath != null)
                    {
                        System.Diagnostics.Process.Start(AppPath);
                    }
                    else
                    {
                        // update status for information
                        StatusLabel.Content = "Executable doesn't exist.";
                    }
                }

                JFolder CurrentDisplay = (DirectoryView.ItemsSource as List <JFolder>).First();

                // If no match found
                if (CurrentDisplay == null)
                {
                    StatusLabel.Content = "No file to open.";
                }
                // If more than one match if found
                if (CurrentDisplay.Files.Count > 1)
                {
                    StatusLabel.Content = "More than one match is found, please open using tree view.";
                }
                // Otherwise there can be only one match
                else
                {
                    if (FolderCheckBox.IsChecked == true) // We are displaying folder serach results
                    {
                        // Get JFolder first
                        List <JFolder> subFolders = CurrentDisplay.Folders;
                        while (subFolders[0].Folders.Count != 0)
                        {
                            subFolders = subFolders[0].Folders;
                        }
                        JFolder foundFolder = subFolders[0];

                        // If used Alt to open properties
                        if ((Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt)
                        {
                            SystemInterpService.ShowFileProperties(App.GetParentFolderPath(foundFolder));
                        }
                        // Otherwise open folder
                        else
                        {
                            OpenFolderForInspection(foundFolder);
                        }
                    }
                    else // We are displaying file search results
                    {
                        // Get JFile first
                        List <JFolder> subFolders = CurrentDisplay.Folders;
                        while (subFolders[0].Folders.Count != 0)
                        {
                            subFolders = subFolders[0].Folders;
                        }
                        JFile foundFile = subFolders[0].Files[0];
                        // If used SHIFT then open file location
                        if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
                        {
                            OpenFolderForInspection(foundFile.Parent);
                        }
                        // If used Alt to open properties
                        else if ((Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt)
                        {
                            SystemInterpService.ShowFileProperties(App.GetParentFolderPath(foundFile.Parent) + foundFile.FileName);
                        }
                        // Otherwise just open file
                        else
                        {
                            OpenFileForEditing(foundFile);
                            PreviousOpenFile = foundFile;   // For later quick access
                        }
                    }
                }
            }
        }
Пример #5
0
        // App-wise Short cut setup
        // http://stackoverflow.com/questions/4682915/defining-menuitem-shortcuts
        // http://stackoverflow.com/questions/3574405/c-wpf-implement-keyboard-shortcuts
        // https://social.msdn.microsoft.com/Forums/vstudio/en-US/2b2121f9-ef4e-4e38-8442-763f608e1837/how-to-create-keyboard-shortcuts-in-wpf?forum=wpf input bindings
        // Also see personal WPF notes
        private void HandleKeyDownEvent(object sender, KeyEventArgs e)
        {
            // Example: if (e.Key == Key.H && (Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) == (ModifierKeys.Control | ModifierKeys.Shift))

            // Ctrl-H Open Home Folder (Application Home)
            if (e.Key == Key.H && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
            {
                System.Diagnostics.Process.Start(AppDomain.CurrentDomain.BaseDirectory + "\\" + App.UserHome);
                e.Handled = true;
            }
            // ESC: Hide Application (Minimize)
            if (e.Key == Key.Escape)
            {
                this.WindowState = WindowState.Minimized;
                e.Handled        = true;
            }
            // Ctrl-O: Load JSON file shortcut: I know this is a bit not so professional but WHY I CANNOT FIND MY VS PROJECT for 墨迹笔记?!
            if (e.Key == Key.O && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
            {
                LoadJSONFile_MouseDown(null, null);
                e.Handled = true;
            }
            // Ctrl-F: Search
            if (e.Key == Key.F && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
            {
                Keyboard.Focus(SearchKeywordBox);
                SearchKeywordBox.SelectAll();
                e.Handled = true;
            }
            // Ctrl/Shift/Alt-P: Open previously opened file
            if (e.Key == Key.P)
            {
                // If used SHIFT then open file location
                if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    OpenFolderForInspection(PreviousOpenFile.Parent);
                    e.Handled = true;
                }
                // If used Alt to open properties
                else if ((Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt)
                {
                    SystemInterpService.ShowFileProperties(App.GetParentFolderPath(PreviousOpenFile.Parent) + PreviousOpenFile.FileName);
                    e.Handled = true;
                }
                // Otherwise just open file
                else if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
                {
                    OpenFileForEditing(PreviousOpenFile);
                    e.Handled = true;
                }
            }
            // F1: File Mode
            if (e.Key == Key.F1)
            {
                if (CurrentSearchMode == ContentSearchMode.SingleFile)
                {
                    UpdateSearchMode(ContentSearchMode.MultiFile);
                }
                else
                {
                    FolderCheckBox.IsChecked = false;   // Notice when the state of check box changes it will trigger its checked/unchecked handler where we have already set the value
                    UpdateSearchMode(ContentSearchMode.SingleFile);
                }
                e.Handled = true;
            }
            // F2: Folder Mode
            if (e.Key == Key.F2)
            {
                if (CurrentSearchMode == ContentSearchMode.SingleFolder)
                {
                    UpdateSearchMode(ContentSearchMode.MultiFolder);
                }
                else
                {
                    FolderCheckBox.IsChecked = true;
                    UpdateSearchMode(ContentSearchMode.SingleFolder);
                }
                e.Handled = true;
            }
            // F3: Airi on/off
            if (e.Key == Key.F3)
            {
                if (CurrentAiriMode == AiriMode.Activated)
                {
                    UpdateAiriMode(AiriMode.Disabled);
                    voiceEngine.Deactivate();
                }
                else
                {
                    UpdateAiriMode(AiriMode.Activated);
                    voiceEngine.Activate();
                }
                e.Handled = true;
            }
            // F4: Dictionary Mode
        }