SharpDisplay: Migrating to new robust client scheme.
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;
16 using System.Windows.Forms;
18 using System.Net.Sockets;
19 using System.Diagnostics;
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();
29 localIP = getLocalIP();
32 private void portTextBox_TextChanged(object sender, EventArgs e) {
36 private string getLocalIP() {
39 host = Dns.GetHostEntry(Dns.GetHostName());
40 foreach (IPAddress ip in host.AddressList) {
41 if (ip.AddressFamily == AddressFamily.InterNetwork) {
42 localIP = ip.ToString();
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);
55 private void portOKButton_Click(object sender, EventArgs e) {
56 parent.Server.ListenerPort = (int)portNumericUpDn.Value;
60 private void portCancelButton_Click(object sender, EventArgs e) {
64 private void PortForm_Load(object sender, EventArgs e) {
65 portNumericUpDn.Value = parent.Server.ListenerPort;
66 portNumericUpDn_ValueChanged(null, null);
69 private void webServerLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
71 Process.Start(new ProcessStartInfo(e.Link.LinkData.ToString()));