コード例 #1
0
ファイル: Library.cs プロジェクト: zcwfeng/IconDrop
        public static void Setup()
        {
            var    data = File.ReadAllBytes(Consts.AppDir_Shared + "id_flaticons.json");
            string json = Encoding.UTF8.GetString(data);

            _lib = FromSV(SciterValue.FromJSONString(json));

#if DEBUG
            var r = _lib.sources.GroupBy(l => l.name);
            Debug.Assert(r.Count() == _lib.sources.Count);
#endif


            int ihash = 100;
            foreach (var source in _lib.sources)
            {
                var source_sv = source.ToSV();
                _lib.sources_sv.Add(source_sv);
                foreach (var icon in source.icons)
                {
                    icon.hash   = Utils.CalculateMD5Hash(string.Join("", icon.arr_svgpath)) + "-" + (ihash++);
                    icon.source = source_sv;
                }
            }
        }
コード例 #2
0
        public static void Setup()
        {
            new Thread(() =>
            {
                var service = new WebfontsService(new Google.Apis.Services.BaseClientService.Initializer()
                {
                    ApiKey = API_KEY
                });

                var request  = service.Webfonts.List();
                request.Sort = WebfontsResource.ListRequest.SortEnum.Popularity;

                _fontlist = request.Execute().Items;                // if you get an Exception here, plz disable your Firewall!
                Debug.Assert(_fontlist.Count > 0);

                // converts the Webfont list to JSON string
                string json = JsonConvert.SerializeObject(_fontlist);

                // converts the JSON string to SciterValue
                SciterValue sv = SciterValue.FromJSONString(json);

                // calls UI layer TIScript function with the font data
                App.AppHost.InvokePost(() =>
                {
                    App.AppHost.CallFunction("View_OnFontList", sv);
                    App.AppHost.EvalScript("view.Host_DownloadFont(\"D:/\", \"Open Sans\", function(res) {})");
                });
            }).Start();
        }
コード例 #3
0
ファイル: UnitTests.cs プロジェクト: bytey-xyz/SciterSharp
        public void TestSciterValue()
        {
            //string[] arr = new string[] { "A", "B", "C" };
            int[] arr = new int[] { 1, 2, 3 };
            //SciterValue res = SciterValue.FromList(arr);
            SciterValue res = new SciterValue();

            res.Append(new SciterValue(1));
            res.Append(new SciterValue(1));
            res.Append(new SciterValue(1));
            string r  = res.ToString();
            string r2 = res.ToString();
            string r3 = res.ToJSONString(SciterSharp.Interop.SciterXValue.VALUE_STRING_CVT_TYPE.CVT_JSON_LITERAL);

            {
                // http://sciter.com/forums/topic/erasing-sequence-elements-with-scitervalue/
                SciterValue sv = SciterValue.FromJSONString("[1,2,3,4,5])");
                sv[0] = SciterValue.Undefined;
                sv[2] = SciterValue.Undefined;

                SciterValue sv2 = SciterValue.FromJSONString("{one: 1, two: 2, three: 3}");
                sv2["one"] = SciterValue.Undefined;
            }

            // Datetime
            {
                SciterValue sv = new SciterValue(DateTime.Now);
            }
        }
コード例 #4
0
        public static (bool, string) IsUpdateAvailable()
        {
            if (!File.Exists(PathUpdateInfo))
            {
                return(false, null);
            }

            SciterValue sv     = SciterValue.FromJSONString(File.ReadAllText(PathUpdateInfo));
            UpdateInfo  upinfo = new UpdateInfo()
            {
                v = sv["v"].Get(0),
                n = sv["n"].Get(0),
                r = sv["r"].Get(0),
            };

            int    major       = upinfo.v >> 16;
            int    minor       = upinfo.v & 0xFFFF;
            string lastVersion = major + "." + minor;

            if (Consts.VersionInt < upinfo.v)
            {
                return(false, lastVersion);
            }
            return(false, null);
        }
コード例 #5
0
ファイル: Host.cs プロジェクト: IDLC1/sciter_c-
        public bool Host_GetMsg(SciterElement el, SciterValue[] args, out SciterValue result)
        {
            var args1 = args[0].Get("");

            result = SciterValue.FromJSONString(args1);
            return(true);
        }
コード例 #6
0
        public static DateTime GetDateTime()
        {
            if (!File.Exists(PathUpdateInfo))
            {
                return(DateTime.Now);
            }

            SciterValue sv     = SciterValue.FromJSONString(File.ReadAllText(PathUpdateInfo));
            int         epoch  = sv["n"].Get(0);
            DateTime    dt_ntp = Utils.FromUnixTime(epoch);

            if (DateTime.UtcNow > dt_ntp)
            {
                dt_ntp = DateTime.UtcNow;
            }
            return(dt_ntp);
        }
コード例 #7
0
        public static void Setup()
        {
            var    data = File.ReadAllBytes(Consts.AppDir_Shared + "id_store.json");
            string json = Encoding.UTF8.GetString(data);

            SciterValue sv = SciterValue.FromJSONString(json);

            foreach (var sv_pack in sv.AsEnumerable())
            {
                var pack = new StorePack()
                {
                    id      = sv_pack["id"].Get(""),
                    name    = sv_pack["name"].Get(""),
                    author  = sv_pack["author"].Get(""),
                    url     = sv_pack["url"].Get(""),
                    icons   = new List <Icon>(),
                    colored = sv_pack["colored"].Get(false)
                };
                Debug.Assert(pack.name != "" && pack.author != "" && pack.url != "");
                pack.sv = pack.ToSV();

                foreach (var sv_file in sv_pack["files"].AsEnumerable())
                {
                    string filename = sv_file.Get("");
                    string hash     = Utils.CalculateMD5Hash($"Store-{pack.id}-{filename}");
                    pack.icons.Add(new Icon()
                    {
                        kind     = EIconKind.STORE,
                        hash     = hash,
                        path     = Consts.DirUserData_Store + pack.id + "/" + filename,
                        source   = pack.sv,
                        colored  = pack.colored,
                        arr_tags = new List <string>()
                        {
                            filename
                        }
                    });
                }

                _store_packs.Add(pack);
            }

            Utils.Shuffle(_store_packs);
        }
コード例 #8
0
        public void TestSciterValue()
        {
            //string[] arr = new string[] { "A", "B", "C" };
            int[] arr = new int[] { 1, 2, 3 };
            //SciterValue res = SciterValue.FromList(arr);
            SciterValue res = new SciterValue();

            res.Append(new SciterValue(1));
            res.Append(new SciterValue(1));
            res.Append(new SciterValue(1));
            string r  = res.ToString();
            string r2 = res.ToString();
            string r3 = res.ToJSONString(SciterXValue.VALUE_STRING_CVT_TYPE.CVT_JSON_LITERAL);

            {
                // http://sciter.com/forums/topic/erasing-sequence-elements-with-scitervalue/
                SciterValue sv = SciterValue.FromJSONString("[1,2,3,4,5])");
                sv[0] = SciterValue.Undefined;
                sv[2] = SciterValue.Undefined;

                SciterValue sv2 = SciterValue.FromJSONString("{one: 1, two: 2, three: 3}");
                sv2["one"] = SciterValue.Undefined;
                Assert.IsTrue(sv2["two"].Get(0) == 2);
            }

            // Datetime
            {
                var         now = DateTime.Now;
                SciterValue sv  = new SciterValue(now);
                Assert.IsTrue(sv.GetDate() == now);
            }

            // SciterValue.AsDictionary
            {
                SciterValue sv  = SciterValue.FromJSONString("{ a: 1, b: true }");
                var         dic = sv.AsDictionary();
                Assert.IsTrue(dic.Count == 2);
            }
        }
コード例 #9
0
        public SciterValue Host_Data()
        {
            return(SciterValue.FromJSONString(File.ReadAllText(@"D:\ProjetosSciter\BibliaSciter\Biblia\nvi.json")));

            return(SciterValue.FromJSONString(File.ReadAllText("/Users/midiway/Documents/BibliaSciter/Biblia/nvi.json", Encoding.UTF8)));
        }