コード例 #1
0
ファイル: MainForm.cs プロジェクト: osherbakov/TeamTrack
        /// <summary>
        /// Called to add Team/Object to the tracking window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddTeam_Click(object sender, EventArgs e)
        {
            AddTeam at_dlg = new AddTeam();

            at_dlg.m_PlaceData = m_Places;

            while (at_dlg.ShowDialog() == DialogResult.OK)
            {
                if (m_Teams.ContainsKey(at_dlg.m_TeamData.CID))
                {
                    MessageBox.Show("The Combat ID entered is already in the list.\nPlease re-enter", "Incorrect CID");
                    continue;
                }
                else
                {
                    ListViewItem lvi = new ListViewItem();
                    TeamData     td  = at_dlg.m_TeamData;
                    td.Status = TrackStatus.TRACKING;

                    lvi.Group = StatusView.Groups["Tracking"];
                    lvi.Name  = td.CID;
                    lvi.Text  = td.CID;
                    lvi.SubItems.Add(td.Name);
                    lvi.SubItems.Add(td.Coordinates.MGRS + " / " + td.Coordinates.Latitude.ToString("N6") + ", " + td.Coordinates.Longitude.ToString("N6"));

                    DateTime add_time = DateTime.Now;
                    td.Coordinates.Time = add_time;
                    lvi.SubItems.Add(add_time.ToShortTimeString() + add_time.ToUniversalTime().ToString(" (HH:mm:ssZ)"));
                    m_Teams.Add(td.CID, td); UpdateTrackingHistory(td);
                    StatusView.Items.Add(lvi);
                    break;
                }
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: osherbakov/TeamTrack
        /// <summary>
        /// Called when user double-clicks on the Team/Place - bring appropriate dialog
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StatusView_DoubleClick(object sender, EventArgs e)
        {
            if (StatusView.SelectedItems.Count != 0)
            {
                ListViewItem lvi   = StatusView.SelectedItems[0];
                String       lvigs = lvi.Group.Name;
                if (lvigs.Equals("Places"))
                {
                    AddPlace ap_dlg = new AddPlace();
                    if (m_Places.ContainsKey(lvi.Name))
                    {
                        ap_dlg.m_PlaceData = m_Places[lvi.Name];
                    }
                    else
                    {
                        PlaceData pd = new PlaceData();
                        pd.Name             = lvi.SubItems[1].Text;
                        pd.Coordinates.MGRS = lvi.SubItems[2].Text;
                        ap_dlg.m_PlaceData  = pd;
                    }
                    ap_dlg.Text = "Change/View Place";
                    if (ap_dlg.ShowDialog() == DialogResult.OK)
                    {
                        PlaceData pd = ap_dlg.m_PlaceData;
                        m_Places[pd.Name] = pd; UpdateTrackingHistory(pd);

                        lvi.SubItems.Clear();
                        lvi.Name = pd.Name;
                        lvi.Text = "*****";
                        lvi.SubItems.Add(pd.Name);
                        lvi.SubItems.Add(pd.Coordinates.MGRS + " / " + pd.Coordinates.Latitude.ToString("N6") + ", " + pd.Coordinates.Longitude.ToString("N6"));
                        DateTime add_time = DateTime.Now;
                        lvi.SubItems.Add(add_time.ToShortTimeString() + add_time.ToUniversalTime().ToString(" (HH:mm:ssZ)"));
                    }
                }
                else
                {
                    AddTeam at_dlg = new AddTeam();
                    at_dlg.m_PlaceData = m_Places;

                    if (m_Teams.ContainsKey(lvi.Text))
                    {
                        at_dlg.m_TeamData = m_Teams[lvi.Text];
                    }
                    else
                    {
                        TeamData td = new TeamData();
                        td.CID              = lvi.Text;
                        td.Name             = lvi.SubItems[1].Text;
                        td.Coordinates.MGRS = lvi.SubItems[2].Text;
                        at_dlg.m_TeamData   = td;
                    }
                    at_dlg.Text = "Change/View Team";
                    if (at_dlg.ShowDialog() == DialogResult.OK)
                    {
                        TeamData td = at_dlg.m_TeamData;
                        td.Coordinates.Time = DateTime.Now;
                        m_Teams[td.CID]     = td;  UpdateTrackingHistory(td);
                        lvi.SubItems.Clear();
                        lvi.Name = td.CID;
                        lvi.Text = td.CID;
                        lvi.SubItems.Add(td.Name);
                        lvi.SubItems.Add(td.Coordinates.MGRS + " / " + td.Coordinates.Latitude.ToString("N6") + ", " + td.Coordinates.Longitude.ToString("N6"));
                        DateTime add_time = td.Coordinates.Time;
                        lvi.SubItems.Add(add_time.ToShortTimeString() + add_time.ToUniversalTime().ToString(" (HH:mm:ssZ)"));
                    }
                }
            }
        }