private void Label_MouseDoubleClick(object sender, MouseButtonEventArgs e) { CodeWindow window = new CodeWindow(); window.Show(); Close(); }
private void listadecodigos(object sender, RoutedEventArgs e) { CodeWindow c = new CodeWindow(); c.Show(); this.Close(); }
public MainWindow() { InitializeComponent(); InitializeEvents(); _consoleWindow = new ConsoleWindow(consoleWindowRichTextBox); _codeWindow = new CodeWindow(codeWindowRichTextBox); }
/// <summary> /// Initializes a new instance of the <see cref="DynamicCodeTests.DynamicCodePage"/> class. /// </summary> public DynamicCodePage(Project project, CodeWindow codeWindow) { Trace.Log(TraceEventType.Information, "project=\"{0}\", codeWindow=\"{1}\"", project.ToString(), codeWindow.ToString()); Project = project; CodeWindow = codeWindow; DynamicCompiler = new Compiler(project); lockOutput.AcquireWriterLock(0); int mark = 0; ScrolledWindow w = new ScrolledWindow(); tvInput = new TextView(); w.AddWithViewport(tvInput); Pack2(w, false, true); w = new ScrolledWindow(); tvOutput = new TextView(); tvOutput.Editable = false; w.AddWithViewport(tvOutput); Pack1(w, true, true); Position = 234; PositionSet = true; tvInput.GrabFocus(); List<string> codeHistory = project.CodeHistory; tvInput.KeyReleaseEvent += delegate(object o, KeyReleaseEventArgs args) { if (args.Event.State.HasFlag(Gdk.ModifierType.ControlMask)) { if (args.Event.Key.Equals(Gdk.Key.space)) ShowCompletions(); else if (args.Event.Key.Equals(Gdk.Key.Return)) ExecuteCode(); else if (codeHistory.Count > 0) { if (args.Event.Key.Equals(Gdk.Key.Up)) CodeHistoryUp(); else if (args.Event.Key.Equals(Gdk.Key.Down)) CodeHistoryDown(); } } else { codeHistoryIndex = -1; } tvInputPreviousText = tvInput.Buffer.Text; }; lockOutput.ReleaseWriterLock(); ShowAll(); }
private void Window_Closing(object sender, EventArgs e) { NewFileItem_Click(null, null); debugThread?.Abort(); textEditor?.clearHover(); codeWindow?.Close(); codeWindow = null; Application.Current.Shutdown(); }
public static void CreateWindow() { // Create the window CodeWindow window = CreateInstance <CodeWindow>(); // Set the window title window.SetTitle("Code Editor"); // Set the window's minimum size and display it window.minSize = new Vector2(250, 250); window.Show(); }
public VMcode(CodeWindow parent, ContractCollection collection) : base() { this.parent = parent; this.selected = collection.Contracts[0].Name; this.code = new Dictionary <string, Dictionary <string, string> >(); foreach (ContractModel cm in collection.Contracts) { this.code.Add(cm.Name, cm.Functions.ToDictionary(f => f.Name, f => FunctionConverter.Convert(f))); } this.CommandSelectionChanged = new DelegateCommand <object>(this.Select); }
private IVsDropdownBarClient CreateDropdownBarClient() { var componentModel = ServiceProvider.GetComponentModel(); var editorAdaptersFactory = componentModel.DefaultExportProvider.GetExportedValueOrDefault <IVsEditorAdaptersFactoryService>(); var bufferGraphFactoryService = componentModel.DefaultExportProvider.GetExportedValue <IBufferGraphFactoryService>(); var textView = editorAdaptersFactory.GetWpfTextView(CodeWindow.GetPrimaryView()); var editorNavigationSourceProvider = componentModel.DefaultExportProvider.GetExportedValueOrDefault <EditorNavigationSourceProvider>(); var editorNavigationSource = editorNavigationSourceProvider.TryCreateEditorNavigationSource(textView.TextBuffer); return(new EditorNavigationDropdownBarClient(CodeWindow, editorAdaptersFactory, editorNavigationSource, bufferGraphFactoryService)); }
private static void OpenInCodeEditor() { if (Selection.activeObject.GetType() == typeof(TextAsset)) { TextAsset asset = Selection.activeObject as TextAsset; CodeWindow.CreateWindow(Application.dataPath + AssetDatabase.GetAssetPath(asset).Substring(6)); } if (Selection.activeObject.GetType() == typeof(MonoScript)) { MonoScript asset = Selection.activeObject as MonoScript; CodeWindow.CreateWindow(Application.dataPath + AssetDatabase.GetAssetPath(asset).Substring(6)); } }
private void codeItem_Click(object sender, RoutedEventArgs e) { if (String.IsNullOrEmpty(intermediateCode)) { run_Click(null, null); } if (String.IsNullOrEmpty(intermediateCode)) { return; } codeWindow = new CodeWindow(); codeWindow.Text = intermediateCode; codeWindow.Show(); }
/// <summary> /// Set the Window Title /// </summary> /// <param name="title">The new window title</param> public void SetTitle(string title) { CodeWindow window = this as CodeWindow; // The API changed in Unity 5.3 so previous versions use old API #if UNITY_4_6 window.title = "Code Editor"; #elif UNITY_5_0 window.title = "Code Editor"; #elif UNITY_5_1 window.title = "Code Editor"; #elif UNITY_5_2 window.title = "Code Editor"; #else window.titleContent = new GUIContent("Code Editor"); #endif }
public override void OnInspectorGUI() { try { base.OnInspectorGUI(); GUILayout.Space(10); GUILayout.BeginHorizontal(); if (GUILayout.Button("Open in Code Editor", GUILayout.Height(30))) { MonoScript script = (MonoScript)target; CodeWindow.CreateWindow(Application.dataPath + AssetDatabase.GetAssetPath(script).Substring(6)); } GUILayout.EndHorizontal(); } catch { base.OnInspectorGUI(); } }
public override void OnInspectorGUI() { try { EditorGUI.EndDisabledGroup(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Open in Code Editor", GUILayout.Height(30))) { TextAsset script = (TextAsset)target; CodeWindow.CreateWindow(Application.dataPath + AssetDatabase.GetAssetPath(script).Substring(6)); } GUILayout.EndHorizontal(); EditorGUI.BeginDisabledGroup(true); } catch { base.OnInspectorGUI(); } }
public override void OnInspectorGUI() { try { base.OnInspectorGUI(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Open in Code Editor")) { MonoBehaviour myTarget = (MonoBehaviour)target; MonoScript script = MonoScript.FromMonoBehaviour(myTarget); CodeWindow.CreateWindow(Application.dataPath + AssetDatabase.GetAssetPath(script).Substring(6)); } GUILayout.EndHorizontal(); } catch { base.OnInspectorGUI(); } }
private static void SoftwareCode(object sender, ExecutedRoutedEventArgs e) { MainWindow mainWindow = (MainWindow)sender; if (IsLicenseStateValid()) { if (_codeWindow == null) { _codeWindow = new CodeWindow(mainWindow); _codeWindow.Show(); } else { _codeWindow.Close(); _codeWindow = new CodeWindow(mainWindow); _codeWindow.Show(); } } }
public int AddAdornments() { IVsTextView textView; if (ErrorHandler.Succeeded(CodeWindow.GetPrimaryView(out textView)) && textView != null) { ErrorHandler.ThrowOnFailure(OnNewView(textView)); } if (ErrorHandler.Succeeded(CodeWindow.GetSecondaryView(out textView)) && textView != null) { ErrorHandler.ThrowOnFailure(OnNewView(textView)); } if (ServiceProvider.GetHlslToolsService().LanguagePreferences.NavigationBar) { return(AddDropDownBar()); } return(VSConstants.S_OK); }
public virtual int AddAdornments() { IVsTextView textView; if (ErrorHandler.Succeeded(CodeWindow.GetPrimaryView(out textView)) && textView != null) { ErrorHandler.ThrowOnFailure(OnNewView(textView)); } if (ErrorHandler.Succeeded(CodeWindow.GetSecondaryView(out textView)) && textView != null) { ErrorHandler.ThrowOnFailure(OnNewView(textView)); } int comboBoxCount; IVsDropdownBarClient client; if (LanguagePreferences.ShowDropdownBar && TryCreateDropdownBarClient(out comboBoxCount, out client)) { ErrorHandler.ThrowOnFailure(AddDropdownBar(comboBoxCount, client)); _dropdownBarClient = client; } return(VSConstants.S_OK); }
// : base(WindowType.Toplevel) /// <summary> /// Initializes a new instance of the <see cref="DynamicCodeTests.SceneTypeDialog"/> class. /// </summary> /// <param name='sceneTypes'><see cref="JGL.Heirarchy.Scene"/>-derived types</param> /// <exception cref='ArgumentException'> /// Is thrown when an argument passed to a method is invalid. /// </exception> public SceneTypeDialog(Type[] sceneTypes, CodeWindow codeWindow) { //_codeWindow = codeWindow; Glade.XML gxml = new Glade.XML(/*"/home/jk/Code/JGL/DynamicCodeTests/UI/*/ "UI/CodeWindow.glade", "SceneTypeDialog", null); gxml.Autoconnect(this); // load & autoconnect glade UI for a CodeWindow CellRenderer r = new CellRendererText(); cmbSceneTypes.PackStart(r, true); cmbSceneTypes.SetAttributes(r, "text", 0); ListStore store = new ListStore(typeof(string)); for (int i = 0; i < sceneTypes.Length; i++) { Type sType = sceneTypes[i]; if (!sType.IsSubclassOf(typeof(Scene))) throw new ArgumentException(string.Format("{0} is not a scene type", sType.FullName), string.Format("sceneTypes[{0}]", i)); else store.AppendValues(sType.FullName); } cmbSceneTypes.Model = store; cmbSceneTypes.ShowAll(); cmbSceneTypes.Toplevel.ShowAll(); }
/// <summary> /// Draws the elements within the window /// </summary> private void OnGUI() { // Load the text area font from the 'Editor Default Resources' folder if (!font) { font = (Font)EditorGUIUtility.Load("Code Editor/Inconsolata-Regular.ttf"); } // If we have opened a file, set the window's title to the file name if (fileLoaded) { if (!string.IsNullOrEmpty(pathOpened)) { SetTitle(System.IO.Path.GetFileName(pathOpened)); } else { SetTitle("Code Editor"); } } GUILayout.BeginHorizontal(); // Draw the buttons across the top of the window if (GUILayout.Button("New")) { GUI.FocusControl(null); // << Loose focus of the text area so the text can be changed properly fileLoaded = true; // We are editing a blank file which has not been saved anywhere so keep these blank: pathOpened = ""; fileText = ""; } if (GUILayout.Button("Open")) { // Show Dialogue to open file string path = EditorUtility.OpenFilePanel("Open Text File", UnityEngine.Application.dataPath, ""); try { // Try to open the file StreamReader fileReader = new StreamReader(path); fileText = fileReader.ReadToEnd(); fileReader.Close(); GUI.FocusControl(null); // << Loose focus of the text area so the text can be changed properly // Remeber the path and set the text area text pathOpened = path; fileLoaded = true; } catch { } } if (GUILayout.Button("Save")) { if (pathOpened == "") { // If it is a new file we don't know the path so we need to display a dialogue to get one (same as save as) SaveAsStuff(false); } else { // We have the path so save the file there StreamWriter fileWriter = new StreamWriter(pathOpened, false); fileWriter.Write(fileText); fileWriter.Close(); } // Recompile scripts if we should if (compileAfterSaving) { AssetDatabase.Refresh(); } } if (GUILayout.Button("Save As")) { // Open the file dialogue to do a save as (within SaveAsStuff function) SaveAsStuff(false); if (compileAfterSaving) { AssetDatabase.Refresh(); } } if (GUILayout.Button("Close")) { // Close the window. CloseRequest() shows 'Save Changes?' dialogue if required CloseRequest(); Close(); } // Draw the settings to be changed across the top of the window GUILayout.FlexibleSpace(); GUILayout.Label("Wrap Text:"); wrapText = EditorGUILayout.Toggle(wrapText); GUILayout.Label("Compile On Save:"); compileAfterSaving = EditorGUILayout.Toggle(compileAfterSaving); GUILayout.Label("Line Nums:"); lineNums = EditorGUILayout.Toggle(lineNums); // Draw button to open another Code Editor Window GUILayout.FlexibleSpace(); if (GUILayout.Button("+")) { CodeWindow window = CreateInstance <CodeWindow>(); window.Show(); } GUILayout.EndHorizontal(); // We want the text area within a scroll view. (Always showing vertical scrollbar makes calculating line heights for wrapped text easier) scrollRect = GUILayout.BeginScrollView(scrollRect, false, true); if (fileLoaded) { // Get the default editor style and change it. Replace font, change font size and enable word wrap (if requried) GUIStyle editorStyle = new GUIStyle(EditorStyles.textArea); editorStyle.font = font; editorStyle.fontSize = 16; if (wrapText) { editorStyle.wordWrap = true; } else { editorStyle.wordWrap = false; } // Make the text area take up the space of the rest of the window editorStyle.stretchHeight = true; editorStyle.stretchWidth = true; GUILayout.BeginHorizontal(); // Draw line numbers if required if (lineNums) { GUILayout.BeginVertical(GUILayout.Width(30)); // Get the editor label style and adjust it for line numbers. We don't want any margins. Set font and font size GUIStyle lineNum = new GUIStyle(EditorStyles.label); lineNum.margin = new RectOffset(0, 0, 0, 0); lineNum.border = new RectOffset(0, 0, 0, 0); lineNum.padding = new RectOffset(0, 0, 0, 0); lineNum.overflow = new RectOffset(0, 0, 0, 0); lineNum.font = font; lineNum.fontSize = 16; // This lines it up with the text area lines as the text area has padding GUILayout.Space(3); // Split up the text into lines and iterate through them string[] lines = fileText.Split(new string[1] { "\n" }, System.StringSplitOptions.None); for (int i = 0; i < lines.Length; i++) { // Here we use the lineNum text style to calculate the height of each line in the text area. So we temporarily enable word wrap if required if (wrapText) { lineNum.wordWrap = true; } GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); // Calculate the height of each line within the text area so we know where to position the line numbers. This is required in case word wrap is enabled and a single line in the file takes up multiple lines in the text area. float size = lineNum.lineHeight; if (i < lines.Length) { GUIContent content = new GUIContent(lines[i]); size = lineNum.CalcHeight(content, position.width - 58.0f); } // Diable word wrap for displaying the line numbers lineNum.wordWrap = false; // Display the line number. The height property makes sure the next line number is drawn in the correct place GUILayout.Label((i + 1) + ":", lineNum, GUILayout.Height(Mathf.Max(size, editorStyle.lineHeight))); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); } // Draw the text area for editing the file's text GUI.SetNextControlName("MainTextArea"); // << This is needed so changing the editor window focus works fileText = EditorGUILayout.TextArea(fileText, editorStyle); GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); Repaint(); // << Redraw the window immediatley instead of waiting for it to be focused on }