# HG changeset patch # User sl # Date 1409502785 -7200 # Node ID b22b0127afa4e965280b648b13a5569183a28ba4 # Parent ae2052cc89ef1d6c92eecd403fcb084dcf32e6de Adding support for power on/off. diff -r ae2052cc89ef -r b22b0127afa4 Server/Display.cs --- a/Server/Display.cs Sun Aug 31 17:44:18 2014 +0200 +++ b/Server/Display.cs Sun Aug 31 18:33:05 2014 +0200 @@ -105,6 +105,21 @@ MiniDisplayRequest(iDevice, TMiniDisplayRequest.EMiniDisplayRequestFirmwareRevision); } + public void PowerOn() + { + MiniDisplayPowerOn(iDevice); + } + + public void PowerOff() + { + MiniDisplayPowerOff(iDevice); + } + + public bool SupportPowerOnOff() + { + return MiniDisplaySupportPowerOnOff(iDevice); + } + public bool PowerSupplyStatus() { bool res = MiniDisplayPowerSupplyStatus(iDevice); @@ -249,6 +264,15 @@ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] public static extern void MiniDisplayCancelRequest(IntPtr aDevice); + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] + public static extern void MiniDisplayPowerOn(IntPtr aDevice); + + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] + public static extern void MiniDisplayPowerOff(IntPtr aDevice); + + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + public static extern bool MiniDisplaySupportPowerOnOff(IntPtr aDevice); } } diff -r ae2052cc89ef -r b22b0127afa4 Server/MainForm.Designer.cs --- a/Server/MainForm.Designer.cs Sun Aug 31 17:44:18 2014 +0200 +++ b/Server/MainForm.Designer.cs Sun Aug 31 18:33:05 2014 +0200 @@ -43,6 +43,9 @@ this.buttonStartClient = new System.Windows.Forms.Button(); this.treeViewClients = new System.Windows.Forms.TreeView(); this.tabPageDisplay = new System.Windows.Forms.TabPage(); + this.buttonPowerOff = new System.Windows.Forms.Button(); + this.buttonPowerOn = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); this.maskedTextBoxTimerInterval = new System.Windows.Forms.MaskedTextBox(); this.comboBoxDisplayType = new System.Windows.Forms.ComboBox(); this.buttonSuspend = new System.Windows.Forms.Button(); @@ -67,7 +70,6 @@ this.checkBoxReverseScreen = new System.Windows.Forms.CheckBox(); this.buttonRemoveRow = new System.Windows.Forms.Button(); this.buttonAddRow = new System.Windows.Forms.Button(); - this.label1 = new System.Windows.Forms.Label(); this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel(); this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel(); this.panelDisplay.SuspendLayout(); @@ -163,6 +165,40 @@ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); this.tableLayoutPanel.Size = new System.Drawing.Size(256, 64); this.tableLayoutPanel.TabIndex = 5; // @@ -256,6 +292,8 @@ // // tabPageDisplay // + this.tabPageDisplay.Controls.Add(this.buttonPowerOff); + this.tabPageDisplay.Controls.Add(this.buttonPowerOn); this.tabPageDisplay.Controls.Add(this.label1); this.tabPageDisplay.Controls.Add(this.maskedTextBoxTimerInterval); this.tabPageDisplay.Controls.Add(this.comboBoxDisplayType); @@ -275,6 +313,35 @@ this.tabPageDisplay.Text = "Display"; this.tabPageDisplay.UseVisualStyleBackColor = true; // + // buttonPowerOff + // + this.buttonPowerOff.Location = new System.Drawing.Point(293, 211); + this.buttonPowerOff.Name = "buttonPowerOff"; + this.buttonPowerOff.Size = new System.Drawing.Size(75, 23); + this.buttonPowerOff.TabIndex = 21; + this.buttonPowerOff.Text = "OFF"; + this.buttonPowerOff.UseVisualStyleBackColor = true; + this.buttonPowerOff.Click += new System.EventHandler(this.buttonPowerOff_Click); + // + // buttonPowerOn + // + this.buttonPowerOn.Location = new System.Drawing.Point(293, 182); + this.buttonPowerOn.Name = "buttonPowerOn"; + this.buttonPowerOn.Size = new System.Drawing.Size(75, 23); + this.buttonPowerOn.TabIndex = 20; + this.buttonPowerOn.Text = "ON"; + this.buttonPowerOn.UseVisualStyleBackColor = true; + this.buttonPowerOn.Click += new System.EventHandler(this.buttonPowerOn_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(184, 45); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(98, 13); + this.label1.TabIndex = 19; + this.label1.Text = "Timer interval (ms) :"; + // // maskedTextBoxTimerInterval // this.maskedTextBoxTimerInterval.Location = new System.Drawing.Point(288, 42); @@ -306,7 +373,7 @@ this.buttonSuspend.Name = "buttonSuspend"; this.buttonSuspend.Size = new System.Drawing.Size(75, 23); this.buttonSuspend.TabIndex = 16; - this.buttonSuspend.Text = "Suspend"; + this.buttonSuspend.Text = "Pause"; this.buttonSuspend.UseVisualStyleBackColor = true; this.buttonSuspend.Click += new System.EventHandler(this.buttonSuspend_Click); // @@ -550,21 +617,12 @@ this.buttonAddRow.UseVisualStyleBackColor = true; this.buttonAddRow.Click += new System.EventHandler(this.buttonAddRow_Click); // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(184, 45); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(98, 13); - this.label1.TabIndex = 19; - this.label1.Text = "Timer interval (ms) :"; - // // marqueeLabelTop // this.marqueeLabelTop.AutoEllipsis = true; this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent; this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill; - this.marqueeLabelTop.Location = new System.Drawing.Point(1, -9); + this.marqueeLabelTop.Location = new System.Drawing.Point(1, 1); this.marqueeLabelTop.Margin = new System.Windows.Forms.Padding(0); this.marqueeLabelTop.Name = "marqueeLabelTop"; this.marqueeLabelTop.OwnTimer = false; @@ -580,7 +638,7 @@ // this.marqueeLabelBottom.AutoEllipsis = true; this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill; - this.marqueeLabelBottom.Location = new System.Drawing.Point(1, 2); + this.marqueeLabelBottom.Location = new System.Drawing.Point(1, -19); this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0); this.marqueeLabelBottom.Name = "marqueeLabelBottom"; this.marqueeLabelBottom.OwnTimer = false; @@ -666,6 +724,8 @@ private System.Windows.Forms.ComboBox comboBoxDisplayType; private System.Windows.Forms.MaskedTextBox maskedTextBoxTimerInterval; private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button buttonPowerOff; + private System.Windows.Forms.Button buttonPowerOn; } } diff -r ae2052cc89ef -r b22b0127afa4 Server/MainForm.cs --- a/Server/MainForm.cs Sun Aug 31 17:44:18 2014 +0200 +++ b/Server/MainForm.cs Sun Aug 31 18:33:05 2014 +0200 @@ -373,6 +373,17 @@ trackBarBrightness.Enabled = true; toolStripStatusLabelConnect.Text = "Connected - " + iDisplay.Vendor() + " - " + iDisplay.Product(); //+ " - " + iDisplay.SerialNumber(); + + if (iDisplay.SupportPowerOnOff()) + { + buttonPowerOn.Enabled = true; + buttonPowerOff.Enabled = true; + } + else + { + buttonPowerOn.Enabled = false; + buttonPowerOff.Enabled = false; + } } else { @@ -381,6 +392,8 @@ buttonOpen.Enabled = true; buttonClose.Enabled = false; trackBarBrightness.Enabled = false; + buttonPowerOn.Enabled = false; + buttonPowerOff.Enabled = false; toolStripStatusLabelConnect.Text = "Disconnected"; toolStripStatusLabelPower.Text = "N/A"; } @@ -500,10 +513,11 @@ private void buttonSuspend_Click(object sender, EventArgs e) { + LastTickTime = DateTime.Now; //Reset timer to prevent jump timer.Enabled = !timer.Enabled; if (!timer.Enabled) { - buttonSuspend.Text = "Suspend"; + buttonSuspend.Text = "Run"; } else { @@ -859,6 +873,16 @@ } } + private void buttonPowerOn_Click(object sender, EventArgs e) + { + iDisplay.PowerOn(); + } + + private void buttonPowerOff_Click(object sender, EventArgs e) + { + iDisplay.PowerOff(); + } + } ///