Open Office Communicator Session from C# - c#

I am working on a WPF application and I wish to open sip:Username#company.com links. I am able to open mailto links using the following code:
private void btnSendEmail_Click(object sender, RoutedEventArgs e)
{
try
{
string mailURL = String.Format("mailto:{0}", UserDetails.EmailAddress);
Process.Start(mailURL);
Close();
}
catch
{
// Handle exception
}
}
Although, I am unable to open sip: links in a similar way. What I am trying to achieve is to open a new chat session with a user, like I am able to do when I follow sip: links from Outlook.
Any ideas?
Edit: I ended up using the CommunicatorAPI. Messenger.InstantMessage() seems to work for me. More info here: http://msdn.microsoft.com/en-us/library/bb787232.aspx

Using Process.Start works fine on my system (with Microsoft Lync 2010, a newer version of Communicator):
void Main()
{
Process.Start("sip:username#company.com");
}
Running the above code results in a new chat window opening. The only exception is when I enter my own user name, in which it starts composing a new Outlook e-mail message to myself. What happens when you use this (maybe also try omitting the following call to Close).

You probably need to associate a program with the "sip" uri scheme. Try this: how do I create my own URL protocol? (e.g. so://...)

if you have Lync or Office Communicator installed, they should respond appropriately to the sip: uri scheme. Also, tel:, callto: etc. For reference, the full list is here.
Is this not working for you from a WPF app? Does it work for you from a basic html page?

I ended up using the CommunicatorAPI. Messenger.InstantMessage() seems to work for me. More info here: http://msdn.microsoft.com/en-us/library/bb787232.aspx

The following code probably didn't work for you because you were trying to IM yourself.
Process.Start("sip:username#company.com");

Related

Can't connect a midi output device to .net MAUI using DryWetMidi

I am using the library DryWetMIDI for .net 7 and I am trying to connect a MIDI output device to MAUI. When I connect a input device it seems to work fine but the only output from the outputdevice I could get was the following error: Internal error (OUT_SENDSHORTRESULT_INVALIDHANDLE). When I tried everything in a simple console application it works perfectly.
Also because of my lack in experience in Maui I don’t really know if I should change something in the project dependencies or in the builder. Or maybe declare the MIDI in the App or the Appshell...
So I tried to create a input device and a output device and connect them to eachother (This is what the DryWetMIDI suggested). Next I try to get the events from the input and the outup device, the input device works but the output device doesnt.
I use the following code where the ouput device doesnt work in Maui:
private InputDevice inputDevice;
private OutputDevice outputDevice;
private DevicesConnector devicesConnector;
void ConnectMidi()
{
//create input device
inputDevice = InputDevice.GetByName("Keystation Mini 32");
inputDevice.EventReceived += OnEventReceived;
//create ouput device;
outputDevice = OutputDevice.GetByName("Microsoft GS Wavetable Synth");
outputDevice.EventSent += OnEventSent;
//connect them
devicesConnector = inputDevice.Connect(outputDevice);
inputDevice.StartEventsListening();
}
public void OnEventReceived(object sender, MidiEventReceivedEventArgs e)
{
var midiDevice = (MidiDevice)sender;
Debug.WriteLine("This gets called when a key is pressed") ;
}
public void OnEventSent(object sender, MidiEventReceivedEventArgs e)
{
var midiDevice = (MidiDevice)sender;
Debug.WriteLine("This gets never called");
}
If there is anohter solution using a diffrent library or something else I would love to hear it!
Hopefully this makes my problem clear and thanks in advance.
(This is also my first post so feedback would also be nice)
I'm the author of the DryWetMIDI. I've analyzed the problem:
The bug is not with the library, it's a MAUI related one.
The error comes from midiOutOpen system Windows function which fails for Microsoft GS Wavetable Synth in a MAUI project but works for any other project types.
I've reported the bug in MAUI repo: https://github.com/dotnet/maui/issues/12368. So what we have is to wait for response from Microsoft.
Update:
The bug has been moved to WinUI repo: https://github.com/microsoft/microsoft-ui-xaml/issues/8055. Also you can mark your project as Unpackaged and the issue should go away.

Reflections for ReGIS graphics screen scraping in C# .NET API

I'm trying to create a windows forms application that can scrub screen information from a Reflections window. The problem is that it's an older version of reflections from back when WRQ still owned the app. Since Attachmate have taken it over, I can't find any documentation on the .net API related to this older version.
What I have so far is this:
private void button1_Click(object sender, EventArgs e)
{
openApp();
}
private void openApp()
{
// Create a new instance of Reflection.
Reflection4.Session reflection = new Reflection4.Session();
reflection.Visible = true;
}
So this is fine for opening a new Reflections window, but I want it to run the screen scrape on a window that is already open.
Below is a way to get the first active Reflection4.Session using Marshal.GetActiveObject(). I found the progid for Reflection4 using the ProgID Key website on MSDN. With that I found that the following code works:
Reflection4.Session session = (Marshal.GetActiveObject("Reflection4.Session.8") as Reflection4.Session);

Hyperlink to a local file doesn't work

I need to add 2 type of links to existing report with c#. For exapmle:
1) http://www.google.co.il/
2) file:///C:/index.html
I added the links, but only the "http://" works. when I press the link of "file:///" nothing happens.
I've uploaded the full project (very small though) which includes the problem:
http://www.filefactory.com/file/452gsoyymalv/n/ObjectReports.zip
BTW, the "index.html" is a simple 'helloWorld' which loaded successfully when writing the path on the address bar in the browser.
Do anyone knows what additional settings should be set to make the file link work?
*Credit for the sample (without my case):
http://www.c-sharpcorner.com/uploadfile/mahesh/reportviewerobject04172007111636am/reportviewerobject.aspx
AFAIK this is disabled for security reasons - the ReportViewer is NOT a complete browser...
You can try to circumvent that limitation by handling ReportViewer.Hyperlink event yourself... can't try it myself right now, but that's about the only option that can possibly work IMHO...
This is the detailed solution (main idea suggested by #Yahia):
First, I created the event handler:
public void HyperLinkReportHandler(Object sender, HyperlinkEventArgs e)
{
Process.Start(e.Hyperlink);
}
Second, I associated the event handler:
this.rvContainer.Hyperlink += HyperLinkReportHandler;

Windows 8 C# Store app - Link to store and reviews

We are about to submit a game for Windows 8 with two versions:
An ad-supported free version with 3 levels
The full game
So on the ad-supported version, we need a button to link to the store for the full version.
In both versions, we also would like to place a button to link to the store to review each app.
How are these two scenarios handled in Windows 8?
Thanks to the lovely folks who created Physamajig not only working this out, but also sharing the information on their blog! Here's how you can link directly to your Review page:
Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store:REVIEW?PFN=MY_PACKAGE_FAMILY_NAME"));
Replacing MY_PACKAGE_FAMILY_NAME with the one from your package manifest.
See full details: http://andybeaulieu.com/Home/tabid/67/EntryID/227/Default.aspx
var storeURI = new Uri("ms-windows-store:PDP?PFN=<Your package family name from the manifest>");
await Windows.System.Launcher.LaunchUriAsync(storeURI);
should do the trick.
We asked about linking directly to the review page at an AEL today. The link to Rate and Review in the settings charm is added automatically once your app is in the store. No coding required.
You can directly use below code in click event:
MarketplaceReviewTask marketplaceReviewTask = new MarketplaceReviewTask();
marketplaceReviewTask.Show();
You will need to add
using Microsoft.Phone.Tasks;
also.
Use this:-
private async void Rate_Click(object sender, RoutedEventArgs e)
{
String pfn = Package.Current.Id.FamilyName;
await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store:REVIEW?PFN=" + pfn + ""));
}
You can find detailed solution here.

Silverlight 2 - Download file - IE Blocks file download

I'm having a problem with IE only in my Silverlight application. Since Silverlight 2 doesn't include a mechanism for file downloads I was left to my own devices to come up with a solution. The way I did it was as follows:
HtmlPage.Window.Navigate(new Uri(sb.ToString(), UriKind.Relative));
My StringBuilder contains the relative url with query string to a *.ashx handler on the server that reads the query string, gets some data from the database, and returns an Excel file.
When I do this I get a blocked file download bar in IE only. I understand that this is a new security "feature" in IE and that it is being blocked because it believes that the download wasn't triggered by the user interaction with the web page. The users can choose to allow the download and that setting seems to be remembered for the rest of the session. However next time they open the page it happens again. Even if the site is in the Trusted zone and even if the popup blocker is configured to allow popups for the site.
Does anyone know how to make IE know that the user did in fact request this file?
I had exactly the same problem. The solution for me was to not use HtmlPage.Window.Navigate, but to instead use a HyperlinkButton and dynamically set the NavigateUri property.
Saving and restoring the app state as suggested above didn't work. Well, it did, but it was impossible to determine when it needed to be done and when it didn't. So, ultimately, it didn't really work.
See this discussion on codeplex....
http://slideshow2.codeplex.com/Thread/View.aspx?ThreadId=60242
Try HtmlPage.PopupWindow instead of HtmlPage.Window.Navigate. This has helped me get around IE's "Automatic prompting for file downloads" setting being disabled by default for Internet zone sites.
This is my code solution to open URL for download and override Automatic prompting for file downloads option issue in IE 8.
It also use HyperlinkButton, but all is called from code:
public class BrowserHelper
{
private sealed class HyperlinkButtonCaller : HyperlinkButton
{
public static void OpenUrl(Uri url)
{
var button = new HyperlinkButtonCaller()
{
NavigateUri = url
};
button.OnClick();
}
}
public static void OpenUrl(Uri url)
{
if (url == null)
{
throw new ArgumentNullException("url");
}
HyperlinkButtonCaller.OpenUrl(url);
}
}
BrowserHelper.OpenUrl(new Uri(ClientGlobalInfo.Current.ApplicationUrl, "myhandler.ashx"));
In my case only happended the first time (using IE 7), maybe that happens on your local dev instance?
I think there's not much you can do, even MSDN pages tells you that "a message will appear on top of...", things that could mitigate this:
Warn the user that the message will be shown, then once he clicks the app is reset (Store the current app state in the isolated storage, when you receive the reset reload the app with the settings).
Open a popup, and in the popup include and standard HTML button to download.
HTH
Braulio

Categories

Resources