how can i migrate or cast the CommanBar control to new VSTO controls? - custom-controls

I want to pass the control for the new VSTO button click.
I want to migrate this to new VSTO ribbon click. How can I do this?
I am using the ribbon.xml where i have added a onAction event
onAction="Ribbon3_Click"
public bool Ribbon3_Click(Office.IRibbonControl control)
{
xsComp.myRibbon3_Click();
return true;
}
and the method I am calling is
public void myRibbon3_Click(Core.CommandBarButton Ctrl, ref bool CancelDefault)
It is hitting the error to pass the argument. How can I do this?
I am using .net c# 4.0 VSTO addin for Office 2010.

Seems you have some problems with arguments. I checked my ribbon button handlers and they have a signature like this:
private void Button_OnClick(object sender, IRibbonControl control, bool pressed)
Yours only accepts the IRibbonControl. And when you call your myRibbon3_Click, you call it with no arguments while the signature tells you need to pass it two arguments.

Related

How to execute JS Code when Outlook is started with Web Add Ins?

I want to make a async request to my server every time a user of my plugin starts outlook (or at least before they open an email).
I have a web Add In with a function file. This file is called whenever a user press a button for this addin. The function file is only loaded after a button (of my plugin) press.
Try this:
// This function is called when Office.js is ready to start your Add-in
Office.initialize = function ()
{
$(document).ready(function ()
{
//call your function here
This is not possible with WebAddIns as the Outlook Add-Ins Teams said in the comments under the question.
One solution is to create a VSTO AddIn and make the request there.

Outlook VSTO form does not display in release version (installed)

Thanks for looking.
I am working on an Outlook plugin that includes a pop-up Form that loads a browser inside of it to allow the user to log in via a 3rd party auth service.
This works great when running from a debug session: I see the custom tab in the ribbon, click the "login" button, and the form pops up as a modal using .ShowDialog().
I am using Outlook 2016.
Problem
When I publish this VSTO and then install it on my machine, the plugin loads and I can see the "login" button in the custom ribbon tab, but clicking it does nothing. I have checked to be sure that the dialog isn't simply popping under the main form. If it's there--I can't find it.
Back to debug session--everything works great. I suspect a permissions issue, but I don't get any prompts or errors from Outlook.
Last, I don't know if it's related, but I sent the VSTO installer to a colleague and they get the following error when attempting to install:
System.Security.SecurityException: Customized functionality in this
application will not work because the certificate used to sign the
deployment manifest for {APP NAME REMOVED} or its location is not
trusted. Contact your administrator for further assistance.
Any help is greatly appreciated.
Most probably your form is shown behind the Outlook window. You need to specify the parent window handle if you want to see the form all the time on top of Outlook windows. The Show and ShowDialog methods of the System.Windows.Forms.Form class allows to specify the parent window handle by passing an instance of the IWin32Window interface as a parameter.
First, you need a class which implements that interface:
public class WindowWrapper : System.Windows.Forms.IWin32Window
{
public WindowWrapper(IntPtr handle)
{
_hwnd = handle;
}
public IntPtr Handle
{
get
{
return _hwnd;
}
}
private IntPtr _hwnd;
}
In Outlook you can cast an instance of the Explorer or Inspector class to the IOleWindow interface and get the window handle which can be used for the IWin32Window implementation.

Getting AppID for Windows Phone in Unity3d

I am developing game for windows phone in unity3d, I have inserted Rate me button in game but on run time in windows phone it didn't work, is there any method to access AppID for the current application running in windows phone developed in Unity3d. I need code in unity3d CSharp for getting AppID.
I tried this C# code in Unity but It didn't work and having error no keywork found windows.
string appId = Windows.ApplicationModel.Store.CurrentApp.AppId.ToString();
LinkUri = new Uri("http://www.windowsphone.com/s?appid=" + appId, UriKind.Absolute)
Here I needed AppID to complete my link for rate me.
As far as i know Unity can not access the Windows namespace but you can make use of EventHandler to call 'Review Task' from Unity. You can do this by following below steps(visit Unity Expert for detailed explanation).
In Unity Game Engine-
Create Event -
using UnityEngine;
using System;
public static class events
{
//Create a new event
public static event EventHandler RateUs;
public static void FireRateUs()
{
Debug.Log ("Opening Rate Task......");
//If event is subscribed than fire it
if(RateUs!=null)
RateUs(null,null);
}
}
Fire Event -
using UnityEngine;
public class RateUs : MonoBehaviour
{
void OnMouseDown()
{
events.FireRateUs();
}
}
In Visual Studio IDE
Subscribe Event -
public MainPage()
{
.
.
.
.
events.RateUs += events_RateUs;
}
Call Function -
void events_RateUs(object sender, EventArgs e)
{
String AppId = Windows.ApplicationModel.Store.CurrentApp.AppId.ToString();
Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store:reviewapp?appid=" + AppId));
}
You have to get your AppID from your developer's portal on Microsoft Create's web page. You can then hardcode it into your app or save it as a static/globally available variable for accessing purposes. This would mean you would have to begin the process of creating your app entry prior to the programming of the rating game feature. Just create the entry, and don't submit it! Or create it, and add Rate app as an update. I'd choose the former method, personally!
For Apple and Google rating/submit information you have to create the entry ahead of time to get a SKU number. Also in iTunes/Apple/iOS/OSX you have to create the app and give it a unique name, etc in the developer's portal/certificate store.

Scrolling WebBrowser control on Windows phone 7

I want to scroll down or up in the webbrowser control on the windows phone 7 using code behind (no javascript). i mean like using some button to scroll down for example. is that possible?
EDIT:
I tried to call a javascript function using InvokeScript, but it keeps giving me an unknown error 80020006. i tried to do this:
public MainPage()
{
InitializeComponent();
webBrowser1.Navigate(new Uri("http://www.msn.com"));
}
private void button1_Click(object sender, RoutedEventArgs e)
{
webBrowser1.InvokeScript("window.scrollBy(100,100);");
}
something wrong in my code?
There is no way to interact with the scrolling of the page inside a WebBrowser control from outside of it.
In terms of doing it with JavaScript look at windows.scrollBy()
update
Try webBrowser1.InvokeScript("eval", "window.scrollBy(100,100);");
But be aware that the page you're viewing may have overridden eval which coudl prevent this from running.
Note that the WebBrowser control was not intended to be used to view websites directly.
Also, have you tried calling scrollBy directly from within your own page?

Ready event in Microsoft Outlook 2010?

Is there an event in Microsoft Outlook 2010 which one can subscribe on, in order to known when Outlook has finished initializing and all components, folders etc. have been loaded?
Not sure about VSTO but good ol' COM addins get the StartupComplete "event" (via IDTExtensibility2) for exactly that purpose.
Ok, I found out what I needed to do...
...
private void ThisAddInStartup(object sender, EventArgs e)
{
this.Application.Startup += ApplicationStartup;
this.Application.ItemLoad += ApplicationItemLoad;
}
void ApplicationItemLoad(object Item)
{
//Do something
}
private void ApplicationStartup()
{
//Do something
}
...
http://msdn.microsoft.com/en-us/library/ff869298.aspx
Not that I'm aware of. Usually, addins don't do anything that requires talking with many outlook objects till some triggering event happens (like opening a mail, or creating a new inspector) so THAT'S when you'd typically see some custom code hooked in.
In my addins, the code connected to startup does things like load up some config, and maybe connect to a DB (although even that I tend to do on demand vs once at startup).

Resources