public LoanFormTemplateViewModel(MultimediaLink model)
     : base(model)
 {
 }
Beispiel #2
0
 private void AddNewLinkFromExternalLink(MultimediaLink externalLink)
 {
     if (externalLink != null) {
         // Link to existing multimedia
         var model = new MultimediaLink();
         model.MultimediaID = externalLink.MultimediaID;
         model.MultimediaLinkID = NewLinkID();
         model.Name = externalLink.Name;
         model.Extension = externalLink.Extension;
         var viewModel = new MultimediaLinkViewModel(model);
         GenerateThumbnail(viewModel, THUMB_SIZE);
         _model.Add(viewModel);
         RegisterPendingChange(new InsertMultimediaLinkCommand(model, CategoryType, Owner));
     }
 }
Beispiel #3
0
        private void AddTaxonRow(DataMatrix results, Taxon taxa, MultimediaLink link, string multimediaSource = "Taxon", int? materialId= null)
        {
            // Filter the rows...
            bool addRow = true;
            if (!string.IsNullOrWhiteSpace(_extensionFilter)) {
                addRow = _extensionFilter.Equals(link.Extension, StringComparison.CurrentCultureIgnoreCase);
            }

            if (addRow && !string.IsNullOrWhiteSpace(_typeFilter)) {
                addRow = _typeFilter.Equals(link.MultimediaType, StringComparison.CurrentCultureIgnoreCase);
            }

            if (addRow) {
                var row = results.AddRow();
                row[0] = link.MultimediaID;
                row[1] = taxa.TaxaID.Value;
                row[2] = link;
                row[3] = taxa.TaxaFullName;
                row[4] = taxa.Rank;
                row[5] = link.Name;
                row[6] = link.Extension;
                row[7] = link.MultimediaType;
                row[8] = link.SizeInBytes;
                row[9] = multimediaSource;
                row[10] = materialId;
            }
        }
Beispiel #4
0
        private void AddMultimediaFromFile(string filename)
        {
            if (IsReadOnly) {
                return;
            }

            if (string.IsNullOrWhiteSpace(filename)) {
                return;
            }

            FileInfo finfo = new FileInfo(filename);
            if (finfo.Exists) {
                MultimediaLink model = null;
                MultimediaLinkViewModel viewModel = null;
                Multimedia duplicate = null;
                var action = CheckDuplicate(finfo, out duplicate);
                switch (action) {
                    case MultimediaDuplicateAction.Cancel:
                        // Do nothing
                        break;
                    case MultimediaDuplicateAction.NoDuplicate:
                    case MultimediaDuplicateAction.InsertDuplicate:
                        // Insert new multimedia and new link
                        model = new MultimediaLink();
                        model.MultimediaID = NextNewId();
                        model.MultimediaLinkID = model.MultimediaID;
                        if (finfo.Name.Contains(".")) {
                            model.Name = finfo.Name.Substring(0, finfo.Name.LastIndexOf("."));
                            model.Extension = finfo.Extension.Substring(1);
                        } else {
                            model.Name = finfo.Name;
                        }
                        model.SizeInBytes = (int)finfo.Length;

                        viewModel = new MultimediaLinkViewModel(model);
                        viewModel.Thumbnail = GraphicsUtils.GenerateThumbnail(filename, THUMB_SIZE);
                        _tempFileManager.CopyToTempFile(viewModel.MultimediaID, filename);
                        _model.Add(viewModel);
                        RegisterPendingChange(new InsertMultimediaCommand(model, _tempFileManager.GetContentFileName(viewModel.MultimediaID, finfo.Extension.Substring(1))));
                        RegisterPendingChange(new InsertMultimediaLinkCommand(model, CategoryType, Owner));
                        break;
                    case MultimediaDuplicateAction.UseExisting:
                        // Link to existing multimedia
                        model = new MultimediaLink();
                        model.MultimediaID = duplicate.MultimediaID;
                        model.MultimediaLinkID = NewLinkID();
                        model.Name = duplicate.Name;
                        model.Extension = duplicate.FileExtension;
                        viewModel = new MultimediaLinkViewModel(model);
                        GenerateThumbnail(viewModel, THUMB_SIZE);
                        _model.Add(viewModel);
                        RegisterPendingChange(new InsertMultimediaLinkCommand(model, CategoryType, Owner));
                        break;
                    case MultimediaDuplicateAction.ReplaceExisting:
                        // register an update for the multimedia,
                        // and insert a new link
                        // Link to existing multimedia
                        model = new MultimediaLink();
                        model.MultimediaID = duplicate.MultimediaID;
                        model.MultimediaLinkID = NewLinkID();
                        model.Name = duplicate.Name;
                        model.Extension = duplicate.FileExtension;
                        viewModel = new MultimediaLinkViewModel(model);
                        GenerateThumbnail(viewModel, THUMB_SIZE);
                        _model.Add(viewModel);
                        _tempFileManager.CopyToTempFile(viewModel.MultimediaID, filename);
                        RegisterPendingChange(new UpdateMultimediaBytesCommand(model, filename));
                        RegisterPendingChange(new InsertMultimediaLinkCommand(model, CategoryType, Owner));
                        break;
                }

                if (viewModel != null) {
                    viewModel.IsSelected = true;
                    thumbList.SelectedItem = viewModel;
                }
            }
        }
Beispiel #5
0
        private void AddNew()
        {
            var dlg = new OpenFileDialog();
            dlg.Filter = "All files (*.*)|*.*";
            dlg.Multiselect = true;
            if (dlg.ShowDialog().ValueOrFalse()) {
                foreach (string filename in dlg.FileNames) {
                    FileInfo finfo = new FileInfo(filename);
                    if (finfo.Exists) {
                        MultimediaLink model = null;
                        MultimediaLinkViewModel viewModel = null;
                        Multimedia duplicate = null;
                        var action = CheckDuplicate(finfo, out duplicate);
                        switch (action) {
                            case MultimediaDuplicateAction.Cancel:
                                // Do nothing
                                break;
                            case MultimediaDuplicateAction.NoDuplicate:
                            case MultimediaDuplicateAction.InsertDuplicate:
                                // Insert new multimedia and new link
                                model = new MultimediaLink();
                                model.MultimediaID = NextNewId();
                                model.MultimediaLinkID = model.MultimediaID;
                                if (finfo.Name.Contains(".")) {
                                    model.Name = finfo.Name.Substring(0, finfo.Name.LastIndexOf("."));
                                    model.Extension = finfo.Extension.Substring(1);
                                } else {
                                    model.Name = finfo.Name;
                                }
                                viewModel = new MultimediaLinkViewModel(model);
                                _tempFileManager.CopyToTempFile(viewModel.MultimediaID, filename);
                                _model.Add(viewModel);
                                RegisterPendingChange(new InsertMultimediaCommand(model, _tempFileManager.GetContentFileName(viewModel.MultimediaID, finfo.Extension.Substring(1))));
                                break;
                            case MultimediaDuplicateAction.UseExisting:
                                // Should never get here!
                                break;
                            case MultimediaDuplicateAction.ReplaceExisting:
                                // register an update for the multimedia,
                                // and insert a new link
                                // Link to existing multimedia
                                model = new MultimediaLink();
                                model.MultimediaID = duplicate.MultimediaID;
                                model.MultimediaLinkID = -1;
                                model.Name = duplicate.Name;
                                model.Extension = duplicate.FileExtension;
                                viewModel = new MultimediaLinkViewModel(model);
                                _model.Add(viewModel);
                                _tempFileManager.CopyToTempFile(viewModel.MultimediaID, filename);
                                RegisterPendingChange(new UpdateMultimediaBytesCommand(model, filename));
                                break;
                        }

                        if (viewModel != null) {
                            viewModel.IsSelected = true;
                        }
                    }
                }
            }
        }