예제 #1
0
파일: EditTrail.cs 프로젝트: tsofron/trails
 private void MoveRow(int isUp)
 {
     if (this.EList.SelectedItems.Count == 1)
     {
         IList selected = this.EList.SelectedItems;
         IList <EditTrailRow> result = (IList <EditTrailRow>) this.EList.RowData;
         if (selected != null && selected.Count > 0)
         {
             for (int j = selected.Count - 1; j >= 0; j--)
             {
                 for (int i = result.Count - 1; i >= 0; i--)
                 {
                     EditTrailRow r = (EditTrailRow)((IList <EditTrailRow>) this.EList.RowData)[i];
                     if ((isUp < 0 && i - isUp < result.Count ||
                          isUp > 0 && i - isUp >= 0) &&
                         selected[j].Equals(r))
                     {
                         result[i]        = result[i - isUp];
                         result[i - isUp] = r;
                         break;
                     }
                 }
             }
             this.EList.RowData = result;
             this.m_TrailToEdit.TrailLocations = EditTrailRow.getTrailGPSLocation((IList <EditTrailRow>) this.EList.RowData);
         }
     }
 }
예제 #2
0
파일: EditTrail.cs 프로젝트: tsofron/trails
        void EList_SelectedItemsChanged(object sender, System.EventArgs e)
        {
            IList <EditTrailRow> result = new List <EditTrailRow>();

            if (this.EList.SelectedItems.Count == 1)
            {
                this.btnUp.Enabled   = true;
                this.btnDown.Enabled = true;
            }
            else
            {
                this.btnUp.Enabled   = false;
                this.btnDown.Enabled = false;
            }

            if (this.EList.SelectedItems.Count > 0)
            {
                IList selected = EList.SelectedItems;
                if (selected != null && selected.Count > 0)
                {
                    for (int j = 0; j < selected.Count; j++)
                    {
                        for (int i = ((IList <EditTrailRow>) this.EList.RowData).Count - 1; i >= 0; i--)
                        {
                            EditTrailRow r = (EditTrailRow)((IList <EditTrailRow>) this.EList.RowData)[i];
                            if (selected[j].Equals(r))
                            {
                                result.Add(r);
                            }
                        }
                    }
                }
                this.btnDelete.Enabled = true;
            }
            else
            {
                this.btnDelete.Enabled = false;
            }

            if (!this.m_updatingFromMap)
            {
                this.m_layer.SelectedTrailPoints = EditTrailRow.getTrailGPSLocation(result);
            }
        }
예제 #3
0
파일: EditTrail.cs 프로젝트: tsofron/trails
        private void EList_DeleteRow()
        {
            int lastDeleted = -1;

            if (this.EList.SelectedItems.Count > 0 && ((IList <EditTrailRow>) this.EList.RowData).Count > 0)
            {
                IList selected = EList.SelectedItems;
                if (selected != null && selected.Count > 0)
                {
                    for (int j = selected.Count - 1; j >= 0; j--)
                    {
                        IList <EditTrailRow> list = ((IList <EditTrailRow>) this.EList.RowData);
                        for (int i = 0; i < list.Count; i++)
                        {
                            //Only first selected
                            if (selected[j].Equals(list[i]))
                            {
                                ((IList <EditTrailRow>)EList.RowData).RemoveAt(i);
                                //Required to make ST see the update, Refresh() is not enough?
                                this.EList.RowData           = ((IList <EditTrailRow>) this.EList.RowData);
                                m_TrailToEdit.TrailLocations = EditTrailRow.getTrailGPSLocation((IList <EditTrailRow>)EList.RowData);
                                m_layer.TrailPoints          = m_TrailToEdit.TrailLocations;
                                lastDeleted = i;
                                break;
                            }
                        }
                    }
                }
            }
            this.EList.Refresh();
            if (EList.SelectedItems.Count == 1 && lastDeleted >= 0)
            {
                if (lastDeleted > 0)
                {
                    lastDeleted--;
                }
                if (lastDeleted < ((IList <EditTrailRow>) this.EList.RowData).Count)
                {
                    EList.SelectedItems = new object[] { ((IList <EditTrailRow>) this.EList.RowData)[lastDeleted] };
                }
            }
        }
예제 #4
0
파일: EditTrail.cs 프로젝트: tsofron/trails
        private void EList_AddRow()
        {
            int i = EList_SelectedRow();

            if (i < 0)
            {
                if (((IList <EditTrailRow>) this.EList.RowData).Count > 0)
                {
                    i = ((IList <EditTrailRow>) this.EList.RowData).Count - 1;
                }
                else
                {
                    i = 0;
                }
            }
            TrailGPSLocation sel;

            if (((IList <EditTrailRow>) this.EList.RowData).Count > 0)
            {
                sel        = new TrailGPSLocation(((IList <EditTrailRow>) this.EList.RowData)[i].TrailGPS);
                sel.GpsLoc = new GPSLocation(sel.LatitudeDegrees + 0.0001F, sel.LongitudeDegrees + 0.0001F);
            }
            else
            {
                IGPSLocation l = m_layer.GetCenterMap();
                sel = new TrailGPSLocation(l, this.m_TrailToEdit.Radius);
            }

            sel.Name += " " + ZoneFiveSoftware.Common.Visuals.CommonResources.Text.ActionNew;

            //If a point is selected on the track, use it instead
            IList <IActivity> activities = new List <IActivity> {
                Controller.TrailController.Instance.ReferenceActivity
            };
            IList <IItemTrackSelectionInfo> selectedGPS =
                TrailsItemTrackSelectionInfo.SetAndAdjustFromSelectionFromST(m_view.RouteSelectionProvider.SelectedItems, activities);

            if (TrailsItemTrackSelectionInfo.ContainsData(selectedGPS))
            {
                IList <TrailGPSLocation> loc = TrailSelectorControl.GetGPS(this.Trail, activities, selectedGPS);
                if (loc.Count > 0 && loc[0] != null)
                {
                    sel.GpsLoc = loc[0];
                }
            }

            EditTrailRow newRow = new EditTrailRow(sel);

            if (((IList <EditTrailRow>) this.EList.RowData).Count > 0)
            {
                ((IList <EditTrailRow>) this.EList.RowData).Insert(i + 1, newRow);
            }
            else
            {
                this.EList.RowData = new List <EditTrailRow> {
                    newRow
                };
            }

            //Make ST see the update
            this.EList.RowData = ((IList <EditTrailRow>) this.EList.RowData);
            foreach (EditTrailRow t in (IList <EditTrailRow>) this.EList.RowData)
            {
                //Note: For reverse results, this is incorrect (but reverse results are only for incomplete, so no impact)
                this.EList.SetChecked(t, t.TrailGPS.Required);
            }
            this.EList.SelectedItems = new object[] { newRow };
            this.EList.Refresh();

            this.m_TrailToEdit.TrailLocations = EditTrailRow.getTrailGPSLocation((IList <EditTrailRow>) this.EList.RowData);
            this.m_layer.TrailPoints          = m_TrailToEdit.TrailLocations;
            this.m_layer.SelectedTrailPoints  = new List <TrailGPSLocation> {
                sel
            };
            this.m_layer.Refresh();
        }