コード例 #1
0
ファイル: ClipDataType.cs プロジェクト: wlu0119/SmartPaster
 /// <summary>
 /// クリップボードの情報の形式
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 internal static bool IsPasteType(this ClipDataType type)
 {
     if (type == ClipDataType.Text)
     {
         return(true);
     }
     else if (type == ClipDataType.Image)
     {
         return(true);
     }
     else if (type == ClipDataType.Folder)
     {
         return(true);
     }
     else if (type == ClipDataType.File)
     {
         return(true);
     }
     else if (type == ClipDataType.Other)
     {
         return(false);
     }
     else
     {
         return(false);
     }
 }
コード例 #2
0
        public static object ReadData(JToken jToken, ClipDataType dataType)
        {
            switch (dataType)
            {
                case ClipDataType.Text:
                    return jToken.Value<string>();
            }

            return null;
        }
コード例 #3
0
        public bool Equals(ClipDataType clipDataType, string text)
        {
            if (DataType != clipDataType)
                return false;

            if (Data != null && ((string)Data).CompareTo(text) != 0)
                return false;

            return true;
        }
コード例 #4
0
        public bool AddNewClipData(ClipDataType clipDataType, string text)
        {
            if (m_history.Last != null && m_history.Last.Value.Equals(clipDataType, text) == true)
                return false;

            HistoryData historyData = new HistoryData();
            historyData.DataType = clipDataType;
            historyData.Data = text;

            m_history.AddLast(historyData);

            CheckHistoryCapacity();

            return true;
        }
コード例 #5
0
ファイル: ClipDataType.cs プロジェクト: wlu0119/SmartPaster
        /// <summary>
        /// 保存処理
        /// </summary>
        /// <param name="type"></param>
        /// <param name="stream"></param>
        internal static void Export(this ClipDataType type, Stream stream)
        {
            if (stream == null)
            {
                return;
            }
            if (type == ClipDataType.Text)
            {
                using (StreamWriter sw = new StreamWriter(stream))
                {
                    if (Clipboard.ContainsText(TextDataFormat.CommaSeparatedValue))
                    {
                        sw.Write(Clipboard.GetText(TextDataFormat.CommaSeparatedValue));
                    }
                    else
                    {
                        sw.Write(Clipboard.GetText(TextDataFormat.Text));
                    }
                }
            }

            else if (type == ClipDataType.Image)
            {
                Image bmp = Clipboard.GetImage();
                bmp.Save(stream, ImageFormat.Bmp);
            }

            else if (type == ClipDataType.Folder)
            {
                throw new NotSupportedException("未対応のファイル形式がクリップボードに含まれています.");
            }
            else if (type == ClipDataType.File)
            {
                throw new NotSupportedException("未知のフォルダ形式がクリップボードに含まれています.");
            }
            else if (type == ClipDataType.Other)
            {
                throw new NotSupportedException("未知の形式がクリップボードに含まれています.");
            }
            else
            {
                throw new NotSupportedException("未知の形式がクリップボードに含まれています.");
            }
        }
コード例 #6
0
ファイル: ClipDataType.cs プロジェクト: wlu0119/SmartPaster
        /// <summary>
        /// 拡張子の取得
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        internal static string GetExt(this ClipDataType type)
        {
            if (type == ClipDataType.Text)
            {
                if (Clipboard.ContainsText(TextDataFormat.CommaSeparatedValue))
                {
                    return("csv");
                }
                else
                {
                    return("txt");
                }
            }

            else if (type == ClipDataType.Image)
            {
                return("bmp");
            }

            else if (type == ClipDataType.Folder)
            {
                throw new NotSupportedException("未対応のファイル形式がクリップボードに含まれています.");
            }
            else if (type == ClipDataType.File)
            {
                throw new NotSupportedException("未知のフォルダ形式がクリップボードに含まれています.");
            }
            else if (type == ClipDataType.Other)
            {
                throw new NotSupportedException("未知の形式がクリップボードに含まれています.");
            }
            else
            {
                throw new NotSupportedException("未知の形式がクリップボードに含まれています.");
            }
        }