Example #1
0
        public void Save(Bitmap Image, ImageFormat Format, string FileName, TextLocalizer Status, RecentViewModel Recents)
        {
            using (Image)
                Image.WriteToClipboard(Format.Equals(ImageFormat.Png));

            Status.LocalizationKey = nameof(LanguageManager.ImgSavedClipboard);
        }
Example #2
0
 public void TargetLanguageStringEmptyTest()
 {
     TextLocalizer.Initialize("ja", "en", $"key,ja,en{Environment.NewLine}KeyTest,テスト{Environment.NewLine}KeyTest2,テスト2,{Environment.NewLine}KeyTest3,テスト3,Test3");
     Assert.AreEqual(TextLocalizer.GetText("KeyTest"), "テスト");
     Assert.AreEqual(TextLocalizer.GetText("KeyTest2"), "テスト2");
     Assert.AreEqual(TextLocalizer.GetText("KeyTest3"), "Test3");
 }
Example #3
0
        public Task Save(Bitmap Image, ImageFormat Format, string FileName, TextLocalizer Status, RecentViewModel Recents)
        {
            try
            {
                _settings.EnsureOutPath();

                var extension = Format.Equals(ImageFormat.Icon) ? "ico"
                    : Format.Equals(ImageFormat.Jpeg) ? "jpg"
                    : Format.ToString().ToLower();

                var fileName = FileName ?? Path.Combine(_settings.OutPath, $"{DateTime.Now:yyyy-MM-dd-HH-mm-ss}.{extension}");

                Image.Save(fileName, Format);

                Status.LocalizationKey = nameof(LanguageManager.ImgSavedDisk);
                Recents.Add(fileName, RecentItemType.Image, false);

                // Copy path to clipboard only when clipboard writer is off
                if (_settings.CopyOutPathToClipboard && !ServiceProvider.Get <ClipboardWriter>().Active)
                {
                    fileName.WriteToClipboard();
                }

                _systemTray.ShowScreenShotNotification(fileName);
            }
            catch (Exception e)
            {
                _messageProvider.ShowError($"{nameof(LanguageManager.NotSaved)}\n\n{e}");

                Status.LocalizationKey = nameof(LanguageManager.NotSaved);
            }

            return(Task.CompletedTask);
        }
    private void CreateInventoryEntries()
    {
        foreach (Inventory inventory in PrototypeManager.Inventory.Values.OrderByDescending(inv => inv.Category))
        {
            GameObject inventorySlot_go = new GameObject();
            inventorySlot_go.name  = "Slot - " + inventory.Type;
            inventorySlot_go.layer = LayerMask.NameToLayer("UI");

            inventorySlot_go.transform.SetParent(spawnUI.transform);

            HorizontalLayoutGroup hlg = inventorySlot_go.AddComponent <HorizontalLayoutGroup>();
            hlg.childForceExpandWidth  = false;
            hlg.childForceExpandHeight = false;
            hlg.spacing = 2;

            inventorySlot_go.AddComponent <Image>();

            string localName = inventory.LocalizationName;

            GameObject    textComponent = CreateTextComponent(inventorySlot_go, localName, TextAnchor.MiddleLeft);
            TextLocalizer textLocalizer = textComponent.AddComponent <TextLocalizer>();
            textLocalizer.formatValues = new string[0];
            CreateButtonComponents(inventorySlot_go, inventory, new int[] { 1, 20, 50 });

            LayoutElement layoutElement = inventorySlot_go.AddComponent <LayoutElement>();
            layoutElement.minWidth  = 160;
            layoutElement.minHeight = 20;
        }
    }
Example #5
0
 public void GetDefaultTextTest()
 {
     TextLocalizer.Initialize("ja", "en", $"key,ja,en{Environment.NewLine}KeyTest,テスト{Environment.NewLine}KeyTest2,テスト2,Test2{Environment.NewLine}KeyTest3,テスト3,Test3");
     Assert.AreEqual(TextLocalizer.GetText("KeyTest"), "テスト");
     Assert.AreEqual(TextLocalizer.GetText("KeyTest2"), "Test2");
     Assert.AreEqual(TextLocalizer.GetText("KeyTest3"), "Test3");
 }
Example #6
0
 private void OnDestroy()
 {
     OnLocalizeText   = null;
     OnRefreshAllText = null;
     _instance        = null;
     _allLocalizerText.Clear();
 }
Example #7
0
        public void Save(Bitmap Image, ImageFormat Format, string FileName, TextLocalizer Status, RecentViewModel Recents)
        {
            try
            {
                Settings.Instance.EnsureOutPath();

                var extension = Format.Equals(ImageFormat.Icon) ? "ico"
                    : Format.Equals(ImageFormat.Jpeg) ? "jpg"
                    : Format.ToString().ToLower();

                var fileName = FileName ?? Path.Combine(Settings.Instance.OutPath, $"{DateTime.Now:yyyy-MM-dd-HH-mm-ss}.{extension}");

                using (Image)
                    Image.Save(fileName, Format);

                Status.LocalizationKey = nameof(Resources.ImgSavedDisk);
                Recents.Add(fileName, RecentItemType.Image, false);

                if (Settings.Instance.CopyOutPathToClipboard)
                {
                    fileName.WriteToClipboard();
                }

                ServiceProvider.SystemTray.ShowScreenShotNotification(fileName);
            }
            catch (Exception E)
            {
                ServiceProvider.MessageProvider.ShowError($"{nameof(Resources.NotSaved)}\n\n{E}");

                Status.LocalizationKey = nameof(Resources.NotSaved);
            }
        }
Example #8
0
 public static void Initialize(int languageType)
 {
     if (_instance == null)
     {
         _instance = new GameObject("TextLocalizer").AddComponent <TextLocalizer>();
     }
     _instance._languageType = languageType;
 }
Example #9
0
        public void LastLineBrTest()
        {
            TextLocalizer.Initialize("en", "en", $"key,ja,en{Environment.NewLine}KeyTest,テスト,Test{Environment.NewLine}");
            Assert.AreEqual(TextLocalizer.GetText("KeyTest"), "Test");

            TextLocalizer.Initialize("en", "en", $"key,ja,en{Environment.NewLine}KeyTest,テスト,Test{Environment.NewLine}");
            Assert.AreEqual(TextLocalizer.GetText("KeyTest"), "Test");
        }
Example #10
0
        public void Save(Bitmap Image, ImageFormat Format, string FileName, TextLocalizer Status, RecentViewModel Recents)
        {
            using (Image)
                Image.WriteToClipboard(Format.Equals(ImageFormat.Png));

            Status.LocalizationKey = nameof(LanguageManager.ImgSavedClipboard);

            LanguageManager.Instance.LanguageChanged += L => RaisePropertyChanged(nameof(Display));
        }
Example #11
0
        public Hotkey(HotkeyModel Model)
        {
            ServiceName = Model.ServiceName;
            Key         = Model.Key;
            Modifiers   = Model.Modifiers;
            Description = new TextLocalizer(GetDescriptionKey(Model.ServiceName));

            IsActive = Model.IsActive;
        }
 private void OnEnable()
 {
     TextLocalizer    = (TextLocalizer)target;
     SOTextLocalizer  = new SerializedObject(TextLocalizer);
     LocalizationList = SOTextLocalizer.FindProperty("localizationList");
     UIText           = SOTextLocalizer.FindProperty("UIText");
     text             = SOTextLocalizer.FindProperty("text");
     key = SOTextLocalizer.FindProperty("key");
 }
Example #13
0
 private void OnEnable()
 {
     _controls = new PlayerControls();
     DisableDialog(true);
     _interact      = _controls.Player.Interact;
     _textLocalizer = _dialogText.GetComponent <TextLocalizer>();
     GameSignals.DIALOG_OPEN.AddListener(EnableDialog);
     GameSignals.DIALOG_CLOSE.AddListener(DisableDialog);
     GameSignals.DIALOG_SHOW.AddListener(OnDialogShow);
 }
Example #14
0
        public Hotkey(HotkeyModel Model)
        {
            ServiceName = Model.ServiceName;
            Key         = Model.Key;
            Modifiers   = Model.Modifiers;
            Work        = ServiceProvider.Get <Action>(Model.ServiceName);
            Description = new TextLocalizer(ServiceProvider.GetDescriptionKey(Model.ServiceName));

            IsActive = Model.IsActive;
        }
        public TestHelper()
        {
            var localizerService = new TextLocalizerService();

            Localizer          = new TextLocalizer <ValidationMessage>(localizerService);
            CuesheetController = new CuesheetController();
            ApplicationOptions = new ApplicationOptions
            {
                LinkTracksWithPreviousOne = false
            };
        }
Example #16
0
        public void ConvertTextToDic()
        {
            TextLocalizer.Initialize("ja", "ja", $"key,ja,en{Environment.NewLine}KeyTest,テスト,Test{Environment.NewLine}");
            Assert.AreEqual(TextLocalizer.GetText("KeyTest"), "テスト");

            TextLocalizer.Initialize("en", "en", $"key,ja,en{Environment.NewLine}KeyTest,テスト,Test");
            Assert.AreEqual(TextLocalizer.GetText("KeyTest"), "Test");

            TextLocalizer.Initialize("en", "en", $"key,ja,en{Environment.NewLine}KeyTest,テスト,Test{Environment.NewLine}");
            Assert.AreEqual(TextLocalizer.GetText("KeyTest"), "Test");
        }
Example #17
0
        public string ToText(TextLocalizer localizer)
        {
            string resources = "";

            foreach (var res in _delta)
            {
                resources += "[" + res.Key + "] " + res.Value;
            }

            Dictionary <string, object> param = new()
            {
Example #18
0
        private void Initialize()
        {
            _textLocalizer = (TextLocalizer)target;

            var dictionary = (LocalizationStorage)AssetDatabase.LoadAssetAtPath(LocalizationStorage.AssetPath + "LocalizationStorage.asset", typeof(LocalizationStorage));

            if (dictionary != null)
            {
                _keys          = dictionary.Keys;
                _selectedIndex = Mathf.Max(0, _keys.FindIndex(key => key == _textLocalizer.Key));
            }
        }
Example #19
0
    private GameObject CreateButtonGO(UnityEngine.Object buttonPrefab, string name, string localizationCode)
    {
        GameObject buttonGameObject = (GameObject)Instantiate(buttonPrefab);

        buttonGameObject.transform.SetParent(this.transform, false);
        buttonGameObject.name = "Button " + name;
        TextLocalizer textLocalizer = buttonGameObject.transform.GetComponentInChildren <TextLocalizer>();

        textLocalizer.formatValues = new string[] { LocalizationTable.GetLocalization(localizationCode) };
        textLocalizer.defaultText  = localizationCode;

        return(buttonGameObject);
    }
Example #20
0
 public void FailConvertTextToDic()
 {
     // Duplicated Key
     try
     {
         TextLocalizer.Initialize("ja", "ja", $"key,ja,en{Environment.NewLine}KeyTest,テスト,Test{Environment.NewLine}KeyTest,テスト,Test{Environment.NewLine}");
     }
     catch (ArgumentException e)
     {
         Debug.Log($"Test OK :{e.Message}");
         return;
     }
     Assert.Fail();
 }
Example #21
0
 public void KeyNotFoundTest()
 {
     TextLocalizer.Initialize("ja", "ja", $"key,ja,en{Environment.NewLine}KeyTest,テスト,Test{Environment.NewLine}");
     try
     {
         TextLocalizer.GetText("NotExistKey");
     }
     catch (KeyNotFoundException)
     {
         // KeyNotFoundException が出れば成功
         return;
     }
     Assert.Fail();
 }
Example #22
0
        public void GetTextWithArgsTest()
        {
            TextLocalizer.Initialize("ja", "ja", $"key,ja{Environment.NewLine}KeyTest,テスト{{0}}{{1}}{{2}}{Environment.NewLine}");
            Assert.AreEqual(TextLocalizer.GetText("KeyTest", "引数", "の", "Test"), "テスト引数のTest");
            TextLocalizer.Initialize("ja", "ja", $"key,ja{Environment.NewLine}KeyTest,テスト{{0}}{{1}}{{2}}{Environment.NewLine}");
            Assert.AreEqual(TextLocalizer.GetText("KeyTest", "引数", "の", "Test", "ですよ"), "テスト引数のTest");
            TextLocalizer.Initialize("ja", "ja", $"key,ja{Environment.NewLine}KeyTest,テスト{{0}}{{1}}{{2}}{Environment.NewLine}");
            try
            {
                TextLocalizer.GetText("KeyTest", "引数", "の");
            }
            catch
            {
                // catch していれば成功
                return;
            }

            Assert.Fail();
        }
Example #23
0
 private void OnEnable()
 {
     TextLocalizer.ExecLocalizeText(this, textKey);
     TextLocalizer.RegisterText(this, textKey);
 }
Example #24
0
 private void Awake()
 {
     TextLocalizer.Initialize("ja", "ja");
 }
Example #25
0
 public string ToText(TextLocalizer localizer)
 {
     Dictionary <string, object> param = new()
     {
Example #26
0
        public async void Save(Bitmap Image, ImageFormat Format, string FileName, TextLocalizer Status, RecentViewModel Recents)
        {
            var ritem = Recents.Add($"{_loc.ImgurUploading} (0%)", RecentItemType.Link, true);

            using (var w = new WebClient {
                Proxy = _settings.Proxy.GetWebProxy()
            })
            {
                w.UploadProgressChanged += (s, e) =>
                {
                    ritem.Display = $"{_loc.ImgurUploading} ({e.ProgressPercentage}%)";
                };

                w.Headers.Add("Authorization", $"Client-ID {ApiKeys.ImgurClientId}");

                NameValueCollection values;

                using (var ms = new MemoryStream())
                {
                    Image.Save(ms, Format);

                    values = new NameValueCollection
                    {
                        { "image", Convert.ToBase64String(ms.ToArray()) }
                    };
                }

                XDocument xdoc;

                try
                {
                    var response = await w.UploadValuesTaskAsync("https://api.imgur.com/3/upload.xml", values);

                    xdoc = XDocument.Load(new MemoryStream(response));

                    var xAttribute = xdoc.Root?.Attribute("success");

                    if (xAttribute == null || int.Parse(xAttribute.Value) != 1)
                    {
                        throw new Exception("Response indicates Failure");
                    }

                    Image.Dispose();
                }
                catch (Exception E)
                {
                    ritem.Display          = _loc.ImgurFailed;
                    Status.LocalizationKey = nameof(LanguageManager.ImgurFailed);

                    var yes = _messageProvider.ShowYesNo($"{_loc.ImgurFailed}\n{E.Message}\n\nDo you want to Save to Disk?", "Imgur Upload Failed");

                    if (yes)
                    {
                        _diskWriter.Save(Image, Format, FileName, Status, Recents);
                    }

                    return;
                }

                var link = xdoc.Root.Element("link").Value;

                if (_settings.CopyOutPathToClipboard)
                {
                    link.WriteToClipboard();
                }

                ritem.FilePath = ritem.Display = link;
                ritem.Saved();

                _systemTray.ShowTextNotification($"{_loc.ImgurSuccess}: {link}", _settings.UI.ScreenShotNotifyTimeout, () => Process.Start(link));

                Status.LocalizationKey = nameof(LanguageManager.ImgurSuccess);
            }
        }
Example #27
0
 // Use this for initialization
 void Start()
 {
     TextLocalizer.ExecLocalizeText(this, textKey);
 }
Example #28
0
 void Awake()
 {
     _instance = this;
     DontDestroyOnLoad(gameObject);
 }
Example #29
0
 private void OnDestroy()
 {
     TextLocalizer.UnRegisterText(this);
 }
Example #30
0
 private void OnDisable()
 {
     TextLocalizer.UnRegisterText(this);
 }