GUI/PortForm.cs
author moel.mich
Mon, 02 Jul 2012 21:14:40 +0000
changeset 357 fb8dc26f65a4
child 358 7962499f9cd6
permissions -rw-r--r--
Added mainboard specific configurations for the following Gigabyte mainboards: EX58-UD3R, G41M-Combo, G41MT-S2, G41MT-S2P, GA-MA770T-UD3P, GA-MA785GM-US2H, GA-MA78LM-S2H, GA-MA790X-UD3P, H55-USB3, H55N-USB3, H61M-DS2 REV 1.2, H61M-USB3-B3 REV 2.0, H67A-USB3-B3, P55A-UD3, P67A-UD3-B3, P67A-UD3R-B3, Z68A-D3H-B3, Z68AP-D3, Z68X-UD3H-B3.
     1 /*
     2  
     3   This Source Code Form is subject to the terms of the Mozilla Public
     4   License, v. 2.0. If a copy of the MPL was not distributed with this
     5   file, You can obtain one at http://mozilla.org/MPL/2.0/.
     6  
     7 	Copyright (C) 2012 Prince Samuel <prince.samuel@gmail.com>
     8 
     9 */
    10 
    11 using System;
    12 using System.Collections.Generic;
    13 using System.ComponentModel;
    14 using System.Data;
    15 using System.Drawing;
    16 using System.Text;
    17 using System.Windows.Forms;
    18 using System.Net;
    19 using System.Net.Sockets;
    20 using System.Diagnostics;
    21 
    22 namespace OpenHardwareMonitor.GUI {
    23   public partial class PortForm : Form {
    24     private MainForm parent;
    25     private string localIP;
    26     public PortForm(MainForm m) {
    27       InitializeComponent();
    28       parent = m;
    29 
    30       localIP = getLocalIP();
    31     }
    32 
    33     private void portTextBox_TextChanged(object sender, EventArgs e) {
    34 
    35     }
    36 
    37     private string getLocalIP() {
    38       IPHostEntry host;
    39       string localIP = "?";
    40       host = Dns.GetHostEntry(Dns.GetHostName());
    41       foreach (IPAddress ip in host.AddressList) {
    42         if (ip.AddressFamily == AddressFamily.InterNetwork) {
    43           localIP = ip.ToString();
    44         }
    45       }
    46       return localIP;
    47     }
    48 
    49     private void portNumericUpDn_ValueChanged(object sender, EventArgs e) {
    50       string url = "http://" + localIP + ":" + portNumericUpDn.Value + "/";
    51       webServerLinkLabel.Text = url;
    52       webServerLinkLabel.Links.Remove(webServerLinkLabel.Links[0]);
    53       webServerLinkLabel.Links.Add(0, webServerLinkLabel.Text.Length, url);
    54     }
    55 
    56     private void portOKButton_Click(object sender, EventArgs e) {
    57       parent.Server.ListenerPort = (int)portNumericUpDn.Value;
    58       this.Close();
    59     }
    60 
    61     private void portCancelButton_Click(object sender, EventArgs e) {
    62       this.Close();
    63     }
    64 
    65     private void PortForm_Load(object sender, EventArgs e) {
    66       portNumericUpDn.Value = parent.Server.ListenerPort;
    67       portNumericUpDn_ValueChanged(null, null);
    68     }
    69 
    70     private void webServerLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
    71       try {
    72         Process.Start(new ProcessStartInfo(e.Link.LinkData.ToString()));
    73       } catch { }
    74     }
    75 
    76   }
    77 }