Exemple #1
0
        private void _locationSources_AfterLabelEdit(object sender, LabelEditEventArgs e)
        {
            ListView lv = sender as ListView;

            if (null == lv)
            {
                e.CancelEdit = true;
                return;
            }

            if (e.Label != null)
            {
                if (0 == e.Label.Length)
                {
                    e.CancelEdit = true;
                    return;
                }

                int index = e.Item;

                ListViewItem     item      = lv.Items[index];
                TrackItemSummary trackItem = item.Tag as TrackItemSummary;
                if (null == trackItem)
                {
                    e.CancelEdit = true;
                    return;
                }
                trackItem.Name = e.Label;

                _trackItemBag.Save();
            }
        }
Exemple #2
0
        private void UpdateLocationList()
        {
            try
            {
                int    selIndex = -1;
                UInt32 ID       = 0;
                // 選択されているITEMのIDを記録しておく
                if (1 == _locationSources.SelectedItems.Count)
                {
                    TrackItemSummary tiSum = _locationSources.SelectedItems[0].Tag as TrackItemSummary;
                    if (null != tiSum)
                    {
                        ID = tiSum.ID;
                    }
                }

                _locationSources.BeginUpdate();
                _locationSources.Items.Clear();
                // Itemを再設定
                foreach (TrackItemSummary tiSum in _trackItemBag.Items)
                {
                    ListViewItem viewItem = new ListViewItem(new string[] { tiSum.Name, tiSum.From.ToString("yyyy/MM/dd HH:mm:ss"), tiSum.To.ToString("yyyy/MM/dd HH:mm:ss"), tiSum.PointCount.ToString() });
                    if (null != tiSum.Description && 0 <= tiSum.Description.Length)
                    {
                        viewItem.ToolTipText = tiSum.Description;
                    }
                    viewItem.Tag = tiSum;

                    _locationSources.Items.Add(viewItem);

                    if (0 != ID)
                    {
                        // 選択されていたIDと同じITEMのindexを記録
                        if (ID == tiSum.ID)
                        {
                            selIndex = _locationSources.Items.Count - 1;
                        }
                    }
                }

                // 選択されていたIDを再選択
                if (0 <= selIndex)
                {
                    _locationSources.SelectedIndices.Add(selIndex);
                }
            }
            finally
            {
                _locationSources.EndUpdate();
            }
        }
Exemple #3
0
        public void Down(UInt32 ID)
        {
            for (int index = 0; index < _locations.Count; ++index)
            {
                if (ID == _locations[index].ID)
                {
                    TrackItemSummary item = _locations[index];

                    _locations.Remove(item);
                    _locations.Insert(index + 1, item);

                    break;
                }
            }
        }
Exemple #4
0
        public UInt32 AddItem(bykIFv1.TrackItem track)
        {
            TrackItemSummary tiSum = new TrackItemSummary(track);

            if (0 == _locations.Count)
            {
                _locations.Add(tiSum);
            }
            else
            {
                _locations.Insert(0, tiSum);
            }

            return(tiSum.ID);
        }
Exemple #5
0
        public UInt32 AddItem(UInt32 id, bykIFv1.TrackItem track)
        {
            TrackItemSummary tiSum = new TrackItemSummary(track);
            int index = _locations.FindIndex(x => x.ID == id);

            if (0 > index)
            {
                _locations.Add(tiSum);
            }
            else
            {
                _locations.Insert(index, tiSum);
            }

            return(tiSum.ID);
        }
Exemple #6
0
        private void _export_Click(object sender, EventArgs e)
        {
            if (1 != _locationSources.SelectedItems.Count)
            {
                return;
            }
            ListViewItem     item             = _locationSources.SelectedItems[0];
            TrackItemSummary trackItemSummary = item.Tag as TrackItemSummary;

            if (null == trackItemSummary)
            {
                return;
            }

            ToolStripMenuItem menu = sender as ToolStripMenuItem;

            if (null == menu)
            {
                return;
            }

            ExportMethod  exportMethod = null;
            EXPORT_FORMAT format       = (EXPORT_FORMAT)menu.Tag;

            switch (format)
            {
            case EXPORT_FORMAT.GPX:
                _exportFileDialog.DefaultExt = ".gpx";
                _exportFileDialog.Filter     = "GPX Files|*.gpx|ALL Files|*.*";
                _exportFileDialog.FileName   = trackItemSummary.Name;
                exportMethod = new ExportMethod(ExportGPX);
                break;

            default:
                return;
            }

            if (DialogResult.OK == _exportFileDialog.ShowDialog(this))
            {
                bykIFv1.TrackItem trackItem = trackItemSummary.TrackItem;
                if (null != exportMethod)
                {
                    exportMethod(_exportFileDialog.FileName, trackItem);
                }
            }
        }
Exemple #7
0
        private void _deleteTrackItem_Click(object sender, EventArgs e)
        {
            if (0 >= _locationSources.SelectedItems.Count)
            {
                return;
            }
            if (DialogResult.OK != MessageBox.Show(Properties.Resources.MSG1, this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question))
            {
                return;
            }

            bool removed = false;

            foreach (ListViewItem item in _locationSources.SelectedItems)
            {
                TrackItemSummary tiSum = item.Tag as TrackItemSummary;
                if (null == tiSum)
                {
                    continue;
                }

                _trackItemBag.Remove(tiSum.ID);
                removed = true;
            }
            if (removed)
            {
                this.UseWaitCursor = true;

                UpdateLocationList();

#if true
                // データが変化したので保存します。
                var task = Task.Factory.StartNew(() =>
                {
                    _trackItemBag.Save();
                }).ContinueWith(_ =>
                {
                    this.UseWaitCursor = false;
                }, TaskScheduler.FromCurrentSynchronizationContext());
#else
                _trackItemBag.Save();
                this.UseWaitCursor = false;
#endif
            }
        }
Exemple #8
0
        public void Load()
        {
            // 場所情報のサマリーを取得する
            string locations = System.IO.Path.Combine(_savePath, "BayakiSummary.dat");

            if (File.Exists(locations))
            {
                using (var stream = new FileStream(locations, FileMode.Open))
                {
                    BinaryFormatter bf = new BinaryFormatter();
                    _locations = bf.Deserialize(stream) as List <TrackItemSummary>;
                }
            }
            else
            {
                // ファイルがないけど、リカバリーを試みよう
                DirectoryInfo di = new DirectoryInfo(_savePath);
                foreach (FileInfo fi in di.GetFiles("TrackItem*.dat"))
                {
                    try
                    {
                        using (TrackItemReader tir = new TrackItemReader(fi.FullName))
                        {
                            bykIFv1.TrackItem item = tir.Read();
                            if (null != item)
                            {
                                TrackItemSummary summary = new TrackItemSummary(item, fi.FullName);

                                _locations.Add(summary);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        // 読み込みでエラーが発生する可能性は、この場合では無視する。
                        System.Diagnostics.Debug.Print(ex.Message);
                    }
                }

                if (0 < _locations.Count)
                {
                    Save();
                }
            }
        }
Exemple #9
0
        private void _downPriority_Click(object sender, EventArgs e)
        {
            if (1 != _locationSources.SelectedItems.Count)
            {
                return;
            }

            TrackItemSummary tiSum = _locationSources.SelectedItems[0].Tag as TrackItemSummary;

            if (null == tiSum)
            {
                return;
            }

            _trackItemBag.Down(tiSum.ID);

            _trackItemBag.Save();
            UpdateLocationList();
        }
Exemple #10
0
        private void _routePreview_Click(object sender, EventArgs e)
        {
            if (1 != _locationSources.SelectedItems.Count)
            {
                return;
            }
            ListViewItem     lvItem       = _locationSources.SelectedItems[0];
            TrackItemSummary trackSummary = lvItem.Tag as TrackItemSummary;

            if (null == trackSummary)
            {
                return;
            }

            bykIFv1.TrackItem trackItem = trackSummary.TrackItem;

            trackItem.Name = trackSummary.Name;
            TrackPointPreviewForm tpf = new TrackPointPreviewForm(trackItem);

            tpf.Show(this);
        }
Exemple #11
0
        private void _splitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (1 != _locationSources.SelectedItems.Count)
            {
                return;
            }
            ListViewItem     lvItem       = _locationSources.SelectedItems[0];
            TrackItemSummary trackSummary = lvItem.Tag as TrackItemSummary;

            if (null == trackSummary)
            {
                return;
            }

            bykIFv1.TrackItem trackItem = trackSummary.TrackItem;

            trackItem.Name = trackSummary.Name;

            SplitForm sf = new SplitForm(trackItem);

            if (DialogResult.OK != sf.ShowDialog())
            {
                return;
            }

            UInt32 inserPosID  = trackSummary.ID;
            bool   blNewTracks = false;

            foreach (bykIFv1.TrackItem track in sf.Items)
            {
                if (null == track)
                {
                    continue;
                }
                if (1 > track.Items.Count)
                {
                    continue;
                }

                System.Diagnostics.Debug.Print(string.Format("create:{1} name:{0}", track.Name, track.CreateTime));

                inserPosID  = _trackItemBag.AddItem(inserPosID, track);
                blNewTracks = true;
            }

            if (blNewTracks)
            {
                // 分割されたので元データを削除します
                _trackItemBag.Remove(trackSummary.ID);

                this.UseWaitCursor = true;

                // 読み込んでいるイメージに対して再度位置情報のマッチングを実施する
                LocationMatching();

                // リストを更新する
                UpdateLocationList();

#if true
                // データが変化したので保存します。
                var task = Task.Factory.StartNew(() =>
                {
                    _trackItemBag.Save();
                }).ContinueWith(_ =>
                {
                    this.UseWaitCursor = false;
                }, TaskScheduler.FromCurrentSynchronizationContext());
#else
                _trackItemBag.Save();
                this.UseWaitCursor = false;
#endif
            }
        }