using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Shell32;
using Microsoft.Win32;
namespace RDPManager
{
public partial class frmAbout : Form
{
String version = "";
String mainWebsite = "http://sourceforge.net/projects/rdpmanager/";
String softwareJediSite = "http://www.AnAppADay.com";
String willisKnightonSite = "http://sourceforge.net/users/jwbrit/";
dlgShowMachineSettings dlgDispManual = null;
public frmAbout()
{
InitializeComponent();
#if DEBUG
this.Text = this.Text + " *";
#endif
}
public String Version
{
get { return version; }
set { version = value; }
}
private void linkWebsite_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start(mainWebsite);
}
private void llblSoftwareJedi_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start(softwareJediSite);
}
private void llblWillisKnighton_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start(willisKnightonSite);
}
private void About_Shown(object sender, EventArgs e)
{
lblVersion.Text = "Version " + version;
#if DEBUG
lblVersion.Text += " (Debug)";
#endif
llblSoftwareJedi.AutoSize = true;
llblSoftwareJedi.Text = "Dana Hanna";
llblSoftwareJedi.LinkArea = new System.Windows.Forms.LinkArea(0, 10);
llblWillisKnighton.AutoSize = true;
llblWillisKnighton.Text = "Jeff Britton";
llblWillisKnighton.LinkArea = new System.Windows.Forms.LinkArea(0, 15);
txtRecent.Text = RdpManager.RecentMaxCount.ToString();
txtMRUs.Text = RdpManager.MUMaxCount.ToString();
}
private void btnOK_Click(object sender, EventArgs e)
{
Close();
}
private void btnShortcut_Click(object sender, EventArgs e)
{
try
{
OpenFileDialog fileDg = new OpenFileDialog();
fileDg.InitialDirectory = Environment.GetEnvironmentVariable("USERPROFILE") + "\\Start Menu\\Programs\\Startup";
fileDg.FileName = "RdpManager.lnk";
fileDg.AutoUpgradeEnabled = true;
fileDg.CheckFileExists = false;
fileDg.DefaultExt = ".lnk";
fileDg.DereferenceLinks = false;
fileDg.RestoreDirectory = true;
fileDg.ValidateNames = true;
fileDg.Multiselect = false;
fileDg.AddExtension = true;
fileDg.Filter = "Shortcuts (*.lnk)|*.lnk";
fileDg.Title = "Locate xml file";
if (fileDg.ShowDialog() != DialogResult.Cancel)
{
ShellShortcut shortCut = new ShellShortcut(fileDg.FileName);
shortCut.Description = "Launch RDP Manager";
String execPath = String.Format("\"{0}\"", Application.ExecutablePath);
shortCut.Path = execPath;
shortCut.IconPath = Application.ExecutablePath;
shortCut.IconIndex = 0;
if (MessageBox.Show("Do you want to set the configuration files RDPManager is currently using as arguments?", "RDPManager Start Menu Shortcut", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
shortCut.Arguments = "";
foreach( String configFile in RdpManager.ConfigFiles )
{
shortCut.Arguments += "\"" + configFile + "\" ";
}
}
shortCut.Save();
MessageBox.Show("Shortcut Created!", "Shortcut Created", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception exc)
{
MessageBox.Show("Could not create shortcut, error: " + exc.ToString(), "Shortcut not created", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btnReloadConfig_Click(object sender, EventArgs e)
{
RdpManager.reloadConfig();
}
private void btnResetRecent_Click(object sender, EventArgs e)
{
RdpManager.ResetRecent();
RdpManager.reloadConfig();
}
private void btnAddtoRegistry_Click(object sender, EventArgs e)
{
int count = 0;
if ( MessageBox.Show("This will import all the machines RDPManager knows about into the registry, which will suppress the unknown publisher warning dialog box. Continue?", "Import machines into registry", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.No) return;
foreach (Machine mach in RdpManager.Machines.Values)
{
if( mach.MachineName == "Default" ) continue;
RDPManager.RdpManager.AddToReg(mach.MachineName);
count++;
}
MessageBox.Show( String.Format("Registry import completed, {0} machines imported", count), "Registry Import Done", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
private void btnDisplayMRU_Click(object sender, EventArgs e)
{
frmDisplayMUs dispMRU = new frmDisplayMUs();
dispMRU.ShowDialog();
}
private void btnShowMach_Click(object sender, EventArgs e)
{
if (dlgDispManual == null)
{
dlgDispManual = new dlgShowMachineSettings();
dlgDispManual.ShowDialog();
dlgDispManual.Dispose();
dlgDispManual = null;
}
else
{
dlgDispManual.BringToFront();
}
}
}
}