- smoothy_source.zip
- Smoothy.gpState
- Smoothy.sln
- SmoothyInterface
- app.config
- bin
- Data
- Enum
- External
- BusyBarLib.dll
- Forms
- monitor.ico
- obj
- Program.cs
- Properties
- Resources
- action_refresh_blue.gif
- add.png
- afraid.bmp
- arrow_in.png
- arrow_out.png
- arrow_refresh.png
- arrow_refresh_small.png
- arrow_right.png
- arrow_up.png
- cancel.png
- cancel1.png
- color_swatch.png
- color_wheel.png
- connect.png
- door_out.png
- error.png
- FailureAudit.gif
- flag_orange.gif
- flag_red.gif
- flag_red.png
- help.png
- information.png
- key.png
- link_add.png
- link_error.png
- link_go.png
- lock.png
- monitor-48.png
- page.png
- page_copy.png
- page_gear.png
- script_code.png
- script_code_red.png
- SuccessAudit.gif
- tab_go.png
- table.png
- Warning.gif
- SmoothyInterface.csproj
- SmoothyInterface.snk
- Util
- TestEventLogTypes
- smoothy_bin.zip
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SmoothyInterface.Properties;
using System.Collections.Specialized;
using System.Diagnostics;
namespace SmoothyInterface.Forms
{
public partial class ConnectToComputer : Form
{
#region Globals
private EventLog[] eventLogsRetrieved = null;
private string machineName = null;
private List<string> ignoreComputers = null;
#endregion
#region Construction
public ConnectToComputer(List<string> ignoreComputers_)
{
#region Assertions
Debug.Assert(ignoreComputers_ != null);
#endregion
InitializeComponent();
ignoreComputers = ignoreComputers_;
LoadComputers();
}
private void ConnectToComputer_Load(object sender, EventArgs e)
{
}
#endregion
#region Properties
public EventLog[] EventLogsRetrieved
{
get
{
return eventLogsRetrieved;
}
}
public string MachineNameSpecified
{
get
{
return machineName;
}
}
#endregion
#region Methods
private void LoadComputers()
{
StringCollection computers = Settings.Default.RemoteComputers;
if (computers != null)
{
for (int i = 0; i < computers.Count; i++)
{
dlComputerName.Items.Add(computers[i]);
}
}
}
#endregion
#region Events
private void dlComputerName_TextChanged(object sender, EventArgs e)
{
btnConnect.Enabled = (dlComputerName.Text != String.Empty);
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
}
private void btnConnect_Click(object sender, EventArgs e)
{
try
{
this.Cursor = Cursors.WaitCursor;
if (ignoreComputers.Contains(dlComputerName.Text))
{
MessageBox.Show("A connection to this computer is allready open.", "Smoothy", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
if (Settings.Default.RemoteComputers == null)
{
Settings.Default.RemoteComputers = new StringCollection();
}
EventLog[] logs = EventLog.GetEventLogs(dlComputerName.Text);
eventLogsRetrieved = logs;
machineName = dlComputerName.Text;
// Save the machine name in the user's config file
if (!Settings.Default.RemoteComputers.Contains(machineName))
{
Settings.Default.RemoteComputers.Add(machineName);
Settings.Default.Save();
}
this.DialogResult = DialogResult.OK;
}
}
catch (Exception ex)
{
MessageBox.Show("Failed to connect to remote computer : " + ex.Message, "Smoothy", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
this.Cursor = Cursors.Default;
}
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
The author is a software consultant in South Africa, specializing in bespoke software solutions.