Esempio n. 1
0
        private void Compile_Click(object sender, EventArgs e)
        {
            try
            {
                p_OpenFileDialog.FileName = String.Empty;
                //p_OpenFileDialog.InitialDirectory = Config.PluginPath;
                p_OpenFileDialog.Filter = "C# class files (*.cs)|*.cs";
                p_OpenFileDialog.Title  = "Compile and save plug-in (.cs->.dll)";

                if (p_OpenFileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    var p_PluginEngine = new PluginEngine(p_OpenFileDialog.FileName, Config.MainForm);

                    if (
                        !p_PluginEngine.Compile(Path.GetDirectoryName(p_OpenFileDialog.FileName) + "\\" +
                                                Path.GetFileNameWithoutExtension(p_OpenFileDialog.FileName) + ".dll"))
                    {
                        foreach (string error in p_PluginEngine.Errors)
                        {
                            MessageBox.Show("Error compiling plug-in (" + p_PluginEngine.FileName + ")" +
                                            Environment.NewLine + Environment.NewLine + error);
                        }
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                MsgBox.ShowExceptionMessage(ex);
            }
        }
Esempio n. 2
0
        private void InitPluginEngine()
        {
            PluginEngine pluginEngine = new PluginEngine();

            //Restore from context
            pluginEngine.RestorePlugins();
            SimpleEventBus.GetDefaultEventBus().Register(pluginEngine);
        }
Esempio n. 3
0
        private void RefreshAvailablePlugins(object sender, System.Windows.RoutedEventArgs e)
        {
            PluginEngine.RefreshAvailablePlugins(txtPluginsLocation.Text);

            // Force refresh by re-binding the CollectionView source
            // TODO: how should this be done with MVVM properly? we don't have property change notifications for the read-only list of plugins...
            ((CollectionViewSource)this.Resources["AvailablePluginsCollectionViewSource"]).Source = PluginEngine.GetAllAvailablePlugins();
        }
Esempio n. 4
0
 public PluginManager(string fileName, IApp app)
 {
     pluginFileInfo = new FileInfo(fileName);
     if (Find(pluginFileInfo.FullName) != null)
     {
         throw new Exception("Plug-in has been added!");
     }
     engine = new PluginEngine(fileName, app);
 }
Esempio n. 5
0
        public static void Remove(string fileName)
        {
            PluginEngine engine = Find(fileName);

            if (null != engine)
            {
                engines.Remove(engine);
            }
        }
Esempio n. 6
0
        private void LoadPlugins()
        {
            string pluginPath = @"H:\Dokumenty\Kod\C#\UploadApp\BaseApp\PluginMusicPlayer\bin\Debug\";

            WpfConsole.WriteLine("Load Plugins from: " + pluginPath);
            PluginEngine pluginEngine = new PluginEngine();

            pluginEngine.FindPlugins(pluginPath);
            pluginEngine.InitializePlugins();
        }
Esempio n. 7
0
 public override void Register(SafeContextHandle context)
 {
     base.Register(context);
     unsafe
     {
         GVC_t *      gvc = (GVC_t *)context.DangerousGetHandle();
         PluginEngine textLayoutEngine = Engines.Single(i => i.Api == api_t.TextLayout);
         gvc->textlayout.engine = (gvtextlayout_engine_t *)textLayoutEngine.InstalledPluginData->engine;
     }
 }
Esempio n. 8
0
        public SettingsWindow(MainWindow mainWindow, PluginEngine pluginEngine)
        {
            InitializeComponent();
            Model = new SettingsWindowModel();

            _mainWindow   = mainWindow;
            _pluginEngine = pluginEngine;

            _ = Dispatcher.InvokeAsync(async() => await PopulateUpdateLog());
        }
Esempio n. 9
0
        public SettingsWindow(MainWindow mainWindow, PluginEngine pluginEngine)
        {
            InitializeComponent();
            Model = new SettingsWindowModel();

            _mainWindow   = mainWindow;
            _pluginEngine = pluginEngine;

            LblVersion.Content = "Version " + AppConstants.Version;
        }
        public TextSnippetWindow(PluginEngine pluginEngine, TextSnippet snippet = null)
        {
            _pluginEngine = pluginEngine;
            InitializeComponent();

            if (snippet != null)
            {
                TxtTitle.Text   = snippet.Identifier;
                TxtContent.Text = snippet.RawContent;
            }
        }
Esempio n. 11
0
        /// <summary>
        ///     是否已经存在
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static bool Exists(string fileName)
        {
            bool         result = false;
            PluginEngine pe     = Find(fileName);

            if (pe != null)
            {
                result = true;
            }
            return(result);
        }
Esempio n. 12
0
        public static Dictionary <Guid, TPluginType> GetPlugins <TPluginType>(string pluginsPath)
            where TPluginType : IBasePlugin
        {
            Dictionary <Guid, TPluginType> result = new Dictionary <Guid, TPluginType>();

            //Get all plugins of required plugin type
            foreach (TPluginType plugin in PluginEngine.GetPlugins <TPluginType>(pluginsPath))
            {
                result.Add(plugin.PluginGuid, plugin);
            }

            return(result);
        }
Esempio n. 13
0
        public override void InitInternals()
        {
            base.InitInternals();
            var exeName = MinersBinsUrlsSettings?.ExePath.LastOrDefault();

            PluginEngine = GuessMinerBinaryPluginEngine(exeName);
            Logger.Info(Name, $"PluginEngine {PluginEngine}");
            try
            {
                // since MinerSettings is extending MinerCommandLineSettings delete this internal setting file to reduce confusion
                //(MinerCommandLineSettings, _) = InternalConfigsCommon.GetDefaultOrFileSettings(Paths.MinerPluginsPath(PluginUUID, "internals", "MinerCommandLineSettings.json"), MinerCommandLineSettings);
                File.Delete(Paths.MinerPluginsPath(PluginUUID, "internals", "MinerCommandLineSettings.json"));
            }
            catch
            {}
            MinerCommandLineSettings = MinerSettings;
        }
Esempio n. 14
0
        public MainWindow()
        {
            InitializeComponent();

            Editor.API.NotificationSystem.Initialize(UI_DockPanel_Notification, UI_DockPanel_Notification_Translate);
            UpdateSystem.Initialize();

            Navegation.NavegationMenu = navegationBar;
            Navegation.TabControl     = UI_TabControl;
            PluginEngine.Initialize();

            //PluginManager pluginManager = new PluginManager();
            // Internal.System.Initialize();
            // NavegationBar = this.navegationBar;
            // Main = this;
            InitializeUI();
        }
Esempio n. 15
0
        static void Main()
        {
            ObjectDefinition objDef = new ObjectDefinition();

            objDef.Name      = "PluginEngine";
            objDef.Type      = typeof(CompactPlugs.PluginEngine).ToString();
            objDef.FileName  = "CompactPlugs.dll";
            objDef.Singleton = true;
            Property p = new Property("PluginLocator", typeof(CompactPlugs.PluginLocators.SimpleFilePluginLocator), "CompactPlugs.dll");

            objDef.Properties = new Property[] { p };
            CompactInjection.CompactConstructor.DefaultConstructor.AddDefinition(objDef, "default");
            PluginEngine plugEngine = CompactConstructor.DefaultConstructor.New <PluginEngine>("PluginEngine");

            plugEngine.Run();
            Application.Run(plugEngine.WinForm as System.Windows.Forms.Form);
        }
Esempio n. 16
0
        public MainWindow()
        {
            InitializeComponent();

            Model = new MainWindowModel();

            _pluginEngine   = new PluginEngine();
            _queryHistory   = new QueryHistory(10);
            _settingsWindow = new SettingsWindow(this, _pluginEngine);

            _pluginEngine.Listeners.Add(_settingsWindow);

            RegisterHotkey(AppConstants.HotkeyToggleVisibilityId, _settingsWindow.Model.HotkeyToggleVisibility, OnToggleVisibility);
            RegisterHotkey(AppConstants.HotkeyPasteId, _settingsWindow.Model.HotkeyPasteClipboard, OnSystemClipboardPaste);

            _clipboard.ClipboardChanged += ClipboardOnClipboardChanged;
        }
Esempio n. 17
0
        public OcrSnippetWindow(PluginEngine pluginEngine, OcrTextSnippet abstractSnippet = null)
        {
            _pluginEngine = pluginEngine;

            InitializeComponent();
            Model = new OcrSnippetWindowModel();

            if (abstractSnippet != null)
            {
                TxtTitle.Text = abstractSnippet.Identifier;

                foreach (var(content, base64) in abstractSnippet.Transcriptions)
                {
                    var bitmap = BitmapToBase64Converter.ConvertBack(base64);
                    Model.BitmapPairs.Add(new BitmapTextPair(bitmap.ToImageSource(), null, content));
                }
            }
        }
Esempio n. 18
0
        private void InstallSystemPlugins()
        {
            var allPlugins = TypeFinder.ClassesOfType <IPlugin>();

            var systemPlugins =
                allPlugins.Where(x => (x as IPlugin).IsSystemPlugin)
                .Select(plugin => (IPlugin)Activator.CreateInstance(plugin))
                .ToList();

            //run the install method
            foreach (var plugin in systemPlugins)
            {
                if (!PluginEngine.IsInstalled(plugin.PluginInfo))
                {
                    plugin.Install();
                }
            }
        }
Esempio n. 19
0
        public static PluginEngine Find(string fileName)
        {
            PluginEngine engine = null;

            if (null == engines)
            {
                return(null);
            }

            foreach (PluginEngine pe in engines)
            {
                if (pe.FileName.ToLower() == fileName.ToLower())
                {
                    engine = pe;
                    break;
                }
            }

            return(engine);
        }
Esempio n. 20
0
        public MainWindow()
        {
            InitializeComponent();

            // Load old settings
            AppSettings.Load();

            Model = new MainWindowModel();

            _pluginEngine   = new PluginEngine();
            _queryHistory   = new QueryHistory(10);
            _settingsWindow = new SettingsWindow(this, _pluginEngine);

            _pluginEngine.Listeners.Add(_settingsWindow);

            LoadPlugins();

            var hotkey = _settingsWindow.Model.Hotkey;

            HotkeyManager.Current.AddOrReplace(AppConstants.HotkeyIdentifier, hotkey.Key, hotkey.Modifiers, OnToggleVisibility);
        }
Esempio n. 21
0
        public MainWindow()
        {
            InitializeComponent();

            Model = new MainWindowModel();

            _pluginEngine   = new PluginEngine();
            _queryHistory   = new QueryHistory(10);
            _settingsWindow = new SettingsWindow(this, _pluginEngine);

            _pluginEngine.Listeners.Add(_settingsWindow);

            var hotkey = _settingsWindow.Model.Hotkey;

            try
            {
                HotkeyManager.Current.AddOrReplace(AppConstants.HotkeyIdentifier, hotkey.Key, hotkey.Modifiers, OnToggleVisibility);
            }
            catch (HotkeyAlreadyRegisteredException)
            {
                var msg = $"Failed to register Pinpoint hotkey, {_settingsWindow.Model.Hotkey.Text} seems to already be bound. You can pick another one in settings.";
                MessageBox.Show(msg, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 22
0
        void button1_Click(object sender, EventArgs e)
        {
            PluginEngine plugEngine = CompactConstructor.DefaultConstructor.New <PluginEngine>("PluginEngine");

            plugEngine.CallPlugins(this);
        }
Esempio n. 23
0
 public OcrSnippetWindow(PluginEngine pluginEngine) : this(pluginEngine, null)
 {
 }
Esempio n. 24
0
        private void App_OnStartup(object sender, StartupEventArgs e)
        {
            try
            {
                Log.Info("Boot strapping the services and UI.");

                // We manually close this because automatic closure steals focus from the
                // dynamic splash screen.
                splashScreen.Close(TimeSpan.FromSeconds(0.5f));

                //Apply theme
                applyTheme();

                //Define MainViewModel before services so I can setup a delegate to call into the MainViewModel
                //This is to work around the fact that the MainViewModel is created after the services.
                MainViewModel     mainViewModel         = null;
                Action <KeyValue> fireKeySelectionEvent = kv =>
                {
                    if (mainViewModel != null) //Access to modified closure is a good thing here, for once!
                    {
                        mainViewModel.FireKeySelectionEvent(kv);
                    }
                };

                CleanupAndPrepareCommuniKateInitialState();

                ValidateDynamicKeyboardLocation();

                // Handle plugins. Validate if directory exists and is accessible and pre-load all plugins, building a in-memory list of available ones.
                ValidatePluginsLocation();
                if (Settings.Default.EnablePlugins)
                {
                    PluginEngine.LoadAvailablePlugins();
                }

                var presageInstallationProblem = PresageInstallationProblemsDetected();

                //Create services
                var           errorNotifyingServices = new List <INotifyErrors>();
                IAudioService audioService           = new AudioService();

                IDictionaryService           dictionaryService           = new DictionaryService(Settings.Default.SuggestionMethod);
                IPublishService              publishService              = new PublishService();
                ISuggestionStateService      suggestionService           = new SuggestionStateService();
                ICalibrationService          calibrationService          = CreateCalibrationService();
                ICapturingStateManager       capturingStateManager       = new CapturingStateManager(audioService);
                ILastMouseActionStateManager lastMouseActionStateManager = new LastMouseActionStateManager();
                IKeyStateService             keyStateService             = new KeyStateService(suggestionService, capturingStateManager, lastMouseActionStateManager, calibrationService, fireKeySelectionEvent);
                IInputService inputService = CreateInputService(keyStateService, dictionaryService, audioService,
                                                                calibrationService, capturingStateManager, errorNotifyingServices);
                IKeyboardOutputService keyboardOutputService = new KeyboardOutputService(keyStateService, suggestionService, publishService, dictionaryService, fireKeySelectionEvent);
                IMouseOutputService    mouseOutputService    = new MouseOutputService(publishService);
                errorNotifyingServices.Add(audioService);
                errorNotifyingServices.Add(dictionaryService);
                errorNotifyingServices.Add(publishService);
                errorNotifyingServices.Add(inputService);

                ReleaseKeysOnApplicationExit(keyStateService, publishService);

                //Compose UI
                var mainWindow = new MainWindow(audioService, dictionaryService, inputService, keyStateService);
                IWindowManipulationService mainWindowManipulationService = CreateMainWindowManipulationService(mainWindow);
                errorNotifyingServices.Add(mainWindowManipulationService);
                mainWindow.WindowManipulationService = mainWindowManipulationService;

                //Subscribing to the on closing events.
                mainWindow.Closing += dictionaryService.OnAppClosing;

                mainViewModel = new MainViewModel(
                    audioService, calibrationService, dictionaryService, keyStateService,
                    suggestionService, capturingStateManager, lastMouseActionStateManager,
                    inputService, keyboardOutputService, mouseOutputService, mainWindowManipulationService,
                    errorNotifyingServices);

                mainWindow.SetMainViewModel(mainViewModel);

                //Setup actions to take once main view is loaded (i.e. the view is ready, so hook up the services which kicks everything off)
                Action postMainViewLoaded = () =>
                {
                    mainViewModel.AttachErrorNotifyingServiceHandlers();
                    mainViewModel.AttachInputServiceEventHandlers();
                };

                mainWindow.AddOnMainViewLoadedAction(postMainViewLoaded);

                //Show the main window
                mainWindow.Show();

                if (Settings.Default.LookToScrollShowOverlayWindow)
                {
                    // Create the overlay window, but don't show it yet. It'll make itself visible when the conditions are right.
                    new LookToScrollOverlayWindow(mainViewModel);
                }

                //Display splash screen and check for updates (and display message) after the window has been sized and positioned for the 1st time
                EventHandler sizeAndPositionInitialised = null;
                sizeAndPositionInitialised = async(_, __) =>
                {
                    mainWindowManipulationService.SizeAndPositionInitialised -= sizeAndPositionInitialised; //Ensure this handler only triggers once
                    await ShowSplashScreen(inputService, audioService, mainViewModel, OptiKey.Properties.Resources.OPTIKEY_SYMBOL_DESCRIPTION);

                    await mainViewModel.RaiseAnyPendingErrorToastNotifications();
                    await AttemptToStartMaryTTSService(inputService, audioService, mainViewModel);
                    await AlertIfPresageBitnessOrBootstrapOrVersionFailure(presageInstallationProblem, inputService, audioService, mainViewModel);

                    inputService.RequestResume(); //Start the input service

                    await CheckForUpdates(inputService, audioService, mainViewModel);
                };

                if (mainWindowManipulationService.SizeAndPositionIsInitialised)
                {
                    sizeAndPositionInitialised(null, null);
                }
                else
                {
                    mainWindowManipulationService.SizeAndPositionInitialised += sizeAndPositionInitialised;
                }

                Current.Exit += (o, args) =>
                {
                    mainWindowManipulationService.PersistSizeAndPosition();
                    Settings.Default.Save();
                };
            }
            catch (Exception ex)
            {
                Log.Error("Error starting up application", ex);
                throw;
            }
        }
Esempio n. 25
0
 public ScreenCaptureOverlayWindow(PluginEngine pluginEngine)
 {
     _ocrSnippetWindow = new OcrSnippetWindow(pluginEngine);
     InitializeComponent();
 }
Esempio n. 26
0
 private void RefreshAvailablePlugins(object sender, System.Windows.RoutedEventArgs e)
 {
     PluginEngine.RefreshAvailablePlugins();
 }
Esempio n. 27
0
        private void InitPluginEngine()
        {
            PluginEngine pluginEngine = new PluginEngine();

            SimpleEventBus.GetDefaultEventBus().Register(pluginEngine);
        }