Beispiel #1
0
        /// <summary>
        /// Initializer method for this class.
        /// </summary>
        public AboutDialog()
        {
            InitializeComponent();
            InitializeStyles();

            appIcon.Image = IconExtensions.ExtractFromAssembly("AppIcon", appIcon.Size).ToBitmap();

            // Set localized strings
            Text = App.LocalizationManager.GetString("About");
            appNameLabel.Text     = Application.ProductName;
            versionLabel.Text     = String.Join(".", Application.ProductVersion.Split('.').Take(2));
            descriptionLabel.Text = App.LocalizationManager.GetString("AppDescription");
            appLink.Text          = App.LocalizationManager.GetString("AppURL");
            appLink.Left          = (Width - appLink.Width) / 2;

            toolTip.SetToolTip(versionLabel, Application.ProductVersion.ToString() + Environment.NewLine + ((GuidAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(GuidAttribute), true)[0]).Value);
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            Mutex mutex = new Mutex(false, Application.ProductName + Application.ProductVersion.ToString());

            try {
                if (!mutex.WaitOne(0, false))
                {
                    // another instance of the application may be running
                    return;
                }

                if (args.Contains("/verbose"))
                {
                    ConsoleManager.Show();
                }

                Logger = new Logger();
                Logger.WriteLine(LogLevel.Informational, "{0} version {1}", Application.ProductName, Application.ProductVersion);

                Directory.CreateDirectory(AppDirectory);
                FileStream stream = new FileStream(Path.Combine(AppDirectory, Application.ProductName + ".log"), args.Contains("/appendLog") ? FileMode.Append : FileMode.OpenOrCreate);
                Logger.Streams.Add(stream);

#if !DEBUG
                AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs e) {
                    Logger.WriteLine(LogLevel.Error, "unhandled exception: {0}", e.ExceptionObject);

                    if (e.IsTerminating)
                    {
                        Logger.WriteLine(LogLevel.Warning, "CLR terminating");
                        Environment.Exit(1);
                    }
                };
#endif

                // Disable Windows XP-like text rendering
                Application.SetCompatibleTextRenderingDefault(false);

                // Initialize localization manager
                LocalizationManager = new LocalizationManager();

                // Initialize context menu
                mContextMenu = new ContextMenu(new MenuItem[] {
                    new MenuItem(LocalizationManager.GetString("TakeScreenshot"), OnScreenshotClicked)
                    {
                        DefaultItem = true
                    },
                    new MenuItem("-"),
                    new MenuItem(LocalizationManager.GetString("Preferences"), OnPreferencesClicked),
                    new MenuItem(LocalizationManager.GetString("About"), OnAboutClicked),
                    new MenuItem("-"),
                    new MenuItem(LocalizationManager.GetString("Quit"), OnQuitClicked)
                });

                // Initialize notify icon
                mNotifyIcon = new NotifyIcon()
                {
                    Icon = IconExtensions.ExtractFromAssembly("AppIcon", new Size(16, 16)),
                    Text = Application.ProductName,

                    ContextMenu = mContextMenu
                };
                mNotifyIcon.MouseClick += delegate(object sender, MouseEventArgs mouseEventArgs) {
                    if (mouseEventArgs.Button == MouseButtons.Left)
                    {
                        OnScreenshotClicked(sender, mouseEventArgs);
                    }
                    else if (mouseEventArgs.Button == MouseButtons.Middle)
                    {
                        OnQuitClicked(sender, mouseEventArgs);
                    }
                };

                mNotifyIcon.BalloonTipClosed += delegate(object balloonTipEventSender, EventArgs balloonTipEventArgs) {
                    StopIconAnimation();
                };

                SetIconFrame(0, 16, GetNotifyIconVariant());
                mNotifyIcon.Visible = true;

                RefreshThemeState();
                SystemEvents.UserPreferenceChanging += (sender, eventArgs) => {
                    if (eventArgs.Category == UserPreferenceCategory.General)
                    {
                        // just in case!
                        RefreshThemeState();
                    }
                };

                CustomActions = new Dictionary <string, CustomAction>();
                CreateActionDirectory();
                RegisterCustomActions();
                Preferences = Preferences.Load();
                RecreateLocalDirectory();
                RegisterHotKeys();
                WatchActionDirectory();

                InitializeAssetCache();

                // start application event loop
                Application.Run();
            } finally {
                if (mutex != null)
                {
                    mutex.Close();
                    mutex = null;
                }
            }
        }