/// <summary> /// Returns the best fit size for the asset to the given size. /// </summary> /// <param name="width">Max possible width.</param> /// <param name="height">Max possible height.</param> /// <returns>Returns the best fit size for the asset.</returns> private Size GetSizeMaintainingAspectRatio(double width, double height) { width -= MarginX; height -= MarginY; ImageAsset asset = this.Asset as ImageAsset; if (asset != null) { double aspectRatioWidth = Convert.ToDouble(asset.Width); double aspectRatioHeight = Convert.ToDouble(asset.Height); if (aspectRatioWidth == 0 || aspectRatioHeight == 0) { return(new Size(width, height)); } if (width >= height * aspectRatioWidth / aspectRatioHeight) { return(new Size(height * aspectRatioWidth / aspectRatioHeight, height)); } else { return(new Size(width, width * aspectRatioHeight / aspectRatioWidth)); } } return(new Size(width, height)); }
/// <summary> /// Runs the code example. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The customer ID for which the call is made.</param> public void Run(GoogleAdsClient client, long customerId) { // Get the AssetServiceClient. AssetServiceClient assetService = client.GetService(Services.V6.AssetService); // Creates an image content. byte[] imageContent = MediaUtilities.GetAssetDataFromUrl(IMAGE_URL, client.Config); // Creates an image asset. ImageAsset imageAsset = new ImageAsset() { Data = ByteString.CopyFrom(imageContent), FileSize = imageContent.Length, MimeType = MimeType.ImageJpeg, FullSize = new ImageDimension() { HeightPixels = 315, WidthPixels = 600, Url = IMAGE_URL } }; // Creates an asset. Asset asset = new Asset() { // Optional: Provide a unique friendly name to identify your asset. // If you specify the name field, then both the asset name and the image being // uploaded should be unique, and should not match another ACTIVE asset in this // customer account. // Name = 'Jupiter Trip #' + ExampleUtilities.GetRandomString(), Type = AssetType.Image, ImageAsset = imageAsset }; // Creates an asset operation. AssetOperation operation = new AssetOperation() { Create = asset }; try { // Issues a mutate request to add the asset. MutateAssetsResponse response = assetService.MutateAssets(customerId.ToString(), new[] { operation }); // Displays the result. Console.WriteLine($"Image asset with resource name: " + $"'{response.Results.First().ResourceName}' is created."); } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
// load the scene protected override void Load() { // load fonts _font = Assets.LoadFont("gfx/OpenSans-Regular.ttf", 22, false); _fontBig = Assets.LoadFont("gfx/OpenSans-Regular.ttf", 42, false); // set level and starting positions _ballPosition.Set(400, 500); _ballSpeed.Set(-1f, -0.75f); // init player var windowSize = Gfx.WindowSize; _player = new RectangleF(windowSize.X / 2 - 60, windowSize.Y - 50, 120, 15); // init level for (int i = 0; i < windowSize.X / BlockSize.X; ++i) { for (int j = 0; j < 10; ++j) { _blocks.Add(new Block() { Rectangle = new RectangleI(i * BlockSize.X, j * BlockSize.Y, BlockSize.X, BlockSize.Y), Color = new Color(1f - (j / 10f), 0f, (j / 10f) - 1f, 1f) }); } } // create empty texture for trail effects _trailEffectTexture = Assets.CreateEmptyImage(windowSize); }
/// <summary> /// Load scene /// </summary> protected override void Load() { // set assets root Assets.AssetsRoot = "../../../../TestAssets"; // load config Game.LoadConfig("config.ini"); // load assets _cursor = Assets.LoadImage("gfx/cursor.png", ImageFilterMode.Nearest); _fontBig = Assets.LoadFont("gfx/OpenSans-Regular.ttf", 46, false); _font = Assets.LoadFont("gfx/OpenSans-Regular.ttf", 28, false); // add demos AddDemo("Input & Spritesheet", new Demos.InputAndSpritesheetScene()); AddDemo("Music & Sound Effects", new Demos.MusicAndSoundScene()); AddDemo("Drawing Texts", new Demos.TextScene()); AddDemo("Fullscreen Mode", new Demos.FullscreenScene()); AddDemo("Windowed Fullscreen", new Demos.WindowedFullscreenScene()); AddDemo("Rendering Viewport", new Demos.ViewportScene()); AddDemo("Performance Test", new Demos.PerformanceTestScene()); AddDemo("Render To Texture", new Demos.RenderToTextureScene()); AddDemo("Basic Lights", new Demos.BasicLightsScene()); AddDemo("Custom Managers", new Demos.CustomManagerScene()); AddDemo("Drawing Shapes", new Demos.DrawingShapesScene()); AddDemo("UI System", new Demos.UIScene()); }
/// <summary> /// Used internally to map a model that inherits from ImageAssetSummary. /// </summary> public ImageAssetSummary Map <TModel>(TModel imageToMap, ImageAsset dbImage) where TModel : ImageAssetSummary { imageToMap.AuditData = _auditDataMapper.MapUpdateAuditData(dbImage); imageToMap.ImageAssetId = dbImage.ImageAssetId; imageToMap.FileExtension = dbImage.FileExtension; imageToMap.FileName = dbImage.FileName; imageToMap.FileSizeInBytes = dbImage.FileSizeInBytes; imageToMap.Height = dbImage.HeightInPixels; imageToMap.Width = dbImage.WidthInPixels; imageToMap.Title = dbImage.Title; imageToMap.FileStamp = AssetFileStampHelper.ToFileStamp(dbImage.FileUpdateDate); imageToMap.FileNameOnDisk = dbImage.FileNameOnDisk; imageToMap.DefaultAnchorLocation = dbImage.DefaultAnchorLocation; imageToMap.VerificationToken = dbImage.VerificationToken; imageToMap.Tags = dbImage .ImageAssetTags .Select(t => t.Tag.TagText) .OrderBy(t => t) .ToList(); imageToMap.Url = _imageAssetRouteLibrary.ImageAsset(imageToMap); return(imageToMap); }
/// <summary> /// Maps an EF ImageAsset record from the db into a ImageAssetDetails /// object. If the db record is null then null is returned. /// </summary> /// <param name="dbImage">ImageAsset record from the database.</param> public ImageAssetRenderDetails Map(ImageAsset dbImage) { if (dbImage == null) { return(null); } var image = new ImageAssetRenderDetails() { ImageAssetId = dbImage.ImageAssetId, FileExtension = dbImage.FileExtension, FileName = dbImage.FileName, FileNameOnDisk = dbImage.FileNameOnDisk, Height = dbImage.HeightInPixels, Width = dbImage.WidthInPixels, Title = dbImage.Title, DefaultAnchorLocation = dbImage.DefaultAnchorLocation, FileUpdateDate = dbImage.FileUpdateDate, VerificationToken = dbImage.VerificationToken }; image.FileStamp = AssetFileStampHelper.ToFileStamp(dbImage.FileUpdateDate); image.Url = _imageAssetRouteLibrary.ImageAsset(image); return(image); }
private void Repopulate() { if (addon == null) { return; } string addonInfo = addonInfoFormat.Replace("%NAME", addon.info.Name).Replace("%AUTHOR", addon.info.Author).Replace("%CONTACT", addon.info.Contact).Replace("%VERSION", addon.info.Version).Replace("%SIZE", UIManager.instance.FormatSize(addon.size)); addonInfoText.GetComponent <TMP_Text>().text = addonInfo; ImageAsset iconAsset = (ImageAsset)AssetManager.instance.GetAsset($"{addon.info.Name}.png"); if (iconAsset != null) { Image image = addonIconImage.GetComponent <Image>(); image.sprite = iconAsset.AsSprite(); image.color = Color.white; } else { Image image = addonIconImage.GetComponent <Image>(); image.sprite = null; image.color = Random.ColorHSV(); } shouldRepopulate = false; }
private Task OnTransactionComplete(ImageAsset imageAsset) { return(_messageAggregator.PublishAsync(new ImageAssetAddedMessage() { ImageAssetId = imageAsset.ImageAssetId })); }
public async Task SaveAsync(IFileSource fileToSave, ImageAsset imageAsset, string validationErrorPropertyName) { var fileExtension = Path.GetExtension(fileToSave.FileName); if (WidthInPixels.HasValue) { imageAsset.WidthInPixels = WidthInPixels.Value; } if (HeightInPixels.HasValue) { imageAsset.HeightInPixels = HeightInPixels.Value; } imageAsset.FileExtension = fileExtension; using var inputSteam = await fileToSave.OpenReadStreamAsync(); imageAsset.FileSizeInBytes = inputSteam.Length; var fileName = Path.ChangeExtension(imageAsset.FileNameOnDisk, imageAsset.FileExtension); using (var scope = _transactionScopeManager.Create(_dbContext)) { if (SaveFile) { await _fileStoreService.CreateAsync(ASSET_FILE_CONTAINER_NAME, fileName, inputSteam); } await _dbContext.SaveChangesAsync(); await scope.CompleteAsync(); } }
public CharacterEntity2d(string rFileBase, int rWidth, int rHeight) { Properties.IsObject = false; Properties.Filebase = rFileBase; ImageAsset tSheet = Media.GetImageAsset(rFileBase + ".png", 1.0f, 1.0f); Agk.Swap(); var spSheet = Agk.CreateSprite(tSheet.ResourceNumber); Agk.SetSpritePosition(spSheet, 0.0f, 0.0f); Agk.Render(); bool isFirst = true; for (int row = 0; row < (Agk.GetImageHeight(tSheet.ResourceNumber) / rHeight); row++) { for (int col = 0; col < (Agk.GetImageWidth(tSheet.ResourceNumber) / rWidth); col++) { var tImg = Agk.GetImage(col * rWidth, row * rHeight, rWidth, rHeight); if (isFirst) { Properties.ResourceNumber = Agk.CreateSprite(tImg); isFirst = false; } Agk.AddSpriteAnimationFrame(Properties.ResourceNumber, tImg); } } Agk.DeleteSprite(spSheet); Agk.ClearScreen(); Agk.Swap(); CharacterHandler2d.CharacterList.Add(this); }
/// <summary> /// Uploads the image from the specified <paramref name="url"/>. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="url">The image URL.</param> /// <returns>ID of the uploaded image.</returns> private static long UploadImageAsset(AdWordsUser user, string url) { using (AssetService assetService = (AssetService)user.GetService(AdWordsService.v201809.AssetService)) { // Create the image asset. ImageAsset imageAsset = new ImageAsset() { // Optional: Provide a unique friendly name to identify your asset. If you // specify the assetName field, then both the asset name and the image being // uploaded should be unique, and should not match another ACTIVE asset in this // customer account. // assetName = "Image asset " + ExampleUtilities.GetRandomString(), imageData = MediaUtilities.GetAssetDataFromUrl(url, user.Config), }; // Create the operation. AssetOperation operation = new AssetOperation() { @operator = Operator.ADD, operand = imageAsset }; // Create the asset and return the ID. return(assetService.mutate(new AssetOperation[] { operation }).value[0].assetId); } }
public StreamPagePanel() { this.panelContainer = new StreamContainerWidget(); this.panelContainer.BaseClip = false; base.AddChildLast(this.panelContainer); this.sprtContainer = new StreamContainerWidget(); this.sprtContainer.BaseClip = false; base.AddChildLast(this.sprtContainer); this.panelList = new List <Panel> (); this.sprtList = new List <UISprite> (); this.pageCount = 0; this.pageIndex = -1; base.Clip = true; base.HookChildTouchEvent = true; this.state = StreamPagePanel.AnimationState.None; this.activeImage = new ImageAsset(SystemImageAsset.PagePanelActive); this.normalImage = new ImageAsset(SystemImageAsset.PagePanelNormal); DragGestureDetector dragGestureDetector = new DragGestureDetector(); dragGestureDetector.DragDetected += new EventHandler <DragEventArgs> (this.DragEventHandler); base.AddGestureDetector(dragGestureDetector); FlickGestureDetector flickGestureDetector = new FlickGestureDetector(); flickGestureDetector.Direction = FlickDirection.Horizontal; flickGestureDetector.FlickDetected += new EventHandler <FlickEventArgs> (this.FlickEventHandler); base.AddGestureDetector(flickGestureDetector); }
public async Task ExecuteAsync(AddImageAssetCommand command, IExecutionContext executionContext) { var imageAsset = new ImageAsset(); imageAsset.FileDescription = command.Title; imageAsset.FileName = SlugFormatter.ToSlug(command.Title); imageAsset.DefaultAnchorLocation = command.DefaultAnchorLocation; _entityTagHelper.UpdateTags(imageAsset.ImageAssetTags, command.Tags, executionContext); _entityAuditHelper.SetCreated(imageAsset, executionContext); using (var scope = _transactionScopeFactory.Create(_dbContext)) { // if adding, save this up front _dbContext.ImageAssets.Add(imageAsset); await _imageAssetFileService.SaveAsync(command.File, imageAsset, nameof(command.File)); command.OutputImageAssetId = imageAsset.ImageAssetId; scope.Complete(); } await _messageAggregator.PublishAsync(new ImageAssetAddedMessage() { ImageAssetId = imageAsset.ImageAssetId }); }
public StreamPagePanel() { this.panelContainer = new StreamContainerWidget (); this.panelContainer.BaseClip = false; base.AddChildLast (this.panelContainer); this.sprtContainer = new StreamContainerWidget (); this.sprtContainer.BaseClip = false; base.AddChildLast (this.sprtContainer); this.panelList = new List<Panel> (); this.sprtList = new List<UISprite> (); this.pageCount = 0; this.pageIndex = -1; base.Clip = true; base.HookChildTouchEvent = true; this.state = StreamPagePanel.AnimationState.None; this.activeImage = new ImageAsset (SystemImageAsset.PagePanelActive); this.normalImage = new ImageAsset (SystemImageAsset.PagePanelNormal); DragGestureDetector dragGestureDetector = new DragGestureDetector (); dragGestureDetector.DragDetected += new EventHandler<DragEventArgs> (this.DragEventHandler); base.AddGestureDetector (dragGestureDetector); FlickGestureDetector flickGestureDetector = new FlickGestureDetector (); flickGestureDetector.Direction = FlickDirection.Horizontal; flickGestureDetector.FlickDetected += new EventHandler<FlickEventArgs> (this.FlickEventHandler); base.AddGestureDetector (flickGestureDetector); }
/// <summary> /// On scene load. /// </summary> protected override void Load() { // set assets root and load config if (IsFirstScene) { Assets.AssetsRoot = "../../../../TestAssets"; Game.LoadConfig("config.ini"); } // load assets _cursor = Assets.LoadImage("gfx/cursor.png", ImageFilterMode.Nearest); _treeImage = Assets.LoadImage("gfx/tree.png", ImageFilterMode.Nearest); _dirtImage = Assets.LoadImage("gfx/dirt.png", ImageFilterMode.Nearest); _font = Assets.LoadFont("gfx/OpenSans-Regular.ttf", 22, false); _fontBig = Assets.LoadFont("gfx/OpenSans-Regular.ttf", 42, false); // get window size _windowSize = Gfx.WindowSize; // create empty texture to draw on _targetTexture = Assets.CreateEmptyImage(_windowSize); // create trees for (var i = 0; i < 55; ++i) { CreateTestSprite(); } // sort trees by y position so it will look like there's depth _sprites.Sort((Sprite a, Sprite b) => (int)(a.Position.Y - b.Position.Y)); }
public void ShouldShowAllAssets() { var imageAsset = new ImageAsset { Title = "Image" }; var videoAsset = new VideoAsset { Title = "Video" }; var audioAsset = new AudioAsset { Title = "Audio" }; var assets = new List <Asset> { imageAsset, videoAsset, audioAsset }; var presentationModel = this.CreatePresentationModel(); this.assetsAvailableEvent.SubscribeArgumentAction.Invoke(new Infrastructure.DataEventArgs <List <Asset> >(assets)); presentationModel.ShowImages = false; presentationModel.ShowVideos = false; presentationModel.ShowAudio = false; Assert.AreEqual(0, presentationModel.Assets.Count); presentationModel.ShowImages = true; presentationModel.ShowVideos = true; presentationModel.ShowAudio = true; Assert.AreEqual(3, presentationModel.Assets.Count); }
/// <summary> /// Loads an image asset. /// </summary> /// <param name="path">Image path.</param> /// <param name="filter">Image filtering mode.</param> /// <param name="useCache">Should we use cache for this asset to make future loadings faster?</param> /// <param name="useAssetsRoot">If true, path will be relative to 'AssetsRoot'. If false, will be relative to working directory.</param> /// <returns>Loaded image asset.</returns> public ImageAsset LoadImage(string path, ImageFilterMode filter = ImageFilterMode.Nearest, bool useCache = true, bool useAssetsRoot = true) { var ret = new ImageAsset(_BonEngineBind.BON_Assets_LoadImage(ToAssetsPath(path, true, useAssetsRoot), (int)filter, useCache)); ret.Path = path; return(ret); }
/// <summary> /// Draws an image on screen. /// </summary> /// <param name="image">Image to draw.</param> /// <param name="position">Drawing position.</param> /// <param name="size">Drawing size.</param> /// <param name="blend">Blend mode.</param> /// <param name="sourceRect">Source rectangle to draw.</param> /// <param name="origin">Rotation and source position origin (relative to size).</param> /// <param name="rotation">Rotation, in degrees.</param> /// <param name="color">Tint color.</param> public void DrawImage(ImageAsset image, PointF position, PointI size, BlendModes blend, RectangleI sourceRect, PointF origin, float rotation, Color color) { if (!image.HaveHandle) { throw new Exception("Tried to render an image without handle!"); } _BonEngineBind.BON_Gfx_DrawImageEx(image._handle, position.X, position.Y, size.X, size.Y, (int)blend, sourceRect.X, sourceRect.Y, sourceRect.Width, sourceRect.Height, origin.X, origin.Y, rotation, color.R, color.G, color.B, color.A); }
/// <summary> /// Draws an image on screen. /// </summary> /// <param name="image">Image to draw.</param> /// <param name="position">Drawing position.</param> /// <param name="size">Drawing size.</param> /// <param name="blend">Blend mode.</param> public void DrawImage(ImageAsset image, PointF position, PointI size, BlendModes blend = BlendModes.AlphaBlend) { if (!image.HaveHandle) { throw new Exception("Tried to render an image without handle!"); } _BonEngineBind.BON_Gfx_DrawImage(image._handle, position.X, position.Y, size.X, size.Y, (int)blend); }
public static void CreateMenuScene(Game game) { var jouer_entity = new Entity(true); jouer_entity.Name = "jouer"; jouer_entity.Transform.x = 300; jouer_entity.Transform.y = 200; var jouer_cmp = new Engine.System.UI.ImageButtonComponent(jouer_entity); var jouer_img_asset = new Engine.System.UI.ImageAsset(); jouer_img_asset.ContentName = "bouton_jouer"; jouer_cmp.onclick.action = (entity, context) => { Embed.LoadScene("game_scene", Engine.Core.Game.Instance); }; jouer_cmp.AddAsset(jouer_img_asset); jouer_entity.AddComponent(jouer_cmp); var quitter_entity = new Entity(true); quitter_entity.Name = "quitter"; quitter_entity.Transform.x = 288; quitter_entity.Transform.y = 275; var quitter_cmp = new ImageButtonComponent(quitter_entity); var quitter_img_asset = new ImageAsset(); quitter_img_asset.ContentName = "bouton_quitter"; quitter_cmp.AddAsset(quitter_img_asset); jouer_cmp.onclick.contextRefs = null; quitter_cmp.onclick.action = (entity, context) => { Game.Instance.Exit(); }; quitter_entity.AddComponent(quitter_cmp); var text_entity = new Entity(true); text_entity.Name = "text"; text_entity.Transform.x = 230; text_entity.Transform.y = 100; var text_cmp = new UITextComponent(text_entity); text_cmp.Text = "Makers² : le jeu démo !"; text_cmp.Color = new Vector4(0, 0, 0, 1); text_cmp.FontSize = 36; var font_asset = new FontAsset(); font_asset.ContentName = "coolvetica"; text_cmp.AddAsset(font_asset); text_entity.AddComponent(text_cmp); var save_manager = new SavedFilesManager(Manager.Instance); var PreSave = new List <Entity> { jouer_entity, quitter_entity, text_entity }; var scene = new SavedScene(); scene.entities = PreSave; save_manager.SaveScene(scene, "menu_scene"); }
public void ImageAsset_InitializeWithFile_ButDoNotLoad_VerifyEmptyFields() { var sut = new ImageAsset(testFileSystem, testFileSystem.Path.Combine(mockFolderParth, TestJpegFile1FileName)); sut.Should().NotBeNull(); sut.Title.Should().Be(string.Empty); sut.Description.Should().Be(string.Empty); sut.Keywords.Should().BeEquivalentTo(new List <string>()); }
public ImageAssetDto(ImageAsset imageAsset) { Id = imageAsset.Id; CreationDate = imageAsset.CreationDate; Name = imageAsset.Name; ContentType = imageAsset.ContentType; Guid = imageAsset.Guid; FolderId = imageAsset.FolderId; }
// load the scene protected override void Load() { // init sprites _background = Assets.LoadImage("gfx/forest_scene.png"); _cursor = Assets.LoadImage("gfx/cursor.png"); // load fonts _font = Assets.LoadFont("gfx/OpenSans-Regular.ttf", 22, false); _fontBig = Assets.LoadFont("gfx/OpenSans-Regular.ttf", 42, false); }
public void ImageAsset_InitializeWithExistingFile_RemoveFileAndTryRead_ExpectException() { var testFile = testFileSystem.Path.Combine(mockFolderParth, TestJpegFile1FileName); var sut = new ImageAsset(testFileSystem, testFile); sut.Should().NotBeNull(); sut.Title.Should().Be(string.Empty); this.testFileSystem.RemoveFile(testFile); Assert.Throws <FileNotFoundException>(() => sut.ReadMetaData()); }
XElement FromImageAsset(ImageAsset asset) { return(new XElement( nameof(ImageAsset), new XAttribute(nameof(asset.Id), asset.Id), new XAttribute(nameof(asset.Width), asset.Width), new XAttribute(nameof(asset.Height), asset.Height), new XAttribute(nameof(asset.Path), asset.Path), new XAttribute(nameof(asset.FileName), asset.FileName))); }
/// <summary> /// Initializes a new instance of the <see cref="ImagePreview"/> class. /// </summary> /// <param name="asset">The asset.</param> public ImagePreview(ImageAsset asset) { InitializeComponent(); if (asset == null) { throw new ArgumentNullException("asset"); } this.DataContext = asset; }
// [END add_smart_display_ad_4] /// <summary> /// Uploads the image asset. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID for which the call is made.</param> /// <param name="imageUrl">The image URL.</param> /// <param name="width">The image width in pixels.</param> /// <param name="height">The image height in pixels.</param> /// <param name="imageName">Name of the image asset.</param> /// <returns>The resource name of the asset.</returns> // [START add_smart_display_ad_3] private static string UploadImageAsset(GoogleAdsClient client, long customerId, string imageUrl, long width, long height, string imageName) { // Get the AssetServiceClient. AssetServiceClient assetService = client.GetService(Services.V10.AssetService); // Creates an image content. byte[] imageContent = MediaUtilities.GetAssetDataFromUrl(imageUrl, client.Config); // Creates an image asset. ImageAsset imageAsset = new ImageAsset() { Data = ByteString.CopyFrom(imageContent), FileSize = imageContent.Length, MimeType = MimeType.ImageJpeg, FullSize = new ImageDimension() { HeightPixels = height, WidthPixels = width, Url = imageUrl } }; // Creates an asset. Asset asset = new Asset() { // Optional: Provide a unique friendly name to identify your asset. // If you specify the name field, then both the asset name and the image being // uploaded should be unique, and should not match another ACTIVE asset in this // customer account. // Name = 'Jupiter Trip #' + ExampleUtilities.GetRandomString(), Type = AssetType.Image, ImageAsset = imageAsset, Name = imageName }; // Creates an asset operation. AssetOperation operation = new AssetOperation() { Create = asset }; // Issues a mutate request to add the asset. MutateAssetsResponse response = assetService.MutateAssets(customerId.ToString(), new[] { operation }); string assetResourceName = response.Results.First().ResourceName; // Print out some information about the added asset. Console.WriteLine($"Added asset with resource name = '{assetResourceName}'."); return(assetResourceName); }
public async Task <int> UpdateAsync(ImageAsset asset, int userID) { const string sql = @"UPDATE SET FileName = @FileName, ContentType = @ContentType, Height = @Height, Width = @Width, AltText = @AltText, Title = @Title WHERE ID = @ID"; using (IDbConnection db = new SqliteConnection(_connectionString)) { return(await db.ExecuteAsync(sql, new { ID = asset.ID, FileName = asset.FileName, ContentType = asset.ContentType, Height = asset.Height, Width = asset.Width, AltText = asset.AltText, Title = asset.Title })); } }
// load the scene protected override void Load() { // set fullscreen // note: only works when there are no loaded assets. Gfx.SetWindowProperties("BonEngine Windowed Fullscreen", 0, 0, WindowModes.WindowedBorderless, false); // load fonts _font = Assets.LoadFont("gfx/OpenSans-Regular.ttf", 22, false); _fontBig = Assets.LoadFont("gfx/OpenSans-Regular.ttf", 42, false); _cursor = Assets.LoadImage("gfx/cursor.png", ImageFilterMode.Nearest); }
YamlObject FromImageAsset(ImageAsset asset) { return(new YamlMap { { "Id", asset.Id }, { "Width", asset.Width }, { "Height", asset.Height }, { "Path", asset.Path }, { "Filename", asset.FileName }, }); }
/// <summary> /// Runs the code example. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The customer ID for which the call is made.</param> public void Run(GoogleAdsClient client, long customerId) { // Get the GoogleAdsServiceClient. GoogleAdsServiceClient googleAdsService = client.GetService(Services.V3.GoogleAdsService); // Creates the search query. string searchQuery = "SELECT asset.name, asset.image_asset.file_size, " + "asset.image_asset.full_size.width_pixels, " + "asset.image_asset.full_size.height_pixels, " + "asset.image_asset.full_size.url FROM asset WHERE asset.type = 'IMAGE'"; // Creates the request. SearchGoogleAdsRequest request = new SearchGoogleAdsRequest() { CustomerId = customerId.ToString(), Query = searchQuery }; try { // Issues the search request and prints the results. int count = 0; foreach (GoogleAdsRow row in googleAdsService.Search(request)) { Asset asset = row.Asset; ImageAsset imageAsset = asset.ImageAsset; // Displays the results. Console.WriteLine($"Image with name '{asset.Name}', file size " + $"{imageAsset.FileSize} bytes, width {imageAsset.FullSize.WidthPixels}px," + $" height {imageAsset.FullSize.HeightPixels}px, and url " + $"'{imageAsset.FullSize.Url}' found."); count++; } if (count == 0) { // Displays a response if no images are found. if (count == 0) { Console.WriteLine("No image assets found."); } } } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
static TestResultDetail() { _failureImageAsset = Resources.GetImageAsset("VitaUnit.assets.vitaunit_failure.png"); _successImageAsset = Resources.GetImageAsset("VitaUnit.assets.vitaunit_success.png"); }
protected override void DisposeSelf() { if (this.activeImage != null) { this.activeImage.Dispose (); this.activeImage = null; } if (this.normalImage != null) { this.normalImage.Dispose (); this.normalImage = null; } base.DisposeSelf (); }
public static void Initialize () { // Set up the graphics system graphics = new GraphicsContext (); UISystem.Initialize(graphics); // Initiliaze a new scene scene = new Scene(); // Build a play button Button play_btn = new Button(); play_btn.X = 50f; play_btn.Y = 50f; play_btn.Width = 50f; play_btn.Height = 50f; play_btn.ButtonAction += HandlePlay_btnButtonAction; CustomButtonImageSettings play_btn_bg = new CustomButtonImageSettings(); ImageAsset play_image = new ImageAsset("play.png"); play_btn_bg.BackgroundNormalImage = play_image; play_btn_bg.BackgroundDisabledImage = play_image; play_btn_bg.BackgroundPressedImage = play_image; play_btn.CustomImage = play_btn_bg; play_btn.Style = ButtonStyle.Custom; // Add the button to the scene scene.RootWidget.AddChildFirst(play_btn); // Build a Pause button Button pause_btn = new Button(); pause_btn.X = 120f; pause_btn.Y = 50f; pause_btn.Width = 50f; pause_btn.Height = 50f; pause_btn.ButtonAction += HandlePause_btnButtonAction; CustomButtonImageSettings pause_btn_bg = new CustomButtonImageSettings(); ImageAsset pause_image = new ImageAsset("pause.png"); pause_btn_bg.BackgroundNormalImage = pause_image; pause_btn_bg.BackgroundDisabledImage = pause_image; pause_btn_bg.BackgroundPressedImage = pause_image; pause_btn.CustomImage = pause_btn_bg; pause_btn.Style = ButtonStyle.Custom; // Add the button to the scene scene.RootWidget.AddChildFirst(pause_btn); // Build a Stop button Button stop_btn = new Button(); stop_btn.X = 190f; stop_btn.Y = 50f; stop_btn.Width = 50f; stop_btn.Height = 50f; stop_btn.ButtonAction += HandleStop_btnButtonAction; CustomButtonImageSettings stop_btn_bg = new CustomButtonImageSettings(); ImageAsset stop_image = new ImageAsset("stop.png"); stop_btn_bg.BackgroundNormalImage = stop_image; stop_btn_bg.BackgroundDisabledImage = stop_image; stop_btn_bg.BackgroundPressedImage = stop_image; stop_btn.CustomImage = stop_btn_bg; stop_btn.Style = ButtonStyle.Custom; // Add the button to the scene scene.RootWidget.AddChildFirst(stop_btn); // Set the scene UISystem.SetScene(scene, null); }