Пример #1
0
        /// <summary>
        /// クリップボードに貼り付けられたアイテムを取得します.
        /// </summary>
        /// <returns>クリップボードに貼り付けられたアイテムを格納したClipboardEntryのインスタンス</returns>
        public ClipboardEntry getCopiedItems()
        {
            ClipboardEntry ce = null;

#if CLIPBOARD_AS_TEXT
            String clip = PortUtil.getClipboardText();
            if (clip != null && str.startsWith(clip, CLIP_PREFIX))
            {
                int    index1   = clip.IndexOf(":");
                int    index2   = clip.IndexOf(":", index1 + 1);
                String typename = str.sub(clip, index1 + 1, index2 - index1 - 1);
#if DEBUG
                sout.println("ClipboardModel#getCopiedItems; typename=" + typename);
#endif
                if (typename.Equals(typeof(ClipboardEntry).FullName))
                {
                    try {
                        ce = (ClipboardEntry)getDeserializedObjectFromText(clip);
                    } catch (Exception ex) {
                        Logger.write(typeof(ClipboardModel) + ".getCopiedItems; ex=" + ex + "\n");
                    }
                }
            }
#else
            IDataObject dobj = Clipboard.GetDataObject();
            if (dobj != null)
            {
                Object obj = dobj.GetData(typeof(ClipboardEntry));
                if (obj != null && obj is ClipboardEntry)
                {
                    ce = (ClipboardEntry)obj;
                }
            }
#endif
            if (ce == null)
            {
                ce = new ClipboardEntry();
            }
            if (ce.beziers == null)
            {
                ce.beziers = new SortedDictionary <CurveType, List <BezierChain> >();
            }
            if (ce.events == null)
            {
                ce.events = new List <VsqEvent>();
            }
            if (ce.points == null)
            {
                ce.points = new SortedDictionary <CurveType, VsqBPList>();
            }
            if (ce.tempo == null)
            {
                ce.tempo = new List <TempoTableEntry>();
            }
            if (ce.timesig == null)
            {
                ce.timesig = new List <TimeSigTableEntry>();
            }
            return(ce);
        }