예제 #1
0
    AppCount CalculateAppCount(int numberOfApps = 0)
    {
        AppCount count  = new AppCount();
        int      width  = (int)Math.Floor(LauncherObject.GetComponent <RectTransform>().rect.width);
        int      height = (int)Math.Floor(LauncherObject.GetComponent <RectTransform>().rect.height);

        for (count.columns = 1; (width - (100 * (count.columns + 1))) / (count.columns + 2) >= 40; count.columns++)
        {
            ;
        }
        for (count.rows = 1; (height - (100 * (count.rows + 1))) / (count.rows + 2) >= 40; count.rows++)
        {
            ;
        }
        if (numberOfApps > 0)
        {
            count.pages = (int)Math.Ceiling((double)(numberOfApps / (count.rows * count.columns)));
        }
        count.columnPadding = (width - (count.columns * 100)) / (count.columns + 1);
        count.rowPadding    = (height - (count.rows * 100)) / (count.rows + 1);
        //Debug.Log("cols: " + count.columns);
        //Debug.Log("rows: " + count.rows);
        //Debug.Log("colPad: " + count.columnPadding);
        //Debug.Log("rowPad: " + count.rowPadding);
        return(count);
    }
예제 #2
0
    void UpdateIcons()
    {
        foreach (GameObject app in appIcons)
        {
            Destroy(app);
        }
        appIcons = new List <GameObject>();
        apps.Sort();
        AppCount count = CalculateAppCount(apps.Count);
        float    y     = LauncherObject.GetComponent <RectTransform>().rect.height;
        //Debug.Log("base height = " + y);
        int i = 0;

        foreach (LauncherAppIcon app in apps)
        {
            if (Math.Floor((double)i / (count.columns * count.rows)) == currentPage)
            {
                GameObject appIcon = Instantiate(LauncherAppIcon, LauncherObject.transform).gameObject;
                appIcon.GetComponent <LauncherAppIcon>()._name     = app._name;
                appIcon.GetComponent <LauncherAppIcon>().title     = app.title;
                appIcon.GetComponent <LauncherAppIcon>().hoverName = app.hoverName;
                appIcon.GetComponent <LauncherAppIcon>().icon      = app.icon;
                appIcon.GetComponent <LauncherAppIcon>().path      = app.path;
                appIcon.GetComponent <LauncherAppIcon>().arguments = app.arguments;
                appIcon.GetComponent <LauncherAppIcon>().UpdateIcon();
                appIcon.GetComponent <LauncherAppIcon>().LauncherObject = this;
                appIcon.GetComponent <LauncherAppIcon>().AddIconDialog  = AddIconDialog;
                appIcon.GetComponent <LauncherAppIcon>().Canvas         = Canvas;
                //appIcon.GetComponent<AppIcon>().Dock = Dock;
                appIcons.Add(appIcon);
            }
            i++;
        }
    }
예제 #3
0
        public void ReadJson_ForConversationAppCount_ReturnsValidCount()
        {
            String       input        = "{\"type\":\"count.hash\",\"company\":{\"count\":6},\"user\":{\"count\":2025082},\"lead\":{\"count\":1},\"tag\":{\"count\":17},\"segment\":{\"count\":7}}";
            StringReader stringReader = new StringReader(input);
            JsonReader   reader       = new JsonTextReader(stringReader);
            AppCount     appCount     = appCountJsonConverter.ReadJson(reader, typeof(int), null, null) as AppCount;

            Assert.AreEqual(6, appCount.company);
            Assert.AreEqual(2025082, appCount.user);
        }