예제 #1
0
 public static MenuItem AddStringList(this Menu config, string name, string displayName, string[] stringList = null, int Index = 0)
 {
     if (config.Items.Any(m => m.Name == name))
     {
         DeBug.Debug("创建菜单错误", $"已经包含了名为{name}的菜单!", DebugLevel.Warning);
     }
     return(config.AddItem(new MenuItem(name, MultiLanguage._(displayName)).SetValue(new StringList(stringList.Select(s => MultiLanguage._(s)).ToArray(), Index))));
 }
예제 #2
0
 public static MenuItem AddCircle(this Menu config, string name, string displayName, bool active = false, Color color = new Color())
 {
     if (config.Items.Any(m => m.Name == name))
     {
         DeBug.Debug("创建菜单错误", $"已经包含了名为{name}的菜单!", DebugLevel.Warning);
     }
     return(config.AddItem(new MenuItem(name, MultiLanguage._(displayName)).SetValue(new Circle(active, color))));
 }
예제 #3
0
 public static MenuItem AddKeyBind(this Menu config, string name, string displayName, uint key, KeyBindType type, bool active = false)
 {
     if (config.Items.Any(m => m.Name == name))
     {
         DeBug.Debug("创建菜单错误", $"已经包含了名为{name}的菜单!", DebugLevel.Warning);
     }
     return(config.AddItem(new MenuItem(name, MultiLanguage._(displayName)).SetValue(new KeyBind(key, type, active))));
 }
예제 #4
0
 public static MenuItem AddSlider(this Menu config, string name, string displayName, int Defaults = 0, int min = 0, int max = 100)
 {
     if (config.Items.Any(m => m.Name == name))
     {
         DeBug.Debug("创建菜单错误", $"已经包含了名为{name}的菜单!", DebugLevel.Warning);
     }
     return(config.AddItem(new MenuItem(name, MultiLanguage._(displayName)).SetValue(new Slider(Defaults, min, max))));
 }
예제 #5
0
 public static void Load(Dictionary <string, Dictionary <string, string> > LanguageDictionary)
 {
     DeBug.Debug($"IsChinese{IsCN}");
     if (!IsCN)
     {
         Translations = LanguageDictionary["English"];
     }
 }
예제 #6
0
        public static MenuItem AddBool(this Menu config, string name, string displayName, bool Defaults = false)
        {
            if (config.Items.Any(m => m.Name == name))
            {
                DeBug.Debug("创建菜单错误", $"已经包含了名为{name}的菜单!", DebugLevel.Warning);
            }

            return(config.AddItem(new MenuItem(name, MultiLanguage._(displayName)).SetValue(Defaults)));
        }
예제 #7
0
        /// <summary>
        /// 添加子菜单
        /// </summary>
        /// <param name="config"></param>
        /// <param name="name"></param>
        /// <param name="displayName"></param>
        /// <returns></returns>
        public static Menu AddMenu(this Menu config, string name, string displayName)
        {
            if (config.Children.Any(m => m.Name == name))
            {
                DeBug.Debug("创建菜单错误", $"已经包含了名为{name}的子菜单!", DebugLevel.Warning);
            }

            return(config.AddSubMenu(new Menu(MultiLanguage._(displayName), name)));
        }
예제 #8
0
        public string ReadFile()
        {
            var path = Path.Combine(StoragePath, StorageName + ".json");

            DeBug.Debug("[存储]", $"StorageName:{StorageName} 存储位置:{path}");
            if (File.Exists(path))
            {
                return(File.ReadAllText(path));
            }
            return(string.Empty);
        }
예제 #9
0
        public void Save()
        {
            var path = Path.Combine(StoragePath, StorageName + ".json");

            DeBug.Debug("[存储]", $"StorageName:{StorageName} 存储位置:{path}");

            //DeBug.Debug("[存储]", $"============Instance.Contents内容===============");
            //foreach (var item in Contents)
            //{
            //	DeBug.Debug("[存储]", $"键:{item.key} 值:{item.value}");
            //}
            //DeBug.Debug("[存储]", $"============Instance.Contents内容===============");

            File.WriteAllText(path, JsonConvert.SerializeObject(this));
        }
예제 #10
0
 private static bool IsChinese()
 {
     if (!string.IsNullOrEmpty(Config.SelectedLanguage))
     {
         if (Config.SelectedLanguage == "Chinese")
         {
             return(true);
         }
     }
     else
     {
         var CultureName = System.Globalization.CultureInfo.InstalledUICulture.Name;
         var lid         = CultureName.Contains("-")
                                         ? CultureName.Split('-')[0].ToUpperInvariant()
                                         : CultureName.ToUpperInvariant();
         DeBug.Debug($"lid:{System.Globalization.CultureInfo.InstalledUICulture.Name}");
         DeBug.Debug($"lid:{lid}");
         if (lid == "ZH")
         {
             return(true);
         }
     }
     return(false);
 }