private void Chart1_PostPaint(object sender, ChartPaintEventArgs e)
        {
            // Painting series object
            if(e.ChartElement is Series)
            {
                // Add custom painting only to the series with name "Series2"
                Series series = (Series)e.ChartElement;
                if(series.Name == "Series2" && series.Tag == null)
                {
                    // Find data point with maximum Y value
                    DataPoint	dataPoint = series.Points.FindMaxByValue();

                    // Load bitmap from file
                    System.Drawing.Image bitmap = Bitmap.FromFile(this.Page.MapPath("money.png"));

                    // Set White color as transparent
                    ImageAttributes attrib = new ImageAttributes();
                    attrib.SetColorKey(Color.White, Color.White, ColorAdjustType.Default);

                    // Calculates marker position depending on the data point X and Y values
                    RectangleF	imagePosition = RectangleF.Empty;
                    imagePosition.X = (float)e.ChartGraphics.GetPositionFromAxis(
                        "Chart Area 1", AxisName.X, dataPoint.XValue);
                    imagePosition.Y = (float)e.ChartGraphics.GetPositionFromAxis(
                        "Chart Area 1", AxisName.Y, dataPoint.YValues[0]);
                    imagePosition = e.ChartGraphics.GetAbsoluteRectangle(imagePosition);
                    imagePosition.Width = bitmap.Width;
                    imagePosition.Height = bitmap.Height;
                    imagePosition.Y -= bitmap.Height;
                    imagePosition.X -= bitmap.Width /2;

                    // Draw image
                    e.ChartGraphics.Graphics.DrawImage(bitmap,
                        Rectangle.Round(imagePosition),
                        0, 0, bitmap.Width, bitmap.Height,
                        GraphicsUnit.Pixel,
                        attrib);

                    // Add a custom map area in the coordinates of the image
                    RectangleF	rect = e.ChartGraphics.GetRelativeRectangle(imagePosition);

                    MapArea area = new MapArea("Maximum Y value marker. Y = " + dataPoint.YValues[0], "money.htm", "target=\"_blank\"", String.Empty, rect, null);
                    Chart1.MapAreas.Add(area);
                    // Dispose image object
                    bitmap.Dispose();

                    series.Tag = true;
                }
            }
        }
Beispiel #2
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<MapArea> TableToList(DataTable table){
			List<MapArea> retVal=new List<MapArea>();
			MapArea mapArea;
			for(int i=0;i<table.Rows.Count;i++) {
				mapArea=new MapArea();
				mapArea.MapAreaNum = PIn.Long  (table.Rows[i]["MapAreaNum"].ToString());
				mapArea.Extension  = PIn.Int   (table.Rows[i]["Extension"].ToString());
				mapArea.XPos       = PIn.Double(table.Rows[i]["XPos"].ToString());
				mapArea.YPos       = PIn.Double(table.Rows[i]["YPos"].ToString());
				mapArea.Width      = PIn.Double(table.Rows[i]["Width"].ToString());
				mapArea.Height     = PIn.Double(table.Rows[i]["Height"].ToString());
				mapArea.Description= PIn.String(table.Rows[i]["Description"].ToString());
				mapArea.ItemType   = (OpenDentBusiness.MapItemType)PIn.Int(table.Rows[i]["ItemType"].ToString());
				retVal.Add(mapArea);
			}
			return retVal;
		}
Beispiel #3
0
    public Mesh DeleteMap()
    {
        if (mapHandler != null) {
            IMapHandler handler = mapHandler.GetComponent<IMapHandler>();

            if (handler != null) {
                handler.OnMapDelete(mapArea);
            } else {
                Debug.LogWarning("map handler lacks IMapHandler script");
            }
        }

        mapArea = null;
        MeshFilter filter = GetComponent<MeshFilter>();
        Mesh mesh = filter.sharedMesh;
        filter.mesh = null;
        return mesh;
    }
        private void update_view()
        {
            Map map = Session.Project.FindTacticalMap(this.fMapElement.MapID);

            if (map == null)
            {
                this.MapView.Map       = null;
                this.MapView.Viewpoint = Rectangle.Empty;
                return;
            }
            this.MapView.Map = map;
            MapArea mapArea = map.FindArea(this.fMapElement.MapAreaID);

            if (mapArea == null)
            {
                this.MapView.Viewpoint = Rectangle.Empty;
                return;
            }
            this.MapView.Viewpoint = mapArea.Region;
        }
Beispiel #5
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <MapArea> TableToList(DataTable table)
        {
            List <MapArea> retVal = new List <MapArea>();
            MapArea        mapArea;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                mapArea             = new MapArea();
                mapArea.MapAreaNum  = PIn.Long(table.Rows[i]["MapAreaNum"].ToString());
                mapArea.Extension   = PIn.Int(table.Rows[i]["Extension"].ToString());
                mapArea.XPos        = PIn.Double(table.Rows[i]["XPos"].ToString());
                mapArea.YPos        = PIn.Double(table.Rows[i]["YPos"].ToString());
                mapArea.Width       = PIn.Double(table.Rows[i]["Width"].ToString());
                mapArea.Height      = PIn.Double(table.Rows[i]["Height"].ToString());
                mapArea.Description = PIn.String(table.Rows[i]["Description"].ToString());
                mapArea.ItemType    = (MapItemType)PIn.Int(table.Rows[i]["ItemType"].ToString());
                retVal.Add(mapArea);
            }
            return(retVal);
        }
Beispiel #6
0
        public void TestMapAreaRemove()
        {
            var mapArea = new MapArea();

            mapArea.Add(GoRogue.Utility.Yield <Coord>((1, 1), (2, 2), (3, 2)));

            Assert.AreEqual(3, mapArea.Count);
            Assert.AreEqual(1, mapArea.Bounds.X);
            Assert.AreEqual(1, mapArea.Bounds.Y);
            Assert.AreEqual(3, mapArea.Bounds.MaxExtentX);
            Assert.AreEqual(2, mapArea.Bounds.MaxExtentY);

            mapArea.Remove((3, 2));

            Assert.AreEqual(2, mapArea.Count);
            Assert.AreEqual(1, mapArea.Bounds.X);
            Assert.AreEqual(1, mapArea.Bounds.Y);
            Assert.AreEqual(2, mapArea.Bounds.MaxExtentX);
            Assert.AreEqual(2, mapArea.Bounds.MaxExtentY);
        }
Beispiel #7
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <MapArea> TableToList(DataTable table)
        {
            List <MapArea> retVal = new List <MapArea>();
            MapArea        mapArea;

            foreach (DataRow row in table.Rows)
            {
                mapArea                     = new MapArea();
                mapArea.MapAreaNum          = PIn.Long(row["MapAreaNum"].ToString());
                mapArea.Extension           = PIn.Int(row["Extension"].ToString());
                mapArea.XPos                = PIn.Double(row["XPos"].ToString());
                mapArea.YPos                = PIn.Double(row["YPos"].ToString());
                mapArea.Width               = PIn.Double(row["Width"].ToString());
                mapArea.Height              = PIn.Double(row["Height"].ToString());
                mapArea.Description         = PIn.String(row["Description"].ToString());
                mapArea.ItemType            = (OpenDentBusiness.MapItemType)PIn.Int(row["ItemType"].ToString());
                mapArea.MapAreaContainerNum = PIn.Long(row["MapAreaContainerNum"].ToString());
                retVal.Add(mapArea);
            }
            return(retVal);
        }
Beispiel #8
0
        private static void add_map_area(List <Pair <Tile, TileData> > tiles)
        {
            int left   = 2147483647;
            int top    = 2147483647;
            int right  = -2147483648;
            int bottom = -2147483648;

            foreach (Pair <Tile, TileData> tile in tiles)
            {
                Rectangle _rect = MapBuilder.get_rect(tile.First, tile.Second);
                if (_rect.Left < left)
                {
                    left = _rect.Left;
                }
                if (_rect.Right > right)
                {
                    right = _rect.Right;
                }
                if (_rect.Top < top)
                {
                    top = _rect.Top;
                }
                if (_rect.Bottom <= bottom)
                {
                    continue;
                }
                bottom = _rect.Bottom;
            }
            left--;
            top--;
            right++;
            bottom++;
            MapArea mapArea = new MapArea()
            {
                Name   = string.Concat("Area ", MapBuilder.fMap.Areas.Count + 1),
                Region = new Rectangle(left, top, right - left, bottom - top)
            };

            MapBuilder.fMap.Areas.Add(mapArea);
        }
Beispiel #9
0
    /// <summary>
    ///
    /// </summary>
    public void LoadData()
    {
        gridIndex = 0;

        corridorWidth = Config.CorridorWidth;

        random = Const.Random;

        RoomDatas = new List <RoomData>();

        CorridorDatas = new List <RoomData>();

        DoorDatas = new List <RoomData>();

        gridOccupy = new bool[Config.MapAreaWidth, Config.MapAreaHeight];

        root = new MapArea(Coordinate.Zero, Config.MapAreaWidth, Config.MapAreaHeight);

        CreateMapAreaGroup(root, Config.MapAreaDepth);

        CreateCorridors(root);
    }
Beispiel #10
0
 ///<summary>Takes all required fields as input. Suggest using this version when adding a cubicle to a ClinicMapPanel.</summary>
 public MapAreaRoomControl(MapArea cubicle, string elapsed, string employeeName, long employeeNum, string extension, string status, Font font, Font fontHeader, Color innerColor, Color outerColor, Color backColor, Point location, Size size, Image phoneImage, bool allowDragging, bool allowEdit)
     : this()
 {
     cubicle.ItemType = MapItemType.Room;
     MapAreaItem      = cubicle;
     Elapsed          = elapsed;
     EmployeeName     = employeeName;
     EmployeeNum      = employeeNum;
     Extension        = extension;
     Status           = status;
     Font             = font;
     FontHeader       = fontHeader;
     Location         = location;
     Size             = size;
     InnerColor       = innerColor;
     OuterColor       = outerColor;
     BackColor        = backColor;
     PhoneImage       = phoneImage;
     AllowDragging    = allowDragging;
     AllowEdit        = allowEdit;
     Name             = MapAreaItem.MapAreaNum.ToString();
 }
Beispiel #11
0
        public MapAreaSelectForm(Guid map_id, Guid map_area_id)
        {
            InitializeComponent();

            Application.Idle += new EventHandler(Application_Idle);

            UseTileBtn.Visible = map_tiles_exist();

            MapBox.Items.Add("(no map)");
            foreach (Map m in Session.Project.Maps)
            {
                MapBox.Items.Add(m);
            }

            Map map = Session.Project.FindTacticalMap(map_id);

            if (map != null)
            {
                MapBox.SelectedItem = map;

                MapArea ma = map.FindArea(map_area_id);
                if (ma != null)
                {
                    AreaBox.SelectedItem = ma;
                }
                else
                {
                    AreaBox.SelectedIndex = 0;
                }
            }
            else
            {
                MapBox.SelectedIndex = 0;

                AreaBox.Items.Add("(no map)");
                AreaBox.SelectedIndex = 0;
            }
        }
Beispiel #12
0
        public async Task GetTrafficIncidents_IncidentTypesSeverityMapArea_ValidTrafficIncidents()
        {
            IRestRequest request     = null;
            var          serviceMock = new Mock <BingTraffic>();

            serviceMock.Setup(zc => zc.ExecuteAsync <Response>(It.IsAny <IRestRequest>()))
            .Callback <IRestRequest>(r => request = r)
            .CallBase();
            var service    = serviceMock.Object;
            var mapArea    = new MapArea(37, -105, 45, -94);
            var parameters = new TrafficIncidentsParameters(mapArea);

            parameters.IncludeLocationCodes = true;
            parameters.Severity             = new[] { Severity.Minor, Severity.Moderate };
            parameters.TrafficIncidentTypes = new[] { TrafficIncidentType.Construction };

            var response = await service.GetTrafficIncidents(parameters);

            serviceMock.Verify(zc => zc.ExecuteAsync <Response>(It.IsAny <IRestRequest>()), Times.Once);
            Assert.That(response, Is.Not.Null);
            Assert.That(response.ResourceSets.Length, Is.GreaterThan(0));
            Assert.That(response.ResourceSets.First().Resources.OfType <TrafficIncident>().Count(), Is.GreaterThan(0));
            Assert.That(request, Is.Not.Null);
            Assert.That(request.Method, Is.EqualTo(Method.GET));
            Assert.That(request.Resource, Is.EqualTo("Traffic/Incidents/{MapArea}/"));
            Assert.That(request.Parameters.Find(x => x.Name == "version"), Is.Not.Null);
            Assert.That(request.Parameters.Find(x => x.Name == "key"), Is.Not.Null);
            Assert.That(request.Parameters.Find(x => x.Name == "o"), Is.Not.Null);
            Assert.That(request.Parameters.Find(x => x.Name == "c"), Is.Not.Null);
            Assert.That(request.Parameters.Find(x => x.Name == "MapArea"), Is.Not.Null);
            Assert.That(request.Parameters.Find(x => x.Name == "MapArea").Value, Is.EqualTo(mapArea.ToString()));
            Assert.That(request.Parameters.Find(x => x.Name == "includeLocationCodes"), Is.Not.Null);
            Assert.That(request.Parameters.Find(x => x.Name == "includeLocationCodes").Value, Is.EqualTo(parameters.IncludeLocationCodes.ToString()));
            Assert.That(request.Parameters.Find(x => x.Name == "s"), Is.Not.Null);
            Assert.That(request.Parameters.Find(x => x.Name == "s").Value, Is.EqualTo(parameters.Severity.ToCSVString()));
            Assert.That(request.Parameters.Find(x => x.Name == "t"), Is.Not.Null);
            Assert.That(request.Parameters.Find(x => x.Name == "t").Value, Is.EqualTo(parameters.TrafficIncidentTypes.ToCSVString()));
        }
Beispiel #13
0
    /// <summary>
    /// 创建房间数据
    /// </summary>
    /// <param name="area"></param>
    private void CreateRoomData(MapArea area)
    {
        if (area == null)
        {
            return;
        }

        var maxW = area.Wdith - 2;

        var maxH = area.Height - 2;

        var minW = maxW / 2;

        var minH = maxH / 2;

        var roomData = new RoomData()
        {
            RoomType = RoomType.Room,

            Id = RoomDatas.Count,

            Width = Const.Random.Next(minW, maxW),

            Height = Const.Random.Next(minH, maxH),
        };

        var xMax = area.Wdith - roomData.Width;

        var yMax = area.Height - roomData.Height;

        roomData.Coordinate = new Coordinate(Const.Random.Next(0, xMax), Const.Random.Next(0, yMax)) + area.Coordinate;

        roomData.Build();

        RoomDatas.Add(roomData);

        area.RoomData = roomData;
    }
Beispiel #14
0
        void show_map()
        {
            Map m = MapBox.SelectedItem as Map;

            if (m != null)
            {
                MapView.Map = m;

                MapArea ma = AreaBox.SelectedItem as MapArea;
                if (ma != null)
                {
                    MapView.Viewpoint = ma.Region;
                }
                else
                {
                    MapView.Viewpoint = Rectangle.Empty;
                }
            }
            else
            {
                MapView.Map = null;
            }
        }
Beispiel #15
0
        public override void Import(DCFG cfg)
        {
            MapArea data = cfg as MapArea;

            this.ID         = data.ID;
            this.Name       = data.Name;
            this.Pos        = data.Pos;
            this.Scale      = data.Scale;
            this.Shape      = (EAreaShape)data.Shape;
            this.AllowRide  = data.AllowRide;
            this.AllowPK    = data.AllowPK;
            this.AllowTrade = data.AllowTrade;
            FTGroupEvent group = Map.GetGroup <FTGroupEvent>();

            for (int i = 0; i < data.Events.Count; i++)
            {
                FTEvent e = group.GetElement(data.Events[i]);
                if (e != null)
                {
                    Events.Add(e);
                }
            }
        }
Beispiel #16
0
    public void Despawner(ResourceType t, DropItemInfo dropItem)
    {
        if (null == dropItem)
        {
            return;
        }

        if (dropItem.InfoId == (int)ItemType.ITEM_RAREENERGY)
        {
            if (TSCData.Instance.RareEnergyDic.ContainsKey(dropItem.ItemId))
            {
                TSCData.Instance.RareEnergyDic.Remove(dropItem.ItemId);
            }
        }
        else
        {
            ItemDespawnerInfo despawnItem = new ItemDespawnerInfo(dropItem.ItemId, dropItem.InfoId);
            MapArea           area        = dropItem.Area;

            if (TSCData.Instance.BackItemMapDic.ContainsKey(area))
            {
                TSCData.Instance.BackItemMapDic[area].Add(despawnItem);
            }
            else
            {
                List <ItemDespawnerInfo> itemIds = new List <ItemDespawnerInfo>();
                itemIds.Add(despawnItem);
                TSCData.Instance.BackItemMapDic[area] = itemIds;
            }

            if (TSCData.Instance.DropItemDic.ContainsKey(dropItem.ItemId))
            {
                TSCData.Instance.DropItemDic.Remove(dropItem.ItemId);
            }
        }
        Despawner(t, dropItem.Cache);
    }
Beispiel #17
0
        ///<summary>Inserts one MapArea into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(MapArea mapArea, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO maparea (";

            if (!useExistingPK && isRandomKeys)
            {
                mapArea.MapAreaNum = ReplicationServers.GetKeyNoCache("maparea", "MapAreaNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "MapAreaNum,";
            }
            command += "Extension,XPos,YPos,Width,Height,Description,ItemType,MapAreaContainerNum) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(mapArea.MapAreaNum) + ",";
            }
            command +=
                POut.Int(mapArea.Extension) + ","
                + "'" + POut.Double(mapArea.XPos) + "',"
                + "'" + POut.Double(mapArea.YPos) + "',"
                + "'" + POut.Double(mapArea.Width) + "',"
                + "'" + POut.Double(mapArea.Height) + "',"
                + "'" + POut.String(mapArea.Description) + "',"
                + POut.Int((int)mapArea.ItemType) + ","
                + POut.Long(mapArea.MapAreaContainerNum) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                mapArea.MapAreaNum = Db.NonQ(command, true, "MapAreaNum", "mapArea");
            }
            return(mapArea.MapAreaNum);
        }
Beispiel #18
0
        void update_map_area()
        {
            Rectangle view = Rectangle.Empty;

            Map.BoxedTokens.Clear();

            if ((SelectedCombatant != null) && (SelectedCombatant.Location != CombatData.NoPoint))
            {
                EncounterSlot slot = fEncounter.FindSlot(SelectedCombatant);
                Map.BoxedTokens.Add(new CreatureToken(slot.ID, SelectedCombatant));
                Map.MapChanged();

                ICreature creature = Session.FindCreature(slot.Card.CreatureID, SearchType.Global);
                int       size     = Creature.GetSize(creature.Size);

                int dx = 7;
                int dy = 4;

                int left   = SelectedCombatant.Location.X - dx;
                int top    = SelectedCombatant.Location.Y - dy;
                int width  = dx + size + dx;
                int height = dy + size + dy;

                view = new Rectangle(left, top, width, height);
            }
            else if (fEncounter.MapAreaID != Guid.Empty)
            {
                MapArea ma = Map.Map.FindArea(fEncounter.MapAreaID);
                if (ma != null)
                {
                    view = ma.Region;
                }
            }

            Map.Viewpoint = view;
        }
        private static MapAreas DeserializeMapAreas(BinaryReader Reader)
        {
            int      areasLength = DeserializeLength(Reader);
            MapAreas areas       = new MapAreas();
            Dictionary <Guid, MapArea> areasDict = new Dictionary <Guid, MapArea>();

            for (int i = 0; i < areasLength; i++)
            {
                MapArea area = DeserializeMapObject(Reader) as MapArea;
                areas.Areas.Add(area);
                areasDict[area.Id] = area;
            }

            int transitionPointsLength = DeserializeLength(Reader);

            for (int i = 0; i < transitionPointsLength; i++)
            {
                MapAreaTransitionPoint transitionPoint =
                    DeserializeMapObject(Reader, null, areasDict) as MapAreaTransitionPoint;
                transitionPoint.From.TransitionPoints.Add(transitionPoint);
            }

            return(areas);
        }
Beispiel #20
0
 ///<summary>Returns true if Update(MapArea,MapArea) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(MapArea mapArea, MapArea oldMapArea)
 {
     if (mapArea.Extension != oldMapArea.Extension)
     {
         return(true);
     }
     if (mapArea.XPos != oldMapArea.XPos)
     {
         return(true);
     }
     if (mapArea.YPos != oldMapArea.YPos)
     {
         return(true);
     }
     if (mapArea.Width != oldMapArea.Width)
     {
         return(true);
     }
     if (mapArea.Height != oldMapArea.Height)
     {
         return(true);
     }
     if (mapArea.Description != oldMapArea.Description)
     {
         return(true);
     }
     if (mapArea.ItemType != oldMapArea.ItemType)
     {
         return(true);
     }
     if (mapArea.MapAreaContainerNum != oldMapArea.MapAreaContainerNum)
     {
         return(true);
     }
     return(false);
 }
Beispiel #21
0
        ///<summary>Add a cubicle to the panel.</summary>
        public void AddCubicle(MapArea cubicle)
        {
            MapAreaRoomControl phone = new MapAreaRoomControl(
                cubicle,
                TimeSpan.FromSeconds(Rand.Next(60, 1200)).ToString(),
                "Emp: " + this.Controls.Count.ToString(),
                this.Controls.Count,
                cubicle.Extension.ToString(),
                "Status",
                this.FontCubicle,
                this.FontCubicleHeader,
                Color.FromArgb(40, Color.Red),
                Color.Red,
                this.FloorColor,
                GetScreenLocation(cubicle.XPos, cubicle.YPos, this.PixelsPerFoot),
                GetScreenSize(cubicle.Width, cubicle.Height, this.PixelsPerFoot),
                Properties.Resources.phoneInUse,
                this.AllowDragging,
                this.AllowEditing);

            phone.DragDone           += mapAreaControl_DragDone;
            phone.MapAreaRoomChanged += mapAreaControl_Changed;
            this.Controls.Add(phone);
        }
Beispiel #22
0
		///<summary>Inserts one MapArea into the database.  Returns the new priKey.</summary>
		public static long Insert(MapArea mapArea){
			if(DataConnection.DBtype==DatabaseType.Oracle) {
				mapArea.MapAreaNum=DbHelper.GetNextOracleKey("maparea","MapAreaNum");
				int loopcount=0;
				while(loopcount<100){
					try {
						return Insert(mapArea,true);
					}
					catch(Oracle.DataAccess.Client.OracleException ex){
						if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
							mapArea.MapAreaNum++;
							loopcount++;
						}
						else{
							throw ex;
						}
					}
				}
				throw new ApplicationException("Insert failed.  Could not generate primary key.");
			}
			else {
				return Insert(mapArea,false);
			}
		}
Beispiel #23
0
        void update_view()
        {
            Map map = Session.Project.FindTacticalMap(fMapElement.MapID);

            if (map != null)
            {
                MapView.Map = map;

                MapArea area = map.FindArea(fMapElement.MapAreaID);
                if (area != null)
                {
                    MapView.Viewpoint = area.Region;
                }
                else
                {
                    MapView.Viewpoint = Rectangle.Empty;
                }
            }
            else
            {
                MapView.Map       = null;
                MapView.Viewpoint = Rectangle.Empty;
            }
        }
Beispiel #24
0
 public override void OnUpdateMap(MapArea viewarea)
 {
     for (int i = 0; i < busNum; i++)
     {
         tempLocations[i].Offset(deltaLats[i], deltaLngs[i]);
         currCounts[i]++;
         if (currCounts[i] >= totalCounts[i])
         {
             currPt[i]++;
             if (currPt[i] >= routes[i].Count - 1)
             {
                 routes[i].Reverse();
                 currPt[i] = 0;
             }
             starts[i]        = routes[i][currPt[i]];
             ends[i]          = routes[i][currPt[i] + 1];
             tempLocations[i] = starts[i];
             totalCounts[i]   = (int)(TimeSpan.FromMilliseconds(rand.Next(2000, 6000)).TotalMilliseconds / deltaTime.TotalMilliseconds);
             deltaLats[i]     = (ends[i].Lat - starts[i].Lat) / totalCounts[i];
             deltaLngs[i]     = (ends[i].Lng - starts[i].Lng) / totalCounts[i];
             currCounts[i]    = 0;
         }
     }
 }
        // populates the home tab
        private void PopulateHomeTab(JObject result)
        {
            //set the logo
            Logo.Source        = Utils.GetRestaurantField(result, "LogoUrl");
            Logo.WidthRequest  = Application.Current.MainPage.Height / 8;
            Logo.HeightRequest = Application.Current.MainPage.Height / 8;

            NameLabel.Text     = Utils.GetRestaurantField(result, "Name");
            CuisinesLabel.Text = Utils.GetRestaurantField(result, "CuisineTypes");

            //set the price range of that restuarant
            int price = 0;

            if (result["PricePoint"].Type != JTokenType.Null)
            {
                price = Int32.Parse(result["PricePoint"].ToString(), CultureInfo.CurrentCulture);
            }
            PriceLabel.Text = Utils.GetRestaurantField(result, "PricePoint", "£", price);

            HomeStars.Value       = Convert.ToDouble(Utils.GetRestaurantField(result, "AverageReviewScore"));
            DescriptionLabel.Text = Utils.GetRestaurantField(consumer, "ShortDescription");

            //set functionality of clicking the ViewMore button on the HomePage
            var viewMoreTap = new TapGestureRecognizer();

            viewMoreTap.Tapped += async(s, e) =>
            {
                await Navigation.PushPopupAsync(new AboutPopup(Utils.GetRestaurantField(consumer, "Description")));
            };
            ViewMoreLabel.GestureRecognizers.Clear();
            ViewMoreLabel.GestureRecognizers.Add(viewMoreTap);

            OpeningInformationLabel.Text = Utils.GetRestaurantField(consumer, "OpeningInformation").Replace("<br/>", Environment.NewLine);

            //Set the Social Media of each restaurant
            if (consumer["SocialNetworks"].Type == JTokenType.Null || string.IsNullOrEmpty(consumer["SocialNetworks"].ToString()))
            {
                SocialMediaLabel.IsVisible = true;
                SocialMediaLabel.Text      = "No social media";
            }
            else if (consumer["SocialNetworks"] is JArray)
            {
                JToken[] arr    = consumer["SocialNetworks"].ToArray();
                int      column = 0;

                foreach (var a in arr)
                {
                    //create a button for each social media platform - to link to it
                    Button button = new Button
                    {
                        Text              = a["Type"].ToString(),
                        Margin            = new Thickness(15, 10, 0, 0),
                        TextColor         = Color.FromHex("#11a0dc"),
                        FontSize          = 12,
                        CornerRadius      = 18,
                        BorderWidth       = 2,
                        BorderColor       = Color.FromHex("#11a0dc"),
                        VerticalOptions   = LayoutOptions.Start,
                        HorizontalOptions = LayoutOptions.Start
                    };
                    button.SetDynamicResource(Button.BackgroundColorProperty, "BarBackgroundColor");
                    HomeGrid.Children.Add(button, column, 15);
                    column++;

                    button.Clicked += async(sender, args) => await Browser.OpenAsync(a["Url"].ToString(), BrowserLaunchMode.SystemPreferred);
                }
            }

            //set up the maps for the application
            double latitude  = Convert.ToDouble(result["Latitude"].ToString(), CultureInfo.CurrentCulture);
            double longitude = Convert.ToDouble(result["Longitude"].ToString(), CultureInfo.CurrentCulture);
            string name      = result["Name"].ToString();

            //add a pin for the current restaurant
            var pin = new Pin()
            {
                Position = new Position(latitude, longitude),
                Label    = name,
            };

            MapArea.Pins.Add(pin);
            MapArea.MoveToRegion(new MapSpan(new Position(latitude, longitude), 0.01, 0.01));

            // open up directions to restaurant in map app when map area is clicked
            MapArea.MapClicked += async(object sender, MapClickedEventArgs e) =>
            {
                await Xamarin.Essentials.Map.OpenAsync(
                    new Location(latitude, longitude),
                    new MapLaunchOptions { Name = name, NavigationMode = NavigationMode.Default }
                    );
            };
        }
 /// <summary>
 /// Selects and returns a random point from each MapArea's positions list.
 /// </summary>
 /// <param name="area1">First MapArea to connect.</param>
 /// <param name="area2">Second MapArea to connect</param>
 /// <returns>A tuple containing the selected Coords.</returns>
 public Tuple <Coord, Coord> SelectConnectionPoints(MapArea area1, MapArea area2) =>
 new Tuple <Coord, Coord>(area1.Positions.RandomItem(rng), area2.Positions.RandomItem(rng));
Beispiel #27
0
 public SpawnEvent(Race race, int number, GameTime occursAt, MapArea location)
     : base(occursAt, location)
 {
     Race   = race;
     Number = number;
 }
Beispiel #28
0
        /// <summary>
        /// Gets a URL for requesting imagery data for a POST request.
        /// </summary>
        /// <returns>Imagery request URL for POST request.</returns>
        public string GetPostRequestUrl()
        {
            var isQuery = !string.IsNullOrWhiteSpace(Query);
            var isRoute = (Waypoints != null && Waypoints.Count >= 2);

            var sb = new StringBuilder(this.Domain);

            sb.Append("Imagery/Map/");

            sb.Append(Enum.GetName(typeof(ImageryType), ImagerySet));

            if (CenterPoint != null)
            {
                sb.AppendFormat(CultureInfo.InvariantCulture, "/{0:0.#####},{1:0.#####}/", CenterPoint.Latitude, CenterPoint.Longitude);

                if (zoomLevel != 0)
                {
                    sb.Append(zoomLevel);
                }
                else if (HighlightEntity)
                {
                    sb.Append(Enum.GetName(typeof(EntityType), EntityType));
                }
                else if (ImagerySet == ImageryType.Road || ImagerySet == ImageryType.Aerial || ImagerySet == ImageryType.AerialWithLabels ||
                         ImagerySet == ImageryType.RoadOnDemand || ImagerySet == ImageryType.AerialWithLabelsOnDemand || ImagerySet == ImageryType.CanvasDark ||
                         ImagerySet == ImageryType.CanvasGray || ImagerySet == ImageryType.CanvasLight)
                {
                    throw new Exception("Zoom Level must be specified when a centerPoint is specified and ImagerySet is Road, Aerial, AerialWithLabels, or any variation of these (Canvas/OnDemand).");
                }
            }
            else if (isQuery)
            {
                sb.AppendFormat("/{0}", Uri.EscapeDataString(Query));
            }

            if (isRoute)
            {
                sb.AppendFormat("/Routes/{0}?", Enum.GetName(typeof(TravelModeType), (RouteOptions != null) ? RouteOptions.TravelMode : TravelModeType.Driving));
            }
            else
            {
                sb.Append("?");
            }

            sb.AppendFormat("ms={0},{1}", mapWidth, mapHeight);

            if (DeclutterPins)
            {
                sb.Append("&dcl=1");
            }

            if (Format.HasValue)
            {
                sb.AppendFormat("&fmt={0}", Enum.GetName(typeof(ImageFormatType), Format.Value));
            }

            if (MapArea != null && (CenterPoint == null || !isRoute))
            {
                sb.AppendFormat("&ma={0}", MapArea.ToString());
            }

            if (ShowTraffic)
            {
                sb.Append("&ml=TrafficFlow");
            }

            if (GetMetadata)
            {
                sb.Append("&mmd=1");
            }

            if (HighlightEntity)
            {
                sb.Append("&he=1");
            }

            if (Resolution == ImageResolutionType.High)
            {
                sb.Append("&dpi=Large");
            }

            //Routing Parameters

            if (isRoute)
            {
                if (Waypoints.Count > 25)
                {
                    throw new Exception("More than 25 waypoints in route request.");
                }

                for (int i = 0; i < Waypoints.Count; i++)
                {
                    sb.AppendFormat("&wp.{0}=", i);

                    if (Waypoints[i].Coordinate != null)
                    {
                        sb.AppendFormat(CultureInfo.InvariantCulture, "{0:0.#####},{1:0.#####}", Waypoints[i].Coordinate.Latitude, Waypoints[i].Coordinate.Longitude);
                    }
                    else
                    {
                        sb.AppendFormat("{0}", Uri.EscapeDataString(Waypoints[i].Address));
                    }
                }

                if (RouteOptions != null)
                {
                    sb.Append(RouteOptions.GetUrlParam(0));
                }
            }

            sb.Append(GetBaseRequestUrl());

            if (!string.IsNullOrWhiteSpace(Style))
            {
                var s = CustomMapStyleManager.GetRestStyle(Style);

                if (!string.IsNullOrWhiteSpace(s))
                {
                    sb.AppendFormat("&st={0}", s);
                }
            }

            return(sb.ToString());
        }
Beispiel #29
0
        private void filePrintPreviewMenuItem_Click(Object sender,
                EventArgs e)
        {
            StartPage = (MapArea) 1;
            StopPage = (MapArea) 5;
            CurrentPage = StartPage;
            PrintPreviewDialog dlg = new PrintPreviewDialog();

            dlg.Document = printDoc;

            dlg.Width = 1000;
            dlg.Height = 650;
            dlg.ShowDialog();
        }
Beispiel #30
0
		///<summary>Updates one MapArea in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
		public static bool Update(MapArea mapArea,MapArea oldMapArea){
			string command="";
			if(mapArea.Extension != oldMapArea.Extension) {
				if(command!=""){ command+=",";}
				command+="Extension = "+POut.Int(mapArea.Extension)+"";
			}
			if(mapArea.XPos != oldMapArea.XPos) {
				if(command!=""){ command+=",";}
				command+="XPos = '"+POut.Double(mapArea.XPos)+"'";
			}
			if(mapArea.YPos != oldMapArea.YPos) {
				if(command!=""){ command+=",";}
				command+="YPos = '"+POut.Double(mapArea.YPos)+"'";
			}
			if(mapArea.Width != oldMapArea.Width) {
				if(command!=""){ command+=",";}
				command+="Width = '"+POut.Double(mapArea.Width)+"'";
			}
			if(mapArea.Height != oldMapArea.Height) {
				if(command!=""){ command+=",";}
				command+="Height = '"+POut.Double(mapArea.Height)+"'";
			}
			if(mapArea.Description != oldMapArea.Description) {
				if(command!=""){ command+=",";}
				command+="Description = '"+POut.String(mapArea.Description)+"'";
			}
			if(mapArea.ItemType != oldMapArea.ItemType) {
				if(command!=""){ command+=",";}
				command+="ItemType = "+POut.Int   ((int)mapArea.ItemType)+"";
			}
			if(command==""){
				return false;
			}
			command="UPDATE maparea SET "+command
				+" WHERE MapAreaNum = "+POut.Long(mapArea.MapAreaNum);
			Db.NonQ(command);
			return true;
		}
Beispiel #31
0
    //TODO
    //Relay point = zone comme la base qui affect des squads et n'est pas affecter par les ordes générals


    public Map_SS(FixedMap map)
        : base(map)
    {
        left  = new MapArea(new int[] { 0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11 });
        right = new MapArea(new int[] { 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 });
    }
        private void update_view()
        {
            this.SkillList.Items.Clear();
            ListView.ListViewItemCollection items = this.SkillList.Items;
            object[]     name = new object[] { this.fChallenge.Name, ": ", this.fChallenge.GetXP(), " XP" };
            ListViewItem item = items.Add(string.Concat(name));

            item.Group = this.SkillList.Groups[0];
            ListViewItem listViewItem = this.SkillList.Items.Add(this.fChallenge.Info);

            listViewItem.Group = this.SkillList.Groups[0];
            if (this.fChallenge.MapID != Guid.Empty)
            {
                Map map = Session.Project.FindTacticalMap(this.fChallenge.MapID);
                if (map != null)
                {
                    MapArea mapArea = map.FindArea(this.fChallenge.MapAreaID);
                    if (mapArea != null)
                    {
                        string str = string.Concat("Location: ", map.Name);
                        if (mapArea != null)
                        {
                            str = string.Concat(str, " (", mapArea.Name, ")");
                        }
                        ListViewItem item1 = this.SkillList.Items.Add(str);
                        item1.Group = this.SkillList.Groups[0];
                    }
                }
            }
            foreach (SkillChallengeData skill in this.fChallenge.Skills)
            {
                string str1 = string.Concat(skill.Difficulty.ToString().ToLower(), " DCs");
                if (skill.DCModifier != 0)
                {
                    str1 = (skill.DCModifier <= 0 ? string.Concat(str1, " ", skill.DCModifier) : string.Concat(str1, " +", skill.DCModifier));
                }
                string str2 = string.Concat(skill.SkillName, " (", str1, ")");
                if (skill.Details != "")
                {
                    str2 = string.Concat(str2, ": ", skill.Details);
                }
                ListViewItem red = this.SkillList.Items.Add(str2);
                red.Tag = skill;
                switch (skill.Type)
                {
                case SkillType.Primary:
                {
                    red.Group = this.SkillList.Groups[1];
                    break;
                }

                case SkillType.Secondary:
                {
                    red.Group = this.SkillList.Groups[2];
                    break;
                }

                case SkillType.AutoFail:
                {
                    red.Group = this.SkillList.Groups[3];
                    break;
                }
                }
                if (skill.Difficulty != Difficulty.Trivial && skill.Difficulty != Difficulty.Extreme)
                {
                    continue;
                }
                red.ForeColor = Color.Red;
            }
            if (this.SkillList.Groups[1].Items.Count == 0)
            {
                ListViewItem grayText = this.SkillList.Items.Add("(none)");
                grayText.Group     = this.SkillList.Groups[1];
                grayText.ForeColor = SystemColors.GrayText;
            }
            if (this.SkillList.Groups[2].Items.Count == 0)
            {
                ListViewItem grayText1 = this.SkillList.Items.Add("(none)");
                grayText1.Group     = this.SkillList.Groups[2];
                grayText1.ForeColor = SystemColors.GrayText;
            }
            this.SkillList.Sort();
        }
 public TrafficIncidentsParameters(MapArea mapArea)
 {
     MapArea = mapArea;
 }
Beispiel #34
0
 protected Event(GameTime occursAt, MapArea location)
 {
     OccursAt = occursAt;
     Location = location;
 }
 private static MapArea DeserializeMapArea(BinaryReader Reader)
 {
     MapArea area = new MapArea();
     area.Position = DeserializeMapPoint(Reader);
     area.Size = DeserializeMapSize(Reader);
     return area;
 }
Beispiel #36
0
 public StayInAreaCondition(MapArea area)
 {
     Area = area;
 }
Beispiel #37
0
    public void RegenerateMap()
    {
        mapArea = ruleset.generate();

        if (mapHandler != null) {
            IMapHandler handler = mapHandler.GetComponent<IMapHandler>();

            if (handler != null) {
                handler.OnMapFinish(mapArea);
            } else {
                Debug.LogWarning("map handler lacks IMapHandler script");
            }
        }

        // TODO: remove new mesh when creating new map without createMesh
        if (createMesh) {
            GetComponent<MeshFilter>().mesh = CreateMesh(width, height);
        }
    }
Beispiel #38
0
 protected void Chart1_PostPaint(object sender, ChartPaintEventArgs e)
 {
     if (e.ChartElement == Chart1)
     {
         for (Int32 i = Chart1.ChartAreas.Count-1; i >= 0; i--)
         {
             ChartArea area = Chart1.ChartAreas[i];
             MapArea mapArea = new MapArea(area.Name, String.Empty, String.Empty, area.Name, area.Position.ToRectangleF(), null);
             Chart1.MapAreas.Add(mapArea);
         }
     }
 }
Beispiel #39
0
	void OnEnable()
	{
		thisTarget = serializedObject.targetObject as MapArea;
		m_Object = new SerializedObject(target);
	}
Beispiel #40
0
    /// <summary>
    /// 创建走廊数据
    /// </summary>
    /// <param name="area"></param>
    private void CreateCorridors(MapArea area)
    {
        if (area == null || area.LeftChild == null || area.RightChild == null)
        {
            return;
        }

        var area1 = area.LeftChild;

        var area2 = area.RightChild;

        CreateCorridors(area1);

        CreateCorridors(area2);

        var room1 = area1.GetRoom();

        var room2 = area2.GetRoom();

        if (room1 == null || room2 == null)
        {
            return;
        }

        var id = CorridorDatas.Count;

        var isVertical = area1.Coordinate.X == area2.Coordinate.X;

        var doors = FindRoomsDoor(room1, room2, isVertical);

        var w = Mathf.Abs(doors[1].X - doors[0].X) + 1;

        var h = Mathf.Abs(doors[1].Y - doors[0].Y) + 1;

        if (isVertical) // 垂直
        {
            if (w > corridorWidth)
            {
                var startX = doors[0].X < doors[1].X ? doors[0].X : doors[1].X;

                var endX = doors[0].X < doors[1].X ? doors[1].X - corridorWidth + 1 : doors[1].X;

                CorridorDatas.Add(new RoomData()
                {
                    RoomType = RoomType.Corridor,

                    Id = id,

                    Width = w,

                    Height = h >= corridorWidth ? corridorWidth : h,

                    Coordinate = new Coordinate(startX, doors[0].Y),

                    Start = room1.Id,

                    End = room2.Id,
                });

                if (h > corridorWidth)
                {
                    CorridorDatas.Add(new RoomData()
                    {
                        RoomType = RoomType.Corridor,

                        Id = id,

                        Width = corridorWidth,

                        Height = h - corridorWidth,

                        Coordinate = new Coordinate(endX, doors[0].Y + corridorWidth),

                        Start = room1.Id,

                        End = room2.Id,
                    });
                }
            }
            else
            {
                if (h > 0)
                {
                    CorridorDatas.Add(new RoomData()
                    {
                        RoomType = RoomType.Corridor,

                        Id = id,

                        Width = corridorWidth,

                        Height = h,

                        Coordinate = doors[0],

                        Start = room1.Id,

                        End = room2.Id,
                    });
                }
            }
        }
        else // 水平
        {
            if (h > corridorWidth)
            {
                var startY = doors[0].Y < doors[1].Y ? doors[0].Y : doors[1].Y;

                var endY = doors[0].Y < doors[1].Y ? doors[1].Y - corridorWidth + 1 : doors[1].Y;

                CorridorDatas.Add(new RoomData()
                {
                    RoomType = RoomType.Corridor,

                    Id = id,

                    Width = w,

                    Height = h >= corridorWidth ? corridorWidth : h,

                    Coordinate = new Coordinate(doors[0].X, startY),

                    Start = room1.Id,

                    End = room2.Id,
                });

                if (h > corridorWidth)
                {
                    CorridorDatas.Add(new RoomData()
                    {
                        RoomType = RoomType.Corridor,

                        Id = id,

                        Width = corridorWidth,

                        Height = h - corridorWidth,

                        Coordinate = new Coordinate(doors[0].X, endY),

                        Start = room1.Id,

                        End = room2.Id,
                    });
                }
            }
            else
            {
                if (w > 0)
                {
                    CorridorDatas.Add(new RoomData()
                    {
                        RoomType = RoomType.Corridor,

                        Id = id,

                        Width = w,

                        Height = corridorWidth,

                        Coordinate = doors[0],

                        Start = room1.Id,

                        End = room2.Id,
                    });
                }
            }
        }
    }
Beispiel #41
0
		///<summary>Updates one MapArea in the database.</summary>
		public static void Update(MapArea mapArea){
			string command="UPDATE maparea SET "
				+"Extension  =  "+POut.Int   (mapArea.Extension)+", "
				+"XPos       = '"+POut.Double(mapArea.XPos)+"', "
				+"YPos       = '"+POut.Double(mapArea.YPos)+"', "
				+"Width      = '"+POut.Double(mapArea.Width)+"', "
				+"Height     = '"+POut.Double(mapArea.Height)+"', "
				+"Description= '"+POut.String(mapArea.Description)+"', "
				+"ItemType   =  "+POut.Int   ((int)mapArea.ItemType)+" "
				+"WHERE MapAreaNum = "+POut.Long(mapArea.MapAreaNum);
			Db.NonQ(command);
		}
 public static void SerializeMapArea(BinaryWriter Writer, MapArea Area)
 {
     SerializeMapObject(Writer, Area);
     SerializeMapPoint(Writer, Area.Position);
     SerializeMapSize(Writer, Area.Size);
 }
Beispiel #43
0
 private void DrawPage(MapArea Page, PrintPageEventArgs e)
 {
     switch (Page)
     {
         case MapArea.SandyBrook:
             {
                 DrawSandyBrook(e);
                 DrawSandyBrookTextAndStuff(e);
                 break;
             }
         case MapArea.Condos:
             {
                 DrawCondos(e);
                 DrawCondosTextAndStuff(e);
                 break;
             }
         case MapArea._100East:
             {
                 Draw_100E(e);
                 Draw100EastTextAndStuff(e);
                 break;
             }
         case MapArea._1700South:
             {
                 Draw_1700South(e);
                 Draw1700SouthTextAndStuff(e);
                 break;
             }
         case MapArea.Church:
             {
                 DrawChurchArea(e);
                 DrawChurchAreaTextAndStuff(e);
                 break;
             }
         default:
             break;
     }
 }
        private static MapAreaState DeserializeMapAreaState(BinaryReader Reader, MapArea area)
        {
            MapAreaState state = new MapAreaState(area);

            for (int i = 0; i < area.TransitionPoints.Count; i++ )
            {
                state.TransitionPoints[i] = DeserializeMapTransitionPointState(Reader, area.TransitionPoints[i]);
            }
            return state;
        }
Beispiel #45
0
		///<summary>Inserts one MapArea into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(MapArea mapArea,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				mapArea.MapAreaNum=ReplicationServers.GetKey("maparea","MapAreaNum");
			}
			string command="INSERT INTO maparea (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="MapAreaNum,";
			}
			command+="Extension,XPos,YPos,Width,Height,Description,ItemType) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(mapArea.MapAreaNum)+",";
			}
			command+=
				     POut.Int   (mapArea.Extension)+","
				+"'"+POut.Double(mapArea.XPos)+"',"
				+"'"+POut.Double(mapArea.YPos)+"',"
				+"'"+POut.Double(mapArea.Width)+"',"
				+"'"+POut.Double(mapArea.Height)+"',"
				+"'"+POut.String(mapArea.Description)+"',"
				+    POut.Int   ((int)mapArea.ItemType)+")";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				mapArea.MapAreaNum=Db.NonQ(command,true);
			}
			return mapArea.MapAreaNum;
		}
Beispiel #46
0
 // -------------- event handlers ---------------------------------
 private void filePrintMenuItem_Click(Object sender,
         EventArgs e)
 {
     printDoc.DefaultPageSettings = pgSettings;
     PrintDialog dlg = new PrintDialog();
     dlg.Document = printDoc;
     dlg.AllowSomePages = true;
     //printDoc.DefaultPageSettings.PrinterSettings.MaximumPage = 4;
     //printDoc.DefaultPageSettings.PrinterSettings.MinimumPage = 1;
     dlg.Document.PrinterSettings.FromPage = 1;
     dlg.Document.PrinterSettings.ToPage = 5 ;// MAX_PAGES;
     dlg.Document.PrinterSettings.MaximumPage = 5;// MAX_PAGES;
     dlg.Document.PrinterSettings.MinimumPage = 1;
        if (dlg.ShowDialog() == DialogResult.OK)
     {
         StartPage = (MapArea)dlg.Document.PrinterSettings.FromPage;
         StopPage = (MapArea)dlg.Document.PrinterSettings.ToPage;
         CurrentPage = StartPage;
         printDoc.Print();
     }
 }