コード例 #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="config"></param>
        public ConsoleController(Config config)
        {
            if (config == null)
                throw new ArgumentNullException("config");

            this.config = config;

            this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
            this.ShowInTaskbar = false;
            this.WindowState = FormWindowState.Minimized;
            this.Visible = false;

            this.trayIcon = new NotifyIcon();
            this.trayIcon.Icon = WinQuakeCon.Properties.Resources.Icon;
            this.trayIcon.Visible = true;

            ContextMenu menu = new ContextMenu();
            menu.MenuItems.Add("Toggle Console", this.TrayIcon_ToggleConsole);
            menu.MenuItems.Add("Reload Config", this.TrayIcon_ReloadConfig);
            menu.MenuItems.Add("Exit", this.TrayIcon_Exit);

            this.trayIcon.ContextMenu = menu;
            this.trayIcon.DoubleClick += this.TrayIcon_ToggleConsole;
        }
コード例 #2
0
ファイル: Config.cs プロジェクト: smack0007/WinQuakeCon
        public static Config Load(string fileName)
        {
            Config config = new Config();

            // TODO: Validate config file.

            try
            {
                XDocument document = XDocument.Load(fileName);
                config.HotKeyCode = int.Parse(document.Root.Element("HotKeyCode").Value);
                config.HotKeyAlt = document.Root.Element("HotKeyAlt").Value.ToUpper() == "TRUE" ? true : false;
                config.HotKeyCtrl = document.Root.Element("HotKeyCtrl").Value.ToUpper() == "TRUE" ? true : false;
                config.HotKeyShift = document.Root.Element("HotKeyShift").Value.ToUpper() == "TRUE" ? true : false;
                config.HotKeyWin = document.Root.Element("HotKeyWin").Value.ToUpper() == "TRUE" ? true : false;
                config.Console = document.Root.Element("Console").Value;
                config.ConsoleRemoveBorder = document.Root.Element("ConsoleRemoveBorder").Value.ToUpper() == "TRUE" ? true : false;
                config.ConsoleWidth = int.Parse(document.Root.Element("ConsoleWidth").Value);
                config.ConsoleHeight = int.Parse(document.Root.Element("ConsoleHeight").Value);
                config.ConsoleScreen = int.Parse(document.Root.Element("ConsoleScreen").Value);
                config.ConsoleHiddenX = int.Parse(document.Root.Element("ConsoleHiddenX").Value);
                config.ConsoleHiddenY = int.Parse(document.Root.Element("ConsoleHiddenY").Value);
                config.ConsoleVisibleX = int.Parse(document.Root.Element("ConsoleVisibleX").Value);
                config.ConsoleVisibleY = int.Parse(document.Root.Element("ConsoleVisibleY").Value);
                config.WorkingDirectory = document.Root.Element("WorkingDirectory").Value;
                config.Animate = document.Root.Element("Animate").Value.ToUpper() == "TRUE" ? true : false;
                config.AnimateSpeedX = int.Parse(document.Root.Element("AnimateSpeedX").Value);
                config.AnimateSpeedY = int.Parse(document.Root.Element("AnimateSpeedY").Value);
            }
            catch (Exception)
            {
                return null;
            }

            if (config.AnimateSpeedX <= 0)
                config.AnimateSpeedX = 1;

            if (config.AnimateSpeedY <= 0)
                config.AnimateSpeedY = 1;

            return config;
        }
コード例 #3
0
        /// <summary>
        /// Called when the "Reload Config" tray icon menu item is selected.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TrayIcon_ReloadConfig(object sender, EventArgs e)
        {
            Config config = Config.Load("Config.xml");

            if (config == null)
            {
                MessageBox.Show(this, "Failed to load Config.xml.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            this.config = config;
        }