public ControllerApplicationContext(SettingsForm.Factory settingsFormFactory, HostHelper.Factory hostHelperFactory, ICommandsSettings commandsSettings, CommandsManager.Factory commandManagerFactory)
        {
            var catalog = new AggregateCatalog();

            var files = Directory.GetFiles($@"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}\Plugins", "*.dll", SearchOption.AllDirectories);

            foreach (var dllFilePath in files)
            {
                var assembly        = Assembly.LoadFrom(Path.GetFullPath(dllFilePath));
                var assemblyCatalog = new AssemblyCatalog(assembly);
                catalog.Catalogs.Add(assemblyCatalog);
            }

            var container = new CompositionContainer(catalog);

            var commands = new List <IRemoteCommand>(container.GetExportedValues <IRemoteCommand>());

            commands.AddRange(container.GetExportedValues <IRemoteCommandContainer>().SelectMany(c => c));
            _commandsManager = commandManagerFactory.Invoke(commands, commandsSettings);
            _settingsForm    = settingsFormFactory.Invoke(_commandsManager);
            _hostHelper      = hostHelperFactory.Invoke(_commandsManager);

            // Initialize Tray Icon
            _trayIcon = new NotifyIcon
            {
                Icon             = Resources.AppIcon,
                ContextMenuStrip = GetContextMenuStrip(),
                Visible          = true
            };

            _hostHelper.SecretCode = Settings.Default.SecretCode;
            _hostHelper.CreateHostAsync(Settings.Default.RemotePort);
        }
예제 #2
0
 public override void Initialize(IHostHelper host)
 {
     try
     {
         m_objHelper = host;
     }
     catch (Exception ex)
     {
         LogWriter.WriteLog(ex);
     }
 }
예제 #3
0
        public ControllerApplicationContext(ITrayCommandHelper trayCommandHelper, SettingsForm settingsForm, IHostHelper hostHelper)
        {
            _trayCommandHelper = trayCommandHelper;
            _settingsForm      = settingsForm;
            _hostHelper        = hostHelper;
            var notifyContextMenu = new ContextMenuStrip();

            _commandButton = new ToolStripMenuItem(_trayCommandHelper.GetText((TrayCommandType)Settings.Default.DefaultCommand))
            {
                Image = Resources.Shutdown.ToBitmap()
            };
            _commandButton.Click += ShutDownClick;
            notifyContextMenu.Items.Add(_commandButton);

            notifyContextMenu.Items.Add("-");

            var settings = new ToolStripMenuItem("Settings")
            {
                Image = Resources.Settings.ToBitmap()
            };

            settings.Click += SettingsClick;
            notifyContextMenu.Items.Add(settings);

            notifyContextMenu.Items.Add("-");

            var exit = new ToolStripMenuItem("Exit")
            {
                Image = Resources.Exit.ToBitmap()
            };

            exit.Click += Exit;
            notifyContextMenu.Items.Add(exit);


            // Initialize Tray Icon
            _trayIcon = new NotifyIcon
            {
                Icon             = Resources.AppIcon,
                ContextMenuStrip = notifyContextMenu,
                Visible          = true
            };

            _hostHelper.SecretCode     = Settings.Default.SecretCode;
            _hostHelper.DefaultCommand = (TrayCommandType)Settings.Default.DefaultCommand;
            _hostHelper.CreateHostAsync(Settings.Default.RemotePort);
        }