private void DownloadButton_Click(object sender, EventArgs e)
        {
            DownloadButton.Enabled = false;

            ChangesTextBox.AppendText(Environment.NewLine);
            ChangesTextBox.AppendText("Downloading..." + Environment.NewLine);

            var downloadAction = new Action(() =>
            {
                Parallel.ForEach(m_newDefinitions, definition =>
                {
                    var localPath = Path.Combine(NFEPaths.DefinitionsDirectory, definition.Name);

                    NFEPaths.EnsureDirectoryExists(NFEPaths.DefinitionsDirectory);
                    GitHubApi.DownloadFile(definition.DownloadUrl, localPath);

                    UpdateUI(() => ChangesTextBox.AppendText(definition.Name + " done." + Environment.NewLine));
                });

                UpdateUI(() =>
                {
                    DialogResult = DialogResult.OK;
                });
            });

            downloadAction.BeginInvoke(null, null);
        }
예제 #2
0
        public void InitializeStorage([NotNull] IEnumerable <FirmwareDefinition> definitions)
        {
            if (definitions == null)
            {
                throw new ArgumentNullException("definitions");
            }

            var patchDirEx = Safe.Execute(() => NFEPaths.EnsureDirectoryExists(NFEPaths.PatchDirectory));

            if (patchDirEx != null)
            {
                Trace.Warn(patchDirEx, "An error occured during creating primary pathes directory '{0}'.", NFEPaths.PatchDirectory);
                return;
            }

            foreach (var definition in definitions)
            {
                var definitionPatchDir = Path.Combine(NFEPaths.PatchDirectory, definition.Name);
                var ex = Safe.Execute(() => NFEPaths.EnsureDirectoryExists(definitionPatchDir));
                if (ex != null)
                {
                    Trace.Warn(ex, "An error occured during creating patches directory '{0}'.", definitionPatchDir);
                }
            }
        }
        private void DownloadButton_Click(object sender, EventArgs e)
        {
            DownloadButton.Enabled = false;

            ChangesTextBox.AppendText(Environment.NewLine);
            ChangesTextBox.AppendText("Downloading..." + Environment.NewLine);

            var downloadAction = new Action(() =>
            {
                Parallel.ForEach(m_newPatches, patch =>
                {
                    var localPath = PatchManager.GetPatchFilePath(m_definition, patch.Name);
                    var directory = PatchManager.GetPatchDirectoryPath(m_definition);

                    NFEPaths.EnsureDirectoryExists(directory);
                    GitHubApi.DownloadFile(patch.DownloadUrl, localPath);

                    UpdateUI(() => ChangesTextBox.AppendText(patch.Name + " done." + Environment.NewLine));
                });

                UpdateUI(() =>
                {
                    DialogResult = DialogResult.OK;
                });
            });

            downloadAction.BeginInvoke(null, null);
        }
예제 #4
0
 public MainWindow(string[] args) : this()
 {
     m_firmwareFile = NFEPaths.ValidateInputArgs(args);
     if (!string.IsNullOrEmpty(m_firmwareFile))
     {
         Shown += (s, e) =>
         {
             OpenFirmware(m_firmwareFile, fileName => m_loader.TryLoad(fileName, m_definitions));
         };
     }
 }
        public void Initialize()
        {
            var initEx = Safe.Execute(() => NFEPaths.EnsureDirectoryExists(NFEPaths.DefinitionsDirectory));

            if (initEx == null)
            {
                return;
            }

            Trace.Warn(initEx, "An error occured during creating definitions directory '{0}'.", NFEPaths.DefinitionsDirectory);
        }