public ImageLinkSimpleX(AggRenderer renderer, string imageUrl, string linkUrl = null) { this.HAnchor = HAnchor.Stretch; this.VAnchor = VAnchor.Fit; this.Selectable = false; this.ImageUrl = imageUrl; this.LinkUrl = linkUrl; this.aggRenderer = renderer; if (linkUrl != null) { this.Selectable = true; } imageSequence = new ImageSequence(icon); // var sequenceWidget = new ImageSequenceWidget(imageSequence); var sequenceWidget = new ResponsiveImageSequenceWidget(imageSequence) { Cursor = Cursors.Hand, }; sequenceWidget.Click += SequenceWidget_Click; this.AddChild(sequenceWidget); }
protected override object CreateResourceConfiguration(string fileName) { var extension = Path.GetExtension(fileName); fileName = PathConvert.GetProjectPath(fileName); Texture2D configuration; if (Array.IndexOf(VideoExtensions, extension) >= 0) { if (Control.ModifierKeys == Keys.Control) { configuration = new ImageSequence { FileName = fileName } } ; else { configuration = new VideoTexture { FileName = fileName } }; } else { configuration = new ImageTexture { FileName = fileName } }; configuration.Name = Path.GetFileNameWithoutExtension(fileName); return(configuration); } }
/// <summary> /// Creates image sequences for given order reading trajectories /// if they are missing in database. /// </summary> /// <param name="matterIds"> /// Matters ids. /// </param> /// <param name="notations"> /// notations of images. /// </param> /// <param name="imageOrderExtractors"> /// Reading trajectories. /// </param> private void CreateMissingImageSequences(long[] matterIds, Notation[] notations, ImageOrderExtractor?[] imageOrderExtractors) { if (notations[0].GetNature() == Nature.Image) { var existingSequences = Db.ImageSequences .Where(s => matterIds.Contains(s.MatterId) && notations.Contains(s.Notation) && imageOrderExtractors.Contains(s.OrderExtractor)) .ToList(); ImageSequenceRepository imageSequenceRepository = new ImageSequenceRepository(); for (int i = 0; i < matterIds.Length; i++) { for (int j = 0; j < notations.Length; j++) { if (!existingSequences.Any(s => s.MatterId == matterIds[i] && s.Notation == notations[j] && s.OrderExtractor == imageOrderExtractors[j])) { var newImageSequence = new ImageSequence() { MatterId = matterIds[i], Notation = notations[j], OrderExtractor = imageOrderExtractors[j] ?? ImageOrderExtractor.LineLeftToRightTopToBottom }; imageSequenceRepository.Create(newImageSequence, Db); existingSequences.Add(newImageSequence); } } } Db.SaveChanges(); } }
public ResponsiveImageSequenceWidget(ImageSequence initialSequence) { HAnchor = HAnchor.Stretch; ImageSequence = initialSequence; MaximumSize = new Vector2(initialSequence.Width * GuiWidget.DeviceScale, initialSequence.Height * GuiWidget.DeviceScale); if (ImageSequence != null) { ImageSequence.Invalidated += ImageChanged; } animation.DrawTarget = this; animation.Update += (s, updateEvent) => { var currentImageIndex = ImageSequence.GetImageIndexByTime(currentTime); currentTime += updateEvent.SecondsPassed; while (ImageSequence.Time > 0 && currentTime > ImageSequence.Time) { currentTime -= ImageSequence.Time; } var newImageIndex = ImageSequence.GetImageIndexByTime(currentTime); updateEvent.ShouldDraw = currentImageIndex != newImageIndex; }; AnimationRunning = true; }
public ImageLinkSimpleX(string url) { this.HAnchor = HAnchor.Fit; this.VAnchor = VAnchor.Fit; this.Selectable = false; this.Url = url; if (true) { var imageSequence = new ImageSequence(icon); var sequenceWidget = new ImageSequenceWidget(imageSequence); this.AddChild(sequenceWidget); if (url.StartsWith("http")) { ApplicationController.Instance.DownloadToImageSequenceAsync(imageSequence, url); } } else { var imageBuffer = new ImageBuffer(icon); var imageWidget = new ImageWidget(imageBuffer); this.AddChild(imageWidget); if (url.StartsWith("http")) { ApplicationController.Instance.DownloadToImageAsync(imageBuffer, url, false); } } }
public ResponsiveImageSequenceWidget(ImageSequence initialSequence) { HAnchor = HAnchor.Stretch; ImageSequence = initialSequence; if (ImageSequence != null) { ImageSequence.Invalidated += ImageChanged; } animation.DrawTarget = this; animation.Update += (s, updateEvent) => { var currentImageIndex = ImageSequence.GetImageIndexByTime(currentTime); currentTime += updateEvent.SecondsPassed; while (ImageSequence.Time > 0 && currentTime > ImageSequence.Time) { currentTime -= ImageSequence.Time; } var newImageIndex = ImageSequence.GetImageIndexByTime(currentTime); updateEvent.ShouldDraw = currentImageIndex != newImageIndex; }; RunAnimation = true; }
public HowManyPlayersMenu(RectangleDouble bounds) { BoundsRelativeToParent = bounds; ImageSequence onePlayerButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "OnePlayerButton"); Button onePlayerGameButton = new Button(270, 310, new ButtonViewThreeImage(onePlayerButtonSequence.GetImageByIndex(0), onePlayerButtonSequence.GetImageByIndex(1), onePlayerButtonSequence.GetImageByIndex(2))); AddChild(onePlayerGameButton); onePlayerGameButton.Click += OnStartOnePlayerGameButton; ImageSequence twoPlayerButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "TwoPlayerButton"); Button twoPlayerGameButton = new Button(400, 310, new ButtonViewThreeImage(twoPlayerButtonSequence.GetImageByIndex(0), twoPlayerButtonSequence.GetImageByIndex(1), twoPlayerButtonSequence.GetImageByIndex(2))); AddChild(twoPlayerGameButton); twoPlayerGameButton.Click += OnStartTwoPlayerGameButton; ImageSequence fourPlayerButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "FourPlayerButton"); Button fourPlayerGameButton = new Button(530, 310, new ButtonViewThreeImage(fourPlayerButtonSequence.GetImageByIndex(0), fourPlayerButtonSequence.GetImageByIndex(1), fourPlayerButtonSequence.GetImageByIndex(2))); AddChild(fourPlayerGameButton); fourPlayerGameButton.Click += OnStartFourPlayerGameButton; ImageSequence cancelButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "NumPlayersCancelButton"); Button cancelGameButton = new Button(400, 210, new ButtonViewThreeImage(cancelButtonSequence.GetImageByIndex(0), cancelButtonSequence.GetImageByIndex(1), cancelButtonSequence.GetImageByIndex(2))); AddChild(cancelGameButton); cancelGameButton.Click += OnCancelMenuButton; }
public SkillVM() { _exclusionListLazy = new Lazy <ListCollectionView>(() => CreateExclusionList()); _icon = new Lazy <BitmapSource>( () => { Aow2.Collections.AowList <ImageSequence> imageData = Model.Icon; if (imageData == null) { return(null); } ImageSequence sequence = imageData.FirstOrDefault(); if (sequence == null) { return(null); } if (sequence.FrameTable.Count == 0) { return(null); } string ilbPath = sequence.ImageLibraryFilename; int index = sequence.FrameTable[0]; return(_imageProvider.GetImage(ilbPath, index)); }); }
private static void DownloadImageAsync(ImageSequence imageSequenceToLoadInto, string uriToLoad, Action doneLoading, ImageSequence asyncImageSequence, string pngFileName, string gifFileName) { WebClient client = new WebClient(); client.DownloadDataCompleted += (object sender, DownloadDataCompletedEventArgs e) => { try // if we get a bad result we can get a target invocation exception. In that case just don't show anything { Task.Run(() => { // scale the loaded image to the size of the target image byte[] raw = e.Result; Stream stream = new MemoryStream(raw); lock (locker) { StaticData.Instance.LoadImageSequenceData(stream, asyncImageSequence); } if (asyncImageSequence.Frames.Count == 1) { // save the as png lock (locker) { if (!File.Exists(pngFileName)) { ImageIO.SaveImageData(pngFileName, asyncImageSequence.Frames[0]); } } } else // save original stream as gif { using (var writter = new FileStream(gifFileName, FileMode.Create)) { stream.Position = 0; stream.CopyTo(writter); } } UiThread.RunOnIdle(() => { imageSequenceToLoadInto.Copy(asyncImageSequence); imageSequenceToLoadInto.Invalidate(); doneLoading?.Invoke(); }); }); } catch { } }; try { client.DownloadDataAsync(new Uri(uriToLoad)); } catch { } }
public override void OnDraw(RendererBase rendererToDrawWith) { ImageSequence menuBackground = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "CreditsScreen"); rendererToDrawWith.Render(menuBackground.GetImageByIndex(0), 0, 0); base.OnDraw(rendererToDrawWith); }
public override void OnDraw(Graphics2D graphics2D) { ImageSequence menuBackground = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "CreditsScreen"); graphics2D.Render(menuBackground.GetImageByIndex(0), 0, 0); base.OnDraw(graphics2D); }
private string CreateOutputFilePath(ImageSequence sequence, UmmConfig config) { var outputFileName = UmmApp.Instance.CreateOutputFileName(CreateOutputFileName(sequence.FirstImageName, sequence.Type)); var outputFilePath = Path.Combine(config.OutputAllFilesToSameFolder ? config.OutputFolderPath : Path.GetDirectoryName(_folderPath), outputFileName); outputFilePath = UmmApp.Instance.ValidateAndFixOutputFilePath(outputFilePath); return(outputFilePath); }
public CreditsMenu(RectangleDouble bounds) { BoundsRelativeToParent = bounds; ImageSequence cancelButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "NumPlayersCancelButton"); Button cancelGameButton = new Button(400, 200, new ButtonViewThreeImage(cancelButtonSequence.GetImageByIndex(0), cancelButtonSequence.GetImageByIndex(1), cancelButtonSequence.GetImageByIndex(2))); AddChild(cancelGameButton); cancelGameButton.Click += OnCancelMenuButton; }
public CreditsMenu(rect_d bounds) { Bounds = bounds; ImageSequence cancelButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "NumPlayersCancelButton"); ButtonWidget cancelGameButton = new ButtonWidget(400, 200, new ThreeImageButtonView(cancelButtonSequence.GetImageByIndex(0), cancelButtonSequence.GetImageByIndex(1), cancelButtonSequence.GetImageByIndex(2))); AddChild(cancelGameButton); cancelGameButton.ButtonClick += new ButtonWidget.ButtonEventHandler(OnCancelMenuButton); }
public PlayfieldView(RectangleDouble bounds) { BoundsRelativeToParent = bounds; ImageSequence menuButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MenuButtonFromGame"); Button menuButton = new Button(400, 12, new ButtonViewThreeImage(menuButtonSequence.GetImageByIndex(0), menuButtonSequence.GetImageByIndex(1), menuButtonSequence.GetImageByIndex(2))); AddChild(menuButton); menuButton.Click += EscapeMenu; }
public override void OnDraw(Graphics2D graphics2D) { ImageSequence background = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "GameBackground"); graphics2D.Render(background.GetImageByIndex(0), 0, 0); m_Playfield.Draw(graphics2D); base.OnDraw(graphics2D); }
public override void Update(double numSecondsPassed) { ImageSequence rockShip = GetImageSequence(); playRatio += (numSecondsPassed * rockShip.FramePerSecond) / rockShip.NumFrames; if (playRatio > 1) { playRatio = 0; } base.Update(numSecondsPassed); }
public void Create(ImageSequence sequence, LibiadaWebEntities db) { if (sequence.Id == default) { sequence.Id = db.GetNewElementId(); } var parameters = new List <NpgsqlParameter> { new NpgsqlParameter <long>("id", NpgsqlDbType.Bigint) { TypedValue = sequence.Id }, new NpgsqlParameter <byte>("notation", NpgsqlDbType.Smallint) { TypedValue = (byte)sequence.Notation }, new NpgsqlParameter <long>("matter_id", NpgsqlDbType.Bigint) { TypedValue = sequence.MatterId }, new NpgsqlParameter <byte[]>("image_transformations", NpgsqlDbType.Array | NpgsqlDbType.Smallint) { TypedValue = Array.Empty <byte>() }, new NpgsqlParameter <byte[]>("matrix_transformations", NpgsqlDbType.Array | NpgsqlDbType.Smallint) { TypedValue = Array.Empty <byte>() }, new NpgsqlParameter <byte>("order_extractor", NpgsqlDbType.Smallint) { TypedValue = (byte)sequence.OrderExtractor }, }; const string Query = @"INSERT INTO image_sequence ( id, notation, matter_id, image_transformations, matrix_transformations, order_extractor ) VALUES ( @id, @notation, @matter_id, @image_transformations, @matrix_transformations, @order_extractor );"; db.ExecuteCommand(Query, parameters.ToArray()); }
private List <ImageSequence> SplitSequences(string[] filePaths) { var sequences = new List <ImageSequence>(); for (var i = 0; i < filePaths.Length;) { var fileNameI = Path.GetFileName(filePaths[i]).ToLower(); var regExString = CreateSequenceRegExString(fileNameI); var sequenceRegEx = new Regex(regExString, RegexOptions.Compiled); var imagePaths = new List <string>(); imagePaths.Add(filePaths[i]); for (var j = i + 1; j < filePaths.Length; ++j) { var fileNameJ = Path.GetFileName(filePaths[j]).ToLower(); if (sequenceRegEx.IsMatch(fileNameJ)) { imagePaths.Add(filePaths[j]); i = j; } else { i = j; break; } } if (imagePaths.Count == 1) { continue; } var firstImageName = fileNameI; var sequence = new ImageSequence(); var hasDepth = firstImageName.Contains(".depth."); var hasStencil = firstImageName.Contains(".stencil."); var sequenceType = hasDepth ? ImageType.Depth : (hasStencil ? ImageType.Stencil : ImageType.Normal); sequence.FirstImageName = firstImageName; sequence.ImageFilePaths.AddRange(imagePaths); sequence.ImageSequencePath = CreateMEncoderSequenceString(firstImageName); sequence.ImageSequenceRegEx = regExString; sequence.Monochrome = hasDepth || hasStencil; sequence.Type = sequenceType; sequences.Add(sequence); if (i == filePaths.Length - 1) { break; } } return(sequences); }
public virtual bool LoadImageData(String pathToGifFile, ImageSequence destImageSequence) { if (File.Exists(pathToGifFile)) { using (Stream stream = new StreamReader(pathToGifFile).BaseStream) { return(LoadImageData(stream, destImageSequence)); } } return(false); }
public override void OnDraw(RendererBase rendererToDrawWith) { ImageSequence menuBackground = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MainMenuBackground"); rendererToDrawWith.Render(menuBackground.GetImageByIndex(0), 0, 0); ImageSequence planetOnMenu = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "PlanetOnMenu"); rendererToDrawWith.Render(planetOnMenu.GetImageByRatio(planetRatio.Read()), 620, 360); base.OnDraw(rendererToDrawWith); }
public void LoadImageSequenceData(Stream stream, ImageSequence sequence) { lock (locker) { System.Drawing.Image image; try { image = System.Drawing.Image.FromStream(stream); } catch { return; } sequence.Frames.Clear(); sequence.FrameTimesMs.Clear(); var dimension = new System.Drawing.Imaging.FrameDimension(image.FrameDimensionsList[0]); // Number of frames int frameCount = image.GetFrameCount(dimension); if (frameCount > 1) { var minFrameTimeMs = int.MaxValue; for (var i = 0; i < frameCount; i++) { // Return an Image at a certain index image.SelectActiveFrame(dimension, i); ImageBuffer imageBuffer = new ImageBuffer(); if (ImageIOWindowsPlugin.ConvertBitmapToImage(imageBuffer, new Bitmap(image))) { var frameDelay = BitConverter.ToInt32(image.GetPropertyItem(20736).Value, i * 4) * 10; sequence.AddImage(imageBuffer, frameDelay); minFrameTimeMs = Math.Max(10, Math.Min(frameDelay, minFrameTimeMs)); } } var item = image.GetPropertyItem(0x5100); // FrameDelay in libgdiplus // Time is in milliseconds sequence.SecondsPerFrame = minFrameTimeMs / 1000.0; } else { ImageBuffer imageBuffer = new ImageBuffer(); if (ImageIOWindowsPlugin.ConvertBitmapToImage(imageBuffer, new Bitmap(image))) { sequence.AddImage(imageBuffer); } } } }
private string CreateOutputFileName(ImageSequence sequence, int sequenceIndex) { var demoName = Path.GetFileName(_folderPath); var cutName = "timeunknown"; var type = sequence.Type == ImageType.Colour ? "colour" : "depth"; var underscoreIdx = sequence.DemoCutFolderName.IndexOf('_'); if (underscoreIdx >= 0 && underscoreIdx < sequence.DemoCutFolderName.Length - 1) { cutName = sequence.DemoCutFolderName.Substring(0, underscoreIdx); } return(demoName + "_" + cutName + "_" + type + ".avi"); }
public ImageLinkSimpleX(string url) { this.HAnchor = HAnchor.Stretch; this.VAnchor = VAnchor.Fit; this.Selectable = false; this.Url = url; imageSequence = new ImageSequence(icon); //var sequenceWidget = new ImageSequenceWidget(imageSequence); var sequenceWidget = new ResponsiveImageSequenceWidget(imageSequence); this.AddChild(sequenceWidget); }
public void LoadProgram(RunWorkerCompletedEventHandler onComplete) { ImageSequence imageSequence = new ImageSequence(Path.Join(Environment.CurrentDirectory, "Animations", "Loading")); View = imageSequence; worker = new BackgroundWorker(); worker.DoWork += (s, a) => { menuFont = BDFFont.LoadFont5x7(); LoadProgramAsync(); }; worker.RunWorkerCompleted += onComplete; worker.RunWorkerAsync(); }
public PlayfieldView(rect_d bounds) { Bounds = bounds; backgroundImageSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "Map1Background"); backgroundImage = backgroundImageSequence.GetImageByIndex(0); ImageSequence menuButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MenuButtonFromGame"); ButtonWidget menuButton = new ButtonWidget(400, 12, new ThreeImageButtonView(menuButtonSequence.GetImageByIndex(0), menuButtonSequence.GetImageByIndex(1), menuButtonSequence.GetImageByIndex(2))); AddChild(menuButton); menuButton.ButtonClick += new ButtonWidget.ButtonEventHandler(EscapeMenu); playerViews[0] = new PlayerView(new rect_d(400, 300, 800, 600)); playerViews[1] = new PlayerView(new rect_d(400, 0, 800, 300)); playerViews[2] = new PlayerView(new rect_d(0, 300, 400, 600)); playerViews[3] = new PlayerView(new rect_d(0, 0, 400, 300)); }
public Form1() { InitializeComponent(); target = new BPMInfo(TargetBPMTextBox, TargetDelay, ResetTargetBPM, MeasureTargetBPM); sequence = new BPMInfo(ImageBPMTextBox, ImageDelay, ResetImageBPM, MeasureImageBPM); images = new ImageSequence(Location, SelectLocation, folderBrowserDialog1, Prefix, Interfix, Suffix, BeginFrame, EndFrame, FPS, Frames, pictureBox1, Load, this); MaximizeBox = false; //this.ControlBox = false; //this.FormBorderStyle = FormBorderStyle.FixedToolWindow; this.ShowIcon = false; this.KeyPreview = true; this.KeyUp += Form1_KeyUp; Measure(); }
public ImageSequenceWidget(int width, int height) { LocalBounds = new RectangleDouble(0, 0, width, height); animation.DrawTarget = this; animation.Update += (s, updateEvent) => { var currentImageIndex = ImageSequence.GetImageIndexByTime(currentTime); currentTime += updateEvent.SecondsPassed; while (ImageSequence.Time > 0 && currentTime > ImageSequence.Time) { currentTime -= ImageSequence.Time; } var newImageIndex = ImageSequence.GetImageIndexByTime(currentTime); updateEvent.ShouldDraw = currentImageIndex != newImageIndex; }; RunAnimation = true; }
public MainMenu(RectangleDouble bounds) { BoundsRelativeToParent = bounds; ImageSequence startButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MainMenuStartButton"); Button StartGameButton = new Button(400, 310, new ButtonViewThreeImage(startButtonSequence.GetImageByIndex(0), startButtonSequence.GetImageByIndex(1), startButtonSequence.GetImageByIndex(2))); AddChild(StartGameButton); StartGameButton.Click += OnStartGameButton; ImageSequence creditsButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MainMenuCreditsButton"); Button creditsGameButton = new Button(400, 230, new ButtonViewThreeImage(creditsButtonSequence.GetImageByIndex(0), creditsButtonSequence.GetImageByIndex(1), creditsButtonSequence.GetImageByIndex(2))); AddChild(creditsGameButton); creditsGameButton.Click += OnShowCreditsButton; ImageSequence exitButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MainMenuExitButton"); Button exitGameButton = new Button(400, 170, new ButtonViewThreeImage(exitButtonSequence.GetImageByIndex(0), exitButtonSequence.GetImageByIndex(1), exitButtonSequence.GetImageByIndex(2))); AddChild(exitGameButton); exitGameButton.Click += OnExitGameButton; }
public void LoadSequence(string pathToImages, ImageSequence sequence) { if (DirectoryExists(pathToImages)) { string propertiesPath = Path.Combine(pathToImages, "properties.json"); if (FileExists(propertiesPath)) { string jsonData = ReadAllText(propertiesPath); var properties = JsonConvert.DeserializeObject <ImageSequence.Properties>(jsonData); sequence.FramePerSecond = properties.FramePerFrame; sequence.Looping = properties.Looping; } var pngFiles = GetFiles(pathToImages).Where(fileName => Path.GetExtension(fileName).ToUpper() == ".PNG").OrderBy(s => s); foreach (string path in pngFiles) { ImageBuffer image = LoadImage(path); sequence.AddImage(image); } } }