MainForm.cs
author sl
Mon, 07 Jul 2014 21:32:02 +0200
changeset 3 71b55cfd8c05
parent 2 f516c3f656bf
child 4 0825370a7947
permissions -rw-r--r--
Adding basic display functions: open, close, clear, fill, brightness control.
     1 using System;
     2 using System.Collections.Generic;
     3 using System.ComponentModel;
     4 using System.Data;
     5 using System.Drawing;
     6 using System.Linq;
     7 using System.Text;
     8 using System.Threading.Tasks;
     9 using System.Windows.Forms;
    10 using CodeProject.Dialog;
    11 
    12 namespace SharpDisplayManager
    13 {
    14     public partial class MainForm : Form
    15     {
    16         DateTime LastTickTime;
    17         Display iDisplay;
    18 
    19         public MainForm()
    20         {
    21             LastTickTime = DateTime.Now;
    22             iDisplay = new Display();
    23 
    24             InitializeComponent();
    25         }
    26 
    27         private void buttonFont_Click(object sender, EventArgs e)
    28         {
    29             //fontDialog.ShowColor = true;
    30             //fontDialog.ShowApply = true;
    31             fontDialog.ShowEffects = true;
    32             //fontDialog.ShowHelp = true;
    33 
    34             //fontDlg.MaxSize = 40;
    35             //fontDlg.MinSize = 22;
    36 
    37             //fontDialog.Parent = this;
    38             //fontDialog.StartPosition = FormStartPosition.CenterParent;
    39 
    40             //DlgBox.ShowDialog(fontDialog);
    41 
    42             //if (fontDialog.ShowDialog(this) != DialogResult.Cancel)
    43             if (DlgBox.ShowDialog(fontDialog) != DialogResult.Cancel)
    44             {
    45 
    46                 MsgBox.Show("MessageBox MsgBox", "MsgBox caption");
    47 
    48                 //MessageBox.Show("Ok");
    49                 //textBox1.Font = fontDlg.Font;
    50                 //label1.Font = fontDlg.Font;
    51                 //textBox1.BackColor = fontDlg.Color;
    52                 //label1.ForeColor = fontDlg.Color;
    53             }
    54         }
    55 
    56         private void buttonCapture_Click(object sender, EventArgs e)
    57         {
    58             System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height);
    59             tableLayoutPanel.DrawToBitmap(bmp, tableLayoutPanel.ClientRectangle);
    60             bmp.Save("c:\\capture.png");
    61         }
    62 
    63         private void timer_Tick(object sender, EventArgs e)
    64         {
    65             //Update our animations
    66             DateTime NewTickTime = DateTime.Now;
    67 
    68             marqueeLabelTop.UpdateAnimation(LastTickTime, NewTickTime);
    69             marqueeLabelBottom.UpdateAnimation(LastTickTime, NewTickTime);
    70 
    71             LastTickTime = NewTickTime;
    72         }
    73 
    74         private void buttonOpen_Click(object sender, EventArgs e)
    75         {
    76             if (iDisplay.Open())
    77             {
    78                 trackBarBrightness.Minimum = iDisplay.MinBrightness();
    79                 trackBarBrightness.Maximum = iDisplay.MaxBrightness();                
    80             }
    81             
    82         }
    83 
    84         private void buttonClose_Click(object sender, EventArgs e)
    85         {
    86             iDisplay.Close();
    87         }
    88 
    89         private void buttonClear_Click(object sender, EventArgs e)
    90         {
    91             iDisplay.Clear();
    92             iDisplay.SwapBuffers();
    93         }
    94 
    95         private void buttonFill_Click(object sender, EventArgs e)
    96         {
    97             iDisplay.Fill();
    98             iDisplay.SwapBuffers();
    99         }
   100 
   101         private void trackBarBrightness_Scroll(object sender, EventArgs e)
   102         {
   103             iDisplay.SetBrightness(trackBarBrightness.Value);
   104         }
   105     }
   106 }