Exemple #1
0
        // Initiate tray service which has console access and allows remote access
        public AppContext(string clientId, string configLocation, string scriptFile, string logFile, int logLevel)
        {
            //TODO Make sure passed in loglevel sets the menubuttons correctly
            //TODO The loglevel icons do not seem to appear in the far left image column
            //TODO Can we make the log level menu NOT disappear when a value is clicked
            //TODO Make sure title image on popup displays correctly

            if (logFile != "") _logFile = logFile;

            _manager = new Manager();
            _manager.Initialise(configLocation, clientId, logFile, logLevel);

            _commands = new CommandService();
            _messages = new MessageService();

            _clientId = clientId;
            _configLocation = configLocation;

            if (File.Exists(scriptFile)) {
                string scriptContents = File.ReadAllText(scriptFile);
                _commands.ExecuteCommand(_clientId, scriptContents, null);
            }

            _fixedTitle = Assembly.GetExecutingAssembly().GetName().Name + " " + Assembly.GetExecutingAssembly().GetName().Version.ToString();

            #region CreateMenu

            //TODO Image not correct for heading label
            _heading = new ToolStripLabel(Properties.Resources.TycTakTitle);
            _heading.AutoSize = false;
            _heading.Size = new System.Drawing.Size(100, 25);
            _heading.DisplayStyle = ToolStripItemDisplayStyle.Image;
            _heading.ImageScaling = ToolStripItemImageScaling.None;

            _console = new ToolStripMenuItem("Console", Properties.Resources.Client.ToBitmap(), OpenConsole);
            _logLevel1 = new ToolStripButton("Internal", Properties.Resources.IntCode.ToBitmap(), ChangeLog); _logLevel1.Tag = "2"; _logLevel1.CheckOnClick = true;
            _logLevel2 = new ToolStripButton("External", Properties.Resources.ExtCode.ToBitmap(), ChangeLog); _logLevel2.Tag = "4"; _logLevel2.CheckOnClick = true;
            _logLevel3 = new ToolStripButton("Errors", Properties.Resources.ErrorCode.ToBitmap(), ChangeLog); _logLevel3.Tag = "8"; _logLevel3.CheckOnClick = true;
            _viewLog = new ToolStripButton("View Log", Properties.Resources.Log.ToBitmap(), ViewLog);
            _sep3 = new ToolStripSeparator();
            _logLevel = new ToolStripMenuItem("Logging", Properties.Resources.Log.ToBitmap(), new ToolStripItem[] { _viewLog, _sep3, _logLevel1, _logLevel2, _logLevel3 }); _logLevel.CheckOnClick = true;
            _sep1 = new ToolStripSeparator();
            _start = new ToolStripMenuItem("Start service", Properties.Resources.StartService.ToBitmap(), Start); _start.Enabled = true;
            _stop = new ToolStripMenuItem("Stop service", Properties.Resources.StopService.ToBitmap(), Stop); _stop.Enabled = false;
            _sep2 = new ToolStripSeparator();
            //_processCommand = new ToolStripMenuItem("Process Command", Properties.Resources.StartService.ToBitmap(), ProcessCommand); _processCommand.Enabled = true;
            _exit = new ToolStripMenuItem("Exit", Properties.Resources.ExitService.ToBitmap(), Exit);

            _mainmenu = new ContextMenuStrip();
            _mainmenu.Items.AddRange(new ToolStripItem[] { _heading, _console, _logLevel, _sep1, _start, _stop, _sep2, _exit });

            _tray = new NotifyIcon();
            _tray.Icon = Properties.Resources.TrayIcon;
            _tray.ContextMenuStrip = _mainmenu;

            #endregion

            _tray.Text = Title();
            _tray.Visible = true;
        }
Exemple #2
0
        public Client(string clientId, CommandService process, MessageService messages, Manager manager, string title)
        {
            InitializeComponent();

            _title = title;
            _clientId = clientId;
            _process = process;
            _messages = messages;
            _manager = manager;

            _prompt = _manager.Prompt();

            txtConsole.Clear();

            txtConsole.AcceptsTab = false;
            txtConsole.AllowDrop = false;
            txtConsole.AutoWordSelection = true;
            txtConsole.Capture = false;
            txtConsole.DetectUrls = true;
            txtConsole.EnableAutoDragDrop = false;
            txtConsole.HideSelection = false;
            txtConsole.SelectionStart = txtConsole.Text.Length;
            txtConsole.ShortcutsEnabled = false;
            txtConsole.WordWrap = false;

            txtConsole.KeyDown += new KeyEventHandler(catchKeyDown);

            //DisableMouseClicks();

            DisplayTitle();
            DisplayPrompt(false);
        }