public WOL2Host(string sName, string sDescription, string sIpAddress, string sMacAddress, string sSubnetMask, /* string sSubnetAddress , */ WOL2HostState nState, WOL2ConnectionType nConnection, string sGroups, string sIconFile, string sSecureOnPwd, bool bIsDynamicHost, bool bWakeOnAlarm, bool bNotifyOnStateChanges, string sIpv6Address, WOLPacketTransferMode transfer) { m_sName = sName; m_sDescription = sDescription; m_sIpAddress = sIpAddress; m_sIpv6Address = sIpv6Address; m_sMacAddress = sMacAddress; // m_sSubnetAddress = sSubnetAddress; m_sSubnetMask = sSubnetMask; m_nState = nState; m_nConnectionType = nConnection; m_sIconFile = sIconFile; m_sGroups = sGroups; m_sSecureOnPasswd = sSecureOnPwd; m_bWakeOnAlarm = bWakeOnAlarm; m_bNotifyOnStateChanges = bNotifyOnStateChanges; m_bIsDynamicHost = bIsDynamicHost; m_lPingReplyTime = -1; m_bStateChanged = false; PacketTransferMode = transfer; }
void BtnOkClick(object sender, EventArgs e) { m_Host.SetName(txtName.Text); m_Host.SetMacAddress(txtMac.Text); m_Host.SetSubnetMask(txtSnMask.Text); m_Host.SetDescription(txtComment.Text); m_Host.SetIpAddress(txtIp.Text); m_Host.SetGroups(txtGroups.Text); m_Host.SetIsDynamicHost(chkDHCP.Checked); m_Host.SetIsStateChangedNoftificationEnabled(chkNotify.Checked); m_Host.SetSecureOnPassword(txtSecureOn.Text); m_Host.SetIpV6Address(txtIPv6.Text); WOLPacketTransferMode f = WOLPacketTransferMode.modeNone; switch (cboWolMode.SelectedIndex) { case 1: f = WOLPacketTransferMode.modeBCast; break; case 2: f = WOLPacketTransferMode.modeNetCast; break; case 3: f = WOLPacketTransferMode.modeSendToHost; break; } m_Host.PacketTransferMode = f; this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); }
public WOL2Host( string sName, string sDescription, string sIpAddress, string sMacAddress, string sSubnetMask, /* string sSubnetAddress , */ WOL2HostState nState, WOL2ConnectionType nConnection, string sGroups, string sIconFile, string sSecureOnPwd, bool bIsDynamicHost, bool bWakeOnAlarm, bool bNotifyOnStateChanges, string sIpv6Address, WOLPacketTransferMode transfer ) { m_sName = sName; m_sDescription = sDescription; m_sIpAddress = sIpAddress; m_sIpv6Address = sIpv6Address; m_sMacAddress = sMacAddress; // m_sSubnetAddress = sSubnetAddress; m_sSubnetMask = sSubnetMask; m_nState = nState; m_nConnectionType = nConnection; m_sIconFile = sIconFile; m_sGroups = sGroups; m_sSecureOnPasswd = sSecureOnPwd; m_bWakeOnAlarm = bWakeOnAlarm; m_bNotifyOnStateChanges = bNotifyOnStateChanges; m_bIsDynamicHost = bIsDynamicHost; m_lPingReplyTime = -1; m_bStateChanged = false; PacketTransferMode = transfer; }
public DlgEditHost(WOL2Host h) { // The InitializeComponent() call is required for Windows Forms designer support. InitializeComponent(); // Assign the host to this instance m_Host = h; // Check if the host is a new one /* if( !m_Host.IsValid() ) * { * // Create a new host * } * else * {*/ // Edit an existing host txtComment.Text = m_Host.GetDescription(); txtIp.Text = m_Host.GetIpAddress(); txtIPv6.Text = m_Host.GetIpV6Address(); txtMac.Text = m_Host.GetMacAddress(); txtSnMask.Text = m_Host.GetSubnetMask(); txtName.Text = m_Host.GetName(); txtGroups.Text = m_Host.GetGroups(); chkDHCP.Checked = m_Host.IsDynamicHost(); chkNotify.Checked = m_Host.IsStateChangedNoftificationEnabled(); txtSecureOn.Text = m_Host.GetSecureOnPassword(); WOLPacketTransferMode f = m_Host.PacketTransferMode; if ((f & WOLPacketTransferMode.modeBCast) == WOLPacketTransferMode.modeBCast) { cboWolMode.SelectedIndex = 1; } else if ((f & WOLPacketTransferMode.modeNetCast) == WOLPacketTransferMode.modeNetCast) { cboWolMode.SelectedIndex = 2; } else if ((f & WOLPacketTransferMode.modeSendToHost) == WOLPacketTransferMode.modeSendToHost) { cboWolMode.SelectedIndex = 3; } else { cboWolMode.SelectedIndex = 0; } // } }
public void SetWOLFlags(WOLPacketTransferMode f) { if ((f & WOLPacketTransferMode.modeBCast) == WOLPacketTransferMode.modeBCast) { rbSendToBCast.Checked = true; } else if ((f & WOLPacketTransferMode.modeNetCast) == WOLPacketTransferMode.modeNetCast) { rbSendToNetwork.Checked = true; } else if ((f & WOLPacketTransferMode.modeSendToHost) == WOLPacketTransferMode.modeSendToHost) { rbSendToNode.Checked = true; } }
public WOLPacketTransferMode GetWOLFlags( ) { WOLPacketTransferMode f = WOLPacketTransferMode.modeNone; if (rbSendToBCast.Checked) { f |= WOLPacketTransferMode.modeBCast; } else if (rbSendToNetwork.Checked) { f |= WOLPacketTransferMode.modeNetCast; } else if (rbSendToNode.Checked) { f |= WOLPacketTransferMode.modeSendToHost; } return(f); }
private Dictionary<string, WOL2Tool> m_Tools = new Dictionary< string, WOL2Tool >(); // The tools list #endregion Fields #region Constructors public MainForm( string[] args ) { // The InitializeComponent() call is required for Windows Forms designer support. InitializeComponent(); // Initialize the command line arguments class Arguments CommandLine = new Arguments(args); // Create a new list view sorter m_ListViewSorter = new ListViewColumnSorter(); listView.ListViewItemSorter = m_ListViewSorter; // Load the settings #region Read Profile ---------------------- string sLastFile = ""; // Check where we should read our settings from if (CommandLine["registry"] != null) { m_bUseRegistryProfile = true; } else if (!WOL2Profile.HasXmlProfile()) { m_bUseRegistryProfile = true; } WOL2Profile profile = new WOL2Profile(m_bUseRegistryProfile); if (profile.OpenProfile(WOL2Profile.WOL2ProfileAccessMode.ModeRead)) { m_iOnlineCheckInterval = profile.GetSetting("RefreshInterval", 10000); // milli seconds m_iWakeDelay = profile.GetSetting("GroupWakeDelay", 500); m_iWakePort = profile.GetSetting("WOLPort", 7); m_iPingTimeout = profile.GetSetting("PingTimeout", 250); listView.View = (View)View.Parse(typeof(View), (string)profile.GetSetting("ViewStyle", "Details")); m_PacketTransferOptions = (WOLPacketTransferMode)Enum.Parse(typeof(WOLPacketTransferMode), profile.GetSetting("WOLFlags", "modeBCast"), true); m_bAskForSecureOnPwd = profile.GetSetting("AskForSecureOnPwd", false); m_bOpenLastFile = profile.GetSetting("OpenLastFile", true); sLastFile = profile.GetSetting("LastFile", ""); m_bHasDoneSurvey = profile.GetSetting("SurveyCompleted", false); m_bDoLogging = profile.GetSetting("DoLogging", false); // Start Logging? #if DEBUG MOE.Logger.StartLogging("wol2.log", Logger.LogLevel.lvlDebug); #else if (m_bDoLogging) MOE.Logger.StartLogging("wol2.log", Logger.LogLevel.lvlDebug); #endif m_bColorizeListView = profile.GetSetting("ColorizeListView", false); m_bAutosaveHostFile = profile.GetSetting("AutosaveHostlist", false); m_bMinimizeToTray = profile.GetSetting("MinimizeToTray", false); m_bConfirmNetActions = profile.GetSetting("ConfirmNetworkOptions", true); m_bUseIpV6 = profile.GetSetting("UseIPv6", false); // Notification options m_bDisplayStateNotifications = profile.GetSetting("DisplayStateNotifications", false); m_bAlwaysDisplayNotifications = profile.GetSetting("AlwaysDisplayNotifications", false); m_iNotificationTimeout = profile.GetSetting("NotificationTimeout", 3000); // ms m_bUpdateIPInOnlineChecker = profile.GetSetting("UpdateIPAddressesForDHCP", false); m_sHostStateChangedCommand = profile.GetSetting("HostStateChangedCommand", ""); m_sGroupStateChangedCommand = profile.GetSetting("GroupStateChangedCommand", ""); // Network scanner options m_bUnresolvedNameOk = profile.GetSetting("UnresolvedNameOk", false); m_bUnresolvedMacOk = profile.GetSetting("UnresolvedMacOk", false); // Restore List View Columns for (int i = 0; i < listView.Columns.Count; i++) { int d = profile.GetSetting("ColumnOrder" + i, -1); int w = profile.GetSetting("ColumnWidth" + i, -1); if (d != -1) listView.Columns[i].DisplayIndex = d; if (w != -1) { listView.Columns[i].Width = w; } } // Restore the list view sort order m_ListViewSorter.SortColumn = profile.GetSetting("SortColumn", 0); m_ListViewSorter.Order = profile.GetSetting("SortOrder", "Ascending") == "Ascending" ? SortOrder.Ascending : SortOrder.Descending; // Make the sort order visible ListViewExtensions.SetSortIcon(listView, m_ListViewSorter.SortColumn, m_ListViewSorter.Order); listView.Sort(); // Load tools string temp = profile.GetSetting("Tool0", ""); int idx = 0; while (temp != "") { WOL2Tool t = WOL2Tool.parse(temp); if (t != null) m_Tools.Add(t.GetName(), t); temp = profile.GetSetting("Tool" + ++idx, ""); } // Load the MRU temp = profile.GetSetting("MRUItem1", ""); idx = 1; while (temp != "") { m_MruList.Add(temp); temp = profile.GetSetting("MRUItem" + ++idx, ""); } BuildMruList(); m_iShutdownTimeout = profile.GetSetting("ShutdownTimeout", 60); // seconds m_sShutdownComment = profile.GetSetting("ShutdownComment", ""); temp = profile.GetSetting("ShutdownPaswd", ""); if (temp != "") { string s = MOE.Utility.Base64Decode(temp); m_sShutdownPaswd = MOE.Utility.SecureStringFromString(s); } m_sShutdownUser = profile.GetSetting("ShutdownUser", ""); m_sShutdownDomain = profile.GetSetting("ShutdownDomain", ""); m_bForceShutdown = profile.GetSetting("ForceShutdown", false); m_iRebootTimeout = profile.GetSetting("RebootTimeout", 60); m_sRebootComment = profile.GetSetting("RebootComment", ""); temp = profile.GetSetting("RebootPaswd", ""); if (temp != "") { string s = MOE.Utility.Base64Decode(temp); m_sRebootPaswd = MOE.Utility.SecureStringFromString(s); } m_sRebootUser = profile.GetSetting("RebootUser", ""); m_sRebootDomain = profile.GetSetting("RebootDomain", ""); m_bForceReboot = profile.GetSetting("ForceReboot", false); // Done profile.CloseProfile(); profile = null; } #endregion // Create an empty document CreateNewHostsFile(); // Parse the command line. if( CommandLine["file"] != null ) { OpenHostList( CommandLine["file"] ); } else { // Check whether to open the last file if( m_bOpenLastFile && sLastFile != "" ) { m_sHostFileName = sLastFile; OpenHostList(m_sHostFileName); } } if( CommandLine["wake"] != null ) { string s = CommandLine["wake"]; string [] sHosts = s.Split( ';' ); Monitor.Enter( m_LockHosts ); foreach( string sHost in sHosts ) { WOL2Host h = m_Hosts.Find( delegate( WOL2Host theHost ) { return theHost.GetName().ToLower() == sHost.ToLower(); } ); if( h != null ) WakeHost( h, true ); DateTime dwTime = DateTime.Now.AddMilliseconds(m_iWakeDelay); while (DateTime.Now < dwTime) Application.DoEvents(); } Monitor.Exit( m_LockHosts ); } if (CommandLine["shutdown"] != null) { string s = CommandLine["shutdown"]; string[] sHosts = s.Split(';'); Monitor.Enter(m_LockHosts); foreach (string sHost in sHosts) { WOL2Host h = m_Hosts.Find(delegate(WOL2Host theHost) { return theHost.GetName().ToLower() == sHost.ToLower(); }); if (h != null) ShutdownHost(h, true); } Monitor.Exit(m_LockHosts); } if (CommandLine["reboot"] != null) { string s = CommandLine["reboot"]; string[] sHosts = s.Split(';'); Monitor.Enter(m_LockHosts); foreach (string sHost in sHosts) { WOL2Host h = m_Hosts.Find(delegate(WOL2Host theHost) { return theHost.GetName().ToLower() == sHost.ToLower(); }); if (h != null) RebootHost(h, true); } Monitor.Exit(m_LockHosts); } if (CommandLine["wakegrp"] != null) { string s = CommandLine["wakegrp"]; string[] sGroups = s.Split(';'); foreach (string sGroup in sGroups) { WOL2Group g; if( m_Groups.TryGetValue( sGroup, out g ) ) WakeGroup(g, true); } } if (CommandLine["rebootgrp"] != null) { string s = CommandLine["rebootgrp"]; string[] sGroups = s.Split(';'); foreach (string sGroup in sGroups) { WOL2Group g; if (m_Groups.TryGetValue(sGroup, out g)) RebootGroup(g, true); } } if (CommandLine["shutdowngrp"] != null) { string s = CommandLine["shutdowngrp"]; string[] sGroups = s.Split(';'); foreach (string sGroup in sGroups) { WOL2Group g; if (m_Groups.TryGetValue(sGroup, out g)) ShutdownGroup(g, true); } } // Last parameter: Close the App. if( CommandLine["close"] != null ) { this.Close(); m_bNoStart = true; return; } // Refresh the tools menu RefreshToolsMenu(); // Kick Up the OnlineStateChecker InitOnlineStateChecker(); // Say hello lblStatus.Text = MOE.Utility.GetStringFromRes("strWelcome"); // Load toolbar settings ToolStripManager.LoadSettings(this); // Make the toolbars visible if they were hidden (by a bug in ToolStripManager) toolStrip1.Visible = true; toolStripTools.Visible = true; menuStrip1.Visible = true; statusStrip1.Visible = true; }
public void SetWOLFlags( WOLPacketTransferMode f ) { if( ( f & WOLPacketTransferMode.modeBCast ) == WOLPacketTransferMode.modeBCast ) rbSendToBCast.Checked = true; else if( ( f & WOLPacketTransferMode.modeNetCast ) == WOLPacketTransferMode.modeNetCast ) rbSendToNetwork.Checked = true; else if( ( f & WOLPacketTransferMode.modeSendToHost ) == WOLPacketTransferMode.modeSendToHost ) rbSendToNode.Checked = true; }
/// <summary> /// Recreates a host from an XML node. /// </summary> /// <param name="n">The XML node to recreate this host from.</param> public bool DeserializeXML( XmlNode n ) { while( n != null ) { if (n.Name == "HostName") SetName(n.InnerText); else if (n.Name == "IPAddress") SetIpAddress(n.InnerText); else if (n.Name == "IPV6Address") SetIpV6Address(n.InnerText); else if (n.Name == "MACAddress") SetMacAddress(n.InnerText); else if (n.Name == "SecureOnPwd") SetSecureOnPassword(n.InnerText); /* else if( n.Name == "SubnetAddress" ) SetSubnetAddress( n.InnerText ); */ // MOE: Not used anymore. else if (n.Name == "SubnetMask") SetSubnetMask(n.InnerText); else if (n.Name == "Comment") SetDescription(n.InnerText); else if (n.Name == "Groups") SetGroups(n.InnerText); else if (n.Name == "IconFile") SetIconFile(n.InnerText); else if (n.Name == "IsDynamicHost") m_bIsDynamicHost = (n.InnerText == "1" ? true : false); // Old Attribute "WakeOnAlarm" is mapped to the wake timer else if (n.Name == "WakeOnAlarm") m_Timer.SetIsEnabled(n.InnerText == "1" ? true : false); // else if( n.Name == "ConnectionType" ) //TODO: Load ConnectionType else if (n.Name == "Timer") m_Timer.DeserializeXML(n.FirstChild); else if (n.Name == "ShutdownTimer") m_ShutdownTimer.DeserializeXML(n.FirstChild); else if (n.Name == "RebootTimer") m_RebootTimer.DeserializeXML(n.FirstChild); else if (n.Name == "NotifyOnStateChanges") m_bNotifyOnStateChanges = (n.InnerText == "1" ? true : false); else if (n.Name == "TransferMode") { try { PacketTransferMode = (WOLPacketTransferMode)Enum.Parse(typeof(WOLPacketTransferMode), n.InnerText); } catch { } } n = n.NextSibling; } return IsValid(); }