Exemple #1
0
        public void LoadFromFile(string fileName)
        {
            CurrentIndex = 0;
            Points.Clear();

            // Departure
            Source = Runways.LSI_RW03;
            Points.Add(Runways.LSI_RW03.StartPoint);
            Points.Add(Runways.LSI_RW03.EndPoint);
            Points.Add(Runways.LSI_RW03.ExtendForward(140));

            foreach (var line in System.IO.File.ReadAllLines(fileName))
            {
                var parts = line.Split(',');
                Debug.Assert(parts.Length == 2);
                Points.Add(new PointF((float)double.Parse(parts[0]), (float)double.Parse(parts[1])));
            }

            // Approach
            Points.Add(Runways.LSI_RW30L.ExtendBackward(800));
            Points.Add(Runways.LSI_RW30L.StartPoint);
            Points.Add(Runways.LSI_RW30L.EndPoint);
            Destination = Runways.LSI_RW30L;

            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Points)));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CurrentIndex)));
        }
        public void InverseData()
        {
            if (Points.Count == 0)
            {
                return;
            }

            foreach (PointModel pt in _points)
            {
                pt.InverseIndex();
            }

            _points.Sort(PointModel.SortAsc);

            Points.Clear();
            foreach (PointModel pt in _points)
            {
                double value;
                if (!double.TryParse(pt.Value, out value))
                {
                    continue;
                }

                this.Points.Add(new OxyPlot.DataPoint(pt.Index, value));
            }
        }
Exemple #3
0
 private void Reset()
 {
     radiusChecked = false;
     Points.Clear();
     AddNewEmptyPoint();
     ShowHint(ModelingResources.CircleStep1);
 }
 private void PointsOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Add)
     {
         foreach (ObservablePoint item in e.NewItems)
         {
             Points.Add(item);
         }
     }
     else if (e.Action == NotifyCollectionChangedAction.Remove)
     {
         foreach (ObservablePoint item in e.OldItems)
         {
             Points.Remove(item);
         }
     }
     else if (e.Action == NotifyCollectionChangedAction.Reset)
     {
         Points.Clear();
     }
     else
     {
         throw new NotImplementedException("Func don't implemented");
     }
 }
Exemple #5
0
        /// <summary>
        ///     Updates the polygon. Call this after you change something.
        /// </summary>
        /// <param name="offset">Added radius</param>
        public void UpdatePolygon(int offset = 0)
        {
            Points.Clear();

            var outRadius = (offset + InnerRadius + OuterRadius) /
                            (float)System.Math.Cos(2 * System.Math.PI / _quality);
            var innerRadius = InnerRadius - OuterRadius - offset;

            for (var i = 0; i <= _quality; i++)
            {
                var angle = i * 2 * System.Math.PI / _quality;
                var point = new Vector2(
                    Center.X - outRadius * (float)System.Math.Cos(angle),
                    Center.Y - outRadius * (float)System.Math.Sin(angle));

                Points.Add(point);
            }

            for (var i = 0; i <= _quality; i++)
            {
                var angle = i * 2 * System.Math.PI / _quality;
                var point = new Vector2(
                    Center.X + innerRadius * (float)System.Math.Cos(angle),
                    Center.Y - innerRadius * (float)System.Math.Sin(angle));

                Points.Add(point);
            }
        }
Exemple #6
0
 public void startCalibrating()
 {
     isCalibrated = false;
     Points.Clear();
     Lines.Clear();
     isCalibrating = true;
 }
Exemple #7
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            Points.Clear();
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.InitialDirectory = Application.StartupPath;
            dialog.RestoreDirectory = true;
            dialog.Filter           = "text file|*.txt";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                using (StreamReader sr = new StreamReader(dialog.FileName))
                {
                    while (sr.Peek() >= 0)
                    {
                        string   line   = sr.ReadLine();
                        string[] splits = line.Split(',');
                        Points.Add(new CGPoint()
                        {
                            id = int.Parse(splits[1]),
                            x  = int.Parse(splits[2]),
                            y  = int.Parse(splits[3]),
                        });
                    }
                    sr.Close();
                }
            }
            Draw.DrawPoints(Points, true);
        }
        public void DrawLines()
        {
            if (Pairs == null)
            {
                return;
            }
            //Clear canvas
            foreach (var l in Lines)
            {
                _overlay.Children.Remove(l);
            }

            foreach (var p in Points)
            {
                _overlay.Children.Remove(p);
            }

            Points.Clear();
            Lines.Clear();
            //Drawing points
            foreach (var p in Pic1Points)
            {
                DrawPoint(p, 0);
            }

            foreach (var p in Pic2Points)
            {
                DrawPoint(p, 800);
            }

            foreach (var p in Pairs)
            {
                DrawLine(p);
            }
        }
Exemple #9
0
 //virtual void Move(PointF PValue)override;
 //virtual void MoveTo(PointF PValue) override;
 public override void AddPoint(PointF PValue)
 {
     Points.Clear();
     base.AddPoint(PValue);
     FRect.Location = PValue;
     if (FRect.Width > FRect.Height)
     {
         FWidth = 64;
         FHight = 64 * (FRect.Height / FRect.Width);
     }
     else if (FRect.Width < FRect.Height)
     {
         FHight = 64;
         FWidth = 64 * (FRect.Width / FRect.Height);
     }
     else
     {
         FWidth = 64;
         FHight = 64;
     }
     foreach (CFocus Focus in FocusList)
     {
         Focus.SelectRectWidth  = Math.Abs(CFocus.FocusRectWidth / (FWidth / FRect.Width));
         Focus.SelectRectHeight = Math.Abs(CFocus.FocusRectWidth / (FHight / FRect.Height));
     }
     foreach (CBase Ob in Children)
     {
         Ob.SelectedDisWMargin = Math.Abs(SelectedDisWMargin / (FWidth / FRect.Width));
         Ob.SelectedDisHMargin = Math.Abs(SelectedDisHMargin / (FHight / FRect.Height));
     }
     FDrawing = false;
 }
Exemple #10
0
        private void FilterPoints()
        {
            Points.Clear();
            // Check which items are checked and add them to the points list.
            foreach (var point in _cachePoints)
            {
                switch (point.DestinationView)
                {
                case "CustomerInfo":
                    if (CustomerChecked)
                    {
                        Points.Add(point);
                    }
                    break;

                case "FestivalInfo":
                    if (FestivalChecked)
                    {
                        Points.Add(point);
                    }
                    break;

                case "EmployeeInfo":
                    if (EmployeeChecked)
                    {
                        Points.Add(point);
                    }
                    break;
                }
            }
        }
        public async Task Draw()
        {
            //Clear canvas
            foreach (var l in Lines)
            {
                _overlay.Children.Remove(l);
            }

            foreach (var p in Points)
            {
                _overlay.Children.Remove(p);
            }

            Points.Clear();
            Lines.Clear();
            //Drawing points
            foreach (var p in Pic1Points)
            {
                DrawPoint(p, 0);
            }

            foreach (var p in Pic2Points)
            {
                DrawPoint(p, 800);
            }


            Thread t = new Thread(FindPairs);

            t.SetApartmentState(ApartmentState.STA);

            t.Start();
            //            DrawLines();
        }
Exemple #12
0
        public void TrimEnd(LayoutLine trimLine, bool extendIfNeeded = false)
        {
            int    interIdx;
            PointM interPt = PointM.Empty;

            if (!Intersects(trimLine, out interPt, out interIdx, extendIfNeeded))
            {
                return;
            }

            var pointsToKeep = new List <PointM>();

            for (int i = 0; i <= interIdx; i++)
            {
                pointsToKeep.Add(Points[i]);

                if (interIdx == i)
                {
                    var ptRel = GetLocationRelativeToSegment(Points[i].ToVector(), Points[i + 1].ToVector(), interPt.ToVector());
                    if (ptRel == PointRelation.After)
                    {
                        pointsToKeep.Add(Points[i + 1]);
                    }
                }
            }

            pointsToKeep.Add(interPt);

            Points.Clear();
            _Points.AddRange(pointsToKeep);

            //remove points that are very close
            MergePoints(0.05);
        }
        public void LoadWorld(string filename)
        {
            _loadTimer.Reset();
            _loadTimer.Start();
            _saveTimer.Stop();
            CurrentFile = filename;

            Task.Factory.StartNew(() => World.LoadWorld(filename))
            .ContinueWith(t => CurrentWorld = t.Result, TaskFactoryHelper.UiTaskScheduler)
            .ContinueWith(t => RenderEntireWorld())
            .ContinueWith(t =>
            {
                if (CurrentWorld != null)
                {
                    PixelMap = t.Result;
                    UpdateTitle();
                    Points.Clear();
                    Points.Add("Spawn");
                    Points.Add("Dungeon");
                    foreach (var npc in CurrentWorld.NPCs)
                    {
                        Points.Add(npc.Name);
                    }
                    _loadTimer.Stop();
                    OnProgressChanged(this, new ProgressChangedEventArgs(0, string.Format("World loaded in {0} seconds.", _loadTimer.Elapsed.TotalSeconds)));
                    _saveTimer.Start();
                }
                _loadTimer.Stop();
            }, TaskFactoryHelper.UiTaskScheduler);
        }
        /// <summary>
        /// Load data from the loader.
        /// </summary>
        /// <param name="begin">The beginning date.</param>
        /// <param name="end">The ending date.</param>
        public void Load(DateTime begin, DateTime end)
        {
            // define the starting point if it is not already defined
            if (StartingPoint == DateTime.MinValue)
            {
                StartingPoint = begin;
            }

            // clear out any loaded points
            Points.Clear();

            // first obtain a collection of symbols that need to be looked up
            IDictionary <TickerSymbol, object> set = new Dictionary <TickerSymbol, object>();

            foreach (TemporalDataDescription desc in Descriptions)
            {
                var mdesc = (MarketDataDescription)desc;
                set[mdesc.Ticker] = null;
            }

            // now loop over each symbol and load the data
            foreach (TickerSymbol symbol in set.Keys)
            {
                LoadSymbol(symbol, begin, end);
            }

            // resort the points
            SortPoints();
        }
Exemple #15
0
        /// <summary>
        /// Clears (removes) all assignments from the specified group.
        /// </summary>
        public void Clear()
        {
            foreach (var point in Points)
            {
                Remove(point);
            }

            foreach (var frame in Frames)
            {
                Remove(frame);
            }

            foreach (var area in Areas)
            {
                Remove(area);
            }

            foreach (var link in Links)
            {
                Remove(link);
            }

            Points.Clear();
            Frames.Clear();
            Areas.Clear();
            Links.Clear();
            Cables.Clear();
            Tendons.Clear();
            Solids.Clear();
        }
 public void Clear()
 {
     if (Points.Count > N)
     {
         Points.Clear();
     }
 }
Exemple #17
0
        public void Read(BinaryData data, uint startPos)
        {
            bool ende = false;

            // Set position
            data.Position = startPos;

            // Clear list
            Points.Clear();

            // Read xyz
            while (!ende)
            {
                if ((ulong)data.ReadInt64() != 0xFFFFFFFFFFFFFFFF)
                {
                    data.Position -= 6;
                    var point = new Vector3();
                    point.X = data.ReadInt16();
                    point.Y = data.ReadInt16();
                    point.Z = data.ReadInt16();
                    Points.Add(point);
                }
                else
                {
                    ende = true;
                }
            }
        }
Exemple #18
0
        /// <summary>
        /// Setup.
        /// </summary>
        /// <param name="bounds"></param>
        public void Setup(System.Drawing.RectangleF bounds)
        {
            Triangle.ResetIndex();
            Facets.Clear();
            Points.Clear();
            Bounds = bounds;

            Vertex   tl = new Vertex(Bounds.Left, Bounds.Top, 0);
            Vertex   tr = new Vertex(Bounds.Right, Bounds.Top, 0);
            Vertex   bl = new Vertex(Bounds.Left, Bounds.Bottom, 0);
            Vertex   br = new Vertex(Bounds.Right, Bounds.Bottom, 0);
            Triangle t1 = new Triangle();
            Triangle t2 = new Triangle();

            t1.A  = bl;
            t1.B  = tr;
            t1.C  = tl;
            t2.A  = bl;
            t2.B  = br;
            t2.C  = tr;
            t1.AB = t2;
            t2.CA = t1;
            Facets.Add(t1);
            Facets.Add(t2);
        }
Exemple #19
0
 /// <summary>
 /// Handles the CollectionChanged event of the PointsSource control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="NotifyCollectionChangedEventArgs"/> instance containing the event data.</param>
 void PointsSource_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Add)
     {
         double xValue = GetReflectionValue(XPath, PointsSource, XValues.Count + 1);
         double yValue = GetReflectionValue(HighPath, PointsSource, YValues.Count + 1);
         this.XValues.Add(xValue);
         this.YValues.Add(yValue);
         this.Points.Add(new ChartPoint()
         {
             XValue = xValue, YValue = yValue
         });
     }
     else if (e.Action == NotifyCollectionChangedAction.Remove)
     {
         IList  oldItems  = e.OldItems;
         double oldXValue = GetReflectionValueFromItem(XPath, oldItems[0]);
         int    index     = this.XValues.IndexOf(oldXValue);
         this.XValues.RemoveAt(index);
         this.YValues.RemoveAt(index);
         this.Points.RemoveAt(index);
     }
     else if (e.Action == NotifyCollectionChangedAction.Reset)
     {
         Points.Clear();
         GeneratePointsFromSource();
     }
 }
Exemple #20
0
        public void Generate()
        {
            Points.Clear();
            double n   = Options["N"].Value;
            double l   = Options["Side Length"].Value;
            double min = -l / 2;
            var    s   = Math.Sin(Options["Rotation"].Value * Math.PI / 180);
            var    c   = Math.Cos(Options["Rotation"].Value * Math.PI / 180);

            for (double i = 0; i <= l; i += l / n)
            {
                var x = i + min;
                var y = 0.0;

                var new_x = c * x - s * y;
                var new_y = s * x + c * y;

                Points.Add(new Point(Math.Round(new_x, 0), Math.Round(new_y, 0)));

                x = 0.0;
                y = i + min;

                new_x = c * x - s * y;
                new_y = s * x + c * y;
                Points.Add(new Point(Math.Round(new_x, 0), Math.Round(new_y, 0)));
            }
        }
Exemple #21
0
        public void LoadWorld(string filename)
        {
            _loadTimer.Reset();
            _loadTimer.Start();
            _saveTimer.Stop();
            CurrentFile  = filename;
            CurrentWorld = null;
            GC.WaitForFullGCComplete();

            Task.Factory.StartNew(() => World.LoadWorld(filename))
            .ContinueWith(t => CurrentWorld = t.Result, TaskFactoryHelper.UiTaskScheduler)
            .ContinueWith(t => RenderEntireWorld())
            .ContinueWith(t =>
            {
                if (CurrentWorld != null)
                {
                    PixelMap = t.Result;
                    UpdateTitle();
                    Points.Clear();
                    Points.Add("Spawn");
                    Points.Add("Dungeon");
                    foreach (NPC npc in CurrentWorld.NPCs)
                    {
                        Points.Add(npc.Name);
                    }
                    MinimapImage = RenderMiniMap.Render(CurrentWorld);
                    _loadTimer.Stop();
                    OnProgressChanged(this, new ProgressChangedEventArgs(0,
                                                                         $"World loaded in {_loadTimer.Elapsed.TotalSeconds} seconds."));
                    _saveTimer.Start();
                }
                _loadTimer.Stop();
            }, TaskFactoryHelper.UiTaskScheduler);
        }
 private void ClearPoints()
 {
     Positions.Clear();
     Points.Clear();
     canvas.Children.Clear();
     lastPoint = default(Point);
 }
Exemple #23
0
        /// <summary>
        /// Mouse up function.
        /// </summary>
        /// <param name="document">Informations transferred from DrawingPanel.</param>
        /// <param name="e">MouseEventArgs.</param>
        public override void MouseUp(IDocument document, MouseEventArgs e)
        {
            this.CurrentDocument    = document;
            MousePressed            = false;
            this.isAnnotationActive = false;

            Points.Add(e.Location);
            m_colpathType.Add(byte.Parse("0"));
            mcolTempPoint.Add(e.Location);
            IShape shape = CreateDrawingShape(e.Location, mcolTempPoint);

            mcolTempPoint.Clear();
            if (shape == null)
            {
                return;
            }

            if (this.group == null)//Added by rm
            {
                this.group = new CompositeShape();
            }

            this.group.Shapes.Add(shape);//Added by rm
            this.group.Appearance = shape.Appearance;

            if (!document.Shapes.Contains(group) && group != null) //Added by rm
            {
                document.Shapes.Add(group);                        //Added by rm
            }

            Points.Clear();
        }
Exemple #24
0
 public void CurrentPosition(Point location)
 {
     Height = location.Y;
     Width  = location.X;
     Points.Clear();
     CalculateVertices();
 }
 private void OnOpenImage(object p)
 {
     try
     {
         OpenFileDialog openFileDialog = new OpenFileDialog();
         openFileDialog.Filter = "Изображение (*.png)|*.png|(*.jpg)|*.jpg|(*.bmp)|*.bmp";
         if (openFileDialog.ShowDialog() == true)
         {
             FilteringColor = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(FillSet);
             if (Shapes.Count > 0)
             {
                 Shapes.Clear();
                 if (Points.Count > 0)
                 {
                     Points.Clear();
                 }
             }
             Bitmap bitmap  = new Bitmap(openFileDialog.FileName);
             Uri    fileUri = new Uri(openFileDialog.FileName);
             var    outFile = new BitmapImage(fileUri);
             GetPixelsArray(bitmap);
             ImageOut     = outFile;
             CanvasHeight = bitmap.Height;
             CanvasWidth  = bitmap.Width;
             Start();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Ошибка: " + ex.Message, "Exception Sample", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Exemple #26
0
        /// <summary>
        /// Mouse up function.
        /// </summary>
        /// <param name="document">Informations transferred from DrawingPanel.</param>
        /// <param name="e">MouseEventArgs.</param>
        public override void MouseUp(IDocument document, MouseEventArgs e)
        {
            MousePressed            = false;
            this.isAnnotationActive = false;

            IShape shape = CreateDrawingShape(e.Location);

            if (shape == null)
            {
                return;
            }

            if (this.group != null)           //Added by rm
            {
                this.group.Shapes.Add(shape); //Added by rm
            }
            else                              //Added by rm
            {
                this.group       = new CompositeShape();
                group.Appearance = shape.Appearance;
                this.group.Shapes.Add(shape);
            }

            if (!document.Shapes.Contains(group) && group != null) //Added by rm
            {
                document.Shapes.Add(group);                        //Added by rm
            }

            Points.Clear();
            //base.MouseMove(document, e);
            document.DrawingControl.Invalidate();
        }
Exemple #27
0
 public void Reset()
 {
     Points.Clear();
     Text      = string.Empty;
     shape     = null;
     textBlock = null;
 }
Exemple #28
0
        protected override void OnMouseDownAction(Mouse3DPosition mouseData)
        {
            if (Points.Count == 0)
            {
                Points.Add(mouseData.Point);
                _firstCoordinateSet = true;
                Points.Add(new Point3D());
                return;
            }
            if (Points.Count == 2)
            {
                InitSession();
                var sketchCreator = new SketchCreator(Document);
                var normalOnPlane = sketchCreator.NormalOnSketch.Value.GpAxis;

                var builder = NodeBuilderUtils.BuildLineInDocument(Document, false, normalOnPlane, Points[0], Points[1]);

                NodeBuilderUtils.BuildDimensionForLine(Document, builder, Points[0], Points[1]);
                UpdateView();
                Points.Clear();
                AddNodeToTree(builder.Node);
                RebuildTreeView();
                Document.Commit("Added Dimension");
            }
        }
Exemple #29
0
        /// <summary>
        /// Sets the points in the list Points, They are set starting with
        /// bottom left then go in clockwise fashion. Clears points list
        /// every time to avoid stale data
        /// </summary>
        protected new void SetPoints()
        {
            if (Points.Count > 0)
            {
                Points.Clear();
            }
            Points.Add(MainPoint);

            Points.Add(new Point
            {
                X = MainPoint.X,
                Y = MainPoint.Y + Height
            });

            Points.Add(new Point
            {
                X = MainPoint.X + Width,
                Y = MainPoint.Y + Height
            });

            Points.Add(new Point
            {
                X = MainPoint.X + Width,
                Y = MainPoint.Y
            });
        }
Exemple #30
0
        /// <summary>
        /// Render loop
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CompositionTarget_Rendering(object sender, EventArgs e)
        {
            TimeSpan timeSinceLastRender = DateTime.Now.TimeOfDay - LastRenderTime;

            if (timeSinceLastRender.TotalSeconds < (1.0 / FrameLimiter))
            {
                return;
            }

            LastRenderTime = DateTime.Now.TimeOfDay;

            // Stop animation if there is no more points
            if (!Points.Any())
            {
                CompositionTarget.Rendering -= CompositionTarget_Rendering;
                IsBusy    = false;
                IsPlaying = false;
                Demo.PositionPoints.Clear();
                Points.Clear();
                CommandManager.InvalidateRequerySuggested();
                return;
            }

            // Draw points for each player
            foreach (List <PositionPoint> positionPoints in Points)
            {
                if (positionPoints.Any())
                {
                    // get the first point of the list
                    PositionPoint positionPoint = positionPoints.First();

                    // If there is an event at this point, draw it
                    if (positionPoint.Event != null)
                    {
                        if (!string.IsNullOrWhiteSpace(positionPoint.Event.Message))
                        {
                            _events.Add(positionPoint.Event);
                        }

                        _drawService.DrawEvent(positionPoint);
                    }
                    else
                    {
                        // Draw it
                        _drawService.DrawPixel(positionPoint);
                        _drawService.DrawPlayerMarker(positionPoint);
                    }

                    // Remove this point
                    positionPoints.Remove(positionPoint);

                    // If there is no more points remove the list from all the lists
                    if (!positionPoints.Any())
                    {
                        Points.Remove(positionPoints);
                        break;
                    }
                }
            }
        }
Exemple #31
0
        public Points GetAlternativeWaySegments(Car car)
        {
            var result = new Points();
            var myCell = GetCell(car.X, car.Y);
            result.Add(new Point(car));
            Cell prevCell = null;

            var passedWayPoints = new List<Cell>();

            for (var e = 1; result.Count < 5; e++)
            {
                var nextWp = GetNextWayPoint(car, e);
                for (var curCell = myCell; !curCell.Equals(nextWp); )
                {
                    var nextCell = DijkstraNextCell(curCell, nextWp, prevCell == null ? new Cell[] { } : new[] { prevCell });
                    var nextCenter = GetCenter(nextCell);
                    for (var i = 0; i < result.Count; i++)
                    {
                        if (CheckVisibilityAndWp(car, result[i], nextCenter, passedWayPoints))
                        {
                            result.RemoveRange(i + 1, result.Count - i - 1);
                            break;
                        }
                    }
                    result.Add(nextCenter);
                    prevCell = curCell;
                    curCell = nextCell;
                }
                myCell = nextWp;
                passedWayPoints.Add(nextWp);
            }
            var extended = ExtendWaySegments(result, 100);
            result.Clear();

            passedWayPoints.Clear();
            foreach (var t in extended)
            {
                if (result.Count > 0 && result.Last().Equals(t))
                    continue;
                if (GetNextWayPoint(car).Equals(GetCell(t)))
                    passedWayPoints.Add(GetCell(t));

                while (result.Count > 1 && CheckVisibilityAndWp(car, result[result.Count - 2], t, passedWayPoints))
                    result.Pop();
                result.Add(t);
            }
            return result;
        }