예제 #1
0
        // Constructor
        public PicturesForm( CISRecord r, CGedcom gedcom )
        {
            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();

            m_bExtraUserInfoAdded = false;
            m_bDisablePictureListCheckEvent = true;
            m_record = r;
            // Add pictures
            // Copy MFRs to a new list
            m_alMultimediaFileRefs = new ArrayList();
            foreach( CMultimediaFileReference mfr in m_record.m_alUniqueFileRefs )
            {
                CAsidPair mmasidPair = mfr.m_asidPair;
                CMultimediaFileReference new_mfr = new CMultimediaFileReference( mfr, true ); // Make copy
                m_alMultimediaFileRefs.Add( new_mfr );
            }

            m_gedcom = gedcom;

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            m_listviewPictures.View = View.Details;
            m_listviewPictures.Columns.Add("Title", (m_listviewPictures.Width-6) * 40 / 100, HorizontalAlignment.Left);
            m_listviewPictures.Columns.Add("Filename", (m_listviewPictures.Width-6) * 60 / 100, HorizontalAlignment.Left);

            m_sizePictureBox = m_picturebox.Size;

            // Add pictures
            FillPicturesList( m_listviewPictures, m_alMultimediaFileRefs );
            EnableButtons();

            // Select first checked picture
            int index = 0;
            foreach( CListableMFR lmfr in m_listviewPictures.Items )
            {
                if( lmfr.Checked )
                {
                    index = lmfr.Index;
                    break;
                }
            }
            SetPicture(index);

            Cursor.Current = Cursors.Default;
            Cursor.Show();
        }
        // Constructor
        public CRecordDetailsForm( IWin32Window parent, CISRecord r, CGedcom gedcomParser, bool bCanEditPictures, bool bCanSelectText )
        {
            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();
            m_bCanSelectText = bCanSelectText;
            m_gedcom = gedcomParser;
            m_record = r;

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
            m_buttonPictures.Visible = bCanEditPictures;

            m_sizePictureBox = m_picturebox.Size;

            if( r == null )
            {
                return;
            }

            string sDetails = m_record.Details();

            if( m_record is CSourceRecord )
            {
                sDetails += "\r\nReferenced by: ";
                string sBackref = "";
                Hashtable htBackrefs = ((CSourceRecord)m_record).MakeBackRefList();

                IDictionaryEnumerator ide = htBackrefs.GetEnumerator();
                while( ide.MoveNext() )
                {
                    CIndividualRecord ir = (CIndividualRecord)(ide.Value);
                    if( ir != null )
                    {

                        string sFirstName = "";
                        string sSurname = "";
                        string sName = MainForm.s_config.CapitaliseName( ir.Name, ref sFirstName, ref sSurname );
                        if( sName == "" )
                        {
                            sName = MainForm.s_config.m_sUnknownName;
                        }

                        if( sName != "" )
                        {
                            if( sBackref != "" )
                            {
                                sBackref += ", ";
                            }
                            sBackref += sName;
                        }
                    }
                }
                if( sBackref == "" )
                {
                    sDetails += "no references";
                }
                else
                {
                    sDetails += sBackref;
                }
            }

            if( m_bCanSelectText )
            {
                m_textbox.Text = sDetails;
                m_textbox.SelectionLength = 0;
            }
            else
            {
                m_labelDetailsText.Text = sDetails;
            }

            // Select first picture
            SetPicture();

            m_buttonOk.Select(); // To avoid flashing cursor appearing in text box when window appears.

            Cursor.Current = Cursors.Default;
            Cursor.Show();
        }
예제 #3
0
 // Reads the MFRs from the changes file (MFR here is for the user's modifications to the multimedia attached to a record)
 private bool LoadMFRs(CISRecord isr, CISRecordChanges isrc)
 {
     bool bDifferencesDetected = false;
     for (int n = isr.m_alUniqueFileRefs.Count - 1; n >= 0; --n) // Can't use foreach, because then Remove() would corrupt iterator.
     {
         CMultimediaFileReference mfr = (CMultimediaFileReference)(isr.m_alUniqueFileRefs[n]);
         if (mfr.m_bFromGEDCOM == false)
         {
             isr.m_alUniqueFileRefs.RemoveAt(n);
         }
         else
         {
             mfr.m_bVisible = false;
         }
     }
     foreach (CMultimediaFileReference mfr in isrc.m_alMfrs)
     {
         CMultimediaFileReference mfrFound = null;
         foreach (CMultimediaFileReference mfrUnique in isr.m_alUniqueFileRefs)
         {
             if (mfr.m_bEmbedded && mfrUnique.m_bEmbedded)
             {
                 if (mfr.m_xrefEmbedded == mfrUnique.m_xrefEmbedded)
                 {
                     mfrFound = mfrUnique;
                     break;
                 }
             }
             if (!mfr.m_bEmbedded && !mfrUnique.m_bEmbedded)
             {
                 if (mfr.m_sMultimediaFileReference == mfrUnique.m_sMultimediaFileReference)
                 {
                     mfrFound = mfrUnique;
                     break;
                 }
             }
         }
         if (mfrFound == null)
         {
             //Must be a user added file. Add it to unique mfrs
             if (File.Exists(mfr.m_sMultimediaFileReference))
             {
                 isr.m_alUniqueFileRefs.Add(mfr);
                 if (mfr.m_bFromGEDCOM)
                 {
                     // User must have removed this file in the interim
                     bDifferencesDetected = true;
                 }
             }
             else
             {
                 // File has been deleted or moved in the interim
                 bDifferencesDetected = true;
             }
         }
         else
         {
             if (mfrFound.m_bEmbedded)
             {
                 string sKeepEmbeddedFilename = mfrFound.m_sMultimediaFileReference;
                 mfrFound.CopyFrom(mfr);
                 mfrFound.m_sMultimediaFileReference = sKeepEmbeddedFilename;
             }
             else
             {
                 mfrFound.CopyFrom(mfr);
             }
         }
     }
     // Fix duplicates of order values
     foreach (CMultimediaFileReference imfr in isr.m_alUniqueFileRefs)
     {
         foreach (CMultimediaFileReference dimfr in isr.m_alUniqueFileRefs)
         {
             int nOrderIndex = imfr.m_nOrderIndex;
             if (imfr != dimfr && nOrderIndex == dimfr.m_nOrderIndex)
             {
                 foreach (CMultimediaFileReference iimfr in isr.m_alUniqueFileRefs)
                 {
                     if (iimfr.m_nOrderIndex >= nOrderIndex)
                     {
                         iimfr.m_nOrderIndex += 1;
                     }
                 }
                 imfr.m_nOrderIndex = nOrderIndex;
             }
         }
     }
     return (bDifferencesDetected);
 }