private static string BuildImgElement(PictureData pictureData, LazyLoadType lazyLoadType, string cssClass)
        {
            var imgElement = new TagBuilder("img");

            imgElement.Attributes.Add("alt", HttpUtility.HtmlEncode(pictureData.AltText));

            //Add src and/or data-src attribute
            switch (lazyLoadType)
            {
            case LazyLoadType.Regular:
                imgElement.Attributes.Add("data-src", pictureData.ImgSrc);
                break;

            case LazyLoadType.Progressive:
                imgElement.Attributes.Add("src", pictureData.ImgSrcLowQuality);
                imgElement.Attributes.Add("data-src", pictureData.ImgSrc);
                break;

            default:
                imgElement.Attributes.Add("src", pictureData.ImgSrc);
                break;
            }

            //Add class attribute
            if (!string.IsNullOrEmpty(cssClass))
            {
                imgElement.Attributes.Add("class", cssClass);
            }

            return(imgElement.ToString(TagRenderMode.SelfClosing));
        }
    private void CheckPrecacheResources()
    {
        PictureData pictureData = this.task.PictureData;

        if (FileHelper.FileExist(this.directory, this.iconPath))
        {
            this.iconState = PictureDataDownloader.DownloadState.Cached;
            FMLogger.Log("skip dl icon, already stored");
        }
        if (FileHelper.FileExist(this.directory, this.linePath))
        {
            this.lineState = PictureDataDownloader.DownloadState.Cached;
            FMLogger.Log("skip dl line, already stored");
        }
        if (pictureData.FillType == FillAlgorithm.Flood)
        {
            if (FileHelper.FileExist(this.directory, this.coloredPath))
            {
                this.colorState = PictureDataDownloader.DownloadState.Cached;
                FMLogger.Log("skip dl colormap, already stored");
            }
        }
        else
        {
            this.colorState = PictureDataDownloader.DownloadState.Cached;
            FMLogger.Log("skip dl colormap, not needed anymore");
        }
        if (FileHelper.FileExist(this.directory, this.jsonPath))
        {
            this.jsonState = PictureDataDownloader.DownloadState.Cached;
            FMLogger.Log("skip dl json, already stored");
        }
    }
Ejemplo n.º 3
0
        public void Test01()
        {
            PictureData picture = new PictureData(new Canvas2(@"C:\wb2\20191204_ジャケット的な\バンドリ_イニシャル.jpg"), 1920, 1080);

            const int FRAME_NUM = 200;

            const int D_MAX = 20;
            int       dTarg = D_MAX;
            int       d     = D_MAX;

            using (WorkingDir wd = new WorkingDir())
            {
                FileTools.CreateDir(wd.GetPath("img"));

                for (int frame = 0; frame < FRAME_NUM; frame++)
                {
                    Console.WriteLine(frame);                     // test

                    picture.SetFrame(frame * 1.0 / FRAME_NUM);

                    // ---- 暗くする ----

                    if (frame == 10)
                    {
                        dTarg = 0;
                    }
                    else if (frame + 10 + D_MAX == FRAME_NUM)
                    {
                        dTarg = D_MAX;
                    }

                    if (d < dTarg)
                    {
                        d++;
                    }
                    else if (dTarg < d)
                    {
                        d--;
                    }

                    if (0 < d)
                    {
                        picture.SetDrakness(d * 1.0 / D_MAX);
                    }

                    // ----

                    picture.Save(wd.GetPath("img\\" + frame + ".jpg"));
                }

                ProcessTools.Batch(new string[]
                {
                    @"C:\app\ffmpeg-4.1.3-win64-shared\bin\ffmpeg.exe -r 20 -i %%d.jpg ..\out.mp4",
                },
                                   wd.GetPath("img")
                                   );

                File.Copy(wd.GetPath("out.mp4"), @"C:\temp\1.mp4", true);
            }
        }
Ejemplo n.º 4
0
    public void StartShameSavingProcess(PictureData _pData)
    {
        string    matchCount = player1count.ToString() + " - " + player2count.ToString();
        MatchData mData      = new MatchData(uiManager.GetPlayerNames(), GetDate(), matchCount);

        shManager.AddNewShame(_pData, mData);
    }
        /// <summary>
        /// Get the data necessary for rendering a Picture element.
        /// </summary>
        public static PictureData GetPictureData(UrlBuilder imageUrl, ImageType imageType, bool includeLowQuality = false, string altText = "")
        {
            var pData = new PictureData
            {
                AltText = altText
            };

            var currentFormat = GetFormatFromExtension(imageUrl.Path);

            if (imageType.SrcSetWidths != null)
            {
                pData.SrcSet         = BuildSrcSet(imageUrl, imageType, currentFormat);
                pData.ImgSrc         = BuildQueryString(imageUrl, imageType, imageType.DefaultImgWidth, currentFormat);
                pData.SizesAttribute = string.Join(", ", imageType.SrcSetSizes);

                if (includeLowQuality)
                {
                    pData.SrcSetLowQuality = BuildSrcSet(imageUrl, imageType, currentFormat, true);
                    pData.ImgSrcLowQuality = BuildQueryString(imageUrl, imageType, imageType.DefaultImgWidth, currentFormat, 10);
                }

                //if jpg, also add webp versions
                if (currentFormat == "jpg")
                {
                    pData.SrcSetWebp = BuildSrcSet(imageUrl, imageType, "webp");
                    if (includeLowQuality)
                    {
                        pData.SrcSetLowQualityWebp = BuildSrcSet(imageUrl, imageType, "webp", true);
                    }
                }
            }

            return(pData);
        }
        private static string BuildSourceElement(PictureData pictureData, LazyLoadType lazyLoadType, string format = "")
        {
            var sourceElement = new TagBuilder("source");

            var srcset = pictureData.SrcSet;

            if (format == "webp")
            {
                srcset = pictureData.SrcSetWebp;
                sourceElement.Attributes.Add("type", "image/" + format);
            }

            switch (lazyLoadType)
            {
            case LazyLoadType.Regular:
                sourceElement.Attributes.Add("data-srcset", srcset);
                break;

            case LazyLoadType.Progressive:
                sourceElement.Attributes.Add("srcset", format == "webp" ? pictureData.SrcSetLowQualityWebp : pictureData.SrcSetLowQuality);
                sourceElement.Attributes.Add("data-srcset", srcset);
                break;

            default:
                sourceElement.Attributes.Add("srcset", srcset);
                break;
            }

            //Add sizes attribute
            sourceElement.Attributes.Add("sizes", pictureData.SizesAttribute);

            return(sourceElement.ToString(TagRenderMode.SelfClosing));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Hier können eigene Renderer zugeschaltet werden:
        /// </summary>
        /// <returns></returns>
        public static Renderer Create(PictureData pdata, Formulas formula, ParameterDict dict)
        {
            Renderer retVal = null;

            switch (ParameterDict.Current["Composite.Renderer"])
            {
            case "":
            case "PlasicRenderer":
            case "6":
                //retVal = new PlasicRenderer(pdata.Clone());
                retVal = new FloatPlasicRenderer(pdata.Clone(), dict);
                break;

            case "FastPreviewRenderer":
            case "8":
                retVal = new FastPreviewRenderer(pdata.Clone());
                break;

            default:
                //retVal = new PlasicRenderer(pdata.Clone());
                retVal = new FloatPlasicRenderer(pdata.Clone(), dict);
                break;
            }

            if (retVal != null)
            {
                retVal.Init(formula);
            }

            return(retVal);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Split computing in threads.
        /// </summary>
        // public void StartAsync(FracValues act_val, int zyklen, double screensize, int formula, bool perspective)
        public void StartAsync(FracValues act_val, int zyklen, double screensize, bool _isJulia, bool perspective)
        {
            _start = true;
            System.Diagnostics.Debug.WriteLine("Iter start");
            _actVal     = act_val;
            _cycles     = zyklen;
            _screensize = screensize;
            _formula    = -1;
            if (_isJulia)
            {
                _formula = -2;
            }
            _perspective = perspective;
            _availableY  = 0;

            int noOfThreads = ParameterDict.Current.GetInt("Computation.NoOfThreads");

            if (noOfThreads == 1)
            {
                Generate(act_val, zyklen, screensize, _formula, perspective);
                _starter.ComputationEnds();
                return;
            }
            _startCount = noOfThreads;
            _pData      = new PictureData(_width, _height);
            for (int i = 0; i < noOfThreads; i++)
            {
                System.Threading.ThreadStart tStart = new System.Threading.ThreadStart(Start);
                System.Threading.Thread      thread = new System.Threading.Thread(tStart);
                thread.Start();
            }
        }
    public void Load(string file, Transform parent)
    {
        if (file.EndsWith(".json"))
        {
            string dataAsJson = File.ReadAllText(file);

            try
            {
                Debug.Log("Loading!");
                buttonDirect.SetActive(false);
                PictureData loadedData = JsonUtility.FromJson <PictureData>(dataAsJson);
                GameObject  blipObject = GameObject.Instantiate(blipPrefab, Vector3.zero, Quaternion.identity, parent);
                Vector3     pos        = ComputeBlipPos(loadedData.Latitude, loadedData.Longitude);

                Debug.Log("[MAP] Created " + loadedData.Name + " at " + pos);

                blipObject.name = loadedData.Name;
                blipObject.GetComponent <Blip>().CreateBlip(loadedData.Name, pos, loadedData.Description, loadedData.Picture, loadedData.Latitude, loadedData.Longitude, loadedData.CurrentTime, loadedData.Material, loadedData.Era, loadedData.Size, loadedData.ArtifactClass, manager);
                blipData.Add(blipObject.GetComponent <Blip>());
            }
            catch (Exception e)
            {
                Debug.Log("Exception: " + e);
            }
        }
    }
        public async Task <IActionResult> PutPictureData(int id, PictureData pictureData)
        {
            if (id != pictureData.PictureId)
            {
                return(BadRequest());
            }

            _context.Entry(pictureData).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PictureDataExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 11
0
        public override List <PictureData> ExtractImages(string html)
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(html);
            var nodes = doc.DocumentNode.SelectNodes(ThumbnLinkNodes);

            if (nodes == null)
            {
                return(null);
            }
            var info = new List <PictureData>();

            foreach (var child in nodes)
            {
                var anInfo = new PictureData(this)
                {
                    PageUrl  = HomePage + child.Attributes["href"].Value,
                    ThumbUrl = child.Element("img").Attributes["src"].Value
                };
                info.Add(anInfo);
            }
            ThumbPerPage = info.Count;
            return(info.Count < 1 ? null : info);
        }
Ejemplo n.º 12
0
    public PictureData AddPictureToPack(PictureData pd)
    {
        PictureData pictureData = new PictureData(PictureType.Local, pd.PackId, pd.Id, pd.FillType);

        pictureData.CopyExtras(pd.Extras);
        if (pd.PicClass == PicClass.Daily)
        {
            pictureData.SetPicClass(PicClass.Daily);
        }
        DatabaseManager.AddPicture(pictureData);
        for (int i = 0; i < this.orderedMainPage.Count; i++)
        {
            if (this.orderedMainPage[i].Id == pictureData.Id)
            {
                this.orderedMainPage[i] = pictureData;
            }
        }
        if (this.featuredSection != null)
        {
            this.featuredSection.UpdatePicData(pictureData);
        }
        if (this.newsTabInfo != null)
        {
            this.newsTabInfo.UpdatePicData(pictureData);
        }
        if (this.dailyTabInfo != null)
        {
            this.dailyTabInfo.UpdatePicData(pictureData);
        }
        return(pictureData);
    }
Ejemplo n.º 13
0
        public async Task Revert_ImageChanged()
        {
            // Arrange
            var original = await CallUpdate(ResourceHelper.TestImage());          // First version, this is the one being restored to

            await CallUpdate(ResourceHelper.TestImage2, "image/png");             // Second version, with a different image

            var entryFromRepo = _repository.Load <Artist>(_artist.Id);

            PictureData.IsNullOrEmpty(entryFromRepo.Picture).Should().BeFalse("Artist has picture");
            var oldPictureData = entryFromRepo.Picture.Bytes;

            var oldVer = entryFromRepo.ArchivedVersionsManager.GetVersion(original.Version);             // Get the first archived version

            oldVer.Should().NotBeNull("Old version was found");

            // Act
            var result = await _queries.RevertToVersion(oldVer.Id);

            // Assert
            entryFromRepo = _repository.Load <Artist>(result.Id);
            PictureData.IsNullOrEmpty(entryFromRepo.Picture).Should().BeFalse("Artist has picture");
            entryFromRepo.Picture.Bytes.Should().NotEqual(oldPictureData, "Picture data was updated");
            entryFromRepo.PictureMime.Should().Be(MediaTypeNames.Image.Jpeg, "Picture MIME was updated");

            var lastVersion = entryFromRepo.ArchivedVersionsManager.GetLatestVersion();

            lastVersion.Should().NotBeNull("Last version is available");
            lastVersion.Reason.Should().Be(ArtistArchiveReason.Reverted, "Last version archive reason");
            lastVersion.Diff.Picture.IsChanged.Should().BeTrue("Picture was changed");
        }
Ejemplo n.º 14
0
 private void OnPicureDataDeleted(PictureData delPicData, PictureData replacePicData)
 {
     base.StartCoroutine(this.DelayAction(delegate
     {
         this.RemoveItemFromFeed(delPicData.Id);
     }));
 }
Ejemplo n.º 15
0
 public void DeleteSave(PictureData picData)
 {
     DatabaseManager.DeleteSave(picData.Id, true);
     if (this.orderedMainPage != null)
     {
         for (int i = 0; i < this.orderedMainPage.Count; i++)
         {
             if (this.orderedMainPage[i].Id == picData.Id)
             {
                 this.orderedMainPage[i].SetSaveState(false);
             }
         }
     }
     if (this.featuredSection != null)
     {
         this.featuredSection.UpdateSaveState(picData.Id, false);
     }
     if (this.newsTabInfo != null)
     {
         this.newsTabInfo.UpdateSaveState(picData.Id, false);
     }
     if (this.dailyTabInfo != null)
     {
         this.dailyTabInfo.UpdateSaveState(picData.Id, false);
     }
     picData.SetSaveState(false);
 }
Ejemplo n.º 16
0
 private void OnPicDeleted(PictureData delPicData, PictureData replacePicData)
 {
     if (replacePicData == null)
     {
         return;
     }
     for (int i = 0; i < this.items.Count; i++)
     {
         PicItem picItem            = null;
         FeaturedItem.ItemType type = this.items[i].Type;
         if (type != FeaturedItem.ItemType.Daily)
         {
             if (type == FeaturedItem.ItemType.PromoPic)
             {
                 picItem = ((PromoPicItem)this.items[i]).PicItem;
             }
         }
         else
         {
             picItem = ((DailyPicItem)this.items[i]).PicItem;
         }
         if (picItem != null && picItem.PictureData.Id == replacePicData.Id)
         {
             FMLogger.Log("found and replaced in featured section " + replacePicData.Id);
             picItem.Reset();
             picItem.Init(replacePicData, false, false, false);
         }
     }
 }
Ejemplo n.º 17
0
        public override List <PictureData> ExtractImages(string html)
        {
            var info = new List <PictureData>();
            var doc  = new HtmlDocument();

            doc.LoadHtml(html);
            var links  = doc.DocumentNode.SelectNodes(LinkNodes);
            var thumbs = doc.DocumentNode.SelectNodes(ThumbNodes);
            int i      = 0;

            if (links == null || thumbs == null)
            {
                return(info);
            }
            foreach (var node in links)
            {
                var anInfo = new PictureData(this)
                {
                    ThumbUrl = HomePage + thumbs[i].Attributes["src"].Value,
                    PageUrl  = HomePage + node.Attributes["href"].Value
                };
                info.Add(anInfo);
                i++;
            }
            ThumbPerPage = info.Count;
            return(info.Count < 1 ? null : info);
        }
Ejemplo n.º 18
0
    public void Init(PictureData picData, bool lazyIconLoad = false, bool showLabels = true, bool isDailyTab = false)
    {
        this.pd       = picData;
        this.lazyLoad = lazyIconLoad;
        this.InternalInit();
        PictureType picType = this.pd.picType;

        if (picType != PictureType.System)
        {
            if (picType != PictureType.Local)
            {
                if (picType == PictureType.Web)
                {
                    this.WebInit();
                }
            }
            else
            {
                this.LocalInit();
            }
        }
        else
        {
            this.SysPicInit();
        }
        if (showLabels && this.pd.Extras != null && this.pd.Extras.labels != null)
        {
            this.labels.AddLabels(this.pd.Extras.labels);
        }
        if (isDailyTab && this.pd.Extras != null && this.pd.Extras.dailyTabDate > 0)
        {
            this.labels.AddDailyTab(this.pd.Extras.dailyTabDate);
        }
    }
Ejemplo n.º 19
0
    IEnumerator Start()
    {
        data = new List <PictureData>();
        for (int i = 0; i < numberOfData; i++)
        {
            PictureData temp = new PictureData();
            temp.id = ids[i];
            data.Add(temp);
        }
        yield return(StartCoroutine(data[0].GetAudio(1)));

        yield return(StartCoroutine(data[0].GetText(1)));

        yield return(StartCoroutine(data[0].GetSprites()));

        StartCoroutine(DataStorage.Instance.Download <SaBan>(this, true));

        aSource = GetComponent <AudioSource>();

        EventManager.Instance.AddListener("OnShowTime", OnEvent);
        EventManager.Instance.AddListener("OnSabanNextData", OnEvent);
        EventManager.Instance.AddListener("OnFinishMoveToObject", OnEvent);
        EventManager.Instance.AddListener("OnMoveToObject", OnEvent);

        pointOfView = transform.TransformPoint(pointOfView);
    }
Ejemplo n.º 20
0
        public PictureContract(PictureData pictureData, Size requestedSize)
        {
            ParamIs.NotNull(() => pictureData);

            Bytes = pictureData.GetBytes(requestedSize);
            Mime  = pictureData.Mime;
        }
Ejemplo n.º 21
0
        public override List <PictureData> ExtractImages(string html)
        {
            var info = new List <PictureData>();
            var doc  = new HtmlDocument();

            doc.LoadHtml(html);
            var links  = doc.DocumentNode.SelectNodes(LinkNodes);
            var thumbs = doc.DocumentNode.SelectNodes(ThumbNodes);
            int i      = 0;

            if (links == null || thumbs == null)
            {
                return(info);
            }
            foreach (var node in links)
            {
                var anInfo = new PictureData(this)
                {
                    ThumbUrl = thumbs[i].Attributes["src"].Value,
                    PageUrl  =
                        node.Attributes["href"].Value.StartsWith("/wall")
                            ? LinkPrefix + node.Attributes["href"].Value
                            : node.Attributes["href"].Value
                        //page has 2 types of wallpaper page url: some with prefix https://avto.goodfon.ru/ some dont.
                };
                info.Add(anInfo);
                i++;
            }
            ThumbPerPage = info.Count;
            return(info.Count < 1 ? null : info);
        }
Ejemplo n.º 22
0
        private void DisplayImage(double[][] source, PictureData pictureData)
        {
            width  = source.Length;
            height = source[0].Length;
            Bitmap bmp = new Bitmap(width, height);

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    int   value = (int)source[i][j];
                    Color c;
                    if (Colored && value < 0)
                    {
                        c = Color.FromArgb(255, 255, 0, 0);
                    }
                    else
                    {
                        c = Color.FromArgb(255, value, value, value);
                    }

                    bmp.SetPixel(i, j, c);
                }
            }
            pictureData.Picture.Image = Image.FromHbitmap(bmp.GetHbitmap());
            tbWidth.Text  = "" + source.Length;
            tbHeight.Text = "" + source[0].Length;
        }
        public async Task <ActionResult <PictureData> > PostPictureData(PictureData pictureData)
        {
            _context.PictureData.Add(pictureData);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPictureData", new { id = pictureData.PictureId }, pictureData));
        }
Ejemplo n.º 24
0
        public void Revert_ImageChanged()
        {
            // Arrange
            var original = CallUpdate(ResourceHelper.TestImage());          // First version, this is the one being restored to

            CallUpdate(ResourceHelper.TestImage2, "image/png");             // Second version, with a different image

            var entryFromRepo = repository.Load <Artist>(artist.Id);

            Assert.IsFalse(PictureData.IsNullOrEmpty(entryFromRepo.Picture), "Artist has picture");
            var oldPictureData = entryFromRepo.Picture.Bytes;

            var oldVer = entryFromRepo.ArchivedVersionsManager.GetVersion(original.Version);             // Get the first archived version

            Assert.IsNotNull(oldVer, "Old version was found");

            // Act
            var result = queries.RevertToVersion(oldVer.Id);

            // Assert
            entryFromRepo = repository.Load <Artist>(result.Id);
            Assert.IsTrue(!PictureData.IsNullOrEmpty(entryFromRepo.Picture), "Artist has picture");
            Assert.AreNotEqual(oldPictureData, entryFromRepo.Picture.Bytes, "Picture data was updated");
            Assert.AreEqual(MediaTypeNames.Image.Jpeg, entryFromRepo.PictureMime, "Picture MIME was updated");

            var lastVersion = entryFromRepo.ArchivedVersionsManager.GetLatestVersion();

            Assert.IsNotNull(lastVersion, "Last version is available");
            Assert.AreEqual(ArtistArchiveReason.Reverted, lastVersion.Reason, "Last version archive reason");
            Assert.IsTrue(lastVersion.Diff.Picture, "Picture was changed");
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Initialisation
 /// </summary>
 public Iterate(int width, int height)
 {
     _gData       = new GraphicData(width, height);
     _pData       = new PictureData(width, height);
     this._width  = width;
     this._height = height;
 }
Ejemplo n.º 26
0
        public PictureContract(PictureData pictureData, string mime)
        {
            ParamIs.NotNull(() => pictureData);

            Bytes = pictureData.Bytes;
            Mime  = mime;
        }
Ejemplo n.º 27
0
        /// <summary>
        /// call Generate(m_act_val,  m_zyklen,  m_raster,  m_screensize,  m_formula,  m_perspective) auf.
        /// </summary>
        protected void Start()
        {
            Generate(_actVal, _cycles, _screensize, _formula, _perspective);
            lock (_startCountLock)
            {
                _startCount--;
            }

            if (_startCount == 0)
            {
                if (_starter != null)
                {
                    if (_abort)
                    {
                        if (_oldData != null)
                        {
                            _gData = _oldData;
                        }
                        if (_oldPictureData != null)
                        {
                            _pData = _oldPictureData;
                        }
                    }
                    System.Diagnostics.Debug.WriteLine("Iter ends");
                    _start = false;
                    _starter.ComputationEnds();
                }
            }
        }
Ejemplo n.º 28
0
    IEnumerator Start()
    {
        data = new PictureData();

        data.id = id;
        //yield return StartCoroutine(data.GetModel());

        yield return(StartCoroutine(data.GetAudio(1)));

        yield return(StartCoroutine(data.GetText(1)));

        yield return(StartCoroutine(data.GetSprites()));

        StartCoroutine(DataStorage.Instance.Download <Picture>(this, true));

        // Nhan su kien
        EventManager.Instance.AddListener("OnShowTime", OnEvent);
        EventManager.Instance.AddListener("OnFinishMoveToObject", OnEvent);
        EventManager.Instance.AddListener("OnEndOfView2D", OnEvent);

        EventManager.Instance.AddListener("OnEndOfPictureView", OnEvent);

        EventManager.Instance.AddListener("OnMoveToObject", OnEvent);

        pointOfView = transform.TransformPoint(pointOfView);
        //pointToLook = transform.TransformPoint(pointToLook);
        //Debug.Log(pointOfView);
    }
Ejemplo n.º 29
0
    public IEnumerator DownLoadContent(bool isSingle = false)
    {
        if (data == null)
        {
            data = new PictureData();
            data.id = id;
            isDownloading = true;
            #region Download Island Content
            yield return StartCoroutine(data.GetAudio(1));
            AssetBundleLoadAssetOperation request =
                BundleManager.LoadAssetAsync(data.audioBundle[0], data.audioBundle[1], typeof(AudioClip));
            if (request == null)
                yield break;
            yield return StartCoroutine(request);
            data.introAudio = request.GetAsset<AudioClip>();

            request = BundleManager.LoadAssetAsync(data.audioBundle[2], data.audioBundle[3], typeof(AudioClip));
            Debug.Log(request);
            if (request == null)
                yield break;
            yield return StartCoroutine(request);
            data.detailAudio = request.GetAsset<AudioClip>();
            // =====================================

            //// Download text================
            //bundleName = "";
            //assetName = "";
            //request = null;
            //DBManager.Instance.GetText(id, ref bundleName, ref assetName);
            //request = BundleManager.LoadAssetAsync(bundleName, assetName, typeof(TextAsset));
            //if (request == null)
            //    yield break;
            //yield return StartCoroutine(request);
            ////Debug.Log(request.GetAsset<TextAsset>());
            //data.text = request.GetAsset<TextAsset>();
            //// =====================================

            // Download sprites================
            yield return StartCoroutine(data.GetSprites());
            int size = data.spriteBundle.Length - 1;
            for (int i = 0; i < size; i += 2)
            {
                request = BundleManager.LoadAssetAsync(data.spriteBundle[i], data.spriteBundle[i + 1], typeof(Sprite));
                if (request == null)
                    yield break;
                yield return StartCoroutine(request);
                data.sprites.Add(request.GetAsset<Sprite>());
            }
            // =====================================

            data.imgTime = time;
            #endregion
            isDownloading = false;
        }

        isReady = true;
        if (!isSingle)
            EventManager.Instance.PostNotification("OnDownloadIsland", this, order + 1);
    }
Ejemplo n.º 30
0
        public PictureDataContract(PictureData pictureData)
        {
            ParamIs.NotNull(() => pictureData);

            Bytes    = pictureData.Bytes;
            Mime     = pictureData.Mime;
            Thumb250 = (pictureData.Thumb250 != null ? new PictureThumbContract(pictureData.Thumb250) : null);
        }
Ejemplo n.º 31
0
 /// <summary>
 /// Returns a thumbnail of the picture. If the picture already contains an embeded thumbnail,
 /// that thumbnail is returned scaled to the size
 /// </summary>
 /// <param name="width">the width in pixel</param>
 /// <param name="height">The height in pixel</param>
 /// <returns>The thumbnail</returns>
 /// <exception cref="ModelException">Throws an exception if picture data is null</exception>
 public Image GetThumbnail(int width, int height)
 {
     if (PictureData == null)
     {
         throw new Exceptions.ModelException("PictureData is null");
     }
     return(PictureData.GetThumbnailImage(width, height, () => false, IntPtr.Zero));
 }
Ejemplo n.º 32
0
 IEnumerator StartPlay()
 {
     if (recvData.text != null)
     {
         textObject.text = recvData.text.text;
     }
     StartCoroutine(recvData.PlayImage(image));
     yield return StartCoroutine(recvData.PlayAudio(audioSource, false));
     EventManager.Instance.PostNotification("OnEndOfView2D", this, recvData.id);
     recvData = null;
     gameObject.SetActive(false);
 }
Ejemplo n.º 33
0
 public void OnEvent(string eventType, Component sender, object param = null)
 {
     switch (eventType)
     {
         case "OnPictureClick":
             {
                 gameObject.SetActive(true);
                 recvData = (PictureData)param;
                 if (recvData != null)
                 {
                     Item.isInteractable = false;
                     StartCoroutine(StartPlay());
                 }
                 break;
             }
         default:
             break;
     }
 }
Ejemplo n.º 34
0
    IEnumerator Start()
    {
        data = new List<PictureData>();
        for (int i = 0; i < numberOfData; i++)
        {
            PictureData temp = new PictureData();
            temp.id = ids[i];
            data.Add(temp);
        }
        yield return StartCoroutine(data[0].GetAudio(1));
        yield return StartCoroutine(data[0].GetText(1));
        yield return StartCoroutine(data[0].GetSprites());

        StartCoroutine(DataStorage.Instance.Download<SaBan>(this, true));

        aSource = GetComponent<AudioSource>();

        EventManager.Instance.AddListener("OnShowTime", OnEvent);
        EventManager.Instance.AddListener("OnSabanNextData", OnEvent);
        EventManager.Instance.AddListener("OnFinishMoveToObject", OnEvent);
        EventManager.Instance.AddListener("OnMoveToObject", OnEvent);

        pointOfView = transform.TransformPoint(pointOfView);
    }
Ejemplo n.º 35
0
    public void OnEvent(string eventType, Component sender, object param = null)
    {
        switch (eventType)
        {
            case "OnPictureManualClick":
                {
                    recvData = (PictureData)param;
                    if (recvData != null)
                    {
                        listImage = new Sprite[recvData.sprites.Count];
                        for (int i = 0; i < recvData.sprites.Count; i++)
                        {
                            listImage[i] = recvData.sprites[i];
                        }
                        maxImage = recvData.sprites.Count;
                        Debug.Log("max image " + maxImage);
                        View2dWindow.SetActive(true);
                        audio.clip = recvData.detailAudio;
                        uiSliderTime.minValue = 0;
                        uiSliderTime.maxValue = audio.clip.length;
                        //Debug.Log(audio.clip);
                        audio.Play();
                        imageDisplay.sprite = listImage[0];
                        //AutoNextImage();
                    }
                    break;

                }
            case "OnReload":
                {
                    HideSiteMap();
                    break;
                }

            default:
                break;
        }
    }
Ejemplo n.º 36
0
    public void OnEvent(string eventType, Component sender, object param = null)
    {
        switch (eventType)
        {
            case "OnSabanFirstTime":
                {
                    gameObject.SetActive(true);
                    count = 0;
                    sabanData = (PictureData)param;

                    Debug.Log("OnFirstTime");

                    // Khong cho tuong tac voi cac vat the khi dang trong man hinh 2D
                    Item.isInteractable = false;
                    AICharacterControl.isEscapable = false;

                    // Play detail audio
                    StartCoroutine(PlayContent(true, false));

                    break;
                }

            case "OnSabanShowTime":
                {
                    sabanData = (PictureData)param;

                    StartCoroutine(PlayContent(false, false));
                    Debug.Log("OnShowTime");

                    break;
                }

            case "OnSabanLastTime":
                {

                    sabanData = (PictureData)param;

                    StartCoroutine(PlayContent(false, true));

                    // Mo các đảo để download
                    islandView.SetActive(true);

                    Debug.Log("OnLastTime");

                    break;
                }

            case "OnIslandPlay":
                {

                    //Debug.Log(param);

                    if (PlayerPrefs.GetInt("IsAutoMode") == 1)
                    {
                        sabanData = (PictureData)param;
                        StartCoroutine(AutoPlayIsland());
                    }

                    else
                    {
                        if (sabanData != null && islandPlayRoutine != null)
                        {
                            StopCoroutine(islandPlayRoutine);
                            sabanData.Stop();
                        }
                        sabanData = (PictureData)param;
                        islandPlayRoutine = PlayIsland();
                        StartCoroutine(islandPlayRoutine);
                    }

                    break;
                }

            default:
                break;
        }
    }
Ejemplo n.º 37
0
    IEnumerator Start()
    {
        data = new PictureData();

        data.id = id;
        //yield return StartCoroutine(data.GetModel());

        yield return StartCoroutine(data.GetAudio(1));
        yield return StartCoroutine(data.GetText(1));
        yield return StartCoroutine(data.GetSprites());
        StartCoroutine(DataStorage.Instance.Download<Picture>(this, true));

        // Nhan su kien
        EventManager.Instance.AddListener("OnShowTime", OnEvent);
        EventManager.Instance.AddListener("OnFinishMoveToObject", OnEvent);
        EventManager.Instance.AddListener("OnEndOfView2D", OnEvent);

        EventManager.Instance.AddListener("OnEndOfPictureView", OnEvent);

        EventManager.Instance.AddListener("OnMoveToObject", OnEvent);

        pointOfView = transform.TransformPoint(pointOfView);
        //pointToLook = transform.TransformPoint(pointToLook);
        //Debug.Log(pointOfView);
    }