예제 #1
0
        static void InitForAndroidBuild()
        {
            // 清空下载目录
            DownloadList _instance = DownloadList.GetInstance();

            if (_instance != null)
            {
                _instance.Clear(true);
            }
            BuildSettings.GetInstance(BuildSettings.AssetFileDir);

            // 清空Plugins/Android目录
            ClearPluginsAndroid();

            // 重置Plugins/Android
            ResetPluginsAndroid();

            // 设置相关AndroidSDK相关设定
            IAndroidSDKSettings androidSDK = GetCurAndroidSDKSetting();

            if (androidSDK != null)
            {
                string gameName    = BuildInfo.GetInstance().BuildName;
                string packageName = BuildInfo.GetInstance().BuildID;
                // 打包Android(apk文件)之前,提前应用设定
                androidSDK.PreApplyAndroidBuild(gameName, packageName);
            }
            else
            {
                BuildLogger.LogWarning("Android SDK invalid!!");
            }

            // 刷新
            UtilsAsset.AssetsRefresh();
        }
예제 #2
0
        /// <summary>
        /// 新老版本两版软件之间的需要更新的文件列表,老软件信息可以为null
        /// </summary>
        /// <param name="verOld">老软件信息,可以为null</param>
        /// <param name="verNew">新版软件信息,可以为null</param>
        public static DownloadList CompareToDownloadList(SoftFile verOld, SoftFile verNew)
        {
            DownloadList downloadList = new DownloadList
            {
                targetVersion = verNew.version //目标版本
            };

            if (verOld != null)
            {
                downloadList.curVersion = verOld.version;//当前版本
            }

            //遍历所有新文件
            foreach (var item in verNew.files)
            {   //如果这一项在老文件里包含了,那么就不用下载
                if (verOld == null || !verOld.IsContainFile(item))
                {
                    DownloadFileItem dfi = new DownloadFileItem(item);
                    if (verNew.rootUrl.EndsWith("/"))
                    {
                        dfi.url = verNew.rootUrl + dfi.relativePath;
                    }
                    else
                    {
                        dfi.url = verNew.rootUrl + "/" + dfi.relativePath;
                    }
                    downloadList.files.Add(dfi);
                }
            }

            return(downloadList);
        }
예제 #3
0
        private void DownloadItem_StateChanged(object sender, DownloadSessionStateChangedEventArgs e)
        {
            var downloadItem = e.Session as DownloadItem;

            if (downloadItem == null)
            {
                return;
            }

            if (((e.OldState == DownloadState.Downloading) || (e.OldState == DownloadState.Paused) ||
                 (e.OldState == DownloadState.Ready)) &&
                ((e.NewState == DownloadState.Cancelled) || (e.NewState == DownloadState.Failed) ||
                 (e.NewState == DownloadState.Success)))
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    DownloadList.Remove(downloadItem);
                    CompletedList.Add(downloadItem);
                });
            }
            else if (CompletedList.Contains(downloadItem))
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    CompletedList.Remove(downloadItem);
                    DownloadList.Add(downloadItem);
                });
            }
            SetDownloadItemStatusText(downloadItem);
        }
예제 #4
0
        void InitializeComponent()
        {
            DefaultSize = new Gdk.Size(900, 500);

            var mainVbox = new VBox(false, 0);

            MainMenubar = new MenuBar();
            InitMenu(MainMenubar);

            MainToolbar = new Toolbar();
            InitToolbar(MainToolbar);

            var splitCont = new HPaned();

            // list of downloads
            downloadList = new DownloadList();
            var scrolledWindow = new ScrolledWindow();

            scrolledWindow.Child = downloadList;
            splitCont.Add2(scrolledWindow);
            nodeModel = downloadList.Model;

            // categories list
            catList = new CategoryTreeView();
            splitCont.Add1(catList);

            catList.Selection.Changed += CategorySelectionOnChanged;

            mainVbox.PackStart(MainMenubar, false, true, 0);
            mainVbox.PackStart(MainToolbar, false, false, 0);
            mainVbox.PackStart(splitCont);

            Add(mainVbox);
            ShowAll();
        }
예제 #5
0
        public static FSFileInfo GetFileInfo(string fileName, bool addToDownloadList = false)
        {
            FSFileInfo result = null;

            var isFullPath   = fileName.IndexOfAny(_slashes) != -1;
            var isWorkshopId = ulong.TryParse(fileName, out ulong workshopId);

            foreach (var provider in FileProviders)
            {
                foreach (var file in provider.Files)
                {
                    if ((isFullPath && PathsAreEqual(file.Value.FullPath, fileName)) ||
                        (!isFullPath && string.Equals(fileName, file.Value.NameWithExtension, StringComparison.InvariantCultureIgnoreCase)) ||
                        (isWorkshopId && file.Value.WorkshopId == workshopId))
                    {
                        result = file.Value;
                        break;
                    }
                }
            }

            if (result != null && addToDownloadList)
            {
                DownloadList.Add(result);
            }

            return(result);
        }
예제 #6
0
        private async void FetchMALAPIAnimeList()
        {
            try
            {
                MALAPI.API api    = new MALAPI.API();
                var        animes = await api.UsersController.GetUserAnimeListAsync(UserListName);

                animes.Animes.ForEach(x =>
                {
                    if (x.MyStatus == MALAPI.AnimeListStatus.Watching)
                    {
                        if (x.SeriesStatus == "1")
                        {
                            DownloadList.Add(new AnimeViewModel(new Anime()
                            {
                                Title = x.SeriesTitle, Quality = this.Quality
                            }));
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                TextBlock block = new TextBlock();
                block.Margin = new Thickness(20);
                block.Text   = ex.Message;
                await DialogHost.Show(ex.Message);
            }
        }
예제 #7
0
        public override void Cleanup()
        {
            base.Cleanup();
            MessengerInstance.Unregister(this);
            Settings.Default.CompletedListXml = CompletedList.Count > 0
                ? XmlTools.Serialize(CompletedList.ToArray())
                : string.Empty;

            if (DownloadList.Count > 0)
            {
                var downloadItems = DownloadList.ToArray();
                var tasks         = new List <Task>();
                foreach (var downloadItem in downloadItems)
                {
                    var cancelTask =
                        downloadItem.CancelAsync().ContinueWith(task => SetDownloadItemStatusText(downloadItem));
                    tasks.Add(cancelTask);
                }
                Task.WaitAll(tasks.ToArray());
                Settings.Default.DownloadListXml = XmlTools.Serialize(downloadItems);
            }
            else
            {
                Settings.Default.DownloadListXml = string.Empty;
            }
            Settings.Default.Save();
        }
예제 #8
0
        private void SaveImages()
        {
            if (string.IsNullOrEmpty(GlobalSettings.Instance.SavePath))
            {
                new MetroMessagebox("Error", "No save directory specified. \nPlease go to settings and select a folder.").ShowDialog();
                return;
            }

            var selected = MainImageList.Where(x => x.IsSelected);

            if (DownloadList.Count == 0)
            {
                _itemsDownloadingCount = 0;
            }

            foreach (BasePost post in selected)
            {
                if (post.IsSelected && DownloadList.IndexOf(post) == -1)
                {
                    post.DownloadCompleted += post_DownloadCompleted;
                    DownloadList.Add(post);
                }
            }

            // Fire the save for each file after all files have been added to the list.
            // Otherwise the completed event could be fired at incorrect times and cause progress bar to be off sometimes and/or jump around
            foreach (BasePost post in DownloadList)
            {
                if (!post.IsDownloaded)
                {
                    post.SaveImage();
                }
            }
        }
예제 #9
0
 private async void HandleNewVideoDownload(VideoDownloadItem downloadItem)
 {
     downloadItem.DownloadProgressChanged += DownloadItem_DownloadProgressChanged;
     downloadItem.StateChanged            += DownloadItem_StateChanged;
     //downloadItem.DownloadSession.DownloadFileCompleted += WebClientOnDownloadFileCompleted;
     DownloadList.Add(downloadItem);
     await downloadItem.DownloadAsync(false);
 }
예제 #10
0
 private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     Save();
     _removeCompletedCommand?.RaiseCanExecuteChanged();
     _removeAllCommand?.RaiseCanExecuteChanged();
     _installAllCommand?.RaiseCanExecuteChanged();
     HasMoreThanOneWaiting = DownloadList.Count(x => x.State == ContentInstallationEntryState.WaitingForConfirmation) > 1;
 }
예제 #11
0
 private void RemoveDownloadItem(DownloadItem downloadItem)
 {
     if ((downloadItem == null) || !downloadItem.CanBeRemoved)
     {
         return;
     }
     DownloadList.Remove(downloadItem);
     CompletedList.Remove(downloadItem);
 }
예제 #12
0
        private async void DownloadButton_OnClick(object sender, RoutedEventArgs e)
        {
            var model = currentModel;

            DownloadList.Remove(model);
            await PixivEx.DownloadIllustInternal(model);

            messageQueue.Enqueue(Externally.DownloadComplete(model));
        }
예제 #13
0
        private async void DownloadSingleFromDownloadListButton_OnClick(object sender, RoutedEventArgs e)
        {
            var illust = sender.GetDataContext <Illustration>();

            DownloadList.Remove(illust);
            await PixivEx.DownloadIllustInternal(illust);

            Notice(Externally.DownloadComplete(illust));
        }
예제 #14
0
        private async void DownloadNowMenuItem_OnClick(object sender, RoutedEventArgs e)
        {
            var illust = sender.GetDataContext <Illustration>();

            DownloadList.Remove(illust);
            await PixivEx.DownloadIllustInternal(illust);

            MessageQueue.Enqueue(Externally.DownloadComplete(illust));
        }
예제 #15
0
        private async void DownloadButton_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var model = sender.GetDataContext <Illustration>();

            DownloadList.Remove(model);
            await PixivEx.DownloadIllustInternal(model);

            MessageQueue.Enqueue(Externally.DownloadComplete(model));
        }
예제 #16
0
        private static void InitForExportXcodeProject()
        {
            // 清空下载目录
            DownloadList _instance = DownloadList.GetInstance();

            if (_instance != null)
            {
                _instance.Clear(true);
            }

            BuildSettings.GetInstance(BuildSettings.AssetFileDir);
        }
        private void DownloadTXTs(DownloadMeta meta)
        {
            DownloadList dl        = new DownloadList(meta, this.GetFileList(meta));
            var          something = dl.GetNext();

            if (something.HasValue)
            {
                this.OnDownloadBegin(new StringEventArgs(Path.GetFileName(something.Value.Key)));
                this.OnDownloadTranslationProgressChanged(new DownloadTranslationProgressChangedEventArgs(dl.CurrentCount, dl.TotalCount));
                this.myWebClient.DownloadToMemoryAsync(something.Value.Value, something.Value.Key, dl);
            }
        }
예제 #18
0
 private void AddAllToDownloadListButton_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (SpotlightTab.IsSelected)
     {
         DownloadList.Add(sender.GetDataContext <Illustration>());
     }
     else if (GetImageSourceCopy() is { } illusts)
     {
         DownloadList.AddRange(illusts);
     }
     MessageQueue.Enqueue(Externally.AddedAllToDownloadList);
 }
예제 #19
0
        static void InitForAndroidBuild()
        {
            // 清空下载目录
            DownloadList _instance = DownloadList.GetInstance();

            if (_instance != null)
            {
                _instance.Clear(true);
            }
            // 初始化打包信息
            BuildSettings.GetInstance(BuildSettings.AssetFileDir);

                        #if UNITY_ANDROID
            // 设定选项
            // 天鸽的场合
            if (TPlatformType.Tiange == BuildInfo.GetInstance().PlatformType)
            {
                // 初始化SDK设定信息&导入最新
                TiangeSDKSettings.GetInstance(TiangeSDKSettings.AssetFileDir).ImportFromJsonFile(true);
                BuildLogger.LogMessage("TiangeSDKSettings -> ImportFromJsonFile().");
                BuildLogger.LogMessage("TiangeSDKSettings::OneSDK:{0}(MetaData:{1}).",
                                       TiangeSDKSettings.GetInstance().Data.Options.isOptionValid(BuildSystem.Options.TSDKOptions.OneSDK).ToString(),
                                       TiangeSDKSettings.GetInstance().Data.Options.OneSDK.MetaDatas.Count.ToString());

                TiangeSDKSettings.GetInstance().Data.Options.OptionsSettings =
                    BuildInfo.GetInstance().Data.Options.OptionsSettings;
            }

            // 清空Plugins/Android目录
            ClearPluginsAndroid();

            // 重置Plugins/Android
            ResetPluginsAndroid();

            // 设置相关AndroidSDK相关设定
            IAndroidSDKSettings androidSDK = GetCurAndroidSDKSetting();
            if (androidSDK != null)
            {
                string gameName    = BuildInfo.GetInstance().BuildName;
                string packageName = BuildInfo.GetInstance().BuildID;
                // 打包Android(apk文件)之前,提前应用设定
                androidSDK.PreApplyAndroidBuild(gameName, packageName);
            }
            else
            {
                BuildLogger.LogWarning("Android SDK invalid!!");
            }
                        #endif

            // 刷新
            UtilsAsset.AssetsRefresh();
        }
        private void MyWebClient_DownloadToMemoryCompleted(object sender, DownloadToMemoryCompletedEventArgs e)
        {
            // e.Tag
            DownloadList dl = e.UserState as DownloadList;

            if (e.Error != null)
            {
                this.OnDownloadTranslationCompleted(new System.ComponentModel.AsyncCompletedEventArgs(e.Error, false, null));
            }
            else if (e.Cancelled)
            {
                this.OnDownloadTranslationCompleted(new System.ComponentModel.AsyncCompletedEventArgs(null, true, null));
            }
            else
            {
                // Throw the memory to the archive then free it
                // e.Result
                System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(delegate
                {
                    dl.ZipFile.AddEntry(dl.CurrentItem.Value.Key, e.Result);

                    /*var entry = dl.ZipFile.AddEntry(dl.CurrentItem.Value.Key, new Ionic.Zip.WriteDelegate((_string, _stream) =>
                     * {
                     *  _stream.Write(e.Result.GetBuffer(), 0, (int)e.Result.Length);
                     * }));*/
                    dl.ZipFile.Save();
                    e.Result.Dispose();
                    var something = dl.GetNext();
                    if (something != null && something.HasValue)
                    {
                        this.OnDownloadBegin(new StringEventArgs(Path.GetFileName(something.Value.Key)));
                        this.OnDownloadTranslationProgressChanged(new DownloadTranslationProgressChangedEventArgs(dl.CurrentCount, dl.TotalCount));
                        this.myWebClient.DownloadToMemoryAsync(something.Value.Value, something.Value.Key, dl);
                    }
                    else
                    {
                        dl.ZipFile.AddEntry("TranslationPackData.ini", dl.Meta.TranslationDescription.ToString());
                        dl.ZipFile.AddEntry("datas.ini", dl.Meta.DataEncryption.ToString());
                        dl.ZipFile.Save();
                        dl.ZipFile.Dispose();
                        File.Delete(dl.OutputPath);
                        File.Move(dl.ZipPath, dl.OutputPath);
                        if (dl.Meta.VersionDate.HasValue)
                        {
                            File.SetLastWriteTime(dl.OutputPath, dl.Meta.VersionDate.Value);
                        }

                        this.OnDownloadTranslationCompleted(new System.ComponentModel.AsyncCompletedEventArgs(null, false, dl.Meta));
                    }
                }), null);
            }
        }
예제 #21
0
        public async void Downloadfile(object sender, RoutedEventArgs e)
        {
            filenames = new List <string>();
            string url = ServiceConfig.BaseURL + string.Format(ServiceConfig.filenamelistFormat, "YN", objectname, objectid.ToString());

            filenames = await CommonRepo.Getappendixnames(url);

            DownloadList downloadfilewindow = new DownloadList(this);

            downloadfilewindow.Show();

            //await DownloadfileAsync();
        }
예제 #22
0
        internal void Download(string URL, string Category, Action <string[], object> Callback, object State = null)
        {
            string Folder;

            if (Category == null)
            {
                Folder = DownloadFolder;
            }
            else
            {
                Folder = Path.Combine(DownloadFolder, Category);
            }
            DownloadList.Add(new DownloadEntry(URL, Folder, null, Callback, State));
        }
예제 #23
0
        public void RemoveItemFromListByValue(DownloadOperationValue value)
        {
            var index = DownloadList.ToList().FindIndex(i => i.Value == value);

            if (index == -1)
            {
                return;
            }
            var item = DownloadList[index].Key;

            item.FinishedTime = DateTime.Now.ToString("h:mm tt");
            DownloadFinishedList.Insert(0, DownloadList[index].Key);
            DownloadList.RemoveAt(index);
        }
예제 #24
0
        void InitData()
        {
            spriteObjDict.Clear();

            string       baseUrl      = @"https://download.setsuodu.com/Pokemon Models/";
            DownloadList downloadList = Resources.Load <DownloadList>("DownloadList");

            //Debug.Log(downloadList.list.Count);
            for (int i = 0; i < downloadList.list.Count; i++)
            {
                string fileurl = baseUrl + downloadList.list[i].filename;
                urlList.Add(fileurl);
            }
        }
예제 #25
0
 public void DeleteTask(TaskViewModel from)
 {
     if (DownloadList.Contains(from))
     {
         DownloadList.Remove(from);
     }
     if (CompleteList.Contains(from))
     {
         CompleteList.Remove(from);
     }
     if (ErrorList.Contains(from))
     {
         ErrorList.Remove(from);
     }
 }
예제 #26
0
 public void TaskDownload(TaskViewModel from)
 {
     if (DownloadList.Contains(from) == false)
     {
         if (ErrorList.Contains(from))
         {
             ErrorList.Remove(from);
         }
         if (CompleteList.Contains(from))
         {
             CompleteList.Remove(from);
         }
         DownloadList.Insert(0, from);
     }
 }
예제 #27
0
 public void SaveSettings()
 {
     try
     {
         configFile.Write("UserListName", UserListName, "Settings");
         configFile.Write("DownloadsPath", DownloadsPath, "Settings");
         configFile.Write("TorrentsPath", TorrentsPath, "Settings");
         configFile.Write("ConfigPath", ConfigPath, "Settings");
         configFile.Write("Quality", Quality, "Settings");
         configFile.Write("MinimizeOnExit", MinimizeOnExit.ToString(), "Settings");
         configFile.Write("MaxDownloadSpeed", MaxDownloadSpeed, "Settings");
         configFile.Write("DownloadList", DownloadList.Select(x => $"{x.Title}~{x.Quality}").Aggregate((x, y) => $"{x},{y}"), "Settings");
     }
     catch { }
 }
예제 #28
0
        /// <summary>
        /// Сохраняем информацию о манге
        /// </summary>
        /// <param name="path">Путь сохранения. При дефолтном значении, будет использован путь автосохранения.</param>
        /// <param name="dList">Список загрузки</param>
        /// <returns>0 - всё ок, иначе - код ошибки</returns>
        public byte saveManga(DownloadList dList, string path = null)
        {
            byte ex = 1;
            byte result;

            try
            {
                //Инициализируем сериализатор XML
                XmlSerializer xs = new XmlSerializer(typeof(DownloadListXml));
                //Инициализируем класс списка загрузок
                DownloadListXml list = new DownloadListXml();
                //Загружаем информацию о манге в список загрузок
                result = list.loadFromMangaList(dList);
                //Если всё ок
                if (result == 0)
                {
                    //Если не был указан путь сохранения
                    if (path == null)
                    {
                        //Указываем путь автосохранения
                        path = autosavePath;
                        //Делаем бекап файла автосохранения (если он нужен)
                        backupAutosave();
                    }

                    //Инициализируем поток записи в файл
                    using (StreamWriter sw = new StreamWriter(path))
                    {
                        //Сериализуем в файл наш класс
                        xs.Serialize(sw, list);
                        //Сохраняем и закрываем поток
                        sw.Flush();
                        sw.Dispose();
                    }
                    //Всё ок
                    ex = 0;
                }
                else
                {
                    //Ошибка - манга не была загружена
                    ex = 2;
                }
            }
            catch { ex = 1; }

            return(ex);
        }
예제 #29
0
        /// <summary>
        /// Загружаем мангу
        /// </summary>
        /// <param name="path">Путь загрузки манги. По дефолту - путь автозагрузки</param>
        /// <returns>Результат выполнения операции. 0 - всё ок, иначе - код ошибки.</returns>
        public byte loadManga(string path = null)
        {
            byte ex = 1;

            try
            {
                //Если список загрузки был создан
                if (dList != null)
                {
                    //Если путь не пустой
                    if ((path == null) || (path.Length != 0))
                    {
                        //Очищаем список загрузки
                        dList.clearManga();
                        //Загружаем мангу
                        dList = xw.loadManga(path);

                        //Если была ошибка загрузки
                        if (dList == null)
                        {
                            //РЕинициализируем список
                            dList = new DownloadList();
                            //Возвращаем код ошибки загрузки
                            ex = 3;
                        }
                        else
                        {
                            //Всё ок
                            ex = 0;
                        }
                    }
                    else
                    {
                        //ОШибка - пустой путь
                        ex = 4;
                    }
                }
                else
                {
                    //Список загрузки ещё не было проинициализирован
                    ex = 2;
                }
            }
            catch { ex = 1; }

            return(ex);
        }
예제 #30
0
        /// <summary>
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            MainDownloadList  = new DownloadList();
            StatsForm         = new StatisticsForm();
            ManageBuildsForm  = new ManageBuildsForm();
            ManageTagsForm    = new ManageTagsForm();
            ManageRoutesForm  = new ManageRoutesForm();
            ManageUsersForm   = new ManageUsersForm();
            ManageServerForm  = new ManageServerForm();
            ConsoleOutputForm = new ConsoleForm();
            PeersForm         = new PeersForm();
            ManifestsForm     = new ManifestsForm();

            DeserializedDockContent = GetLayoutContentFromPersistString;
        }