Exemple #1
0
        /// <summary>
        /// Отображение служебных организаций на Bmp
        /// </summary>
        /// <param name="DataOfBot"></param>
        /// <param name="FloorID"></param>
        public void DrawLandMarksExtra(CachedDataModel DataOfBot, int FloorID)
        {
            var AllOrgsOnThisFloor     = DataOfBot.GetOrganizations(DataOfBot.MapObjects.Where(x => x.FloorID == FloorID).ToList());
            var ServiceOrgsOnThisFloor = AllOrgsOnThisFloor.Where(x => DataOfBot.IsServiceOrganizaion(x)).ToList();
            var MapObjectsOnThisFloor  = DataOfBot.GetMapObjects(ServiceOrgsOnThisFloor);

            foreach (var mapObj in MapObjectsOnThisFloor.Where(x => x.FloorID == FloorID))
            {
                var cat = ServiceOrgsOnThisFloor.FirstOrDefault(x => x.OrganizationMapObject.Select(y => y.MapObject).Contains(mapObj))?.
                          CategoryOrganization?.FirstOrDefault(x => x.Category?.ServiceCategoryType == ServiceCategoryType.Service || x.Category?.ServiceCategoryType == ServiceCategoryType.Link)?.Category;

                if (cat != null && cat?.CategoryID != null && cat?.LogoExtension != null)
                {
                    Image img = Image.FromFile(ConfigurationManager.AppSettings["ContentPath"] + $"Categories\\{cat.CategoryID}.{cat.LogoExtension}");
                    using (Bitmap newBitmap = new Bitmap(img))
                    {
                        newBitmap.SetResolution(96, 96);
                        img.Dispose();
                        img = ImagingHelper.ResizeImage(newBitmap, 90, 90);
                        DrawLocation(mapObj.LongitudeFixed, mapObj.LatitudeFixed, "default", img);
                    }
                    img.Dispose();
                }
            }
        }
Exemple #2
0
        static void Draw()
        {
            string
                      path    = @"C:\MOLOKO.Backup\Floors\23.png"; //ConfigurationManager.AppSettings["ContentPath"] + $"Floors\\{f.FloorID}.{f.FileExtension}";
            int       floorID = 23;
            var       bitmap  = new BitmapSettings(new Bitmap(Image.FromFile(path)), floorID);
            var       img     = Image.FromFile(@"C:\Git\Mall.Bot\Mall.Bot.Tests\Mall.Bot.Test\Resources\Shop.png");
            MapObject mObj    = new MapObject();
            Floor     floor   = new Floor();

            mObj.Longitude = 60.505823849213;
            mObj.Latitude  = 56.82443852894;

            //mObj.Longitude = (56.820858302078406 - 56.82621855007867)/2  + 56.820858302078406;
            //mObj.Latitude = (60.498856113983154 - 60.51062564714051) / 2 + 60.51062564714051;

            //56.823765, 60.505341
            //floor.ImportMetadata = "60.498856113983154;56.820858302078406;60.51062564714051;56.82621855007867";
            floor.ImportMetadata = "60.498856113983154;56.82621855007867;60.51062564714051;56.820858302078406";
            floor.Width          = 4352;
            floor.Height         = 3584;

            mObj.FixCoords(floor);

            img = ImagingHelper.ResizeImage(img, 110, 110);
            System.IO.File.WriteAllBytes(@"C:\Temp\vk_m.png", ImagingHelper.ImageToByteArray(img));

            bitmap.DrawLocation(mObj.LongitudeFixed, mObj.LatitudeFixed, "default", img);

            System.IO.File.WriteAllBytes(@"C:\Temp\vk.png", ImagingHelper.ImageToByteArray(bitmap.Bmp));
        }
Exemple #3
0
        public void DrawLocation(double x, double y, string p, Image img = null)
        {
            x /= ZoomOfPicture; y /= ZoomOfPicture;
            using (var gr = Graphics.FromImage(Bmp))
            {
                gr.SmoothingMode      = SmoothingMode.HighQuality;
                gr.CompositingQuality = CompositingQuality.HighQuality;
                gr.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                gr.PixelOffsetMode    = PixelOffsetMode.HighQuality;

                switch (p)
                {
                case "A":
                    img = Properties.Resources.A;
                    img = ImagingHelper.ResizeImage(img, (int)(img.Width / s), (int)(img.Height / s));
                    gr.DrawImage(
                        img,
                        (float)x + I - img.Width / 2,
                        (float)y + J - img.Height);
                    break;

                case "B":
                    img = Properties.Resources.B;
                    img = ImagingHelper.ResizeImage(img, (int)(img.Width / s), (int)(img.Height / s));
                    gr.DrawImage(
                        img,
                        (float)x + I - img.Width / 2,
                        (float)y + J - img.Height);
                    break;

                case "MultyDraw":
                    img = ImagingHelper.ResizeImage(img, (int)(img.Width / s), (int)(img.Height / s));
                    gr.DrawImage(
                        img,
                        (float)x + I - img.Width / 2,
                        (float)y + J - img.Height);
                    break;

                default:
                    img = ImagingHelper.ResizeImage(img, (int)(img.Width / s), (int)(img.Height / s));
                    gr.DrawImage(
                        img,
                        (float)x + I - img.Width / 2,
                        (float)y + J - img.Height / 2);
                    break;
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Отображает огранизации с подписью их названий и с черной точков
        /// </summary>
        /// <param name="mapObjects"></param>
        public void DrawSpecialOrgs(List <MapObject> mapObjects, List <Organization> parrentOrganizations)
        {
            using (var gr = Graphics.FromImage(Bmp))
            {
                foreach (var mObj in mapObjects)
                {
                    if (mObj?.Params != "Перейдите на следующий этаж") // для текстового описания. так обозначается переход между этажами
                    {
                        string OrgName = parrentOrganizations.FirstOrDefault(x => x.OrganizationMapObject.Select(y => y?.MapObject).Contains(mObj))?.Name;
                        Image  img     = Properties.Resources.ShopLocation;
                        img = ImagingHelper.ResizeImage(img, (int)(img.Width * 2 / 2.5F), (int)(img.Height * 2 / 2.5F));
                        DrawLocation(mObj.LongitudeFixed, mObj.LatitudeFixed, "default", img);

                        DrawText(OrgName,
                                 mObj.LongitudeFixed / ZoomOfPicture + I,
                                 mObj.LatitudeFixed / ZoomOfPicture + J,

                                 OrganizationKegel, Color.Black);
                        img.Dispose();
                    }
                }
            }
        }
Exemple #5
0
        public BitmapSettings(Bitmap bmp, int _floorID = 0)
        {
            double koeff = (double)bmp.Width / bmp.Height;
            double temp  = 1150 / koeff;
            Image  img   = ImagingHelper.ResizeImage(bmp, 1150, (int)temp);


            //избавляемя от прозрачных областей (типа convert to jpg)
            var b = new Bitmap(img.Width, img.Height);

            b.SetResolution(img.HorizontalResolution, img.VerticalResolution);
            using (var g = Graphics.FromImage(b))
            {
                g.Clear(Color.White);
                g.DrawImageUnscaled(img, 0, 0);
            }
            Bmp           = b;
            I             = b.Width / 2;
            J             = b.Height / 2;
            ZoomOfPicture = (float)bmp.Width / b.Width;

            MyPen   = new Pen(Color.Red, 2.5F);
            FloorID = _floorID;
        }
Exemple #6
0
        /// <summary>
        /// Рисует все найденные организации на карте этажа
        /// Возвращает структуру с добавленными в нее картинками
        /// </summary>
        /// <returns></returns>
        public FindedInformation DrawFindedShops()
        {
            var groupedOrgs = (List <GroupedOrganization>)answer.GroopedResult; // получает группы огранизаций

            groupedOrgs.OrderByDescending(x => x.AverageRating).ToList();

            foreach (Floor f in dataOfBot.Floors)
            {
                var groupsFromFloor = groupedOrgs.Where(x => x.FloorID == f.FloorID).ToList();
                if (groupsFromFloor.Count != 0)
                {
                    //var bitmap = new BitmapSettings(new Bitmap(Image.FromStream(new MemoryStream(f.File))), f.FloorID);
                    var bitmap = new BitmapSettings(new Bitmap(Image.FromFile(ConfigurationManager.AppSettings["ContentPath"] + $"Floors\\{f.FloorID}.{f.FileExtension}")), f.FloorID);



                    foreach (var group in groupsFromFloor)
                    {
                        foreach (var org in group.Orgs)
                        {
                            Image img;
                            var   mObjofThisOrg = group.MapObjects.Where(x => org.OrganizationMapObject.Select(y => y.MapObjectID).Contains(x.MapObjectID));
                            if (group.MapObjects.Count == 1)
                            {
                                img = Properties.Resources.Shop;
                            }
                            else
                            {
                                img = Properties.Resources.ShopG; // для групп рисуем оранжевую точку
                            }
                            foreach (var mObj in mObjofThisOrg)
                            {
                                var temp = org.CategoryOrganization.Select(x => x.Category).Select(x => x.ServiceCategoryType);
                                if (temp.Contains(ServiceCategoryType.Service) || temp.Contains(ServiceCategoryType.Link))
                                {
                                    img = ImagingHelper.ResizeImage(img, 110, 110);
                                    bitmap.DrawLocation(mObj.LongitudeFixed, mObj.LatitudeFixed, "default", img);
                                    bitmap.DrawLandMarksExtra(dataOfBot, f.Number);
                                }
                                else
                                {
                                    img = ImagingHelper.ResizeImage(img, (int)(img.Width * 4 / 2.5F), (int)(img.Height * 4 / 2.5F));
                                    bitmap.DrawLocation(mObj.LongitudeFixed, mObj.LatitudeFixed, "default", img);
                                }
                            }
                        }
                    }

                    bitmap.DrawLandMarksExtra(dataOfBot, f.FloorID);
                    bitmap.DrawLandMarksOrganizations(dataOfBot, f.FloorID);
                    bitmap.DrawSignPoint(dataOfBot, f.FloorID, dataOfBot.Customers[0].Name);

                    // расставляем балуны для каждой группы
                    char index = 'A';
                    for (int i = 0; i < 5 && i < groupsFromFloor.Count; i++)
                    {
                        var   obj = Properties.Resources.ResourceManager.GetObject(index.ToString());
                        Image img = (Bitmap)obj;
                        bitmap.DrawLocation(BotMapHelper.CenterOfDiagonal(groupsFromFloor[i].MapObjects), "MultyDraw", img);
                        index++;
                    }
                    // подпись картинки
                    var tmp = title.Replace("%floornumber%", f.Number.ToString());
                    bitmap.DrawText(tmp, BotTextHelper.LengthOfString(tmp, bitmap), 5F, 23, Color.DarkSlateGray, true);
                    answer.FloorsPictures.Add(bitmap);
                }
            }
            return(answer);
        }