예제 #1
0
        /// <summary>
        /// Метод для отрисовки расписания
        /// </summary>
        private void DrawSchedule()
        {
            var machines      = (Schedule ?? throw new ArgumentNullException()).Select(m => m.Machine).Distinct().OrderBy(m => m.Name).ToList();
            var y             = 10;
            var timeLinePoint = 0;

            foreach (var machine in machines)
            {
                TextItems.Add(new TextDetails(10, y - 35, 50, 50, machine.Name));
                RectItems.Add(new RectItem(10, y, 50, 50, "Black"));
                var batches = Schedule.Where(m => m.Machine.Id == machine.Id).Select(b => b.Batch).ToList();
                var x       = 65;
                foreach (var b in batches)
                {
                    var color = b.NomenclatureId switch
                    {
                        0 => "Gold",
                        1 => "Silver",
                        2 => "LightSteelBlue",
                        _ => "Black"
                    };
                    timeLinePoint += machine.TimeDictionary[b.NomenclatureId];
                    var widthFromTime = machine.TimeDictionary[b.NomenclatureId] + 15;
                    TextItems.Add(new TextDetails(x + widthFromTime, y + 32, 20, 20, timeLinePoint.ToString()));
                    TextItems.Add(new TextDetails(x, y, widthFromTime, 20, b.Nomenclature.Name.Substring(0, 3)));
                    RectItems.Add(new RectItem(x, y, widthFromTime, 50, color));
                    x += widthFromTime + 2;
                }
                TimeLines.Add(new TimeLine(10, y + 23, x + 10, y + 23));
                y            += 90;
                timeLinePoint = 0;
            }
        }
    }
예제 #2
0
 public void AddTimeLine(LineType type, TimeLine <KeyValuePair <DateTime, decimal> > line)
 {
     if (TimeLines.ContainsKey(type))
     {
         TimeLines[type] = line;
     }
     else
     {
         TimeLines.Add(type, line);
     }
 }
예제 #3
0
        public CalendarWeek(DateTime weekStartDateTime)
        {
            WeekStartDateTime = weekStartDateTime;

            var weekDates = Enumerable.Range(0, 7)
                            .Select(offset => weekStartDateTime.AddDays(offset))
                            .ToList();

            SpansAcrossTwoMonths = weekDates.First().Month != weekDates.Last().Month;
            SpansAcrossTwoYears  = weekDates.First().Year != weekDates.Last().Year;

            weekDates.ForEach(cd =>
            {
                TimeLines.Add(new TimeLine(cd, new TimeSpan(24, 0, 0)));
            });
        }
예제 #4
0
        public void TimeLine_Load(Stream _s)
        {
            int num  = _s.ReadInteger();
            int num2 = _s.ReadInteger();

            for (int i = 0; i < num2; i++)
            {
                Stream stream = _s;
                if (num == 800)
                {
                    stream = _s.ReadStreamC();
                }
                bool flag = stream.ReadBoolean();
                KeyValuePair <string, GMTimeLine> item = default(KeyValuePair <string, GMTimeLine>);
                if (flag)
                {
                    string     key   = stream.ReadString();
                    GMTimeLine value = new GMTimeLine(this, stream);
                    item = new KeyValuePair <string, GMTimeLine>(key, value);
                }
                TimeLines.Add(item);
            }
        }
        private async void FillTimeLine()
        {
            var anyScene = _scenes.FirstOrDefault();

            for (int i = 0; i < anyScene.Areas.Count; i++)
            {
                TimeLines.Add(i + 1, new TimeLinePointCollection());
            }


            var rnd = new Random();

            while (_startDate < _endDate)
            {
                for (int i = 0; i < anyScene.Areas.Count; i++)
                {
                    var timeLinePoint = new TimeLinePoint()
                    {
                        Area     = anyScene.Areas[i].Number,
                        DateTime = _startDate,
                        Lon      = anyScene.Areas[i].LonLat.Lon,
                        Lat      = anyScene.Areas[i].LonLat.Lat,
                        Meteo    = (await _weatherService.GetPastWeatherForLocationAsync(anyScene.Areas[i].LonLat.ToString(), _startDate)).Now,
                        Map      = 0
                    };

                    TimeLines[timeLinePoint.Area].Add(timeLinePoint);
                }

                _startDate = _startDate.AddDays(_interval);
            }

            foreach (var scene in Scenes)
            {
                for (int i = 0; i < scene.Areas.Count; i++)
                {
                    try
                    {
                        var timeLinePoint = new TimeLinePoint()
                        {
                            Area     = scene.Areas[i].Number,
                            DateTime = scene.TimeStamp,
                            Lat      = scene.Areas[i].LonLat.Lat,
                            Lon      = scene.Areas[i].LonLat.Lon,
                            Meteo    = 0,
                            Map      = scene.Areas[i].UnitPoints.Select(x => x.PictureTemperature).Average()
                        };

                        TimeLines[timeLinePoint.Area].Add(timeLinePoint);
                    }
                    catch
                    {
                        continue;
                    }
                }
            }

            foreach (var timeLine in TimeLines)
            {
                await _dbService.InsertTimeLinePoints(timeLine.Value.ToList());
            }
        }