示例#1
0
        public async void Save()
        {
            if (CurrentWallpaper == null)
            {
                MessageBox.Show(await LanService.Get("wallpaperEditor_warning_invalidWallpaper"));
                return;
            }
            if (string.IsNullOrEmpty(CurrentWallpaper.ProjectInfo.Title))
            {
                MessageBox.Show(await LanService.Get("wallpaperEditor_warning_titleEmpty"));
                return;
            }

            CanSave = false;

            try
            {
                if (_editMode)
                {
                    if (_OldWallpaper == null)
                    {
                        //只修改了title,desc等信息
                        _OldWallpaper = CurrentWallpaper;
                    }
                    await Wallpaper.EditLocakPack(CurrentWallpaper, _OldWallpaper.Dir);
                }
                else
                {
                    string destDir; destDir = Path.Combine(AppManager.LocalWallpaperDir, Guid.NewGuid().ToString());
                    await Wallpaper.CreateLocalPack(CurrentWallpaper, destDir);
                }
                //if (_editMode)
                //{
                //    //删除旧包
                //    var temp = CurrentWallpaper;
                //    CurrentWallpaper = null;
                //    bool ok = await Wallpaper.Delete(temp);
                //    if (!ok)
                //    {
                //        MessageBox.Show("删除失败请手动删除");
                //    }
                //}
            }
            catch (Exception ex)
            {
                CanSave = true;
                logger.Error(ex);
                MessageBox.Show(ex.Message);
                return;
            }
            Result = true;
            TryClose();
        }