private static void CheckTagWithLists(GDMTree tree, GEDCOMFormat format, GDMTagWithLists tag) { int num = tag.MultimediaLinks.Count; for (int i = 0; i < num; i++) { GDMMultimediaLink mmLink = tag.MultimediaLinks[i]; if (!mmLink.IsPointer) { TransformMultimediaLink(tree, mmLink); } } num = tag.Notes.Count; for (int i = 0; i < num; i++) { GDMNotes note = tag.Notes[i]; if (!note.IsPointer) { TransformNote(tree, note); } } num = tag.SourceCitations.Count; for (int i = 0; i < num; i++) { GDMSourceCitation sourCit = tag.SourceCitations[i]; if (!sourCit.IsPointer) { TransformSourceCitation(tree, sourCit); } } }
// TODO: refactor private static void CheckRecord_RepairTag(GDMTree tree, GEDCOMFormat format, GDMTagWithLists tag) { for (int i = tag.MultimediaLinks.Count - 1; i >= 0; i--) { GDMMultimediaLink mmLink = tag.MultimediaLinks[i]; if (mmLink.IsPointer && mmLink.Value == null) { tag.MultimediaLinks.DeleteAt(i); } } for (int i = tag.Notes.Count - 1; i >= 0; i--) { GDMNotes note = tag.Notes[i]; if (note.IsPointer && note.Value == null) { tag.Notes.DeleteAt(i); } } for (int i = tag.SourceCitations.Count - 1; i >= 0; i--) { GDMSourceCitation sourCit = tag.SourceCitations[i]; if (sourCit.IsPointer && sourCit.Value == null) { tag.SourceCitations.DeleteAt(i); } } }
private static void TransformMultimediaLink(GDMTree tree, GDMMultimediaLink mmLink) { string title = mmLink.Title; GDMMultimediaRecord mmRec = tree.CreateMultimedia(); int num = mmLink.FileReferences.Count; for (int i = 0; i < num; i++) { GDMFileReference srcFileRef = mmLink.FileReferences[i]; GDMFileReferenceWithTitle tgtFileRef = new GDMFileReferenceWithTitle(mmRec); tgtFileRef.LinkFile(srcFileRef.StringValue); if (srcFileRef.MultimediaFormat != GDMMultimediaFormat.mfNone) { tgtFileRef.MultimediaFormat = srcFileRef.MultimediaFormat; } if (srcFileRef.MediaType != GDMMediaType.mtUnknown) { tgtFileRef.MediaType = srcFileRef.MediaType; } tgtFileRef.Title = title; mmRec.FileReferences.Add(tgtFileRef); } mmLink.Clear(); mmLink.Value = mmRec; }
public static bool AddIndividualPortrait(IBaseWindow baseWin, ChangeTracker localUndoman, GDMIndividualRecord iRec) { bool result = false; GDMMultimediaRecord mmRec = baseWin.Context.SelectRecord(GDMRecordType.rtMultimedia, null) as GDMMultimediaRecord; if (mmRec == null) { return(false); } // remove previous portrait link GDMMultimediaLink mmLink = iRec.GetPrimaryMultimediaLink(); if (mmLink != null) { mmLink.IsPrimary = false; } // set new portrait link mmLink = iRec.SetPrimaryMultimediaLink(mmRec); // select portrait area using (var selectDlg = AppHost.ResolveDialog <IPortraitSelectDlg>(baseWin)) { selectDlg.MultimediaLink = mmLink; result = AppHost.Instance.ShowModalX(selectDlg, false); } if (result) { result = localUndoman.DoOrdinaryOperation(OperationType.otIndividualPortraitAttach, iRec, mmLink); } return(result); }
private bool ProcessIndividualPortrait(bool redo) { GDMIndividualRecord iRec = fObj as GDMIndividualRecord; GDMMultimediaLink mmLink = fNewVal as GDMMultimediaLink; if (iRec == null || mmLink == null) { return(false); } if (fType == OperationType.otIndividualPortraitDetach) { redo = !redo; } if (redo) { mmLink.IsPrimary = true; } else { mmLink.IsPrimary = false; } return(true); }
private static void CheckRecord(IBaseContext baseContext, GDMTree tree, GDMRecord rec, GEDCOMFormat format, int fileVer) { if (format != GEDCOMFormat.gf_Native) { int num = rec.MultimediaLinks.Count; for (int i = 0; i < num; i++) { GDMMultimediaLink mmLink = rec.MultimediaLinks[i]; if (!mmLink.IsPointer) { TransformMultimediaLink(tree, mmLink); } } num = rec.Notes.Count; for (int i = 0; i < num; i++) { GDMNotes note = rec.Notes[i]; if (!note.IsPointer) { TransformNote(tree, note); } } num = rec.SourceCitations.Count; for (int i = 0; i < num; i++) { GDMSourceCitation sourCit = rec.SourceCitations[i]; if (!sourCit.IsPointer) { TransformSourceCitation(tree, sourCit); } } } switch (rec.RecordType) { case GDMRecordType.rtIndividual: CheckIndividualRecord(baseContext, tree, format, rec as GDMIndividualRecord); break; case GDMRecordType.rtFamily: CheckFamilyRecord(baseContext, tree, format, rec as GDMFamilyRecord); break; case GDMRecordType.rtGroup: CheckGroupRecord(rec as GDMGroupRecord); break; case GDMRecordType.rtSource: CheckSourceRecord(rec as GDMSourceRecord); break; case GDMRecordType.rtMultimedia: CheckMultimediaRecord(rec as GDMMultimediaRecord, format, fileVer); break; } }
public override void Setup() { fBase = new BaseWindowStub(); fContext = fBase.Context; fMultimediaLink = new GDMMultimediaLink(); fDialog = new PortraitSelectDlg(fBase); fDialog.MultimediaLink = fMultimediaLink; fDialog.Show(); }
public static bool DeleteIndividualPortrait(IBaseWindow baseWin, ChangeTracker localUndoman, GDMIndividualRecord iRec) { GDMMultimediaLink mmLink = iRec.GetPrimaryMultimediaLink(); if (mmLink != null) { return(localUndoman.DoOrdinaryOperation(OperationType.otIndividualPortraitDetach, iRec, mmLink)); } return(false); }
public static GDMMultimediaLink AddMultimedia(this IGDMStructWithMultimediaLinks _struct, GDMMultimediaRecord mediaRec) { GDMMultimediaLink result = null; if (mediaRec != null) { result = new GDMMultimediaLink(); result.XRef = mediaRec.XRef; _struct.MultimediaLinks.Add(result); } return(result); }
public static GDMMultimediaLink AddMultimedia(this IGDMStructWithMultimediaLinks _struct, GDMMultimediaRecord mediaRec) { GDMMultimediaLink result = null; if (mediaRec != null) { result = new GDMMultimediaLink((GDMObject)_struct); result.Value = mediaRec; _struct.MultimediaLinks.Add(result); } return(result); }
public GDMMultimediaLink AddMultimedia(GDMMultimediaRecord mediaRec) { GDMMultimediaLink result = null; if (mediaRec != null) { result = new GDMMultimediaLink(this); result.Value = mediaRec; fMultimediaLinks.Add(result); } return(result); }
private static void CheckTagWithMultimediaLinks(GDMTree tree, GEDCOMFormat format, IGDMStructWithMultimediaLinks tag) { for (int i = tag.MultimediaLinks.Count - 1; i >= 0; i--) { GDMMultimediaLink mmLink = tag.MultimediaLinks[i]; if (!mmLink.IsPointer) { TransformMultimediaLink(tree, mmLink); } else { if (mmLink.Value == null) { tag.MultimediaLinks.DeleteAt(i); } } } }
private void CheckTagWithMultimediaLinks(IGDMStructWithMultimediaLinks tag) { for (int i = tag.MultimediaLinks.Count - 1; i >= 0; i--) { GDMMultimediaLink mmLink = tag.MultimediaLinks[i]; if (!mmLink.IsPointer) { TransformMultimediaLink(mmLink); } else { var mmRec = fTree.GetPtrValue <GDMMultimediaRecord>(mmLink); if (mmRec == null) { tag.MultimediaLinks.DeleteAt(i); } } } }
private bool ProcessRecordMediaRemove(bool redo) { IGEDCOMStructWithLists swl = fObj as IGEDCOMStructWithLists; GDMMultimediaLink mediaLink = fNewVal as GDMMultimediaLink; bool result = (swl != null && mediaLink != null); if (result) { if (redo) { swl.MultimediaLinks.Extract(mediaLink); // bugfix(no delete!) } else { swl.MultimediaLinks.Add(mediaLink); } } return(result); }
private bool ProcessRecordMediaAdd(bool redo) { IGEDCOMStructWithLists swl = fObj as IGEDCOMStructWithLists; GDMMultimediaRecord mediaRec = fNewVal as GDMMultimediaRecord; bool result = (swl != null && mediaRec != null); if (result) { if (redo) { GDMMultimediaLink mmLink = swl.AddMultimedia(mediaRec); fOldVal = mmLink; } else { GDMMultimediaLink mmLink = fOldVal as GDMMultimediaLink; swl.MultimediaLinks.Delete(mmLink); } } return(result); }
public void RemoveObsolete(GDMMultimediaLink mmLink) { if (mmLink == null) { return; } try { string imageUID = mmLink.GetUID(); string cachedFile = GetCachedFilename(imageUID); if (fMemoryCache.ContainsKey(cachedFile)) { fMemoryCache.Remove(cachedFile); } if (File.Exists(cachedFile)) { File.Delete(cachedFile); } } catch (Exception ex) { Logger.LogWrite("PortraitsCache.RemoveObsolete(): " + ex.Message); } }
public override void Modify(object sender, ModifyEventArgs eArgs) { var dataOwner = fDataOwner as IGDMStructWithMultimediaLinks; if (fBaseWin == null || fSheetList == null || dataOwner == null) { return; } GDMMultimediaLink mmLink = eArgs.ItemData as GDMMultimediaLink; bool result = false; GDMMultimediaRecord mmRec; switch (eArgs.Action) { case RecordAction.raAdd: mmRec = fBaseWin.Context.SelectRecord(GDMRecordType.rtMultimedia, new object[0]) as GDMMultimediaRecord; if (mmRec != null) { result = fUndoman.DoOrdinaryOperation(OperationType.otRecordMediaAdd, (GDMObject)dataOwner, mmRec); } break; case RecordAction.raEdit: if (mmLink != null) { mmRec = fBaseContext.Tree.GetPtrValue <GDMMultimediaRecord>(mmLink); result = BaseController.ModifyMedia(fBaseWin, ref mmRec); } break; case RecordAction.raDelete: if (AppHost.StdDialogs.ShowQuestionYN(LangMan.LS(LSID.LSID_DetachMultimediaQuery))) { result = fUndoman.DoOrdinaryOperation(OperationType.otRecordMediaRemove, (GDMObject)dataOwner, mmLink); } break; case RecordAction.raMoveUp: case RecordAction.raMoveDown: { int idx = dataOwner.MultimediaLinks.IndexOf(mmLink); switch (eArgs.Action) { case RecordAction.raMoveUp: dataOwner.MultimediaLinks.Exchange(idx - 1, idx); break; case RecordAction.raMoveDown: dataOwner.MultimediaLinks.Exchange(idx, idx + 1); break; } result = true; } break; } if (result) { fBaseWin.Context.Modified = true; eArgs.IsChanged = true; } }
public static GDMMultimediaRecord GetPtrValue(this GDMTree tree, GDMMultimediaLink ptr) { return(tree.GetPtrValue <GDMMultimediaRecord>(ptr)); }