コード例 #1
0
        /// <inheritdoc />
        public System.IO.Stream CreateImageMask(System.IO.Stream sourceImageStream, string maskColorCode)
        {
            #region validation

            if (sourceImageStream == null)
            {
                throw new ArgumentNullException(nameof(sourceImageStream));
            }

            Regex regex = HexColorUtil.GetHexColorRegex();
            if (!regex.IsMatch(maskColorCode))
            {
                throw new ArgumentException($"Color code {maskColorCode} is malformed!");
            }

            #endregion

            // create solid color brush to draw mask
            IBrush brush = new SolidBrush(Rgba32Util.InitFromHex(maskColorCode));

            // create graphic options for overlay of alpha-channel-image with solid color brush
            //   non-transparent pixels of image should be overlayed with solid color brush
            GraphicsOptions graphicsOptions = new GraphicsOptions()
            {
                AlphaCompositionMode = PixelAlphaCompositionMode.SrcIn,
                ColorBlendingMode    = PixelColorBlendingMode.Normal
            };

            using (Image <Rgba32> originalImage = LoadImageFromStream <Rgba32>(sourceImageStream, out IImageFormat imageFormat))
            {
                originalImage.Mutate(x => x.Fill(graphicsOptions, brush));
                return(SaveAsStream(originalImage, imageFormat));
            }
        }
コード例 #2
0
        protected override string GetGraphXml()
        {
            using (var helper = new FusionChartsMultiSeriesHelper())
            {
                if (ReportObjectsList.Count <= 0)
                {
                    throw new Exception("No se encontraron datos asociados a los filtros seleccionados!");
                }

                SetGraphProperties(helper);

                AddDates(helper);

                var maxTurnos = ReportObjectsList.Select(res => res.HsTurnos.Count).Max();

                var colorGenerator = new ColorGenerator();
                FusionChartsDataset niveles;

                for (var i = 0; i < maxTurnos; i++)
                {
                    niveles = new FusionChartsDataset();
                    niveles.SetPropertyValue("color", HexColorUtil.ColorToHex(colorGenerator.GetNextColor()));

                    foreach (var dia in ReportObjectsList)
                    {
                        if (dia.HsTurnos.Count > 1)
                        {
                            niveles.addValue(dia.HsTurnos.First().ToString(CultureInfo.InvariantCulture));
                            dia.HsTurnos.Remove(dia.HsTurnos.First());
                            niveles.addValue(dia.HsReales.First().ToString(CultureInfo.InvariantCulture));
                            dia.HsReales.Remove(dia.HsReales.First());
                            niveles.addValue("0");
                        }
                        else
                        if (dia.HsTurnos.Count == 1)
                        {
                            niveles.addValue("0");
                            niveles.addValue("0");
                            niveles.addValue("0");
                        }
                    }
                    helper.AddDataSet(niveles);
                }

                niveles = new FusionChartsDataset();
                niveles.SetPropertyValue("color", HexColorUtil.ColorToHex(Color.Gray));
                niveles.SetPropertyValue("seriesName", "Fuera de Turno");
                foreach (var dia in ReportObjectsList)
                {
                    niveles.addValue(dia.HsTurnos.First().ToString(CultureInfo.InvariantCulture));
                    niveles.addValue(dia.HsReales.First().ToString(CultureInfo.InvariantCulture));
                    niveles.addValue("0");
                }
                helper.AddDataSet(niveles);

                return(helper.BuildXml());
            }
        }
コード例 #3
0
        protected override string GetGraphXml()
        {
            ToogleItems(lbBase);

            using (var helper = new FusionChartsMultiSeriesHelper())
            {
                SetGraphConfiguration(helper);

                var iniDate  = SecurityExtensions.ToDataBaseDateTime(dtpDate.SelectedDate.GetValueOrDefault());
                var finDate  = SecurityExtensions.ToDataBaseDateTime(dtpDate.SelectedDate.GetValueOrDefault()).AddHours(23).AddMinutes(59).AddSeconds(59);
                var colorGen = new ColorGenerator();

                var noCategoriesAdded = true;
                var hasValue          = false;
                if (lbBase.GetSelectedIndices().Length == 0)
                {
                    lbBase.ToogleItems();
                }

                foreach (var index in lbBase.GetSelectedIndices())
                {
                    var data = ReportFactory.IdleTimesDAO.GetAllMovilesStoppedInPlanta(Convert.ToInt32((string)lbBase.Items[index].Value),
                                                                                       iniDate, finDate, chkUndefined.Checked);

                    var dataset = new FusionChartsDataset {
                        Name = lbBase.Items[index].Text
                    };
                    dataset.SetPropertyValue("SeriesName", lbBase.Items[index].Text);
                    dataset.SetPropertyValue("color", HexColorUtil.ColorToHex(colorGen.GetNextColor()));

                    foreach (var item in data)
                    {
                        if (noCategoriesAdded)
                        {
                            helper.AddCategory(item.Date.ToShortTimeString());
                        }
                        dataset.addValue(item.TotalVehicles.ToString(CultureInfo.InvariantCulture));
                        if (!item.TotalVehicles.Equals(0))
                        {
                            hasValue = true;
                        }
                    }

                    helper.AddDataSet(dataset);
                    noCategoriesAdded = false;
                }

                if (!hasValue)
                {
                    throw new Exception(CultureManager.GetError("NO_MOBILE_IN_BASE"));
                }

                return(helper.BuildXml());
            }
        }
コード例 #4
0
        public void GetBFromRGBATest()
        {
            // Init
            string hexColor = "#465A";

            // Act
            byte result = HexColorUtil.GetB(hexColor);

            // Assert
            Assert.AreEqual(80, result);
        }
コード例 #5
0
        /// <inheritdoc />
        public System.IO.Stream FillPolygon(System.IO.Stream sourceImageStream, string polygonColorCode, Polygon polygon)
        {
            #region validation

            if (sourceImageStream == null)
            {
                throw new ArgumentNullException(nameof(sourceImageStream));
            }

            if (string.IsNullOrEmpty(polygonColorCode))
            {
                throw new ArgumentNullException(nameof(polygonColorCode));
            }

            Regex regex = HexColorUtil.GetHexColorRegex();
            if (!regex.IsMatch(polygonColorCode))
            {
                throw new ArgumentException($"Color code {polygonColorCode } is malformed!");
            }

            if (polygon == null)
            {
                throw new ArgumentNullException(nameof(polygon));
            }

            if (polygon.Points == null)
            {
                throw new ArgumentException(nameof(polygon.Points));
            }

            if (polygon.Points.Count() < 2)
            {
                throw new ArgumentException($"Polygon {nameof(polygon)} has to contain more than one entry!");
            }

            #endregion

            IBrush brush = new SolidBrush(Rgba32Util.InitFromHex(polygonColorCode));

            ShapeGraphicsOptions graphicsOptions = new ShapeGraphicsOptions()
            {
                GraphicsOptions = new GraphicsOptions()
                {
                    ColorBlendingMode = PixelColorBlendingMode.Normal
                }
            };

            using (Image <Rgba32> originalImage = LoadImageFromStream <Rgba32>(sourceImageStream, out IImageFormat imageFormat))
            {
                originalImage.Mutate(c => c.FillPolygon(graphicsOptions, brush, polygon.Points.Select(p => new PointF(p.X, p.Y)).ToArray()));

                return(SaveAsStream(originalImage, imageFormat));
            }
        }
コード例 #6
0
        public void GetAFromRRGGBBAATest()
        {
            // Init
            string hexColor = "#128Fa53C";

            // Act
            byte result = HexColorUtil.GetA(hexColor);

            // Assert
            Assert.AreEqual(60, result);
        }
コード例 #7
0
        public void GetAFromRGBTest()
        {
            // Init
            string hexColor = "#465";

            // Act
            byte result = HexColorUtil.GetA(hexColor);

            // Assert
            Assert.AreEqual(255, result);
        }
コード例 #8
0
        public void GetBFromRRGGBBTest()
        {
            // Init
            string hexColor = "#128Fa5";

            // Act
            byte result = HexColorUtil.GetB(hexColor);

            // Assert
            Assert.AreEqual(165, result);
        }
コード例 #9
0
        public void GetHexColorRegexInvalidCharacterTest()
        {
            // Init
            Regex  hexColorRegex = HexColorUtil.GetHexColorRegex();
            string hexColor      = "#f5C93Td4";

            // Act
            bool result = hexColorRegex.IsMatch(hexColor);

            // Assert
            Assert.IsFalse(result);
        }
コード例 #10
0
        public void GetHexColorRegexRGBATest()
        {
            // Init
            Regex  hexColorRegex = HexColorUtil.GetHexColorRegex();
            string hexColor      = "#f5C9";

            // Act
            bool result = hexColorRegex.IsMatch(hexColor);

            // Assert
            Assert.IsTrue(result);
        }
コード例 #11
0
        public void GetHexColorRegexLength9Test()
        {
            // Init
            Regex  hexColorRegex = HexColorUtil.GetHexColorRegex();
            string hexColor      = "#f5C93dd47";

            // Act
            bool result = hexColorRegex.IsMatch(hexColor);

            // Assert
            Assert.IsFalse(result);
        }
コード例 #12
0
        /// <summary>
        /// Adds engine average consumption refference line.
        /// </summary>
        /// <param name="helper"></param>
        private void AddEnginesConsumptionTrendline(FusionChartsMultiSeriesHelper helper)
        {
            var trendline = new FusionChartsTrendline();

            var avgConsumption = (from nivel in ReportObjectsList select nivel.Consumo).Average();

            trendline.AddPropertyValue("startValue", string.Format("{0}", (int)avgConsumption));
            trendline.AddPropertyValue("displayValue", string.Format("{0}: {1}lit", CultureManager.GetLabel("CONSUMO"), (int)avgConsumption));
            trendline.AddPropertyValue("color", HexColorUtil.ColorToHex(Color.LightCoral));
            trendline.AddPropertyValue("thickness", "3");

            helper.AddTrendLine(trendline);
        }
コード例 #13
0
        /// <summary>
        /// Searchs result positions to be displayed.
        /// </summary>

        /*private void SearchPositions()
         * {
         *  var route = DAOFactory.RoutePositionDAO.GetPositions(Mobile, InitialDate.ToDataBaseDateTime(), FinalDate.ToDataBaseDateTime());
         *
         *  if (route.Count == 0)
         *  {
         *      ShowInfo("No se encontraron posiciones para los parametros de busqueda ingresados!");
         *
         *      return;
         *  }
         *
         *  var pos = "[";
         *
         *  for (var i = 0; i < route.Count; i++)
         *  {
         *      var dist = i == route.Count - 1 ? 0 : Distancias.Loxodromica(route[i].Latitude, route[i].Longitude, route[i + 1].Latitude, route[i + 1].Longitude);
         *
         *      var duration = i == route.Count - 1 ? 0 : route[i + 1].Date.Subtract(route[i].Date).TotalSeconds;
         *
         *      if (i > 0) pos = string.Concat(pos, ',');
         *
         *      pos = string.Concat(pos, string.Format("{{lon: {0}, lat: {1}, speed: {2}, distance: {3}, duration: {4}, time: new Date{5}}}",
         *          route[i].Longitude.ToString(CultureInfo.InvariantCulture), route[i].Latitude.ToString(CultureInfo.InvariantCulture), route[i].Speed,
         *          dist.ToString(CultureInfo.InvariantCulture), duration.ToString(CultureInfo.InvariantCulture), route[i].Date.ToString("(yyyy, MM, dd, HH, mm, ss)")));
         *  }
         *
         *  pos = string.Concat(pos, "]");
         *
         *  System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "route", string.Format("simulador.createRoute({0});", pos), true);
         * }
         */
        private void SearchPositions()
        {
            var colorGenerator = new ColorGenerator(new List <Color> {
                Color.Red, Color.Blue, Color.Green, Color.Orange, Color.Violet, Color.Cyan, Color.Purple
            });
            var empresa   = DAOFactory.EmpresaDAO.FindById(ddlDistrito.Selected);
            var maxMonths = empresa != null && empresa.Id > 0 ? empresa.MesesConsultaPosiciones : 3;

            var route = DAOFactory.RoutePositionsDAO.GetPositionsByRoute(Mobile, InitialDate.ToDataBaseDateTime(), FinalDate.ToDataBaseDateTime(), TimeSpan.Zero, maxMonths);

            if (route.Count == 0)
            {
                ShowInfo("No se encontraron posiciones para los parametros de busqueda ingresados!");

                return;
            }

            var pos = "[";

            for (var j = 0; j < route.Count; j++)
            {
                var tramo = route[j];
                var color = HexColorUtil.ColorToHex(colorGenerator.GetNextColor(j)).Substring(1);
                color = color.Substring(4, 2) + color.Substring(2, 2) + color.Substring(0, 2);
                for (var i = 0; i < tramo.Count; i++)
                {
                    var posicion = tramo[i];
                    var next     = i == tramo.Count - 1
                                   ? j == route.Count - 1 ? null : route[j + 1][0]
                                   : tramo[i + 1];
                    var dist = next == null ? 0 : Distancias.Loxodromica(posicion.Latitude, posicion.Longitude, next.Latitude, next.Longitude);

                    var duration = next == null ? 0 : next.Date.Subtract(posicion.Date).TotalSeconds;

                    if (j > 0 || i > 0)
                    {
                        pos = string.Concat(pos, ',');
                    }

                    pos = string.Concat(pos, string.Format("{{lon: {0}, lat: {1}, speed: {2}, distance: {3}, duration: {4}, time: new Date{5}, 'color': '{6}' }}",
                                                           posicion.Longitude.ToString(CultureInfo.InvariantCulture), posicion.Latitude.ToString(CultureInfo.InvariantCulture), posicion.Speed,
                                                           dist.ToString(CultureInfo.InvariantCulture), duration.ToString(CultureInfo.InvariantCulture), posicion.Date.ToDisplayDateTime().ToString("(yyyy, MM, dd, HH, mm, ss)"), color));
                }
            }
            pos = string.Concat(pos, "]");

            var startflag = CreateAbsolutePath("~/images/salida.png");
            var endflag   = CreateAbsolutePath("~/images/llegada.png");

            System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "route", string.Format("simulador.createRoute({0},'{1}','{2}');", pos, startflag, endflag), true);
        }
コード例 #14
0
        /// <summary>
        /// Adds tank level variation.
        /// </summary>
        /// <param name="helper"></param>
        private void AddEnginesCaudal(FusionChartsMultiSeriesHelper helper)
        {
            var niveles = new FusionChartsDataset();

            var avgCaudal = (from nivel in ReportObjectsList select nivel.Caudal).Average();

            niveles.SetPropertyValue("seriesName", string.Format("{0}: {1}lit", CultureManager.GetLabel("CAUDAL"), (int)avgCaudal));
            niveles.SetPropertyValue("color", HexColorUtil.ColorToHex(Color.SteelBlue));

            foreach (var nivel in ReportObjectsList)
            {
                niveles.addValue(nivel.Caudal.ToString(CultureInfo.InvariantCulture));
            }
            helper.AddDataSet(niveles);
        }
コード例 #15
0
        public System.IO.Stream RecolorImage(System.IO.Stream imageStream, string sourceColorCode, string targetColorCode)
        {
            #region validation

            if (imageStream == null)
            {
                throw new ArgumentNullException(nameof(imageStream));
            }

            if (string.IsNullOrEmpty(sourceColorCode))
            {
                throw new ArgumentNullException(nameof(sourceColorCode));
            }

            if (string.IsNullOrEmpty(targetColorCode))
            {
                throw new ArgumentNullException(nameof(targetColorCode));
            }

            Regex regex = HexColorUtil.GetHexColorRegex();
            if (!regex.IsMatch(sourceColorCode))
            {
                throw new ArgumentException($"Color code {sourceColorCode} is malformed!");
            }

            if (!regex.IsMatch(targetColorCode))
            {
                throw new ArgumentException($"Color code {targetColorCode} is malformed!");
            }

            #endregion

            Rgba32 sourceColor = Rgba32Util.InitFromHex(sourceColorCode);
            Rgba32 targetColor = Rgba32Util.InitFromHex(targetColorCode);

            RecolorBrush <Rgba32> recolorBrush = new RecolorBrush <Rgba32>(sourceColor, targetColor, 0.2f);

            using (Image <Rgba32> originalImage = LoadImageFromStream(imageStream))
                using (Image <Rgba32> targetImage = originalImage.Clone())
                {
                    targetImage.Mutate(x => x.Fill(recolorBrush));

                    return(SaveAsStream(targetImage));
                }
        }
コード例 #16
0
        /// <inheritdoc />
        public System.IO.Stream ColorizePixel(System.IO.Stream imageStream, GetPixelColor getPixelColor)
        {
            #region validation

            if (imageStream == null)
            {
                throw new ArgumentNullException(nameof(imageStream));
            }

            if (getPixelColor == null)
            {
                throw new ArgumentNullException(nameof(getPixelColor));
            }

            #endregion

            // create map for colorcode-representation
            // stores already translated HEX-colors
            Dictionary <string, Rgba32> colorMap = new Dictionary <string, Rgba32>();

            using (Image <Rgba32> image = LoadImageFromStream <Rgba32>(imageStream, out IImageFormat imageFormat))
            {
                // iterate over all pixels of image
                for (int x = 0; x < image.Width; x++)
                {
                    for (int y = 0; y < image.Height; y++)
                    {
                        // get color for pixel
                        // if null, background color should be used
                        string pixelColor = getPixelColor(x, y);
                        if (!string.IsNullOrEmpty(pixelColor))
                        {
                            if (!colorMap.ContainsKey(pixelColor))
                            {
                                colorMap.Add(pixelColor, new Rgba32(HexColorUtil.GetR(pixelColor), HexColorUtil.GetG(pixelColor), HexColorUtil.GetB(pixelColor), HexColorUtil.GetA(pixelColor)));
                            }

                            image[x, y] = colorMap[pixelColor];
                        }
                    }
                }

                return(SaveAsStream(image, imageFormat));
            }
        }
コード例 #17
0
        /// <inheritdoc />
        public System.IO.Stream DrawRects(System.IO.Stream sourceImageStream, IEnumerable <DrawableRect> rects)
        {
            #region validation

            if (sourceImageStream == null)
            {
                throw new ArgumentNullException(nameof(sourceImageStream));
            }

            if (rects == null)
            {
                throw new ArgumentNullException(nameof(rects));
            }

            Regex regex = HexColorUtil.GetHexColorRegex();
            foreach (DrawableRect rect in rects)
            {
                if (!regex.IsMatch(rect.BorderColorCode))
                {
                    throw new ArgumentException($"Color code {rect.BorderColorCode} is malformed!");
                }
            }

            #endregion

            using (Image <Rgba32> sourceImage = LoadImageFromStream <Rgba32>(sourceImageStream, out IImageFormat imageFormat))
            {
                foreach (DrawableRect rect in rects)
                {
                    Rgba32     rectColor = Rgba32Util.InitFromHex(rect.BorderColorCode);
                    SolidBrush brush     = new SolidBrush(rectColor);

                    sourceImage.Mutate(x => x.DrawPolygon(brush, rect.BorderThickness, new PointF[] {
                        new Vector2(rect.X, rect.Y),
                        new Vector2(rect.X + rect.Width, rect.Y),
                        new Vector2(rect.X + rect.Width, rect.Y + rect.Height),
                        new Vector2(rect.X, rect.Y + rect.Height)
                    }));
                }

                return(SaveAsStream(sourceImage, imageFormat));
            }
        }
コード例 #18
0
        /// <summary>
        /// Gets the graph XML file.
        /// </summary>
        /// <returns></returns>
        protected override string GetGraphXml()
        {
            var datasets = new List <FusionChartsDataset>();

            using (var helper = new FusionChartsMultiSeriesHelper())
            {
                SetGraphProperties(helper);
                var flag = true;

                var colores = new ColorGenerator();

                foreach (var m in _horas.Keys)
                {
                    var horas       = new FusionChartsDataset();
                    var descripcion = DAOFactory.CaudalimetroDAO.FindById(m).Descripcion;
                    horas.SetPropertyValue("seriesName", descripcion);
                    horas.SetPropertyValue("color", HexColorUtil.ColorToHex(colores.GetNextColor()));
                    var list = _horas[m];

                    if (list.Count.Equals(0))
                    {
                        continue;
                    }

                    foreach (var h in list)
                    {
                        if (flag)
                        {
                            helper.AddCategory(h.Fecha.ToShortDateString());
                        }
                        horas.addValue(h.HsEnMarcha.ToString(CultureInfo.InvariantCulture));
                    }
                    flag = false;
                    helper.AddDataSet(horas);
                    datasets.Add(horas);
                }
                var categories = new List <string>();
                categories.AddRange(helper.GetCategoriesList());
                GraphCategories = categories;
                GraphDataSet    = datasets;
                return(helper.BuildXml());
            }
        }
コード例 #19
0
        protected override void GetGraphCategoriesAndDatasets()
        {
            var datasets   = new List <FusionChartsDataset>();
            var categories = new List <string>();

            var iniDate  = SecurityExtensions.ToDataBaseDateTime(dtpDate.SelectedDate.GetValueOrDefault());
            var finDate  = SecurityExtensions.ToDataBaseDateTime(dtpDate.SelectedDate.GetValueOrDefault()).AddHours(23).AddMinutes(59).AddSeconds(59);
            var colorGen = new ColorGenerator();

            var noCategoriesAdded = true;

            if (lbBase.GetSelectedIndices().Length == 0)
            {
                lbBase.ToogleItems();
            }

            foreach (var index in lbBase.GetSelectedIndices())
            {
                var data = ReportFactory.IdleTimesDAO.GetAllMovilesStoppedInPlanta(Convert.ToInt32((string)lbBase.Items[index].Value),
                                                                                   iniDate, finDate, chkUndefined.Checked);

                var dataset = new FusionChartsDataset {
                    Name = lbBase.Items[index].Text
                };
                dataset.SetPropertyValue("color", HexColorUtil.ColorToHex(colorGen.GetNextColor()));

                foreach (var item in data)
                {
                    if (noCategoriesAdded)
                    {
                        categories.Add(item.Date.ToShortTimeString());
                    }
                    dataset.addValue(item.TotalVehicles.ToString(CultureInfo.InvariantCulture));
                }

                datasets.Add(dataset);
                noCategoriesAdded = false;
            }

            GraphCategories = categories;
            GraphDataSet    = datasets;
        }
コード例 #20
0
 private string SerializeQtree(QLeaf x, double hres, double vres)
 {
     return
         (string.Format("{{'id':'{0}','lon':{1},'lat':{2},'hres':{3},'vres':{4},'color':'{5}'}}",
                        x.Index.Y.ToString() + "-" + x.Index.X.ToString(),
                        x.Posicion.Longitud.ToString(CultureInfo.InvariantCulture),
                        x.Posicion.Latitud.ToString(CultureInfo.InvariantCulture),
                        hres.ToString(CultureInfo.InvariantCulture),
                        vres.ToString(CultureInfo.InvariantCulture),
                        System.Web.HttpUtility.JavaScriptStringEncode(HexColorUtil.ColorToHex(BaseQtree.GetColorForLevel(x.Valor)))
                        ).Replace("'", "\""));
     //return string.Format("{{ \"id\": '{0}{1}', \"lon\": {2}, \"lat\": {3}, \"hres\": {4}, \"vres\": {5}, \"color\": \"{6}\" }}",
     //    x.Index.Y,
     //    x.Index.X,
     //    x.Posicion.Longitud.ToString(CultureInfo.InvariantCulture),
     //    x.Posicion.Latitud.ToString(CultureInfo.InvariantCulture),
     //    hres.ToString(CultureInfo.InvariantCulture),
     //    vres.ToString(CultureInfo.InvariantCulture),
     //    HexColorUtil.ColorToHex(BaseQtree.GetColorForLevel(x.Valor))
     //    );
 }
コード例 #21
0
        /// <inheritdoc />
        public System.IO.Stream CreateImage(Rect dimension, string backgroundColorCode)
        {
            #region validation

            if (dimension == null)
            {
                throw new ArgumentNullException(nameof(dimension));
            }

            Regex regex = HexColorUtil.GetHexColorRegex();
            if (!regex.IsMatch(backgroundColorCode))
            {
                throw new ArgumentException($"Color code {backgroundColorCode} is malformed!");
            }

            #endregion

            using (Image <Rgba32> image = new Image <Rgba32>(SixLabors.ImageSharp.Configuration.Default, dimension.Width, dimension.Height, Rgba32Util.InitFromHex(backgroundColorCode)))
            {
                return(SaveAsStream(image, PngFormat.Instance));
            }
        }
コード例 #22
0
        /// <summary>
        /// Adds tank level variation.
        /// </summary>
        /// <param name="helper"></param>
        private void AddTankLevelVariation(FusionChartsMultiSeriesHelper helper)
        {
            var niveles = new FusionChartsDataset();

            var labelInterval = (ReportObjectsList.Count / _MAX_LABELS) + 1;
            var i             = labelInterval;

            int resto;

            Math.DivRem(Convert.ToInt32(npIntervalo.Value), 1440, out resto);
            var printOnlyDate = resto.Equals(0);

            niveles.SetPropertyValue("seriesName", ddlTanque.SelectedItem.Text);
            niveles.SetPropertyValue("color", HexColorUtil.ColorToHex(Color.SteelBlue));

            if (ReportObjectsList.Any(o => o.VolumenConsumido > 0.01))
            {
                foreach (var nivel in ReportObjectsList)
                {
                    var str = string.Empty;

                    if (i.Equals(labelInterval))
                    {
                        str = printOnlyDate ? String.Format("{0}", nivel.Fecha.ToShortDateString()) :
                              String.Format("{0} - {1}", nivel.Fecha.ToShortDateString(), nivel.Fecha.ToShortTimeString());

                        i = 0;
                    }

                    i++;

                    helper.AddCategory(str);

                    niveles.addValue(nivel.VolumenConsumido.ToString(CultureInfo.InvariantCulture));
                }
            }
            helper.AddDataSet(niveles);
        }
コード例 #23
0
        public System.IO.Stream DrawRect(System.IO.Stream sourceImageStream, Rect rect, string rectColorCode)
        {
            #region validation

            if (sourceImageStream == null)
            {
                throw new ArgumentNullException(nameof(sourceImageStream));
            }

            if (rect == null)
            {
                throw new ArgumentNullException(nameof(rect));
            }

            Regex regex = HexColorUtil.GetHexColorRegex();
            if (!regex.IsMatch(rectColorCode))
            {
                throw new ArgumentException($"Color code {rectColorCode} is malformed!");
            }

            #endregion

            Rgba32 rectColor = Rgba32Util.InitFromHex(rectColorCode);

            SolidBrush <Rgba32> brush = new SolidBrush <Rgba32>(rectColor);
            using (Image <Rgba32> sourceImage = LoadImageFromStream(sourceImageStream))
            {
                sourceImage.Mutate(x => x.DrawPolygon(brush, 5.0f, new SixLabors.Primitives.PointF[] {
                    new Vector2(rect.X, rect.Y),
                    new Vector2(rect.X + rect.Width, rect.Y),
                    new Vector2(rect.X + rect.Width, rect.Y + rect.Height),
                    new Vector2(rect.X, rect.Y + rect.Height)
                }));

                return(SaveAsStream(sourceImage));
            }
        }
コード例 #24
0
        /// <inheritdoc />
        public System.IO.Stream DrawRect(System.IO.Stream sourceImageStream, Rect rect, string rectColorCode)
        {
            #region validation

            if (sourceImageStream == null)
            {
                throw new ArgumentNullException(nameof(sourceImageStream));
            }

            if (rect == null)
            {
                throw new ArgumentNullException(nameof(rect));
            }

            Regex regex = HexColorUtil.GetHexColorRegex();
            if (!regex.IsMatch(rectColorCode))
            {
                throw new ArgumentException($"Color code {rectColorCode} is malformed!");
            }

            #endregion

            List <DrawableRect> drawableRects = new List <DrawableRect>
            {
                new DrawableRect()
                {
                    BorderColorCode = rectColorCode,
                    X      = rect.X,
                    Y      = rect.Y,
                    Width  = rect.Width,
                    Height = rect.Height
                }
            };

            return(DrawRects(sourceImageStream, drawableRects));
        }
コード例 #25
0
ファイル: OdometroAlta.aspx.cs プロジェクト: jesumarquez/lt
        protected override void OnSave()
        {
            EditObject.Descripcion      = txtDescripcion.Text;
            EditObject.PorKm            = chkPorKm.Checked;
            EditObject.PorTiempo        = chkPorTiempo.Checked;
            EditObject.PorHoras         = chkPorHoras.Checked;
            EditObject.EsIterativo      = chkEsIterativo.Checked;
            EditObject.EsReseteable     = chkReseteable.Checked;
            EditObject.ReferenciaKm     = EditObject.PorKm ? npKilometrosReferencia.Value: 0;
            EditObject.ReferenciaTiempo = EditObject.PorTiempo ? (int)npDiasReferencia.Value : 0;
            EditObject.ReferenciaHoras  = EditObject.PorHoras ? (int)npHorasReferencia.Value : 0;

            EditObject.Alarma1Km     = EditObject.PorKm ? npKmAlarma1.Value : 0;
            EditObject.Alarma1Tiempo = EditObject.PorTiempo ? (int)npDiasAlarma1.Value: 0;
            EditObject.Alarma1Horas  = EditObject.PorHoras ? (int)npHorasAlarma1.Value : 0;
            EditObject.Alarma1RGB    = !string.IsNullOrEmpty(txtColorAlarma1.Color) ? txtColorAlarma1.Color : HexColorUtil.ColorToHex(Color.White).TrimStart('#');

            EditObject.Alarma2Km     = EditObject.PorKm ? npKmAlarma2.Value: 0;
            EditObject.Alarma2Tiempo = EditObject.PorTiempo ?(int)npDiasAlarma2.Value: 0;
            EditObject.Alarma2Horas  = EditObject.PorHoras ? (int)npHorasAlarma2.Value : 0;
            EditObject.Alarma2Rgb    = !string.IsNullOrEmpty(txtColorAlarma2.Color) ? txtColorAlarma2.Color : HexColorUtil.ColorToHex(Color.White).TrimStart('#');

            var linea   = ddlBase.Selected > 0 ? DAOFactory.LineaDAO.FindById(ddlBase.Selected) : null;
            var empresa = ddlDistrito.Selected > 0 ? DAOFactory.EmpresaDAO.FindById(ddlDistrito.Selected) : linea != null ? linea.Empresa : null;

            EditObject.Empresa = empresa;
            EditObject.Linea   = linea;
            EditObject.Insumo  = cbInsumos.Selected > 0 ? DAOFactory.InsumoDAO.FindById(cbInsumos.Selected) : null;

            var usuario = DAOFactory.UsuarioDAO.FindById(Usuario.Id);

            if (ddclTipos.SelectedValues.Contains(-1))
            {
                ddclTipos.ToogleItems();
            }

            RefreshOdometerVehicleTypes();

            DAOFactory.OdometroDAO.SaveOrUpdate(EditObject, (IEnumerable <int>)VehiculoListBox.SelectedValues, usuario);
        }
コード例 #26
0
ファイル: StyleFactory.cs プロジェクト: jesumarquez/lt
 /// <summary>
 /// Gets a point style for the givenn color.
 /// </summary>
 /// <param name="color"></param>
 /// <returns></returns>
 public static string GetPointFromColor(Color color)
 {
     return(string.Format("{{strokeColor: '{0}', fillColor: '{0}', fillOpacity: 0.5}}", HexColorUtil.ColorToHex(color)));
 }
コード例 #27
0
ファイル: StyleFactory.cs プロジェクト: jesumarquez/lt
 public static string GetDottedLineFromColor(Color color, int size, double opacity)
 {
     return(string.Concat("{strokeColor: '", HexColorUtil.ColorToHex(color), "', strokeWidth: " + size + ", strokeDashstyle: 'dot', strokeOpacity: " + opacity.ToString("0.0", CultureInfo.InvariantCulture) + "}"));
 }
コード例 #28
0
ファイル: StyleFactory.cs プロジェクト: jesumarquez/lt
 public static string GetDottedLineFromColor(Color color)
 {
     return(string.Concat("{strokeColor: '", HexColorUtil.ColorToHex(color), "', strokeWidth: 4, strokeDashstyle: 'dot'}"));
 }
コード例 #29
0
ファイル: StyleFactory.cs プロジェクト: jesumarquez/lt
 /// <summary>
 /// Gets a line style for the givenn color.
 /// </summary>
 /// <param name="color"></param>
 /// <returns></returns>
 public static string GetLineFromColor(Color color)
 {
     return(string.Concat("{strokeColor: '", HexColorUtil.ColorToHex(color), "', strokeWidth: 4}"));
 }
コード例 #30
0
ファイル: StyleFactory.cs プロジェクト: jesumarquez/lt
 public static string GetPolygonFromColor(Color backColor, Color borderColor)
 {
     return(string.Format("{{strokeColor: '{0}', fillColor: '{0}', fillOpacity: 0.5, strokeColor: '{1}', strokeWidth: 1}}", HexColorUtil.ColorToHex(backColor), HexColorUtil.ColorToHex(borderColor)));
 }