Пример #1
0
 private void LoadingComplete(object sender, EventArgs e)
 {
     if (Proxy == null)
     {
         return;
     }
     if (IsGif = Proxy.IsGif)
     {
         if (RealImageGif == null)
         {
             RealImageGif = new AnimatedImage {
                 Stretch = Stretch.Uniform
             }
         }
         ;
         imageArea.Content   = RealImageGif;
         RealImageGif.Source = Proxy.GifImage;
     }
     else
     {
         if (RealImage == null)
         {
             RealImage = new Image {
                 Stretch = Stretch.Uniform
             }
         }
         ;
         imageArea.Content = RealImage;
         RealImage.Source  = Proxy.Image;
     }
     ImageHolder.Visibility = Visibility.Collapsed;
     FailedFlag.Visibility  = Visibility.Collapsed;
 }
Пример #2
0
 public void Draw(Vector2 position)
 {
     if (m_enabled)
     {
         AnimatedImage?.Draw(position);
     }
 }
Пример #3
0
        public void NewAnimated_Returns_PageAndImage()
        {
            var stub = new Stubs.PageSelectorStub
            {
                DontThrowNotImpl = true,
                Result           = null         //в этом тесте новых страниц нет, поэтому первый селектор вернет null
            };

            IPageSelector pageSelectorForNewPages = stub;

            //а главную "роль" в тесте исполнит селектор новых аним.изображений - он должен вернуть
            AnimatedImage animatedImage = new AnimatedImage
            {
                BlobName  = "code-geass:img1.gif",
                TweetDate = null                 //гифка новая даты твита не должно быть
            };

            var animNewStub = new Stubs.AnimatedSelectorStub
            {
                DontThrowNotImpl = true,
                Result           = new AnimatedImage[] { animatedImage }       //стаб вернет этот результат
            };

            IFindAnimatedByPage animatedSelectorForNewImages = animNewStub;

            //в этом тесте ожидается работа стаба FindPageByBlobNameStub - он должен "найти" страницу по имени блоба
            SitePage page = new SitePage
            {
                URL = "https://dummy/code-geass"
            };

            var findPageByBlob = new Stubs.FindPageByBlobNameStub
            {
                DontThrowNotImpl = true,
                Result           = page
            };

            //имитируем найденную страницу...
            IFindPageByBlobName findPageByBlobName = findPageByBlob;

            IPageSelector                    pageSelectorForAnyPages         = new Stubs.PageSelectorStub();
            IFindAnimatedByPage              findAnimatedByPage              = new Stubs.FindAnimatedByPageStub();
            IPageOrExternalImageSelector     pageOrExternalImageSelector     = new Stubs.PageOrExternalImageSelectorStub();
            IAnimatedSelectorWithExcludeLast animatedSelectorWithExcludeLast = new Stubs.AnimatedSelectorWithExcludeLastStub();

            var pageForTwittingSelector = new kawaii.twitter.core.SelectLogic.PageForTwittingSelector(pageSelectorForNewPages, animatedSelectorForNewImages, pageSelectorForAnyPages, findAnimatedByPage, pageOrExternalImageSelector, animatedSelectorWithExcludeLast, new TweetCreator.Stubs.Logger());

            TwittData result = pageForTwittingSelector.GetPageForTwitting().Result;

            //проверяем что он вернул
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Page);
            Assert.IsNotNull(result.Image);

            //для поиска должны передать строго то имя блоба, что мы предусмотрели тестом
            Assert.IsTrue(findPageByBlob.UsedBlobNameForFind == animatedImage.BlobName);

            Assert.AreSame(page, result.Page);
            Assert.AreSame(animatedImage, result.Image);
        }
Пример #4
0
 public Enemy6(Point p, Map m, Player target) : base(p, 1, 0, target, m, 6, 800)
 {
     image        = new AnimatedImage("e6", Globals.StdFrame, 16, 5);
     respawns     = true;
     respawntime *= 3;
     direction    = GlobalRandom.random.Next(4);
 }
Пример #5
0
        /// <summary>
        /// Sets the screen up (UI components, multimedia content, etc.)
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            SetBackground(ResourceManager.CreateImage("bg_mobile"), Adjustment.CENTER);

            StripAnimation animation = new StripAnimation(1020, 868, 204, 217, 19);
            animation.FramesPerSecond = 40;
            img = ResourceManager.CreateAnimatedImage("ball");

            img.AddAnimation("bounce", animation);
            img.EndedCurrentStripAnimation += new EventHandler(img_EndedCurrentStripAnimation);
            numberPlayed = 0;
            AddComponent(new Label(img), 10, 100);
            Button play = new Button("Play");
            Button stop = new Button("Stop");
            Button pause = new Button("Pause");
            play.Released += new Component.ComponentEventHandler(play_Released);
            stop.Released += new Component.ComponentEventHandler(stop_Released);
            pause.Released += new Component.ComponentEventHandler(pause_Released);

            playNumbers = new Label("0");

            AddComponent(play, 150, 100);
            AddComponent(stop, 150, 150);
            AddComponent(pause, 150, 200);
            AddComponent(playNumbers, 10, 50);
        }
Пример #6
0
        internal static FrameworkElement SnakeControlFactory(SnakeBody snakeHead, double scale)
        {
            AnimatedImage snakeControl;

            //AnimatedImage snakeControl = new AnimatedImage(new List<string>() { "player.png" }, TimeSpan.FromSeconds(1));
            if (snakeHead.BodyType == SnakeBodyType.SnakeBody)
            {
                snakeControl = new AnimatedImage(new List <string>()
                {
                    "snakebody.png"
                }, TimeSpan.FromSeconds(1));
            }
            else
            {
                snakeControl = new AnimatedImage(new List <string>()
                {
                    "snakehead.png"
                }, TimeSpan.FromSeconds(1));
            }

            snakeControl.Width  = snakeHead.Size.Width * scale;
            snakeControl.Height = snakeHead.Size.Height * scale;
            SetCanvasLocation(snakeControl, snakeHead.Location.X * scale, snakeHead.Location.Y * scale);
            return(snakeControl);
        }
Пример #7
0
        public void OnAnimFinish(AnimatedImage image)
        {
            switch (current)
            {
            case 1:
                myMap.AllEnemies.Add(new Enemy1(spawn.SpawnOrigin, myMap, myMap.player));
                break;

            case 2:
                myMap.AllEnemies.Add(new Enemy2(spawn.SpawnOrigin, myMap, myMap.player));
                break;

            case 3:
                myMap.AllEnemies.Add(new Enemy3(spawn.SpawnOrigin, myMap, myMap.player));
                break;

            case 4:
                myMap.AllEnemies.Add(new Enemy4(spawn.SpawnOrigin, myMap, myMap.player));
                break;

            case 5:
                myMap.AllEnemies.Add(new Enemy5(spawn.SpawnOrigin, myMap, myMap.player));
                break;

            case 6:
                myMap.AllEnemies.Add(new Enemy6(spawn.SpawnOrigin, myMap, myMap.player));
                break;
            }
            animRunning = false;
            canSpawn    = true;
            image.reset();
        }
Пример #8
0
        public async Task <IDecodedImage <Bitmap> > DecodeAsync(Stream stream, string path, ImageSource source, ImageInformation imageInformation, TaskParameter parameters)
        {
            var result = new DecodedImage <Bitmap>();
            var helper = new PlatformGifHelper();

            await helper.ReadGifAsync(stream, path, parameters);

            result.IsAnimated = helper.Frames.Count > 1;

            if (result.IsAnimated && Configuration.AnimateGifs)
            {
                result.AnimatedImages = new AnimatedImage <Bitmap> [helper.Frames.Count];

                for (int i = 0; i < helper.Frames.Count; i++)
                {
                    var animatedImage = new AnimatedImage <Bitmap>();
                    animatedImage.Delay      = helper.Frames[i].Delay;
                    animatedImage.Image      = helper.Frames[i].Image;
                    result.AnimatedImages[i] = animatedImage;
                }
            }
            else
            {
                result.IsAnimated = false;
                result.Image      = helper.Frames[0].Image;
            }

            return(result);
        }
Пример #9
0
 private void ModelShipChangedEventHandler(object sender, ShipChangedEventArgs e)
 {
     if (!e.Killed)
     {
         if (e.ShipUpdated is Invader)
         {
             Invader invader = e.ShipUpdated as Invader;
             if (!_invaders.ContainsKey(invader))
             {
                 FrameworkElement invaderControl = InvadersHelper.InvaderControlFactory(invader, Scale);
                 _invaders[invader] = invaderControl;
                 _sprites.Add(invaderControl);
             }
             else
             {
                 FrameworkElement invaderControl = _invaders[invader];
                 InvadersHelper.MoveElement(invaderControl, invader.Location.X, Scale, invader.Location.Y * Scale);
                 InvadersHelper.ResizeElement(invaderControl, invader.Size.Width * Scale, invader.Size.Height * Scale);
             }
         }
         else if (e.ShipUpdated is Player)
         {
             if (_playerFlashing)
             {
                 AnimatedImage playerImage = _playControl as AnimatedImage;
                 _playerFlashing = false;
             }
             if (_playControl == null)
             {
                 FrameworkElement playerControl = InvadersHelper.PlayerControlFactory(player, Scale);
                 _sprites.Add(playerControl);
             }
         }
     }
 }
Пример #10
0
        private unsafe void RCB_EggHatch(uint *bmpAddress, int bmpWidth, int bmpHeight)
        {
            RenderUtils.OverwriteRectangle(bmpAddress, bmpWidth, bmpHeight, RenderUtils.Color(30, 30, 30, 255));

            AnimatedImage.UpdateCurrentFrameForAll();
            _img.DrawOn(bmpAddress, bmpWidth, bmpHeight, _imgX, _imgY);

            switch (_state)
            {
            case State.FadeIn:
            case State.FadeToWhite:
            case State.FadeToHatched:
            case State.FadeOut:
            {
                _fadeTransition.RenderTick(bmpAddress, bmpWidth, bmpHeight);
                return;
            }

            case State.AnEggIsHatchingMsg:
            case State.PkmnHatchedMsg:
            {
                _stringWindow.Render(bmpAddress, bmpWidth, bmpHeight);
                return;
            }
            }
        }
Пример #11
0
        void LoadImagesAsync(string[] files)
        {
            for (int i = 0; i < files.Length; i++)
            {
                if (_images != null)
                {
                    var image = Image.FromFile(files[i]);

                    lock (_images)
                    {
                        _maxImageSize = new Size(
                            Math.Max(_maxImageSize.Width, image.Width),
                            Math.Max(_maxImageSize.Height, image.Height));

                        var animatedImage = new AnimatedImage(
                            this,
                            image,
                            new Point(i % Columns * _maxImageSize.Width, i / Columns * _maxImageSize.Height));

                        _images.Add(animatedImage);
                        animatedImage.BeginAnimation();
                    }
                }
            }
        }
Пример #12
0
        /// <summary>
        /// Sets the screen up (UI components, multimedia content, etc.)
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();
            SetBackground(ResourceManager.CreateImage("Background"), Adjustment.CENTER);

            #region Moi
            aiMoi = ResourceManager.CreateAnimatedImage("MoiWalkingStripAnimation");

            int width = aiMoi.Width;
            int height = aiMoi.Height;

            StripAnimation saMoiWalkingFrontRight = new StripAnimation(width, height, width / 4, height / 4, 4);
            aiMoi.AddAnimation("MoiWalkingFrontRight", saMoiWalkingFrontRight);
            StripAnimation saMoiWalkingFrontLeft = new StripAnimation(width, height, width / 4, height / 4, 4, 0, height / 4);
            aiMoi.AddAnimation("MoiWalkingFrontLeft", saMoiWalkingFrontLeft);
            StripAnimation saMoiWalkingRearRight = new StripAnimation(width, height, width / 4, height / 4, 4, 0, height / 4 * 2);
            aiMoi.AddAnimation("MoiWalkingRearRight", saMoiWalkingRearRight);
            StripAnimation saMoiWalkingRearLeft = new StripAnimation(width, height, width / 4, height / 4, 4, 0, height / 4 * 3);
            aiMoi.AddAnimation("MoiWalkingRearLeft", saMoiWalkingRearLeft);
            lMoi = new Sprite("Moi", aiMoi) { Pivot = Vector2.One / 2, BringToFront = false };
            AddComponent(lMoi, Preferences.ViewportManager.MiddleCenterAnchor);
            #endregion Moi

            #region Game pad

            thumbStick = new ThumbStick();
            thumbStick.Pivot = new Vector2(0, 1);
            Vector2 margin = new Vector2(5, -5);
            AddComponent(thumbStick, Preferences.ViewportManager.BottomLeftAnchor + margin);

            Buttons buttons = new Buttons();
            margin = new Vector2(-5, -5) - buttons.Size;
            AddComponent(buttons, Preferences.ViewportManager.BottomRightAnchor + margin);
            #endregion Game pad
        }
Пример #13
0
        public void NewAnimated_FindPageByBlobName_Returns_Null_Exception()
        {
            var stub = new Stubs.PageSelectorStub
            {
                DontThrowNotImpl = true,
                Result           = null         //в этом тесте новых страниц нет, поэтому первый селектор вернет null
            };

            IPageSelector pageSelectorForNewPages = stub;

            //это часть урла, а блоб всегда содержит в начале такое же (до двоеточия)
            string codeGeassURLPart = "code-geass";

            //а главную "роль" в тесте исполнит селектор новых аним.изображений - он должен вернуть
            AnimatedImage animatedImage = new AnimatedImage
            {
                BlobName  = "code-geass:img1.gif",
                TweetDate = null                 //гифка новая даты твита не должно быть
            };

            var animNewStub = new Stubs.AnimatedSelectorStub
            {
                DontThrowNotImpl = true,
                Result           = new AnimatedImage[] { animatedImage }       //стаб вернет этот результат
            };

            IFindAnimatedByPage animatedSelectorForNewImages = animNewStub;

            //в этом тесте ожидается работа стаба FindPageByBlobNameStub - он должен НЕ найти страницу по имени блоба (вернуть null)
            //и это приведет в итоге к исключению
            var findPageByBlob = new Stubs.FindPageByBlobNameStub
            {
                DontThrowNotImpl = true,
                Result           = null
            };

            //имитируем найденную страницу...
            IFindPageByBlobName findPageByBlobName = findPageByBlob;

            IPageSelector                    pageSelectorForAnyPages         = new Stubs.PageSelectorStub();
            IFindAnimatedByPage              findAnimatedByPage              = new Stubs.FindAnimatedByPageStub();
            IPageOrExternalImageSelector     pageOrExternalImageSelector     = new Stubs.PageOrExternalImageSelectorStub();
            IAnimatedSelectorWithExcludeLast animatedSelectorWithExcludeLast = new Stubs.AnimatedSelectorWithExcludeLastStub();

            var pageForTwittingSelector = new kawaii.twitter.core.SelectLogic.PageForTwittingSelector(pageSelectorForNewPages, animatedSelectorForNewImages, pageSelectorForAnyPages, findAnimatedByPage, pageOrExternalImageSelector, animatedSelectorWithExcludeLast, new TweetCreator.Stubs.Logger());

            try
            {
                TwittData result = pageForTwittingSelector.GetPageForTwitting().Result;
            }
            catch (AggregateException aggrEx)
            {
                ApplicationException appEx = (ApplicationException)aggrEx.InnerExceptions[0];

                //это и должно было произойти. В тексте наш спец.текст
                Assert.IsTrue(appEx.Message.Contains("Find page by blob name failed for"));
                Assert.IsTrue(appEx.Message.Contains(codeGeassURLPart));
            }
        }
Пример #14
0
 public Enemy4(Point p, Map m, Player target) : base(p, 1, 0, target, m, 4, 600)
 {
     image = new AnimatedImage("e4", Globals.StdFrame, 32, 4);
     while (!isInBounds(TargetTile()) || m.myData.Map[TargetTile().X, TargetTile().Y] == 0)
     {
         direction++;
     }
 }
Пример #15
0
        public void PageFound_But_EmptyArray_Animated()
        {
            //этот аналог важен для покрытия кода (случай когда не null но пустой массив)

            AnimatedImage[] emptyArr = new AnimatedImage[0];

            _PageFoundBody(emptyArr);
        }
 public override void Stop()
 {
     base.Stop();
     ReleaseImage(_upperImage);
     ReleaseImage(_lowerImage);
     _upperImage = null;
     _lowerImage = null;
 }
Пример #17
0
 internal MapImage(int x, int y, string image)
 {
     LocationUnit = new Vector2(x, y);
     CurrentImage = new AnimatedImage()
     {
         Path = Path.Combine(BasePath, image)
     };
 }
Пример #18
0
 public Enemy5(Point p, Map m, Player target) : base(p, 1, 0, target, m, 5, 600)
 {
     while (!isInBounds(TargetTile()) || m.myData.Map[TargetTile().X, TargetTile().Y] == 0)
     {
         direction++;
     }
     image = new AnimatedImage("e5", Globals.StdFrame, 16, 3);
 }
Пример #19
0
        public IndexingStatusWindow() : base("IndexingStatusWindow")
        {
            indexingSpinner = new Hyena.Widgets.AnimatedImage();
            indexingSpinner.SetSizeRequest(16, 16);
            indexingSpinner.Pixbuf      = Gui.LoadIcon(22, "process-working");
            indexingSpinner.FrameHeight = 22;
            indexingSpinner.FrameWidth  = 22;
            indexingSpinner.Load();
            indexingSpinnerAlignment.Add(indexingSpinner);

            hashingSpinner = new Hyena.Widgets.AnimatedImage();
            hashingSpinner.SetSizeRequest(16, 16);
            hashingSpinner.Pixbuf      = Gui.LoadIcon(22, "process-working");
            hashingSpinner.FrameHeight = 22;
            hashingSpinner.FrameWidth  = 22;
            hashingSpinner.Load();
            hashingSpinnerAlignment.Add(hashingSpinner);

            Core.ShareBuilder.StartedIndexing += delegate {
                Application.Invoke(delegate {
                    indexingFileLabel.Text = "(Starting...)";
                    indexingSpinner.Show();
                });
            };

            Core.ShareBuilder.IndexingFile += delegate(object sender, FilenameEventArgs args) {
                Application.Invoke(delegate {
                    indexingFileLabel.Text = args.Filename;
                    indexingSpinner.Show();
                });
            };

            Core.ShareBuilder.FinishedIndexing += delegate {
                Application.Invoke(delegate {
                    indexingFileLabel.Text = "(Idle)";
                    indexingSpinner.Hide();
                });
            };

            Core.ShareBuilder.StoppedIndexing += delegate {
                Application.Invoke(delegate {
                    indexingFileLabel.Text = "(Idle - last run aborted)";
                    indexingSpinner.Hide();
                });
            };

            Core.ShareHasher.StartedHashingFile += delegate {
                UpdateShareHasherStatus();
            };

            Core.ShareHasher.FinishedHashingFile += delegate {
                UpdateShareHasherStatus();
            };

            Core.ShareHasher.QueueChanged += delegate {
                UpdateShareHasherStatus();
            };
        }
Пример #20
0
        private void HidePokemon(PBEBattlePokemon pkmn, PBEFieldPosition oldPosition)
        {
            PkmnPosition  pos = GetStuff(pkmn, oldPosition);
            AnimatedImage img = pos.SPkmn.AnimImage;

            pos.InfoVisible = false;
            pos.PkmnVisible = false;
            img.IsPaused    = true;
        }
Пример #21
0
        protected virtual async Task DecodeFrames()
        {
            m_image = await Decoder.DecodeAnimatedImage(m_source, CanvasBitmapFileFormat.Gif);

            Width  = m_image.Width;
            Height = m_image.Height;

            Duration = m_image.Duration;
        }
Пример #22
0
    private static void SaveAnimatedImage(AnimatedImage image, string path, int index)
    {
        for (int i = 0; i < image.images.Length; i++)
        {
            image.images[i] = SaveImage(image.images[i].texture, Path.Combine(path, i + ".png"));
        }

        AssetDatabase.CreateAsset(image, Path.Combine(path, "AnimatedImage_" + index + ".asset"));
    }
Пример #23
0
        public void UpdateTweetDateForBlob(AnimatedImage img, DateTime date)
        {
            if (!DontThrowNotImpl)
            {
                throw new NotImplementedException();
            }

            CalledImage = img;
            CalledDate  = date;
        }
Пример #24
0
 private void OnViewModelProprtyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (Property.NameEquals(e.PropertyName, () => ViewModel.IsOpen))
     {
         if (!ViewModel.IsOpen)
         {
             AnimatedImage.Stop();
         }
     }
 }
 public override void Start()
 {
     base.Start();
     _upperImage = GifImage();
     _lowerImage = GifImage();
     _upperCanvas.Children.Add(_upperImage);
     _lowerCanvas.Children.Add(_lowerImage);
     _upperImage.Start();
     _lowerImage.Start();
 }
Пример #26
0
        internal static FrameworkElement FruitControlFactory(Fruit fruit, double scale)
        {
            IEnumerable <string> imageNames   = CreateImageList(fruit.MyFruitType);
            AnimatedImage        fruitControl = new AnimatedImage(imageNames, TimeSpan.FromSeconds(.75));

            fruitControl.Width  = fruit.Size.Width * scale;
            fruitControl.Height = fruit.Size.Height * scale;
            SetCanvasLocation(fruitControl, fruit.Location.X * scale, fruit.Location.Y * scale);
            return(fruitControl);
        }
Пример #27
0
        private unsafe void RCB_RenderTick(uint *bmpAddress, int bmpWidth, int bmpHeight)
        {
            RenderUtils.ThreeColorBackground(bmpAddress, bmpWidth, bmpHeight, RenderUtils.Color(215, 231, 230, 255), RenderUtils.Color(231, 163, 0, 255), RenderUtils.Color(242, 182, 32, 255));

            AnimatedImage.UpdateCurrentFrameForAll();
            _pkmnImage.DrawOn(bmpAddress, bmpWidth, bmpHeight,
                              RenderUtils.GetCoordinatesForCentering(bmpWidth, _pkmnImage.Width, 0.2f), RenderUtils.GetCoordinatesForEndAlign(bmpHeight, _pkmnImage.Height, 0.6f));

            _pageImage.DrawOn(bmpAddress, bmpWidth, bmpHeight, 1f - PageImageWidth, 1f - PageImageHeight);
        }
        public override void InitScene()
        {
            arcaneLogo = new AnimatedImage(@"Assets\ArcaneSchool2.png", new IntVector2(16, 16), 3);
            natureLogo = new AnimatedImage(@"Assets\NatureSchool.png", new IntVector2(16, 16), 7);
            shadowLogo = new AnimatedImage(@"Assets\ShadowSchoolFinal.png", new IntVector2(16, 16), 5);

            arcaneDescription = "The Discipline of the Arcane is concerned with the purest understanding of magic itself.  Arcane spells channel raw mystical energies, unleashing powerful effects and warping reality around the caster.  An Arcane wizard can not only wield deadly magical forces, but can dispel the magic of his foes as well.  Arcane wizards tend to struggle when they are faced by creatures resistant to magical energy.";
            natureDescription = "The Discipline of Nature uses magic to control plants, animals, and the earth.  Nature wizards can fight their foes using the rocks and plants around them, while shielding themselves in clouds of fog or behind magically summoned stone walls.  Since most Nature magic deals with the physical world, a Nature wizard may have trouble against incorporeal enemies like spirits or ghosts.";
            shadowDescription = "The Discipline of Shadow draws its power from Umbra, the Shadow Plane.  Shadow wizards can cripple enemies with powerful curses, cloak themselves in darkness to avoid enemies, and teleport short distances to avoid their foes.  Shadow magic provides very little protection in direct combat, making sneak attacks essential for Shadow wizards who want to survive against more powerful creatures.";
        }
Пример #29
0
 private void InitAnimatedImage()
 {
     try {
         _animatedImage = new AnimatedImage();
         _animatedImage.PropertyChanged += OnAnimatedImagePropertyChanged;
     }
     catch (Exception exception) {
         _log.Error(exception);
     }
 }
Пример #30
0
            public AnimatedImage DecodeImage(Stream stream)
            {
                _image = new AnimatedImage();

                _stream = stream;
                _stream.Seek(6, SeekOrigin.Current);

                ReadLogicalScreenDescriptor();

                if (_logicalScreenDescriptor.GlobalColorTableFlag == true)
                {
                    _globalColorTable = new byte[_logicalScreenDescriptor.GlobalColorTableSize * 3];

                    // Read the global color table from the stream
                    stream.Read(_globalColorTable, 0, _globalColorTable.Length);
                }

                int nextFlag = stream.ReadByte();

                while (nextFlag != 0)
                {
                    if (nextFlag == ImageLabel)
                    {
                        ReadFrame();
                    }
                    else if (nextFlag == ExtensionIntroducer)
                    {
                        int gcl = stream.ReadByte();
                        switch (gcl)
                        {
                        case GraphicControlLabel:
                            ReadGraphicalControlExtension();
                            break;

                        case CommentLabel:
                            ReadComments();
                            break;

                        case ApplicationExtensionLabel:
                            Skip(12);
                            break;

                        case PlainTextLabel:
                            Skip(13);
                            break;
                        }
                    }
                    else if (nextFlag == EndIntroducer)
                    {
                        break;
                    }
                    nextFlag = stream.ReadByte();
                }
                return(_image);
            }
Пример #31
0
        public void Init()
        {
            // TODO: Move this
            DefaultImage = _textureLoader.Load(File.ReadAllBytes("Resources/Images/default-image.png"));
            LoadingImage = new AnimatedImage(_textureLoader.Load(File.ReadAllBytes("Resources/Images/loading-image.png")), 9, 5, 40, Direction.TopToBottom, 5);

            var transp = new System.Drawing.Bitmap(1, 1);

            System.Drawing.Graphics.FromImage(transp).Clear(System.Drawing.Color.White);
            WhiteImage = _textureLoader.Load(transp.ToByteArray());
        }
Пример #32
0
        IMongoCollection <AnimatedImage> _PrepareAnimatedCollection(bool doEmptyCollection, bool doAllWithTweetDate)
        {
            string connString = "mongodb://localhost:27017/?readPreference=primary&appname=kawaiitwitter&ssl=false";
            string dbName     = "unit-test-kawaii";
            string collName   = "not-twitted-animated";

            var db = new Database(connString, false, dbName);

            var animatedCollection = new AnimatedImageCollection(db, collName, true);
            var pages = animatedCollection.AnimatedImages;

            //удаляем все записи, заполняем тест данными
            var delFilter = Builders <AnimatedImage> .Filter.Exists(x => x.BlobName);

            pages.DeleteMany(delFilter);

            if (doEmptyCollection)
            {
                return(pages);                  //на этом все - пустая коллекция
            }
            AnimatedImage[] imgsToAdd = new AnimatedImage[] { _Img1, _Img2, _Img3, _Img4, _Img5 };

            if (doAllWithTweetDate)
            {
                //здесь чуть сложнее - клонируем исходные данные, чтобы потенциально не мешать другим, и прошьем дату всем (порядок и разм.массива достаточна для тех, у кого нет своей даты твита)

                DateTime[] tweedDates = new DateTime[] { _TweetDate1, _TweetDate2, _TweetDate3 };

                AnimatedImage[] imgsToAddCloned = new AnimatedImage[imgsToAdd.Length];
                for (int i = 0; i < imgsToAdd.Length; i++)
                {
                    var srcImg = imgsToAdd[i];

                    var img = new AnimatedImage
                    {
                        BlobName  = srcImg.BlobName,
                        TweetDate = srcImg.TweetDate
                    };

                    if (img.TweetDate == null)
                    {
                        img.TweetDate = tweedDates[i];
                    }

                    imgsToAddCloned[i] = img;
                }                //for i

                imgsToAdd = imgsToAddCloned;
            }

            pages.InsertMany(imgsToAdd);

            return(pages);
        }
Пример #33
0
        internal FrameworkElement PlayerControlFactory(Player player, double scale)
        {
            var playerControl = new AnimatedImage("player.png")
            {
                Width  = player.Size.Width * scale,
                Height = player.Size.Height * scale
            };

            SetCanvasLocation(playerControl, player.Location.X, player.Location.Y, scale);
            return(playerControl);
        }
Пример #34
0
 public Enemy3(Point p, Map m, Player target) : base(p, 1, 0, target, m, 3, 400)
 {
     image         = new AnimatedImage("e3", Globals.StdFrame, 32, 4);
     respawns      = true;
     respawntime  *= 2;
     notespawntime = 0;
     while (!isInBounds(TargetTile()) || m.myData.Map[TargetTile().X, TargetTile().Y] == 0)
     {
         direction++;
     }
 }
 private AnimatedImage GifImage()
 {
     var source = new ExtendedImage { UriSource = new Uri(_gifPath, UriKind.RelativeOrAbsolute) };
     var animatedImage = new AnimatedImage {
         AnimationMode = AnimationMode.Repeat,
         Width = ScreenWidth,
         Height = 320,
         Stretch = Stretch.Fill,
         Opacity = Opacity,
         Source = source,
     };
     return animatedImage;
 }
Пример #36
0
            public AnimatedImage DecodeImage(Stream stream)
            {
                _image = new AnimatedImage();

                _stream = stream;
                _stream.Seek(6, SeekOrigin.Current);

                ReadLogicalScreenDescriptor();

                if (_logicalScreenDescriptor.GlobalColorTableFlag == true)
                {
                    _globalColorTable = new byte[_logicalScreenDescriptor.GlobalColorTableSize * 3];

                    // Read the global color table from the stream
                    stream.Read(_globalColorTable, 0, _globalColorTable.Length);
                }

                int nextFlag = stream.ReadByte();
                while (nextFlag != 0)
                {
                    if (nextFlag == ImageLabel)
                    {
                        ReadFrame();
                    }
                    else if (nextFlag == ExtensionIntroducer)
                    {
                        int gcl = stream.ReadByte();
                        switch (gcl)
                        {
                            case GraphicControlLabel:
                                ReadGraphicalControlExtension();
                                break;
                            case CommentLabel:
                                ReadComments();
                                break;
                            case ApplicationExtensionLabel:
                                Skip(12);
                                break;
                            case PlainTextLabel:
                                Skip(13);
                                break;
                        }
                    }
                    else if (nextFlag == EndIntroducer)
                    {
                        break;
                    }
                    nextFlag = stream.ReadByte();
                }
                return _image;
            }
Пример #37
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var uri = value as Uri;
            if (uri == null)
            {
                if (value is string)
                {
                    uri = new Uri(value as string, UriKind.RelativeOrAbsolute);
                }

                else
                {
                    return value;
                }
            }

            string uriString;
            try { uriString = uri.AbsolutePath; }
            catch (InvalidOperationException) { uriString = uri.OriginalString; }

            string extension = uriString.Split('.').Last();
            if (extension.Equals("gif", StringComparison.OrdinalIgnoreCase))
            {
                ExtendedImage gifImage = null;
                try
                {
                    gifImage = _gifConverter.Convert(uri, typeof(object), null, null) as ExtendedImage;
                }
                catch (ImageTools.IO.UnsupportedImageFormatException e)
                {
                    MessageBox.Show(e.InnerException.Message);
                }

                var aniImage = new AnimatedImage() { Source = gifImage, Stretch = Stretch.Fill };
                aniImage.Unloaded += new RoutedEventHandler(OnAnimatedImageUnloaded);
                return aniImage;
            }

            else
            {
                var source = new BitmapImage(uri);
                var img = new Image() { Source = source, Stretch = Stretch.Fill };
                img.Unloaded += new RoutedEventHandler(OnImageUnloaded);
                return img;
            }
        }
        private void disposeMessageImage()
        {
            if (messageImage != null)
            {
                messageImage.Stop();

                if (messageImage.Source != null & messageImage.Source.Frames != null)
                    messageImage.Source.Frames.Clear();

                messageImage.Source = null;
                messageImage = null;

                GC.Collect();
            }
        }
Пример #39
0
        private void LoadImageFromStream(Stream imageStream, bool isCached = false)
        {
            bool imageLoaded = false;
            ImagePanel.Children.Clear();
            _bitmap = null;
            _imageControl = null;
            _extImageControl = null;

            if (_dupStream != null)
            {
                _dupStream.Close();
                _dupStream = null;
            }

            if (imageStream != null)
            {
                try
                {
                    Image imageControl = new System.Windows.Controls.Image();

                    _bitmap = new System.Windows.Media.Imaging.BitmapImage();
                    _bitmap.SetSource(imageStream);
                    imageControl.Source = _bitmap;
                    imageControl.DataContext = this;

                    if (_bitmap.PixelHeight > 0)
                    {
                        ImageHeight = _bitmap.PixelHeight;
                    }

                    if (_bitmap.PixelWidth > 0)
                    {
                        ImageWidth = _bitmap.PixelWidth;
                    }

                    imageControl.MaxHeight = MaxImageHeight;
                    imageControl.MaxWidth = MaxImageWidth;

                    imageControl.DataContext = this;

                    CreateButtons();

                    ImagePanel.Children.Add(imageControl);
                    _imageControl = imageControl;

                    if (HandlePinch)
                    {
                        AddGestureHandler(imageControl);
                    }

                    ImagePanel.Height = double.NaN;
                    imageLoaded = true;
                    ImageState = ImageStateType.Loaded;
                }
                catch (Exception)
                {
                    imageLoaded = false;
                    _bitmap = null;
                    _imageControl = null;
                }

                if (!imageLoaded && (imageStream.Length > 200))
                {
                    try
                    {
                        imageStream.Seek(0, System.IO.SeekOrigin.Begin);

                        _dupStream = new MemoryStream();

                        imageStream.CopyTo(_dupStream);
                        _dupStream.Seek(0, System.IO.SeekOrigin.Begin);

                        ImageTools.Controls.AnimatedImage extImageControl = new ImageTools.Controls.AnimatedImage();

                        ImageTools.ExtendedImage image = new ImageTools.ExtendedImage();
                        image.SetSource(_dupStream);
                        extImageControl.Source = image;
                        extImageControl.DataContext = this;

                        if (image.PixelHeight > 0)
                        {
                            ImageHeight = image.PixelHeight;
                        }

                        if (image.PixelWidth > 0)
                        {
                            ImageWidth = image.PixelWidth;
                        }

                        extImageControl.MaxHeight = MaxImageHeight;
                        extImageControl.MaxWidth = MaxImageWidth;

                        extImageControl.DataContext = this;

                        CreateButtons();

                        ImagePanel.Children.Add(extImageControl);
                        _extImageControl = extImageControl;

                        if (HandlePinch)
                        {
                            AddGestureHandler(extImageControl);
                        }

                        ImagePanel.Height = double.NaN;
                        imageLoaded = true;
                        ImageState = ImageStateType.Loaded;
                    }
                    catch (Exception)
                    {

                    }
                }
            }

            if (!imageLoaded)
            {
                if (isCached)
                {
                    imageStream.Close();
                    App.Settings.OfflineContentManager.CleanupOfflineContent(OfflineID, ImageUrl);

                    IsOffline = false;
                    ImageState = ImageStateType.Unloaded;
                    ShowManualLoad();

                    _web = null;

                    if (ImageItemLoaded != null)
                    {
                        ImageItemLoaded(this, null);
                    }
                }
                else
                {
                    ImageState = ImageStateType.Error;

                    if (ShowViewerLink)
                    {
                        ShowViewer();
                    }
                    else
                    {
                        ShowError();
                    }
                }
            }

            _web = null;

            if (ImageItemLoaded != null)
            {
                ImageItemLoaded(this, null);
            }

            if (imageLoaded && !isCached && imageStream != null && CacheImage)
            {
                imageStream.Seek(0, System.IO.SeekOrigin.Begin);
                App.Settings.OfflineContentManager.SaveOfflineContent(OfflineID, ImageUrl, imageStream);
            }
        }
Пример #40
0
 public AnimatedImage GetAnimatebyIDImage()
 {
     AnimatedImage animatedImage = null;
     Bitmap image = IDKin.IM.Windows.Properties.Resources.login;
     if (image != null)
     {
         animatedImage = new AnimatedImage();
         animatedImage.LoadSmile(image);
     }
     return animatedImage;
 }
 private void createMessageImage()
 {
     messageImage = new AnimatedImage();
     messageImage.Stretch = Stretch.UniformToFill;
     MessageImageContainer.Content = messageImage;
 }
Пример #42
0
 public void InsertAnimatedImage(AnimatedImage animateImage)
 {
     try
     {
         if (animateImage != null)
         {
             animateImage.Stretch = Stretch.None;
             new InlineUIContainer(animateImage, this.inputMsgBox.Selection.End);
             this.inputMsgBox.Focus();
             this.inputMsgBox.ScrollToEnd();
         }
     }
     catch (System.Exception e)
     {
         this.logger.Error(e.ToString());
     }
 }
Пример #43
0
		private static UIElement buildImage(string src)
		{
			if (!src.ToLower().EndsWith(".gif"))
			{
				Image ret = new Image();
				ret.HorizontalAlignment = HorizontalAlignment.Left;
				ret.Margin = new Thickness(3, 3, 3, 3);
				BitmapImage img = new BitmapImage(new Uri(IMG_PREFIX+src));
				ret.Source = img;
				ret.ImageOpened += (s, e) =>
				{
					/*
					ret.Width = img.PixelWidth;
					ret.Height = img.PixelHeight;
					 */
				};
				ret.ImageFailed += (s, e) =>
				{
					// corp proxy returns 302
				};
				return ret;
			}
			ImageTools.IO.Decoders.AddDecoder <ImageTools.IO.Gif.GifDecoder>();
			AnimatedImage gifRet = new AnimatedImage();
			gifRet.HorizontalAlignment = HorizontalAlignment.Left;
			gifRet.Margin = new Thickness(3, 3, 3, 3);
			ExtendedImage gifImg = new ExtendedImage();
			// fetch gif images directly
			gifImg.UriSource = new Uri(src);
			gifRet.Source = gifImg;
			gifRet.LoadingCompleted += (s, e) =>
			{
				/*
				gifRet.Width = gifImg.PixelWidth;
				gifRet.Height = gifImg.PixelHeight;
				 */
			};
			return gifRet;
		}
Пример #44
0
 private void ViewMsgBox_ContextMenuOpening(object sender, ContextMenuEventArgs e)
 {
     this.ViewerMenuItemImageSaveAs.IsEnabled = false;
     if (!string.IsNullOrEmpty(UIControlUtil.Instance.TempImagePath))
     {
         this.ViewerMenuItemImageSaveAs.IsEnabled = true;
         this.tempImageFile = UIControlUtil.Instance.TempImagePath;
         this.tempAnimatedImage = UIControlUtil.Instance.TempAnimatedImage;
     }
 }
Пример #45
0
 private void inputMsgBoxCommandCopy(object sender, ExecutedRoutedEventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(UIControlUtil.Instance.TempImagePath))
         {
             TextRange tr = new TextRange(this.inputMsgBox.Selection.Start, this.inputMsgBox.Selection.End);
             if (!string.IsNullOrEmpty(tr.Text.Trim()))
             {
                 System.Windows.Clipboard.SetText(tr.Text);
             }
             else
             {
                 System.Windows.Clipboard.Clear();
                 if (this.tempImageFile == "Ax012Face" && this.tempAnimatedImage != null)
                 {
                     System.Windows.Clipboard.SetText("Ax012Face" + this.tempAnimatedImage.DataContext);
                     this.tempImageFile = string.Empty;
                     this.tempAnimatedImage = null;
                 }
             }
         }
         else
         {
             if (UIControlUtil.Instance.TempImagePath == "Ax012Face" && UIControlUtil.Instance.TempAnimatedImage != null)
             {
                 System.Windows.Clipboard.Clear();
                 System.Windows.Clipboard.SetText("Ax012Face" + UIControlUtil.Instance.TempAnimatedImage.DataContext);
             }
             else
             {
                 if (UIControlUtil.Instance.TempImage != null)
                 {
                     BitmapSource bitmap = (BitmapSource)UIControlUtil.Instance.TempImage.Source;
                     if (bitmap != null)
                     {
                         System.Windows.Clipboard.SetImage(bitmap);
                     }
                 }
             }
         }
     }
     catch (System.Exception ex)
     {
         this.logger.Error(ex.ToString());
     }
 }
Пример #46
0
 private void LoadingComplete(object sender, EventArgs e)
 {
     if (Proxy == null) return;
     if (IsGif = Proxy.IsGif)
     {
         if (RealImageGif == null)
             RealImageGif = new AnimatedImage { Stretch = Stretch.Uniform };
         imageArea.Content = RealImageGif;
         RealImageGif.Source = Proxy.GifImage;
     }
     else
     {
         if (RealImage == null)
             RealImage = new Image { Stretch = Stretch.Uniform };
         imageArea.Content = RealImage;
         RealImage.Source = Proxy.Image;
     }
     ImageHolder.Visibility = Visibility.Collapsed;
     FailedFlag.Visibility = Visibility.Collapsed;
 }
Пример #47
0
        public void Unload()
        {
            if (ImageState == ImageStateType.Loaded)
            {
                ImagePanel.Height = ImagePanel.ActualHeight;
            }

            ImagePanel.Children.Clear();

            if (_bitmap != null)
            {
                _bitmap = null;
            }

            if (_imageControl != null)
            {
                _imageControl.Source = null;
                _imageControl = null;
            }

            if (_extImageControl != null)
            {
                _extImageControl.Source = null;
                _extImageControl = null;
            }

            if (_dupStream != null)
            {
                _dupStream.Close();
                _dupStream = null;
            }

            ImageState = ImageStateType.Unloaded;

            ShowManualLoad();
        }
 private void ReleaseImage(AnimatedImage image)
 {
     image.Source.Frames.Clear();
     image.Stop();
     image.Source = null;
 }