Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        PreviewItem tempItem = GetComponent <PreviewItem>();

        if (tempItem != null)
        {
            levelInfo = tempItem.info;
        }
    }
Exemplo n.º 2
0
    public void PreviewItemClick(PreviewItem previewItem)
    {
        CodelabUtils._ShowAndroidToastMessage("Preview Image is clicked");

        overpreview.texture = previewItem.preview;

        Texture2D texture = previewItem.preview;

        Sprite image = Sprite.Create(texture, new Rect(0f, 0f, 512f, 512f), new Vector2(0, 0));

        imagepreview.sprite = image;
    }
Exemplo n.º 3
0
    private IEnumerator downloadTexture(string imagestring)
    {
        Texture2D texture = new Texture2D(512, 512);



        //var handler = UnityWebRequestTexture.GetTexture(asset.images[0]).downloadHandler;

        UnityWebRequest www = UnityWebRequestTexture.GetTexture(imagestring);

        // yield return new WaitUntil(() => handler.isDone);

        yield return(www.SendWebRequest());


        if (www.isNetworkError || www.isHttpError)
        {
            CodelabUtils._ShowAndroidToastMessage($"Something went wrong : {www.error}");
        }
        else
        {
            texture = ((DownloadHandlerTexture)www.downloadHandler).texture;
            // ---------------------- or -------------------------
            // texture = DownloadHandlerTexture.GetContent(www);

            CodelabUtils._ShowAndroidToastMessage($"Texture is got");
        }

        PreviewItem previewItem = new PreviewItem(texture, imagestring);

        CodelabUtils._ShowAndroidToastMessage($"downloadtexture : Adding Item {previewItem.id}");


        // TODO: check if the itemchild is contain in the Itemchildren. use a method to loop through the itemchildren and check



        // Add to the preview list and spawn the image object
        if (!isPreviewInList.Contains(previewItem.id))
        {
            previewItems.Add(previewItem);
            SpawnPreview(previewItems);

            isPreviewInList.Add(previewItem.id);
        }
    }
Exemplo n.º 4
0
 private void SaveImage(PreviewItem item)
 {
     if (item.IsSavedDone == true)
     {
         return;
     }
     try
     {
         MyMainWindow.SaveBitmapSub(item.Image, item.SavePath);
         item.IsSavedDone = true;
         UpdateStatusText($"{item.SavePath}に保存した");
     }
     catch (Exception ex)
     {
         UpdateStatusText($"{item.SavePath}の保存に失敗した");
         MessageBox.Show($"セーブできなかった\n{ex}");
     }
 }
Exemplo n.º 5
0
 public static Texture GetPreviewIcon(PreviewItem item, Data.RuleObject rule)
 {
     RuleObj = rule;
     if (rule == null || item.layerType != LayerType.Group)
     {
         return(previewIcons[item.layerType.ToString()]);
     }
     else
     {
         string   groupType = PSDUnityConst.emptySuffix;
         string[] args;
         rule.AnalysisGroupName(item.name, out groupType, out args);
         if (!previewIcons.ContainsKey(groupType))
         {
             previewIcons[groupType] = LoadTexture(groupType);
         }
         return(previewIcons[groupType]);
     }
 }
Exemplo n.º 6
0
        public async Task <ActionResult> ShowPreview(int id)
        {
            await IncrementPageCounters();

            using (var dataBase = new ApplicationDbContext())
            {
                byte[] fileContent        = null;
                var    currentPreviewItem = dataBase.PreviewItems.SingleOrDefault(previewItem => previewItem.ImageId == id);
                if (currentPreviewItem != null)
                {
                    fileContent = currentPreviewItem.Image;
                }
                else
                {
                    var galleryItem = dataBase.Images.SingleOrDefault(item => item.Id == id);

                    fileContent = galleryItem.Image;
                    if (IsJpegOrPngImage(fileContent))
                    {
                        var resizedImage      = ResizeImage(fileContent, width: 300, height: 225);
                        var resizedImageBytes = (byte[])new ImageConverter().ConvertTo(resizedImage, typeof(byte[]));

                        var previewItem = new PreviewItem();
                        previewItem.ImageId = id;
                        previewItem.Image   = new byte[resizedImageBytes.Length];
                        Array.Copy(resizedImageBytes, previewItem.Image, resizedImageBytes.Length);
                        dataBase.PreviewItems.Add(previewItem);
                        dataBase.SaveChanges();

                        fileContent = previewItem.Image;
                    }
                }

                if (IsJpegOrPngImage(fileContent))
                {
                    fileContent = WatermarkImage(fileContent);
                }

                var fileName = $"{Path.GetFileNameWithoutExtension(Path.GetRandomFileName())}.jpg";
                return(File(fileContent, "image/jpg", fileName));
            }
        }
Exemplo n.º 7
0
            private void run_npc(NpcData data)
            {
                List <NpcDropGroup> items = data.GetDropGroups();

                if (items == null)
                {
                    return;
                }
                //
                PreviewItem  preview_item;
                NpcDropGroup group, src_group;
                decimal      sum = 0m;
                int          cc, c = items.Count;

                for (int i = 0; i < c; i++)
                {
                    src_group = items[i];
                    if (src_group.GetSum(ref sum))
                    {
                        group = src_group.Clone();
                        group.BalanceRemainders(ref sum);
                        //
                        NpcDropItem item, src_item;
                        cc = group.Items.Count;
                        for (int y = 0; y < cc; y++)
                        {
                            item                    = group.Items[y];
                            src_item                = src_group.Items[y];
                            preview_item            = new PreviewItem(data, item);
                            preview_item.ChancePre  = src_item.Chance.ToString("#,##0.#####");
                            preview_item.ChancePost = item.Chance.ToString("#,##0.#####");
                            if (y > 0)
                            {
                                preview_item.NpcName = null;
                            }
                            PreviewItems.Add(preview_item);
                        }
                        count++;
                    }
                    Total++;
                }
            }
Exemplo n.º 8
0
 internal static Texture GetPreviewIcon(PreviewItem item, RuleObject rule)
 {
     if (rule == null || item.layerType != LayerType.Group)
     {
         return(previewIcons[item.layerType.ToString()]);
     }
     else
     {
         GroupType groupType = GroupType.EMPTY;
         string[]  args;
         /*string name = */ rule.AnalysisGroupName(item.name, out groupType, out args);
         if (previewIcons.ContainsKey(groupType.ToString()) && previewIcons[groupType.ToString()] != null)
         {
             return(previewIcons[groupType.ToString()]);
         }
         else
         {
             return(previewIcons[LayerType.Group.ToString()]);
         }
     }
 }
    // -----
    public void SetItem(PreviewItem item)
    {
        m_ResearchItem = item;

        m_Description.SetNewText(m_ResearchItem.GetDescription());

        int maxParams = item.GetNumOfParams();

        for (int i = 0; i < maxParams; i++)
        {
            m_Params[i].Name.Uppercase = true;
            m_Params[i].Name.SetNewText(item.GetParamName(i));
            m_Params[i].Value.SetNewText(item.GetParamValue(i));
            m_Params[i].Value.Widget.Color = Color.white;
            ShowWidget(m_Params[i].Parent, true);
        }

        for (int i = maxParams; i < ResearchItem.MAX_PARAMS; i++)
        {
            ShowWidget(m_Params[i].Parent, false);
        }
    }
Exemplo n.º 10
0
        /// <summary>
        /// Update the preview pane... should do this whenever the item or type changes
        /// </summary>
        /// <param name="window"></param>
        void Update()
        {
            switch (PreviewType)
            {
            case PreviewTypes.NONE:
            case PreviewTypes.PREVIEW:
                break;

            case PreviewTypes.DEPTHMAP:
                if (window.SelectedDepthmap != PreviewItem)
                {
                    PreviewItem = window.SelectedDepthmap;
                }
                break;

            case PreviewTypes.TEXTURE:
                if (window.SelectedTexture != null && window.SelectedTexture != PreviewItem)
                {
                    PreviewItem = window.SelectedTexture;
                }
                break;

            case PreviewTypes.STEREOGRAM:
                if (window.SelectedStereogram != null && window.SelectedStereogram != PreviewItem)
                {
                    PreviewItem = window.SelectedStereogram;
                }
                break;

            default:
                throw new Exception("Unknown preview type");
            }

            if (PreviewItem != null)
            {
                imageView2D.Source = PreviewItem.GetBitmap();
            }
        }
Exemplo n.º 11
0
    void AutoCreatePreviewItems()
    {
        if (levelInfos != null && originalPreviewItem != null)
        {
            for (int i = 0; i < levelInfos.Length; i++)
            {
                LevelInfo   tempInfo   = levelInfos[i];
                PreviewItem clonedItem = GameObject.Instantiate(originalPreviewItem) as PreviewItem;
                clonedItem.transform.parent        = this.transform;
                clonedItem.info                    = tempInfo;
                clonedItem.transform.localScale    = Vector3.one;
                clonedItem.transform.localPosition = Vector2.zero;
                clonedItem.indexForClassic         = i + 1;
            }
        }
        UIGrid uigrid = this.GetComponent <UIGrid>();

        if (null != uigrid)
        {
            uigrid.repositionNow = true;
            uigrid.Reposition();
        }
    }
Exemplo n.º 12
0
 public MyDispatcherTimer(PreviewItem parent)
 {
Exemplo n.º 13
0
 private void ShowNextItem(object sender, EventArgs eventArgs)
 {
     DispatcherTimer thisTimer = (DispatcherTimer)sender;
     PreviewItem     thisItem  = this;  // <-- for example, because you're in the object itself...
Exemplo n.º 14
0
 public void SetUp(PreviewItem item, Overview overviews)
 {
     preview.texture = item.preview;
     Overview        = overviews;
     previewItem     = item;
 }
Exemplo n.º 15
0
 /// <summary>
 /// Adds the previewItem to the end of the list.
 /// </summary>
 /// <param name="previewItem">The rule to be added to the end of the list.</param>
 public void Add(PreviewItem previewItem)
 {
     List.Add(previewItem);
 }