Adding support for power on/off.
authorsl
Sun, 31 Aug 2014 18:33:05 +0200
changeset 52b22b0127afa4
parent 51 ae2052cc89ef
child 53 f7ad2dce46a9
Adding support for power on/off.
Server/Display.cs
Server/MainForm.Designer.cs
Server/MainForm.cs
     1.1 --- a/Server/Display.cs	Sun Aug 31 17:44:18 2014 +0200
     1.2 +++ b/Server/Display.cs	Sun Aug 31 18:33:05 2014 +0200
     1.3 @@ -105,6 +105,21 @@
     1.4              MiniDisplayRequest(iDevice, TMiniDisplayRequest.EMiniDisplayRequestFirmwareRevision);
     1.5          }
     1.6  
     1.7 +        public void PowerOn()
     1.8 +        {
     1.9 +            MiniDisplayPowerOn(iDevice);
    1.10 +        }
    1.11 +
    1.12 +        public void PowerOff()
    1.13 +        {
    1.14 +            MiniDisplayPowerOff(iDevice);
    1.15 +        }
    1.16 +
    1.17 +        public bool SupportPowerOnOff()
    1.18 +        {
    1.19 +            return MiniDisplaySupportPowerOnOff(iDevice);
    1.20 +        }
    1.21 +
    1.22          public bool PowerSupplyStatus()
    1.23          {
    1.24              bool res = MiniDisplayPowerSupplyStatus(iDevice);
    1.25 @@ -249,6 +264,15 @@
    1.26          [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    1.27          public static extern void MiniDisplayCancelRequest(IntPtr aDevice);
    1.28  
    1.29 +        [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    1.30 +        public static extern void MiniDisplayPowerOn(IntPtr aDevice);
    1.31 +
    1.32 +        [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    1.33 +        public static extern void MiniDisplayPowerOff(IntPtr aDevice);
    1.34 +
    1.35 +        [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    1.36 +        [return: MarshalAs(UnmanagedType.I1)]
    1.37 +        public static extern bool MiniDisplaySupportPowerOnOff(IntPtr aDevice);
    1.38  
    1.39      }
    1.40  }
     2.1 --- a/Server/MainForm.Designer.cs	Sun Aug 31 17:44:18 2014 +0200
     2.2 +++ b/Server/MainForm.Designer.cs	Sun Aug 31 18:33:05 2014 +0200
     2.3 @@ -43,6 +43,9 @@
     2.4              this.buttonStartClient = new System.Windows.Forms.Button();
     2.5              this.treeViewClients = new System.Windows.Forms.TreeView();
     2.6              this.tabPageDisplay = new System.Windows.Forms.TabPage();
     2.7 +            this.buttonPowerOff = new System.Windows.Forms.Button();
     2.8 +            this.buttonPowerOn = new System.Windows.Forms.Button();
     2.9 +            this.label1 = new System.Windows.Forms.Label();
    2.10              this.maskedTextBoxTimerInterval = new System.Windows.Forms.MaskedTextBox();
    2.11              this.comboBoxDisplayType = new System.Windows.Forms.ComboBox();
    2.12              this.buttonSuspend = new System.Windows.Forms.Button();
    2.13 @@ -67,7 +70,6 @@
    2.14              this.checkBoxReverseScreen = new System.Windows.Forms.CheckBox();
    2.15              this.buttonRemoveRow = new System.Windows.Forms.Button();
    2.16              this.buttonAddRow = new System.Windows.Forms.Button();
    2.17 -            this.label1 = new System.Windows.Forms.Label();
    2.18              this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel();
    2.19              this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel();
    2.20              this.panelDisplay.SuspendLayout();
    2.21 @@ -163,6 +165,40 @@
    2.22              this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.23              this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.24              this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.25 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.26 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.27 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.28 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.29 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.30 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.31 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.32 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.33 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.34 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.35 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.36 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.37 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.38 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.39 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.40 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.41 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.42 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.43 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.44 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.45 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.46 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.47 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.48 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.49 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.50 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.51 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.52 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.53 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.54 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.55 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.56 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.57 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.58 +            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    2.59              this.tableLayoutPanel.Size = new System.Drawing.Size(256, 64);
    2.60              this.tableLayoutPanel.TabIndex = 5;
    2.61              // 
    2.62 @@ -256,6 +292,8 @@
    2.63              // 
    2.64              // tabPageDisplay
    2.65              // 
    2.66 +            this.tabPageDisplay.Controls.Add(this.buttonPowerOff);
    2.67 +            this.tabPageDisplay.Controls.Add(this.buttonPowerOn);
    2.68              this.tabPageDisplay.Controls.Add(this.label1);
    2.69              this.tabPageDisplay.Controls.Add(this.maskedTextBoxTimerInterval);
    2.70              this.tabPageDisplay.Controls.Add(this.comboBoxDisplayType);
    2.71 @@ -275,6 +313,35 @@
    2.72              this.tabPageDisplay.Text = "Display";
    2.73              this.tabPageDisplay.UseVisualStyleBackColor = true;
    2.74              // 
    2.75 +            // buttonPowerOff
    2.76 +            // 
    2.77 +            this.buttonPowerOff.Location = new System.Drawing.Point(293, 211);
    2.78 +            this.buttonPowerOff.Name = "buttonPowerOff";
    2.79 +            this.buttonPowerOff.Size = new System.Drawing.Size(75, 23);
    2.80 +            this.buttonPowerOff.TabIndex = 21;
    2.81 +            this.buttonPowerOff.Text = "OFF";
    2.82 +            this.buttonPowerOff.UseVisualStyleBackColor = true;
    2.83 +            this.buttonPowerOff.Click += new System.EventHandler(this.buttonPowerOff_Click);
    2.84 +            // 
    2.85 +            // buttonPowerOn
    2.86 +            // 
    2.87 +            this.buttonPowerOn.Location = new System.Drawing.Point(293, 182);
    2.88 +            this.buttonPowerOn.Name = "buttonPowerOn";
    2.89 +            this.buttonPowerOn.Size = new System.Drawing.Size(75, 23);
    2.90 +            this.buttonPowerOn.TabIndex = 20;
    2.91 +            this.buttonPowerOn.Text = "ON";
    2.92 +            this.buttonPowerOn.UseVisualStyleBackColor = true;
    2.93 +            this.buttonPowerOn.Click += new System.EventHandler(this.buttonPowerOn_Click);
    2.94 +            // 
    2.95 +            // label1
    2.96 +            // 
    2.97 +            this.label1.AutoSize = true;
    2.98 +            this.label1.Location = new System.Drawing.Point(184, 45);
    2.99 +            this.label1.Name = "label1";
   2.100 +            this.label1.Size = new System.Drawing.Size(98, 13);
   2.101 +            this.label1.TabIndex = 19;
   2.102 +            this.label1.Text = "Timer interval (ms) :";
   2.103 +            // 
   2.104              // maskedTextBoxTimerInterval
   2.105              // 
   2.106              this.maskedTextBoxTimerInterval.Location = new System.Drawing.Point(288, 42);
   2.107 @@ -306,7 +373,7 @@
   2.108              this.buttonSuspend.Name = "buttonSuspend";
   2.109              this.buttonSuspend.Size = new System.Drawing.Size(75, 23);
   2.110              this.buttonSuspend.TabIndex = 16;
   2.111 -            this.buttonSuspend.Text = "Suspend";
   2.112 +            this.buttonSuspend.Text = "Pause";
   2.113              this.buttonSuspend.UseVisualStyleBackColor = true;
   2.114              this.buttonSuspend.Click += new System.EventHandler(this.buttonSuspend_Click);
   2.115              // 
   2.116 @@ -550,21 +617,12 @@
   2.117              this.buttonAddRow.UseVisualStyleBackColor = true;
   2.118              this.buttonAddRow.Click += new System.EventHandler(this.buttonAddRow_Click);
   2.119              // 
   2.120 -            // label1
   2.121 -            // 
   2.122 -            this.label1.AutoSize = true;
   2.123 -            this.label1.Location = new System.Drawing.Point(184, 45);
   2.124 -            this.label1.Name = "label1";
   2.125 -            this.label1.Size = new System.Drawing.Size(98, 13);
   2.126 -            this.label1.TabIndex = 19;
   2.127 -            this.label1.Text = "Timer interval (ms) :";
   2.128 -            // 
   2.129              // marqueeLabelTop
   2.130              // 
   2.131              this.marqueeLabelTop.AutoEllipsis = true;
   2.132              this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent;
   2.133              this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill;
   2.134 -            this.marqueeLabelTop.Location = new System.Drawing.Point(1, -9);
   2.135 +            this.marqueeLabelTop.Location = new System.Drawing.Point(1, 1);
   2.136              this.marqueeLabelTop.Margin = new System.Windows.Forms.Padding(0);
   2.137              this.marqueeLabelTop.Name = "marqueeLabelTop";
   2.138              this.marqueeLabelTop.OwnTimer = false;
   2.139 @@ -580,7 +638,7 @@
   2.140              // 
   2.141              this.marqueeLabelBottom.AutoEllipsis = true;
   2.142              this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill;
   2.143 -            this.marqueeLabelBottom.Location = new System.Drawing.Point(1, 2);
   2.144 +            this.marqueeLabelBottom.Location = new System.Drawing.Point(1, -19);
   2.145              this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0);
   2.146              this.marqueeLabelBottom.Name = "marqueeLabelBottom";
   2.147              this.marqueeLabelBottom.OwnTimer = false;
   2.148 @@ -666,6 +724,8 @@
   2.149          private System.Windows.Forms.ComboBox comboBoxDisplayType;
   2.150          private System.Windows.Forms.MaskedTextBox maskedTextBoxTimerInterval;
   2.151          private System.Windows.Forms.Label label1;
   2.152 +        private System.Windows.Forms.Button buttonPowerOff;
   2.153 +        private System.Windows.Forms.Button buttonPowerOn;
   2.154      }
   2.155  }
   2.156  
     3.1 --- a/Server/MainForm.cs	Sun Aug 31 17:44:18 2014 +0200
     3.2 +++ b/Server/MainForm.cs	Sun Aug 31 18:33:05 2014 +0200
     3.3 @@ -373,6 +373,17 @@
     3.4                  trackBarBrightness.Enabled = true;
     3.5                  toolStripStatusLabelConnect.Text = "Connected - " + iDisplay.Vendor() + " - " + iDisplay.Product();
     3.6                  //+ " - " + iDisplay.SerialNumber();
     3.7 +
     3.8 +                if (iDisplay.SupportPowerOnOff())
     3.9 +                {
    3.10 +                    buttonPowerOn.Enabled = true;
    3.11 +                    buttonPowerOff.Enabled = true;
    3.12 +                }
    3.13 +                else
    3.14 +                {
    3.15 +                    buttonPowerOn.Enabled = false;
    3.16 +                    buttonPowerOff.Enabled = false;
    3.17 +                }
    3.18              }
    3.19              else
    3.20              {
    3.21 @@ -381,6 +392,8 @@
    3.22                  buttonOpen.Enabled = true;
    3.23                  buttonClose.Enabled = false;
    3.24                  trackBarBrightness.Enabled = false;
    3.25 +                buttonPowerOn.Enabled = false;
    3.26 +                buttonPowerOff.Enabled = false;
    3.27                  toolStripStatusLabelConnect.Text = "Disconnected";
    3.28                  toolStripStatusLabelPower.Text = "N/A";
    3.29              }
    3.30 @@ -500,10 +513,11 @@
    3.31  
    3.32          private void buttonSuspend_Click(object sender, EventArgs e)
    3.33          {
    3.34 +            LastTickTime = DateTime.Now; //Reset timer to prevent jump
    3.35              timer.Enabled = !timer.Enabled;
    3.36              if (!timer.Enabled)
    3.37              {
    3.38 -                buttonSuspend.Text = "Suspend";
    3.39 +                buttonSuspend.Text = "Run";
    3.40              }
    3.41              else
    3.42              {
    3.43 @@ -859,6 +873,16 @@
    3.44              }
    3.45          }
    3.46  
    3.47 +        private void buttonPowerOn_Click(object sender, EventArgs e)
    3.48 +        {
    3.49 +            iDisplay.PowerOn();
    3.50 +        }
    3.51 +
    3.52 +        private void buttonPowerOff_Click(object sender, EventArgs e)
    3.53 +        {
    3.54 +            iDisplay.PowerOff();
    3.55 +        }
    3.56 +
    3.57      }
    3.58  
    3.59      /// <summary>