Exemplo n.º 1
0
        public EditAlbumViewModel(Common.Database.Entities.Album album, IMetadataService metadataService, IDialogService dialogService, ICacheService cacheService)
        {
            this.Album           = album;
            this.metadataService = metadataService;
            this.dialogService   = dialogService;
            this.cacheService    = cacheService;

            this.artwork = new MetadataArtworkValue();

            this.LoadedCommand = new DelegateCommand(async() => await this.GetAlbumArtworkAsync());

            this.ExportArtworkCommand = new DelegateCommand(async() =>
            {
                if (HasArtwork)
                {
                    await SaveFileUtils.SaveImageFileAsync("cover", this.Artwork.Value);
                }
            });

            this.ChangeArtworkCommand = new DelegateCommand(async() =>
            {
                if (!await OpenFileUtils.OpenImageFileAsync(new Action <byte[]>(this.UpdateArtwork)))
                {
                    this.dialogService.ShowNotification(0xe711, 16, ResourceUtils.GetString("Language_Error"), ResourceUtils.GetString("Language_Error_Changing_Image"), ResourceUtils.GetString("Language_Ok"), true, ResourceUtils.GetString("Language_Log_File"));
                }
            });


            this.RemoveArtworkCommand   = new DelegateCommand(() => this.UpdateArtwork(null));
            this.DownloadArtworkCommand = new DelegateCommand(() => this.DownloadArtworkAsync(), () => this.album.AlbumArtist != Defaults.UnknownArtistText && this.Album.AlbumTitle != Defaults.UnknownAlbumText);
        }
Exemplo n.º 2
0
        public EditTrackViewModel(IList <string> paths, IMetadataService metadataService, IDialogService dialogService)
        {
            this.multipleValuesText = "<" + ResourceUtils.GetString("Language_Multiple_Values") + ">";

            this.artists      = new MetadataValue();
            this.title        = new MetadataValue();
            this.album        = new MetadataValue();
            this.albumArtists = new MetadataValue();
            this.year         = new MetadataValue();
            this.trackNumber  = new MetadataValue();
            this.trackCount   = new MetadataValue();
            this.discNumber   = new MetadataValue();
            this.discCount    = new MetadataValue();
            this.genres       = new MetadataValue();
            this.grouping     = new MetadataValue();
            this.comment      = new MetadataValue();
            this.lyrics       = new MetadataValue();
            this.artwork      = new MetadataArtworkValue();

            this.paths           = paths;
            this.metadataService = metadataService;
            this.dialogService   = dialogService;

            this.HasMultipleArtwork = false;
            this.UpdateAlbumArtwork = false;

            this.LoadedCommand = new DelegateCommand(async() => await this.GetFilesMetadataAsync());

            this.NavigateCommand = new DelegateCommand <string>((index) => Navigate(index));

            this.ExportArtworkCommand = new DelegateCommand(async() =>
            {
                if (HasArtwork)
                {
                    await SaveFileUtils.SaveImageFileAsync("cover", this.Artwork.Value);
                }
            });

            this.ChangeArtworkCommand = new DelegateCommand(async() =>
            {
                if (!await OpenFileUtils.OpenImageFileAsync(new Action <byte[]>(this.UpdateArtwork)))
                {
                    this.dialogService.ShowNotification(
                        0xe711,
                        16,
                        ResourceUtils.GetString("Language_Error"),
                        ResourceUtils.GetString("Language_Error_Changing_Image"),
                        ResourceUtils.GetString("Language_Ok"),
                        true,
                        ResourceUtils.GetString("Language_Log_File"));
                }
            });

            this.RemoveArtworkCommand = new DelegateCommand(() => this.UpdateArtwork(null));

            this.Navigate("1"); // Make sure something is displayed when the screen is shown
        }
Exemplo n.º 3
0
        /// <summary>
        /// 保存文件地址
        /// </summary>
        /// <returns></returns>
        public string SaveFilePath()
        {
            string filePath = OpenFileUtils.OpenFolderBrowser();

            if (filePath != null)
            {
                WriteSaveFilePath(filePath);
            }
            return(filePath);
        }
Exemplo n.º 4
0
        public EditTrackViewModel(IList <TrackInfo> trackinfos, IMetadataService metadataService, IDialogService dialogService)
        {
            this.multipleValuesText = ResourceUtils.GetStringResource("Language_Multiple_Values");

            this.artists      = new MetadataValue();
            this.title        = new MetadataValue();
            this.album        = new MetadataValue();
            this.albumArtists = new MetadataValue();
            this.year         = new MetadataValue();
            this.trackNumber  = new MetadataValue();
            this.trackCount   = new MetadataValue();
            this.discNumber   = new MetadataValue();
            this.discCount    = new MetadataValue();
            this.genres       = new MetadataValue();
            this.grouping     = new MetadataValue();
            this.comment      = new MetadataValue();
            this.artwork      = new MetadataArtworkValue();

            this.trackInfos      = trackinfos;
            this.metadataService = metadataService;
            this.dialogService   = dialogService;

            this.HasMultipleArtwork = false;
            this.UpdateAlbumArtwork = false;

            this.LoadedCommand = new DelegateCommand(async() => await this.GetFilesMetadataAsync());

            this.ChangeArtworkCommand = new DelegateCommand(async() =>
            {
                if (!await OpenFileUtils.OpenImageFileAsync(new Action <string, byte[]>(this.UpdateArtwork)))
                {
                    this.dialogService.ShowNotification(
                        0xe711,
                        16,
                        ResourceUtils.GetStringResource("Language_Error"),
                        ResourceUtils.GetStringResource("Language_Error_Changing_Image"),
                        ResourceUtils.GetStringResource("Language_Ok"),
                        true,
                        ResourceUtils.GetStringResource("Language_Log_File"));
                }
            });


            this.RemoveArtworkCommand = new DelegateCommand(() => this.UpdateArtwork(String.Empty, null));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 添加文件
        /// </summary>
        /// <param name="filePh"></param>
        /// <returns></returns>
        public List <string> AddFile(string filePh)
        {
            List <string> filePath = new List <string>();
            List <string> oldPath  = OpenFileUtils.OpenFiles("添加工件", "部件文件(*.prt*)|");

            if (oldPath.Count > 0)
            {
                if (!Directory.Exists(filePh))
                {
                    return(filePath);
                }
                foreach (string st in oldPath)
                {
                    string temp = Path.GetFileName(st);
                    File.Copy(st, filePh + temp);
                    filePath.Add(filePh + temp);
                }
            }
            return(filePath);
        }
Exemplo n.º 6
0
        public EditAlbumViewModel(Album album, IMetadataService metadataService, IDialogService dialogService)
        {
            this.Album           = album;
            this.metadataService = metadataService;
            this.dialogService   = dialogService;

            this.artwork = new MetadataArtworkValue();

            this.LoadedCommand        = new DelegateCommand(async() => await this.GetAlbumArtworkAsync());
            this.ChangeArtworkCommand = new DelegateCommand(async() =>
            {
                if (!await OpenFileUtils.OpenImageFileAsync(new Action <string, byte[]>(this.UpdateArtwork)))
                {
                    this.dialogService.ShowNotification(0xe711, 16, ResourceUtils.GetStringResource("Language_Error"), ResourceUtils.GetStringResource("Language_Error_Changing_Image"), ResourceUtils.GetStringResource("Language_Ok"), true, ResourceUtils.GetStringResource("Language_Log_File"));
                }
            });


            this.RemoveArtworkCommand = new DelegateCommand(() => this.UpdateArtwork(string.Empty, null));
        }
Exemplo n.º 7
0
        /// <summary>
        /// 移动文件
        /// </summary>
        /// <returns></returns>
        public List <string> CopyFile()
        {
            List <string> filePath = new List <string>();
            List <string> oldPath  = OpenFileUtils.OpenFiles("添加工件", "部件文件(*.prt*)|");

            if (oldPath.Count > 0)
            {
                eleFile = camFile + GetTimeStamp() + "\\";
                if (!Directory.Exists(eleFile))
                {
                    Directory.CreateDirectory(eleFile);
                }
                foreach (string st in oldPath)
                {
                    string temp = Path.GetFileName(st);
                    File.Copy(st, eleFile + temp);
                    filePath.Add(eleFile + temp);
                }
            }
            return(filePath);
        }
Exemplo n.º 8
0
        public EditAlbumViewModel(string albumKey, IMetadataService metadataService,
                                  IDialogService dialogService, ICacheService cacheService) : base(cacheService)
        {
            this.metadataService = metadataService;
            this.dialogService   = dialogService;
            this.cacheService    = cacheService;

            this.LoadedCommand = new DelegateCommand(async() => await this.GetAlbumArtworkAsync(albumKey));

            this.ChangeArtworkCommand = new DelegateCommand(async() =>
            {
                if (!await OpenFileUtils.OpenImageFileAsync(new Action <byte[]>(this.UpdateArtwork)))
                {
                    this.dialogService.ShowNotification(0xe711, 16, ResourceUtils.GetString("Language_Error"), ResourceUtils.GetString("Language_Error_Changing_Image"), ResourceUtils.GetString("Language_Ok"), true, ResourceUtils.GetString("Language_Log_File"));
                }
            });


            this.RemoveArtworkCommand   = new DelegateCommand(() => this.UpdateArtwork(null));
            this.DownloadArtworkCommand = new DelegateCommand(async() => await this.DownloadArtworkAsync(), () => this.CanDownloadArtwork());
        }
Exemplo n.º 9
0
        public EditTrackViewModel(IList <string> paths, IMetadataService metadataService,
                                  IDialogService dialogService, ICacheService cacheService, IInfoDownloadService infoDownloadService) : base(cacheService, infoDownloadService)
        {
            this.multipleValuesText = "<" + ResourceUtils.GetString("Language_Multiple_Values") + ">";

            this.metadataService     = metadataService;
            this.dialogService       = dialogService;
            this.infoDownloadService = infoDownloadService;

            this.paths = paths;

            this.HasMultipleArtwork = false;
            this.UpdateAlbumArtwork = false;

            this.LoadedCommand = new DelegateCommand(async() =>
            {
                this.NagivateToSelectedPage();
                await this.GetFilesMetadataAsync();
            });

            this.ChangeArtworkCommand = new DelegateCommand(async() =>
            {
                if (!await OpenFileUtils.OpenImageFileAsync(new Action <byte[]>(this.UpdateArtwork)))
                {
                    this.dialogService.ShowNotification(
                        0xe711,
                        16,
                        ResourceUtils.GetString("Language_Error"),
                        ResourceUtils.GetString("Language_Error_Changing_Image"),
                        ResourceUtils.GetString("Language_Ok"),
                        true,
                        ResourceUtils.GetString("Language_Log_File"));
                }
            });

            this.RemoveArtworkCommand   = new DelegateCommand(() => this.UpdateArtwork(null));
            this.DownloadArtworkCommand = new DelegateCommand(async() => await this.DownloadArtworkAsync(), () => this.CanDownloadArtwork());
        }
Exemplo n.º 10
0
 //------------------------------------------------------------------------------
 //Callback Name: update_cb
 //------------------------------------------------------------------------------
 public int update_cb(NXOpen.BlockStyler.UIBlock block)
 {
     try
     {
         if (block == seleEdm)
         {
             //---------Enter your code here-----------
             TaggedObject[] tg = seleEdm.GetSelectedObjects();
             if (tg.Length > 0)
             {
                 this.buttFile.Enable = true;
                 NXOpen.Assemblies.Component ct = tg[0] as NXOpen.Assemblies.Component;
                 edm = new EDMModel(ct.Prototype as Part);
                 this.strMoldNumber.Value    = edm.Info.MoldInfo.MoldNumber;
                 this.strEditionNumber.Value = edm.Info.MoldInfo.EditionNumber;
             }
         }
         else if (block == strMoldNumber)
         {
             //---------Enter your code here-----------
         }
         else if (block == strEditionNumber)
         {
             //---------Enter your code here-----------
         }
         else if (block == buttFile)
         {
             //---------Enter your code here-----------
             partPaths = OpenFileUtils.OpenFiles("添加工件", "部件文件(*.prt*)|");
         }
     }
     catch (Exception ex)
     {
         //---- Enter your exception handling code here -----
         theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
     }
     return(0);
 }