Beispiel #1
0
        private void pgApp_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            if (IsGuiReady)
            {
                LoadSettingsToControls();
                ValidateThumbnailerPaths(s, e);

                if (File.Exists(App.Settings.CustomUploadersConfigPath))
                {
                    App.UploadersConfig = UploadersConfig.Load(App.Settings.CustomUploadersConfigPath);
                }
            }
        }
Beispiel #2
0
        private void UploadersConfigImport()
        {
            OpenFileDialog dlg = new OpenFileDialog {
                Filter = FILTER_XML_FILES
            };

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                UploadersConfig temp = UploadersConfig.Load(dlg.FileName);
                if (temp != null)
                {
                    Engine.ConfigUploaders = temp;
                }
            }
        }
        private void pgAppSettings_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            if (IsReady)
            {
                FormsMgr.OptionsUI.ConfigurePaths();

                if (!string.IsNullOrEmpty(Engine.ConfigApp.UploadersConfigCustomPath))
                {
                    Engine.ConfigUploaders = UploadersConfig.Load(Engine.ConfigApp.UploadersConfigCustomPath);
                }

                if (!string.IsNullOrEmpty(Engine.ConfigApp.WorkflowConfigCustomPath))
                {
                    Engine.ConfigWorkflow = Workflow.Read(Engine.ConfigApp.WorkflowConfigCustomPath);
                }
            }
        }
Beispiel #4
0
 public static void LoadUploadersConfig()
 {
     UploadersConfig = UploadersConfig.Load(UploadersConfigFilePath);
 }
Beispiel #5
0
 private static void ReloadUploadersConfig(string filePath)
 {
     UploadersConfig = UploadersConfig.Load(filePath);
 }
Beispiel #6
0
        private static void Main(string[] args)
        {
            string dirImages         = string.Empty;
            string dirRoot           = string.Empty;
            string mSettingsFilePath = string.Empty;
            string dirTorrents       = string.Empty;

            bool mFileCollection = false;
            bool mShowHelp       = false;

            var p = new OptionSet()
            {
                { "c", "Treat multiple files as a collection", v => mFileCollection = v != null },
                { "m|media=", "Location of the media file/folder", v => mMediaLoc = v },
                { "o|options=", "Location of the settings file", v => mSettingsFilePath = v },
                { "rd=", "Root directory for screenshots, torrent and all other output files. Overrides all other custom folders.", v => dirRoot = v },
                { "s", "Create screenshots", v => mScreenshotsCreate = v != null },
                { "sd=", "Create screenshots in a custom folder and upload", v => dirImages = v },
                { "t", "Create torrent file in the parent folder of the media file", v => mTorrentCreate = v != null },
                { "td=", "Create torrent file in a custom folder", v => dirTorrents = v },
                { "u", "Upload screenshots", v => mScreenshotsUpload = v != null },
                { "x|xml", "Folder path of the XML torrent description file", v => mXmlCreate = v != null },
                { "h|help", "Show this message and exit", v => mShowHelp = v != null }
            };

            if (args.Length == 0)
            {
                mShowHelp = true;
            }

            // give cli the ability to replace environment variables
            string[] args2 = new string[args.Length];
            int      count = 0;

            foreach (string arg in args)
            {
                args2[count++] = arg.Replace("%appdata%", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
            }

            try
            {
                p.Parse(args2);

                // set root folder for images or set images dir if set one
                mScreenshotDir = Directory.Exists(dirRoot) ? dirRoot : dirImages;

                // set root folder for torrents or set torrents dir if set one
                mTorrentsDir = Directory.Exists(dirRoot) ? dirRoot : dirTorrents;
            }
            catch (Exception ex)
            {
                Console.Write("tdmakercli: ");
                Console.WriteLine(ex.Message);
                Console.WriteLine("Try 'tdmakercli --help' for more information.");
                return;
            }

            if (mShowHelp)
            {
                ShowHelp(p);
                return;
            }

            if (!File.Exists(mSettingsFilePath))
            {
                mSettingsFilePath = App.SettingsFilePath;
            }

            if (File.Exists(mSettingsFilePath))
            {
                App.Settings        = Settings.Load(mSettingsFilePath);
                App.UploadersConfig = UploadersConfig.Load(App.UploadersConfigPath);
            }

            if (App.Settings != null)
            {
                App.InitializeDefaultFolderPaths();

                List <string> listFileOrDir = new List <string>()
                {
                    mMediaLoc
                };
                MediaWizardOptions mwo = Adapter.GetMediaType(listFileOrDir, true);
                if (mwo.MediaTypeChoice == MediaType.MediaIndiv && mFileCollection)
                {
                    mwo.MediaTypeChoice = MediaType.MediaCollection;
                }

                TaskSettings ts = new TaskSettings();
                ts.MediaOptions.CreateScreenshots = mScreenshotsCreate;
                ts.MediaOptions.UploadScreenshots = mScreenshotsUpload;

                WorkerTask task = new WorkerTask(ts);
                MediaInfo2 mi   = new MediaInfo2(mwo, mMediaLoc);
                mi.ReadMedia();

                if (mScreenshotsUpload)
                {
                    TakeScreenshots(task);
                    task.UploadScreenshots();
                }
                else if (mScreenshotsCreate)
                {
                    TakeScreenshots(task);
                }

                //  CreatePublish(ti);
                //  CreateTorrent(ti);
            }
        }
Beispiel #7
0
 protected void bwConfig_DoWork(object sender, DoWorkEventArgs e)
 {
     Program.ConfigUploaders = UploadersConfig.Load(Program.ConfigUploadersFilePath);
     Engine.ConfigUploaders  = Program.ConfigUploaders;
     Program.ConfigWorkflow  = WorkflowConfig.Read();
 }
Beispiel #8
0
        private static void ProcessArgs(string[] args)
        {
            var p = new OptionSet()
            {
                { "h|help", "Show this message and exit",
                  v => bShowHelp = v != null },
                { "v|verbose", "Debug output",
                  v => bVerbose = v != null },
                { "o|outputs=", "Outputs. This must be an integer.",
                  (int v) => listOutputTypes.Add(v) },
                { "i|hi=", "Image uploader type. This must be an integer.",
                  (int v) => listImageHosts.Add(v) },
                { "t|ht=", "Text uploader type. This must be an integer.",
                  (int v) => listTextHosts.Add(v) },
                { "f|hf=", "File uploader type. This must be an integer.",
                  (int v) => listFileHosts.Add(v) },
                { "cc=", "Clipboard content. This must be an integer.",
                  (int v) => clipboardContent = v },
                { "s|ws", "Capture selected window.",
                  v => bSelectedWindow = v != null },
                { "r|wc", "Capture rectangular region.",
                  v => bCropShot = v != null },
                { "d|wf", "Capture entire screen.",
                  v => bScreen = v != null },
                { "c|uc", "Upload clipboard content.",
                  v => bClipboardUpload = v != null },
                { "u|uf=", "File path to upload.",
                  v =>
                  {
                      if (File.Exists(v))
                      {
                          listPaths.Add(v);
                      }
                      else if (Directory.Exists(v))
                      {
                          listPaths.Add(v);
                      }
                      if (listPaths.Count > 0)
                      {
                          bFileUpload = true;
                      }
                  } },
            };

            if (args.Length == 0)
            {
                ShowHelp(p);
            }

            List <string> extra;

            try
            {
                extra = p.Parse(args);
            }
            catch (OptionException e)
            {
                Console.Write(string.Format("{0}: ", ApplicationName));
                Console.WriteLine(e.Message);
                Console.WriteLine("Try 'ZScreenCLI.exe -help' for more information.");
                return;
            }

            if (bVerbose)
            {
                Console.WriteLine(string.Format("Loading {0}", Engine.ConfigApp.WorkflowConfigPath));
            }
            Engine.ConfigUploaders = UploadersConfig.Load(Engine.ConfigApp.UploadersConfigPath);
            Engine.ConfigWorkflow  = Workflow.Read(Engine.ConfigApp.WorkflowConfigPath);

            if (bShowHelp)
            {
                ShowHelp(p);
                return;
            }

            if (bFileUpload && listPaths.Count > 0)
            {
                FileUpload();
            }

            if (bClipboardUpload)
            {
                ClipboardUpload();
            }

            if (bCropShot)
            {
                CaptureRectRegion(WorkerTask.JobLevel2.CaptureRectRegion);
            }

            if (bSelectedWindow)
            {
                CaptureRectRegion(WorkerTask.JobLevel2.CaptureSelectedWindow);
            }

            if (bScreen)
            {
                CaptureScreen();
            }
        }
Beispiel #9
0
 public static void LoadSettings()
 {
     LoadSettings(string.Empty);
     LoadProxySettings();
     Program.UploadersConfig = UploadersConfig.Load(UploadersConfigPath);
 }
        public static void LoadSettings(string fp = null)
        {
            LoggerTimer timer = EngineLogger.StartTimer("LoadSettings started");

            Thread threadOptions = new Thread(() =>
            {
                Engine.ConfigOptions = ZScreenOptions.Read(OptionsFilePath);
            });

            Thread threadMainFormSettings = new Thread(() =>
            {
                if (string.IsNullOrEmpty(fp))
                {
                    Engine.ConfigUI = XMLSettings.Read();
                }
                else
                {
                    Engine.ConfigUI = XMLSettings.Read(fp);
                }
            });

            Thread threadWorkflow = new Thread(() =>
            {
                Engine.ConfigWorkflow = Workflow.Read(WorkflowConfigPath);
            });

            Thread threadUploadersConfig = new Thread(() =>
            {
                Engine.ConfigUploaders = UploadersConfig.Load(UploadersConfigPath);
            });

            Thread threadGt = new Thread(() =>
            {
                Engine.ConfigGT = GoogleTranslatorConfig.Read(GoogleTranslateConfigPath);
            });

            threadOptions.Start();
            threadMainFormSettings.Start();
            threadGt.Start();
            threadWorkflow.Start();
            threadUploadersConfig.Start();

            threadMainFormSettings.Join();
            threadWorkflow.Join();
            threadUploadersConfig.Join();

            timer.WriteLineTime("LoadSettings finished");

            Engine.InitializeFiles();

            // Use Configuration Wizard Settings if applied
            if (RunConfig)
            {
                Engine.ConfigUI.ConfOutputs          = Engine.ConfigApp.AppOutputs;
                Engine.ConfigUI.ConfClipboardContent = Engine.ConfigApp.ClipboardContent;
                Engine.ConfigUI.MyImageUploaders     = Engine.ConfigApp.ImageUploaders;
                Engine.ConfigUI.MyTextUploaders      = Engine.ConfigApp.TextUploaders;
                Engine.ConfigUI.MyFileUploaders      = Engine.ConfigApp.FileUploaders;
                Engine.ConfigUI.MyURLShorteners      = Engine.ConfigApp.LinkUploaders;
            }

            // Portable then we don't need PreferSystemFolders to be true
            if (IsPortable)
            {
                Engine.ConfigApp.PreferSystemFolders = false;
            }
        }