public ListControl MakeHeaderButton(Label button, PopupWindowContent popup, Color color) { _headerButtons.Add(new HeaderButton { Label = button, Popup = popup, Color = color }); return(this); }
public ListControl MakeHeaderButton(IconButton icon, PopupWindowContent popup) { _headerButtons.Add(new HeaderButton { Icon = icon, Popup = popup }); return(this); }
protected override void Execute() { var editorController = SdlTradosStudio.Application.GetController <EditorController>(); var document = editorController.ActiveDocument; if (document == null) { return; } var viewPartController = SdlTradosStudio.Application.GetController <RegexMatchAutoSuggestProviderViewPartController>(); if (viewPartController == null) { return; } var regexPatternEntries = viewPartController.RegexPatternEntries; if (regexPatternEntries == null) { return; } var segmentPair = document.ActiveSegmentPair; if (segmentPair == null) { return; } if (document.FocusedDocumentContent != FocusedDocumentContent.Target) { return; } var activeProcess = CaretPosition.GetActiveProcess(); if (activeProcess != "SDLTradosStudio") { return; } var text = string.Join("", segmentPair.Source.AllSubItems.OfType <IText>().Select(txt => txt.Properties.Text)); Task <List <AutoSuggestEntry> > .Factory.StartNew( () => { var variables = viewPartController.Variables; return(regexPatternEntries.GetAutoSuggestEntries(text, variables)); }) .ContinueWith(task => { if (task.Result.Count > 0) { var content = new PopupWindowContent(task.Result); var caretPosition = CaretPosition.EvaluateCarePosition(); _popupToolStrip.Show(caretPosition, content); } }, TaskScheduler.FromCurrentSynchronizationContext()); }
private void btnRun_Click(object sender, EventArgs e) { var sourceText = txtSource.Text; if (string.IsNullOrEmpty(sourceText)) { return; } var autoSuggestEntries = _regexPatternEntries.GetAutoSuggestEntries(sourceText, _variables); var popupContent = new PopupWindowContent(autoSuggestEntries); popupWindow.SetContent(popupContent); }
public static void ShowPopupWindow(Rect rect, PopupWindowContent windowContent, ShowMode showMode) { Type popupWindow = typeof(PopupWindow); foreach (var method in popupWindow.GetMethods(flagsEverything)) { if (method.Name == "Show" && method.GetParameters().Length == 4) { try { method.Invoke(null, new object[] { rect, windowContent, null, (int)showMode }); } catch (Exception e) { Debug.LogError(e); } } } }
private void DrawList <T>(PopupWindowContent compositeAddContent, List <T> effectList) where T : ScriptableObject { GUILayout.BeginHorizontal(); var found = (T)EditorGUILayout.ObjectField("Add Existing Effect", null, typeof(T), false); if (found != null && effectList.Contains(found)) { effectList.Add(found); } if (GUILayout.Button("Add New Effect")) { PopupWindow.Show(new Rect(0, 0, 300, 0), compositeAddContent); } GUILayout.EndHorizontal(); for (var i = 0; i < effectList.Count; i++) { var effectSubEffect = effectList[i]; GUILayout.BeginHorizontal(); effectSubEffect.name = GUILayout.TextField(effectSubEffect.name); if (GUILayout.Button("Edit")) { Selection.SetActiveObjectWithContext(effectSubEffect, this); } if (GUILayout.Button("Delete")) { effectList.RemoveAt(i); DestroyImmediate(effectSubEffect, true); } GUILayout.EndHorizontal(); } }
internal static void Show(Rect activatorRect, PopupWindowContent windowContent, PopupLocation[] locationPriorityOrder, ShowMode showMode) { // If we already have a popup window showing this type of content, then just close // the existing one. var existingWindows = Resources.FindObjectsOfTypeAll(typeof(PopupWindow)); if (existingWindows != null && existingWindows.Length > 0) { var existingPopup = existingWindows[0] as PopupWindow; if (existingPopup != null) { object _WindowContent = existingPopup.GetField <object>("m_WindowContent"); if (_WindowContent != null && _WindowContent.GetType() == windowContent.GetType()) { //existingPopup.CloseWindow(); //existingPopup.MethodInvoke( "CloseWindow", null ); existingPopup.Close(); return; } } } if (ShouldShowWindow(activatorRect)) { object win = ScriptableObject.CreateInstance <PopupWindow>(); if (win != null) { win.MethodInvoke("Init", new object[] { activatorRect, windowContent, null, 1, true }); } if (Event.current != null) { EditorGUIUtility.ExitGUI(); // Needed to prevent GUILayout errors on OSX } } }
internal static void Show(Rect activatorRect, PopupWindowContent windowContent, PopupLocation[] locationPriorityOrder) { Show(activatorRect, windowContent, locationPriorityOrder, ShowMode.PopupMenu); }
public static void Show(Rect activatorRect, PopupWindowContent windowContent) { Show(activatorRect, windowContent, null); }
public static void Show(Rect activatorRect, PopupWindowContent content) { UnityEditor.PopupWindow.Show(activatorRect, content, null, ShowMode.PopupMenu); }