/// <summary> /// Program change event handler /// </summary> /// <param name="program"></param> /// <param name="index"></param> /// <param name="type"></param> protected void OnProgramChange(ProgramInfo program, ushort index, ushort type) { var handler = ProgramChange; if (handler != null) { var args = new ProgramChangeEventArgs(program, type); args.Index = index; ProgramChange(this, args); } }
/// <summary> /// Constructor overload /// </summary> /// <param name="Program"></param> /// <param name="type"></param> public ProgramChangeEventArgs(ProgramInfo program, ushort type, ushort index) { Program = program; Type = type; Index = index; }
/// <summary> /// Constructor overload /// </summary> /// <param name="Program"></param> /// <param name="type"></param> public ProgramChangeEventArgs(ProgramInfo program, ushort type) { Program = program; Type = type; }
/// <summary> /// Gets the program info by index /// </summary> /// <param name="index"></param> public void GetProgramInfoByIndex(ushort index) { if (index < 1 || index > 10) { return; } OnBoolChange(true, 0, SystemInfoConstants.BusyBoolChange); var program = new ProgramInfo(); try { var response = ""; CrestronConsole.SendControlSystemCommand(string.Format("progcomments:{0}", index), ref response); // no program loaded or running if (response.Contains("Bad or Incomplete Command")) { program.Name = ""; program.System = ""; program.Programmer = ""; program.CompileTime = ""; program.Database = ""; program.Environment = ""; } else { // SIMPL returns program.Name = ParseConsoleResponse(response, "Program File", ":", "\x0D"); program.System = ParseConsoleResponse(response, "System Name", ":", "\x0D"); program.ProgramIdTag = ParseConsoleResponse(response, "Friendly Name", ":", "\x0D"); program.Programmer = ParseConsoleResponse(response, "Programmer", ":", "\x0D"); program.CompileTime = ParseConsoleResponse(response, "Compiled On", ":", "\x0D"); program.Database = ParseConsoleResponse(response, "CrestronDB", ":", "\x0D"); program.Environment = ParseConsoleResponse(response, "Source Env", ":", "\x0D"); // S# returns if (program.System.Length == 0) { program.System = ParseConsoleResponse(response, "Application Name", ":", "\x0D"); } if (program.Database.Length == 0) { program.Database = ParseConsoleResponse(response, "PlugInVersion", ":", "\x0D"); } if (program.Environment.Length == 0) { program.Environment = ParseConsoleResponse(response, "Program Tool", ":", "\x0D"); } } OnProgramChange(program, index, SystemInfoConstants.ProgramConfigChange); } catch (Exception e) { var msg = string.Format("GetProgramInfoByIndex failed: {0}", e.Message); CrestronConsole.PrintLine(msg); //ErrorLog.Error(msg); } OnBoolChange(false, 0, SystemInfoConstants.BusyBoolChange); }