Esempio n. 1
0
File: Dwnd.cs Progetto: qmgindi/Au
    bool _FillProperties(bool newWindow)
    {
        bool isCon = !_con.Is0;

        _WinInfo f = default;

        if (!_GetClassName(_wnd, out f.wClass))
        {
            return(false);                                            //note: get even if !newWindow, to detect closed window
        }
        if (isCon && !_GetClassName(_con, out f.cClass))
        {
            return(false);
        }

        bool _GetClassName(wnd w, out string cn)
        {
            cn = w.ClassName; if (cn != null)
            {
                return(true);
            }
            _winInfo.zText       = "Failed to get " + (w == _wnd ? "window" : "control") + " properties: \r\n" + lastError.message;
            _scroller.Visibility = Visibility.Hidden;
            return(false);
        }

        _noeventValueChanged = true;

        var wndName = _wnd.NameTL_;

        if (newWindow)
        {
            nameW.Set(true, TUtil.EscapeWindowName(wndName, true));
            classW.Set(true, TUtil.StripWndClassName(f.wClass, true));
            f.wProg = _wnd.ProgramName;
            var ap = new List <string> {
                f.wProg, "WOwner.Process(processId)", "WOwner.Thread(threadId)"
            }; if (!_wnd.Get.Owner.Is0)
            {
                ap.Add("WOwner.Window(ow)");
            }
            programW.Set(wndName.NE(), f.wProg, ap);
            containsW.Set(false, null, _ContainsCombo_DropDown);
        }
        else if (wndName != _wndName)
        {
            if (TUtil.ShouldChangeTextBoxWildex(nameW.t.Text, wndName))
            {
                nameW.Set(true, TUtil.EscapeWindowName(wndName, true));
            }
        }
        f.wName = _wndName = wndName;

        if (isCon)
        {
            //name combo
            f.cName = _con.Name;
            int iSel = f.cName.NE() ? -1 : 0;
            var an   = new List <string> {
                TUtil.EscapeWildex(f.cName)
            };
            _ConNameAdd("***wfName ", f.cWF = _con.NameWinforms);
            /*bool isElm =*/
            _ConNameAdd("***elmName ", f.cElm = _con.NameElm);
            //bool isLabel = _ConNameAdd("***label ", f.cLabel = _con.NameLabel);
            //if(isElm && isLabel && iSel == an.Count - 2 && f.cElm == f.cLabel) iSel++; //if label == elmName, prefer label
            if (iSel < 0)
            {
                iSel = 0;                       //never select text, even if all others unavailable
            }
            _ConNameAdd("***text ", f.cText = _con.ControlText);
            bool _ConNameAdd(string prefix, string value)
            {
                if (value.NE())
                {
                    return(false);
                }
                if (iSel < 0)
                {
                    iSel = an.Count;
                }
                an.Add(prefix + TUtil.EscapeWildex(value));
                return(true);
            }

            bool idUseful = TUtil.GetUsefulControlId(_con, _wnd, out f.cId);
            //idC.Visible = idUseful;
            idC.Set(idUseful, f.cId.ToS() + (idUseful ? null : " /*probably not useful*/"));
            string sName = an[iSel], sClass = TUtil.StripWndClassName(f.cClass, true);
            nameC.Set(!idUseful, sName, an);
            classC.Set(!idUseful, sClass);
            bool hiddenToo = !_con.IsVisible;
            cHiddenTooC.IsChecked = hiddenToo;
            var skip = idUseful ? null : TUtil.GetControlSkip(_wnd, _con, sName, sClass, hiddenToo);
            skipC.Set(skip != null, skip);
        }

        bool checkControl = isCon && _checkControl;

        _cControl.IsChecked = checkControl;
        _ShowControlProperties(showGrid: checkControl, showAll: isCon);

        _noeventValueChanged = false;

        _scroller.Visibility = Visibility.Visible;
        _FillWindowInfo(f);
        return(true);

        List <string> _ContainsCombo_DropDown()
        {
            try {
                var a1 = new List <string>();
                //child
                foreach (var c in _wnd.Get.Children(onlyVisible: true))
                {
                    var cn = c.Name; if (cn.NE())
                    {
                        continue;
                    }
                    cn = "c '" + TUtil.StripWndClassName(c.ClassName, true) + "' " + TUtil.EscapeWildex(cn);
                    if (!a1.Contains(cn))
                    {
                        a1.Add(cn);
                    }
                }
                //elm
                var    a2       = new List <string>();
                var    a3       = _wnd.Elm[name : "?*", prop : "notin=SCROLLBAR\0maxcc=100", flags : EFFlags.ClientArea].FindAll();     //all that have a name
                string prevName = null;
                for (int i = a3.Length; --i >= 0;)
                {
                    if (!a3[i].GetProperties("Rn", out var prop))
                    {
                        continue;
                    }
                    if (prop.Name == prevName && prop.Role == "WINDOW")
                    {
                        continue;
                    }
                    prevName = prop.Name;                                                                                   //skip parent WINDOW
                    string rn = "e '" + prop.Role + "' " + TUtil.EscapeWildex(prop.Name);
                    if (!a2.Contains(rn))
                    {
                        a2.Add(rn);
                    }
                }
                a2.Reverse();
                a1.AddRange(a2);

                return(a1);
                //rejected: sort
            }
            catch (Exception ex) { Debug_.Print(ex); return(null); }
        }
    }
Esempio n. 2
0
File: Dwnd.cs Progetto: qmgindi/Au
 public static void Dialog(wnd w = default)
 => TUtil.ShowDialogInNonmainThread(() => new Dwnd(w));
Esempio n. 3
0
File: Dwnd.cs Progetto: qmgindi/Au
 static Dwnd()
 {
     TUtil.OnAnyCheckTextBoxValueChanged <Dwnd>((d, o) => d._AnyCheckTextBoxValueChanged(o));
 }
Esempio n. 4
0
 static Duiimage()
 {
     TUtil.OnAnyCheckTextBoxValueChanged <Duiimage>((d, o) => d._AnyCheckTextBoxComboValueChanged(o), comboToo: true);
 }
Esempio n. 5
0
 //when checked/unchecked any checkbox, and when text changed of any textbox
 void _AnyCheckTextBoxComboValueChanged(object source)
 {
     if (!_noeventValueChanged)
     {
         _noeventValueChanged = true;
         //print.it("source", source);
         if (source is KCheckBox c)
         {
             bool on = c.IsChecked;
             if (c == controlC)
             {
                 if (_useCon = on)
                 {
                     _wnd.MapClientToClientOf(_con, ref _rect);
                 }
                 else
                 {
                     _con.MapClientToClientOf(_wnd, ref _rect);
                 }
                 rectC.c.IsChecked = false;
             }
             else if (c == wiflagsC.c)
             {
                 if (_image != null)
                 {
                     TUtil.InfoTooltip(ref _ttInfo, c, "After changing 'Window pixels' may need to capture again.\nClick Test. If not found, click Capture.");
                 }
             }
             else if (c == skipC.c)
             {
                 if (on)
                 {
                     allC.IsChecked = false;
                 }
             }
             else if (c == allC)
             {
                 if (on)
                 {
                     skipC.c.IsChecked = false;
                 }
             }
         }
         else if (source is TextBox t && t.Tag is KCheckTextBox k)
         {
             _noeventValueChanged = _formattedOnValueChanged = false;                 //allow auto-check but prevent formatting twice
             k.CheckIfTextNotEmpty();
             if (_formattedOnValueChanged)
             {
                 return;
             }
         }
         else if (source is ComboBox u && u.Tag is KCheckComboBox m)
         {
             _noeventValueChanged = _formattedOnValueChanged = false;                 //allow auto-check but prevent formatting twice
             m.c.IsChecked        = true;
             if (_formattedOnValueChanged)
             {
                 return;
             }
         }
Esempio n. 6
0
 public static void Dialog()
 => TUtil.ShowDialogInNonmainThread(() => new Duiimage());
Esempio n. 7
0
    /// <summary>
    /// Returns code to find window w and optionally control con in it. Without newline at the end.
    /// If w/con is same as previous and code of this control is modified and valid, gets code from this code control, from the start to ZReadonlyStart.
    /// Else creates code "var w = wnd.find(...);". If w is invalid, creates code "wnd w = default;".
    /// The returned wndVar is final wnd variable name (of window or control).
    /// </summary>
    public (string code, string wndVar) ZGetWndFindCode(bool test, wnd w, wnd con = default, bool private1 = false)
    {
        if (test)           //remove 'wait' and 'activate' from wnd.find and wnd.Child. If no 'wait', insert 0 to throw notfoundexception.
        {
            var k = ZGetWndFindCode(false, w, con, private1: true);
            var s = k.code;
            var p = _ParseWndFind(s, test: true);
            if (p?.wVar != null)
            {
                void _Replace(int end, int argsStart, int argsEnd, int nameStart, bool orRun = false, bool orRunReplace = false, int funcNameEnd = 0)
                {
                    if (orRun && !orRunReplace)
                    {
                        return;
                    }
                    s = s.ReplaceAt(argsEnd..end, ");");                                      //remove '.Activate()' etc. If orRun, removes run etc arguments.
                    s = s.ReplaceAt(argsStart..nameStart, nameStart < argsEnd ? "0, " : "0"); //remove 'waitS, ' and add '0, ' (to throw NotFoundException)
                    if (orRun)
                    {
                        s = s.Remove(funcNameEnd - 5, 5);                            //findOrRun -> find
                    }
                }

                if (p.cVar != null)
                {
                    _Replace(p.cEnd, p.cArgsStart, p.cArgsEnd, p.cNameStart);
                }
                _Replace(p.wEnd, p.wArgsStart, p.wArgsEnd, p.wNameStart, p.orRun, p.orRunReplace, p.wFuncNameEnd);
            }
            //print.it(s);
            k.code = s;
            return(k);
        }

        string R = null, sCode = null, wndVar = "w", conVar = "c";

        if (w != _wnd)
        {
            _userModified = false;
        }
        else if (!_userModified)
        {
            _userModified = 0 != Call(Sci.SCI_GETMODIFY);
        }
        if (!w.Is0)
        {
            if (_userModified)
            {
                sCode = zRangeText(false, 0, _ReadonlyStartUtf8);
                var p = _ParseWndFind(sCode, test: false);
                if (p?.wVar != null)
                {
                    bool isConCode = p.cVar != null;
                    //print.it(isConCode);
                    if (con == _con && !con.Is0 == isConCode)
                    {
                        //print.it(isConCode ? "same control" : "no control");
                        if (!private1 && p.wName != null)
                        {
                            //if window name changed and does not match the name in code, change it in code
                            var name = w.NameTL_;
                            if (name != null && !new wildex(p.wName, noException: true).Match(name))
                            {
                                var s = TUtil.EscapeWindowName(name, true);
                                if (!(TUtil.IsVerbatim(s, out _) || TUtil.MakeVerbatim(ref s)))
                                {
                                    s = s.Escape(quote: true);
                                }
                                sCode = sCode.ReplaceAt(p.wNameStart..p.wNameEnd, s);
                            }
                        }
                        return(sCode, p.cVar ?? p.wVar);
                    }
                    wndVar = p.wVar;
                    if (isConCode)
                    {
                        sCode = sCode[..p.cStart];