public void AutoFill()
        {
            ServiceName         = ServiceTemplate.ServiceTemplateName;
            ServiceAbbreviation = ServiceTemplate.ServiceTemplateAbbreviation;
            int StartTime = TimeConverters.TimeToMinutes(StartTimeText);

            EndTimeText = TimeConverters.MinutesToString(StartTime + ServiceTemplate.CalculatedDuration);
            NotifyOfPropertyChange(() => CanSaveService);
        }
Esempio n. 2
0
        public PlottableScatter PlotService(ScottPlotGraph model, TimeGraphUIModel graph, string serviceAbbreviation)
        {
            int startTime = TimeConverters.TimeToMinutes(model.StartTimeText);
            int endTime   = TimeConverters.TimeToMinutes(model.EndTimeText);

            double[] dataX = new double[graph.DataLine.Count];
            double[] dataY = new double[graph.DataLine.Count];

            int j = 0;

            if (graph.DataLine[0].Y >= startTime && graph.DataLine[0].Y < endTime)
            {
                foreach (var dataSet in graph.DataLine)
                {
                    dataX[j] = dataSet.X;
                    dataY[j] = -dataSet.Y;
                    scatterDataX[scatterIndex] = dataSet.X;
                    scatterDataY[scatterIndex] = -dataSet.Y;
                    highlightedTimeGraphUiModels[scatterIndex] = graph;
                    scatterIndex++;
                    j++;
                }


                double        xOffset = 0;
                double        yOffset = 5;
                TextAlignment alignment;
                if (dataX[0] < dataX.GetLength(0) / 2)
                {
                    alignment = TextAlignment.upperLeft;
                }
                else
                {
                    alignment = TextAlignment.upperRight;
                }
                TimetableGraph.plt.PlotText(serviceAbbreviation,
                                            dataX[0] + xOffset, dataY[0] + yOffset, fontName: "Arial", fontSize: 10,
                                            color: GetResourceColor("GraphText"), bold: true, alignment: alignment);
                return(TimetableGraph.plt.PlotScatterHighlight(dataX, dataY, GetLineColor(graph.ServiceType)));
            }
            else
            {
                return(null);
            }
        }
        public void SaveService()
        {
            ServiceModel newService = new ServiceModel();

            newService.ServiceName         = ServiceName;
            newService.ServiceAbbreviation = ServiceAbbreviation;
            newService.ServiceTemplateId   = ServiceTemplate.Id;
            newService.StartTime           = TimeConverters.TimeToMinutes(StartTimeText);
            newService.EndTime             = TimeConverters.TimeToMinutes(EndTimeText);
            if (ServiceId <= 0)
            {
                ServicesDataAccess.InsertService(newService);
            }
            else
            {
                newService.Id = ServiceId;
                ServicesDataAccess.UpdateService(newService);
            }
            ServiceList = new BindableCollection <ServiceModel>(ServicesDataAccess.GetServicesPerRoute(RouteId).OrderBy(x => x.StartTime));
            ClearService();
            NotifyOfPropertyChange(() => ServiceList);
        }