/// <summary> /// データ文字列を読み取り各フィールドを設定する。 /// </summary> /// <param name="dataString">データ文字列</param> private void InterpretDataString(string dataString) { try { DataStringDictionary dsd = new DataStringDictionary(dataString); this.author = dsd["Author"]; this.id = dsd["ID"]; this.serialNumber = long.Parse(dsd["SerialNumber"]); this.date = new DateTime(long.Parse(dsd["Ticks"])); AddTag(PhotoChat.StringToArray(dsd.GetValue("TagList", string.Empty))); this.proximity = dsd.GetValue("Proximity", string.Empty); this.noteCount = int.Parse(dsd.GetValue("NoteCount", "0")); this.unread = bool.Parse(dsd.GetValue("Unread", "false")); this.updated = bool.Parse(dsd.GetValue("Updated", "false")); this.marked = bool.Parse(dsd.GetValue("Marked", "false")); this.attentionFlag = bool.Parse(dsd.GetValue("AttentionFlag", "false")); this.needImageUpdate = int.Parse(dsd.GetValue("NeedImageUpdate", "0")); // GPS座標の読み取り string str = dsd.GetValue("Geo", "200,200"); int index = str.IndexOf(','); this.latitude = double.Parse(str.Substring(0, index)); this.longitude = double.Parse(str.Substring(index + 1)); } catch (Exception e) { throw new UnsupportedDataException(e.Message); } }
/// <summary> /// データ文字列を読み取り各値を設定する。 /// </summary> /// <param name="dataString">データ文字列</param> private void InterpretDataString(string dataString) { try { DataStringDictionary dsd = new DataStringDictionary(dataString); this.author = dsd["Author"]; this.id = dsd["ID"]; this.serialNumber = long.Parse(dsd["SerialNumber"]); this.date = new DateTime(long.Parse(dsd["Ticks"])); this.photoName = dsd["PhotoName"]; Color color = Color.FromArgb(int.Parse(dsd["Color"])); this.brush = new SolidBrush(color); int fontSize = int.Parse(dsd["Size"]); this.font = new Font(PhotoChat.FontName, fontSize, FontStyle.Bold); this.infoText = author + date.ToString(PhotoChat.DateFormat); // テキストの位置の読み取り string str = dsd["Point"]; int index = str.IndexOf(SubDelimiter); int x = int.Parse(str.Substring(0, index)); int y = int.Parse(str.Substring(index + 1)); Point point = new Point(x, y); // テキストの読み取り str = dsd["Body"]; this.bodyText = str.Replace("< BR >", Environment.NewLine); // 書き込み領域を求める this.range = GetRange(point); } catch (Exception e) { throw new UnsupportedDataException(e.Message); } }
/// <summary> /// データ文字列を読み取り各値を設定する。 /// </summary> /// <param name="dataString">データ文字列</param> private void InterpretDataString(string dataString) { try { DataStringDictionary dsd = new DataStringDictionary(dataString); this.author = dsd["Author"]; this.id = dsd["ID"]; this.serialNumber = long.Parse(dsd["SerialNumber"]); this.date = new DateTime(long.Parse(dsd["Ticks"])); this.photoName = dsd["PhotoName"]; this.soundFileName = dsd["SoundFileName"]; this.infoText = author + date.ToString(PhotoChat.DateFormat); // 位置の読み取り string str = dsd["Point"]; int index = str.IndexOf(SubDelimiter); int x = int.Parse(str.Substring(0, index)); int y = int.Parse(str.Substring(index + 1)); this.range = new Rectangle(new Point(x, y), soundImage.Size); } catch (Exception e) { throw new UnsupportedDataException(e.Message); } }
/// <summary> /// データ文字列を読み取り各値を設定する。 /// </summary> /// <param name="dataString">データ文字列</param> private void InterpretDataString(string dataString) { try { DataStringDictionary dsd = new DataStringDictionary(dataString); this.author = dsd["Author"]; this.id = dsd["ID"]; this.serialNumber = long.Parse(dsd["SerialNumber"]); this.date = new DateTime(long.Parse(dsd["Ticks"])); this.photoName = dsd["PhotoName"]; this.linkedPhotoName = dsd["Link"]; this.thumbnailImage = Thumbnail.GetImage( linkedPhotoName, PhotoChat.ThumbnailBoxWidth, PhotoChat.ThumbnailBoxHeight); this.infoText = author + date.ToString(PhotoChat.DateFormat); // 貼り付け位置の読み取り string str = dsd["Point"]; int index = str.IndexOf(SubDelimiter); int x = int.Parse(str.Substring(0, index)); int y = int.Parse(str.Substring(index + 1)); this.range = new Rectangle( x, y, PhotoChat.ThumbnailBoxWidth, PhotoChat.ThumbnailBoxHeight); } catch (Exception e) { throw new UnsupportedDataException(e.ToString()); } }
/// <summary> /// データ文字列を読み取り各値を設定する。 /// </summary> /// <param name="dataString">データ文字列</param> private void InterpretDataString(string dataString) { try { DataStringDictionary dsd = new DataStringDictionary(dataString); this.author = dsd["Author"]; this.id = dsd["ID"]; this.serialNumber = long.Parse(dsd["SerialNumber"]); this.date = new DateTime(long.Parse(dsd["Ticks"])); this.proximity = dsd.GetValue("Proximity", string.Empty); this.infoText = author + date.ToString(PhotoChat.DateFormat); SetPhotoName(); // GPS座標の読み取り string str = dsd.GetValue("Geo", "200,200"); int index = str.IndexOf(','); this.latitude = double.Parse(str.Substring(0, index)); this.longitude = double.Parse(str.Substring(index + 1)); } catch (Exception e) { throw new UnsupportedDataException(e.Message); } }
/// <summary> /// データ文字列を読み取り各値を設定する。 /// </summary> /// <param name="dataString">データ文字列</param> private void InterpretDataString(string dataString) { try { DataStringDictionary dsd = new DataStringDictionary(dataString); this.id = dsd["ID"]; this.serialNumber = long.Parse(dsd["SerialNumber"]); this.fileName = dsd["FileName"]; } catch (Exception e) { throw new UnsupportedDataException(e.Message); } }
/// <summary> /// データのバイト列を読み取り各値を設定する。 /// </summary> /// <param name="dataBytes">データのバイト列</param> private void InterpretDataBytes(byte[] dataBytes) { try { string dataString = PhotoChat.DefaultEncoding.GetString(dataBytes); DataStringDictionary dsd = new DataStringDictionary(dataString); this.serialNumber = long.Parse(dsd["SerialNumber"]); this.timeStamp = new DateTime(long.Parse(dsd["TimeStamp"])); this.authorID = dsd["AuthorID"]; this.sourceID = dsd["SourceID"]; this.userName = dsd["UserName"]; this.photoName = dsd["PhotoName"]; } catch (Exception e) { throw new UnsupportedDataException(e.Message); } }
/// <summary> /// データ文字列を読み取り各値を設定する。 /// </summary> /// <param name="dataString">データ文字列</param> private void InterpretDataString(string dataString) { try { DataStringDictionary dsd = new DataStringDictionary(dataString); this.author = dsd["Author"]; this.id = dsd["ID"]; this.serialNumber = long.Parse(dsd["SerialNumber"]); this.date = new DateTime(long.Parse(dsd["Ticks"])); this.photoName = dsd["PhotoName"]; this.tagString = dsd["Tag"]; this.infoText = author + date.ToString(PhotoChat.DateFormat); } catch (Exception e) { throw new UnsupportedDataException(e.Message); } }
/// <summary> /// 写真に付けられたタグをコンマ区切りで取得する。 /// インスタンスが存在する場合はTagsプロパティから取得したほうが速い。 /// </summary> /// <param name="photoName">写真名</param> /// <returns>写真に付けられたタグのコンマ区切り文字列</returns> public static string GetTags(string photoName) { try { string filePath = GetDataFilePath(photoName); if (File.Exists(filePath)) { string line; using (StreamReader sr = new StreamReader(filePath)) { line = sr.ReadLine(); } DataStringDictionary dsd = new DataStringDictionary(line); return(dsd.GetValue("TagList", string.Empty)); } } catch (Exception e) { PhotoChat.WriteErrorLog(e.ToString()); } return(string.Empty); }
/// <summary> /// データ文字列を読み取り各値を設定する。 /// </summary> /// <param name="dataString">データ文字列</param> private void InterpretDataString(string dataString) { try { DataStringDictionary dsd = new DataStringDictionary(dataString); this.author = dsd["Author"]; this.id = dsd["ID"]; this.serialNumber = long.Parse(dsd["SerialNumber"]); this.date = new DateTime(long.Parse(dsd["Ticks"])); this.photoName = dsd["PhotoName"]; this.color = Color.FromArgb(int.Parse(dsd["Color"])); this.strokeWidth = int.Parse(dsd["Width"]); this.infoText = author + date.ToString(PhotoChat.DateFormat); SetPen(); // 点素データの読み取り string pointData = dsd["Points"]; this.points = new List <Point>(); int index, x, y; foreach (string str in pointData.Split( new Char[] { Space }, StringSplitOptions.RemoveEmptyEntries)) { index = str.IndexOf(SubDelimiter); x = int.Parse(str.Substring(0, index)); y = int.Parse(str.Substring(index + 1)); points.Add(new Point(x, y)); } // ストロークを固定し範囲を計算する Fix(); FigureRange(); } catch (Exception e) { throw new UnsupportedDataException(e.Message); } }