Ejemplo n.º 1
0
        public string SaveTrackItem(out ITrackItemCache nextStatus, string path)
        {
            // ファイルを作成してみて保存パス名を決める
            string fileName = string.Empty;

            for (int index = 1; index < int.MaxValue; ++index)
            {
                fileName = string.Format("TrackItem{0:D4}.dat", index);
                try
                {
                    string savePath = Path.Combine(path, fileName);
                    using (Stream stream = new FileStream(savePath, FileMode.CreateNew))
                    {
                        stream.SetLength(0);
                        stream.Flush();
                        using (TrackItemWriter tiw = new TrackItemWriter(stream))
                        {
                            // 保存します
                            tiw.Write(_item);

                            // ファイルが作成できたからこれをファイル名にします。
                            _fileName = fileName;
                            break;
                        }
                    }
                }
                catch (IOException)
                {
                    // ファイル名が作成できないみたいだらから
                    continue;
                }
            }
            nextStatus = new TrackItemCacheLoaded(_item, _fileName);
            return(_fileName);
        }
Ejemplo n.º 2
0
        public void UpdateTrackItem(out ITrackItemCache nextStatus, string path)
        {
            nextStatus = this;

            // 保存されていないのですから、ここでは更新しません。
            return;
        }
Ejemplo n.º 3
0
        public string SaveTrackItem(out ITrackItemCache nextStatus, string path)
        {
            nextStatus = this;

            // もともとあるものをロードされているので、ここでは保存しない

            return(_fileName);
        }
Ejemplo n.º 4
0
        public TrackItem GetTrackItem(out ITrackItemCache nextStatus)
        {
            string filePath = System.IO.Path.Combine(_savePath, _fileName);

            using (TrackItemReader tir = new TrackItemReader(filePath))
            {
                _item = tir.Read();
            }

            nextStatus = new TrackItemCacheLoaded(_item, _fileName);
            return(_item);
        }
Ejemplo n.º 5
0
        public TrackItemSummary(SerializationInfo info, StreamingContext context)
        {
            ID = GenerateID();

            int version = info.GetInt32("Version");

            PointCount    = info.GetInt32("PointCount");
            From          = info.GetDateTime("From");
            To            = info.GetDateTime("To");
            _name         = info.GetString("Name");
            Description   = info.GetString("Description");
            _saveFileName = info.GetString("saveFileName");

            _trackItemProxy = new TrackItemCacheNotLoaded(_savePath, _saveFileName);
        }
Ejemplo n.º 6
0
        public string SaveTrackItem(out ITrackItemCache nextStatus, string path)
        {
            // 上書き保存
            string savaPath = Path.Combine(path, this._fileName);

            using (Stream stream = new FileStream(savaPath, FileMode.Create, FileAccess.Write))
            {
                stream.SetLength(0);
                stream.Flush();
                using (TrackItemWriter tiw = new TrackItemWriter(stream))
                {
                    // 保存します
                    tiw.Write(_item);
                }
            }

            nextStatus = new TrackItemCacheLoaded(_item, _fileName);

            return(_fileName);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// リカバリー用コンストラクタ
        /// </summary>
        /// <param name="track">リカバリーデータ</param>
        /// <param name="filePath">リカバリー元のファイル</param>
        public TrackItemSummary(bykIFv1.TrackItem track, string filePath)
        {
            track.Normalize();

            PointCount = track.Items.Count;
            From       = track.Items[0].Time;
            TimeSpan span = System.TimeZoneInfo.Local.GetUtcOffset(From);

            From = From.Add(span);

            To   = track.Items[PointCount - 1].Time;
            span = System.TimeZoneInfo.Local.GetUtcOffset(To);
            To   = To.Add(span);

            Description = track.Description;

            _name           = track.Name;
            _trackItemProxy = new TrackItemCacheLoaded(track, filePath);

            _saveFileName = filePath;
        }
Ejemplo n.º 8
0
        public TrackItemSummary(bykIFv1.TrackItem track)
        {
            track.Normalize();

            ID = GenerateID();

            PointCount = track.Items.Count;
            From       = track.Items[0].Time;
            TimeSpan span = System.TimeZoneInfo.Local.GetUtcOffset(From);

            From = From.Add(span);

            To   = track.Items[PointCount - 1].Time;
            span = System.TimeZoneInfo.Local.GetUtcOffset(To);
            To   = To.Add(span);

            Description = track.Description;

            _name           = track.Name;
            _trackItemProxy = new TrackItemCacheNotYetSaved(track);

            _saveFileName = string.Empty;
        }
Ejemplo n.º 9
0
 public TrackItem GetTrackItem(out ITrackItemCache nextStatus)
 {
     nextStatus = this;
     return(this._item);
 }
Ejemplo n.º 10
0
 public void UpdateTrackItem(out ITrackItemCache nextStatus, string path)
 {
     nextStatus = new TrackItemCacheModified(_item, _fileName);
     // 処理なし
     return;
 }
Ejemplo n.º 11
0
 public void UpdateTrackItem(out ITrackItemCache nextStatus, string path)
 {
     nextStatus = this;
     // 処理なし
     return;
 }
Ejemplo n.º 12
0
 public void UpdateTrackItem(out ITrackItemCache nextStatus, string path)
 {
     throw new Exception("未ロードから変更へは状態を更新できません。");
 }
Ejemplo n.º 13
0
        public string SaveTrackItem(out ITrackItemCache nextStatus, string path)
        {
            nextStatus = this;

            return(_fileName);
        }