コード例 #1
0
ファイル: Form1.cs プロジェクト: acezack/watch
        public Form1()
        {
            InitializeComponent();

            this.Location = Properties.Settings.Default.location;

            // Initializes the form for options.
            formOptions = new FormOptions();

            // Used to make the background transparent.
            TransparencyKey = Color.FromArgb(0, 0, 1);
            BackColor       = Color.FromArgb(0, 0, 1);

            // Hides the border.
            FormBorderStyle = FormBorderStyle.None;

            // Starts the timer.
            updateTimer.Interval = 200;
            updateTimer.Enabled  = true;
            updateTimer.Tick    += updateTimer_Tick;

            // Initializes the notificationmenu
            #region notificationmenu initialization
            // Initializes the notification-right-click-menu
            this.components         = new System.ComponentModel.Container();
            this.contextMenu1       = new System.Windows.Forms.ContextMenu();
            this.menuItemToggleShow = new System.Windows.Forms.MenuItem();
            this.menuItemExit       = new System.Windows.Forms.MenuItem();
            this.menuItemOptions    = new System.Windows.Forms.MenuItem();

            // Adds items to the menu.
            this.contextMenu1.MenuItems.AddRange(
                new System.Windows.Forms.MenuItem[]
            {
                this.menuItemToggleShow,
                this.menuItemExit,
                this.menuItemOptions
            });

            // Toggle border
            this.menuItemToggleShow.Index  = 0;
            this.menuItemToggleShow.Text   = "Show border";
            this.menuItemToggleShow.Click += menuItemToggleShow_Click;

            // Show options
            this.menuItemOptions.Index  = 1;
            this.menuItemOptions.Text   = "Show options";
            this.menuItemOptions.Click += menuItemOptions_Click;

            // Exit program
            this.menuItemExit.Index  = 2;
            this.menuItemExit.Text   = "Exit";
            this.menuItemExit.Click += menuItemExit_Click;
            #endregion

            // Sets the contextMenu.
            watchNotifyIcon.ContextMenu = this.contextMenu1;

            // Hooks the clicks and sends the to the window below.
            SetWindowLong(this.Handle, -20, (int)GetWindowLong(this.Handle, -20) | 0x00000020);

            if (!settingsChosen)
            {
                formOptions.Show();
                settingsChosen = true;
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: acezack/watch
 // Shows the options-form.
 void menuItemOptions_Click(object sender, EventArgs e)
 {
     formOptions = new FormOptions();
     formOptions.Show();
 }