private void SimpleStyleRenderer_Paint(object sender, PaintEventArgs e)
		{
			VisualStyleElement element = VisualStyleElement.Button.CheckBox.CheckedNormal;
			
			if (Application.RenderWithVisualStyles &&
				VisualStyleRenderer.IsElementDefined(element))
			{
				VisualStyleRenderer renderer = new VisualStyleRenderer(element);
				Rectangle rectCheck = new Rectangle(10, 10, 50, 50);
				Rectangle rectBox = new Rectangle(10, 10, 200, 50);
				Rectangle rectText = new Rectangle(50, 25, 150, 25);
				renderer.DrawBackground(e.Graphics, rectCheck);
				renderer.DrawEdge(e.Graphics, rectBox, 
					Edges.Bottom | Edges.Top | Edges.Left | Edges.Right,
					EdgeStyle.Etched, EdgeEffects.Flat);
				renderer.DrawText(e.Graphics, rectText, "Styled checkbox", false, TextFormatFlags.Top);
			}
			else
			{
				// (Perform ControlPaint drawing here.)
			}

		}
		public static void DrawHorizontalTicks(Graphics g, Rectangle bounds, int numTicks, EdgeStyle edgeStyle)
		{
			if (!IsSupported)
				throw new InvalidOperationException ();

			if (bounds.Height <= 0 || bounds.Width <= 0 || numTicks <= 0)
				return;
				
			VisualStyleRenderer vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Ticks.Normal);
			
			double x = bounds.Left;
			double delta = (double)(bounds.Width - 2) / (double)(numTicks-1);
			
			for(int i = 0; i < numTicks; i++)
			{
				vsr.DrawEdge(g, new Rectangle((int)Math.Round(x), bounds.Top, 5, bounds.Height), Edges.Left, edgeStyle, EdgeEffects.None);
				x += delta;
			}
		}
Beispiel #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Form Settings

            this.Icon = Properties.Resources.WhyNs_Stream_Watcher_Icon_32x32;

            // Top Bar Settings

            VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.TextBox.TextEdit.Normal);
            panelTopbarMainForm.Paint += new PaintEventHandler(delegate (Object o, PaintEventArgs a) {

                renderer.DrawEdge(a.Graphics, panelTopbarMainForm.ClientRectangle,
                    Edges.Bottom, EdgeStyle.Raised, EdgeEffects.Flat);

            });

            panelTopbarMainForm.MouseDown   += new MouseEventHandler(delegate(Object o, MouseEventArgs a) { this.OnMouseDown(a); });
            panelTopbarMainForm.MouseUp     += new MouseEventHandler(delegate(Object o, MouseEventArgs a) { this.OnMouseUp(a); });
            panelTopbarMainForm.MouseMove   += new MouseEventHandler(delegate(Object o, MouseEventArgs a) { this.OnMouseMove (a); });

            tsmiMain.Text += " " + ApplicationInfo.Version;

            // Tray Icon ContextMenuStrip Settings

            ContextMenuStrip cmsTrayIcon = new ContextMenuStrip();

            cmsTrayIcon.Name = "cmsTrayIcon";

            cmsTrayIcon.Items.Add("Restore", null, new EventHandler(restoreForm));
            cmsTrayIcon.Items.Add("Exit", null, new EventHandler(delegate (Object o, EventArgs a) {

                appExit();

            }));

            // Tray Icon Settings

            notifyIconMain.Icon = Properties.Resources.WhyNs_Stream_Watcher_Icon_16x16;
            notifyIconMain.ContextMenuStrip = cmsTrayIcon;
            notifyIconMain.Text = this.Text;
            notifyIconMain.MouseDoubleClick += new MouseEventHandler(restoreForm);

            // View Settings
            tsmiShowOfflineStreams.Checked = Properties.Settings.Default.ShowOfflineStreams;

            // Creating Pages

            pageStreams = new Streams(ui);
            pageSettings = new Settings(ui);
            pageAbout = new About(ui);

            // Adding Pages to Form (Should be hidden)

            this.Controls.Add(pageStreams.GetPageControl());
            this.Controls.Add(pageSettings.GetPageControl());
            this.Controls.Add(pageAbout.GetPageControl());

            // Setting Main Default Page

            ui.SetMainPage(pageStreams);

            // Load Default Page
            ui.ShowPage(this.pageStreams);

            // Hide Application to tray at launch if settings is true
            if (Properties.Settings.Default.TrayOnLaunch)
            {

                formToTray();

            }
        }