Пример #1
0
        private Trail Copy(Guid id)
        {
            Trail result = new Trail(id, false)
            {
                Name = this.Name,

                //Do not copy "auto" attributes
                m_radius           = this.Radius,
                MinDistance        = this.MinDistance,
                MaxRequiredMisses  = this.MaxRequiredMisses,
                BiDirectional      = this.BiDirectional,
                IsNameMatch        = this.IsNameMatch,
                IsCompleteActivity = this.IsCompleteActivity,
                IsURFilter         = this.IsURFilter,
                //result.IsAutoTryAll = this.IsAutoTryAll;
                IsTemporary = this.IsTemporary,
                Parent      = this.Parent
            };

            foreach (Trail t in this.Children)
            {
                result.Children.Add(t);
            }

            if (!this.m_generated)
            {
                result.TrailPriority = this.TrailPriority;
            }
            result.DefaultRefActivity = this.DefaultRefActivity;

            result.m_trailLocations = new List <TrailGPSLocation>();
            foreach (TrailGPSLocation t in this.TrailLocations)
            {
                TrailGPSLocation t2 = new TrailGPSLocation(t);
                result.m_trailLocations.Add(t2);
            }

            return(result);
        }
Пример #2
0
        public TrailNameWrapper(IList <ActivityTrail> allActivityTrails, IList <ActivityTrail> selectedActivityTrails)
        {
            if (selectedActivityTrails != null && selectedActivityTrails.Count > 0)
            {
                this.SelectedItems = new object[selectedActivityTrails.Count];
            }

            IDictionary <Trail, ActivityTrailWrapper> ats = new Dictionary <Trail, ActivityTrailWrapper>();
            IList <ActivityTrailWrapper> children         = new List <ActivityTrailWrapper>();
            IList <ActivityTrailWrapper> exps             = new List <ActivityTrailWrapper>();
            IList <ActivityTrailWrapper> rows             = new List <ActivityTrailWrapper>();
            int selIndex = 0;
            ActivityTrailWrapper split = null;

            foreach (ActivityTrail at in allActivityTrails)
            {
                ActivityTrailWrapper atw = new ActivityTrailWrapper(at);
                ats[at.Trail] = atw;
                if (at.Trail.Parent == null)
                {
                    rows.Add(atw);
                }
                else
                {
                    //added as links to the parent rows below
                    children.Add(atw);
                }
                if (at.Trail.Children.Count > 0 && at.Status < TrailOrderStatus.NotInBound)
                {
                    //expand only for (partial) matches
                    exps.Add(atw);
                }
                if (selectedActivityTrails != null && selectedActivityTrails.Contains(at))
                {
                    this.SelectedItems[selIndex++] = atw;
                }
                if (at.Trail.IsSplits)
                {
                    split = atw;
                }
            }
            if (split != null)
            {
                //Show first in list
                rows.Remove(split);
                rows.Insert(0, split);
            }

            foreach (ActivityTrailWrapper atw in children)
            {
                //Update link to and from parent
                Trail parentResult = atw.ActivityTrail.Trail.Parent;
                if (parentResult != null)
                {
                    System.Diagnostics.Debug.Assert(ats.ContainsKey(parentResult), "Parent unexpectedly not in all trails");
                    ActivityTrailWrapper parentWrapper = ats[parentResult];
                    atw.Parent = parentWrapper;
                    parentWrapper.Children.Add(atw);
                }
            }
            RowData = rows;

            this.Expanded = new object[exps.Count];
            int allIndex = 0;

            foreach (ActivityTrailWrapper atw in exps)
            {
                this.Expanded[allIndex++] = atw;
            }
        }
Пример #3
0
        public static Trail ReadOptions(XmlDocument xmlDoc, XmlNamespaceManager nsmgr, XmlElement node)
        {
            Guid Id;

            if (node.Attributes[XmlTags.sId] == null || String.IsNullOrEmpty(node.Attributes[XmlTags.sId].Value))
            {
                Id = System.Guid.NewGuid();
            }
            else
            {
                try
                {
                    Id = new Guid(node.Attributes[XmlTags.sId].Value.ToString());
                }
                catch (Exception)
                {
                    Id = System.Guid.NewGuid();
                }
            }
            Trail trail = new Trail(Id, false)
            {
                Name = node.Attributes[XmlTags.sName].Value.ToString()
            };

            //Hidden possibility to get trails matching everything while activities are seen
            //if (trail.Name.EndsWith("MatchAll"))
            //{
            //    trail.IsSplits = true;
            //}
            if (node.Attributes[XmlTags.sRadius] != null)
            {
                trail.Radius = Settings.ParseFloat(node.Attributes[XmlTags.sRadius].Value);
            }
            if (node.Attributes[XmlTags.sDefaultRefActivity] != null)
            {
                trail.m_DefaultRefActivityString = node.Attributes[XmlTags.sDefaultRefActivity].Value;
            }

            if (node.Attributes[XmlTags.sMinDistance] != null)
            {
                trail.MinDistance = (Int16)XmlConvert.ToInt16(node.Attributes[XmlTags.sMinDistance].Value);
            }
            if (node.Attributes[XmlTags.sMaxRequiredMisses] != null)
            {
                trail.MaxRequiredMisses = (Int16)XmlConvert.ToInt16(node.Attributes[XmlTags.sMaxRequiredMisses].Value);
            }
            if (node.Attributes[XmlTags.sBiDirectional] != null)
            {
                //Output prior to 1.0.604 is not xml parsable (only if trail modified manually)
                trail.BiDirectional = XmlConvert.ToBoolean(node.Attributes[XmlTags.sBiDirectional].Value.ToLower());
            }
            if (node.Attributes[XmlTags.sNameMatch] != null)
            {
                trail.IsNameMatch = XmlConvert.ToBoolean(node.Attributes[XmlTags.sNameMatch].Value);
            }
            if (node.Attributes[XmlTags.sCompleteActivity] != null)
            {
                trail.IsCompleteActivity = XmlConvert.ToBoolean(node.Attributes[XmlTags.sCompleteActivity].Value);
            }
            if (node.Attributes[XmlTags.sURFilter] != null)
            {
                trail.IsURFilter = XmlConvert.ToBoolean(node.Attributes[XmlTags.sURFilter].Value);
            }
            //if (node.Attributes[xmlTags.sAutoTryAll] != null)
            //{
            //    trail.IsAutoTryAll = XmlConvert.ToBoolean(node.Attributes[xmlTags.sAutoTryAll].Value);
            //}
            if (node.Attributes[XmlTags.sTrailPriority] != null)
            {
                trail.TrailPriority = (Int16)XmlConvert.ToInt16(node.Attributes[XmlTags.sTrailPriority].Value);
            }

            trail.TrailLocations.Clear();
            foreach (XmlNode TrailGPSLocationNode in node.SelectNodes(XmlTags.sTrailGPSLocation))
            {
                trail.TrailLocations.Add(TrailGPSLocation.FromXml(TrailGPSLocationNode));
                if (string.IsNullOrEmpty(trail.TrailLocations[trail.TrailLocations.Count - 1].Name))
                {
                    //Name the trail points
                    trail.TrailLocations[trail.TrailLocations.Count - 1].Name =
                        "#" + trail.TrailLocations.Count;
                }
            }
            //Set radius - not stored per trail point
            trail.Radius = trail.m_radius;

            return(trail);
        }