If you would like to speak with one of our engineers, please Submit a Question or give us a call at the phone number here. In North America, To route your phone support request directly to a technical support engineer, call toll-free 1-888-382-1583 or 1-440-646-3434, select Option 3 (Technical Support), then select Option 5 (More Options). When prompted, enter the ThinManager Direct Dial Code 201. |
TermMon Demo Program Source
Insert source here
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Reflection; using System.Diagnostics; namespace TermMon_Demo { public enum CommandConst { TermSecureCheckAccess = -2, ChangeTerminalServerGroup = -1, } public partial class Form1 : Form { public Form1() { InitializeComponent(); EnableControl(true); ChangeEnabled(false); textBoxConnectionState.Text = "Disconnected"; textBoxConnectionState.BackColor = System.Drawing.Color.LightGray; Assembly a = Assembly.GetExecutingAssembly(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(a.Location); labelVersion.Text = "Version " + fvi.ProductVersion; } private void WaitForConnection() { timerWaitForConnection.Enabled = true; } private void EnableControl(bool enabled) { groupBoxDemoControl.Enabled = enabled; groupBoxOverrideIP.Enabled = enabled; } private void ChangeEnabled(bool enabled) { groupBoxTerminalInfo.Enabled = enabled; groupBoxTerminalControl.Enabled = enabled; groupBoxSessionControl.Enabled = enabled; groupBoxNavigation.Enabled = enabled; groupBoxGetDisplayClientScreen.Enabled = enabled; groupBoxTermSecure.Enabled = enabled; groupBoxCameraOverlay.Enabled = enabled; groupBoxActiveScreen.Enabled = enabled; groupBoxWatchdog.Enabled = enabled; buttonEnable.Enabled = !enabled; buttonDisable.Enabled = enabled; } private bool CheckValidIP(string IPAddress) { System.Net.IPAddress address; if (System.Net.IPAddress.TryParse(IPAddress, out address)) { if (address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { return true; } else { MessageBox.Show("Please use an IPv4 address"); } } else { MessageBox.Show("Please use xxx.xxx.xxx.xxx format for Override IP function"); } return false; } private string ResultLookup(int res) { switch(res) { case (short)TERMMONLib.TermMonConst.Busy: return "Busy"; case (short)TERMMONLib.TermMonConst.Connected: return "Connected"; case (short)TERMMONLib.TermMonConst.Disconnected: return "Disconnected"; case (short)TERMMONLib.TermMonConst.Fail: return "Failed"; case (short)TERMMONLib.TermMonConst.GroupNotFound: return "Group Not Found"; case (short)TERMMONLib.TermMonConst.InvalidMember: return "Invalid Member"; case (short)TERMMONLib.TermMonConst.RequestFailed: return "Request Failed"; case (short)TERMMONLib.TermMonConst.Success: return "Success"; case (short)TERMMONLib.TermMonConst.Timeout: return "Timeout"; case (short)TERMMONLib.TermMonConst.Updating: return "Updating"; case (short)TERMMONLib.TermMonConst.UserNotFound: return "User Not Found"; case (short)TERMMONLib.TermMonConst.ValidMember: return "Valid Member"; case (short)TERMMONLib.TermMonConst.BadPassword: return "Bad Password"; case (short)TERMMONLib.TermMonConst.NoPermission: return "No Permission"; case (short)TERMMONLib.TermMonConst.NoWindowsPassword: return "No Windows Password"; case (short)TERMMONLib.TermMonConst.NoWindowsUsername: return "Now Windows Username"; case (short)TERMMONLib.TermMonConst.PasswordChangeReq: return "Password Change Required"; default: return "Error: Other"; } } private void timer2_Tick(object sender, EventArgs e) { axTermMon.Disable(); timerWaitForConnection.Enabled = false; string message = ""; string location = "this terminal"; if (axTermMon.RunInSession == false) { location = axTermMon.OverrideIP; message = "\n- Is 'Only allow connections from session' set to 'NO' in the module?"; } message = "The demo application could not connect to the ActiveX control on " + location + "\n\n- Check that TermMon.ocx is registered on the terminal server.\n- Check that the terminal has the TermMon ActiveX module" + message; int res = (int)MessageBox.Show(message, "TermMon ActiveX Demo", MessageBoxButtons.RetryCancel, MessageBoxIcon.Asterisk); if (res == 4) { WaitForConnection(); } else { EnableControl(true); } } private void axTermMon_OnEvent(object sender, AxTERMMONLib._DTermMonEvents_OnEventEvent e) { switch (e.eventCode) { case (short)TERMMONLib.TermMonEvent.TerminalName: textBoxName.Text = axTermMon.TerminalName; break; case (short)TERMMONLib.TermMonEvent.TerminalIP: textBoxIPAddress.Text = axTermMon.TerminalIP; break; case (short)TERMMONLib.TermMonEvent.TerminalMAC: textBoxMACAddress.Text = axTermMon.TerminalMAC; break; case (short)TERMMONLib.TermMonEvent.TerminalFirmwareVersion: textBoxFirmwareVersion.Text = axTermMon.TerminalFirmwareVersion; break; case (short)TERMMONLib.TermMonEvent.TerminalBootLoaderVersion: textBoxBootRomVersion.Text = axTermMon.TerminalBootLoaderVersion; break; case (short)TERMMONLib.TermMonEvent.TerminalModel: textBoxModel.Text = axTermMon.TerminalModel; break; case (short)TERMMONLib.TermMonEvent.TerminalWindowsUsername: textBoxTermWinUsername.Text = axTermMon.TerminalWindowsUsername; break; case (short)TERMMONLib.TermMonEvent.TerminalServerGroupList: textBoxTSGroupList.Text = axTermMon.TerminalServerGroupList; break; case (short)TERMMONLib.TermMonEvent.CurrentTerminalServerGroup: textBoxCurrentTSGroup.Text = axTermMon.CurrentTerminalServerGroup; break; case (short)TERMMONLib.TermMonEvent.ConnectionState: if (axTermMon.ConnectionState == (short)TERMMONLib.TermMonConst.Connected) { textBoxConnectionState.Text = "Connected"; textBoxConnectionState.BackColor = System.Drawing.Color.Lime; timerWaitForConnection.Enabled = false; ChangeEnabled(true); if (checkBoxRunInNonSession.Checked) groupBoxWatchdog.Enabled = false; } else if (axTermMon.ConnectionState == (short)TERMMONLib.TermMonConst.Disconnected) { textBoxConnectionState.Text = "Disconnected"; textBoxConnectionState.BackColor = System.Drawing.Color.LightGray; ChangeEnabled(false); } else if (axTermMon.ConnectionState == (short)TERMMONLib.TermMonConst.Fail) { textBoxConnectionState.Text = "Failed"; textBoxConnectionState.BackColor = System.Drawing.Color.Red; ChangeEnabled(false); } break; case (short)TERMMONLib.TermMonEvent.CurrentWindowsUsername: textBoxSessionWinUsername.Text = axTermMon.CurrentWindowsUsername; break; case (short)TERMMONLib.TermMonEvent.TerminalServerName: textBoxTermServerName.Text = axTermMon.TerminalServerName; break; case (short)TERMMONLib.TermMonEvent.UserID: textBoxTSUserID.Text = axTermMon.UserID; break; case (short)TERMMONLib.TermMonEvent.TermSecureUsername: textBoxTSUsername.Text = axTermMon.TermSecureUsername; break; case (short)TERMMONLib.TermMonEvent.TermSecureWindowsUsername: textBoxTSWinUsername.Text = axTermMon.TermSecureWindowsUsername; break; case (short)TERMMONLib.TermMonEvent.WatchdogTime: labelWatchdogCount.Text = axTermMon.WatchdogTime.ToString(); break; default: break; } } private void buttonCalibrate_Click(object sender, EventArgs e) { axTermMon.Command((short)TERMMONLib.TermMonCommand.Calibrate); } private void buttonReboot_Click(object sender, EventArgs e) { axTermMon.Command((short)TERMMONLib.TermMonCommand.Reboot); } private void buttonRestart_Click(object sender, EventArgs e) { axTermMon.Command((short)TERMMONLib.TermMonCommand.Restart); } private void buttonDisconnect_Click(object sender, EventArgs e) { axTermMon.Command((short)TERMMONLib.TermMonCommand.DisconnectSession); } private void buttonLogoff_Click(object sender, EventArgs e) { axTermMon.Command((short)TERMMONLib.TermMonCommand.LogOffSession); } private void buttonPrevious_Click(object sender, EventArgs e) { axTermMon.Command((short)TERMMONLib.TermMonCommand.SwitchToPrevGroup); } private void buttonNext_Click(object sender, EventArgs e) { axTermMon.Command((short)TERMMONLib.TermMonCommand.SwitchToNextGroup); } private void buttonStartTiling_Click(object sender, EventArgs e) { axTermMon.Command((short)TERMMONLib.TermMonCommand.TileStart); } private void buttonStopTiling_Click(object sender, EventArgs e) { axTermMon.Command((short)TERMMONLib.TermMonCommand.TileEnd); } private void buttonMainMenu_Click(object sender, EventArgs e) { axTermMon.Command((short)TERMMONLib.TermMonCommand.GotoMainMenu); } private void buttonInstantFailover_Click(object sender, EventArgs e) { axTermMon.Command((short)TERMMONLib.TermMonCommand.SwitchInstFailover); } private void buttonGoToDisplayClient_Click(object sender, EventArgs e) { axTermMon.ChangeTerminalServerGroup(textBoxDisplayClientName.Text); } private void buttonGetScreen_Click(object sender, EventArgs e) { textBoxScreenNumber.Text = ""; textBoxScreenNumber.Text = axTermMon.GetGroupScreen(textBoxGetDisplayClientName.Text).ToString(); } private void buttonTSLogOn_Click(object sender, EventArgs e) { if (checkBoxTSLogOffUserSessions.Checked) { axTermMon.Command((short)TERMMONLib.TermMonCommand.LogOffAndChangeTermSecureUser); } else { axTermMon.Command((short)TERMMONLib.TermMonCommand.ChangeTermSecureUser); } } private void buttonTSLogOff_Click(object sender, EventArgs e) { if (checkBoxTSLogOffUserSessions.Checked) { axTermMon.Command((short)TERMMONLib.TermMonCommand.LogOffTermSecureUser); } else { axTermMon.Command((short)TERMMONLib.TermMonCommand.DisconnectTermSecureUser); } } private void buttonTSCheckAccess_Click(object sender, EventArgs e) { textBoxTSCheckAccessResponse.Text = "Updating..."; textBoxTSCheckAccessResponse.Text = ResultLookup(axTermMon.TermSecureCheckAccess(textBoxTSCheckAccessUsername.Text, textBoxTSCheckAccessGroup.Text)); } private void buttonTSLogOnUser_Click(object sender, EventArgs e) { textBoxTSLogOnResponse.Text = "Updating..."; textBoxTSLogOnResponse.Text = ResultLookup(axTermMon.TermSecureLogonUser(textBoxTSLogOnUsername.Text, textBoxTSLogOnPassword.Text)); } private void buttonCamEnable_Click(object sender, EventArgs e) { axTermMon.CameraOverlayEnable(textBoxCamGroupName.Text, textBoxCamOverlayName.Text); } private void buttonCamDisable_Click(object sender, EventArgs e) { axTermMon.CameraOverlayDisable(textBoxCamGroupName.Text, textBoxCamOverlayName.Text); } private void buttonCamCycleStart_Click(object sender, EventArgs e) { axTermMon.CameraOverlayCycleStart(textBoxCamGroupName.Text, textBoxCamOverlayName.Text); } private void buttonCamCycleStop_Click(object sender, EventArgs e) { axTermMon.CameraOverlayCycleStop(textBoxCamGroupName.Text, textBoxCamOverlayName.Text); } private void buttonCamPrevious_Click(object sender, EventArgs e) { axTermMon.CameraOverlaySwitchPrev(textBoxCamGroupName.Text, textBoxCamOverlayName.Text); } private void buttonCamNext_Click(object sender, EventArgs e) { axTermMon.CameraOverlaySwitchNext(textBoxCamGroupName.Text, textBoxCamOverlayName.Text); } private void buttonCamSwitchByName_Click(object sender, EventArgs e) { axTermMon.CameraOverlaySwitchByName(textBoxCamGroupName.Text, textBoxCamOverlayName.Text, textBoxCamName.Text); } private void buttonCamEnterFullscreen_Click(object sender, EventArgs e) { axTermMon.CameraOverlayFullscreenEnter(textBoxCamGroupName.Text, textBoxCamOverlayName.Text); } private void buttonCamExitFullscreen_Click(object sender, EventArgs e) { axTermMon.CameraOverlayFullscreenExit(textBoxCamGroupName.Text, textBoxCamOverlayName.Text); } private void buttonCamMove_Click(object sender, EventArgs e) { axTermMon.CameraOverlayMove(textBoxCamGroupName.Text, textBoxCamOverlayName.Text, short.Parse(textBoxCamX.Text), short.Parse(textBoxCamY.Text)); } private void buttonCamResize_Click(object sender, EventArgs e) { axTermMon.CameraOverlayResize(textBoxCamGroupName.Text, textBoxCamOverlayName.Text, short.Parse(textBoxCamW.Text), short.Parse(textBoxCamH.Text)); } private void buttonCamMoveResize_Click(object sender, EventArgs e) { axTermMon.CameraOverlayResizeMove(textBoxCamGroupName.Text, textBoxCamOverlayName.Text, short.Parse(textBoxCamX.Text), short.Parse(textBoxCamY.Text), short.Parse(textBoxCamW.Text), short.Parse(textBoxCamH.Text)); } private void buttonEnable_Click(object sender, EventArgs e) { axTermMon.RunInSession = true; if (checkBoxRunInNonSession.Checked) { axTermMon.RunInSession = false; if (CheckValidIP(textBoxOverrideIPAddress.Text)) { axTermMon.OverrideIP = textBoxOverrideIPAddress.Text; } else { return; } } axTermMon.Enable(); WaitForConnection(); } private void buttonDisable_Click(object sender, EventArgs e) { short res = axTermMon.Disable(); if (res == (short)TERMMONLib.TermMonConst.Fail) { MessageBox.Show("Not Enabled"); } } private void buttonSetActiveScreen_Click(object sender, EventArgs e) { short i = -1; if (textBoxSetActiveScreen.Text.Length > 0) i = short.Parse(textBoxSetActiveScreen.Text); if (i >= 0 && i < 6) { axTermMon.ActiveScreen = i; } else { MessageBox.Show("To set active screet use 0 through 5"); } } private void buttonWatchdogSet_Click(object sender, EventArgs e) { if (short.Parse(textBoxWatchdogSeconds.Text) > 32767) { textBoxWatchdogSeconds.Text = "32767"; } labelWatchdogCount.Text = textBoxWatchdogSeconds.Text; axTermMon.WatchdogTime = short.Parse(textBoxWatchdogSeconds.Text); } private void checkBoxTSDisconnectUserSessions_CheckedChanged(object sender, EventArgs e) { if (checkBoxTSDisconnectUserSessions.Checked) { checkBoxTSLogOffUserSessions.Checked = false; } else { checkBoxTSLogOffUserSessions.Checked = true; } } private void checkBoxTSLogOffUserSessions_CheckedChanged(object sender, EventArgs e) { if (checkBoxTSLogOffUserSessions.Checked) { checkBoxTSDisconnectUserSessions.Checked = false; } else { checkBoxTSDisconnectUserSessions.Checked = true; } } } }