public SettingsForm(ITrayCommandHelper trayCommandHelper)
 {
     InitializeComponent();
     txtSecretCode.Text           = Settings.Default.SecretCode;
     txtPort.Text                 = Settings.Default.RemotePort.ToString();
     chkAutoLoad.Checked          = Settings.Default.AutoStart;
     cbxTrayCommand.DisplayMember = "Name";
     cbxTrayCommand.ValueMember   = "CommandType";
     cbxTrayCommand.DataSource    = trayCommandHelper.Commands;
     cbxTrayCommand.SelectedItem  = trayCommandHelper.Commands.SingleOrDefault(c => (int)c.CommandType == Settings.Default.DefaultCommand);
 }
Example #2
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);
        }
Example #3
0
 public HostHelper(ITrayCommandHelper trayCommandHelper)
 {
     _trayCommandHelper       = trayCommandHelper;
     _cancellationTokenSource = new CancellationTokenSource();
 }