public MarkerProperties(Marker aMarker)
 {
     InitializeComponent();
     mMarker = aMarker;
     mNameTag.Text = mMarker.NameTag;
     mDescription.Text = mMarker.Description;
     mShowFlightZone.Checked = mMarker.ShowFlightZone;
 }
示例#2
0
 public int FindMarker(Marker aMarker)
 {
     int num = mMarkers.Count;
     for (int i = 0; i < num; i++)
     {
         if (object.ReferenceEquals(mMarkers[i], aMarker))
         {
             return i;
         }
     }
     return -1;
 }
示例#3
0
        public void Deserialize(string aFilename, Stream aStream)
        {
            using (BinaryReader reader = new BinaryReader(aStream, System.Text.Encoding.UTF8))
            {
                uint id = reader.ReadUInt32();
                if (id != 0x4b434c46)
                {
                    throw new Exception(string.Format("'{0}' is not a flock file", Path.GetFileName(aFilename)));
                }

                int version = reader.ReadInt32();
                if (version <= Version)
                {
                    mBaseMarker = reader.ReadInt32();
                    if (version < 6)
                    {
                        reader.ReadInt32();
                    }

                    mDistanceTolerance = reader.ReadInt32();

                    if (version >= 5)
                    {
                        mAngleTolerance = reader.ReadInt32();
                    }

                    if (version >= 7)
                    {
                        mFlightZoneMode = (FlightZone)reader.ReadInt32();
                    }

                    if (version >= 8)
                    {
                        mPhotoName = reader.ReadString();
                    }

                    if (version >= 9)
                    {
                        mWingsuitSize = reader.ReadInt32();
                        mDotCount = reader.ReadInt32();
                        mDotSize = reader.ReadInt32();
                        mDotDistance = reader.ReadInt32();
                        mDotStretch = reader.ReadInt32();
                        mDotRotate = reader.ReadInt32();
                    }

                    if (version >= 10)
                    {
                        mGridCount = reader.ReadInt32();
                        mGridSize = reader.ReadInt32();
                        mGridRotate = reader.ReadSingle();
                        mGridOffset.X = reader.ReadSingle();
                        mGridOffset.Y = reader.ReadSingle();
                    }

                    if (version >= 2)
                    {
                        mBackColor = Color.FromArgb(reader.ReadInt32());
                        mDescription = reader.ReadString();
                        long date = reader.ReadInt64();
                        mDate = DateTime.FromBinary(date);
                        mPlace = reader.ReadString();
                        mGlideRatio = reader.ReadSingle();
                        mJumpNumber = reader.ReadInt32();
                        mFallrate = reader.ReadInt32();
                    }

                    int numMarkers = reader.ReadInt32();
                    for (int i = 0; i < numMarkers; i++)
                    {
                        float x = reader.ReadSingle();
                        float y = reader.ReadSingle();
                        Marker marker = new Marker(x, y);
                        marker.ShowFlightZone = reader.ReadBoolean();
                        if (version >= 3)
                        {
                            if (version == 3)
                            {
                                reader.ReadBoolean();
                            }
                            marker.SilhoutteColor = Color.FromArgb(reader.ReadInt32());
                        }
                        if (version >= 7)
                        {
                            marker.FlightZoneMode = (FlightZone)reader.ReadInt32();
                        }

                        marker.NameTag = reader.ReadString();
                        marker.Description = reader.ReadString();
                        mMarkers.Add(marker);
                    }

                    int numLines = reader.ReadInt32();
                    for (int i = 0; i < numLines; i++)
                    {
                        int start = reader.ReadInt32();
                        int end = reader.ReadInt32();
                        Line line = new Line(mMarkers[start], mMarkers[end]);
                        if (version >= 3)
                        {
                            line.Color = Color.FromArgb(reader.ReadInt32());
                        }
                        mLines.Add(line);
                    }
                }
                else
                {
                    throw new Exception(string.Format("'{0}' has an unsupported version number {1}.", Path.GetFileName(aFilename), version));
                }
            }
        }
示例#4
0
 public void AddMarker(Marker marker)
 {
     mMarkers.Add(marker);
     Dirty = true;
 }
示例#5
0
        private bool HasBaseLength(out float aBaseLength, out Marker aBaseMarker)
        {
            aBaseMarker = null;
            if (mBaseMarker >= 0 && mBaseMarker < mMarkers.Count)
            {
                aBaseMarker = mMarkers[mBaseMarker];

                int numLines = 0;
                float length = 0.0f;
                foreach (Line line in mLines)
                {
                    if (aBaseMarker == line.End || aBaseMarker == line.Start)
                    {
                        length += line.GetLength();
                        numLines++;
                    }
                }

                if (numLines > 0)
                {
                    aBaseLength = length / numLines;
                    return true;
                }
            }
            aBaseLength = 0;
            return false;
        }
示例#6
0
 private void FindClosestMarker(float aX, float aY, out float aDistance, out Marker aMarker)
 {
     aDistance = float.MaxValue;
     aMarker = null;
     foreach (Marker m in mMarkers)
     {
         float d = Math2.Distance(m.Location.X, m.Location.Y, aX, aY);
         if (d < aDistance)
         {
             aDistance = d;
             aMarker = m;
         }
     }
 }
示例#7
0
 public Line(Marker start, Marker end)
 {
     Start = start;
     End = end;
 }