All pastes #452571 Raw Edit

Untitled

public text v1 · immutable
·published 2007-04-22 11:22 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, OSDControl[] controls)
        {
            OSDControls = controls;
            this.timeout = timeout;
            Show();
            Invalidate();
        }

        #endregion

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

        private void DefaultOSD_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.Clear(this.TransparencyKey);
            if (OSDControls != null)
            {
                int w = 25;
                foreach (OSDControl c in OSDControls) w += c.Width;
                int x = this.Width - w;
                foreach (OSDControl c in OSDControls)
                {
                    c.Draw(e.Graphics, x, this.ClientSize.Height);
                    x += c.Width + 5;
                }
            }
        }

        private void DefaultOSD_Load(object sender, EventArgs e)
        {
        }

        private void DefaultOSD_Shown(object sender, EventArgs 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.Paint += new System.Windows.Forms.PaintEventHandler(this.DefaultOSD_Paint);
            this.Shown += new System.EventHandler(this.DefaultOSD_Shown);
            this.Load += new System.EventHandler(this.DefaultOSD_Load);            
            this.ResumeLayout(false);

        }

        #endregion

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