Differentiate between Calendar and Emails backstage

Add-in Express™ Support Service
That's what is more important than anything else

Differentiate between Calendar and Emails backstage
 
Rob Blackin




Posts: 68
Joined: 2016-02-20
I currently override the backstage idMSO=TabPrint with my own tab.
However, I want the original, normal print tab to be visible when Calendar is selected so the user can print week, month, etc calendars.

I ran into an issue where the Ribbon seems to be same (OutlookExplorer) and therefore I get my replaced tab for Emails and Calendars.

Is there a way to differentiate and show my replaced tab when looking at emails and the original one when looking at Calendars?

thanks,
Rob
Posted 20 Aug, 2016 22:45:44 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Rob,

Retrieve Explorer.CurrentFolder and check MAPIFolder.DefaultItemType (of the Outlook.OlItemType type).


Andrei Smolin
Add-in Express Team Leader
Posted 22 Aug, 2016 03:55:08 Top
Rob Blackin




Posts: 68
Joined: 2016-02-20
but I cannot toggle backstage items visible and no visible except in the initialize, correct? Otherwise it has no effect.

adxBackstagePrint.Visible
Posted 22 Aug, 2016 07:13:01 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Rob,

Use the PropertyChanging event that every Ribbon component provides. See also section Updating ribbon controls at run time at https://www.add-in-express.com/docs/net-ribbon-components.php#properties-events


Andrei Smolin
Add-in Express Team Leader
Posted 22 Aug, 2016 07:58:48 Top
Rob Blackin




Posts: 68
Joined: 2016-02-20
Doesnt seem to be working.

I have two Tabs on the Backstage control. I have both tabs (ADXBackstageTab) in the control. One has he IdMSo=TabPrint and one does not. I want to hide the custom one is it is calendar and show the original one (has IdMso set)
If mail I want the opposite.

This seems to get and set the right values but then in the File menu, they do not show as expected. Sometimes both are hidden and that cant happen with this code. I am testing with 2013 and 2016.

private void adxBackstagePrint_PropertyChanging(object sender, ADXRibbonPropertyChangingEventArgs e)
{
if (e.PropertyType == ADXRibbonControlPropertyType.Visible)
{
var omApp = CurrentInstance.OutlookApp;
if (omApp == null) return;

var expl = omApp.ActiveExplorer();
if (expl != null)
{

var isCalendar = (expl.CurrentFolder.DefaultItemType == Outlook2.OlItemType.olAppointmentItem);
if (string.IsNullOrEmpty(((ADXBackstageTab) sender).IdMso)) //BackstagePrint
{
adxBackstageTabPrint.Visible = isCalendar;
e.Value = !isCalendar;
}
else
{
adxBackstagePrint.Visible = !isCalendar;
e.Value = isCalendar;
}

}

}
}
Posted 22 Aug, 2016 10:45:32 Top
Rob Blackin




Posts: 68
Joined: 2016-02-20
Im thinking that what I want do is not possible.

Seems that once you set the BackstageTab to visible or not visible, it cannot be changed at run-time. Is this the case?
Posted 22 Aug, 2016 11:40:56 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Rob,

The approach below works on custom tabs. On a built-in BackstageView tab, the Ribbon API doesn't allow modifying the tab's properties on the fly: if I specify a callback such as getEnabled="getEnabled_Callback" or getVisible="getVisible_Callback" in the Ribbon XML, I get this error:

Call back functions cannot be specified on built-in controls. Control ID: "TabPrint"

private void adxOutlookAppEvents1_ExplorerFolderSwitch(object sender, object explorer)
{
    Outlook.Explorer theExplorer = explorer as Outlook.Explorer;
    if (theExplorer != null)
    {
        bool isCalendar = (theExplorer.CurrentFolder.DefaultItemType == Outlook.OlItemType.olAppointmentItem);
        bool isEmail = (theExplorer.CurrentFolder.DefaultItemType == Outlook.OlItemType.olMailItem);
        adxBackstageTab1.Enabled = isCalendar;
        adxBackstageTab2.Enabled = isEmail;
    }
}



Andrei Smolin
Add-in Express Team Leader
Posted 23 Aug, 2016 03:59:18 Top
Rob Blackin




Posts: 68
Joined: 2016-02-20
Is there a workaround to be able to hide or unhide the Built-in Backstage tab? I really need to be able allow or disallow the standard printing function based on the user action.

thanks,

Rob
Posted 23 Aug, 2016 15:10:05 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Rob,

You could hide the built-in Print tab and try to emulate it. Unfortunately, some or all control types that they use on that tab aren't available for developers. Specifically, you can't create the print preview area.


Andrei Smolin
Add-in Express Team Leader
Posted 24 Aug, 2016 01:20:22 Top