public IEnumerator SubThreadCanChangeTitle()
        {
            if (!Native.Supported)
            {
                yield break;
            }

            var       input     = DateTime.Now.ToString(CultureInfo.CurrentCulture);
            Exception exception = null;
            var       thread    = new Thread(() =>
            {
                try
                {
                    StandaloneWindowTitle.Change(input);
                }
                catch (Exception threadException)
                {
                    exception = threadException;
                }
            });

            thread.Start();
            yield return(new WaitWhile(() => thread.IsAlive));

            Assert.Null(exception);
            var outputs = Native.ReadStandaloneWindowTitles();

            Assert.Positive(outputs.Count);
            foreach (var output in outputs)
            {
                Assert.AreEqual(input, output);
            }
        }
        private void Update()
        {
            if (!StandaloneWindowTitle.IsSupported)
            {
                return;
            }

            try
            {
                StandaloneWindowTitle.Change(DateTime.Now.ToString(CultureInfo.CurrentCulture));
            }
            catch (StandaloneWindowTitleChangeException e)
            {
                switch (e.Cause)
                {
                case StandaloneWindowTitleChangeException.Error.NoWindow:
                    return;

                case StandaloneWindowTitleChangeException.Error.Unknown:
                    Debug.LogException(e);
                    break;

                default:
                    Debug.LogException(e);
                    break;
                }
            }
        }
        public void ThrowExceptionIfUnsupported()
        {
            if (Native.Supported)
            {
                return;
            }
            var e = Assert.Throws <StandaloneWindowTitleChangeException>(() =>
            {
                StandaloneWindowTitle.Change("test");
            });

            Assert.That(e.Cause, Is.EqualTo(StandaloneWindowTitleChangeException.Error.NotSupported));
        }
        public void MainThreadCanChangeTitle()
        {
            if (!Native.Supported)
            {
                return;
            }
            var input = DateTime.Now.ToString(CultureInfo.CurrentCulture);

            StandaloneWindowTitle.Change(input);
            var outputs = Native.ReadStandaloneWindowTitles();

            Assert.Positive(outputs.Count);
            foreach (var output in outputs)
            {
                Assert.AreEqual(input, output);
            }
        }
Пример #5
0
        private void Start()
        {
            try
            {
                System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
                sw.Start();
                if (!WorkDir.Exists)
                {
                    WorkDir.Create();
                }
                // 读取配置
                ShowOnceTip        = Config.Bind <bool>("config", "ShowOnceTip", false, "仅提示一次的消息");
                OnStartDump        = Config.Bind <bool>("config", "OnStartDump", false, "当启动时进行转储(原词条)");
                OnHasNullValueDump = Config.Bind <bool>("config", "OnHasNullValueDump", false, "当缺失词条时进行转储(合并后词条)");
                DevMode            = Config.Bind <bool>("config", "DevMode", false, "汉化者开发模式");
                RefreshLangKey     = Config.Bind <KeyCode>("config", "RefreshLangKey", KeyCode.F10, "[仅限开发模式]刷新语言快捷键");
                SwitchLangKey      = Config.Bind <KeyCode>("config", "SwitchLangKey", KeyCode.F11, "[仅限开发模式]切换语言快捷键");

                // 备份原文
                Backup();
                if (OnStartDump.Value)
                {
                    // Dump原文到硬盘
                    DumpOri();
                }
                // 开始汉化文本
                ToCN();
                Harmony.CreateAndPatchAll(typeof(VRoidChinese));
                StandaloneWindowTitle.Change("VRoid Studio");
                // 切换到中文
                VRoid.UI.EditorOption.EditorOptionManager.Instance.EditorOption.Preference.languageMode = VRoid.UI.EditorOption.LanguageMode.En;
                Messages.CurrentCrowdinLanguageCode = "en";
                sw.Stop();
                Logger.LogInfo($"总耗时 {sw.ElapsedMilliseconds}ms");
            }
            catch (Exception e)
            {
                Logger.LogError(e);
                ShowUpdateTip = true;
            }
        }
        private static void tick(int id)
        {
            try
            {
                StandaloneWindowTitle.Change("[" + id + "] " + DateTime.Now.ToString(CultureInfo.CurrentCulture));
            }
            catch (StandaloneWindowTitleChangeException e)
            {
                switch (e.Cause)
                {
                case StandaloneWindowTitleChangeException.Error.NoWindow:
                    return;

                case StandaloneWindowTitleChangeException.Error.Unknown:
                    Debug.LogException(e);
                    break;

                default:
                    Debug.LogException(e);
                    break;
                }
            }
        }