Exemplo n.º 1
0
 // Use this for initialization
 void Awake()
 {
     if (inistance == null)
     {
         inistance = this;
     }
 }
Exemplo n.º 2
0
    public void updateAvatar(string userId, string token, byte[] avatar)
    {
        var client = new RestClient(Endpoint.classesURL + "/users/" + userId);

        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
        ServicePointManager.ServerCertificateValidationCallback = MyRemoteCertificateValidationCallback;
        var request = new RestRequest(Method.PUT);

        request.AddHeader("x-access-token", token);
        request.AddFile("avatar", avatar, "avatar");
        bool   cmp = false;
        string res = null;

        client.ExecuteAsync(request, response =>
        {
            //Debug.Log(response.Content);
            res = response.Content;
            cmp = true;
        });
        if (!string.IsNullOrEmpty(res))
        {
            var N = JSON.Parse(res);
            if (N["success"].AsBool == true)
            {
                UnityThreadHelper.Dispatcher.Dispatch(() =>
                {
                    UserManager.CurrentAvatarBytesString = ImagesManager.getSpriteFromBytes(avatar);
                });
            }
        }
    }
Exemplo n.º 3
0
    public void init(string mealName)
    {
        if (title != null)
        {
            this.title.text = mealName;
        }

        if (BG != null)
        {
            ImagesManager.LoadImage(DataManager.getMeal(mealName).imgUrl, BG);
        }

        if (isMeal)
        {
            var btn = gameObject.GetComponent <Button>();
            if (btn == null)
            {
                btn = gameObject.AddComponent <Button>();
            }
            btn.onClick.AddListener(() =>
            {
                ShowDescription(mealName);
            });
        }
    }
Exemplo n.º 4
0
        public ActionResult GetImages(int itemID, string code)
        {
            var           res   = false;
            var           mng   = new ImagesManager();
            List <Object> files = new List <Object>();

            try
            {
                List <as_images> lst = mng.GetImages(itemID, code);

                foreach (var item in lst)
                {
                    files.Add(new { originalUrl = mng.GetImageLink(item), thumbUrl = mng.GetImageLink(item, true), item.id, item.url, item.name, item.description });
                }
                res = true;
            }
            catch (Exception ex)
            {
                RDL.Debug.LogError(ex);
            }


            return(Json(new
            {
                result = res,
                items = files
            }));
        }
Exemplo n.º 5
0
 private void CommentRemove(PostComments coment, PaintStoreContext db)
 {
     db.PostComments.Remove(db.PostComments.First(x => x.Id == coment.Id));
     ImagesManager.ImageCommentCountMinus(db, coment.PostId);
     foreach (var like in db.CommentLikes.Where(x => x.CommentId == coment.Id))
     {
         db.CommentLikes.Remove(db.CommentLikes.First(x => x.Id == like.Id));
     }
 }
        // To add new game menu items override GetGameMenuItems
        public override IEnumerable <GameMenuItem> GetGameMenuItems(GetGameMenuItemsArgs args)
        {
            var GameMenu = args.Games.First();

            List <GameMenuItem> gameMenuItems = new List <GameMenuItem>();

            if (PluginSettings.Settings.EnableBackgroundImage)
            {
                gameMenuItems.Add(new GameMenuItem
                {
                    // Manage game background
                    MenuSection = resources.GetString("LOCBc"),
                    Description = resources.GetString("LOCBcManageBackground"),
                    Action      = (gameMenuItem) =>
                    {
                        var ViewExtension      = new ImagesManager(PlayniteApi, PluginDatabase.Get(GameMenu), false);
                        Window windowExtension = PlayniteUiHelper.CreateExtensionWindow(PlayniteApi, resources.GetString("LOCBc") + " - " + resources.GetString("LOCGameBackgroundTitle"), ViewExtension);
                        windowExtension.ShowDialog();
                    }
                });
            }

            if (PluginSettings.Settings.EnableCoverImage)
            {
                gameMenuItems.Add(new GameMenuItem
                {
                    // Manage game cover
                    MenuSection = resources.GetString("LOCBc"),
                    Description = resources.GetString("LOCBcManageCover"),
                    Action      = (gameMenuItem) =>
                    {
                        var ViewExtension      = new ImagesManager(PlayniteApi, PluginDatabase.Get(GameMenu), true);
                        Window windowExtension = PlayniteUiHelper.CreateExtensionWindow(PlayniteApi, resources.GetString("LOCBc") + " - " + resources.GetString("LOCGameCoverImageTitle"), ViewExtension);
                        windowExtension.ShowDialog();
                    }
                });
            }

#if DEBUG
            gameMenuItems.Add(new GameMenuItem
            {
                MenuSection = resources.GetString("LOCBc"),
                Description = "-"
            });
            gameMenuItems.Add(new GameMenuItem
            {
                MenuSection = resources.GetString("LOCBc"),
                Description = "Test",
                Action      = (mainMenuItem) =>
                {
                }
            });
#endif

            return(gameMenuItems);
        }
Exemplo n.º 7
0
        public PostComments AddComment(AddPostCommentCommand comment)
        {
            ImagesManager.ImageCommentCountPlus(_paintStoreContext, comment.PostId);
            var commentToAdd = _mapper.Map <PostComments>(comment);

            commentToAdd.CreationDate = DateTime.Now;
            _paintStoreContext.PostComments.Add(commentToAdd);
            _paintStoreContext.SaveChanges();
            return(commentToAdd);
        }
Exemplo n.º 8
0
        private void AddWaiting()
        {
            var center = Utils.Viewport.GetViewportCenter();

            var waitLabel = new BaseGuiComponent();

            waitLabel.Texture  = new DrawTexture(ImagesManager.GetTexture("wait"), "waitsign");
            waitLabel.Position = new Vector2(center.X - waitLabel.Texture.Size.X * 0.5f, center.Y - waitLabel.Texture.Size.Y * 0.5f);
            Components.Add(waitLabel);
        }
Exemplo n.º 9
0
    private void Awake()
    {
        Weather = GetComponent <WeatherManager>();
        Images  = GetComponent <ImagesManager>();

        _startSequence = new List <IGameManager>()
        {
            Weather, Images
        };
        StartCoroutine(StartupManagers());
    }
Exemplo n.º 10
0
    public static Sprite getSpriteFromBytes(byte[] bytes)
    {
        Texture2D texture   = new Texture2D(1, 1);
        Sprite    newSprite = null;

        texture.LoadImage(bytes);
        Texture2D roundTxt = ImagesManager.RoundCrop(texture);

        newSprite = Sprite.Create(roundTxt as Texture2D, new Rect(0f, 0f, roundTxt.width, roundTxt.height), Vector2.zero);
        return(newSprite);
    }
Exemplo n.º 11
0
    void Awake()
    {
        Weather = GetComponent <WeatherManager>();
        Images  = GetComponent <ImagesManager>();

        _startSequence = new List <IGameManager>();
        _startSequence.Add(Weather);
        _startSequence.Add(Images);

        StartCoroutine(StartupManagers());
    }
    public IEnumerator initPlayerAvatar(string url, Image avatar)
    {
        var www = new WWW(url);

        yield return(www);

        var       texture  = www.texture;
        Texture2D RoundTxt = ImagesManager.RoundCrop(texture);

        avatar.sprite = Sprite.Create(RoundTxt, new Rect(0, 0, RoundTxt.width, RoundTxt.height), new Vector2(0, 0));
    }
Exemplo n.º 13
0
        public int RemoveImageLike(int userId, int postId)
        {
            using (var db = _paintStoreContext)
            {
                var likeId = db.PostLikes.First(x => x.PostId == postId && x.UserId == userId).Id;

                ImagesManager.ImageLikesCountMinus(db, db.PostLikes.First(x => x.Id == likeId).PostId);
                db.PostLikes.Remove(db.PostLikes.First(x => x.Id == likeId));
                db.SaveChanges();
                return(likeId);
            }
        }
Exemplo n.º 14
0
        private void setAvatar(Texture2D texture)
        {
            Texture2D RoundTxt  = ImagesManager.RoundCrop(texture);
            Sprite    newSprite = Sprite.Create(RoundTxt, new Rect(0, 0, RoundTxt.width, RoundTxt.height), new Vector2(0, 0));

            //Create Sprite and change Profile Avatar
            try {
                GameObject.Find("_Avatar").GetComponent <Image> ().sprite = newSprite;
            } catch (NullReferenceException ex) {
            }
            GameObject.Find("Avatar").GetComponent <Image> ().sprite = newSprite;
        }
Exemplo n.º 15
0
    void updateHeader()
    {
        UserManager um     = new UserManager();
        string      userid = um.getCurrentUserId();
        string      token  = um.getCurrentSessionToken();

        UnityThreadHelper.CreateThread(() => {
            User usr = um.getUser(userid, token);
            if (usr != null)
            {
                Byte[] lnByte = um.getAvatar(usr.avatar);
                UnityThreadHelper.Dispatcher.Dispatch(() => {
                    UserManager.CurrentMoney = usr.money_credit.ToString("N2");
                    UserManager.CurrentWater = usr.bubble_credit.ToString();
                    GameObject.Find("virtual_money").GetComponent <Text>().text = UserManager.CurrentWater;
                    GameObject.Find("solde_euro").GetComponent <Text>().text    = UserManager.CurrentMoney + " " + CurrencyManager.CURRENT_CURRENCY;
                    if (usr.money_credit > 0)
                    {
                        GameObject.Find("Pro").transform.localScale = Vector3.one;
                    }
                    else
                    {
                        GameObject.Find("Pro").transform.localScale = Vector3.zero;
                    }
                    if (UserManager.CurrentAvatarURL != usr.avatar)
                    {
                        Sprite avatar = ImagesManager.getSpriteFromBytes(lnByte);
                        UserManager.CurrentAvatarBytesString = avatar;
                        Image PlayerAvatar  = GameObject.Find("Avatar").GetComponent <Image> ();
                        PlayerAvatar.sprite = avatar;
                    }

                    UserManager.CurrentUsername = usr.username;
                    Text username = GameObject.Find("Text_name").GetComponent <Text> ();
                    username.text = usr.username;
                    PullToRefresh.walletFinished = true;
                    InvokeRepeating("hideAnimation", 0f, 0.5f);
                });
            }
            else
            {
                UnityThreadHelper.Dispatcher.Dispatch(() => {
                    lastResultfinished = true;
                    ongoingfinished    = true;
                    walletFinished     = true;
                    InvokeRepeating("hideAnimation", 0f, 2f);
                    HomeController.GetComponent <HomeController>().enabled = false;
                    HomeController.GetComponent <HomeController>().enabled = true;
                });
            }
        });
    }
Exemplo n.º 16
0
 void Awake()
 {
     Player    = GetComponent <PlayerManager> ();
     Inventory = GetComponent <InventoryManager> ();
     Weather   = GetComponent <WeatherManager> ();
     Images    = GetComponent <ImagesManager> ();
     _managers = new List <IGameManager> ();
     _managers.Add(Player);
     _managers.Add(Inventory);
     _managers.Add(Weather);
     _managers.Add(Images);
     StartCoroutine(StartManagers());
 }
Exemplo n.º 17
0
    void Awake()
    {
        Player    = GetComponent <PlayerManager>();
        Inventory = GetComponent <InventoryManager>();
        Weather   = GetComponent <WeatherManager>();
        Images    = GetComponent <ImagesManager>();

        managers = new List <IGameManager>()
        {
            Player, Inventory, Weather, Images
        };

        StartCoroutine(StartupManagers());
    }
Exemplo n.º 18
0
 public int CommentRemove(int commentId)
 {
     using (var db = _paintStoreContext)
     {
         ImagesManager.ImageCommentCountMinus(db, db.PostComments.First(x => x.Id == commentId).PostId);
         db.PostComments.Remove(db.PostComments.First(x => x.Id == commentId));
         foreach (var like in db.CommentLikes.Where(x => x.CommentId == commentId))
         {
             db.CommentLikes.Remove(db.CommentLikes.First(x => x.Id == like.Id));
         }
         db.SaveChanges();
     }
     return(commentId);
 }
Exemplo n.º 19
0
 public PostLikes AddImageLike(PostLikes like)
 {
     using (var db = _paintStoreContext)
     {
         if ((db.PostLikes.Any(x => x.PostId == like.PostId && x.UserId == like.UserId)))
         {
             throw new NegotiatedContentResultException();
         }
         ImagesManager.ImageLikesCountPlus(db, like.PostId);
         db.PostLikes.Add(like);
         db.SaveChanges();
         return(like);
     }
 }
Exemplo n.º 20
0
    private List <IGameManager> _startSequence; // Список диспетчеров, который просматривается в цикле во время стартовой последовательности

    void Awake()
    {
        Player    = GetComponent <PlayerManager>();
        Inventory = GetComponent <InventoryManager>();
        Weather   = GetComponent <WeatherManager>();
        Images    = GetComponent <ImagesManager>();

        _startSequence = new List <IGameManager>();
        _startSequence.Add(Player);
        _startSequence.Add(Inventory);
        _startSequence.Add(Weather);
        _startSequence.Add(Images);

        StartCoroutine(StartupManagers()); // Асирнхронно загружаем статовую последовательность
    }
Exemplo n.º 21
0
        public async Task <IActionResult> EditProduct(ProductEditorVM model)
        {
            if (ModelState.IsValid)
            {
                if (model.ImageFile != null)
                {
                    string fileName = model.Product.ImagePath = ImagesManager.CreateFileName(model.ImageFile);
                    await ImagesManager.SaveImageToFolder(_webHostEnvironment.WebRootPath,
                                                          ProductImagesFolder, fileName, model.ImageFile);
                }
                await _productService.UpdateProduct(model.Product);

                return(RedirectToAction("ProductList"));
            }

            model.Categories = new SelectList(await _categoryService.GetAllCategories(), "Id", "Name");
            return(View(model));
        }
Exemplo n.º 22
0
        public MenuScene()
        {
            Name = "mainmenu";

            Components.Add(new StaticBackground()
            {
                Texture = new DrawTexture(ImagesManager.GetTexture("mainmenu"))
            });

            var center = Utils.Viewport.GetViewportCenter();

            var logo = new BaseGuiComponent();

            logo.Texture = new DrawTexture(ImagesManager.GetTexture("menu"), "logo");
            var left = center.X - logo.Texture.Size.X * 0.5f;

            logo.Position = new Vector2(left, logo.Position.Y);
            Components.Add(logo);

            var newGameButton = new GuiButton();

            newGameButton.Texture      = new DrawTexture(ImagesManager.GetTexture("menu"), "newgame0");
            newGameButton.HoverTexture = new DrawTexture(ImagesManager.GetTexture("menu"), "newgame1");
            newGameButton.Position     = new Vector2(left, 300);

            Components.Add(newGameButton);

            var quitButton = new GuiButton();

            quitButton.Texture         = new DrawTexture(ImagesManager.GetTexture("menu"), "quit0");
            quitButton.HoverTexture    = new DrawTexture(ImagesManager.GetTexture("menu"), "quit1");
            quitButton.Position        = new Vector2(left, newGameButton.Texture.Size.Y + newGameButton.Position.Y);
            quitButton.MouseLeftClick += (sender, args) => Program.Game.Exit();
            Components.Add(quitButton);

            newGameButton.MouseLeftClick += (sender, args) =>
            {
                logo.isVisible          = false;
                newGameButton.isVisible = false;
                quitButton.isVisible    = false;
                //AddWaiting();
            };
        }
Exemplo n.º 23
0
        public ActionResult DeleteImage(int id)
        {
            var res = false;
            var mng = new ImagesManager();

            try
            {
                mng.DeleteImage(id);
                res = true;
            }
            catch (Exception ex)
            {
                RDL.Debug.LogError(ex);
            }

            return(Json(new
            {
                result = res
            }));
        }
Exemplo n.º 24
0
        public ActionResult UpdateImagesOrder(int itemID, string code, string nums)
        {
            var res = false;
            var mng = new ImagesManager();

            try
            {
                mng.UpdateImagesOrder(nums, itemID, code);
                res = true;
            }
            catch (Exception ex)
            {
                RDL.Debug.LogError(ex);
            }

            return(Json(new
            {
                result = res
            }));
        }
Exemplo n.º 25
0
        public ActionResult Upload()
        {
            int    itemID      = RDL.Convert.StrToInt(HttpContext.Request.Form["itemID"].ToString(), 0);
            string code        = HttpContext.Request.Form["code"].ToString();
            int    thumbWidth  = RDL.Convert.StrToInt(HttpContext.Request.Form["thumbWidth"].ToString(), 0);
            int    thumbHeight = RDL.Convert.StrToInt(HttpContext.Request.Form["thumbHeight"].ToString(), 0);

            var mng     = new ImagesManager();
            var context = HttpContext;

            try
            {
                var file = context.Request.Files["Filedata"];
                if (itemID == 0)
                {
                    return(Content("0"));
                }

                if (file != null)
                {
                    var item = new as_images {
                        ord = 20000, itemID = itemID, filename = file.FileName, id = 0, description = "", name = "", url = "", typeCode = code
                    };
                    int id = mng.SaveImage(item);

                    if (file.ContentType.ToLower() == "image/jpeg" || file.ContentType.ToLower() == "image/jpg" ||
                        file.ContentType.ToLower() == "image/gif" || file.ContentType.ToLower() == "image/png" ||
                        file.ContentType.ToLower() == "application/octet-stream")
                    {
                        System.Drawing.Image img = System.Drawing.Image.FromStream(file.InputStream);
                        mng.UploadImage(item, img, thumbWidth, thumbHeight, file.ContentType.ToLower());
                    }
                }
                return(Content("1"));
            }
            catch (Exception ex)
            {
                RDL.Debug.LogError(ex);
            }
            return(Content("0"));
        }
Exemplo n.º 26
0
    public void init(string mealName)
    {
        var meal = DataManager.getMeal(mealName);

        MealName.text        = meal.name;
        MealDescription.text = meal.Descriptio;
        MealHow.text         = meal.How;

        ImagesManager.LoadImage(meal.imgUrl, MealImg);

        FillContainer(meal.Categories, CatigoriesContainer, CatigorieTempItem, (name) =>
        {
            GameObject.Find("InputField").GetComponent <InputField>().text = name;
        });
        FillContainer(meal.Ingreadients, ingradiantsContainer, ingradiantTempItem, (name) =>
        {
            ingreadientsHirarchy.gameObject.SetActive(true);
            ingreadientsHirarchy.init(name);
        });
        FillContainer(DataManager.GetExtraMeals(mealName), RemainingContainer, RemainingTempItem);
    }
Exemplo n.º 27
0
    private List <IGameManager> _startSequence; // Список диспетчеров, который просматривается в цикле во время стартовой последовательности

    void Awake()
    {
        DontDestroyOnLoad(gameObject); // Сохраняет объект между сценами

        Data      = GetComponent <DataManager>();
        Player    = GetComponent <PlayerManager>();
        Inventory = GetComponent <InventoryManager>();
        Mission   = GetComponent <MissionManager>();

        Weather = GetComponent <WeatherManager>();
        Images  = GetComponent <ImagesManager>();

        _startSequence = new List <IGameManager>();
        _startSequence.Add(Player);
        _startSequence.Add(Inventory);
        _startSequence.Add(Mission);
        _startSequence.Add(Data);

        _startSequence.Add(Weather);
        _startSequence.Add(Images);

        StartCoroutine(StartupManagers()); // Асирнхронно загружаем статовую последовательность
    }
Exemplo n.º 28
0
        private void InitializeList()
        {
            this.listView1.SmallImageList = ImagesManager.GetImages();

            ColumnHeader serialNo = new ColumnHeader();

            serialNo.Text      = "Serial No.";
            serialNo.Width     = 50;
            serialNo.TextAlign = HorizontalAlignment.Center;

            this.listView1.Columns.Add(serialNo);
            this.listView1.Columns.Add("File/Folder Name").Width = 100;
            this.listView1.Columns.Add("Left Folder").Width      = 300;
            this.listView1.Columns.Add("Right Folder").Width     = 300;
            this.listView1.Columns.Add("Match").Width            = 100;

            List <ColumnItem> columnItems = DirectoryComparerBaseInfo.Preferences.Columns;

            foreach (var item in columnItems.Where(c => c.IsVisible))
            {
                this.listView1.Columns.Add(item.ColumnCaption).Width = 100;
            }
        }
Exemplo n.º 29
0
    public void init()
    {
        UserManager um      = new UserManager();
        UserManager manager = new UserManager();

        UnityThreadHelper.CreateThread(() =>
        {
            if (EventsController.advFound == true)
            {
                Byte[] lnByte = manager.getAvatar(Avatar);
                UnityThreadHelper.Dispatcher.Dispatch(() =>
                {
                    CancelInvoke();
                    Texture2D txt = new Texture2D(1, 1);
                    Sprite newSprite;
                    PanelLookingForPlayer.SetActive(false);
                    PanelPlayerFound.transform.localScale = Vector3.one;
                    challengeManager       = new ChallengeManager();
                    opponent_username.text = adversaireName;
                    Byte[] img;
                    opponent_avatar.sprite = ImagesManager.getSpriteFromBytes(lnByte);
                    try
                    {
                        img = Convert.FromBase64String(manager.GetFlagByte(AdvCountryCode));
                        txt.LoadImage(img);
                        newSprite            = Sprite.Create(txt as Texture2D, new Rect(0f, 0f, txt.width, txt.height), Vector2.zero);
                        opponent_flag.sprite = newSprite;
                    }
                    catch (NullReferenceException ex)
                    {
                    }
                    Versus_background.SetBool("StopBG", true);
                    Versus_container.SetActive(true);
                });
            }
        });
    }
Exemplo n.º 30
0
        public ActionResult SaveImage(int id, string name, string url, string description)
        {
            var res = false;
            var mng = new ImagesManager();

            try
            {
                var img = mng.GetImage(id);
                img.name        = name;
                img.url         = url;
                img.description = description;
                mng.SaveImage(img);
                res = true;
            }
            catch (Exception ex)
            {
                RDL.Debug.LogError(ex);
            }

            return(Json(new
            {
                result = res
            }));
        }