public DatabaseSearchControl(Main main) { // Activates double buffering this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); this.UpdateStyles(); _main = main; InitializeComponent(); }
public TreeViewControl(Main main) { // Activates double buffering this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); this.UpdateStyles(); _main = main; InitializeComponent(); // Listen to Messages IMessageQueue queueMessage = ServiceScope.Get<IMessageBroker>().GetOrCreate("message"); queueMessage.OnMessageReceive += OnMessageReceive; LocaliseScreen(); LoadSettings(); tabControlTreeView.SelectFirstTab(); }
public DatabaseSearchControl(Main main) { _main = main; InitializeComponent(); }
private static void Main(string[] args) { // Need to reset the Working directory, since when we called via the Explorer Context menu, it'll be different Directory.SetCurrentDirectory(Application.StartupPath); // Add our Bin and Bin\Bass Directory to the Path SetPath(Path.Combine(Application.StartupPath, "Bin")); SetPath(Path.Combine(Application.StartupPath, @"Bin\Bass")); _portable = 0; _startupFolder = ""; // Process Command line Arguments foreach (string arg in args) { if (arg.ToLower().StartsWith("/folder=")) { _startupFolder = arg.Substring(8); } else if (arg.ToLower() == "/portable") { _portable = 1; } } // Read the Config file ReadConfig(); // Register Bass BassRegistration.BassRegistration.Register(); using (new ServiceScope(true)) { ILogger logger = new FileLogger("MPTagThat.log", NLog.LogLevel.Debug, _portable); ServiceScope.Add(logger); NLog.Logger log = ServiceScope.Get<ILogger>().GetLogger; log.Info("MPTagThat is starting..."); log.Info("Registering Services"); log.Debug("Registering Settings Manager"); ServiceScope.Add<ISettingsManager>(new SettingsManager()); // Set the portable Indicator ServiceScope.Get<ISettingsManager>().SetPortable(_portable); // Set the Max Songs number ServiceScope.Get<ISettingsManager>().SetMaxSongs(_maxSongs); try { logger.Level = NLog.LogLevel.FromString(Options.MainSettings.DebugLevel); } catch (ArgumentException) { Options.MainSettings.DebugLevel = "Info"; logger.Level = NLog.LogLevel.FromString(Options.MainSettings.DebugLevel); } log.Debug("Registering Localisation Services"); ServiceScope.Add<ILocalisation>(new StringManager()); log.Debug("Registering Message Broker"); ServiceScope.Add<IMessageBroker>(new MessageBroker()); log.Debug("Registering Theme Manager"); ServiceScope.Add<IThemeManager>(new ThemeManager()); log.Debug("Registering Action Handler"); ServiceScope.Add<IActionHandler>(new ActionHandler()); // Move Init of Services, which we don't need immediately to a separate thread to increase startup performance Thread initService = new Thread(DoInitService); initService.IsBackground = true; initService.Name = "InitService"; initService.Start(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { Main main = new Main(); // Set the Startup Folder we might have received via an argument, before invoking the form main.CurrentDirectory = _startupFolder; Application.Run(main); } catch (OutOfMemoryException) { GC.Collect(); MessageBox.Show(ServiceScope.Get<ILocalisation>().ToString("message", "OutOfMemory"), ServiceScope.Get<ILocalisation>().ToString("message", "Error_Title"), MessageBoxButtons.OK); log.Error("Running out of memory. Scanning aborted."); } catch (Exception ex) { MessageBox.Show(ServiceScope.Get<ILocalisation>().ToString("message", "FatalError"), ServiceScope.Get<ILocalisation>().ToString("message", "Error_Title"), MessageBoxButtons.OK); log.Error("Fatal Exception: {0}\r\n{1}", ex.Message, ex.StackTrace); } } }
private static void Main(string[] args) { // Need to reset the Working directory, since when we called via the Explorer Context menu, it'll be different Directory.SetCurrentDirectory(Application.StartupPath); // Add our Bin and Bin\Bass Directory to the Path SetPath(Path.Combine(Application.StartupPath, "Bin")); SetPath(Path.Combine(Application.StartupPath, @"Bin\Bass")); _portable = 0; _startupFolder = ""; // Process Command line Arguments foreach (string arg in args) { if (arg.ToLower().StartsWith("/folder=")) { _startupFolder = arg.Substring(8); } else if (arg.ToLower() == "/portable") { _portable = 1; } } try { // Let's see, if we already have an instance of MPTagThat open using (var mmf = MemoryMappedFile.OpenExisting("MPTagThat")) { if (_startupFolder == string.Empty) { // Don't allow a second instance of MPTagThat running return; } byte[] buffer = Encoding.Default.GetBytes(_startupFolder); var messageWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, "MPTagThat_IPC"); // Create accessor to MMF using (var accessor = mmf.CreateViewAccessor(0, buffer.Length)) { // Write to MMF accessor.WriteArray<byte>(0, buffer, 0, buffer.Length); messageWaitHandle.Set(); // End exit this instance return; } } } catch (FileNotFoundException) { // The Memorymap does not exist, so MPTagThat is not yet running } // Read the Config file ReadConfig(); // Register Bass BassRegistration.BassRegistration.Register(); using (new ServiceScope(true)) { ILogger logger = new FileLogger("MPTagThat.log", NLog.LogLevel.Debug, _portable); ServiceScope.Add(logger); NLog.Logger log = ServiceScope.Get<ILogger>().GetLogger; log.Info("MPTagThat is starting..."); log.Info("Registering Services"); log.Debug("Registering Settings Manager"); ServiceScope.Add<ISettingsManager>(new SettingsManager()); // Set the portable Indicator ServiceScope.Get<ISettingsManager>().SetPortable(_portable); // Set the Max Songs number ServiceScope.Get<ISettingsManager>().SetMaxSongs(_maxSongs); try { logger.Level = NLog.LogLevel.FromString(Options.MainSettings.DebugLevel); } catch (ArgumentException) { Options.MainSettings.DebugLevel = "Info"; logger.Level = NLog.LogLevel.FromString(Options.MainSettings.DebugLevel); } log.Debug("Registering Localisation Services"); ServiceScope.Add<ILocalisation>(new StringManager()); log.Debug("Registering Message Broker"); ServiceScope.Add<IMessageBroker>(new MessageBroker()); log.Debug("Registering Theme Manager"); ServiceScope.Add<IThemeManager>(new ThemeManager()); log.Debug("Registering Action Handler"); ServiceScope.Add<IActionHandler>(new ActionHandler()); // Move Init of Services, which we don't need immediately to a separate thread to increase startup performance Thread initService = new Thread(DoInitService); initService.IsBackground = true; initService.Name = "InitService"; initService.Start(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { _main = new Main(); // Set the Startup Folder we might have received via an argument, before invoking the form _main.CurrentDirectory = _startupFolder; Application.Run(_main); } catch (OutOfMemoryException) { GC.Collect(); MessageBox.Show(ServiceScope.Get<ILocalisation>().ToString("message", "OutOfMemory"), ServiceScope.Get<ILocalisation>().ToString("message", "Error_Title"), MessageBoxButtons.OK); log.Error("Running out of memory. Scanning aborted."); } catch (Exception ex) { MessageBox.Show(ServiceScope.Get<ILocalisation>().ToString("message", "FatalError"), ServiceScope.Get<ILocalisation>().ToString("message", "Error_Title"), MessageBoxButtons.OK); log.Error("Fatal Exception: {0}\r\n{1}", ex.Message, ex.StackTrace); } } }