public void Initialize() { //Thread.CurrentThread.Name = "UI Thread"; // Check the directories exist if (!Directory.Exists(ApplicationSettings.Default.LibraryPath + @"\backgrounds\")) { // Will handle the create of everything here Directory.CreateDirectory(ApplicationSettings.Default.LibraryPath + @"\backgrounds"); } // Default the XmdsConnection ApplicationSettings.Default.XmdsLastConnection = DateTime.MinValue; // Show in taskbar ShowInTaskbar = ApplicationSettings.Default.ShowInTaskbar; // Setup the proxy information OptionForm.SetGlobalProxy(); _statLog = new StatLog(); // Create the info form _clientInfoForm = new ClientInfo(); _clientInfoForm.Hide(); // Define the hotkey Keys key; try { key = (Keys)Enum.Parse(typeof(Keys), ApplicationSettings.Default.ClientInformationKeyCode.ToUpper()); } catch { // Default back to I key = Keys.I; } KeyStore.Instance.AddKeyDefinition("ClientInfo", key, ((ApplicationSettings.Default.ClientInfomationCtrlKey) ? Keys.Control : Keys.None)); // Register a handler for the key event KeyStore.Instance.KeyPress += Instance_KeyPress; // Trace listener for Client Info ClientInfoTraceListener clientInfoTraceListener = new ClientInfoTraceListener(_clientInfoForm); clientInfoTraceListener.Name = "ClientInfo TraceListener"; Trace.Listeners.Add(clientInfoTraceListener); // Log to disk? if (!string.IsNullOrEmpty(ApplicationSettings.Default.LogToDiskLocation)) { TextWriterTraceListener listener = new TextWriterTraceListener(ApplicationSettings.Default.LogToDiskLocation); Trace.Listeners.Add(listener); } #if !DEBUG // Initialise the watchdog if (!_screenSaver) { try { // Update/write the status.json file File.WriteAllText(System.IO.Path.Combine(ApplicationSettings.Default.LibraryPath, "status.json"), "{\"lastActivity\":\"" + DateTime.Now.ToString() + "\"}"); // Start watchdog WatchDogManager.Start(); } catch (Exception e) { Trace.WriteLine(new LogMessage("MainForm - InitializeXibo", "Cannot start watchdog. E = " + e.Message), LogType.Error.ToString()); } } #endif // An empty set of overlay regions //_overlays = new Collection<Region>(); Trace.WriteLine(new LogMessage("MainForm", "Client Initialised"), LogType.Info.ToString()); }
/// <summary> /// Initialise Xibo /// </summary> private void InitializeXibo() { // Set the title Title = ApplicationSettings.GetProductNameFromAssembly(); // Check the directories exist if (!Directory.Exists(ApplicationSettings.Default.LibraryPath + @"\backgrounds\")) { // Will handle the create of everything here Directory.CreateDirectory(ApplicationSettings.Default.LibraryPath + @"\backgrounds"); } // Default the XmdsConnection ApplicationSettings.Default.XmdsLastConnection = DateTime.MinValue; // Bind to the resize event Microsoft.Win32.SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged; // Show in taskbar ShowInTaskbar = ApplicationSettings.Default.ShowInTaskbar; // Events Loaded += MainWindow_Loaded; Closing += MainForm_FormClosing; ContentRendered += MainForm_Shown; // Trace listener for Client Info ClientInfoTraceListener clientInfoTraceListener = new ClientInfoTraceListener { Name = "ClientInfo TraceListener" }; Trace.Listeners.Add(clientInfoTraceListener); // Log to disk? if (!string.IsNullOrEmpty(ApplicationSettings.Default.LogToDiskLocation)) { TextWriterTraceListener listener = new TextWriterTraceListener(ApplicationSettings.Default.LogToDiskLocation); Trace.Listeners.Add(listener); } #if !DEBUG // Initialise the watchdog if (!_screenSaver) { try { // Update/write the status.json file ClientInfo.Instance.UpdateStatusMarkerFile(); // Start watchdog WatchDogManager.Start(); } catch (Exception e) { Trace.WriteLine(new LogMessage("MainForm - InitializeXibo", "Cannot start watchdog. E = " + e.Message), LogType.Error.ToString()); } } #endif // An empty set of overlays _overlays = new Collection <Layout>(); // Switch to TLS 2.1 ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12; // Initialise the database StatManager.Instance.InitDatabase(); Trace.WriteLine(new LogMessage("MainForm", "Player Initialised"), LogType.Info.ToString()); }
private void InitializeXibo() { Thread.CurrentThread.Name = "UI Thread"; // Check the directories exist if (!Directory.Exists(ApplicationSettings.Default.LibraryPath) || !Directory.Exists(ApplicationSettings.Default.LibraryPath + @"\backgrounds\")) { // Will handle the create of everything here Directory.CreateDirectory(ApplicationSettings.Default.LibraryPath + @"\backgrounds"); } // Default the XmdsConnection ApplicationSettings.Default.XmdsLastConnection = DateTime.MinValue; // Override the default size if necessary if (ApplicationSettings.Default.SizeX != 0) { _clientSize = new Size((int)ApplicationSettings.Default.SizeX, (int)ApplicationSettings.Default.SizeY); Size = _clientSize; WindowState = FormWindowState.Normal; Location = new Point((int)ApplicationSettings.Default.OffsetX, (int)ApplicationSettings.Default.OffsetY); StartPosition = FormStartPosition.Manual; } else { _clientSize = SystemInformation.PrimaryMonitorSize; ApplicationSettings.Default.SizeX = _clientSize.Width; ApplicationSettings.Default.SizeY = _clientSize.Height; } // Show in taskbar ShowInTaskbar = ApplicationSettings.Default.ShowInTaskbar; // Setup the proxy information OptionForm.SetGlobalProxy(); _statLog = new StatLog(); this.FormClosing += new FormClosingEventHandler(MainForm_FormClosing); this.Shown += new EventHandler(MainForm_Shown); // Create the info form _clientInfoForm = new ClientInfo(); _clientInfoForm.Hide(); // Define the hotkey Keys key; try { key = (Keys)Enum.Parse(typeof(Keys), ApplicationSettings.Default.ClientInformationKeyCode.ToUpper()); } catch { // Default back to I key = Keys.I; } KeyStore.Instance.AddKeyDefinition("ClientInfo", key, ((ApplicationSettings.Default.ClientInfomationCtrlKey) ? Keys.Control : Keys.None)); // Register a handler for the key event KeyStore.Instance.KeyPress += Instance_KeyPress; // Trace listener for Client Info ClientInfoTraceListener clientInfoTraceListener = new ClientInfoTraceListener(_clientInfoForm); clientInfoTraceListener.Name = "ClientInfo TraceListener"; Trace.Listeners.Add(clientInfoTraceListener); // Log to disk? if (!string.IsNullOrEmpty(ApplicationSettings.Default.LogToDiskLocation)) { TextWriterTraceListener listener = new TextWriterTraceListener(ApplicationSettings.Default.LogToDiskLocation); Trace.Listeners.Add(listener); } #if !DEBUG // Initialise the watchdog if (!_screenSaver) { try { // Update/write the status.json file File.WriteAllText(Path.Combine(ApplicationSettings.Default.LibraryPath, "status.json"), "{\"lastActivity\":\"" + DateTime.Now.ToString() + "\"}"); // Start watchdog WatchDogManager.Start(); } catch (Exception e) { Trace.WriteLine(new LogMessage("MainForm - InitializeXibo", "Cannot start watchdog. E = " + e.Message), LogType.Error.ToString()); } } #endif Trace.WriteLine(new LogMessage("MainForm", "Client Initialised"), LogType.Info.ToString()); }