New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In the document status CloseButtonVisible is invalid #464

Closed
chencun opened this Issue Dec 27, 2016 · 6 comments

Comments

Projects
None yet
4 participants
@chencun

chencun commented Dec 27, 2016

Add form and set its type for DockState.Document
Set CloseButtonVisible to false
The close button is still visible on the label
It does not work

@lextm

This comment has been minimized.

Show comment
Hide comment
@lextm

lextm Dec 27, 2016

Member

Duplicate to #356. By design.

Member

lextm commented Dec 27, 2016

Duplicate to #356. By design.

@lextm lextm closed this Dec 27, 2016

@lextm lextm added the duplicate label Dec 27, 2016

@chencun

This comment has been minimized.

Show comment
Hide comment
@chencun

chencun Dec 27, 2016

I have looked at the #356 ,But I still believe that should be fix it ,Otherwise I set up Can't close, users still see a close button, can be closed and he will think, this is very bad for the user experience.As a result, I now can only be set to hideonclose,User wrong operation, need to open again,It's really too bad

chencun commented Dec 27, 2016

I have looked at the #356 ,But I still believe that should be fix it ,Otherwise I set up Can't close, users still see a close button, can be closed and he will think, this is very bad for the user experience.As a result, I now can only be set to hideonclose,User wrong operation, need to open again,It's really too bad

@lextm

This comment has been minimized.

Show comment
Hide comment
@lextm

lextm Dec 27, 2016

Member

If I were the original developer, I would not have even provided this CloseButtonVisible property at all.

The goal of this library should be emulating VS in all cases, and allow individual developers to use their derived themes. And I treated recent changes in this way.

Thus, in your case please develop your own themes by deriving from the existing ones. Then you can disable whatever visual elements at will.

Member

lextm commented Dec 27, 2016

If I were the original developer, I would not have even provided this CloseButtonVisible property at all.

The goal of this library should be emulating VS in all cases, and allow individual developers to use their derived themes. And I treated recent changes in this way.

Thus, in your case please develop your own themes by deriving from the existing ones. Then you can disable whatever visual elements at will.

@sylverdrag

This comment has been minimized.

Show comment
Hide comment
@sylverdrag

sylverdrag Jul 20, 2017

I can see the logic in that. Is there are tutorial on how to do it through the theme? I just read the Theme section of the documentation and I can't find any explanation on how it's done.

VS' users are mostly developers who won't panic if an important window gets closed by accident, but DPS is used for applications targeting the general public. Probably why the switch existed in the first place.

Perhaps that switch was a hack, but it was easy, fast and the ability to prevent a user from accidentally closing a vital panel and calling support because "the application is corrupted" is a big deal in terms of UX.

Also, the main Documentation should be edited, as it is still the recommended procedure:

You can also utilize the CloseButtonVisible property to hide the close button when docked in the DockPanel control

http://docs.dockpanelsuite.com/en/latest/tutorials/customizing-dockcontent.html

Disabling CloseButton has the side effect that if the user double clicks (as he is wont to do when the first click doesn't work), the panel opens in a separate window with no way to move it or dock it again. And of course having a button that doesn't work is non optimal.

Maybe the best way would be to expose that property through the Theme if possible. Something like:

var theme = new VS2015DarkTheme();
theme.EditCloseButtonVisibility = true;

I can't speak for other developers, but in my case, I am not a designer and I am perfectly happy to use one of the default themes - creating a custom theme just to hide a button seems a bit of an overkill.

sylverdrag commented Jul 20, 2017

I can see the logic in that. Is there are tutorial on how to do it through the theme? I just read the Theme section of the documentation and I can't find any explanation on how it's done.

VS' users are mostly developers who won't panic if an important window gets closed by accident, but DPS is used for applications targeting the general public. Probably why the switch existed in the first place.

Perhaps that switch was a hack, but it was easy, fast and the ability to prevent a user from accidentally closing a vital panel and calling support because "the application is corrupted" is a big deal in terms of UX.

Also, the main Documentation should be edited, as it is still the recommended procedure:

You can also utilize the CloseButtonVisible property to hide the close button when docked in the DockPanel control

http://docs.dockpanelsuite.com/en/latest/tutorials/customizing-dockcontent.html

Disabling CloseButton has the side effect that if the user double clicks (as he is wont to do when the first click doesn't work), the panel opens in a separate window with no way to move it or dock it again. And of course having a button that doesn't work is non optimal.

Maybe the best way would be to expose that property through the Theme if possible. Something like:

var theme = new VS2015DarkTheme();
theme.EditCloseButtonVisibility = true;

I can't speak for other developers, but in my case, I am not a designer and I am perfectly happy to use one of the default themes - creating a custom theme just to hide a button seems a bit of an overkill.

@maopost

This comment has been minimized.

Show comment
Hide comment
@maopost

maopost Sep 22, 2017

you can fix this by yourself. here is the directions
For theme 2003:

  1. in vs2003DockLaneCaption.cs

     private bool ShouldShowCloseButton
     {
         //Update
         //get	{	return (DockPane.ActiveContent != null)? DockPane.ActiveContent.DockHandler.CloseButton : false;	}
         get { return (DockPane.ActiveContent != null) ? DockPane.ActiveContent.DockHandler.CloseButtonVisible : false; }
     }
    
  2. In vs2003DockPaneStrip.cs
    private void SetInertButtons()
    {
    // Set the visibility of the inert buttons
    m_buttonScrollLeft.Visible = m_buttonScrollRight.Visible = m_buttonClose.Visible = (DockPane.DockState == DockState.Document);

         m_buttonClose.ForeColor = m_buttonScrollRight.ForeColor	= m_buttonScrollLeft.ForeColor = SystemColors.ControlDarkDark;
         m_buttonClose.BorderColor = m_buttonScrollRight.BorderColor	= m_buttonScrollLeft.BorderColor = SystemColors.ControlDarkDark;
     
         // Enable/disable scroll buttons
         int count = Tabs.Count;
    
         Rectangle rectTabOnly = TabsRectangle;
         Rectangle rectTab = (count == 0) ? Rectangle.Empty : GetTabRectangle(count - 1);
         m_buttonScrollLeft.Enabled = (OffsetX < 0);
         m_buttonScrollRight.Enabled = rectTab.Right > rectTabOnly.Right;
    
         // show/hide close button
         if (Appearance == DockPane.AppearanceStyle.ToolWindow)
             m_buttonClose.Visible = false;
         else
         {
             bool showCloseButton = DockPane.ActiveContent == null ? true : DockPane.ActiveContent.DockHandler.CloseButtonVisible;  //DockPane.ActiveContent.DockHandler.CloseButton;
                  
             if (m_buttonClose.Visible != showCloseButton)
             {
                 m_buttonClose.Visible = showCloseButton;
                 PerformLayout();
             }
         }
     }
    

maopost commented Sep 22, 2017

you can fix this by yourself. here is the directions
For theme 2003:

  1. in vs2003DockLaneCaption.cs

     private bool ShouldShowCloseButton
     {
         //Update
         //get	{	return (DockPane.ActiveContent != null)? DockPane.ActiveContent.DockHandler.CloseButton : false;	}
         get { return (DockPane.ActiveContent != null) ? DockPane.ActiveContent.DockHandler.CloseButtonVisible : false; }
     }
    
  2. In vs2003DockPaneStrip.cs
    private void SetInertButtons()
    {
    // Set the visibility of the inert buttons
    m_buttonScrollLeft.Visible = m_buttonScrollRight.Visible = m_buttonClose.Visible = (DockPane.DockState == DockState.Document);

         m_buttonClose.ForeColor = m_buttonScrollRight.ForeColor	= m_buttonScrollLeft.ForeColor = SystemColors.ControlDarkDark;
         m_buttonClose.BorderColor = m_buttonScrollRight.BorderColor	= m_buttonScrollLeft.BorderColor = SystemColors.ControlDarkDark;
     
         // Enable/disable scroll buttons
         int count = Tabs.Count;
    
         Rectangle rectTabOnly = TabsRectangle;
         Rectangle rectTab = (count == 0) ? Rectangle.Empty : GetTabRectangle(count - 1);
         m_buttonScrollLeft.Enabled = (OffsetX < 0);
         m_buttonScrollRight.Enabled = rectTab.Right > rectTabOnly.Right;
    
         // show/hide close button
         if (Appearance == DockPane.AppearanceStyle.ToolWindow)
             m_buttonClose.Visible = false;
         else
         {
             bool showCloseButton = DockPane.ActiveContent == null ? true : DockPane.ActiveContent.DockHandler.CloseButtonVisible;  //DockPane.ActiveContent.DockHandler.CloseButton;
                  
             if (m_buttonClose.Visible != showCloseButton)
             {
                 m_buttonClose.Visible = showCloseButton;
                 PerformLayout();
             }
         }
     }
    
@maopost

This comment has been minimized.

Show comment
Hide comment
@maopost

maopost Sep 22, 2017

For theme 2012, 2013 and 2015, the close button rendered differently.

first, the Code is in VS2012dockpanestrip.cs (same concept for theme 2013 and 2015)

  1. You need to add a member
    private bool m_closeButtonVisible = false; // for close button visibility

  2. Get the value in "private void SerInertbuttons()"
    m_closeButtonVisible = DockPane.ActiveContent == null ? true : DockPane.ActiveContent.DockHandler.CloseButtonVisible;

  3. Update code for DrawTab_Document
    private void DrawTab_Document(Graphics g, TabVS2012 tab, Rectangle rect),
    draw the image of close button depends on the button visibility

             if (DockPane.IsActiveDocumentPane)
             {
                 paint = activeColor;
                 text = activeText;
    
                 if (m_closeButtonVisible)        //update
                 {
                     image = IsMouseDown
                         ? imageService.TabPressActive_Close
                         : rectCloseButton == ActiveClose
                             ? imageService.TabHoverActive_Close
                             : imageService.TabActive_Close;  
                 }
             }
    
  4. The last thing you need to do is "Shrink the strip tab size if there is no close button".

         // Not show close button space if it not visible
         if (!m_closeButtonVisible)
         {
             rect.Width = rect.Width - rectCloseButton.Width;
         }
    

maopost commented Sep 22, 2017

For theme 2012, 2013 and 2015, the close button rendered differently.

first, the Code is in VS2012dockpanestrip.cs (same concept for theme 2013 and 2015)

  1. You need to add a member
    private bool m_closeButtonVisible = false; // for close button visibility

  2. Get the value in "private void SerInertbuttons()"
    m_closeButtonVisible = DockPane.ActiveContent == null ? true : DockPane.ActiveContent.DockHandler.CloseButtonVisible;

  3. Update code for DrawTab_Document
    private void DrawTab_Document(Graphics g, TabVS2012 tab, Rectangle rect),
    draw the image of close button depends on the button visibility

             if (DockPane.IsActiveDocumentPane)
             {
                 paint = activeColor;
                 text = activeText;
    
                 if (m_closeButtonVisible)        //update
                 {
                     image = IsMouseDown
                         ? imageService.TabPressActive_Close
                         : rectCloseButton == ActiveClose
                             ? imageService.TabHoverActive_Close
                             : imageService.TabActive_Close;  
                 }
             }
    
  4. The last thing you need to do is "Shrink the strip tab size if there is no close button".

         // Not show close button space if it not visible
         if (!m_closeButtonVisible)
         {
             rect.Width = rect.Width - rectCloseButton.Width;
         }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment