mirror of https://github.com/quasar/Quasar.git
Added option to enable/disable Client Tooltips
This commit is contained in:
parent
dbc346d1ec
commit
64a9156d41
|
@ -17,10 +17,10 @@ public GeoIP()
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HttpWebRequest request = (HttpWebRequest) WebRequest.Create("https://freegeoip.net/xml/");
|
HttpWebRequest request = (HttpWebRequest) WebRequest.Create("https://freegeoip.net/xml/");
|
||||||
|
request.UserAgent = "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0";
|
||||||
request.Proxy = null;
|
request.Proxy = null;
|
||||||
request.Timeout = 5000;
|
request.Timeout = 5000;
|
||||||
|
|
||||||
// Be sure that response, dataStream, and reader will be disposed of, even if an error is thrown.
|
|
||||||
using (HttpWebResponse response = (HttpWebResponse) request.GetResponse())
|
using (HttpWebResponse response = (HttpWebResponse) request.GetResponse())
|
||||||
{
|
{
|
||||||
using (Stream dataStream = response.GetResponseStream())
|
using (Stream dataStream = response.GetResponseStream())
|
||||||
|
@ -28,9 +28,6 @@ public GeoIP()
|
||||||
using (StreamReader reader = new StreamReader(dataStream))
|
using (StreamReader reader = new StreamReader(dataStream))
|
||||||
{
|
{
|
||||||
string responseString = reader.ReadToEnd();
|
string responseString = reader.ReadToEnd();
|
||||||
reader.Close();
|
|
||||||
dataStream.Close();
|
|
||||||
response.Close();
|
|
||||||
|
|
||||||
XmlDocument doc = new XmlDocument();
|
XmlDocument doc = new XmlDocument();
|
||||||
doc.LoadXml(responseString);
|
doc.LoadXml(responseString);
|
||||||
|
|
|
@ -58,7 +58,7 @@ public static void HandleInitialize(Client client, Initialize packet)
|
||||||
ShowPopup(client);
|
ShowPopup(client);
|
||||||
|
|
||||||
client.Value.IsAuthenticated = true;
|
client.Value.IsAuthenticated = true;
|
||||||
new Core.Packets.ServerPackets.GetSystemInfo().Execute(client);
|
new Packets.ServerPackets.GetSystemInfo().Execute(client);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -413,41 +413,43 @@ public static void HandleDownloadFileResponse(Client client, DownloadFileRespons
|
||||||
|
|
||||||
public static void HandleGetSystemInfoResponse(Client client, GetSystemInfoResponse packet)
|
public static void HandleGetSystemInfoResponse(Client client, GetSystemInfoResponse packet)
|
||||||
{
|
{
|
||||||
try
|
if (XMLSettings.ShowToolTip)
|
||||||
{
|
{
|
||||||
FrmMain.Instance.lstClients.Invoke((MethodInvoker)delegate
|
try
|
||||||
{
|
{
|
||||||
foreach (ListViewItem item in FrmMain.Instance.lstClients.Items)
|
FrmMain.Instance.lstClients.Invoke((MethodInvoker)delegate
|
||||||
{
|
{
|
||||||
if (item.Tag == client)
|
foreach (ListViewItem item in FrmMain.Instance.lstClients.Items)
|
||||||
{
|
{
|
||||||
var builder = new StringBuilder();
|
if (item.Tag == client)
|
||||||
for (int i = 0; i < packet.SystemInfos.Length; i += 2)
|
|
||||||
{
|
{
|
||||||
if (packet.SystemInfos[i] != null && packet.SystemInfos[i + 1] != null)
|
var builder = new StringBuilder();
|
||||||
|
for (int i = 0; i < packet.SystemInfos.Length; i += 2)
|
||||||
{
|
{
|
||||||
builder.AppendFormat("{0}: {1}\r\n", packet.SystemInfos[i], packet.SystemInfos[i + 1]);
|
if (packet.SystemInfos[i] != null && packet.SystemInfos[i + 1] != null)
|
||||||
|
{
|
||||||
|
builder.AppendFormat("{0}: {1}\r\n", packet.SystemInfos[i], packet.SystemInfos[i + 1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
item.ToolTipText = builder.ToString();
|
||||||
}
|
}
|
||||||
item.ToolTipText = builder.ToString();
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
if (client.Value.FrmSi == null)
|
if (client.Value.FrmSi == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ListViewItem[] lviCollection = new ListViewItem[packet.SystemInfos.Length/2];
|
ListViewItem[] lviCollection = new ListViewItem[packet.SystemInfos.Length/2];
|
||||||
int j = 0;
|
for (int i = 0, j = 0; i < packet.SystemInfos.Length; i += 2, j++)
|
||||||
for (int i = 0; i < packet.SystemInfos.Length; i += 2)
|
|
||||||
{
|
{
|
||||||
if (packet.SystemInfos[i] != null && packet.SystemInfos[i + 1] != null)
|
if (packet.SystemInfos[i] != null && packet.SystemInfos[i + 1] != null)
|
||||||
{
|
{
|
||||||
lviCollection[j] = new ListViewItem(new string[] {packet.SystemInfos[i], packet.SystemInfos[i + 1]});
|
lviCollection[j] = new ListViewItem(new string[] {packet.SystemInfos[i], packet.SystemInfos[i + 1]});
|
||||||
j++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ private void ReadSettings(bool writeIfNotExist = true)
|
||||||
XMLSettings.AutoListen = bool.Parse(XMLSettings.ReadValue("AutoListen"));
|
XMLSettings.AutoListen = bool.Parse(XMLSettings.ReadValue("AutoListen"));
|
||||||
XMLSettings.ShowPopup = bool.Parse(XMLSettings.ReadValue("ShowPopup"));
|
XMLSettings.ShowPopup = bool.Parse(XMLSettings.ReadValue("ShowPopup"));
|
||||||
XMLSettings.UseUPnP = bool.Parse(XMLSettings.ReadValue("UseUPnP"));
|
XMLSettings.UseUPnP = bool.Parse(XMLSettings.ReadValue("UseUPnP"));
|
||||||
|
XMLSettings.ShowToolTip = bool.Parse(!string.IsNullOrEmpty(XMLSettings.ReadValue("ShowToolTip")) ? XMLSettings.ReadValue("ShowToolTip") : "False"); //fallback
|
||||||
XMLSettings.Password = XMLSettings.ReadValue("Password");
|
XMLSettings.Password = XMLSettings.ReadValue("Password");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +49,8 @@ public FrmMain()
|
||||||
Instance = this;
|
Instance = this;
|
||||||
|
|
||||||
ReadSettings();
|
ReadSettings();
|
||||||
#if(!DEBUG)
|
|
||||||
|
#if !DEBUG
|
||||||
ShowTermsOfService(XMLSettings.ShowToU);
|
ShowTermsOfService(XMLSettings.ShowToU);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ private void InitializeComponent()
|
||||||
this.lblPassword = new System.Windows.Forms.Label();
|
this.lblPassword = new System.Windows.Forms.Label();
|
||||||
this.txtPassword = new System.Windows.Forms.TextBox();
|
this.txtPassword = new System.Windows.Forms.TextBox();
|
||||||
this.chkUseUpnp = new System.Windows.Forms.CheckBox();
|
this.chkUseUpnp = new System.Windows.Forms.CheckBox();
|
||||||
|
this.chkShowTooltip = new System.Windows.Forms.CheckBox();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.ncPort)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.ncPort)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
|
@ -47,7 +48,7 @@ private void InitializeComponent()
|
||||||
this.btnSave.Location = new System.Drawing.Point(227, 210);
|
this.btnSave.Location = new System.Drawing.Point(227, 210);
|
||||||
this.btnSave.Name = "btnSave";
|
this.btnSave.Name = "btnSave";
|
||||||
this.btnSave.Size = new System.Drawing.Size(75, 23);
|
this.btnSave.Size = new System.Drawing.Size(75, 23);
|
||||||
this.btnSave.TabIndex = 9;
|
this.btnSave.TabIndex = 10;
|
||||||
this.btnSave.Text = "&Save";
|
this.btnSave.Text = "&Save";
|
||||||
this.btnSave.UseVisualStyleBackColor = true;
|
this.btnSave.UseVisualStyleBackColor = true;
|
||||||
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
|
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
|
||||||
|
@ -88,9 +89,9 @@ private void InitializeComponent()
|
||||||
this.chkAutoListen.AutoSize = true;
|
this.chkAutoListen.AutoSize = true;
|
||||||
this.chkAutoListen.Location = new System.Drawing.Point(15, 63);
|
this.chkAutoListen.Location = new System.Drawing.Point(15, 63);
|
||||||
this.chkAutoListen.Name = "chkAutoListen";
|
this.chkAutoListen.Name = "chkAutoListen";
|
||||||
this.chkAutoListen.Size = new System.Drawing.Size(136, 17);
|
this.chkAutoListen.Size = new System.Drawing.Size(249, 17);
|
||||||
this.chkAutoListen.TabIndex = 5;
|
this.chkAutoListen.TabIndex = 5;
|
||||||
this.chkAutoListen.Text = "Enable auto listening";
|
this.chkAutoListen.Text = "Listen for new connections on xRAT startup";
|
||||||
this.chkAutoListen.UseVisualStyleBackColor = true;
|
this.chkAutoListen.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// chkPopup
|
// chkPopup
|
||||||
|
@ -98,9 +99,9 @@ private void InitializeComponent()
|
||||||
this.chkPopup.AutoSize = true;
|
this.chkPopup.AutoSize = true;
|
||||||
this.chkPopup.Location = new System.Drawing.Point(15, 86);
|
this.chkPopup.Location = new System.Drawing.Point(15, 86);
|
||||||
this.chkPopup.Name = "chkPopup";
|
this.chkPopup.Name = "chkPopup";
|
||||||
this.chkPopup.Size = new System.Drawing.Size(267, 17);
|
this.chkPopup.Size = new System.Drawing.Size(259, 17);
|
||||||
this.chkPopup.TabIndex = 6;
|
this.chkPopup.TabIndex = 6;
|
||||||
this.chkPopup.Text = "Show popup notification on server connection";
|
this.chkPopup.Text = "Show popup notification on new connection";
|
||||||
this.chkPopup.UseVisualStyleBackColor = true;
|
this.chkPopup.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// btnListen
|
// btnListen
|
||||||
|
@ -118,7 +119,7 @@ private void InitializeComponent()
|
||||||
this.btnCancel.Location = new System.Drawing.Point(146, 210);
|
this.btnCancel.Location = new System.Drawing.Point(146, 210);
|
||||||
this.btnCancel.Name = "btnCancel";
|
this.btnCancel.Name = "btnCancel";
|
||||||
this.btnCancel.Size = new System.Drawing.Size(75, 23);
|
this.btnCancel.Size = new System.Drawing.Size(75, 23);
|
||||||
this.btnCancel.TabIndex = 8;
|
this.btnCancel.TabIndex = 9;
|
||||||
this.btnCancel.Text = "&Cancel";
|
this.btnCancel.Text = "&Cancel";
|
||||||
this.btnCancel.UseVisualStyleBackColor = true;
|
this.btnCancel.UseVisualStyleBackColor = true;
|
||||||
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
||||||
|
@ -149,11 +150,22 @@ private void InitializeComponent()
|
||||||
this.chkUseUpnp.Text = "Try to automatically port forward (UPnP)";
|
this.chkUseUpnp.Text = "Try to automatically port forward (UPnP)";
|
||||||
this.chkUseUpnp.UseVisualStyleBackColor = true;
|
this.chkUseUpnp.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// frmSettings
|
// chkShowTooltip
|
||||||
|
//
|
||||||
|
this.chkShowTooltip.AutoSize = true;
|
||||||
|
this.chkShowTooltip.Location = new System.Drawing.Point(15, 132);
|
||||||
|
this.chkShowTooltip.Name = "chkShowTooltip";
|
||||||
|
this.chkShowTooltip.Size = new System.Drawing.Size(268, 17);
|
||||||
|
this.chkShowTooltip.TabIndex = 8;
|
||||||
|
this.chkShowTooltip.Text = "Show tooltip on client with system information";
|
||||||
|
this.chkShowTooltip.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// FrmSettings
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(314, 245);
|
this.ClientSize = new System.Drawing.Size(314, 245);
|
||||||
|
this.Controls.Add(this.chkShowTooltip);
|
||||||
this.Controls.Add(this.chkUseUpnp);
|
this.Controls.Add(this.chkUseUpnp);
|
||||||
this.Controls.Add(this.txtPassword);
|
this.Controls.Add(this.txtPassword);
|
||||||
this.Controls.Add(this.lblPassword);
|
this.Controls.Add(this.lblPassword);
|
||||||
|
@ -169,7 +181,7 @@ private void InitializeComponent()
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
this.MinimizeBox = false;
|
this.MinimizeBox = false;
|
||||||
this.Name = "frmSettings";
|
this.Name = "FrmSettings";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "xRAT 2.0 - Settings";
|
this.Text = "xRAT 2.0 - Settings";
|
||||||
this.Load += new System.EventHandler(this.FrmSettings_Load);
|
this.Load += new System.EventHandler(this.FrmSettings_Load);
|
||||||
|
@ -191,5 +203,6 @@ private void InitializeComponent()
|
||||||
private System.Windows.Forms.Label lblPassword;
|
private System.Windows.Forms.Label lblPassword;
|
||||||
private System.Windows.Forms.TextBox txtPassword;
|
private System.Windows.Forms.TextBox txtPassword;
|
||||||
private System.Windows.Forms.CheckBox chkUseUpnp;
|
private System.Windows.Forms.CheckBox chkUseUpnp;
|
||||||
|
private System.Windows.Forms.CheckBox chkShowTooltip;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -31,6 +31,7 @@ private void FrmSettings_Load(object sender, EventArgs e)
|
||||||
chkPopup.Checked = XMLSettings.ShowPopup;
|
chkPopup.Checked = XMLSettings.ShowPopup;
|
||||||
txtPassword.Text = XMLSettings.Password;
|
txtPassword.Text = XMLSettings.Password;
|
||||||
chkUseUpnp.Checked = XMLSettings.UseUPnP;
|
chkUseUpnp.Checked = XMLSettings.UseUPnP;
|
||||||
|
chkShowTooltip.Checked = XMLSettings.ShowToolTip;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnListen_Click(object sender, EventArgs e)
|
private void btnListen_Click(object sender, EventArgs e)
|
||||||
|
@ -82,6 +83,9 @@ private void btnSave_Click(object sender, EventArgs e)
|
||||||
XMLSettings.WriteValue("UseUPnP", chkUseUpnp.Checked.ToString());
|
XMLSettings.WriteValue("UseUPnP", chkUseUpnp.Checked.ToString());
|
||||||
XMLSettings.UseUPnP = chkUseUpnp.Checked;
|
XMLSettings.UseUPnP = chkUseUpnp.Checked;
|
||||||
|
|
||||||
|
XMLSettings.WriteValue("ShowToolTip", chkShowTooltip.Checked.ToString());
|
||||||
|
XMLSettings.ShowToolTip = chkShowTooltip.Checked;
|
||||||
|
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,15 +13,16 @@ public static class XMLSettings
|
||||||
public static bool AutoListen { get; set; }
|
public static bool AutoListen { get; set; }
|
||||||
public static bool ShowPopup { get; set; }
|
public static bool ShowPopup { get; set; }
|
||||||
public static bool UseUPnP { get; set; }
|
public static bool UseUPnP { get; set; }
|
||||||
|
public static bool ShowToolTip { get; set; }
|
||||||
public static string Password { get; set; }
|
public static string Password { get; set; }
|
||||||
|
|
||||||
private static string settingsFilePath = Path.Combine(Application.StartupPath, "settings.xml");
|
private static string _settingsFilePath = Path.Combine(Application.StartupPath, "settings.xml");
|
||||||
|
|
||||||
public static bool WriteDefaultSettings()
|
public static bool WriteDefaultSettings()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!File.Exists(settingsFilePath))
|
if (!File.Exists(_settingsFilePath))
|
||||||
{
|
{
|
||||||
XmlDocument doc = new XmlDocument();
|
XmlDocument doc = new XmlDocument();
|
||||||
XmlNode root = doc.CreateElement("settings");
|
XmlNode root = doc.CreateElement("settings");
|
||||||
|
@ -33,8 +34,9 @@ public static bool WriteDefaultSettings()
|
||||||
root.AppendChild(doc.CreateElement("Password")).InnerText = "1234";
|
root.AppendChild(doc.CreateElement("Password")).InnerText = "1234";
|
||||||
root.AppendChild(doc.CreateElement("ShowToU")).InnerText = "True";
|
root.AppendChild(doc.CreateElement("ShowToU")).InnerText = "True";
|
||||||
root.AppendChild(doc.CreateElement("UseUPnP")).InnerText = "False";
|
root.AppendChild(doc.CreateElement("UseUPnP")).InnerText = "False";
|
||||||
|
root.AppendChild(doc.CreateElement("ShowToolTip")).InnerText = "False";
|
||||||
|
|
||||||
doc.Save(settingsFilePath);
|
doc.Save(_settingsFilePath);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -48,10 +50,9 @@ public static string ReadValue(string pstrValueToRead)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
XPathDocument doc = new XPathDocument(settingsFilePath);
|
XPathDocument doc = new XPathDocument(_settingsFilePath);
|
||||||
XPathNavigator nav = doc.CreateNavigator();
|
XPathNavigator nav = doc.CreateNavigator();
|
||||||
XPathExpression expr;
|
var expr = nav.Compile(@"/settings/" + pstrValueToRead);
|
||||||
expr = nav.Compile(@"/settings/" + pstrValueToRead);
|
|
||||||
XPathNodeIterator iterator = nav.Select(expr);
|
XPathNodeIterator iterator = nav.Select(expr);
|
||||||
while (iterator.MoveNext())
|
while (iterator.MoveNext())
|
||||||
{
|
{
|
||||||
|
@ -70,24 +71,23 @@ public static bool WriteValue(string pstrValueToRead, string pstrValueToWrite)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
XmlNode oldNode;
|
|
||||||
XmlDocument doc = new XmlDocument();
|
XmlDocument doc = new XmlDocument();
|
||||||
using (var reader = new XmlTextReader(settingsFilePath))
|
using (var reader = new XmlTextReader(_settingsFilePath))
|
||||||
{
|
{
|
||||||
doc.Load(reader);
|
doc.Load(reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlElement root = doc.DocumentElement;
|
XmlElement root = doc.DocumentElement;
|
||||||
oldNode = root.SelectSingleNode(@"/settings/" + pstrValueToRead);
|
var oldNode = root.SelectSingleNode(@"/settings/" + pstrValueToRead);
|
||||||
if (oldNode == null) // create if not exist
|
if (oldNode == null) // create if not exist
|
||||||
{
|
{
|
||||||
oldNode = doc.SelectSingleNode("settings");
|
oldNode = doc.SelectSingleNode("settings");
|
||||||
oldNode.AppendChild(doc.CreateElement(pstrValueToRead)).InnerText = pstrValueToWrite;
|
oldNode.AppendChild(doc.CreateElement(pstrValueToRead)).InnerText = pstrValueToWrite;
|
||||||
doc.Save(settingsFilePath);
|
doc.Save(_settingsFilePath);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
oldNode.InnerText = pstrValueToWrite;
|
oldNode.InnerText = pstrValueToWrite;
|
||||||
doc.Save(settingsFilePath);
|
doc.Save(_settingsFilePath);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|
Loading…
Reference in New Issue