Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using Microsoft.Win32;
- using System.IO;
- using System.Net;
- namespace MonacoAPI
- {
- public class MonacoFuncs
- {
- public void SetText(WebBrowser monaco, String text) // monaco as chosen webbrowser and text as which string you want to get text from
- {
- monaco.Document.InvokeScript("SetText", new object[]
- {
- text
- });
- }
- public String MonacoText;
- public void GetTextFunc(WebBrowser monaco) // monaco as webbrowser name (get text from) and text as the object you want to set text to
- {
- try
- {
- HtmlDocument document = monaco.Document;
- string scriptName = "GetText";
- object[] args = new string[0];
- object obj = document.InvokeScript(scriptName, args);
- string script = obj.ToString();
- MonacoText = script;
- }
- catch(Exception)
- {
- MessageBox.Show("Exception: Invalid WebBrowser / use string 'MonacoText' to assign values (object.text = MonacoText)");
- }
- }
- private string defPath = Application.StartupPath + "//Monaco//";
- WebBrowser monacobrowser = new WebBrowser();
- private void AddIntel(string label, string kind, string detail, string insertText)
- {
- string text = "\"" + label + "\"";
- string text2 = "\"" + kind + "\"";
- string text3 = "\"" + detail + "\"";
- string text4 = "\"" + insertText + "\"";
- monacobrowser.Document.InvokeScript("AddIntellisense", new object[]
- {
- label,
- kind,
- detail,
- insertText
- });
- }
- private void addGlobalF()
- {
- string[] array = File.ReadAllLines(this.defPath + "//globalf.txt");
- foreach (string text in array)
- {
- bool flag = text.Contains(':');
- if (flag)
- {
- this.AddIntel(text, "Function", text, text.Substring(1));
- }
- else
- {
- this.AddIntel(text, "Function", text, text);
- }
- }
- }
- private void addGlobalV()
- {
- foreach (string text in File.ReadLines(this.defPath + "//globalv.txt"))
- {
- this.AddIntel(text, "Variable", text, text);
- }
- }
- private void addGlobalNS()
- {
- foreach (string text in File.ReadLines(this.defPath + "//globalns.txt"))
- {
- this.AddIntel(text, "Class", text, text);
- }
- }
- private void addMath()
- {
- foreach (string text in File.ReadLines(this.defPath + "//classfunc.txt"))
- {
- this.AddIntel(text, "Method", text, text);
- }
- }
- private void addBase()
- {
- foreach (string text in File.ReadLines(this.defPath + "//base.txt"))
- {
- this.AddIntel(text, "Keyword", text, text);
- }
- }
- public void Initialize(WebBrowser monaco)
- {
- if (Directory.Exists(Directory.GetCurrentDirectory() + "\\Monaco\\"))
- {
- monacobrowser = monaco;
- WebClient wc = new WebClient();
- wc.Proxy = null;
- try
- {
- RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
- string friendlyName = AppDomain.CurrentDomain.FriendlyName;
- bool flag2 = registryKey.GetValue(friendlyName) == null;
- if (flag2)
- {
- registryKey.SetValue(friendlyName, 11001, RegistryValueKind.DWord);
- }
- registryKey = null;
- friendlyName = null;
- }
- catch (Exception)
- {
- }
- monaco.Url = new Uri(string.Format("file:///{0}/Monaco/Monaco.html", Directory.GetCurrentDirectory()));
- Task.Delay(500);
- monaco.Document.InvokeScript("SetTheme", new string[]
- {
- "Light"
- });
- }
- else
- {
- MessageBox.Show("Exception: couldnt find directory 'Monaco'");
- }
- }
- public async void SetTheme(WebBrowser monaco, string text)
- {
- try
- {
- await Task.Delay(500);
- monaco.Document.InvokeScript("SetTheme", new string[]
- {
- text
- });
- }
- catch (Exception)
- {
- MessageBox.Show("Exception: only 2 themes available, 'Light' and 'Dark', or string entry point was unavailable. if the fixes still doesnt work, proceed to use 'SetThemeIfException'");
- }
- }
- public async Task SetThemeIfException(WebBrowser monaco, string theme)
- {
- await Task.Delay(500);
- monaco.Document.InvokeScript("SetTheme", new string[]
- {
- theme
- });
- }
- public void addIntel(string label, string kind, string detail, string insertText)
- {
- string text = "\"" + label + "\"";
- string text2 = "\"" + kind + "\"";
- string text3 = "\"" + detail + "\"";
- string text4 = "\"" + insertText + "\"";
- monacobrowser.Document.InvokeScript("AddIntellisense", new object[]
- {
- label,
- kind,
- detail,
- insertText
- });
- }
- public void ReplaceText(WebBrowser monaco, String firstarray, String secondarray)
- {
- GetTextFunc111(monaco);
- String text1 = MonacoText111;
- text1 = text1.Replace(firstarray, secondarray);
- SetText111(monaco, text1);
- }
- private void SetText111(WebBrowser monaco, String text) // monaco as chosen webbrowser and text as which string you want to get text from
- {
- monaco.Document.InvokeScript("SetText", new object[]
- {
- text
- });
- }
- private String MonacoText111;
- private void GetTextFunc111(WebBrowser monaco) // monaco as webbrowser name (get text from) and text as the object you want to set text to
- {
- try
- {
- HtmlDocument document = monaco.Document;
- string scriptName = "GetText";
- object[] args = new string[0];
- object obj = document.InvokeScript(scriptName, args);
- string script = obj.ToString();
- MonacoText111 = script;
- }
- catch (Exception)
- {
- MessageBox.Show("Exception: Invalid WebBrowser / use string 'MonacoText' to assign values (object.text = MonacoText)");
- }
- }
- public void credits(String yourusername)
- {
- MessageBox.Show("Monaco API made by _King_#5471, exception debugging made by _King_#5471, public variabled suggested by FBI blyat AKA Project Cocaine. And best of all, used by the great " + yourusername + "!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement