public override void LoadContent() { base.LoadContent(); _spriteBatch = new SpriteBatch(GraphicsDevice); _image = Content.Load <Texture2D>(ContentPaths.Textures.Cat01); GetImageScaleForCurrentScreenResolution(); tiles = TileHelper.GenerateTiles(_image, scaleX, scaleY, gameSettings.numberOfYTiles); gridLines = tiles.Select(x => x.GetBoundingBox()).ToList(); if (gameSettings.randomlyRotateTiles) { TileHelper.RandomlyRotateTiles(tiles); } if (gameSettings.randomlySwapTilePositions) { TileHelper.ShuffleTileLocations(tiles); } if (gameSettings.randomlyPlaceTiles) { TileHelper.RandomlyPlaceTiles(tiles, GraphicsDevice.Viewport.Bounds, ref lastZIndex, out debugRectangle); } if (gameSettings.tileGameType == TileGameMode.Shuffle) { int shadowTileIndex = RandomHelper.Next(tiles.Count()); tiles[shadowTileIndex].sprite.Alpha = 0.0f; tiles[shadowTileIndex].sprite.IsVisible = false; shadowTile = tiles[shadowTileIndex]; } }
/// <summary> /// Summerizes all layers together for a given direction to see if a connection can be made. Only used for cross connect. /// Needs to know it's own layer to see if the value can be set to null. /// </summary> /// <param name="dir"></param> /// <param name="ownLayer"></param> private void UpdateAllOnDirection(Direction dir, TileLayer ownLayer) { TileMap map = GetComponentInParent <TileMap>(); bool changed = false; foreach (TileLayer layer in TileHelper.GetTileLayers()) { // Get the neighbour for a given direction var vector = TileHelper.ToCardinalVector(dir); TileObject neighbour = map.GetTileObject(layer, transform.position + new Vector3(vector.Item1, 0, vector.Item2)); if ((neighbour.GetPlacedObject(0) && neighbour.GetPlacedObject(0).HasAdjacencyConnector()) || layer == ownLayer) { bool connected = UpdateSingleConnection(dir, neighbour.GetPlacedObject(0)); changed |= connected; // Update our neighbour as well if (connected) { neighbour.GetPlacedObject(0)?.UpdateSingleAdjacency(TileHelper.GetOpposite(dir), GetComponent <PlacedTileObject>()); } } } if (changed) { UpdateMeshAndDirection(); } }
/// <summary> /// Clean up all existing adjacencies when this object is removed. Gets messy really fast when cross connect is involved... /// </summary> public void CleanAdjacencies() { TileMap map = GetComponentInParent <TileMap>(); var neighbourObjects = map.GetNeighbourObjects(GetComponent <PlacedTileObject>().GetLayer(), 0, transform.position); for (int i = 0; i < neighbourObjects.Length; i++) { neighbourObjects[i]?.UpdateSingleAdjacency(TileHelper.GetOpposite((Direction)i), null); } if (CrossConnectAllowed) { foreach (TileLayer layer in TileHelper.GetTileLayers()) { for (int i = 0; i < neighbourObjects.Length; i++) { // Get the neighbour for a given direction var vector = TileHelper.ToCardinalVector((Direction)i); TileObject neighbour = map.GetTileObject(layer, transform.position + new Vector3(vector.Item1, 0, vector.Item2)); if ((neighbour.GetPlacedObject(0) && neighbour.GetPlacedObject(0).HasAdjacencyConnector())) { neighbour.GetPlacedObject(0).UpdateSingleAdjacency(TileHelper.GetOpposite((Direction)i), null); } } } } }
void Start() { GameObject fieldO = GameObject.Find("World"); field = fieldO.GetComponent <Field>(); tilehelper = GetComponent <TileHelper>(); }
/// <summary> /// Show the attack highlights for the specified unit with the specified range. /// </summary> /// <param Name="unit"></param> /// <param Name="range"></param> /// <returns></returns> public int ShowAttackHighlights(UnitGameObject unit, int range) { foreach (var item in TileHelper.GetAllTilesWithinRange(unit.Tile.Coordinate, range)) { foreach (var tile in item.Value.Where(tile => tile.Value.HasUnit() && tile.Value.unitGameObject.index != unit.index)) { // If unit is an archer we don't need to calculate paths because archer can shoot over units, water etc. if (!unit.UnitGame.CanAttackAfterMove && !tile.Value.IsFogShown) { tile.Value.Highlight.ChangeHighlight(HighlightTypes.highlight_attack); highlight.HighlightObjects.Add(tile.Value.Highlight); } else { List <Node> path = movement.CalculateShortestPath(unit.Tile, tile.Value, true); if (path != null && path.Count <= unit.UnitGame.GetAttackMoveRange && !tile.Value.IsFogShown) { tile.Value.Highlight.ChangeHighlight(HighlightTypes.highlight_attack); highlight.HighlightObjects.Add(tile.Value.Highlight); } } } } int count = highlight.HighlightObjects.Count; highlight.IsHighlightOn = count > 0; return(count); }
public void UpdateTiles() { var xmlDoc = TileHelper.CreateTiles(this); var notification = new TileNotification(xmlDoc); _tileUpdater.Update(notification); }
public void UpdateCount(int count) { var badgeXml = TileHelper.CreateBadgeNumber(count); var badge = new BadgeNotification(badgeXml); _badgeUpdater.Update(badge); }
public void ParseInputLineTest() { var testData = new List <Tuple <string, IList <HexMovementDirection> > >() { new Tuple <string, IList <HexMovementDirection> >( "esenee", new List <HexMovementDirection>() { HexMovementDirection.East, HexMovementDirection.SouthEast, HexMovementDirection.NorthEast, HexMovementDirection.East }), new Tuple <string, IList <HexMovementDirection> >( "nwwneeswwsee", new List <HexMovementDirection>() { HexMovementDirection.NorthWest, HexMovementDirection.West, HexMovementDirection.NorthEast, HexMovementDirection.East, HexMovementDirection.SouthWest, HexMovementDirection.West, HexMovementDirection.SouthEast, HexMovementDirection.East }) }; foreach (var testExample in testData) { var actual = TileHelper.ParseInputLine(testExample.Item1); Assert.Equal(testExample.Item2, actual); } }
void SetPinIcon(MetaData data) { if (ApplicationBar.Buttons.Count < 1) { return; } try { var pin = (ApplicationBarIconButton)ApplicationBar.Buttons[0]; if (TileHelper.IsPinned(data)) { pin.IconUri = new Uri("icons/appbar_pin_remove.png", UriKind.Relative); pin.Text = Labels.Unpin; } else { pin.IconUri = new Uri("icons/appbar_pin.png", UriKind.Relative); pin.Text = Labels.Pin; } } catch { //ignore the exception } }
public void GetTileReflectionHorizontalTest() { var testData = new List <Tuple <IList <string>, IList <string> > >() { new Tuple <IList <string>, IList <string> >( new List <string>() { "abcd", "efgh", "ijkl", "mnop" }, new List <string>() { "dcba", "hgfe", "lkji", "ponm" }) }; foreach (var testExample in testData) { var actual = TileHelper.GetTileReflectionHorizontal(testExample.Item1); Assert.Equal(testExample.Item2, actual); } }
public void GetTileOrientationTest() { var testData = new List <Tuple <IList <string>, TileOrientation, IList <string> > >() { new Tuple <IList <string>, TileOrientation, IList <string> >( new List <string>() { "abcd", "efgh", "ijkl", "mnop" }, new TileOrientation(0, false), new List <string>() { "abcd", "efgh", "ijkl", "mnop" }), new Tuple <IList <string>, TileOrientation, IList <string> >( new List <string>() { "abcd", "efgh", "ijkl", "mnop" }, new TileOrientation(90, false), new List <string>() { "dhlp", "cgko", "bfjn", "aeim" }), new Tuple <IList <string>, TileOrientation, IList <string> >( new List <string>() { "abcd", "efgh", "ijkl", "mnop" }, new TileOrientation(90, true), new List <string>() { "plhd", "okgc", "njfb", "miea" }), }; foreach (var testExample in testData) { var actual = TileHelper.GetTileOrientation(testExample.Item1, testExample.Item2); Assert.Equal(testExample.Item3, actual); } }
private void NavigateFromAppOrTile() { string tileId = ApplicationData.Current.LocalSettings.Values["TileId"].ToString(); if (tileId == "App") { _navService.NavigateToMainPage(); } else if (TileHelper.GetTileType() == "Event") { int eventId = TileHelper.GetTileId(); _myEventsService.EventDefinitionService.GetEventDefinitionByIdAsync(eventId, (resultEvent) => { App.RootFrame.Dispatcher.RunAsync(CoreDispatcherPriority.High, new DispatchedHandler(() => { _navService.NavigateToEventDetails(resultEvent); })).AsTask().Wait(); }); } else if (TileHelper.GetTileType() == "Session") { int sessionId = TileHelper.GetTileId(); _myEventsService.SessionService.GetSessionAsync(sessionId, (resultSession) => { App.RootFrame.Dispatcher.RunAsync(CoreDispatcherPriority.High, new DispatchedHandler(() => { _navService.NavigateToSessionDetails(resultSession); })).AsTask().Wait(); }); } }
/// <summary> /// Hides the fow within a certain range of a given Tile. /// </summary> /// <param Name="Tile">The Tile from which to hide the fow.</param> /// <param Name="rangeLineOfSight">The range from which to hide to fow.</param> /// <param Name="showOrhide">Wether or not the fow should be enabled or disabled.</param> private void ShowOrHideFowWithinRange(Tile tile, int rangeLineOfSight, bool showOrhide) { tile.IsFogShown = showOrhide; // Fading when moving gives weird effects. For now disabled. //float fromf = showOrhide ? 0f : 1f; //float tof = showOrhide ? 1f : 0f; //AddToFading(Tile, fromf, tof); Color cc = tile.FogOfWar.renderer.material.color; cc.a = tile.IsFogShown ? 1f : 0f; tile.FogOfWar.renderer.material.color = cc; foreach (var item in TileHelper.GetAllTilesWithinRange(tile.Coordinate, rangeLineOfSight)) { foreach (KeyValuePair <int, Tile> tileValue in item.Value) { tileValue.Value.IsFogShown = showOrhide; // Fading when moving gives weird effects. For now disabled. //float from = showOrhide ? 0f : 1f; //float to = showOrhide ? 1f : 0f; //AddToFading(tileValue.Value, from, to); Color color = tileValue.Value.FogOfWar.renderer.material.color; color.a = tileValue.Value.IsFogShown ? 1f : 0f; tileValue.Value.FogOfWar.renderer.material.color = color; } } }
public void SetupView(BasePlaylist newPlaylist) { // Check if the models saved playlist is null if (newPlaylist != null && (Playlist == null || Playlist.PlaylistId != newPlaylist.PlaylistId)) { // Set the item source PlaylistTracks.Source.PlaylistId = newPlaylist.PlaylistId; PlaylistTracks.Source.Service = newPlaylist.ServiceType; PlaylistTracks.RefreshItems(); // Set the playlist Playlist = newPlaylist; // Get the resource loader var resources = ResourceLoader.GetForCurrentView(); // Check if the tile is pinned if (TileHelper.IsTilePinned("Playlist_" + Playlist.PlaylistId)) { PinButtonIcon = "\uE77A"; PinButtonText = resources.GetString("AppBarUI_Unpin_Raw"); } else { PinButtonIcon = "\uE718"; PinButtonText = resources.GetString("AppBarUI_Pin_Raw"); } } }
public async void ClearAppCache() { var dialog = new MessageDialog( "Warning: Clearing Application cache will delete the following things:\n• Cached Images.\n• Jumplist Items.\n• Pinned Live Tiles.\n• Local Playback History.\n\n To Continue press 'Clear Cache', this may take a while." , "Clear Application Cache?"); dialog.Commands.Add(new UICommand("Clear Cache", null, 0)); dialog.Commands.Add(new UICommand("Cancel", null, 1)); var response = await dialog.ShowAsync(); if ((int)response.Id == 1) { return; } // Clear all the live tiles await TileHelper.RemoveAllTilesAsync(); // Remove all cached images from the app var rootCacheFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("cache", CreationCollisionOption.OpenIfExists); await rootCacheFolder.DeleteAsync(); // Remove all toast notifications ToastNotificationManager.History.Clear(); using (var db = new HistoryContext()) { db.Database.EnsureDeleted(); db.Database.Migrate(); } }
private async Task DeleteMemosAsync(IEnumerable <Memo> items) { var tasks = items.Select(m => Task.Run(async() => { BeginInvoke(() => { Uow.MemoRepository.Delete(m); //Uow.MemoTagRepository.DeleteByMemo(m); Uow.FavoriteRepository.DeleteByMemo(m); //Uow.Save(); TileHelper.UnPinMemo(m); }); if (BackgroundAudioPlayer.Instance.Track != null && BackgroundAudioPlayer.Instance.Track.Source.OriginalString.Contains(m.AudioFile)) { BackgroundAudioPlayer.Instance.Close(); } await StorageHelper.DeleteFileAsync(m.AudioFile); if (!string.IsNullOrWhiteSpace(m.ImageFile)) { await StorageHelper.DeleteFileAsync(m.ImageFile); } })); await Task.WhenAll(tasks); }
public override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { if (TileHelper.IsFavoritesPinnned()) { _pinFavoritesMenuItem.Text = AppResources.UnPinFavoritesMenuItemText; } }
private async void UpdatePreviewTileNotifications() { try { XmlDocument notifContent = await TileHelper.GetCurrentPrimaryTileNotificationContentAsync(ViewModel.Account); if (notifContent == null) { foreach (var tile in AllTiles()) { tile.CreateTileUpdater().Clear(); } } else { foreach (var tile in AllTiles()) { tile.CreateTileUpdater().Update(new TileNotification(notifContent)); } } } catch (Exception ex) { TelemetryExtension.Current?.TrackException(ex); } }
static public List <Tile> FindPath(Tile[,] tiles, Tile src, Tile dest) { List <Tile> path = new List <Tile>(); Tile currTile = src; path.Add(src); int count = 0; do { count++; foreach (Tile n in TileHelper.Neighbours4(currTile)) { if (n.tileType == TileType.Path && path.Contains(n) == false) { path.Add(n); //Debug.Log("Added tile"+n.x +"_"+n.y); currTile = n; break; } } }while (currTile != dest && count < 100); Debug.Log("Path found in " + count + " iterations"); return(path); }
/// <summary> /// Creates a new PlacedTileObject from a TileObjectSO at a given position and direction. Uses NetworkServer.Spawn() if a server is running. /// </summary> /// <param name="worldPosition"></param> /// <param name="origin"></param> /// <param name="dir"></param> /// <param name="tileObjectSO"></param> /// <returns></returns> public static PlacedTileObject Create(Vector3 worldPosition, Vector2Int origin, Direction dir, TileObjectSo tileObjectSO) { GameObject placedGameObject = EditorAndRuntime.InstantiatePrefab(tileObjectSO.prefab); placedGameObject.transform.SetPositionAndRotation(worldPosition, Quaternion.Euler(0, TileHelper.GetRotationAngle(dir), 0)); // Alternative name is required for walls as they can occupy the same tile if (TileHelper.ContainsSubLayers(tileObjectSO.layer)) { placedGameObject.name += "_" + TileHelper.GetDirectionIndex(dir); } PlacedTileObject placedObject = placedGameObject.GetComponent <PlacedTileObject>(); if (placedObject == null) { placedObject = placedGameObject.AddComponent <PlacedTileObject>(); } placedObject.Setup(tileObjectSO, origin, dir); if (NetworkServer.active) { if (!NetworkClient.prefabs.ContainsValue(placedGameObject)) { Debug.LogWarning("Prefab was not found in the Spawnable list. Please add it."); } NetworkServer.Spawn(placedGameObject); } return(placedObject); }
private async Task <float> FetchPreviousPosition(IMediaItem media) { var video = media as VideoItem; if (video == null) { return(0); } var roamFile = await ApplicationData.Current.RoamingFolder.TryGetItemAsync("roamVideo.txt"); if (roamFile != null) { var roamVideos = await FileIO.ReadLinesAsync(roamFile as StorageFile); if (roamVideos.Any()) { if (roamVideos[0] == media.Name) { int leftTime = 0; if (int.TryParse(roamVideos[1], out leftTime)) { video.TimeWatchedSeconds = leftTime; } } } } TileHelper.UpdateVideoTile(); // VLC expects a start-time in seconds return((float)video.TimeWatched.TotalMilliseconds / 1000.0f); }
private async Task SetTileNotification() { Windows.Data.Xml.Dom.XmlDocument _Tile = null; if (string.IsNullOrEmpty(this.Image)) { // a template without an image _Tile = Windows.UI.Notifications.TileUpdateManager .GetTemplateContent(Windows.UI.Notifications.TileTemplateType.TileSquareText01); } else { // a template with an image _Tile = Windows.UI.Notifications.TileUpdateManager .GetTemplateContent(Windows.UI.Notifications.TileTemplateType.TileSquarePeekImageAndText01); var _Path = await TileHelper .ResizeForTile(m_Question.Image, TileHelper.TileSize.Square); (_Tile.GetElementsByTagName("image")[0] as Windows.Data.Xml.Dom.XmlElement) .SetAttribute("src", _Path.ToString()); } var _Texts = _Tile.GetElementsByTagName("text"); _Texts[0].InnerText = this.Answer; _Texts[1].InnerText = Choices[1]; _Texts[2].InnerText = Choices[2]; _Texts[3].InnerText = Choices[3]; var _Notification = new Windows.UI.Notifications.TileNotification(_Tile) { Tag = "no-repeat" }; var _Updater = Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication(); _Updater.Clear(); _Updater.Update(_Notification); }
/// <summary> /// Executes the actual algorithm. /// </summary> protected override void DoRun() { var tiles = new Dictionary <TileIndex, RoutingTile>(); _polygons = new List <Polygon>(); _edgeVisitor.Visit += (id, startWeight, endWeight, shape) => { this.AddEdgeVisit(tiles, startWeight, endWeight, shape); }; _edgeVisitor.Run(); var tileList = tiles.Values.ToList(); tileList = UpdateForWalking(tileList, _level, _walkingSpeed, _limits.Max()); if (tileList == null) { return; } foreach (var isochroneLimit in _limits) { var tilesWithin = tileList.Where(t => t.Weight < isochroneLimit).ToList(); if (tilesWithin.Count > 0) { var polygonOfTileIndexes = TilesToPolygon.TileSetToPolygon(tilesWithin); _polygons.Add(new Polygon { ExteriorRing = TileHelper.ToWorldCoordinates(polygonOfTileIndexes, _level) }); } } }
/// <summary>Update the overlay.</summary> public void Update() { // move UI if it overlaps pause message if (this.WasPaused != Game1.HostPaused) { this.WasPaused = Game1.HostPaused; this.ReinitializeComponents(); } // get updated tiles if (Game1.currentLocation == null || this.CurrentLayer == null) { this.VisibleTiles = this.EmptyTiles; this.TileGroups = this.EmptyTileGroups; } else { Rectangle visibleArea = this.GetVisibleTileArea(Game1.viewport); if (--this.UpdateCountdown <= 0 || (this.CurrentLayer.UpdateWhenVisibleTilesChange && visibleArea != this.LastVisibleArea)) { GameLocation location = Game1.currentLocation; Vector2 cursorTile = TileHelper.GetTileFromCursor(); this.VisibleTiles = visibleArea.GetTiles().ToArray(); this.TileGroups = this.CurrentLayer.Update(location, visibleArea, this.VisibleTiles, cursorTile).ToArray(); this.LastVisibleArea = visibleArea; this.UpdateCountdown = this.CurrentLayer.UpdateTickRate; } } }
private async void DefaultTile_Clicked(object sender, RoutedEventArgs e) { if (app.TimeTables.Count == 0) { var dialog = new CommonDialog("请先导入课程表") { Title = "提示", }; await dialog.ShowAsyncQueue(); return; } var tableCourses = app.TimeTables[TablePivot.SelectedIndex]; localSettings.Values[AppConstants.TILE_TIMETABLE] = JsonConvert.SerializeObject(tableCourses); TileHelper.UpdateTile(await TileHelper.GetDefaultTileTimeTable()); var msgDialog = new CommonDialog("设置成功!") { Title = "提示", }; await msgDialog.ShowAsyncQueue(); }
/// <summary> /// Load the information for a single tile (as in parse the needed .t -file. /// </summary> /// <param name="tileX">The cornerIndexX-value of the tile number</param> /// <param name="tileZ">The cornerIndexZ-value of the tile number</param> /// <param name="loTiles">Loading LO tile (Distant Mountain) or not</param> /// <returns>The tile information as a 'Tile' object</returns> private Tile LoadTile(int tileX, int tileZ, bool loTiles) { TileHelper.Zoom zoom = loTiles ? TileHelper.Zoom.DMSmall : TileHelper.Zoom.Small; string path = loTiles ? this.lotilesPath : this.tilesPath; // Note, code is similar to ORTS.Viewer3D.TileManager.Load // Check for 1x1 or 8x8 tiles. TileHelper.Snap(ref tileX, ref tileZ, zoom); // we set visible to false to make sure errors are loaded Tile newTile = new Tile(path, tileX, tileZ, zoom, false); if (newTile.Loaded) { return(newTile); } else { // Check for 2x2 or 16x16 tiles. TileHelper.Snap(ref tileX, ref tileZ, zoom - 1); newTile = new Tile(tilesPath, tileX, tileZ, zoom - 1, false); if (newTile.Loaded) { return(newTile); } } return(null); }
public void UpdateAll(PlacedTileObject[] neighbourObjects) { // Because we are on a Furniture layer and walls are on the Turf. Discard furniture neighbours and get the turf neighbours. if (!map) { map = GetComponentInParent <TileMap>(); } neighbourObjects = map.GetNeighbourObjects(TileLayer.Turf, 0, transform.position); PlacedTileObject currentObject = GetComponent <PlacedTileObject>(); bool changed = false; for (int i = 0; i < neighbourObjects.Length; i++) { bool updatedSingle = false; updatedSingle = UpdateSingleConnection((Direction)i, neighbourObjects[i]); if (updatedSingle && neighbourObjects[i]) { neighbourObjects[i].UpdateSingleAdjacency(TileHelper.GetOpposite((Direction)i), currentObject); } changed |= updatedSingle; } if (changed) { UpdateWallCaps(); } }
public override void Update() { base.Update(); TileSystem tileSystem = TileSystem.Instance; Vector2Int lookDirection = new Vector2Int(); Vector2 newPosition = new Vector2(); if (_character._playerController.bIsPC) { PCMove(out newPosition, out lookDirection); } else { var joystick = _character._playerController._joystick; if (!joystick.IsNeutral()) { newPosition += TileHelper.GetSlopeDirection(joystick.Direction); lookDirection += joystick.Direction.ToVector2Int(); } } if (newPosition.Equals(Vector2.zero)) { _nextState = eStateType.IDLE; return; } _character.UpdateDirection(lookDirection); _character.UpdatePosition(newPosition); }
/// <summary> /// Generates reference image tiles. /// </summary> /// <param name="shapeFilePath">Shape file path.</param> /// <param name="regionHvMapPath">Region HV map file path.</param> /// <param name="shapeKey">Shape key used.</param> /// <param name="outputDir">Output directory where the reference image tiles have to be stored.</param> /// <param name="maxLevel">Maximum level of the pyramid.</param> private static void GenerateReferenceImageTiles(string shapeFilePath, string regionHvMapPath, string shapeKey, string outputDir, int maxLevel) { // Create output folder. if (!Directory.Exists(outputDir)) { Directory.CreateDirectory(outputDir); } // Define Color map. var shapeGrid = new ShapeValueMap(shapeFilePath, regionHvMapPath, shapeKey); var colorMap = new ShapeColorMap(shapeGrid); // Define serializer. var tileSerializer = new ImageTileSerializer(TileHelper.GetDefaultImageTilePathTemplate(outputDir), ImageFormat.Png); // Create and configure the tile creator. var tileCreator = new ShapeTileCreator(tileSerializer, colorMap, ProjectionTypes.Toast, maxLevel); // Generate shape file tiles. Trace.TraceInformation("{0}: Creating the reference image tiles..", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss")); var tileGenerator = new TileGenerator(tileCreator); tileGenerator.Generate(maxLevel); Trace.TraceInformation("{0}: Reference Image generation completed.", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss")); }
/// <summary> /// 通过本地更新磁贴,未来天气 /// </summary> /// <param name="future"></param> /// <param name="cityName"></param> /// <param name="getWeatherTypeRespose"></param> /// <param name="getUserRespose"></param> private void UpdateTileByClientForTomorrow(Model.Weather.Daily_forecastItem daily_forecast, string cityName) { string tileXmlString = @"<tile>" + "<visual version='2'>" + "<binding template='TileWide310x150Text01' fallback='TileWideText01'>" + "<text id='1'>" + cityName + "</text>" + "<text id='2'>" + daily_forecast.tmp.min + "°~" + daily_forecast.tmp.max + "° " + (daily_forecast.cond.code_d == daily_forecast.cond.code_n ? daily_forecast.cond.txt_d : daily_forecast.cond.txt_d + "转" + daily_forecast.cond.txt_n) + "</text>" + "<text id='3'>" + daily_forecast.wind.dir + " " + daily_forecast.wind.sc + " 级</text>" + "<text id='4'>湿度: " + daily_forecast.hum + "%</text>" + "<text id='5'>能见度: " + daily_forecast.vis + "km</text>" + "</binding>" + "<binding template='TileSquare150x150PeekImageAndText01' fallback='TileSquarePeekImageAndText01'>" + "<image id='1' src='ms-appx:///" + ((DateTime.Compare(DateTime.Now.ToLocalTime(), DateTime.Parse(daily_forecast.astro.sr)) > 0 & DateTime.Compare(DateTime.Now.ToLocalTime(), DateTime.Parse(daily_forecast.astro.ss)) < 0) ? weatherTypeRespose.WeatherTypes.FirstOrDefault(x => x.Code == daily_forecast.cond.code_d).TileSquarePic : weatherTypeRespose.WeatherTypes.FirstOrDefault(x => x.Code == daily_forecast.cond.code_n).TileSquarePic) + "'/>" + "<text id='1'>" + cityName + "</text>" + "<text id='2'>" + daily_forecast.tmp.min + "°~" + daily_forecast.tmp.max + "</text>" + "<text id='3'>" + (daily_forecast.cond.code_d == daily_forecast.cond.code_n ? daily_forecast.cond.txt_d : daily_forecast.cond.txt_d + "转" + daily_forecast.cond.txt_n) + "</text>" + "<text id='4'>" + daily_forecast.wind.dir + " " + daily_forecast.wind.sc + "级</text>" + "</binding>" + "</visual>" + "</tile>"; TileHelper.UpdateTileNotificationsByXml(tileXmlString); }
public void StartLogTile() { queue = new TileQueue(this); log = new Logger(queue); helper = new TileHelper(); com = new Commands(log); if (TShock.Config.StorageType.ToLower() == "sqlite") { string sql = Path.Combine(TShock.SavePath, "logtile.sqlite"); DB = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql)); } else if (TShock.Config.StorageType.ToLower() == "mysql") { try { var hostport = TShock.Config.MySqlHost.Split(':'); DB = new MySqlConnection(); DB.ConnectionString = String.Format("Server={0}; Port={1}; Database={2}; Uid={3}; Pwd={4};", hostport[0], hostport.Length > 1 ? hostport[1] : "3306", TShock.Config.MySqlDbName, TShock.Config.MySqlUsername, TShock.Config.MySqlPassword ); } catch (MySqlException ex) { Log.Error(ex.ToString()); throw new Exception("MySql not setup correctly"); } } else { throw new Exception("Invalid storage type"); } var table = new SqlTable("LogTile", new SqlColumn("id", MySqlDbType.Int32) {Primary = true, AutoIncrement = true}, new SqlColumn("X", MySqlDbType.Int32), new SqlColumn("Y", MySqlDbType.Int32), new SqlColumn("IP", MySqlDbType.Int32), new SqlColumn("Name", MySqlDbType.Text), new SqlColumn("Action", MySqlDbType.Int32), new SqlColumn("TileType", MySqlDbType.Int32), new SqlColumn("Date", MySqlDbType.Int32) ); var creator = new SqlTableCreator(DB, DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator()); creator.EnsureExists(table); logThread = new Thread(log.SaveTimer); CommandQueueThread = new Thread( CommandQueue.ProcessQueue); logThread.Start(); CommandQueueThread.Start(); queue.addHook(); com.addHook(); fileWriter = new Thread(ConfigFileManager); fileWriter.Start(); }
public Commands(Logger l) { this.helper = LogTile.helper; log = l; }