Cannot remove custom ribbon controls from quick access toolbar (QAT) menu - c#

I have a custom addin for Word (could also be for Excel).
The addin has a ribbon with multiple groups and multiple controls (buttons) within them.
This is an ongoing project and some of the ribbon buttons are for users, and some are for testing/development purposes.
When I send the product to the client I only show certain buttons. I want the testing buttons to be completely invisible/inaccessible. I Have tried setting the testing buttons/groups to visible = false.
This works, in the sense that the buttons do not appear on the ribbon, but if the user goes to Word's quick access toolbar > "More Commands" > "Choose Commands From" dropdown and selects my custom addin...
Then the user can see all of my buttons. Even the ones with no label.
I have tried looping the controls in the ribbon load method and setting the testing controls to enabled = false, locked = true, generatemember = false, but none of these hide the buttons from the QAT menu. I also tried control.Dispose() - no joy.
Is there anyway to set the properties of a ribbon button such that it is completely invisible and inaccessible to the user in the QAT??
Many thanks

Set the ApplicationMode.
Button CommandName='cmdExportMetadata' ApplicationModes='1'
Please see the below link too :
https://msdn.microsoft.com/en-us/library/windows/desktop/dd940486(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/ee264330(v=vs.85).aspx

I would suggest you to create debug buttons dynamically. Define a constant variable like public constant string environment = "DEBUG"; and check it on start up

Related

limiting tabbing to a custom in-window message box

I have made a custom MessageBox for my application and it launches as a UserControl. I have two buttons inside it and I would like to allow users to press Tab to switch between Buttons. However, since it's a UserControl overlaying the content, Pressing tab more than twice makes the focus go in the background on elements that aren't supposed to be tabbed at.
I can't figure out a good idea how to prevent this, I've thought of making a method that will select all elements and make their IsTabStop values to false and then restore them later, but I think that would be more of a problem then a solution.
Is there a way around this to limit tabbing only to the UserControl?
I would also appreciate advice on working with the message box.. the whole messagebox is an async function that has an infinitive loop until the answer is given. Is there another way to stop the application until one of the message box options was selected?
Crowcoder's reference has lead to correct MSDN page where I found my solution:
dialog = new UCMessageBox("Are you sure you want to exit the application?", MBType.YesNo);
AppMessageBox.Children.Add(dialog);
KeyboardNavigation.SetTabNavigation(dialog, KeyboardNavigationMode.Cycle);
The key was to call .SetTabNavigation function and direct it to my dialog (custom UserControl for the message box) and setting the KeyboardNavigationMode to Cycle.
After closing the UC rest of the application continued normally regarding navigation.

Create wizard some clarification

I want to create simple wizard with 3 pages
Page 1 have just next button
Page 2 have next and previous
Page 3 have previous and finish
I have created the pages and add to them needed buttons and in the events I have call to the next pages, for instance in page one in the button click I added the following code
private void Button_Click(object sender, RoutedEventArgs e)
{
p2 = new Page2();
NavigationService.Navigate(p2);
}
In the main window cs I have changed the inheritance to NavigationWindow instead of Window and in the xaml also. Currently its working but I have 3 questions.
The pages which displayed is part of the main window, how can i avoid it, since when I run it the buttons place is not like I put in the designer? It was changed.
The button currently in the Grid, should I put them in different control (the button place should be like any wizard in the left buttom of the page) ?
How can I avoid the navigation arrows in the page right upper screen?
Thanks!
To answer your questsions in reverse,
3. How can I avoid the navigation arrows in the page upper right screen?
I have an opensource library http://winchrome.codeplex.com/ that re-styles navigation windows in several ways. For example these are all NavigationWindow s
In short you just style the NavigationWindow to only show the parts you want.
2.The button currently in the Grid, should I put them in different control (the button place should be like any wizard in the left buttom of the page) ?
If you look at the styles from WinChrome then you will see that it is just a case of rebuiliding the UI as you want and providing a ContentPresenter to hold your pages. e.g. the VS2012 style applies lots of styles on the window but avoids adding back and forward buttons., whereas the Win7 style rebuilds the back and forwards in a Win7 Style.
If you do this however you will need a means of passing your enabled or visible states to the buttons outside the pages. Take a look at http://www.codeproject.com/Articles/8197/Designer-centric-Wizard-control for how to do this in Winforms. In WPF you could either derive from your Pages to create WizardPage classes with CanBack, CanNext or IsFinish properties, or alteratively define attached properties to do the same (There are examples of how to do this in VS2012.cs where we define the glow color)
And finally
1. The pages which displayed is part of the main window, how can i avoid it, since when I run it the buttons place is not like I put in the designer? It was changed.
I'd need to see some code to comment on how you've done it, but if you look at any of the demo programs in WinChrome then you can see how I've done it without problems.
Good luck!

devcomponents ribbon bar quick access toolbar

I trying to use the Quick access toolbar on Dev Components Ribbon Bar, it works fine if I set it in the designer.
But if I change the 'CanCustomize' flag on a 'BaseItem' on the form load event the customize dialog does NOT pick this up.
I wondered if there is a command I can call to tell the ribbon bar to redefine itself?
or if I have to redefine the ribbon bar entirely?
I have tried calling RecalcLayout as beloww
BaseItem.CanCustomize = false
RibbonBar.RecalcLayout()
but it does not work.
Hi have figured out what works for this.
BaseItem.visible = false
this will stop it from being shown on the QAT, but it will still be visible on the customize menu, i still want to stop some of these being shown, but have NOT figured that out yet.

Tab Control tab will only use Wait Cursor

So, I'm making a game in C#, and I've created a window to handle custom controls schemes.
On this page there is a tab Control, with three tabs: Scheme 1, Scheme 2, and Custom
Scheme 1 and 2 are perfectly fine, but on the Custom tab, whenever the mouse hovers over it, it displays the wait cursor. The controls inside the tab work perfectly fine and without lag, but it just always displays the waitcursor.
I can't change the cursor property in the Design window (it just goes back to waitCursor), and I've tried changing it in code, but it won't work.
Please check the following property in your tab control and each tab:
UseWaitCursor set to true
If UseWaitCursor = true for a parent control then it will propagate this property to all child controls. I think this is probably your issue. Please see the link below for an explanation of the property:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.usewaitcursor.aspx

WPF Ribbon collapse and expand programmatically

With the latest (October 2010) WPF Ribbon libraries, there exists a menu item to minimize/maximize (or collapse/expand, if you prefer) the ribbon control.
Does anyone know if there's also a way to hook into the events that control this behaviour so that it could be controlled programmatically from separate UI?
Or, better yet, is there a way to get a collapse/expand button to display in the ribbon like the 2010 Office apps do?
You can use the boolean property IsMinimized on the Ribbon class to show/hide the ribbon itself. It is a dependency property, so you can bind to its value to support the scenarios you describe.
As far as I know, the default template does not have a show/hide button, like Office does, but it shouldn't be too hard to modify the template (using Blend) to add one.
If what you need is know when the bar gets minimized (this happens when you double click a tab header) you could hook to the IsMinimizedChanged event, but er.. it is missing.
Hopefully it is a DependencyProperty so you can successfully hook to any DependencyProperty change this way:
DependencyPropertyDescriptor.FromProperty(Ribbon.IsMinimizedProperty, typeof(Ribbon))
.AddValueChanged(ribbon, (o, args) => /* your code here */);
What I wanted to do (and hence got here) is to prevent it from minimizing when double clicking the header so I ended up using this code:
DependencyPropertyDescriptor.FromProperty(Ribbon.IsMinimizedProperty, typeof(Ribbon))
.AddValueChanged(ribbon, (o, args) => ribbon.IsMinimized = false);
Is not so fancy but gets the job done.
Add a toggle button(simple button and set its content to v or ^ depending upon the operation requested) and then you can use ContentControl in button click to fulfill your requirement:
ContentControl contentControl = FindVisualChildataBankyName<ContentControl>(rbnName, "mainItemsPresenterHost");
contentControl.Visibility = System.Windows.Visibility.Collapsed;
Use contentControl.Visibility = System.Windows.Visibility.Visible; in order to maximize the ribbon

Categories

Resources