Beispiel #1
0
    public void RegexWindowShow(SciCode doc, string code, int pos16, TextSpan stringSpan, bool replace)
    {
        int j = stringSpan.Start, vi = _StringPrefixLength(code, j);

        if (!replace && (vi == 0 || !(code[j] == '@' || code[j + 1] == '@')))
        {
            ADialog.ShowInfo(null, "Regular expression string should be like @\"text\", not like \"text\". The Regex tool will not escape \\ when inserting text.");
        }

        if (_regexWindow == null)
        {
            _regexWindow             = new RegexWindow();
            _regexWindow.Window.Name = "Ci.Regex";             //prevent hiding when activated
        }

        var r = CiUtil.GetCaretRectFromPos(doc, pos16);
        int i = Au.Util.ADpi.ScaleInt(100);

        r.Width = i;
        r.Inflate(i, 0);
        _regexWindow.Show(doc, r, false, PopupAlignment.TPM_CENTERALIGN | PopupAlignment.TPM_VERTICAL);
        _regexWindow.InsertInControl = doc;
        var s = _regexWindow.CurrentTopic;

        if (s == "replace")
        {
            if (!replace)
            {
                _regexWindow.CurrentTopic = _regexTopic;
            }
        }
        else if (replace)
        {
            _regexTopic = s;
            _regexWindow.CurrentTopic = "replace";
        }
        doc.ZTempRanges_Add(this, stringSpan.Start + vi + 1, stringSpan.End - 1, onLeave: () => _regexWindow.Hide());
    }
Beispiel #2
0
    static void _ShowRegexOrKeysWindow(bool regex)
    {
        bool retry = false;

g1:
        if (!CodeInfo.GetDocumentAndFindNode(out var cd, out var node))
        {
            return;
        }
        var pos16 = cd.pos16;

        if (!CiUtil.IsInString(ref node, pos16))
        {
            if (regex || retry)
            {
                ADialog.ShowInfo("The text cursor must be in a string.");
                return;
            }
            InsertCode.Statements("AKeys.Key(\"%\");", goToPercent: true);
            retry = true;
            goto g1;
        }
        var doc        = cd.sciDoc;
        var stringSpan = node.Span;

        var t = CodeInfo._tools;

        if (regex)
        {
            t.RegexWindowShow(doc, cd.code, pos16, stringSpan, replace: false);
        }
        else
        {
            t.KeysWindowShow(doc, cd.code, pos16, stringSpan);
        }
    }
Beispiel #3
0
    bool _GetGrid()
    {
        var g = _grid;

        //test script
        FileNode fts = null;

        if (g.ZGetValue("testScript", out var sts, true, true))
        {
            fts = _f.FindRelative(sts, false);
            if (fts == null)
            {
                ADialog.ShowInfo("testScript file not found", "Must be path relative to this file or path in worspace like \\file or \\folder\\file.", owner: this); return(false);
            }
        }
        _f.TestScript = fts;

        //info: _Get returns null if hidden

        _meta.runMode     = _Get("runMode");
        _meta.ifRunning   = _Get("ifRunning");
        _meta.ifRunning2  = _Get("ifRunning2");
        _meta.uac         = _Get("uac");
        _meta.prefer32bit = _Get("prefer32bit");

        _meta.optimize     = _Get("optimize");
        _meta.warningLevel = _Get("warningLevel");
        _meta.noWarnings   = _Get("noWarnings");
        _meta.define       = _Get("define");
        _meta.preBuild     = _Get("preBuild");
        _meta.postBuild    = _Get("postBuild");

        _meta.outputPath = _Get("outputPath");
        _meta.console    = _Get("console");
        _meta.icon       = _Get("icon");
        _meta.manifest   = _Get("manifest");
        _meta.resFile    = _Get("resFile");
        _meta.sign       = _Get("sign");
        _meta.xmlDoc     = _Get("xmlDoc");

        _meta.role = null;
        if (_role != ERole.classFile)
        {
            if (_isClass || _role != ERole.miniProgram)
            {
                _meta.role = _role.ToString();
            }
            switch (_role)
            {
            case ERole.exeProgram:
            case ERole.classLibrary:
                if (_meta.outputPath.NE())
                {
                    _meta.outputPath = _role == ERole.exeProgram ? @"%AFolders.Workspace%\bin" : @"%AFolders.ThisApp%\Libraries";
                }
                break;
            }
            var name = APath.GetFileName(_f.Name, true);
            if (_meta.xmlDoc == "")
            {
                _meta.xmlDoc = name + ".xml";
            }
            if (_meta.manifest == "")
            {
                _meta.manifest = name + ".exe.manifest";
            }
        }

        return(true);
    }
Beispiel #4
0
            internal void SetDockState(_DockState state, bool onStartDrag = false)
            {
                //AOutput.Write(this, Name);
                var gp = this as _Panel;

                if (state == _DockState.LastVisible)
                {
                    if (!this.IsHidden)
                    {
                        if (this.IsTabbedPanel)
                        {
                            gp.ParentTab.SetDockState(_DockState.LastVisible);
                            if (this.IsDocked)
                            {
                                gp.ParentTab.SetActiveItem(gp);
                            }
                        }
                        if (this.ParentControl is _Float gf)
                        {
                            ((AWnd)gf).EnsureInScreen();
                        }
                        return;
                    }
                    state = this.SavedVisibleDockState;
                }

                var prevState = this.DockState;

                if (state == prevState)
                {
                    return;
                }

                if (this.ParentSplit == null && state == _DockState.Docked)                  //new panel
                {
                    ADialog.ShowInfo("How to dock floating panels", "Alt+drag and drop.", owner: _manager);
                    return;
                }

                bool isTab = gp == null;
                _Tab gt = null, gtParent = null;

                if (isTab)
                {
                    gt = this as _Tab;
                }
                else
                {
                    gtParent = gp.ParentTab;
                }

                this.DockState = state;

                //get RECT for floating now, because later this.ParentControl will change and even may be destroyed
                RECT rect = default;

                if (state == _DockState.Floating)
                {
                    if (!onStartDrag && !SavedFloatingBounds.IsEmptyRect())
                    {
                        if (SavedFloatingBounds.X == int.MinValue)                          //specified only width and height
                        {
                            var mp = AMouse.XY;
                            rect = new RECT(mp.x - 15, mp.y - 15, SavedFloatingBounds.Width, SavedFloatingBounds.Height);
                        }
                        else
                        {
                            rect = SavedFloatingBounds;
                        }
                        rect.EnsureInScreen();
                    }
                    else if (this.ParentSplit != null)
                    {
                        rect = this.RectangleInScreen;
                        AWnd.More.WindowRectFromClientRect(ref rect, WS.POPUP | WS.THICKFRAME, WS2.TOOLWINDOW);
                    }
                    else                         //new panel, empty bounds
                    {
                        var mp = AMouse.XY;
                        rect = new RECT(mp.x - 15, mp.y - 15, 300, 150);
                        rect.EnsureInScreen();
                    }
                }

                var panels = isTab ? gt.Items.FindAll(v => v.IsDocked) : new List <_Panel>(1)
                {
                    gp
                };

                //(isTab ? gt.ActiveItem : gp)?.Content.Hide();
                var gtp = isTab ? gt.ActiveItem : gp;

                if (gtp != null)
                {
                    if (state != _DockState.Docked && _manager.ZFocusControlOnUndockEtc != null && gtp.Content.ContainsFocus)
                    {
                        _manager.ZFocusControlOnUndockEtc.Focus();
                    }
                    gtp.Content.Hide();
                }

                Action postAction = null;

                switch (prevState)
                {
                case _DockState.Docked:
                    if (gtParent != null)
                    {
                        gtParent.OnItemUndocked(gp, out postAction);
                    }
                    else
                    {
                        this.ParentSplit.OnChildUndocked(this);
                    }

                    _manager.Invalidate(this.Bounds, true);                     //some controls don't redraw properly, eg ToolStripTextBox
                    break;

                case _DockState.Floating:
                    //case _DockState.AutoHide:
                    var f      = this.ParentControl as _Float;
                    var parent = (gtParent != null) ? gtParent.ParentControl : _manager;
                    _parentControl = parent;
                    foreach (var v in panels)
                    {
                        _ChangeParent(v, parent);
                    }
                    if (prevState == _DockState.Floating)
                    {
                        this.SavedFloatingBounds = f.Bounds;
                    }
                    f.Close();
                    break;
                }

                switch (state)
                {
                case _DockState.Docked:
                    if (gtParent != null)
                    {
                        gtParent.OnItemDocked(gp);
                    }
                    else
                    {
                        this.ParentSplit.OnChildDocked(this);
                    }
                    break;

                case _DockState.Floating:
                    var f = new _Float(_manager, this);
                    this._parentControl = f;
                    foreach (var v in panels)
                    {
                        _ChangeParent(v, f);
                    }

                    f.Bounds = rect;
                    f.Show(_manager.TopLevelControl);
                    break;

                //case _DockState.AutoHide:
                //	break;
                case _DockState.Hidden:
                    this.SavedVisibleDockState = prevState;
                    break;
                }

                if (state != _DockState.Hidden)
                {
                    (isTab ? gt.ActiveItem : gp)?.Content.Show();
                }

                postAction?.Invoke();
                //_manager.Invalidate(true);

                if (prevState != _DockState.Hidden)
                {
                    _manager._OnMouseLeave_Common(this.ParentControl);                                                //calls _UnhiliteTabButton and _HideTooltip
                }
            }
Beispiel #5
0
        /// <summary>
        /// Toolbar button MouseUp handler. Implements context menu that allows to customize.
        /// </summary>
        private void _OnMouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Right)
            {
                return;
            }
            var  item        = sender as ToolStripItem;
            var  ts          = item.Owner;
            var  dd          = ts as ToolStripDropDownMenu;
            bool isMenu      = dd != null;
            bool isCustom    = ts == _tsCustom1 || ts == _tsCustom2;
            bool isSeparator = item is ToolStripSeparator;
            bool isHidden    = item.Overflow == ToolStripItemOverflow.Always;
            var  x           = item.Tag as XElement;

            var m = new AMenu();

            m["Properties..."] = o => {
                using (var f = new FSMProperties(this, item.Tag as XElement, isMenu)) {
                    if (f.ShowDialog(_form) == DialogResult.OK)
                    {
                        _Strips_Customize(6, item, null, f);
                    }
                }
            };
            if (!isMenu)
            {
                if (!isSeparator)
                {
                    m["Hide"] = o => _Strips_Customize(5, item); if (isHidden)
                    {
                        m.LastMenuItem.Checked = true;
                    }
                }
                if (isCustom || isSeparator)
                {
                    m["Remove"] = o => _Strips_Customize(3, item);
                }
                if (!isHidden)
                {
                    m["Add separator"] = o => _Strips_Customize(4, item, ts);
                }
            }
            if (isCustom)
            {
                if (_tsCustom1 != null && _tsCustom2 != null)
                {
                    if (ts == _tsCustom1)
                    {
                        m["Move to toolbar Custom2"] = o => _Strips_Customize(2, item, _tsCustom2);
                    }
                    else
                    {
                        m["Move to toolbar Custom1"] = o => _Strips_Customize(2, item, _tsCustom1);
                    }
                }
            }
            else
            {
                if (_tsCustom1 != null)
                {
                    m["Copy to toolbar Custom1"] = o => _Strips_Customize(1, item, _tsCustom1);
                }
                if (_tsCustom2 != null)
                {
                    m["Copy to toolbar Custom2"] = o => _Strips_Customize(1, item, _tsCustom2);
                }
            }
            if (!isMenu)
            {
                m.Separator();
                m["How to customize..."] = o => ADialog.ShowInfo("Customizing toolbars and menus",
                                                                 @"There are several standard toolbars and two custom toolbars (initially empty). Standard toolbar buttons cannot be added and removed, but can be hidden and reordered. Menu items cannot be added, removed, hidden and reordered.

You can find most customization options in two context menus. Right-clicking a button or menu item shows its context menu. Right-clicking before the first button shows toolbar's context menu. You can Alt+drag toolbar buttons to reorder them on the same toolbar. You can Alt+drag toolbars to dock them somewhere else. Use splitters to resize. Right click a splitter to change its thickness."
                                                                 );
                string folder = APath.GetDirectoryPath(_xmlFileCustom), link = $"<a href=\"{folder}\">{folder}</a>";
                m["How to backup, restore, reset..."] = o => {
                    ADialog.Show("How to backup, restore or reset customizations",
                                 $@"All customizations are saved in XML files in folder
{link}

To backup:  copy the file.
To restore:  exit this application and replace the file with the backup file.
To reset:  exit this application and delete the file."
                                 , icon: DIcon.Info, onLinkClick: h => { AExec.Run(h.LinkHref); });
                };
            }

            m.Show(ts);
        }