示例#1
0
 public ListControl MakeHeaderButton(Label button, PopupWindowContent popup, Color color)
 {
     _headerButtons.Add(new HeaderButton {
         Label = button, Popup = popup, Color = color
     });
     return(this);
 }
示例#2
0
 public ListControl MakeHeaderButton(IconButton icon, PopupWindowContent popup)
 {
     _headerButtons.Add(new HeaderButton {
         Icon = icon, Popup = popup
     });
     return(this);
 }
示例#3
0
        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());
        }
示例#4
0
        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);
                    }
                }
            }
        }
示例#6
0
        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();
            }
        }
示例#7
0
        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
                }
            }
        }
示例#8
0
 internal static void Show(Rect activatorRect, PopupWindowContent windowContent, PopupLocation[] locationPriorityOrder)
 {
     Show(activatorRect, windowContent, locationPriorityOrder, ShowMode.PopupMenu);
 }
示例#9
0
 public static void Show(Rect activatorRect, PopupWindowContent windowContent)
 {
     Show(activatorRect, windowContent, null);
 }
示例#10
0
 public static void Show(Rect activatorRect, PopupWindowContent content)
 {
     UnityEditor.PopupWindow.Show(activatorRect, content, null, ShowMode.PopupMenu);
 }