private void btnOk_Click(object sender, EventArgs e)
        {
            if (txtName.Text.IsEmpty())
            {
                MessageBox.Show("The Group Must have a Name.");
                txtName.Focus();
            }
            else
            {
                if (cboType.SelectedItem != null && cboType.SelectedItem.GetType() == typeof(GroupType))
                {
                    Group = new TtGroup();
                    Group.Name = txtName.Text.Trim();
                    Group.Description = txtDesc.Text;
                    Group.GroupType = (GroupType)cboType.SelectedItem;

                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("You Must Select a Group Type.");
                    cboType.Focus();
                }
            }
        }
        public bool AddGroup(TtGroup group, DataAccessLayer dal)
        {
            if (!Groups.ContainsKey(group.CN))
            {
                Groups.Add(group.CN, group);
                if (dal.InsertGroup(group) > 0)
                    return true;

                Groups.Remove(group.CN);
            }

            return false;
        }
        public bool MergeGroups(TtGroup group1, TtGroup group2, DataAccessLayer dal)
        {
            List<TtPoint> points = dal.GetPointsInGroup(group2.CN);  //group2.Points.Values.ToList();

            for (int i = 0; i < points.Count; i++)
            {
                points[i].GroupCN = group1.CN;
                points[i].GroupName = group1.Name;
            }

            //group1.AddPointsToGroup(points);

            dal.SavePoints(points, points);
            return dal.DeleteGroup(group2.CN);
        }
 private void btnAdd_Click(object sender, EventArgs e)
 {
     TtGroup g = new TtGroup("group");
     dal.InsertGroup(g);
     _DisplayGroups.Insert(0, new GroupEdit(g));
 }
 public GroupEdit(TtGroup g)
 {
     Group = g;
     Edited = false;
 }
        private void CreateWalkPoint(NmeaBurst b)
        {
            try
            {
                if (WalkGroup == null)
                {
                    WalkGroup = new TtGroup();
                    WalkGroup.SetGroupName(String.Format("Walk_{0}", WalkGroup.CN.Truncate(8)), null);

                    DAL.InsertGroup(WalkGroup);
                }

                if (CurrentPoint != null)
                {
                    DAL.InsertPoint(CurrentPoint);
                    DAL.SaveNmeaBurst(CurrentNmea, CurrentPoint.CN);

                    LastPoint = CurrentPoint;

                    btnOk.GuiInvoke(() => { btnOk.Enabled = true; });
                }
            }
            catch (Exception ex)
            {
                TtUtils.WriteError(ex.Message, "WalkFormLogic:CreateWalkPoint-Save Current Point", ex.StackTrace);
            }

            LastNmea = CurrentNmea;
            CurrentNmea = b;

            if (SetupPoint())
            {
                try
                {
                    CurrentPoint.UnAdjX = b._X;
                    CurrentPoint.UnAdjY = b._Y;
                    CurrentPoint.UnAdjZ = b._Z;
                    //CurrentPoint.X = b._X;
                    //CurrentPoint.Y = b._Y;
                    //CurrentPoint.Z = b._Z;
                    CurrentPoint.Time = DateTime.Now;
                    CurrentPoint.MetaDefCN = _currmeta.CN;
                    CurrentPoint.RMSEr = Values.Settings.DeviceOptions.MIN_POINT_ACCURACY;

                    b._Used = true;

                    if (_sound)
                    {
                        try
                        {
                            player.Play();
                        }
                        catch
                        {

                        }
                    }

                    new Thread(()=>
                        {
                            if(TtUtils.PointHasValue(CurrentPoint) || !Values.Settings.ProjectOptions.DropZero)
                                DrawSavePointIcon();
                            else
                                CurrentPoint = LastPoint;
                        }).Start();
                }
                catch (Exception ex)
                {
                    TtUtils.WriteError(ex.Message, "WalkFormLogic:CreateWalkPoint", ex.StackTrace);
                }
            }
        }
        public void Init(TtPolygon poly, DataAccessLayer dal, TtMetaData meta, TtPoint currentPoint, int currIndex)
        {
            this.Icon = Properties.Resources.Map;
            TtUtils.ShowWaitCursor();
            #if (PocketPC || WindowsCE || Mobile)
            lblLabel.Text = "Take " + Values.Settings.DeviceOptions.Take5NmeaAmount.ToString();
            #endif
            btnCapture.Text = "Take " + Values.Settings.DeviceOptions.Take5NmeaAmount.ToString();
            this.Text = "Take " + Values.Settings.DeviceOptions.Take5NmeaAmount.ToString() + " Point Capture";

            Values.GPSA.BurstReceived += GPSA_BurstReceived;
            Values.GPSA.InvalidStringFound += GPSA_InvalidStringFound;
            Values.GPSA.ComTimeout += GPSA_ComTimeout;
            Values.GPSA.GpsStarted += GPSA_GpsStarted;
            Values.GPSA.GpsEnded += GPSA_GpsEnded;
            Values.GPSA.GpsError += GPSA_GpsError;

            travInfoControl1.UseLaser = false;

            Polygon = poly;
            DAL = dal;
            CurrMeta = meta;

            logging = false;
            this.DialogResult = DialogResult.Cancel;
            OnBound = true;
            _index = 0;
            ignore = 0;

            progCapture.Value = 0;
            progCapture.Minimum = 0;
            progCapture.Maximum = Values.Settings.DeviceOptions.Take5NmeaAmount;

            logged = 0;
            _locked = true;

            CurrentNmea = new List<NmeaBurst>();
            LastNmea = new List<NmeaBurst>();
            CurrentPoint = null;

            _index = currIndex;
            LastPoint = currentPoint;

            gpsInfoAdvCtrl.SetZone(CurrMeta.Zone);
            gpsInfoAdvCtrl.StartControl();

            if (Values.GPSA.UsesFile && Values.Settings.DeviceOptions.GetGpsOnStart)
            {
                using (DeviceSetupForm dsf = new DeviceSetupForm())
                {
                    dsf.ShowDialog();
                }
            }

            T5Group = new TtGroup();
            T5Group.Name = String.Format("Take5_{0}", T5Group.CN.Truncate(8));
            T5Group.GroupType = GroupType.Take5;

            if(!Values.GPSA.IsBusy)
                Values.GPSA.OpenGps(Values.Settings.DeviceOptions.GpsComPort, Values.Settings.DeviceOptions.GpsBaud);
            TtUtils.HideWaitCursor();

            if (dal.GetPointCount(poly.CN) < 1)
            {
                checkMeta = true;
            }
        }
        private void InsertUpgradeGroup(TtGroup group)
        {
            StringBuilder queryBeginning = new StringBuilder();
            StringBuilder queryEnd = new StringBuilder();

            if (group.CN.IsEmpty())
                group.CN = Guid.NewGuid().ToString();

            queryBeginning.AppendFormat("INSERT INTO {0} (", TwoTrailsSchema.GroupSchema.TableName);
            queryEnd.Append("(");

            //CN
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.GroupSchema.CN);
            queryEnd.AppendFormat("'{0}',", group.CN);

            //Name
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.GroupSchema.Name);
            queryEnd.AppendFormat("'{0}',", group.Name);

            //Accuracy
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.GroupSchema.Accuracy);
            queryEnd.AppendFormat("{0},", (group.ManualAccuracy == null) ? ("NULL") : (group.ManualAccuracy.ToString()));

            //Description
            queryBeginning.AppendFormat("{0},", TwoTrailsSchema.GroupSchema.Description);
            queryEnd.AppendFormat("'{0}',", group.Description);

            //Type
            queryBeginning.AppendFormat("{0}", TwoTrailsSchema.GroupSchema.Type);
            queryEnd.AppendFormat("'{0}'", group.GroupType.ToString());

            queryBeginning.Append(") values ");
            queryEnd.Append(");");
            queryBeginning.AppendFormat(" {0}", queryEnd.ToString());

            if (!IsOpen)
                OpenDB();

            SQLiteCommand update = _dbConnection.CreateCommand();
            int num = 0;

            try
            {
                update.CommandText = queryBeginning.ToString();
                num = update.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                TtUtils.WriteError(ex.Message, "DataAccessUpgrader:InsertGroup", ex.StackTrace);
            }
            finally
            {
                update.Dispose();
            }
        }
        private List<TtGroup> GetUpgradeGroups()
        {
            List<TtGroup> groups = new List<TtGroup>();

            StringBuilder query = new StringBuilder();
            query.AppendFormat("SELECT {0}, {1}, {2}, {3}, {4} from {5} ",
                TwoTrailsSchema.GroupSchema.CN,
                TwoTrailsSchema.GroupSchema.Name,
                TwoTrailsSchema.GroupSchema.Accuracy,
                TwoTrailsSchema.GroupSchema.Description,
                TwoTrailsSchema.GroupSchema.Type,
                TwoTrailsSchema.GroupSchema.TableName);

            SQLiteCommand cmd = _dbConnection.CreateCommand();

            try
            {
                cmd.CommandText = query.ToString();

                TtGroup group = new TtGroup();
                SQLiteDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    group.CN = reader.GetString(0);
                    group.SetGroupName(reader.GetString(1), null);
                    if (!reader.IsDBNull(2))
                        group.SetGroupManualAccuracy(reader.GetDouble(2), null);
                    if (!reader.IsDBNull(3))
                        group.Description = reader.GetString(3);
                    if (!reader.IsDBNull(4))
                    {
                        group.GroupType = (GroupType)Enum.Parse(typeof(GroupType), reader.GetString(4), true);
                    }

                    //group.Init(GetPointCNsInGroup(group.CN));

                    groups.Add(group);
                    group = new TtGroup();
                }
            }
            catch (Exception ex)
            {
                TtUtils.WriteError(ex.Message, "DataAccessUpgrader:GetGroups", ex.StackTrace);
            }
            finally
            {
                cmd.Dispose();
            }

            return groups;
        }
        private void UpdateGroup(TtGroup currentGroup, TtGroup updatedGroup, SQLiteTransaction trans)
        {
            if (currentGroup.CN != updatedGroup.CN)
                throw new Exception("Mismatch Group CN");

            StringBuilder query = new StringBuilder();
            query.AppendFormat("Update {0} set ", TwoTrailsSchema.GroupSchema.TableName);

            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.GroupSchema.CN, updatedGroup.CN);
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.GroupSchema.Name, updatedGroup.Name);
            query.AppendFormat("{0} = {1}, ", TwoTrailsSchema.GroupSchema.Accuracy, (updatedGroup.ManualAccuracy == null) ? ("NULL") : (updatedGroup.ManualAccuracy.ToString()));
            query.AppendFormat("{0} = '{1}', ", TwoTrailsSchema.GroupSchema.Description, updatedGroup.Description);
            query.AppendFormat("{0} = '{1}' ", TwoTrailsSchema.GroupSchema.Type, updatedGroup.GroupType.ToString());

            query.AppendFormat("where {0} = '{1}'", TwoTrailsSchema.GroupSchema.CN, updatedGroup.CN);
            if (!IsOpen)
                OpenDB();

            SQLiteCommand update = _dbConnection.CreateCommand();

            try
            {
                if (trans != null)
                    update.Transaction = trans;
                update.CommandText = query.ToString();
                update.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                TtUtils.WriteError(ex.Message, "DataAccessLayer:UpdateGroup");
            }
            finally
            {
                update.Dispose();
            }
        }
 public void DeletePointsInGroup(TtGroup group)
 {
     DeletePointsInGroup(group.CN);
 }
        public void UpdateGroup(TtGroup currentGroup, TtGroup updatedGroup)
        {
            SQLiteTransaction trans = _dbConnection.BeginTransaction();

            try
            {
                UpdateGroup(currentGroup, updatedGroup, trans);
                trans.Commit();
            }
            catch (Exception ex)
            {
                TtUtils.WriteError(ex.Message, "DataAccessLayer:UpdateGroup");
            }
            finally
            {
                trans.Dispose();
            }
        }
 public void UpdateGroup(TtGroup currentGroup)
 {
     UpdateGroup(currentGroup, currentGroup);
 }
 public bool DeleteGroup(TtGroup group)
 {
     return DeleteGroup(group.CN);
 }
Example #15
0
        public TtGroup(TtGroup ttgroup)
        {
            _CN = ttgroup._CN;
            _Name = ttgroup._Name;
            //NumberOfPoints = ttgroup.NumberOfPoints;
            ManualAccuracy = ttgroup.ManualAccuracy;
            GroupType = ttgroup.GroupType;
            _Desc = ttgroup._Desc;

            //_PointCNs = ttgroup.PointCNs;

            /*
            _Points = ttgroup._Points;

            NumOfTraversePoints = ttgroup.NumOfTraversePoints;
            NumOfSideShotPoints = ttgroup.NumOfSideShotPoints;
            NumOfQndPoints = ttgroup.NumOfQndPoints;
            NumOfGpsPoints = ttgroup.NumOfGpsPoints;
            NumOfGpsTypePoints = ttgroup.NumOfGpsTypePoints;
            NumOfWayPoints = ttgroup.NumOfWayPoints;
            NumOfWalkPoints = ttgroup.NumOfWalkPoints;
            NumOfTake5Points = ttgroup.NumOfTake5Points;
            NumOfPointsOnBnd = ttgroup.NumOfPointsOnBnd;
            NumOfPointsOffBnd = ttgroup.NumOfPointsOffBnd;
            */
        }
        private void quondamInfoControl1_PointsRetraced2()
        {
            SavePoint();

            using (QuondamRetraceForm form = new QuondamRetraceForm(DAL, quondamInfoControl1.PointListIndex, quondamInfoControl1.PolyListIndex))
            {
                if (form.ShowDialog() == DialogResult.OK)
                {
                    TtGroup qg = new TtGroup();
                    qg.SetGroupName(String.Format("Quondams_{0}", qg.CN.Truncate(8)), null);

                    DAL.InsertGroup(qg);
                    //Values.GroupManager.AddGroup(qg, DAL);

                    foreach(TtPoint p in form.FinalPoints)
                    {

                        p.GroupCN = qg.CN;
                        p.GroupName = qg.Name;
                        //qg.AddPointToGroup(p);
                        CreateNewPoint(OpType.Quondam, false, true);

                        ((QuondamPoint)_UpdatedPoint).ParentPoint = p;
                        _dirty = true;
                    }

                    //Values.GroupManager.SaveGroup(qg.CN, DAL);

                    ChangePolygon();
                }
            }
        }