Form Regions for Outlook and VSTO remove WebViewPane - c#

I have just purchased: http://www.add-in-express.com/outlook-regions/
The reason why I have purchased that product is because I need to show a custom form on the main view of outlook when a specific folder is selected. I have managed to do so by doing the following:
Create a new Project int visual studio of type (Outlook 2010 Add-in)
Once that project is created I add:
Because I want that form to show on the main folder view of mail (replace all other views) I select this option:
I click next and follow all the defaults in order to create the form.
Once that form is created I add the buttons and images I need. In this example I will just add a button.
when I then run outlook and select my inbox folder this is what shows up:
(In other words every time I select a folder of type olMailItem that form shows up)
So now I solve my goal to display my custom form on the "main view of outlook"
Now my question is how can I show that form only on specific folders. For example I do not want to show that form when the folder "Inbox" is selected but I do want to show it when the folder "Outbox" is selected for example
Let's try to hide the form and show the default view when the button is clicked.
In order to solve that problem I have looked at: http://www.add-in-express.com/forum/read.php?FID=5&TID=4540
I have done the same steps but the form shows up again! In other words the code behind of the button looks like:
private void button1_Click(object sender, EventArgs e)
{
// get current folder in this case its inbox the one that is selected
MAPIFolder currentFolder = Globals.ThisAddIn.Application.ActiveExplorer().CurrentFolder;
Globals.ThisAddIn.ADXOlForm1Item.FolderName = string.Empty;
// clear web properties DO NOT SHOW WEB VIEW
currentFolder.WebViewURL = string.Empty;
currentFolder.WebViewOn = false;
// RESET FOLDER BY SELECTING A DIFFERENT ONE THEN THE SAME ONE
NameSpace nameSpace = Globals.ThisAddIn.Application.GetNamespace("MAPI");
MAPIFolder outboxFolder = nameSpace.GetDefaultFolder(OlDefaultFolders.olFolderOutbox);
Globals.ThisAddIn.Application.ActiveExplorer().CurrentFolder = outboxFolder; // CHANGE FOLDER TO A DIFFERNT ONE
System.Windows.Forms.Application.DoEvents();
Globals.ThisAddIn.Application.ActiveExplorer().CurrentFolder = currentFolder; // SET INBOX AGAIN
}
when I run that code the default view shows up for 1 second then it get's replaced with the form!
-------------------------------------------Edit-------------------------------------------
When I add the form region Addin Express adds a ADXOlFormsManager and a ADXOlFormsCollectionItem for the form that I created. Based on your answer I have done:
#region ADXOlForm1
// TODO: Use the ADXOlForm1Item properties to configure the region's location, appearance and behavior.
// See the "The UI Mechanics" chapter of the Add-in Express Developer's Guide for more information.
ADXOlForm1Item = new ADXOlFormsCollectionItem();
ADXOlForm1Item.FolderName = "MyCustomFolder"; // <---- ADDED THIS LINE HOPING TO SHOW THIS FORM ONLY WHEN THAT FOLDER IS SELECTED
ADXOlForm1Item.ExplorerLayout = ADXOlExplorerLayout.WebViewPane;
ADXOlForm1Item.ExplorerItemTypes = ADXOlExplorerItemTypes.olMailItem;
ADXOlForm1Item.UseOfficeThemeForBackground = true;
ADXOlForm1Item.FormClassName = typeof(ADXOlForm1).FullName;
this.FormsManager.Items.Add(ADXOlForm1Item);
#endregion
I was hoping for that form to only show up in MyCustomFolder but it does shows up when selecting any folder of type ADXOlExplorerItemTypes.olMailItem. Perhaps I am doing something wrong....
In other words I was hoping for only the MAPIFolder MyCustomFolder folder had the properties
WebViewOn=true;
WebViewURL = "...AppData\Local\Temp\AddinExpress\ADXOlFormGeneral.html"
but as I traverse all the folders in outlook I can see that all of them have those properties even after specifying ADXOlForm1Item.FolderName = "MyCustomFolder";

Thank you for choosing Add-in Express Regions.
I understand the "main view of outlook" as the folder that Outlook shows when it is started. By default, that folder is the top-level folder of the message store. Note that this can be changed, see File | Options | Advanced | Start Outlook in this folder. I use this setting so that my Outlook shows me the Inbox at start-up.
The below is a citation from the section Context-Sensitivity of Your Outlook Form, see see the PDF file in the folder {Add-in Express}\Docs\ on your development PC:
ADXOlFormsCollectionItem provides a number of properties that allow specifying the context settings for your form. Say, you can specify item types for which your form will be shown. Note that in case of explorer, the item types that you specify are compared with the default item type of the current folder. In addition, you can specify the names of the folders for which your form will be shown in the FolderName and FolderNames properties; these properties also work for Inspector windows – in this case, the parent folder of the Outlook item is checked. An example of the folder path is "\Personal Folders\Inbox".
A special value in FolderName is an asterisk ('*'), which means "all folders". You can also specify message class(es) for which your form will be shown. Note that all context-sensitivity properties of an ADXOlFormsCollectionItem are processed using the OR Boolean operation. That is, specifying e.g. folder names extends, but not limits, the list of contexts for which your form will be shown.
That is, if you need to show the form for a given folder, specify the path to that folder in the FolderName/*FolderNames* property.
Regards from Belarus (GMT+3),
Andrei Smolin, Add-in Express Team Leader

Related

How to use a config.ini file to change button attributes? (Windows Forms)

New to windows forms so please bear with me.
I have a simple application that displays a few buttons, and I'd like the attributes of these buttons to be set by the user using some kind of external config file e.g. config.ini.
In the config file, the attributes would be set out something like this:
[Button 1] //button identifier
isEnabled = True //show/hide the button
colour = "#FFFF" //button background colour
caption = "Button" //text to display on button
action = "Action" //action when button is clicked
The config file should be stored with the program executable, and when the program is launched, it will display the buttons and text defined in this file.
The action determines what happens when the button is clicked. This could either be opening a new page, or writing a string to a variable. The aim of the program is to allow users to navigate through a couple of menus, and then select a button which will print out the string.
Edit: if the action is to go to a new page, it will just say 'Next Page' so I guess I can just use an if/else for this. I.E.
if(string.Equals("Next Page"){
//go to next page
} else{
//save string to variable
}
I know how to set button attributes in the code, but I don't understand how I can read the config file. Its important that these attributes can be set from the external file so that the program can be easily configured without needing to rebuild it.

In Visual Studio how to access the source control history window programmatically?

I am developing a Visual Studio Extension. I need to access the Source Control's History window to check what history items are selected or not.
I've tried several methods including the findWindowPane() method and the activeWindow object, but none of them worked. (I didn't know all the parameters for findWindowPane() and the activeWindow doesn't have any info about specific tool window data)
Update
So I've checked the solution on this page: Show item history windows with TFS SDK
Unfortunately, when I'm trying to get the type of the history window, the result is null.
Type _dialogHistoryType;
Assembly tfsAssembly = typeof(Microsoft.TeamFoundation.VersionControl.Controls.LocalPathLinkBox).Assembly;
_dialogHistoryType = tfsAssembly.GetType("Microsoft.TeamFoundation.VersionControl.Controls.DialogHistory");
var historyWindow = package.FindToolWindow(_dialogHistoryType, 0, false);
My main goal is to get the selected history item's id from the history window during runtime.
Any suggestion, how to get the type?

Strange behaviour using resources in WPF application [duplicate]

I want to use localization in my project so I'm using ".resx" files.
I have two files "StringRes.resx" and "StringRes.fr.resx". As you can guess, I want that all the messages of my app change according to the CultureInfo of the user.
But when I do this :
public MainWindow()
{
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("fr");
InitializeComponent();
}
It doesn't change anything when I do :
Console.WriteLine(StringRes.FirstName);
Indeed, it's always the string in StringRes which is displayed and not the string from StringRes.fr
The both are in the same namespace.
Thank you for any help.
I have created my own test projected an I used "fr-FR" as a culture tag. The test project can be found on my skydrive.
Works perfect.
In short:
I set the culture in the Properties of the project to be en-US as that is what I would want my Resource.resx to be.
Then I created Resource.resx, Resource.fr-FR.resx and Resource.nl-NL.resx.
I filled them with the TestData string. And the created a window with 3 buttons with events hooked to them. Next to the buttons I created a textblock, the textblock is binded to a Text string field.
In the button events I change the culture and the Text field. And you can then see the change happen.
You first need to create your Resource.resx then in the same folder you need to create Resource.fr-FR.resx. The Resource.resx will get a codebehind file, all the cultured resource files should not. If your Resource.fr-FR.resx does have a culture file you did something wrong and it is best to delete that resources file and recreate it so it loses it's codebehind.

How to add readonly fields in outlook contact via plug-in

I have a requirement of adding certain read only fields(once created then it will not change) in existing contacts or while creating new contacts in Outlook through my vsto plug-in. I am able to add user defined fields using ItemProperty and UserProperty:
Outlook.ContactItem newContact = this.Application.CreateItem(Outlook.OlItemType.olContactItem) as Outlook.ContactItem;
Outlook.ItemProperty itemProp = newContact.ItemProperties.Add("PermanentID", Microsoft.Office.Interop.Outlook.OlUserPropertyType.olNumber, false, 1);
itemProp.Value = "123123";
newContact.Email1Address = "abc#d.com";
Outlook.UserProperty mailUserProperty = newContact.UserProperties.Add("ID1", Outlook.OlUserPropertyType.olNumber, false, 1);
mailUserProperty.Value = "123345456";
newContact.Save();
This does create fields in the Contact but they are not read only. Is there any way around to create read only fields or adding new properties to the contact item that can be shown within the Contact window?
Any suggestions?
No, sorry to say, but there is no way to prevent the user from editing the values of UserProperty objects.
They are exposed in Outlook and freely editable by the user or any other add-in.
The only possibility I see it creating a custom pane in VSTO, where you show the value of the field 'read-only', but that doesn't prevent the user from actually changing it.
You can add a user property instead. See the UserProperties property of the ContactItem class. To display them in the inspector window you can develop a form region. You are free to display the required information in the read-only way.
See How to: Add a Form Region to an Outlook Add-in Project to get started.

Visual C# 2008 Control to set a path

Greetings,
What control in Visual C# 2008 would allow me to set a path and get the value of that path.
For example:
I want the user to click a button then select a path where he/she would do the operation such as save a file in selected path.
You want to use a FolderBrowserDiaglog
var folderBrowserDiaglog = new FolderBrowserDiaglog();
if ( folderBrowserDiaglog.ShowDialog() == DialogResult.OK )
{
string path = folderBrowserDiaglog.SelectedPath;
}
I don't mean to repeat, but none of the other answers seemed to be exactly what you wanted.
There are 3 controls: FolderBrowserDialog, OpenFileDialog, and SaveFileDialog. There names are pretty intuitive. You use all 3 the same way. Tanascius has a good example in his post. The folder dialog you would use if you want the user to select a whole folder to look at. The open you would use if you want the user to select one or many files to open. Save is the same as open, but you would use it when saving a file out.
Hope this helps.
The FolderBrowse Dialog....
SaveFileDialog (for a file) or FolderBrowserDialog (for a folder). Located in the dialogs tab in the toolbox.
Assuming Windows Forms, try the OpenFileDialog. All common dialogs descend from CommonDialog, so looking at the descendents of that class may help, too.

Categories