All pastes #452598 Raw Edit

Something

public text v1 · immutable
·published 2007-04-22 11:47 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using InfraRED.Common;

namespace InfraRED.OSD
{

    public partial class DefaultOSD : Form, IOSD
    {
        private OSDControl[] OSDControls;
        private int timeout;
        public DefaultOSD()
        {
            InitializeComponent();
        }

        #region IOSD Members

        Graphics IOSD.Graphics
        {
            get { return this.CreateGraphics(); }
        }

        void IOSD.Show(int timeout, params OSDControl[] controls)
        {
            OSDControls = controls;
            this.timeout = timeout;
            Show();
            Invalidate();
        }

        #endregion

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.Hide();
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            e.Graphics.Clear(this.TransparencyKey);
            if (OSDControls != null)
            {
                int hmargin = 25;
                foreach (OSDControl ctrl in OSDControls) hmargin += ctrl.Width;
                int xpos = this.Width - hmargin;
                foreach (OSDControl ctrl in OSDControls)
                {
                    ctrl.Draw(e.Graphics, xpos, this.ClientSize.Height);
                    xpos += ctrl.Width + 5;
                }
            }

        }

        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);
            Screen s = Screen.FromRectangle(this.Bounds);
            this.Location = new Point(0, s.WorkingArea.Height - this.Height);
            this.Width = s.WorkingArea.Width;

            this.timer1.Stop();
            this.timer1.Interval = timeout;
            this.timer1.Start();

            this.Invalidate();

        }


    }
}



************** DESIGNER CODE **********************




namespace InfraRED.OSD
{
    partial class DefaultOSD
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.timer1 = new System.Windows.Forms.Timer(this.components);
            this.SuspendLayout();
            // 
            // timer1
            // 
            this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
            // 
            // DefaultOSD
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(502, 50);
            this.ControlBox = false;
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "DefaultOSD";
            this.ShowIcon = false;
            this.Text = "DefaultOSD";
            this.TopMost = true;
            this.TransparencyKey = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.Timer timer1;
    }
}