GUI/PortForm.cs
author sl
Sun, 03 Feb 2013 18:01:50 +0100
changeset 391 ca4c0e7ae75d
parent 348 d8fa1e55acfa
permissions -rw-r--r--
Converted project to VisualStudio 2012.
Adding SoundGraphDisplay and SensorFrontView classes.
They were respectively based on SystemTray and SensorNotifyIcon.
SoundGraphDisplay is now able to load iMONDisplay.dll providing it lives on your PATH.
Adding option to sensor context menu for adding it into FrontView.
     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.Drawing;
    15 using System.Text;
    16 using System.Windows.Forms;
    17 using System.Net;
    18 using System.Net.Sockets;
    19 using System.Diagnostics;
    20 
    21 namespace OpenHardwareMonitor.GUI {
    22   public partial class PortForm : Form {
    23     private MainForm parent;
    24     private string localIP;
    25     public PortForm(MainForm m) {
    26       InitializeComponent();
    27       parent = m;
    28 
    29       localIP = getLocalIP();
    30     }
    31 
    32     private void portTextBox_TextChanged(object sender, EventArgs e) {
    33 
    34     }
    35 
    36     private string getLocalIP() {
    37       IPHostEntry host;
    38       string localIP = "?";
    39       host = Dns.GetHostEntry(Dns.GetHostName());
    40       foreach (IPAddress ip in host.AddressList) {
    41         if (ip.AddressFamily == AddressFamily.InterNetwork) {
    42           localIP = ip.ToString();
    43         }
    44       }
    45       return localIP;
    46     }
    47 
    48     private void portNumericUpDn_ValueChanged(object sender, EventArgs e) {
    49       string url = "http://" + localIP + ":" + portNumericUpDn.Value + "/";
    50       webServerLinkLabel.Text = url;
    51       webServerLinkLabel.Links.Remove(webServerLinkLabel.Links[0]);
    52       webServerLinkLabel.Links.Add(0, webServerLinkLabel.Text.Length, url);
    53     }
    54 
    55     private void portOKButton_Click(object sender, EventArgs e) {
    56       parent.Server.ListenerPort = (int)portNumericUpDn.Value;
    57       this.Close();
    58     }
    59 
    60     private void portCancelButton_Click(object sender, EventArgs e) {
    61       this.Close();
    62     }
    63 
    64     private void PortForm_Load(object sender, EventArgs e) {
    65       portNumericUpDn.Value = parent.Server.ListenerPort;
    66       portNumericUpDn_ValueChanged(null, null);
    67     }
    68 
    69     private void webServerLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
    70       try {
    71         Process.Start(new ProcessStartInfo(e.Link.LinkData.ToString()));
    72       } catch { }
    73     }
    74 
    75   }
    76 }