private void LoadSettings()
        {
            Text = Program.Title + " - Settings";
            Icon = Resources.ShareX_Icon;

            // General
            cbShowTray.Checked                = Program.Settings.ShowTray;
            cbStartWithWindows.Checked        = ShortcutHelpers.CheckShortcut(Environment.SpecialFolder.Startup); //RegistryHelper.CheckStartWithWindows();
            cbSendToMenu.Checked              = ShortcutHelpers.CheckShortcut(Environment.SpecialFolder.SendTo);
            cbShellContextMenu.Checked        = RegistryHelpers.CheckShellContextMenu();
            cbCheckUpdates.Checked            = Program.Settings.AutoCheckUpdate;
            cbTrayIconProgressEnabled.Checked = Program.Settings.TrayIconProgressEnabled;
            cbTaskbarProgressEnabled.Enabled  = TaskbarManager.IsPlatformSupported;
            cbTaskbarProgressEnabled.Checked  = Program.Settings.TaskbarProgressEnabled;

            // Paths
            cbUseCustomUploadersConfigPath.Checked = Program.Settings.UseCustomUploadersConfigPath;
            txtCustomUploadersConfigPath.Text      = Program.Settings.CustomUploadersConfigPath;
            cbUseCustomHistoryPath.Checked         = Program.Settings.UseCustomHistoryPath;
            txtCustomHistoryPath.Text          = Program.Settings.CustomHistoryPath;
            cbUseCustomScreenshotsPath.Checked = Program.Settings.UseCustomScreenshotsPath;
            txtCustomScreenshotsPath.Text      = Program.Settings.CustomScreenshotsPath;
            txtSaveImageSubFolderPattern.Text  = Program.Settings.SaveImageSubFolderPattern;
            cmsSaveImageSubFolderPattern       = NameParser.CreateCodesMenu(txtSaveImageSubFolderPattern, ReplacementVariables.n);

            // Proxy
            cbProxyMethod.Items.AddRange(Enum.GetNames(typeof(ProxyMethod)));
            cbProxyType.Items.AddRange(Helpers.GetEnumDescriptions <ProxyType>());
            cbProxyMethod.SelectedIndex = (int)Program.Settings.ProxySettings.ProxyMethod;
            txtProxyUsername.Text       = Program.Settings.ProxySettings.Username;
            txtProxyPassword.Text       = Program.Settings.ProxySettings.Password;
            txtProxyHost.Text           = Program.Settings.ProxySettings.Host ?? string.Empty;
            nudProxyPort.Value          = Program.Settings.ProxySettings.Port;
            cbProxyType.SelectedIndex   = (int)Program.Settings.ProxySettings.ProxyType;
            UpdateProxyControls();

            // Upload
            cbIfUploadFailRetryOnce.Checked = Program.Settings.IfUploadFailRetryOnce;
            nudUploadLimit.Value            = Program.Settings.UploadLimit;

            for (int i = 0; i < MaxBufferSizePower; i++)
            {
                string size = ((long)(Math.Pow(2, i) * 1024)).ToSizeString(Program.Settings.BinaryUnits, 0);
                cbBufferSize.Items.Add(size);
            }

            cbBufferSize.SelectedIndex = Program.Settings.BufferSizePower.Between(0, MaxBufferSizePower);

            foreach (ClipboardFormat cf in Program.Settings.ClipboardContentFormats)
            {
                AddClipboardFormat(cf);
            }

            // Print
            cbDontShowPrintSettingDialog.Checked = Program.Settings.DontShowPrintSettingsDialog;

            // Advanced
            pgSettings.SelectedObject = Program.Settings;
        }
Exemplo n.º 2
0
 public ClipboardFormatForm(ClipboardFormat cbf)
 {
     InitializeComponent();
     ClipboardFormat     = cbf;
     txtDescription.Text = cbf.Description ?? "";
     txtFormat.Text      = cbf.Format ?? "";
     NameParser.CreateCodesMenu(txtFormat);
     lblExample.Text = "Supported variables: $result, $url, $shorturl, $thumbnailurl, $deletionurl, $filepath, $filename, $filenamenoext, $thumbnailfilename, $thumbnailfilenamenoext, $folderpath, $foldername, $uploadtime and other variables such as %y-%mo-%d etc.";
 }
        public WatermarkForm(WatermarkConfig config = null)
        {
            InitializeComponent();

            if (config == null)
            {
                config = new WatermarkConfig();
            }

            Config = config;

            codesMenu = NameParser.CreateCodesMenu(txtWatermarkText, ReplacementVariables.t);
        }
Exemplo n.º 4
0
 public WatermarkForm(WatermarkConfig watermarkConfig)
 {
     InitializeComponent();
     config    = watermarkConfig;
     codesMenu = NameParser.CreateCodesMenu(txtWatermarkText, ReplacementVariables.t);
 }
Exemplo n.º 5
0
        public TaskSettingsForm(TaskSettings hotkeySetting, bool isDefault = false)
        {
            InitializeComponent();
            Icon         = ShareXResources.Icon;
            TaskSettings = hotkeySetting;
            IsDefault    = isDefault;

            if (IsDefault)
            {
                Text = Application.ProductName + " - Task settings";
                tcHotkeySettings.TabPages.Remove(tpTask);
                chkUseDefaultGeneralSettings.Visible    = chkUseDefaultImageSettings.Visible = chkUseDefaultCaptureSettings.Visible = chkUseDefaultActions.Visible =
                    chkUseDefaultUploadSettings.Visible = chkUseDefaultIndexerSettings.Visible = chkUseDefaultAdvancedSettings.Visible = false;
                panelGeneral.BorderStyle = BorderStyle.None;
            }
            else
            {
                Text = Application.ProductName + " - Task settings for " + TaskSettings;
                tbDescription.Text = TaskSettings.Description;
                cbUseDefaultAfterCaptureSettings.Checked = TaskSettings.UseDefaultAfterCaptureJob;
                cbUseDefaultAfterUploadSettings.Checked  = TaskSettings.UseDefaultAfterUploadJob;
                cbUseDefaultDestinationSettings.Checked  = TaskSettings.UseDefaultDestinations;
                chkUseDefaultGeneralSettings.Checked     = TaskSettings.UseDefaultGeneralSettings;
                chkUseDefaultImageSettings.Checked       = TaskSettings.UseDefaultImageSettings;
                chkUseDefaultCaptureSettings.Checked     = TaskSettings.UseDefaultCaptureSettings;
                chkUseDefaultActions.Checked             = TaskSettings.UseDefaultActions;
                chkUseDefaultUploadSettings.Checked      = TaskSettings.UseDefaultUploadSettings;
                chkUseDefaultIndexerSettings.Checked     = TaskSettings.UseDefaultIndexerSettings;
                chkUseDefaultAdvancedSettings.Checked    = TaskSettings.UseDefaultAdvancedSettings;
            }

            AddEnumItemsContextMenu <HotkeyType>(x => TaskSettings.Job = x, cmsTask);
            AddMultiEnumItemsContextMenu <AfterCaptureTasks>(x => TaskSettings.AfterCaptureJob = TaskSettings.AfterCaptureJob.Swap(x), cmsAfterCapture);
            AddMultiEnumItemsContextMenu <AfterUploadTasks>(x => TaskSettings.AfterUploadJob   = TaskSettings.AfterUploadJob.Swap(x), cmsAfterUpload);
            AddEnumItems <ImageDestination>(x => TaskSettings.ImageDestination = x, tsmiImageUploaders);
            tsmiImageFileUploaders = (ToolStripDropDownItem)tsmiImageUploaders.DropDownItems[tsmiImageUploaders.DropDownItems.Count - 1];
            AddEnumItems <FileDestination>(x => TaskSettings.ImageFileDestination = x, tsmiImageFileUploaders);
            AddEnumItems <TextDestination>(x => TaskSettings.TextDestination      = x, tsmiTextUploaders);
            tsmiTextFileUploaders = (ToolStripDropDownItem)tsmiTextUploaders.DropDownItems[tsmiTextUploaders.DropDownItems.Count - 1];
            AddEnumItems <FileDestination>(x => TaskSettings.TextFileDestination      = x, tsmiTextFileUploaders);
            AddEnumItems <FileDestination>(x => TaskSettings.FileDestination          = x, tsmiFileUploaders);
            AddEnumItems <UrlShortenerType>(x => TaskSettings.URLShortenerDestination = x, tsmiURLShorteners);
            AddEnumItems <SocialNetworkingService>(x => TaskSettings.SocialNetworkingServiceDestination = x, tsmiSocialServices);

            SetEnumCheckedContextMenu(TaskSettings.Job, cmsTask);
            SetMultiEnumCheckedContextMenu(TaskSettings.AfterCaptureJob, cmsAfterCapture);
            SetMultiEnumCheckedContextMenu(TaskSettings.AfterUploadJob, cmsAfterUpload);
            SetEnumChecked(TaskSettings.ImageDestination, tsmiImageUploaders);
            SetEnumChecked(TaskSettings.ImageFileDestination, tsmiImageFileUploaders);
            SetEnumChecked(TaskSettings.TextDestination, tsmiTextUploaders);
            SetEnumChecked(TaskSettings.TextFileDestination, tsmiTextFileUploaders);
            SetEnumChecked(TaskSettings.FileDestination, tsmiFileUploaders);
            SetEnumChecked(TaskSettings.URLShortenerDestination, tsmiURLShorteners);
            SetEnumChecked(TaskSettings.SocialNetworkingServiceDestination, tsmiSocialServices);

            // FTP
            if (Program.UploadersConfig != null && Program.UploadersConfig.FTPAccountList.Count > 1)
            {
                chkOverrideFTP.Checked = TaskSettings.OverrideFTP;
                cboFTPaccounts.Items.Clear();
                cboFTPaccounts.Items.AddRange(Program.UploadersConfig.FTPAccountList.ToArray());
                cboFTPaccounts.SelectedIndex = TaskSettings.FTPIndex.BetweenOrDefault(0, Program.UploadersConfig.FTPAccountList.Count - 1);
            }

            UpdateDestinationStates();
            UpdateUploaderMenuNames();

            // General
            cbPlaySoundAfterCapture.Checked     = TaskSettings.GeneralSettings.PlaySoundAfterCapture;
            cbShowAfterCaptureTasksForm.Checked = TaskSettings.GeneralSettings.ShowAfterCaptureTasksForm;
            chkShowBeforeUploadForm.Checked     = TaskSettings.GeneralSettings.ShowBeforeUploadForm;
            cbPlaySoundAfterUpload.Checked      = TaskSettings.GeneralSettings.PlaySoundAfterUpload;
            chkShowAfterUploadForm.Checked      = TaskSettings.GeneralSettings.ShowAfterUploadForm;
            cboPopUpNotification.Items.Clear();
            cboPopUpNotification.Items.AddRange(Helpers.GetEnumDescriptions <PopUpNotificationType>());
            cboPopUpNotification.SelectedIndex = (int)TaskSettings.GeneralSettings.PopUpNotification;
            cbHistorySave.Checked = TaskSettings.GeneralSettings.SaveHistory;

            // Image - General
            cbImageFormat.SelectedIndex     = (int)TaskSettings.ImageSettings.ImageFormat;
            nudImageJPEGQuality.Value       = TaskSettings.ImageSettings.ImageJPEGQuality;
            cbImageGIFQuality.SelectedIndex = (int)TaskSettings.ImageSettings.ImageGIFQuality;
            nudUseImageFormat2After.Value   = TaskSettings.ImageSettings.ImageSizeLimit;
            cbImageFormat2.SelectedIndex    = (int)TaskSettings.ImageSettings.ImageFormat2;
            cbImageFileExist.Items.Clear();
            cbImageFileExist.Items.AddRange(Helpers.GetEnumDescriptions <FileExistAction>());
            cbImageFileExist.SelectedIndex = (int)TaskSettings.ImageSettings.FileExistAction;

            // Image - Effects
            chkShowImageEffectsWindowAfterCapture.Checked = TaskSettings.ImageSettings.ShowImageEffectsWindowAfterCapture;
            cbImageEffectOnlyRegionCapture.Checked        = TaskSettings.ImageSettings.ImageEffectOnlyRegionCapture;

            // Image - Thumbnail
            nudThumbnailWidth.Value      = TaskSettings.ImageSettings.ThumbnailWidth;
            nudThumbnailHeight.Value     = TaskSettings.ImageSettings.ThumbnailHeight;
            txtThumbnailName.Text        = TaskSettings.ImageSettings.ThumbnailName;
            lblThumbnailNamePreview.Text = "ImageName" + TaskSettings.ImageSettings.ThumbnailName + ".jpg";
            cbThumbnailIfSmaller.Checked = TaskSettings.ImageSettings.ThumbnailCheckSize;

            // Capture
            cbShowCursor.Checked             = TaskSettings.CaptureSettings.ShowCursor;
            cbCaptureTransparent.Checked     = TaskSettings.CaptureSettings.CaptureTransparent;
            cbCaptureShadow.Enabled          = TaskSettings.CaptureSettings.CaptureTransparent;
            cbCaptureShadow.Checked          = TaskSettings.CaptureSettings.CaptureShadow;
            nudCaptureShadowOffset.Value     = TaskSettings.CaptureSettings.CaptureShadowOffset;
            cbCaptureClientArea.Checked      = TaskSettings.CaptureSettings.CaptureClientArea;
            cbScreenshotDelay.Checked        = TaskSettings.CaptureSettings.IsDelayScreenshot;
            nudScreenshotDelay.Value         = TaskSettings.CaptureSettings.DelayScreenshot;
            cbCaptureAutoHideTaskbar.Checked = TaskSettings.CaptureSettings.CaptureAutoHideTaskbar;

            if (TaskSettings.CaptureSettings.SurfaceOptions == null)
            {
                TaskSettings.CaptureSettings.SurfaceOptions = new SurfaceOptions();
            }
            pgShapesCapture.SelectedObject = TaskSettings.CaptureSettings.SurfaceOptions;

            // Capture / Screen recorder
            cbScreenRecorderOutput.Items.AddRange(Helpers.GetEnumDescriptions <ScreenRecordOutput>());
            cbScreenRecorderOutput.SelectedIndex = (int)TaskSettings.CaptureSettings.ScreenRecordOutput;
            chkRunScreencastCLI.Checked          = TaskSettings.CaptureSettings.RunScreencastCLI;
            UpdateVideoEncoders();

            nudGIFFPS.Value          = TaskSettings.CaptureSettings.GIFFPS;
            nudScreenRecordFPS.Value = TaskSettings.CaptureSettings.ScreenRecordFPS;
            cbScreenRecorderFixedDuration.Checked = TaskSettings.CaptureSettings.ScreenRecordFixedDuration;
            nudScreenRecorderDuration.Enabled     = TaskSettings.CaptureSettings.ScreenRecordFixedDuration;
            nudScreenRecorderDuration.Value       = (decimal)TaskSettings.CaptureSettings.ScreenRecordDuration;
            nudScreenRecorderStartDelay.Value     = (decimal)TaskSettings.CaptureSettings.ScreenRecordStartDelay;

            // Actions
            TaskHelpers.AddDefaultExternalPrograms(TaskSettings);
            TaskSettings.ExternalPrograms.ForEach(x => AddFileAction(x));

            // Watch folders
            cbWatchFolderEnabled.Checked = TaskSettings.WatchFolderEnabled;

            if (TaskSettings.WatchFolderList == null)
            {
                TaskSettings.WatchFolderList = new List <WatchFolderSettings>();
            }
            else
            {
                foreach (WatchFolderSettings watchFolder in TaskSettings.WatchFolderList)
                {
                    AddWatchFolder(watchFolder);
                }
            }

            // Upload / Name pattern
            txtNameFormatPattern.Text             = TaskSettings.UploadSettings.NameFormatPattern;
            txtNameFormatPatternActiveWindow.Text = TaskSettings.UploadSettings.NameFormatPatternActiveWindow;
            NameParser.CreateCodesMenu(txtNameFormatPattern, ReplacementVariables.n);
            NameParser.CreateCodesMenu(txtNameFormatPatternActiveWindow, ReplacementVariables.n);
            cbFileUploadUseNamePattern.Checked = TaskSettings.UploadSettings.FileUploadUseNamePattern;

            // Upload / Clipboard upload
            chkClipboardUploadContents.Checked       = TaskSettings.UploadSettings.ClipboardUploadURLContents;
            cbClipboardUploadAutoDetectURL.Checked   = TaskSettings.UploadSettings.ClipboardUploadShortenURL;
            cbClipboardUploadAutoIndexFolder.Checked = TaskSettings.UploadSettings.ClipboardUploadAutoIndexFolder;

            // Indexer
            pgIndexerConfig.SelectedObject = TaskSettings.IndexerSettings;

            // Advanced
            pgTaskSettings.SelectedObject = TaskSettings.AdvancedSettings;

            UpdateDefaultSettingVisibility();
            loaded = true;
        }
Exemplo n.º 6
0
        private void ControlSettings()
        {
            ImageList imageUploadersImageList = new ImageList();

            imageUploadersImageList.ColorDepth = ColorDepth.Depth32Bit;
            imageUploadersImageList.Images.Add("ImageShack", Resources.ImageShack);
            imageUploadersImageList.Images.Add("TinyPic", Resources.TinyPic);
            imageUploadersImageList.Images.Add("Imgur", Resources.Imgur);
            imageUploadersImageList.Images.Add("Flickr", Resources.Flickr);
            imageUploadersImageList.Images.Add("Photobucket", Resources.Photobucket);
            imageUploadersImageList.Images.Add("Picasa", Resources.Picasa);
            imageUploadersImageList.Images.Add("TwitPic", Resources.TwitPic);
            imageUploadersImageList.Images.Add("TwitSnaps", Resources.TwitSnaps);
            imageUploadersImageList.Images.Add("YFrog", Resources.YFrog);
            tcImageUploaders.ImageList = imageUploadersImageList;

            ImageList fileUploadersImageList = new ImageList();

            fileUploadersImageList.ColorDepth = ColorDepth.Depth32Bit;
            fileUploadersImageList.Images.Add("Dropbox", Resources.Dropbox);
            fileUploadersImageList.Images.Add("GoogleDrive", Resources.GoogleDrive);
            fileUploadersImageList.Images.Add("Box", Resources.Box);
            fileUploadersImageList.Images.Add("Minus", Resources.Minus);
            fileUploadersImageList.Images.Add("FTP", Resources.folder_network);
            fileUploadersImageList.Images.Add("RapidShare", Resources.RapidShare);
            fileUploadersImageList.Images.Add("SendSpace", Resources.SendSpace);
            fileUploadersImageList.Images.Add("Gett", Resources.Gett);
            fileUploadersImageList.Images.Add("Localhostr", Resources.Localhostr);
            fileUploadersImageList.Images.Add("CustomUploader", Resources.globe_network);
            fileUploadersImageList.Images.Add("SharedFolders", Resources.server_network);
            fileUploadersImageList.Images.Add("Email", Resources.mail);
            fileUploadersImageList.Images.Add("Jira", Resources.jira);
            fileUploadersImageList.Images.Add("Mega", Resources.Mega);
            fileUploadersImageList.Images.Add("AmazonS3", Resources.AmazonS3);
            fileUploadersImageList.Images.Add("Pushbullet", Resources.Pushbullet);
            tcFileUploaders.ImageList = fileUploadersImageList;

            ImageList textUploadersImageList = new ImageList();

            textUploadersImageList.ColorDepth = ColorDepth.Depth32Bit;
            textUploadersImageList.Images.Add("Pastebin", Resources.Pastebin);
            textUploadersImageList.Images.Add("Gist", Resources.Gist);
            textUploadersImageList.Images.Add("Upaste", Resources.Upaste);
            tcTextUploaders.ImageList = textUploadersImageList;

            ImageList urlShortenersImageList = new ImageList();

            urlShortenersImageList.ColorDepth = ColorDepth.Depth32Bit;
            urlShortenersImageList.Images.Add("Google", Resources.Google);
            urlShortenersImageList.Images.Add("Bitly", Resources.Bitly);
            urlShortenersImageList.Images.Add("Yourls", Resources.Yourls);
            tcURLShorteners.ImageList = urlShortenersImageList;

            ImageList socialNetworkingServicesImageList = new ImageList();

            socialNetworkingServicesImageList.ColorDepth = ColorDepth.Depth32Bit;
            socialNetworkingServicesImageList.Images.Add("Twitter", Resources.Twitter);
            tcSocialNetworkingServices.ImageList = socialNetworkingServicesImageList;

            tpImageShack.ImageKey         = "ImageShack";
            tpTinyPic.ImageKey            = "TinyPic";
            tpImgur.ImageKey              = "Imgur";
            tpFlickr.ImageKey             = "Flickr";
            tpPhotobucket.ImageKey        = "Photobucket";
            tpPicasa.ImageKey             = "Picasa";
            tpTwitPic.ImageKey            = "TwitPic";
            tpTwitSnaps.ImageKey          = "TwitSnaps";
            tpYFrog.ImageKey              = "YFrog";
            tpDropbox.ImageKey            = "Dropbox";
            tpGoogleDrive.ImageKey        = "GoogleDrive";
            tpBox.ImageKey                = "Box";
            tpMinus.ImageKey              = "Minus";
            tpFTP.ImageKey                = "FTP";
            tpRapidShare.ImageKey         = "RapidShare";
            tpSendSpace.ImageKey          = "SendSpace";
            tpSharedFolder.ImageKey       = "SharedFolders";
            tpEmail.ImageKey              = "Email";
            tpJira.ImageKey               = "Jira";
            tpGe_tt.ImageKey              = "Gett";
            tpHostr.ImageKey              = "Localhostr";
            tpCustomUploaders.ImageKey    = "CustomUploader";
            tpPastebin.ImageKey           = "Pastebin";
            tpPushbullet.ImageKey         = "Pushbullet";
            tpGoogleURLShortener.ImageKey = "Google";
            tpBitly.ImageKey              = "Bitly";
            tpYourls.ImageKey             = "Yourls";
            tpTwitter.ImageKey            = "Twitter";
            tpMega.ImageKey               = "Mega";
            tpGist.ImageKey               = "Gist";
            tpUpaste.ImageKey             = "Upaste";
            tpAmazonS3.ImageKey           = "AmazonS3";

            NameParser.CreateCodesMenu(txtDropboxPath, ReplacementVariables.n, ReplacementVariables.t, ReplacementVariables.pn);
            NameParser.CreateCodesMenu(txtAmazonS3ObjectPrefix, ReplacementVariables.n, ReplacementVariables.t, ReplacementVariables.pn);
            NameParser.CreateCodesMenu(txtCustomUploaderArgValue, ReplacementVariables.n);

            txtCustomUploaderLog.AddContextMenu();
        }
Exemplo n.º 7
0
        private void LoadSettings()
        {
            Icon = ShareXResources.Icon;

            // General
            cbShowTray.Checked                = Program.Settings.ShowTray;
            cbSilentRun.Enabled               = Program.Settings.ShowTray;
            cbSilentRun.Checked               = Program.Settings.SilentRun;
            cbStartWithWindows.Checked        = ShortcutHelpers.CheckShortcut(Environment.SpecialFolder.Startup); //RegistryHelper.CheckStartWithWindows();
            cbSendToMenu.Checked              = ShortcutHelpers.CheckShortcut(Environment.SpecialFolder.SendTo);
            cbShellContextMenu.Checked        = RegistryHelpers.CheckShellContextMenu();
            cbTrayIconProgressEnabled.Checked = Program.Settings.TrayIconProgressEnabled;
            cbTaskbarProgressEnabled.Enabled  = TaskbarManager.IsPlatformSupported;
            cbTaskbarProgressEnabled.Checked  = Program.Settings.TaskbarProgressEnabled;
            cbRememberMainFormSize.Checked    = Program.Settings.RememberMainFormSize;

            // Paths
            txtPersonalFolderPath.Text = Program.ReadPersonalPathConfig();
            UpdatePersonalFolderPathPreview();
            cbUseCustomScreenshotsPath.Checked = Program.Settings.UseCustomScreenshotsPath;
            txtCustomScreenshotsPath.Text      = Program.Settings.CustomScreenshotsPath;
            txtSaveImageSubFolderPattern.Text  = Program.Settings.SaveImageSubFolderPattern;
            NameParser.CreateCodesMenu(txtSaveImageSubFolderPattern, ReplacementVariables.n);

            // Proxy
            cbProxyMethod.Items.AddRange(Enum.GetNames(typeof(ProxyMethod)));
            cbProxyMethod.SelectedIndex = (int)Program.Settings.ProxySettings.ProxyMethod;
            txtProxyUsername.Text       = Program.Settings.ProxySettings.Username;
            txtProxyPassword.Text       = Program.Settings.ProxySettings.Password;
            txtProxyHost.Text           = Program.Settings.ProxySettings.Host ?? string.Empty;
            nudProxyPort.Value          = Program.Settings.ProxySettings.Port;
            UpdateProxyControls();

            // Upload
            nudUploadLimit.Value = Program.Settings.UploadLimit;

            for (int i = 0; i < MaxBufferSizePower; i++)
            {
                string size = ((long)(Math.Pow(2, i) * 1024)).ToSizeString(Program.Settings.BinaryUnits, 0);
                cbBufferSize.Items.Add(size);
            }

            cbBufferSize.SelectedIndex = Program.Settings.BufferSizePower.Between(0, MaxBufferSizePower);

            foreach (ClipboardFormat cf in Program.Settings.ClipboardContentFormats)
            {
                AddClipboardFormat(cf);
            }

            nudRetryUpload.Value             = Program.Settings.MaxUploadFailRetry;
            chkUseSecondaryUploaders.Checked = Program.Settings.UseSecondaryUploaders;
            tlpBackupDestinations.Enabled    = Program.Settings.UseSecondaryUploaders;

            Program.Settings.SecondaryImageUploaders.AddRange(Helpers.GetEnums <ImageDestination>().Where(n => Program.Settings.SecondaryImageUploaders.All(e => e != n)));
            Program.Settings.SecondaryTextUploaders.AddRange(Helpers.GetEnums <TextDestination>().Where(n => Program.Settings.SecondaryTextUploaders.All(e => e != n)));
            Program.Settings.SecondaryFileUploaders.AddRange(Helpers.GetEnums <FileDestination>().Where(n => Program.Settings.SecondaryFileUploaders.All(e => e != n)));

            Program.Settings.SecondaryImageUploaders.Where(n => Helpers.GetEnums <ImageDestination>().All(e => e != n)).ForEach(x => Program.Settings.SecondaryImageUploaders.Remove(x));
            Program.Settings.SecondaryTextUploaders.Where(n => Helpers.GetEnums <TextDestination>().All(e => e != n)).ForEach(x => Program.Settings.SecondaryTextUploaders.Remove(x));
            Program.Settings.SecondaryFileUploaders.Where(n => Helpers.GetEnums <FileDestination>().All(e => e != n)).ForEach(x => Program.Settings.SecondaryFileUploaders.Remove(x));

            Program.Settings.SecondaryImageUploaders.ForEach <ImageDestination>(x => lvSecondaryImageUploaders.Items.Add(new ListViewItem(x.GetDescription())
            {
                Tag = x
            }));
            Program.Settings.SecondaryTextUploaders.ForEach <TextDestination>(x => lvSecondaryTextUploaders.Items.Add(new ListViewItem(x.GetDescription())
            {
                Tag = x
            }));
            Program.Settings.SecondaryFileUploaders.ForEach <FileDestination>(x => lvSecondaryFileUploaders.Items.Add(new ListViewItem(x.GetDescription())
            {
                Tag = x
            }));

            // Print
            cbDontShowPrintSettingDialog.Checked = Program.Settings.DontShowPrintSettingsDialog;
            cbPrintDontShowWindowsDialog.Checked = !Program.Settings.PrintSettings.ShowPrintDialog;

            // Profiles
            if (Program.Settings.VideoEncoders.Count == 0)
            {
                Program.Settings.VideoEncoders.Add(new VideoEncoder()
                {
                    Name = "Encode using x264.exe to H.264", Path = "x264.exe", Args = "--output %output %input", OutputExtension = "mp4"
                });
                Program.Settings.VideoEncoders.Add(new VideoEncoder()
                {
                    Name = "Encode using ffmpeg.exe to WebM", Path = "ffmpeg.exe", Args = "-i %input -c:v libvpx -crf 12 -b:v 500K %output", OutputExtension = "webm"
                });
                Program.Settings.VideoEncoders.Add(new VideoEncoder()
                {
                    Name = "Change container to MP4 using ffmpeg.exe", Path = "ffmpeg.exe", Args = "-i %input -c:v copy %output", OutputExtension = "mp4"
                });
                Program.Settings.VideoEncoders.Add(new VideoEncoder()
                {
                    Name = "Optimize GIF using gifsicle.exe", Path = "gifsicle.exe", Args = "-O2 %input -o %output", OutputExtension = "gif"
                });
            }

            Program.Settings.VideoEncoders.ForEach(x => AddVideoEncoder(x));

            // Advanced
            pgSettings.SelectedObject = Program.Settings;
        }
Exemplo n.º 8
0
        public TaskSettingsForm(TaskSettings hotkeySetting, bool isDefault = false)
        {
            InitializeComponent();
            Icon         = ShareXResources.Icon;
            TaskSettings = hotkeySetting;
            IsDefault    = isDefault;

            if (IsDefault)
            {
                Text = Application.ProductName + " - Task settings";
                tcHotkeySettings.TabPages.Remove(tpTask);
                chkUseDefaultGeneralSettings.Visible    = chkUseDefaultImageSettings.Visible = chkUseDefaultCaptureSettings.Visible = chkUseDefaultActions.Visible =
                    chkUseDefaultUploadSettings.Visible = chkUseDefaultIndexerSettings.Visible = chkUseDefaultAdvancedSettings.Visible = false;
                panelGeneral.BorderStyle = BorderStyle.None;
            }
            else
            {
                Text = Application.ProductName + " - Task settings for " + TaskSettings;
                tbDescription.Text = TaskSettings.Description;
                cbUseDefaultAfterCaptureSettings.Checked = TaskSettings.UseDefaultAfterCaptureJob;
                cbUseDefaultAfterUploadSettings.Checked  = TaskSettings.UseDefaultAfterUploadJob;
                cbUseDefaultDestinationSettings.Checked  = TaskSettings.UseDefaultDestinations;
                chkUseDefaultGeneralSettings.Checked     = TaskSettings.UseDefaultGeneralSettings;
                chkUseDefaultImageSettings.Checked       = TaskSettings.UseDefaultImageSettings;
                chkUseDefaultCaptureSettings.Checked     = TaskSettings.UseDefaultCaptureSettings;
                chkUseDefaultActions.Checked             = TaskSettings.UseDefaultActions;
                chkUseDefaultUploadSettings.Checked      = TaskSettings.UseDefaultUploadSettings;
                chkUseDefaultIndexerSettings.Checked     = TaskSettings.UseDefaultIndexerSettings;
                chkUseDefaultAdvancedSettings.Checked    = TaskSettings.UseDefaultAdvancedSettings;
            }

            AddEnumItems <HotkeyType>(x => TaskSettings.Job = x, cmsTask);
            AddMultiEnumItems <AfterCaptureTasks>(x => TaskSettings.AfterCaptureJob   = TaskSettings.AfterCaptureJob.Swap(x), cmsAfterCapture);
            AddMultiEnumItems <AfterUploadTasks>(x => TaskSettings.AfterUploadJob     = TaskSettings.AfterUploadJob.Swap(x), cmsAfterUpload);
            AddEnumItems <ImageDestination>(x => TaskSettings.ImageDestination        = x, cmsImageUploaders);
            AddEnumItems <TextDestination>(x => TaskSettings.TextDestination          = x, cmsTextUploaders);
            AddEnumItems <FileDestination>(x => TaskSettings.FileDestination          = x, cmsFileUploaders);
            AddEnumItems <UrlShortenerType>(x => TaskSettings.URLShortenerDestination = x, cmsURLShorteners);
            AddEnumItems <SocialNetworkingService>(x => TaskSettings.SocialNetworkingServiceDestination = x, cmsSocialNetworkingServices);

            SetEnumChecked(TaskSettings.Job, cmsTask);
            SetMultiEnumChecked(TaskSettings.AfterCaptureJob, cmsAfterCapture);
            SetMultiEnumChecked(TaskSettings.AfterUploadJob, cmsAfterUpload);
            SetEnumChecked(TaskSettings.ImageDestination, cmsImageUploaders);
            SetEnumChecked(TaskSettings.TextDestination, cmsTextUploaders);
            SetEnumChecked(TaskSettings.FileDestination, cmsFileUploaders);
            SetEnumChecked(TaskSettings.URLShortenerDestination, cmsURLShorteners);
            SetEnumChecked(TaskSettings.SocialNetworkingServiceDestination, cmsSocialNetworkingServices);

            // FTP
            if (Program.UploadersConfig != null && Program.UploadersConfig.FTPAccountList.Count > 1)
            {
                chkOverrideFTP.Checked = TaskSettings.OverrideFTP;
                cboFTPaccounts.Items.Clear();
                cboFTPaccounts.Items.AddRange(Program.UploadersConfig.FTPAccountList.ToArray());
                cboFTPaccounts.SelectedIndex = TaskSettings.FTPIndex.BetweenOrDefault(0, Program.UploadersConfig.FTPAccountList.Count - 1);
            }

            UpdateDestinationStates();
            UpdateUploaderMenuNames();

            // General
            cbPlaySoundAfterCapture.Checked     = TaskSettings.GeneralSettings.PlaySoundAfterCapture;
            cbShowAfterCaptureTasksForm.Checked = TaskSettings.GeneralSettings.ShowAfterCaptureTasksForm;
            cbPlaySoundAfterUpload.Checked      = TaskSettings.GeneralSettings.PlaySoundAfterUpload;
            chkShowAfterUploadForm.Checked      = TaskSettings.GeneralSettings.ShowAfterUploadForm;
            cbTrayBalloonTipAfterUpload.Checked = TaskSettings.GeneralSettings.TrayBalloonTipAfterUpload;
            cbShowToastWindowAfterTask.Checked  = TaskSettings.GeneralSettings.ShowToastWindowAfterTask;
            cbHistorySave.Checked = TaskSettings.GeneralSettings.SaveHistory;

            // Image - Quality
            cbImageFormat.SelectedIndex     = (int)TaskSettings.ImageSettings.ImageFormat;
            nudImageJPEGQuality.Value       = TaskSettings.ImageSettings.ImageJPEGQuality;
            cbImageGIFQuality.SelectedIndex = (int)TaskSettings.ImageSettings.ImageGIFQuality;
            nudUseImageFormat2After.Value   = TaskSettings.ImageSettings.ImageSizeLimit;
            cbImageFormat2.SelectedIndex    = (int)TaskSettings.ImageSettings.ImageFormat2;

            // Image - Effects
            chkShowImageEffectsWindowAfterCapture.Checked = TaskSettings.ImageSettings.ShowImageEffectsWindowAfterCapture;
            cbImageEffectOnlyRegionCapture.Checked        = TaskSettings.ImageSettings.ImageEffectOnlyRegionCapture;

            // Capture
            cbShowCursor.Checked             = TaskSettings.CaptureSettings.ShowCursor;
            cbCaptureTransparent.Checked     = TaskSettings.CaptureSettings.CaptureTransparent;
            cbCaptureShadow.Enabled          = TaskSettings.CaptureSettings.CaptureTransparent;
            cbCaptureShadow.Checked          = TaskSettings.CaptureSettings.CaptureShadow;
            nudCaptureShadowOffset.Value     = TaskSettings.CaptureSettings.CaptureShadowOffset;
            cbCaptureClientArea.Checked      = TaskSettings.CaptureSettings.CaptureClientArea;
            cbScreenshotDelay.Checked        = TaskSettings.CaptureSettings.IsDelayScreenshot;
            nudScreenshotDelay.Value         = TaskSettings.CaptureSettings.DelayScreenshot;
            cbCaptureAutoHideTaskbar.Checked = TaskSettings.CaptureSettings.CaptureAutoHideTaskbar;

            if (TaskSettings.CaptureSettings.SurfaceOptions == null)
            {
                TaskSettings.CaptureSettings.SurfaceOptions = new SurfaceOptions();
            }
            pgShapesCapture.SelectedObject = TaskSettings.CaptureSettings.SurfaceOptions;

            // Capture / Screen recorder
            cbScreenRecorderOutput.Items.AddRange(Helpers.GetEnumDescriptions <ScreenRecordOutput>());
            cbScreenRecorderOutput.SelectedIndex  = (int)TaskSettings.CaptureSettings.ScreenRecordOutput;
            nudScreenRecorderFPS.Value            = TaskSettings.CaptureSettings.ScreenRecordFPS;
            cbScreenRecorderFixedDuration.Checked = TaskSettings.CaptureSettings.ScreenRecordFixedDuration;
            nudScreenRecorderDuration.Enabled     = TaskSettings.CaptureSettings.ScreenRecordFixedDuration;
            nudScreenRecorderDuration.Value       = (decimal)TaskSettings.CaptureSettings.ScreenRecordDuration;
            nudScreenRecorderStartDelay.Value     = (decimal)TaskSettings.CaptureSettings.ScreenRecordStartDelay;

            gbCommandLineEncoderSettings.Enabled             = TaskSettings.CaptureSettings.ScreenRecordOutput == ScreenRecordOutput.AVICommandLine;
            txtScreenRecorderCommandLinePath.Text            = TaskSettings.CaptureSettings.ScreenRecordCommandLinePath;
            txtScreenRecorderCommandLineArgs.Text            = TaskSettings.CaptureSettings.ScreenRecordCommandLineArgs;
            txtScreenRecorderCommandLineOutputExtension.Text = TaskSettings.CaptureSettings.ScreenRecordCommandLineOutputExtension;

            // Actions
            TaskHelpers.AddDefaultExternalPrograms(TaskSettings);

            foreach (ExternalProgram fileAction in TaskSettings.ExternalPrograms)
            {
                AddFileAction(fileAction);
            }

            // Watch folders
            cbWatchFolderEnabled.Checked = TaskSettings.WatchFolderEnabled;

            if (TaskSettings.WatchFolderList == null)
            {
                TaskSettings.WatchFolderList = new List <WatchFolderSettings>();
            }
            else
            {
                foreach (WatchFolderSettings watchFolder in TaskSettings.WatchFolderList)
                {
                    AddWatchFolder(watchFolder);
                }
            }

            // Upload / Name pattern
            txtNameFormatPattern.Text             = TaskSettings.UploadSettings.NameFormatPattern;
            txtNameFormatPatternActiveWindow.Text = TaskSettings.UploadSettings.NameFormatPatternActiveWindow;
            cmsNameFormatPattern               = NameParser.CreateCodesMenu(txtNameFormatPattern, ReplacementVariables.n);
            cmsNameFormatPatternActiveWindow   = NameParser.CreateCodesMenu(txtNameFormatPatternActiveWindow, ReplacementVariables.n);
            cbFileUploadUseNamePattern.Checked = TaskSettings.UploadSettings.FileUploadUseNamePattern;

            // Upload / Clipboard upload
            cbClipboardUploadAutoDetectURL.Checked = TaskSettings.UploadSettings.ClipboardUploadAutoDetectURL;

            // Indexer
            pgIndexerConfig.SelectedObject = TaskSettings.IndexerSettings;

            // Advanced
            pgTaskSettings.SelectedObject = TaskSettings.AdvancedSettings;

            UpdateDefaultSettingVisibility();
            loaded = true;
        }