private void InitializeDatabase(DbContextOptions <SeriesContext> options) { using (var context = new SeriesContext(options)) { if (context.Database.EnsureCreated()) { var serie = new Serie { Id = 0, Title = "Narcos" }; context.Series.Add(serie); var season = new Season { Id = 0, Title = "Season 1" }; serie.Seasons.Add(season); var episode = new Episode { Id = 0, Title = "Descenso" }; season.Episodes.Add(episode); context.SaveChanges(); } } }
public static void Initialize(SeriesContext context) { context.Database.EnsureCreated(); if (context.Series.Any()) { return; } var series = new Series[] { new Series { ID = 1, Nome = "Vikings", Generos = "Acao", Caminho = "", Duracao = 130 } }; foreach (Series p in series) { context.Series.Add(p); } context.SaveChanges(); }
public override CartesianBounds GetBounds( SizeF controlSize, IAxis <TDrawingContext> x, IAxis <TDrawingContext> y, SeriesContext <TDrawingContext> seriesContext) { var baseBounds = base.GetBounds(controlSize, x, y, seriesContext); var tick = y.GetTick(controlSize, baseBounds.YAxisBounds); return(new CartesianBounds { XAxisBounds = new Bounds { Max = baseBounds.XAxisBounds.Max + 0.5, Min = baseBounds.XAxisBounds.Min - 0.5 }, YAxisBounds = new Bounds { Max = baseBounds.YAxisBounds.Max + tick.Value, min = baseBounds.YAxisBounds.min - tick.Value } }); }
public SeriesQuery(SeriesContext seriesDB) { Name = "Query"; Field <StringGraphType>("Ping", resolve: context => "Ping ok"); Field <ListGraphType <SeriesGraphType> >("allseries", resolve: context => { return(seriesDB.Series.Include(sa => sa.SerieActors).ThenInclude(sa => sa.Actor).ToList()); }); Field <ListGraphType <ActorsGraphType> >("allactors", resolve: context => { return(seriesDB.Actors.Include(sa => sa.SerieActors).ThenInclude(sa => sa.Serie).ToList()); }); Field <ListGraphType <SerieActorGraphType> >("allserieactor", resolve: context => { return(seriesDB.SerieActor.ToList()); }); Field <ListGraphType <SeriesGraphType> >("series", arguments: new QueryArguments( new QueryArgument <IntGraphType> { Name = "id", Description = "Id de la serie" }, new QueryArgument <StringGraphType> { Name = "name" }), resolve: context => { int?id = context.GetArgument <int?>("id"); string name = context.GetArgument <string>("name"); var result = seriesDB.Series.Include(s => s.SerieActors).ThenInclude(s => s.Actor) .Where(s => ((!id.HasValue || s.Id == id) && (string.IsNullOrWhiteSpace(name) || s.Name.Contains(name)))); return(result); }); }
protected override void Measure() { if (series == null) { chartView.CoreCanvas.ForEachGeometry((geometry, drawable) => { if (measuredDrawables.Contains(geometry)) { return; // then the geometry was measured } // at this point,the geometry is not required in the UI geometry.RemoveOnCompleted = true; }); return; } measuredDrawables = new HashSet <IDrawable <TDrawingContext> >(); seriesContext = new SeriesContext <TDrawingContext>(series); if (legend != null) { legend.Draw(this); } ValueBounds = new Bounds(); IndexBounds = new Bounds(); PushoutBounds = new Bounds(); foreach (var series in series) { if (series.SeriesId == -1) { series.SeriesId = nextSeries++; } LiveCharts.CurrentSettings.ResolveSeriesDefaults(series); var seriesBounds = series.GetBounds(this); ValueBounds.AppendValue(seriesBounds.PrimaryBounds.max); ValueBounds.AppendValue(seriesBounds.PrimaryBounds.min); IndexBounds.AppendValue(seriesBounds.SecondaryBounds.max); IndexBounds.AppendValue(seriesBounds.SecondaryBounds.min); PushoutBounds.AppendValue(seriesBounds.TertiaryBounds.max); PushoutBounds.AppendValue(seriesBounds.TertiaryBounds.min); } if (viewDrawMargin == null) { var m = viewDrawMargin ?? new Margin(); SetDrawMargin(controlSize, m); SetDrawMargin(controlSize, m); } // invalid dimensions, probably the chart is too small // or it is initializing in the UI and has no dimensions yet if (drawMarginSize.Width <= 0 || drawMarginSize.Height <= 0) { return; } foreach (var series in series) { series.Measure(this); } chartView.CoreCanvas.ForEachGeometry((geometry, drawable) => { if (measuredDrawables.Contains(geometry)) { return; // then the geometry was measured } // at this point,the geometry is not required in the UI geometry.RemoveOnCompleted = true; }); Canvas.Invalidate(); }
protected override void Measure() { measuredDrawables = new HashSet <IDrawable <TDrawingContext> >(); seriesContext = new SeriesContext <TDrawingContext>(series); if (legend != null) { legend.Draw(this); } var stylesBuilder = LiveCharts.CurrentSettings.GetStylesBuilder <TDrawingContext>(); var initializer = stylesBuilder.GetInitializer(); if (stylesBuilder.CurrentColors == null || stylesBuilder.CurrentColors.Length == 0) { throw new Exception("Default colors are not valid"); } // restart axes bounds and meta data foreach (var axis in secondaryAxes) { axis.Initialize(AxisOrientation.X); initializer.ResolveAxisDefaults(axis); } foreach (var axis in primaryAxes) { axis.Initialize(AxisOrientation.Y); initializer.ResolveAxisDefaults(axis); } // get seriesBounds foreach (var series in series) { if (series.SeriesId == -1) { series.SeriesId = nextSeries++; } initializer.ResolveSeriesDefaults(stylesBuilder.CurrentColors, series); var secondaryAxis = secondaryAxes[series.ScalesXAt]; var primaryAxis = primaryAxes[series.ScalesYAt]; var seriesBounds = series.GetBounds(this, secondaryAxis, primaryAxis); secondaryAxis.DataBounds.AppendValue(seriesBounds.SecondaryBounds.max); secondaryAxis.DataBounds.AppendValue(seriesBounds.SecondaryBounds.min); primaryAxis.DataBounds.AppendValue(seriesBounds.PrimaryBounds.max); primaryAxis.DataBounds.AppendValue(seriesBounds.PrimaryBounds.min); } if (viewDrawMargin == null) { var m = viewDrawMargin ?? new Margin(); float ts = 0f, bs = 0f, ls = 0f, rs = 0f; SetDrawMargin(controlSize, m); foreach (var axis in secondaryAxes) { var s = axis.GetPossibleSize(this); if (axis.Position == AxisPosition.LeftOrBottom) { // X Bottom axis.Yo = m.Bottom + s.Height * 0.5f; bs = bs + s.Height; m.Bottom = bs; //if (s.Width * 0.5f > m.Left) m.Left = s.Width * 0.5f; //if (s.Width * 0.5f > m.Right) m.Right = s.Width * 0.5f; } else { // X Top axis.Yo = ts + s.Height * 0.5f; ts += s.Height; m.Top = ts; //if (ls + s.Width * 0.5f > m.Left) m.Left = ls + s.Width * 0.5f; //if (rs + s.Width * 0.5f > m.Right) m.Right = rs + s.Width * 0.5f; } } foreach (var axis in primaryAxes) { var s = axis.GetPossibleSize(this); var w = s.Width > m.Left ? s.Width : m.Left; if (axis.Position == AxisPosition.LeftOrBottom) { // Y Left axis.Xo = ls + w * 0.5f; ls += w; m.Left = ls; //if (s.Height * 0.5f > m.Top) { m.Top = s.Height * 0.5f; } //if (s.Height * 0.5f > m.Bottom) { m.Bottom = s.Height * 0.5f; } } else { // Y Right axis.Xo = rs + w * 0.5f; rs += w; m.Right = rs; //if (ts + s.Height * 0.5f > m.Top) m.Top = ts + s.Height * 0.5f; //if (bs + s.Height * 0.5f > m.Bottom) m.Bottom = bs + s.Height * 0.5f; } } SetDrawMargin(controlSize, m); } // invalid dimensions, probably the chart is too small // or it is initializing in the UI and has no dimensions yet if (drawMarginSize.Width <= 0 || drawMarginSize.Height <= 0) { return; } foreach (var axis in secondaryAxes) { axis.Measure(this); } foreach (var axis in primaryAxes) { axis.Measure(this); } foreach (var series in series) { var secondaryAxis = secondaryAxes[series.ScalesXAt]; var primaryAxis = primaryAxes[series.ScalesYAt]; series.Measure(this, secondaryAxis, primaryAxis); } chartView.CoreCanvas.ForEachGeometry((geometry, drawable) => { if (measuredDrawables.Contains(geometry)) { return; // then the geometry was measured } // at this point,the geometry is not required in the UI geometry.RemoveOnCompleted = true; }); Canvas.Invalidate(); }
private void Measure() { measuredDrawables = new HashSet <IDrawable <TDrawingContext> >(); seriesContext = new SeriesContext <TDrawingContext>(series); if (legend != null) { legend.Draw(chartView); } // restart axes bounds and meta data foreach (var axis in xAxes) { axis.Initialize(AxisOrientation.X); } foreach (var axis in yAxes) { axis.Initialize(AxisOrientation.Y); } // get seriesBounds foreach (var series in series) { var xAxis = xAxes[series.ScalesXAt]; var yAxis = yAxes[series.ScalesYAt]; var seriesBounds = series.GetBounds(this, xAxis, yAxis); xAxis.DataBounds.AppendValue(seriesBounds.SecondaryBounds.max); xAxis.DataBounds.AppendValue(seriesBounds.SecondaryBounds.min); yAxis.DataBounds.AppendValue(seriesBounds.PrimaryBounds.max); yAxis.DataBounds.AppendValue(seriesBounds.PrimaryBounds.min); } if (viewDrawMargin == null) { var m = viewDrawMargin ?? new Margin(); float ts = 0f, bs = 0f, ls = 0f, rs = 0f; SetDrawMargin(controlSize, m); foreach (var axis in xAxes) { var s = axis.GetPossibleSize(this); if (axis.Position == AxisPosition.LeftOrBottom) { // X Bottom axis.Yo = m.Bottom + s.Height * 0.5f; bs = bs + s.Height; m.Bottom = bs; //if (s.Width * 0.5f > m.Left) m.Left = s.Width * 0.5f; //if (s.Width * 0.5f > m.Right) m.Right = s.Width * 0.5f; } else { // X Top axis.Yo = ts + s.Height * 0.5f; ts += s.Height; m.Top = ts; //if (ls + s.Width * 0.5f > m.Left) m.Left = ls + s.Width * 0.5f; //if (rs + s.Width * 0.5f > m.Right) m.Right = rs + s.Width * 0.5f; } } foreach (var axis in yAxes) { var s = axis.GetPossibleSize(this); var w = s.Width > m.Left ? s.Width : m.Left; if (axis.Position == AxisPosition.LeftOrBottom) { // Y Left axis.Xo = ls + w * 0.5f; ls += w; m.Left = ls; //if (s.Height * 0.5f > m.Top) { m.Top = s.Height * 0.5f; } //if (s.Height * 0.5f > m.Bottom) { m.Bottom = s.Height * 0.5f; } } else { // Y Right axis.Xo = rs + w * 0.5f; rs += w; m.Right = rs; //if (ts + s.Height * 0.5f > m.Top) m.Top = ts + s.Height * 0.5f; //if (bs + s.Height * 0.5f > m.Bottom) m.Bottom = bs + s.Height * 0.5f; } } SetDrawMargin(controlSize, m); } // invalid dimensions, probably the chart is too small // or it is initializing in the UI and has no dimensions yet if (drawMarginSize.Width <= 0 || drawMarginSize.Height <= 0) { return; } foreach (var axis in xAxes) { axis.Measure(this); } foreach (var axis in yAxes) { axis.Measure(this); } foreach (var series in series) { var x = xAxes[series.ScalesXAt]; var y = yAxes[series.ScalesYAt]; series.Measure(this, x, y); } chartView.CoreCanvas.ForEachGeometry((geometry, paint) => { if (measuredDrawables.Contains(geometry)) { return; // then the geometry was measured } // at this point,the geometry is not required in the UI geometry.RemoveOnCompleted = true; }); Canvas.Invalidate(); }
public override void Measure( IChartView <TDrawingContext> view, IAxis <TDrawingContext> xAxis, IAxis <TDrawingContext> yAxis, SeriesContext <TDrawingContext> context, HashSet <IDrawable <TDrawingContext> > drawBucket) { var drawLocation = view.Core.DrawMaringLocation; var drawMarginSize = view.Core.DrawMarginSize; var xScale = new ScaleContext(drawLocation, drawMarginSize, xAxis.Orientation, xAxis.DataBounds); var yScale = new ScaleContext(drawLocation, drawMarginSize, yAxis.Orientation, yAxis.DataBounds); float uw = xScale.ScaleToUi(1f) - xScale.ScaleToUi(0f); float uwm = 0.5f * uw; float sw = Stroke?.StrokeWidth ?? 0; float p = yScale.ScaleToUi(unchecked ((float)Pivot)); var pos = context.GetColumnPostion(this); var count = context.GetColumnSeriesCount(); float cp = 0f; if (!IgnoresColumnPosition && count > 1) { uw = uw / count; uwm = 0.5f * uw; cp = (pos - (count / 2f)) * uw + uwm; } if (uw > MaxColumnWidth) { uw = unchecked ((float)MaxColumnWidth); uwm = uw / 2f; } if (Fill != null) { view.CoreCanvas.AddPaintTask(Fill); } if (Stroke != null) { view.CoreCanvas.AddPaintTask(Stroke); } var chartAnimation = new Animation(view.EasingFunction, view.AnimationsSpeed); var ts = TransitionsSetter ?? SetDefaultTransitions; foreach (var point in GetPonts()) { var x = xScale.ScaleToUi(point.X); var y = yScale.ScaleToUi(point.Y); float b = Math.Abs(y - p); if (point.Visual == null) { var r = new TVisual { X = x - uwm + cp, Y = p, Width = uw, Height = 0 }; ts(r, chartAnimation); point.HoverArea = new HoverArea(); point.Visual = r; if (Fill != null) { Fill.AddGeometyToPaintTask(r); } if (Stroke != null) { Stroke.AddGeometyToPaintTask(r); } } var sizedGeometry = (TVisual)point.Visual; var cy = point.Y > Pivot ? y : y - b; sizedGeometry.X = x - uwm + cp; sizedGeometry.Y = cy; sizedGeometry.Width = uw; sizedGeometry.Height = b; point.HoverArea.SetDimensions(x - uwm + cp, cy, uw, b); OnPointMeasured(point, sizedGeometry); drawBucket.Add(sizedGeometry); } if (HighlightFill != null) { view.CoreCanvas.AddPaintTask(HighlightFill); } if (HighlightStroke != null) { view.CoreCanvas.AddPaintTask(HighlightStroke); } }
public SeriesRepository(string connString) { _context = new SeriesContext(connString); }
public SeriesRepository() { _context = new SeriesContext(); }
private void Measure() { var drawBucket = new HashSet <IDrawable <TDrawingContext> >(); if (chartView.Legend != null) { chartView.Legend.Draw(chartView); } var controlSize = chartView.ControlSize; // restart axes bounds and meta data foreach (var axis in chartView.XAxes) { axis.Initialize(AxisOrientation.X); } foreach (var axis in chartView.YAxes) { axis.Initialize(AxisOrientation.Y); } // get series bounds var seriesContext = new SeriesContext <TDrawingContext>(chartView.Series); foreach (var series in chartView.Series) { var xAxis = chartView.XAxes[series.ScalesXAt]; var yAxis = chartView.YAxes[series.ScalesYAt]; var seriesBounds = series.GetBounds(controlSize, xAxis, yAxis, seriesContext); xAxis.DataBounds.AppendValue(seriesBounds.XAxisBounds.max); xAxis.DataBounds.AppendValue(seriesBounds.XAxisBounds.min); yAxis.DataBounds.AppendValue(seriesBounds.YAxisBounds.max); yAxis.DataBounds.AppendValue(seriesBounds.YAxisBounds.min); } if (chartView.DrawMargin == null) { var m = chartView.DrawMargin ?? new Margin(); float ts = 0f, bs = 0f, ls = 0f, rs = 0f; SetDrawMargin(controlSize, m); foreach (var axis in chartView.XAxes) { var s = axis.GetPossibleSize(chartView); if (axis.Position == AxisPosition.LeftOrBottom) { // X Bottom axis.Yo = m.Bottom + s.Height * 0.5f; bs = bs + s.Height; m.Bottom = bs; //if (s.Width * 0.5f > m.Left) m.Left = s.Width * 0.5f; //if (s.Width * 0.5f > m.Right) m.Right = s.Width * 0.5f; } else { // X Top axis.Yo = ts + s.Height * 0.5f; ts += s.Height; m.Top = ts; //if (ls + s.Width * 0.5f > m.Left) m.Left = ls + s.Width * 0.5f; //if (rs + s.Width * 0.5f > m.Right) m.Right = rs + s.Width * 0.5f; } } foreach (var axis in chartView.YAxes) { var s = axis.GetPossibleSize(chartView); var w = s.Width > m.Left ? s.Width : m.Left; if (axis.Position == AxisPosition.LeftOrBottom) { // Y Left axis.Xo = ls + w * 0.5f; ls += w; m.Left = ls; //if (s.Height * 0.5f > m.Top) { m.Top = s.Height * 0.5f; } //if (s.Height * 0.5f > m.Bottom) { m.Bottom = s.Height * 0.5f; } } else { // Y Right axis.Xo = rs + w * 0.5f; rs += w; m.Right = rs; //if (ts + s.Height * 0.5f > m.Top) m.Top = ts + s.Height * 0.5f; //if (bs + s.Height * 0.5f > m.Bottom) m.Bottom = bs + s.Height * 0.5f; } } SetDrawMargin(controlSize, m); } // invalid dimensions, probably the chart is too small // or it is initializing in the UI and has no dimensions yet if (drawMarginSize.Width <= 0 || drawMarginSize.Height <= 0) { return; } foreach (var axis in chartView.XAxes) { axis.Measure(ChartView, drawBucket); } foreach (var axis in chartView.YAxes) { axis.Measure(ChartView, drawBucket); } foreach (var series in chartView.Series) { var x = ChartView.XAxes[series.ScalesXAt]; var y = ChartView.YAxes[series.ScalesYAt]; series.Measure(chartView, x, y, seriesContext, drawBucket); } chartView.CoreCanvas.ForEachGeometry((geometry, paint) => { if (drawBucket.Contains(geometry)) { return; // then the geometry was updated by the measure method } // at this point, no one used this geometry, we need to remove if from our canvas geometry.RemoveOnCompleted = true; }); NaturalGeometriesCanvas.Invalidate(); }
public RepositorySeries(SeriesContext context) { this.context = context; }
public SeriesRepository(SeriesContext dbContext, IMapper mapper) { this.mapper = mapper; this.dbContext = dbContext; }
public SeriesController(SeriesContext context) { _context = context; }