コード例 #1
0
 /// <summary>
 /// Check for missing translations
 /// </summary>
 public void Check(_Language _Language)
 {
     foreach (JProperty property in JObject.FromObject(this).Properties())
     {
         if (string.IsNullOrEmpty(property.Value.ToString()))
         {
             Console.WriteLine($"NULL {_Language.ToString()}.{property.Name}");
         }
         else if (property.HasValues)
         {
             foreach (JProperty p in property.Value)
             {
                 if (string.IsNullOrEmpty(p.Value.ToString()))
                 {
                     Console.WriteLine($"NULL {_Language.ToString()}.{property.Name}.{p.Name}");
                 }
             }
         }
     }
     _Data.Translate.Add(_Language, this);
 }
コード例 #2
0
    public Main()
    {
        InitializeComponent();

        //Start the loop which is used for the plugins
        Loop.Enabled = true;
        Loop.Start();

        //Deletes all Visual Studio garbage
        try
        {
            foreach (string file in Directory.GetFiles("./"))
            {
                if (file.EndsWith(".pdb") || file.EndsWith(".config"))
                {
                    File.Delete(file);
                }
            }
        }
        catch { }

        //Creates the Plugins folder if it doesn't exist
        if (!Directory.Exists(path + "Plugins"))
        {
            Directory.CreateDirectory(path + "Plugins");
        }

        //Loads all the Plugins from the Plugins folder
        LoadPlugins(path + "Plugins");

        //Creates a bin folder if it doesn't exist
        if (!Directory.Exists(path + "bin"))
        {
            Directory.CreateDirectory(path + "bin");
        }

        //Creates the default language file
        if (!File.Exists(path + "bin/language.json"))
        {
            StringBuilder sb   = new StringBuilder();
            StringWriter  strw = new StringWriter(sb);
            using (JsonWriter writer = new JsonTextWriter(strw))
            {
                writer.Formatting = Formatting.Indented;
                writer.WriteStartObject();
                writer.WritePropertyName("Language");
                writer.WriteValue("None");
                writer.WriteEndObject();
            }

            using (Stream s = File.Open(path + "bin/language.json", FileMode.CreateNew))
                using (StreamWriter sw = new StreamWriter(s))
                {
                    sw.Write(sb.ToString());
                }
        }

        //Installs Monaco if it doesn't exist
        if (!Directory.Exists(path + "bin/Monaco"))
        {
            if (File.Exists(path + "bin/Monaco.zip"))
            {
                File.Delete(path + "bin/Monaco.zip");
            }

            wc.DownloadFile("https://cdn.discordapp.com/attachments/713846997039448134/836901911214686208/Monaco.zip", path + "bin/Monaco.zip");
            ZipFile.ExtractToDirectory(path + "bin/Monaco.zip", path + "bin");

            if (File.Exists(path + "bin/Monaco.zip"))
            {
                File.Delete(path + "bin/Monaco.zip");
            }
        }

        //Creates a config file inside the Monaco file which is used to determine where to change the language
        if (!File.Exists(path + "bin/Monaco/config.json"))
        {
            StringBuilder sb   = new StringBuilder();
            StringWriter  strw = new StringWriter(sb);
            using (JsonWriter writer = new JsonTextWriter(strw))
            {
                writer.Formatting = Formatting.Indented;
                writer.WriteStartObject();
                writer.WritePropertyName("LanguageLine");
                writer.WriteValue("87");
                writer.WriteEndObject();
            }

            using (Stream s = File.Open(path + "bin/Monaco/config.json", FileMode.CreateNew))
                using (StreamWriter sw = new StreamWriter(s))
                {
                    sw.Write(sb.ToString());
                }
        }


        //Sets the language from the default language file
        _Language      _default = _Language.None;
        JsonTextReader reader   = new JsonTextReader(new StringReader(File.ReadAllText(path + "bin/language.json")));

        while (reader.Read())
        {
            if (reader.Value != null)
            {
                if (reader.TokenType == JsonToken.String)
                {
                    _default = (_Language)Enum.Parse(typeof(_Language), reader.Value.ToString(), true);
                }
            }
        }
        SetLanguage(_default);

        //Default startup things
        Location        = new Point((Screen.PrimaryScreen.Bounds.Width / 2) - (Width / 2), (Screen.PrimaryScreen.Bounds.Height / 2) - (Height / 2));
        ConsoleBox.Text = "";
        Tabs.TabButtonPanel.DoubleClick += new EventHandler(Tabs_DoubleClick);
        runnables.Clear();
        runnables.Add(_Language.Python);

        //If the app is opened by right clicking a file it opens a new tab
        string[] paths = Environment.GetCommandLineArgs();
        if (paths.Length > 1)
        {
            AddTab(File.ReadAllText(paths[1]), paths[1].Split('\\')[paths[1].Split('\\').Length - 1], paths[1]);
            //Default things
            Location = new Point(Screen.PrimaryScreen.Bounds.Width - 800, 0);
            Width    = 800;
            Height   = Screen.PrimaryScreen.Bounds.Height - 40;
            SetLanguage(_Language.None);
        }
    }
コード例 #3
0
    public void SetLanguage(_Language lang)
    {
        this.lang = lang;
        if (lang == _Language.None)
        {
            LanguageLabel.Text = "";
        }
        else
        {
            LanguageLabel.Text = lang.ToString();
        }

        if (runnables.Contains(lang))
        {
            RunButton.Show();
        }
        else
        {
            RunButton.Hide();
        }

        int            line   = 87;
        JsonTextReader reader = new JsonTextReader(new StringReader(File.ReadAllText(path + "bin/Monaco/config.json")));

        while (reader.Read())
        {
            if (reader.Value != null)
            {
                if (reader.TokenType == JsonToken.String)
                {
                    line = Int32.Parse(reader.Value.ToString());
                }
            }
        }
        if (lang == _Language.None)
        {
            ChangeLine("					language: '',", path + "bin/Monaco/Monaco.html", line);
        }
        else
        {
            ChangeLine("					language: '"+ lang.ToString().ToLower() + "',", path + "bin/Monaco/Monaco.html", line);
        }

        if (File.Exists(path + "bin/language.json"))
        {
            File.Delete(path + "bin/language.json");
        }

        StringBuilder sb   = new StringBuilder();
        StringWriter  strw = new StringWriter(sb);

        using (JsonWriter writer = new JsonTextWriter(strw))
        {
            writer.Formatting = Formatting.Indented;
            writer.WriteStartObject();
            writer.WritePropertyName("Language");
            writer.WriteValue(lang.ToString());
            writer.WriteEndObject();
        }

        using (Stream s = File.Open(path + "bin/language.json", FileMode.CreateNew))
            using (StreamWriter sw = new StreamWriter(s))
            {
                sw.Write(sb.ToString());
            }
    }