Ejemplo n.º 1
0
        private void refreshMenu()
        {
            reader = new AppSettingsReader();
            try
            {
                readConfig = (string)reader.GetValue("newFile", typeof(string));
                newButton.InputGestureText = readConfig;
                hotkey = (KeyGesture) new KeyGestureConverter().ConvertFromString(readConfig);
                KeyBinding newFileHotkey = new KeyBinding(new RelayCommand(o =>
                {
                    newButton.RaiseEvent(new RoutedEventArgs(MenuItem.ClickEvent));
                }, o => true), hotkey);
                InputBindings.Add(newFileHotkey);

                readConfig = (string)reader.GetValue("openFile", typeof(string));
                openButton.InputGestureText = readConfig;
                hotkey = (KeyGesture) new KeyGestureConverter().ConvertFromString(readConfig);
                KeyBinding openFileHotkey = new KeyBinding(new RelayCommand(o =>
                {
                    openButton.RaiseEvent(new RoutedEventArgs(MenuItem.ClickEvent));
                }, o => true), hotkey);
                InputBindings.Add(openFileHotkey);

                readConfig = (string)reader.GetValue("saveFile", typeof(string));
                saveButton.InputGestureText = readConfig;
                hotkey = (KeyGesture) new KeyGestureConverter().ConvertFromString(readConfig);
                KeyBinding saveFileHotkey = new KeyBinding(new RelayCommand(o =>
                {
                    saveButton.RaiseEvent(new RoutedEventArgs(MenuItem.ClickEvent));
                }, o => true), hotkey);
                InputBindings.Add(saveFileHotkey);

                readConfig = (string)reader.GetValue("closeWindow", typeof(string));
                exitButton.InputGestureText = readConfig;
                hotkey = (KeyGesture) new KeyGestureConverter().ConvertFromString(readConfig);
                KeyBinding closeWindowHotkey = new KeyBinding(new RelayCommand(o =>
                {
                    if (Directory.Exists(Directory.GetCurrentDirectory() + @"\Buffer"))
                    {
                        Directory.Delete(Directory.GetCurrentDirectory() + @"\Buffer", true);
                    }
                    Environment.Exit(1);
                }, o => true), hotkey);
                InputBindings.Add(closeWindowHotkey);

                readConfig = (string)reader.GetValue("pluginsMenu", typeof(string));
                openPlMenuButton.InputGestureText = readConfig;
                hotkey = (KeyGesture) new KeyGestureConverter().ConvertFromString(readConfig);
                KeyBinding pluginsMenuHotkey = new KeyBinding(new RelayCommand(o =>
                {
                    Plugins pluginsWindow = new Plugins(this);
                    pluginsWindow.ShowDialog();
                }, o => true), hotkey);
                InputBindings.Add(pluginsMenuHotkey);

                readConfig = (string)reader.GetValue("runPlugins", typeof(string));
                runButton.InputGestureText = readConfig;
                hotkey = (KeyGesture) new KeyGestureConverter().ConvertFromString(readConfig);
                KeyBinding runPluginsHotkey = new KeyBinding(new RelayCommand(o =>
                {
                    Plugins pluginsWindow = new Plugins(this);
                    pluginsWindow.JustRun();
                }, o => true), hotkey);
                InputBindings.Add(runPluginsHotkey);

                readConfig = (string)reader.GetValue("settings", typeof(string));
                settingsButton.InputGestureText = readConfig;
                hotkey = (KeyGesture) new KeyGestureConverter().ConvertFromString(readConfig);
                KeyBinding settingsHotkey = new KeyBinding(new RelayCommand(o =>
                {
                    settingsButton.RaiseEvent(new RoutedEventArgs(MenuItem.ClickEvent));
                }, o => true), hotkey);
                InputBindings.Add(settingsHotkey);
            }
            catch (Exception)
            {
                MessageBox.Show("Config file not loaded, loaded standart settings", "Warning", MessageBoxButton.OK, MessageBoxImage.Error);
                hotkey = (KeyGesture) new KeyGestureConverter().ConvertFromString("Ctrl+N");
                newButton.InputGestureText = "Ctrl+N";
                KeyBinding newFileHotkey = new KeyBinding(new RelayCommand(o =>
                {
                    newButton.RaiseEvent(new RoutedEventArgs(MenuItem.ClickEvent));
                }, o => true), hotkey);
                InputBindings.Add(newFileHotkey);
                openButton.InputGestureText = "Ctrl+L";
                hotkey = (KeyGesture) new KeyGestureConverter().ConvertFromString("Ctrl+L");
                KeyBinding openFileHotkey = new KeyBinding(new RelayCommand(o =>
                {
                    openButton.RaiseEvent(new RoutedEventArgs(MenuItem.ClickEvent));
                }, o => true), hotkey);
                InputBindings.Add(openFileHotkey);
                saveButton.InputGestureText = "Ctrl+S";
                hotkey = (KeyGesture) new KeyGestureConverter().ConvertFromString("Ctrl+S");
                KeyBinding saveFileHotkey = new KeyBinding(new RelayCommand(o =>
                {
                    saveButton.RaiseEvent(new RoutedEventArgs(MenuItem.ClickEvent));
                }, o => true), hotkey);
                InputBindings.Add(saveFileHotkey);
                exitButton.InputGestureText = "Esc";
                hotkey = (KeyGesture) new KeyGestureConverter().ConvertFromString("Esc");
                KeyBinding closeWindowHotkey = new KeyBinding(new RelayCommand(o =>
                {
                    if (Directory.Exists(Directory.GetCurrentDirectory() + @"\Buffer"))
                    {
                        Directory.Delete(Directory.GetCurrentDirectory() + @"\Buffer", true);
                    }
                    Environment.Exit(1);
                }, o => true), hotkey);
                InputBindings.Add(closeWindowHotkey);
                openPlMenuButton.InputGestureText = "F2";
                hotkey = (KeyGesture) new KeyGestureConverter().ConvertFromString("F2");
                KeyBinding pluginsMenuHotkey = new KeyBinding(new RelayCommand(o =>
                {
                    Plugins pluginsWindow = new Plugins(this);
                    pluginsWindow.ShowDialog();
                }, o => true), hotkey);
                InputBindings.Add(pluginsMenuHotkey);
                runButton.InputGestureText = "F1";
                hotkey = (KeyGesture) new KeyGestureConverter().ConvertFromString("F1");
                KeyBinding runPluginsHotkey = new KeyBinding(new RelayCommand(o =>
                {
                    Plugins pluginsWindow = new Plugins(this);
                    pluginsWindow.JustRun();
                }, o => true), hotkey);
                InputBindings.Add(runPluginsHotkey);
                settingsButton.InputGestureText = "F9";
                hotkey = (KeyGesture) new KeyGestureConverter().ConvertFromString("F9");
                KeyBinding settingsHotkey = new KeyBinding(new RelayCommand(o =>
                {
                    settingsButton.RaiseEvent(new RoutedEventArgs(MenuItem.ClickEvent));
                }, o => true), hotkey);
                InputBindings.Add(settingsHotkey);
            }
        }
Ejemplo n.º 2
0
        private void MenuItem_Click_3(object sender, RoutedEventArgs e)
        {
            Plugins pluginsWindow = new Plugins(this);

            pluginsWindow.JustRun();
        }
Ejemplo n.º 3
0
        private void MenuItem_Click_4(object sender, RoutedEventArgs e)
        {
            Plugins pluginsWindow = new Plugins(this);

            pluginsWindow.ShowDialog();
        }
Ejemplo n.º 4
0
        private void Button_Click_5(object sender, RoutedEventArgs e)
        {
            Plugins plugWindow = new Plugins(this);

            plugWindow.ShowDialog();
        }