Fixed Issue 300.
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/.
7 Copyright (C) 2012 Prince Samuel <prince.samuel@gmail.com>
12 using System.Collections.Generic;
13 using System.ComponentModel;
17 using System.Windows.Forms;
19 using System.Net.Sockets;
20 using System.Diagnostics;
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();
30 localIP = getLocalIP();
33 private void portTextBox_TextChanged(object sender, EventArgs e) {
37 private string getLocalIP() {
40 host = Dns.GetHostEntry(Dns.GetHostName());
41 foreach (IPAddress ip in host.AddressList) {
42 if (ip.AddressFamily == AddressFamily.InterNetwork) {
43 localIP = ip.ToString();
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);
56 private void portOKButton_Click(object sender, EventArgs e) {
57 parent.Server.ListenerPort = (int)portNumericUpDn.Value;
61 private void portCancelButton_Click(object sender, EventArgs e) {
65 private void PortForm_Load(object sender, EventArgs e) {
66 portNumericUpDn.Value = parent.Server.ListenerPort;
67 portNumericUpDn_ValueChanged(null, null);
70 private void webServerLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
72 Process.Start(new ProcessStartInfo(e.Link.LinkData.ToString()));