Esempio n. 1
0
 private void CreateRunFolderAndInitPath()
 {
     runPath = $@"C:\Users\{Environment.UserName}\Documents\DIP1\Screens\{DateTime.Now:yy-MM-dd-hh-ss-tt}_{model.loadedModelType}\";
     try {
         Directory.CreateDirectory(runPath);
     }
     catch (Exception e) {
         Logger.WriteLog("Directory can not be created, it already exists");
     }
 }
Esempio n. 2
0
        private void DrawAxis(Canvas canvas)
        {
            Logger.WriteLog("paint started");
            for (var i = -400; i < 401; i += 10)
            {
                ShapeLine myLine          = new ShapeLine();
                Brush     solidColorBrush = new SolidColorBrush(Color.FromArgb(95, 250, 250, 250));
                if (i != 0)
                {
                    solidColorBrush.Opacity = 0.5;
                    if (i % 100 == 0)
                    {
                        solidColorBrush.Opacity = 0.75;
                    }
                }

                myLine.Stroke          = solidColorBrush;
                myLine.X1              = 0 + i;
                myLine.X2              = 0 + i;
                myLine.Y1              = -400;
                myLine.Y2              = 400;
                myLine.StrokeThickness = 1;
                myLine.ToolTip         = i.ToString();
                testcanvas.Children.Add(myLine);
            }
            for (var i = -400; i < 401; i += 10)
            {
                ShapeLine myLine          = new ShapeLine();
                Brush     solidColorBrush = new SolidColorBrush(Color.FromArgb(95, 250, 250, 250));
                if (i != 0)
                {
                    solidColorBrush.Opacity = 0.15;
                    if (i % 100 == 0)
                    {
                        solidColorBrush.Opacity = 0.25;
                    }
                }

                myLine.Stroke          = solidColorBrush;
                myLine.X1              = -400;
                myLine.X2              = 400;
                myLine.Y1              = 0 + i;
                myLine.Y2              = 0 + i;
                myLine.StrokeThickness = 2;
                myLine.ToolTip         = i.ToString();
                testcanvas.Children.Add(myLine);
            }
        }
Esempio n. 3
0
        private void Paint()
        {
            AutoScrollCosts();
            isPainting = true;
            //LoadDataFromModel();
            testcanvas.Children.Clear();
            //DrawAxis(testcanvas);

            Logger.WriteLog("paint started");
            for (var i = 0; i < model.modelLines.Count; i++)
            {
                MyLine    line            = model.modelLines[i];
                ShapeLine myLine          = new ShapeLine();
                Brush     solidColorBrush = new SolidColorBrush(Color.FromArgb(95, 0, 0, 0));
                solidColorBrush.Opacity = 0.5;
                if (i.Equals(selectedLineIndex))
                {
                    solidColorBrush = Brushes.Yellow;
                }

                myLine.Stroke             = solidColorBrush;
                myLine.X1                 = line.StartMyPoint.X;
                myLine.X2                 = line.EndMyPoint.X;
                myLine.Y1                 = line.StartMyPoint.Y;
                myLine.Y2                 = line.EndMyPoint.Y;
                myLine.StrokeEndLineCap   = PenLineCap.Triangle;
                myLine.StrokeStartLineCap = PenLineCap.Round;
                myLine.StrokeThickness    = 10;
                myLine.ToolTip            = line.ToString();
                testcanvas.Children.Add(myLine);
            }

            for (var i = 0; i < model.ModelPoints.Count; i++)
            {
                MyPoint   point  = model.ModelPoints[i];
                ShapeLine myLine = new ShapeLine();

                var solidColorBrush = new SolidColorBrush(Color.FromArgb(90, 255, 0, 0));
                solidColorBrush.Opacity = 0.5;
                if (i.Equals(selectedPointIndex))
                {
                    solidColorBrush = Brushes.GreenYellow;
                }

                myLine.Stroke             = solidColorBrush;
                myLine.X1                 = point.X;
                myLine.X2                 = point.X + 1;
                myLine.Y1                 = point.Y;
                myLine.Y2                 = point.Y + 1;
                myLine.StrokeStartLineCap = PenLineCap.Round;
                myLine.StrokeEndLineCap   = PenLineCap.Triangle;
                myLine.StrokeThickness    = 10;
                myLine.ToolTip            = point.ToString();
                testcanvas.Children.Add(myLine);
            }

            //foreach (MyRoom room in model.modelRooms) {
            foreach (MyRoom room in Rooms)
            {
                List <MyPoint> boundaries = room.GetBoundaryPointsSorted();
                if (!boundaries.Any())
                {
                    continue;
                }
                //boundaries.RemoveAll(item => item == null); //this is error handling, but I would need to figure out why nulls exist
                List <Point> convertedPoints = boundaries.Select(i => new Point(i.X, i.Y)).ToList();
                Polygon      p = new Polygon();
                p.Points  = new PointCollection(convertedPoints);
                p.Fill    = new SolidColorBrush(room.type.fillColor.ToMediaColor());
                p.Opacity = 0.25;
                p.ToolTip = room.ToString();
                testcanvas.Children.Add(p);
            }

            isPainting = false;
        }