コード例 #1
0
        protected override bool InternalGetDataHere(ref System.Runtime.InteropServices.ComTypes.FORMATETC format, ref System.Runtime.InteropServices.ComTypes.STGMEDIUM medium)
        {
            if (format.cfFormat == DataObjectHelper.CF_EMBEDSOURCE && (format.tymed & TYMED.TYMED_ISTORAGE) != 0)
            {
                medium.tymed          = TYMED.TYMED_ISTORAGE;
                medium.pUnkForRelease = null;
                var stg = (IStorage)Marshal.GetObjectForIUnknown(medium.unionmember);
                // we don't save the document directly, since this would mean to save the whole (and probably huge) project
                // instead we first make a mini project with the neccessary data only and then save this instead
                InternalSaveMiniProject(stg, _altaxoMiniProject, _graphDocumentName);
                return(true);
            }

            if (format.cfFormat == DataObjectHelper.CF_LINKSOURCE && (format.tymed & TYMED.TYMED_ISTREAM) != 0)
            {
                // we should make sure that ComManager is already started, so that the moniker can be used by the program
                if (!_comManager.IsActive)
                {
                    _comManager.StartLocalServer();
                }

                IMoniker documentMoniker = CreateNewDocumentMoniker();

                if (null != documentMoniker)
                {
                    medium.tymed          = TYMED.TYMED_ISTREAM;
                    medium.pUnkForRelease = null;
                    var strm = (IStream)Marshal.GetObjectForIUnknown(medium.unionmember);
                    DataObjectHelper.SaveMonikerToStream(documentMoniker, strm);
                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
 protected override bool InternalGetDataHere(ref System.Runtime.InteropServices.ComTypes.FORMATETC format, ref System.Runtime.InteropServices.ComTypes.STGMEDIUM medium)
 {
     if (format.cfFormat == DataObjectHelper.CF_LINKSOURCE && (format.tymed & TYMED.TYMED_ISTREAM) != 0)
     {
         var moniker = Moniker;
         if (null != moniker)
         {
             medium.tymed          = TYMED.TYMED_ISTREAM;
             medium.pUnkForRelease = null;
             var strm = (IStream)Marshal.GetObjectForIUnknown(medium.unionmember);
             DataObjectHelper.SaveMonikerToStream(Moniker, strm);
             return(true);
         }
     }
     return(false);
 }