コード例 #1
0
 internal Items(Settings settings, FileTypeCollection fileTypes)
 {
     this._Settings = settings;
     this._FileTypes = fileTypes;
 }
コード例 #2
0
        internal static void Save(Settings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException();
            }

            if (settings.IsSynchronized)
            {
                throw new ArgumentException();
            }

            using (RegistryKey Key = Registry.CurrentUser.CreateSubKey(@"Software\Goletas\ScreenCapture", RegistryKeyPermissionCheck.ReadWriteSubTree))
            {
                if (Key != null)
                {
                    Key.SetValue("IncludeCursor", settings.IncludeCursor, RegistryValueKind.DWord);
                    Key.SetValue("AlwaysOnTop", settings.AlwaysOnTop, RegistryValueKind.DWord);
                    Key.SetValue("ImageDestinations", settings.ImageDestinations, RegistryValueKind.DWord);
                    Key.SetValue("FileName", settings.FileNameFormat, RegistryValueKind.String);
                //    Key.SetValue("FileAutoNaming", settings.FileAutoNaming, RegistryValueKind.DWord);
                    Key.SetValue("WorkingDirectory", settings.WorkingDirectory, RegistryValueKind.String);
                    Key.SetValue("UseExternalApp", settings.UseExternalApp, RegistryValueKind.DWord);
                    Key.SetValue("ExternalApp", settings.ExternalApp, RegistryValueKind.String);
                    Key.SetValue("UseFileOverwrite", settings.UseFileOverwrite, RegistryValueKind.DWord);
                    Key.SetValue("FileType", settings.FileType.FormatId.ToString("B"), RegistryValueKind.String);
                }
            }

            using (RegistryKey Key = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", RegistryKeyPermissionCheck.ReadWriteSubTree))
            {
                if (Key != null)
                {
                    if (settings.AutoStartup)
                    {
                        Key.SetValue("Goletas.ScreenCapture", "\"" + System.Windows.Forms.Application.ExecutablePath + "\" background", RegistryValueKind.String);
                    }
                    else
                    {
                        Key.DeleteValue("Goletas.ScreenCapture", false);
                    }
                }
            }
        }
コード例 #3
0
        private static Items Load()
        {
            Settings settings = new Settings();
            FileType[] supportedTypes = new FileType[] { new PngFileType(), new BmpFileType(), new TiffFileType(), new JpegFileType(), new GifFileType() };
            FileTypeCollection fileTypes = new FileTypeCollection(supportedTypes);

            using (RegistryKey Key = Registry.CurrentUser.OpenSubKey(@"Software\Goletas\ScreenCapture", RegistryKeyPermissionCheck.ReadSubTree))
            {
                if (Key != null)
                {
                    try
                    {
                        for (int i = 0; i < supportedTypes.Length; i++)
                        {
                            if (supportedTypes[i].IsEditable)
                            {
                                supportedTypes[i].Deserialize(Key.GetValue(supportedTypes[i].FormatId.ToString("B")) as byte[]);
                            }
                        }

                        settings.IncludeCursor = Settings.Int32ToBoolTrueOnFail(Key.GetValue("IncludeCursor"));
                        settings.AlwaysOnTop = Settings.Int32ToBoolFalseOnFail(Key.GetValue("AlwaysOnTop"));
                        if (settings.UpdateFileNameFormat(Key.GetValue("FileName") as string))
                        {
                            settings.ImageDestinations = Settings.ToImageDestinations(Key.GetValue("ImageDestinations"));
                        }
                        settings.WorkingDirectory = Key.GetValue("WorkingDirectory") as string;
                        settings.UseExternalApp = Settings.Int32ToBoolFalseOnFail(Key.GetValue("UseExternalApp"));
                        settings.ExternalApp = Key.GetValue("ExternalApp") as string;
                        settings.UseFileOverwrite = Settings.Int32ToBoolFalseOnFail(Key.GetValue("UseFileOverwrite"));

                        string FormatId = Key.GetValue("FileType") as string;
                        int TypeIndex;

                        if (Settings.IsGuid(FormatId) && ((TypeIndex = fileTypes.IndexOf(new Guid(FormatId))) >= 0))
                        {
                            settings.FileType = fileTypes[TypeIndex];
                        }
                    }
                    catch (IOException)
                    {

                    }
                }
            }

            using (RegistryKey Key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", RegistryKeyPermissionCheck.ReadSubTree))
            {
                if (Key != null)
                {
                    try
                    {
                        settings.AutoStartup = ((Key.GetValue("Goletas.ScreenCapture") as string) == ("\"" + System.Windows.Forms.Application.ExecutablePath + "\" background"));
                    }
                    catch (IOException)
                    {

                    }
                }
            }

            if (settings.FileType == null)
            {
                settings.FileType = fileTypes[0];
            }

            if (!Settings.IsValidPath(settings.WorkingDirectory))
            {
                settings.WorkingDirectory = null;
                settings.ImageDestinations = ImageDestinations.Clipboard;
            }

            if (!Settings.IsValidPathToExecutable(settings.ExternalApp))
            {
                settings.ExternalApp = null;
                settings.UseExternalApp = false;
            }

            return new Items(Settings.Synchronized(settings), fileTypes);
        }
コード例 #4
0
ファイル: Settings.cs プロジェクト: Goletas/screencapture
            public override void FromSettings(Settings source)
            {
                if (source == null)
                {
                    throw new ArgumentNullException();
                }

                if (!ReferenceEquals(this, source))
                {
                    lock (this._SyncRoot)
                    {
                        int counter = this._Settings._Counter;
                        this._Settings = source.Clone();
                        this._Settings._Counter = counter;
                    }
                }
            }
コード例 #5
0
ファイル: SettingsForm.cs プロジェクト: Goletas/screencapture
        internal SettingsForm()
        {
            this._Settings = Configuration.Current.Settings.Clone();
            this._CurrentFormatId = this._Settings.FileType.FormatId;

            this._Cancel = new System.Windows.Forms.Button();
            this._OK = new System.Windows.Forms.Button();
            this._Apply = new System.Windows.Forms.Button();
            this._FileTypeSettings = new System.Windows.Forms.Button();
            this._Pages = new System.Windows.Forms.TabControl();
            this._GeneralPage = new System.Windows.Forms.TabPage();
            this._HowToUseLabel = new System.Windows.Forms.Label();
            this._PreferencesPage = new System.Windows.Forms.TabPage();
            this._AlwaysOnTop = new System.Windows.Forms.CheckBox();
            this._AppGroup = new Goletas.ScreenCapture.GroupLabel();
            this._AutoStartup = new System.Windows.Forms.CheckBox();
            this._HotKeysGroup = new Goletas.ScreenCapture.GroupLabel();
            this._VirtualScreenKeySelector = new System.Windows.Forms.ComboBox();
            this._VirtualScreenKey = new System.Windows.Forms.Label();
            this._SettingsKeySelector = new System.Windows.Forms.ComboBox();
            this._SettingsKey = new System.Windows.Forms.Label();
            this._ForegroundWindowKeySelector = new System.Windows.Forms.ComboBox();
            this._ForegroundWindowKey = new System.Windows.Forms.Label();
            this._CurrentScreenKeySelector = new System.Windows.Forms.ComboBox();
            this._CurrentScreenKey = new System.Windows.Forms.Label();
            this._ImageCompositionGroup = new Goletas.ScreenCapture.GroupLabel();
            this._IncludeCursor = new System.Windows.Forms.CheckBox();
            this._DestinationPage = new System.Windows.Forms.TabPage();
            this._FileGroup = new Goletas.ScreenCapture.GroupLabel();
            this._WorkingDirectorySelector = new System.Windows.Forms.Button();
            this._WorkingDirectoryPath = new System.Windows.Forms.TextBox();
            this._WorkingDirectory = new System.Windows.Forms.Label();
            this._ExternalAppSelector = new System.Windows.Forms.Button();
            this._UseExternalApp = new System.Windows.Forms.CheckBox();
            this._ExternalAppPath = new System.Windows.Forms.TextBox();
            this._FileNameSelector = new System.Windows.Forms.TextBox();
            this._FileName = new System.Windows.Forms.Label();
            this._UseFileOverwrite = new System.Windows.Forms.CheckBox();
            this._ImageDestinationGroup = new Goletas.ScreenCapture.GroupLabel();
            this._ImageDestinationSelector = new System.Windows.Forms.ComboBox();
            this._ImagePage = new System.Windows.Forms.TabPage();
            this._FileFormatGroup = new Goletas.ScreenCapture.GroupLabel();
            this._FileFormatSelector = new System.Windows.Forms.ComboBox();
            this._AboutPage = new System.Windows.Forms.TabPage();
            this._LegalInfo = new System.Windows.Forms.Label();
            this._RemoveApp = new System.Windows.Forms.LinkLabel();

            this.SuspendLayout();
            this._Pages.SuspendLayout();
            this._GeneralPage.SuspendLayout();
            this._PreferencesPage.SuspendLayout();
            this._DestinationPage.SuspendLayout();
            this._ImagePage.SuspendLayout();
            this._AboutPage.SuspendLayout();
            this._ImageCompositionGroup.SuspendLayout();
            this._HotKeysGroup.SuspendLayout();
            this._AppGroup.SuspendLayout();
            this._ImageDestinationGroup.SuspendLayout();
            this._FileGroup.SuspendLayout();
            this._FileFormatGroup.SuspendLayout();

            this._Pages.Controls.Add(this._GeneralPage);
            this._Pages.Controls.Add(this._PreferencesPage);
            this._Pages.Controls.Add(this._DestinationPage);
            this._Pages.Controls.Add(this._ImagePage);
            this._Pages.Controls.Add(this._AboutPage);
            this._Pages.Bounds = new System.Drawing.Rectangle(6, 6, 320, 348);
            this._Pages.SelectedIndex = 0;

            this._GeneralPage.Controls.Add(this._HowToUseLabel);
            this._GeneralPage.Text = ApplicationManager.GetString("General.Page");
            this._GeneralPage.UseVisualStyleBackColor = true;

            this._PreferencesPage.Controls.Add(this._ImageCompositionGroup);
            this._PreferencesPage.Controls.Add(this._HotKeysGroup);
            this._PreferencesPage.Controls.Add(this._AppGroup);
            this._PreferencesPage.Controls.Add(this._RemoveApp);
            this._PreferencesPage.Text = ApplicationManager.GetString("Preferences.Page");
            this._PreferencesPage.UseVisualStyleBackColor = true;

            this._DestinationPage.Controls.Add(this._ImageDestinationGroup);
            this._DestinationPage.Controls.Add(this._FileGroup);
            this._DestinationPage.Text = ApplicationManager.GetString("Destination.Page");
            this._DestinationPage.UseVisualStyleBackColor = true;

            this._ImagePage.Controls.Add(this._FileFormatGroup);
            this._ImagePage.Text = ApplicationManager.GetString("Image.Page");
            this._ImagePage.UseVisualStyleBackColor = true;

            this._AboutPage.Controls.Add(this._LegalInfo);
            this._AboutPage.Text = ApplicationManager.GetString("About.Page");
            this._AboutPage.UseVisualStyleBackColor = true;

            this._HowToUseLabel.Bounds = new System.Drawing.Rectangle(2, 8, 308, 308);

            if (Environment.OSVersion.Version.Major >= 6) // Vista and later
            {
                this._HowToUseLabel.Text = ApplicationManager.GetString("HowToUse") + Environment.NewLine + Environment.NewLine + ApplicationManager.GetString("OsNotFullySupported");
            }
            else
            {
                this._HowToUseLabel.Text = ApplicationManager.GetString("HowToUse");
            }

            this._HowToUseLabel.UseMnemonic = false;

            this._ImageCompositionGroup.Controls.Add(this._IncludeCursor);
            this._ImageCompositionGroup.Bounds = new System.Drawing.Rectangle(2, 8, 308, 44);
            this._ImageCompositionGroup.Text = ApplicationManager.GetString("ImageComposition.Group");

            this._HotKeysGroup.Controls.Add(this._CurrentScreenKey);
            this._HotKeysGroup.Controls.Add(this._CurrentScreenKeySelector);
            this._HotKeysGroup.Controls.Add(this._VirtualScreenKey);
            this._HotKeysGroup.Controls.Add(this._VirtualScreenKeySelector);
            this._HotKeysGroup.Controls.Add(this._ForegroundWindowKey);
            this._HotKeysGroup.Controls.Add(this._ForegroundWindowKeySelector);
            this._HotKeysGroup.Controls.Add(this._SettingsKey);
            this._HotKeysGroup.Controls.Add(this._SettingsKeySelector);
            this._HotKeysGroup.Bounds = new System.Drawing.Rectangle(2, 64, 308, 116);
            this._HotKeysGroup.Text = ApplicationManager.GetString("HotKeys.Group");

            this._AppGroup.Controls.Add(this._AutoStartup);
            this._AppGroup.Controls.Add(this._AlwaysOnTop);
            this._AppGroup.Bounds = new System.Drawing.Rectangle(2, 188, 308, 64);
            this._AppGroup.Text = ApplicationManager.GetString("App.Group");

            this._RemoveApp.Bounds = new System.Drawing.Rectangle(2, 272, 308, 36);
            this._RemoveApp.Text = ApplicationManager.GetString("RemoveApp");
            this._RemoveApp.LinkArea = new System.Windows.Forms.LinkArea(ApplicationManager.GetInt32("RemoveApp.Start"), ApplicationManager.GetInt32("RemoveApp.Length"));
            this._RemoveApp.DisabledLinkColor = System.Drawing.SystemColors.GrayText;
            this._RemoveApp.VisitedLinkColor = System.Drawing.SystemColors.HotTrack;
            this._RemoveApp.ActiveLinkColor = System.Drawing.SystemColors.HotTrack;
            this._RemoveApp.LinkColor = System.Drawing.SystemColors.HotTrack;
            this._RemoveApp.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(OnRemoveApp);
            SetHelp(this._RemoveApp, "RemoveApp.Help");

            this._IncludeCursor.Bounds = new System.Drawing.Rectangle(14, 20, 280, 18);
            this._IncludeCursor.Text = ApplicationManager.GetString("IncludeCursor");
            this._IncludeCursor.Checked = this._Settings.IncludeCursor;
            this._IncludeCursor.CheckedChanged += new System.EventHandler(this.OnIncludeCursorChanged);
            SetHelp(this._IncludeCursor, "IncludeCursor.Help");

            this._CurrentScreenKey.Bounds = new System.Drawing.Rectangle(14, 16, 134, 20);
            this._CurrentScreenKey.Text = ApplicationManager.GetString("CurrentScreenKey");
            this._CurrentScreenKey.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;

            this._CurrentScreenKeySelector.Bounds = new System.Drawing.Rectangle(14, 36, 134, 21);
            this._CurrentScreenKeySelector.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this._CurrentScreenKeySelector.Items.Add(ApplicationManager.GetString("PrintScreen.Item"));
            this._CurrentScreenKeySelector.SelectedIndex = 0;
            SetHelp(this._CurrentScreenKeySelector, "CurrentScreenKey.Help");

            this._VirtualScreenKey.Bounds = new System.Drawing.Rectangle(160, 16, 134, 20);
            this._VirtualScreenKey.Text = ApplicationManager.GetString("VirtualScreenKey");
            this._VirtualScreenKey.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;

            this._VirtualScreenKeySelector.Bounds = new System.Drawing.Rectangle(160, 36, 134, 21);
            this._VirtualScreenKeySelector.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this._VirtualScreenKeySelector.Items.Add(ApplicationManager.GetString("CtrlPrintScreen.Item"));
            this._VirtualScreenKeySelector.SelectedIndex = 0;
            SetHelp(this._VirtualScreenKeySelector, "VirtualScreenKey.Help");

            this._ForegroundWindowKey.Bounds = new System.Drawing.Rectangle(14, 64, 134, 20);
            this._ForegroundWindowKey.Text = ApplicationManager.GetString("ForegroundWindowKey");
            this._ForegroundWindowKey.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;

            this._ForegroundWindowKeySelector.Bounds = new System.Drawing.Rectangle(14, 84, 134, 21);
            this._ForegroundWindowKeySelector.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this._ForegroundWindowKeySelector.Items.Add(ApplicationManager.GetString("ShiftPrintScreen.Item"));
            this._ForegroundWindowKeySelector.SelectedIndex = 0;
            SetHelp(this._ForegroundWindowKeySelector, "ForegroundWindowKey.Help");

            this._SettingsKey.Bounds = new System.Drawing.Rectangle(160, 64, 134, 20);
            this._SettingsKey.Text = ApplicationManager.GetString("SettingsKey");
            this._SettingsKey.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;

            this._SettingsKeySelector.Bounds = new System.Drawing.Rectangle(160, 84, 134, 21);
            this._SettingsKeySelector.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this._SettingsKeySelector.Items.Add(ApplicationManager.GetString("AltPrintScreen.Item"));
            this._SettingsKeySelector.SelectedIndex = 0;
            SetHelp(this._SettingsKeySelector, "SettingsKey.Help");

            this._AutoStartup.Bounds = new System.Drawing.Rectangle(14, 20, 280, 18);
            this._AutoStartup.Text = ApplicationManager.GetString("AutoStartup");
            this._AutoStartup.Checked = this._Settings.AutoStartup;
            this._AutoStartup.CheckedChanged += new System.EventHandler(this.OnAutoStartupChanged);
            SetHelp(this._AutoStartup, "AutoStartup.Help");

            this._AlwaysOnTop.Bounds = new System.Drawing.Rectangle(14, 40, 280, 18);
            this._AlwaysOnTop.Text = ApplicationManager.GetString("AlwaysOnTop");
            this._AlwaysOnTop.Checked = this._Settings.AlwaysOnTop;
            this._AlwaysOnTop.CheckedChanged += new System.EventHandler(this.OnAlwaysOnTopChanged);
            SetHelp(this._AlwaysOnTop, "AlwaysOnTop.Help");

            this._ImageDestinationGroup.Controls.Add(this._ImageDestinationSelector);
            this._ImageDestinationGroup.Bounds = new System.Drawing.Rectangle(2, 8, 308, 48);
            this._ImageDestinationGroup.Text = ApplicationManager.GetString("ImageDestination.Group");

            this._FileGroup.Controls.Add(this._WorkingDirectory);
            this._FileGroup.Controls.Add(this._WorkingDirectoryPath);
            this._FileGroup.Controls.Add(this._WorkingDirectorySelector);
            this._FileGroup.Controls.SetChildIndex(this._WorkingDirectorySelector, 0);
            this._FileGroup.Controls.Add(this._FileName);
            this._FileGroup.Controls.Add(this._FileNameSelector);
            this._FileGroup.Controls.Add(this._UseFileOverwrite);
            this._FileGroup.Controls.Add(this._UseExternalApp);
            this._FileGroup.Controls.Add(this._ExternalAppPath);
            this._FileGroup.Controls.Add(this._ExternalAppSelector);
            this._FileGroup.Controls.SetChildIndex(this._ExternalAppSelector, 0);
            this._FileGroup.Bounds = new System.Drawing.Rectangle(2, 64, 308, 220);
            this._FileGroup.Text = ApplicationManager.GetString("File.Group");
            this._FileGroup.Enabled = ((this._Settings.ImageDestinations & ImageDestinations.File) == ImageDestinations.File);

            this._ImageDestinationSelector.Bounds = new System.Drawing.Rectangle(14, 20, 280, 21);
            this._ImageDestinationSelector.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this._ImageDestinationSelector.Items.AddRange(new object[] { ApplicationManager.GetString("Clipboard.Item"), ApplicationManager.GetString("File.Item"), ApplicationManager.GetString("ClipboardAndFile.Item") });
            this._ImageDestinations = this._Settings.ImageDestinations;
            this._ImageDestinationSelector.SelectedIndexChanged += new System.EventHandler(OnImageDestinationChanged);
            SetHelp(this._ImageDestinationSelector, "ImageDestination.Help");

            this._WorkingDirectory.Bounds = new System.Drawing.Rectangle(14, 16, 280, 20);
            this._WorkingDirectory.Text = ApplicationManager.GetString("WorkingDirectory");
            this._WorkingDirectory.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;

            this._WorkingDirectoryPath.Bounds = new System.Drawing.Rectangle(14, 36, 248, 20);
            this._WorkingDirectoryPath.MaxLength = NativeMethods.MAX_PATH - 1; // one for null terminator
            this._WorkingDirectoryPath.Text = this._Settings.WorkingDirectory;
            this._WorkingDirectoryPath.TextChanged += new System.EventHandler(this.OnWorkingDirectoryChanged);
            NativeMethods.SetTextualCue(this._WorkingDirectoryPath, ApplicationManager.GetString("WorkingDirectory.Cue"));
            SetHelp(this._WorkingDirectoryPath, "WorkingDirectory.Help");

            this._WorkingDirectorySelector.Bounds = new System.Drawing.Rectangle(268, 34, 28, 24);
            this._WorkingDirectorySelector.Text = ApplicationManager.GetString("Select");
            this._WorkingDirectorySelector.Click += new System.EventHandler(this.OnSelectWorkingDirectory);
            SetHelp(this._WorkingDirectorySelector, "SelectWorkingDirectory.Help");

            this._FileName.Bounds = new System.Drawing.Rectangle(14, 64, 280, 20);
            this._FileName.Text = ApplicationManager.GetString("FileName");
            this._FileName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;

            this._FileNameSelector.Bounds = new System.Drawing.Rectangle(14, 84, 280, 20);
            this._FileNameSelector.MaxLength = NativeMethods.MAX_PATH - 4;
            this._FileNameSelector.Text = this._Settings.FileNameFormat;
            this._FileNameSelector.TextChanged += new System.EventHandler(this.OnFileNameChanged);
            NativeMethods.SetTextualCue(this._FileNameSelector, ApplicationManager.GetString("FileName.Cue"));
            SetHelp(this._FileNameSelector, "FileName.Help");

            this._UseFileOverwrite.Bounds = new System.Drawing.Rectangle(14, 116, 280, 18);
            this._UseFileOverwrite.Text = ApplicationManager.GetString("UseFileOverwrite");
            this._UseFileOverwrite.Checked = this._Settings.UseFileOverwrite;
            this._UseFileOverwrite.CheckedChanged += new System.EventHandler(this.OnUseFileOverwriteChanged);
            SetHelp(this._UseFileOverwrite, "UseFileOverwrite.Help");

            this._UseExternalApp.Bounds = new System.Drawing.Rectangle(14, 136, 280, 18);
            this._UseExternalApp.Text = ApplicationManager.GetString("UseExternalApp");
            this._UseExternalApp.Checked = this._Settings.UseExternalApp;
            this._UseExternalApp.CheckedChanged += new System.EventHandler(this.OnUseExternalAppChanged);
            SetHelp(this._UseExternalApp, "UseExternalApp.Help");

            this._ExternalAppPath.Bounds = new System.Drawing.Rectangle(14, 154, 248, 20);
            this._ExternalAppPath.MaxLength = NativeMethods.MAX_PATH - 1; // one for null terminator
            this._ExternalAppPath.Text = this._Settings.ExternalApp;
            this._ExternalAppPath.Enabled = this._Settings.UseExternalApp;
            this._ExternalAppPath.TextChanged += new System.EventHandler(this.OnExternalAppChanged);
            NativeMethods.SetTextualCue(this._ExternalAppPath, ApplicationManager.GetString("ExternalApp.Cue"));
            SetHelp(this._ExternalAppPath, "ExternalApp.Help");

            this._ExternalAppSelector.Bounds = new System.Drawing.Rectangle(268, 152, 28, 24);
            this._ExternalAppSelector.Text = ApplicationManager.GetString("Select");
            this._ExternalAppSelector.Enabled = this._Settings.UseExternalApp;
            this._ExternalAppSelector.Click += new System.EventHandler(this.OnSelectExternalApp);
            SetHelp(this._ExternalAppSelector, "SelectExternalApp.Help");

            this._FileFormatGroup.Controls.Add(this._FileFormatSelector);
            this._FileFormatGroup.Controls.Add(this._FileTypeSettings);
            this._FileFormatGroup.Bounds = new System.Drawing.Rectangle(2, 8, 308, 48);
            this._FileFormatGroup.Text = ApplicationManager.GetString("FileFormat.Group");
            this._FileFormatGroup.Enabled = ((this._Settings.ImageDestinations & ImageDestinations.File) == ImageDestinations.File);

            this._FileFormatSelector.Bounds = new System.Drawing.Rectangle(14, 20, 248, 21);
            this._FileFormatSelector.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this._FileFormatSelector.Items.AddRange(Configuration.Current.FileTypes.GetDisplayNames());
            this._FileFormatSelector.SelectedIndex = Configuration.Current.FileTypes.IndexOf(this._Settings.FileType.FormatId);
            this._FileFormatSelector.SelectedIndexChanged += new System.EventHandler(OnFileFormatChanged);
            SetHelp(this._FileFormatSelector, "FileFormat.Help");

            this._FileTypeSettings.Bounds = new System.Drawing.Rectangle(268, 18, 28, 24);
            this._FileTypeSettings.Text = ApplicationManager.GetString("Select");
            this._FileTypeSettings.UseVisualStyleBackColor = true;
            this._FileTypeSettings.Enabled = this._Settings.FileType.IsEditable;
            this._FileTypeSettings.Click += new System.EventHandler(OnChangeFileTypeSettings);
            SetHelp(this._FileTypeSettings, "FileType.Help");

            this._LegalInfo.Bounds = new System.Drawing.Rectangle(2, 8, 308, 308);
            this._LegalInfo.Text = ApplicationManager.ProductFullName + Environment.NewLine + ApplicationManager.LegalInfo;
            this._LegalInfo.UseMnemonic = false;

            this._OK.Bounds = new System.Drawing.Rectangle(92, 360, 74, 24);
            this._OK.DialogResult = System.Windows.Forms.DialogResult.OK;
            this._OK.Text = ApplicationManager.GetString("OK");
            this._OK.UseVisualStyleBackColor = true;
            this._OK.Click += new System.EventHandler(this.OnOK);
            SetHelp(this._OK, "AppOK.Help");

            this._Cancel.Bounds = new System.Drawing.Rectangle(172, 360, 74, 24);
            this._Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this._Cancel.Text = ApplicationManager.GetString("Cancel");
            this._Cancel.UseVisualStyleBackColor = true;
            this._Cancel.Click += new System.EventHandler(this.OnCancel);
            SetHelp(this._Cancel, "AppCancel.Help");

            this._Apply.Bounds = new System.Drawing.Rectangle(252, 360, 74, 24);
            this._Apply.Text = ApplicationManager.GetString("Apply");
            this._Apply.UseVisualStyleBackColor = true;
            this._Apply.Enabled = false;
            this._Apply.Click += new System.EventHandler(this.OnApply);
            SetHelp(this._Apply, "AppApply.Help");

            this.Controls.Add(this._OK);
            this.Controls.Add(this._Cancel);
            this.Controls.Add(this._Apply);
            this.Controls.Add(this._Pages);
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(332, 392);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.HelpButton = true;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.ShowInTaskbar = false;

            this.ShowIcon = false;
            this.Icon = System.Drawing.Icon.FromHandle(NativeMethods.GetApplicationIcon());

            #if DEBUG
            this.Text = ApplicationManager.ProductName + " Debug Build";
            #else
            this.Text = ApplicationManager.ProductName;
            #endif

            this._FileFormatGroup.ResumeLayout(false);
            this._FileGroup.ResumeLayout(false);
            this._ImageDestinationGroup.ResumeLayout(false);
            this._AppGroup.SuspendLayout();
            this._HotKeysGroup.ResumeLayout(false);
            this._ImageCompositionGroup.ResumeLayout(false);
            this._AboutPage.ResumeLayout(false);
            this._ImagePage.ResumeLayout(false);
            this._DestinationPage.ResumeLayout(false);
            this._PreferencesPage.ResumeLayout(false);
            this._GeneralPage.ResumeLayout(false);
            this._Pages.ResumeLayout(false);
            this.ResumeLayout(false);
        }
コード例 #6
0
ファイル: Settings.cs プロジェクト: Goletas/screencapture
        private static bool UpdateFileNameFormat(string format, Settings settings)
        {
            if (format != null && format.Length != 0)
            {
                FileNamePattern pattern = FileNamePattern.None;
                string name = format;

                if (name.Contains("<counter>"))
                {
                    pattern |= FileNamePattern.Counter;
                    name = format.Replace("<counter>", "0");
                }

                if (name.Contains("<yyyy>"))
                {
                    pattern |= FileNamePattern.Year;
                    name = name.Replace("<yyyy>", "0000");
                }

                if (name.Contains("<MM>"))
                {
                    pattern |= FileNamePattern.Month;
                    name = name.Replace("<MM>", "00");
                }

                if (name.Contains("<dd>"))
                {
                    pattern |= FileNamePattern.Day;
                    name = name.Replace("<dd>", "00");
                }

                if (name.Contains("<hh>"))
                {
                    pattern |= FileNamePattern.Hour;
                    name = name.Replace("<hh>", "00");
                }

                if (name.Contains("<mm>"))
                {
                    pattern |= FileNamePattern.Minute;
                    name = name.Replace("<mm>", "00");
                }

                if (name.Contains("<ss>"))
                {
                    pattern |= FileNamePattern.Second;
                    name = name.Replace("<ss>", "00");
                }

                if (((pattern != FileNamePattern.None) && Settings.IsValidFileName(name)) || Settings.IsValidFileName(format))
                {
                    if (settings != null)
                    {
                        settings._FileNameFormat = format;
                        settings._FileNamePattern = pattern;
                    }

                    return true;
                }
            }

            return false;
        }
コード例 #7
0
ファイル: Settings.cs プロジェクト: Goletas/screencapture
 internal __Settings(Settings settings)
 {
     this._SyncRoot = new object();
     this._Settings = settings;
 }
コード例 #8
0
ファイル: Settings.cs プロジェクト: Goletas/screencapture
 /// <summary>
 /// Wrapps the supplied <paramref name="settings"/> into the equivalent
 /// class that is safe to share between multiple threads.
 /// </summary>
 /// <param name="settings">
 /// The object to synchronize.
 /// </param>
 /// <returns>
 /// The thread safe wrapper of the <see cref="Settings"/> class.
 /// </returns>
 internal static Settings Synchronized(Settings settings)
 {
     return new __Settings(settings);
 }
コード例 #9
0
ファイル: Settings.cs プロジェクト: Goletas/screencapture
        public virtual void FromSettings(Settings source)
        {
            if (source == null)
            {
                throw new ArgumentNullException();
            }

            if (!ReferenceEquals(this, source))
            {
                this._FileType = source._FileType.Clone();
                this._ImageDestinations = source._ImageDestinations;
                this._WorkingDirectory = source._WorkingDirectory;
                this._AlwaysOnTop = source._AlwaysOnTop;
                this._AutoStartup = source._AutoStartup;
                this._UseExternalApp = source._UseExternalApp;
                this._ExternalApp = source._ExternalApp;
                this._UseFileOverwrite = source._UseFileOverwrite;
                this._IncludeCursor = source._IncludeCursor;
                this._FileNameFormat = source._FileNameFormat;
                this._FileNamePattern = source._FileNamePattern;
            }
        }
コード例 #10
0
 internal __Settings(Settings settings)
 {
     this._SyncRoot = new object();
     this._Settings = settings;
 }
コード例 #11
0
 /// <summary>
 /// Wrapps the supplied <paramref name="settings"/> into the equivalent
 /// class that is safe to share between multiple threads.
 /// </summary>
 /// <param name="settings">
 /// The object to synchronize.
 /// </param>
 /// <returns>
 /// The thread safe wrapper of the <see cref="Settings"/> class.
 /// </returns>
 internal static Settings Synchronized(Settings settings)
 {
     return(new __Settings(settings));
 }
コード例 #12
0
        private static bool UpdateFileNameFormat(string format, Settings settings)
        {
            if (format != null && format.Length != 0)
            {
                FileNamePattern pattern = FileNamePattern.None;
                string          name    = format;

                if (name.Contains("<counter>"))
                {
                    pattern |= FileNamePattern.Counter;
                    name     = format.Replace("<counter>", "0");
                }

                if (name.Contains("<yyyy>"))
                {
                    pattern |= FileNamePattern.Year;
                    name     = name.Replace("<yyyy>", "0000");
                }

                if (name.Contains("<MM>"))
                {
                    pattern |= FileNamePattern.Month;
                    name     = name.Replace("<MM>", "00");
                }

                if (name.Contains("<dd>"))
                {
                    pattern |= FileNamePattern.Day;
                    name     = name.Replace("<dd>", "00");
                }

                if (name.Contains("<hh>"))
                {
                    pattern |= FileNamePattern.Hour;
                    name     = name.Replace("<hh>", "00");
                }

                if (name.Contains("<mm>"))
                {
                    pattern |= FileNamePattern.Minute;
                    name     = name.Replace("<mm>", "00");
                }

                if (name.Contains("<ss>"))
                {
                    pattern |= FileNamePattern.Second;
                    name     = name.Replace("<ss>", "00");
                }

                if (((pattern != FileNamePattern.None) && Settings.IsValidFileName(name)) || Settings.IsValidFileName(format))
                {
                    if (settings != null)
                    {
                        settings._FileNameFormat  = format;
                        settings._FileNamePattern = pattern;
                    }

                    return(true);
                }
            }

            return(false);
        }