Exemplo n.º 1
0
        /// <summary>
        /// Toggle the docked form on and off, can be called first and will initialize the form
        /// </summary>
        public void Toggle()
        {
            try {
                // initialize if not done
                if (_fakeForm == null)
                {
                    // register fake form to Npp
                    _fakeForm = new NppDockableDialogFakeForm
                    {
                        Dock = System.Windows.Forms.DockStyle.Fill
                    };

                    NppTbData nppTbData = new NppTbData {
                        hClient       = _fakeForm.Handle,
                        pszName       = AssemblyInfo.AssemblyProduct + " - " + _dialogDescription,
                        dlgID         = DockableCommandIndex,
                        uMask         = _formDefaultPos | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR,
                        hIconTab      = (uint)Utils.GetIconFromImage(_iconImage).Handle,
                        pszModuleName = AssemblyInfo.AssemblyProduct
                    };
                    Npp.RegisterDockableDialog(nppTbData);
                    _fakeForm.OnDockableDialogClose += FormOnOnDockableDialogClose;
                    InitForm();
                    IsVisible = true;
                }
                else
                {
                    if (IsVisible)
                    {
                        Npp.HideDockableDialog(_fakeForm.Handle);
                        IsVisible = false;
                    }
                    else
                    {
                        Npp.ShowDockableDialog(_fakeForm.Handle);
                        InitForm();
                        IsVisible = true;
                    }
                }

                // Dock the NppDialog at _fakeform
                Form.TopLevel        = false;
                Form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
                Form.Dock            = System.Windows.Forms.DockStyle.Fill;
                _fakeForm.Controls.Add(Form);
            } catch (Exception e) {
                ErrorHandler.ShowErrors(e, "Error loading " + _dialogDescription);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Toggle the docked form on and off, can be called first and will initialize the form
 /// </summary>
 public void Toggle()
 {
     try {
         // initialize if not done
         if (_fakeForm == null)
         {
             // register fake form to Npp
             _fakeForm = new NppDockableDialogFakeForm();
             NppTbData nppTbData = new NppTbData {
                 hClient       = _fakeForm.Handle,
                 pszName       = AssemblyInfo.AssemblyProduct + " - " + _dialogDescription,
                 dlgID         = DockableCommandIndex,
                 uMask         = _formDefaultPos | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR,
                 hIconTab      = (uint)Utils.GetIconFromImage(_iconImage).Handle,
                 pszModuleName = AssemblyInfo.AssemblyProduct
             };
             Npp.RegisterDockableDialog(nppTbData);
             _fakeForm.OnDockableDialogClose += FormOnOnDockableDialogClose;
             InitForm();
             IsVisible = true;
         }
         else
         {
             if (IsVisible)
             {
                 Npp.HideDockableDialog(_fakeForm.Handle);
                 IsVisible = false;
             }
             else
             {
                 Npp.ShowDockableDialog(_fakeForm.Handle);
                 IsVisible = true;
             }
         }
         Form.RefreshPosAndLoc();
     } catch (Exception e) {
         ErrorHandler.ShowErrors(e, "Error loading " + _dialogDescription);
     }
 }