public void Launch(AddInHost host) { // uncomment to debug #if DEBUG host.MediaCenterEnvironment.Dialog("Attach debugger and hit ok", "debug", DialogButtons.Ok, 100, true); #endif var config = GetConfig(); if (config == null) { Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication(); return; } Kernel.Init(config); Environment.CurrentDirectory = ApplicationPaths.AppConfigPath; try { SetupStylesMcml(host); SetupFontsMcml(host); } catch (Exception ex) { host.MediaCenterEnvironment.Dialog(ex.Message, "Customisation Error", DialogButtons.Ok, 100, true); Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication(); return; } Application app = new Application(new MyHistoryOrientedPageSession(), host); app.GoToMenu(); }
public void Launch(AddInHost host) { // uncomment to debug #if DEBUG host.MediaCenterEnvironment.Dialog("Attach debugger and hit ok", "debug", DialogButtons.Ok, 100, true); #endif var config = GetConfig(); if (config == null) { host.ApplicationContext.CloseApplication(); return; } //set us up for single instance host.ApplicationContext.SingleInstance = true; Environment.CurrentDirectory = ApplicationPaths.AppProgramPath; using (new Util.Profiler("Total Kernel Init")) { Kernel.Init(config); } using (new Util.Profiler("Application Init")) { App = new Application(new MyHistoryOrientedPageSession(), host); App.Init(); } Kernel.Instance.OnApplicationInitialized(); }
public Application(MyHistoryOrientedPageSession session, Microsoft.MediaCenter.Hosting.AddInHost host) { this.session = session; if (session != null) { this.session.Application = this; } singleApplicationInstance = this; }
public void Launch(AddInHost host) { // uncomment to debug #if DEBUG host.MediaCenterEnvironment.Dialog("Attach debugger and hit ok", "debug", DialogButtons.Ok, 100, true); #endif var config = GetConfig(); if (config == null) { AddInHost.Current.ApplicationContext.CloseApplication(); return; } //set us up for single instance AddInHost.Current.ApplicationContext.SingleInstance = true; Environment.CurrentDirectory = ApplicationPaths.AppProgramPath; using (new Util.Profiler("Total Kernel Init")) { Kernel.Init(config); while (!Kernel.ServerConnected) { if (!Kernel.ServerConnected) { if (host.MediaCenterEnvironment.Dialog("Could not connect to Media Browser 3 Server. Please be sure it is running on the local network.\n\nWould you like to re-try?", "Error", DialogButtons.Yes | DialogButtons.No, 100, true) != DialogResult.No) { Kernel.ConnectToServer(config); } else { AddInHost.Current.ApplicationContext.CloseApplication(); return; } } } } using (new Util.Profiler("Application Init")) { App = new Application(new MyHistoryOrientedPageSession(), host); App.Init(); } Kernel.Instance.OnApplicationInitialized(); }
public Application(MyHistoryOrientedPageSession session, Microsoft.MediaCenter.Hosting.AddInHost host) { this.session = session; if (session != null) { this.session.Application = this; } singleApplicationInstance = this; //wire up our mouseActiveHooker if enabled so we can know if the mouse is active over us if (Config.Instance.EnableMouseHook) { Kernel.Instance.MouseActiveHooker.MouseActive += new IsMouseActiveHooker.MouseActiveHandler(mouseActiveHooker_MouseActive); } //populate the config model choice ConfigModel = new Choice(); ConfigModel.Options = ConfigPanelNames; //initialize our menu manager menuManager = new MenuManager(); //initialize screen saver ScreenSaverTimer = new Timer() { AutoRepeat = true, Enabled = true, Interval = 60000 }; ScreenSaverTimer.Tick += new EventHandler(ScreenSaverTimer_Tick); }
public void Launch(AddInHost host) { // uncomment to debug #if DEBUG host.MediaCenterEnvironment.Dialog("Attach debugger and hit ok", "debug", DialogButtons.Ok, 100, true); #endif using (Mutex mutex = new Mutex(false, Kernel.MBCLIENT_MUTEX_ID)) { //set up so everyone can access var allowEveryoneRule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl, AccessControlType.Allow); var securitySettings = new MutexSecurity(); try { //don't bomb if this fails securitySettings.AddAccessRule(allowEveryoneRule); mutex.SetAccessControl(securitySettings); } catch (Exception) { //we don't want to die here and we don't have a logger yet so just go on } try { if (mutex.WaitOne(100,false)) { var config = GetConfig(); if (config == null) { Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication(); return; } Environment.CurrentDirectory = ApplicationPaths.AppConfigPath; try { CustomResourceManager.SetupStylesMcml(host); CustomResourceManager.SetupFontsMcml(host); } catch (Exception ex) { host.MediaCenterEnvironment.Dialog(ex.Message, Application.CurrentInstance.StringData("CustomErrorDial"), DialogButtons.Ok, 100, true); Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication(); return; } using (new MediaBrowser.Util.Profiler("Total Kernel Init")) { Kernel.Init(config); } using (new MediaBrowser.Util.Profiler("Application Init")) { Application app = new Application(new MyHistoryOrientedPageSession(), host); app.GoToMenu(); } mutex.ReleaseMutex(); } else { //another instance running and in initialization - just blow out of here Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication(); return; } } catch (AbandonedMutexException) { // Log the fact the mutex was abandoned in another process, it will still get acquired Logger.ReportWarning("Previous instance of core ended abnormally..."); mutex.ReleaseMutex(); } } }
// Constructor. public Updater(Application appRef) { this.appRef = appRef; }
public void Launch(AddInHost host) { // uncomment to debug #if DEBUG host.MediaCenterEnvironment.Dialog("Attach debugger and hit ok", "debug", DialogButtons.Ok, 100, true); #endif using (Mutex mutex = new Mutex(false, Kernel.MBCLIENT_MUTEX_ID)) { //set up so everyone can access var allowEveryoneRule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl, AccessControlType.Allow); var securitySettings = new MutexSecurity(); try { //don't bomb if this fails securitySettings.AddAccessRule(allowEveryoneRule); mutex.SetAccessControl(securitySettings); } catch (Exception) { //we don't want to die here and we don't have a logger yet so just go on } try { if (mutex.WaitOne(100,false)) { var config = GetConfig(); if (config == null) { AddInHost.Current.ApplicationContext.CloseApplication(); return; } Environment.CurrentDirectory = ApplicationPaths.AppProgramPath; using (new Util.Profiler("Total Kernel Init")) { Kernel.Init(config); while (!Kernel.ServerConnected) { if (!Kernel.ServerConnected) { if (host.MediaCenterEnvironment.Dialog("Could not connect to Media Browser 3 Server. Please be sure it is running on the local network.\n\nWould you like to re-try?", "Error", DialogButtons.Yes | DialogButtons.No, 100, true) != DialogResult.No) { Kernel.ConnectToServer(config); } else { AddInHost.Current.ApplicationContext.CloseApplication(); return; } } } } using (new Util.Profiler("Application Init")) { App = new Application(new MyHistoryOrientedPageSession(), host); App.Init(); } Kernel.Instance.OnApplicationInitialized(); mutex.ReleaseMutex(); } else { //another instance running and in initialization - just blow out of here Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication(); return; } } catch (AbandonedMutexException) { // Log the fact the mutex was abandoned in another process, it will still get acquired Logger.ReportWarning("Previous instance of core ended abnormally..."); mutex.ReleaseMutex(); } } }