Notification icon and balloon messages in c# cross-platform - c#

I'm going to develop a desktop application which is a sort of background service listening for events. The requirements for this application are:
tray icon in background always visible
show up notifications on desktop when an event occurs (like receive an email such as, you will notify with a popup)
The main problem is that the application must run under Windows,Mac and Linux.
I decided to develop the main business logic in .NET Core, but I have a few problems about the front-end part; using Windows.Forms.NotifyIcon it's easy, but obviously this solution isn't valid for other platforms.
So, I found GtkSharp project, in particular the StatusIcon object seems to do exactly what I need, except for the notification part. What I need is a sort of balloon info which is already part of Windows.Forms.NotifyIcon, but not in Gtk. Does anyone know if there is a library or a component that allow me to achieve my requirements for a cross-platform context?
[UPDATE]
I asked directly in GtkSharp channel and they told me that is not possible do what I need with GtkSharp (moreover StatusIcon is deprecated and removed from GTK 4).
I found another interesting possible way, seems that Electron framework support all my requirements. Is a different approch, but it covers all what I need and works well on MacOs,Windows and Linux.

Related

Display a message box in a cross-platform manor

For background, I am currently writing an OpenTK app that should show a message box if an error occurs. Usually on Windows-only apps this is easily done with Winforms, but I would like this to work on not just Windows, but Linux and Mac as well. So far, my search for potential solutions has not turned up anything useful to my use case.
I'd prefer to stay away from full UI libraries if possible as to make my app as light as possible. I just want it to use the system-native message box.
Are there any existing libraries that can do this? If there aren't, then how could I go about writing my own implementation, if possible?

DwmRegisterThumbnail for UWP app

I'm working on a UWP app that provides task-switching capabilities for users with complex physical limitations. This question is related to trying to provide the live thumbnails like alt-tab and the taskbar do. So far, much of the functionality has been made possible through an in-process full-trust component making the necessary (winapi) calls and passing information back to the UWP app.
I made a test WPF app utilizing DwmRegisterThumbnail and DwmUpdateThumbnailProperties and it works fine.
However, when I attempt to implement this in the UWP/full-trust app, registration fails with E_INVALIDARG. According to MSDN, this can be because the source or destination windows are not top-level windows. In this case, the destination window is the window handle for the UWP app, and the source window is explorer.exe (file explorer, in this case). Both are enumerated by EnumWindows and aren't children of other windows.
Is the problem that the full-trust side is calling DwmRegisterThumbnail? I tried making the calls from the UWP side as well, but got the same result. I wouldn't really expect to be able to make those calls from the UWP side anyway, since it would seem to violate the sandboxed nature of it. Is there any way to do this?
Edit:
I tried doing a C++ UWP proof-of-concept, but couldn't reference anything DWM-related. Then I found this. Looks like DWM isn't available at all to UWP.
I'm guessing the full-trust component can't register the UWP app to be drawn to because, according to this:
The window designated by hwndDestination must either be the desktop
window itself or be owned by the process that is calling
DwmRegisterThumbnail. This is required to prevent applications from
affecting the content of other applications.
As stated above, I tried having the full-trust component call DwmRegisterThumbnail, using the handle of the host UWP app, but it doesn't appear to work, presumably because it isn't owned by the UWP process?
Does anyone know of alternative methods that could be used to accomplish a thumbnail/window preview?

How can I write windows 7 desktop gadgets using c# & WPF?

I want to write a desktop gadget that will group icons on my desktop (using c# & WPF).
It will be a docked window that I can drag icons to it and they will stay their. Also there can be couple of this windows.
Where do I begin?
**I saw all the post here about it but I got lost. Please direct me to examples and explanation pages.
To expand on cevik's answer:
You cannot create WPF applications as gadgets BUT you have two options (which aren't as bad as you'd expect).
The reason is that widgets are composed mainly of web pages (HTML) and not executable (*.exe).
The problem of course is that WPF will only work with & produce executables.
First option - Windows API:
When I said you can't what I really meant is you can't use the Windows Vista/7 gadget platform to make your widgets.
However, you can always achieve a similar effect by using the Windows API.
The Windows API will let you do stuff to windows such as making them always on the background of other programs, which sounds to me like ~80% there (The rest would be stuff like making sure your window doesn't get re-sized or minimized, etc.).
Just as a note, the function you'd be looking for to make the window behind all other windows would be SetWindowPos (specifically the second parameter).
However make sure there isn't a library which already implements these stuff because it can be rather difficult (and consist of A LOT of surprises).
Second option - Silverlight
silverlight can be perceived as WPF for the web.
That obviously solves our problem.
However there is a cost to it, as expected.
Silverlight doesn't have all the features WPF has (possibly not all of the .NET framework as-well, not sure about that as I'm not really using it).
However it should be more than enough to get you by so you should definitely check it out.
Once you have your Silverlight application (and webpage) you'll have to create a manifest & install the gadget to your desktop. See here how to do so.
Maybe this will help you.
Template to easily get started on developing a Sideber Gadget using Silverlight 3.0 or 4.0 controls in C#.

I'm developing a simple cross platform system tray application. Here are the requirements, which tools should I use?

I hope you can help!
In brief, what I need is something like a cross platform web browser, with little or no chrome, that is easily distributable and allows the (local and remote) HTML pages running in it to receive messages (JavaScript?) when system global hotkeys are pressed.
I'm developing a desktop application which will utilise an existing web-based REST API. I would like this app to be cross-platform (Windows, Mac OS and Linux) and have a consistent interface across all platforms. The app runs in the system tray and uses global hotkeys for convenient access to a lot of it's functions without having to open the main UI window.
I have already written a rough initial version of the app using C#/Windows Forms, but there are a few issues. It currently uses unmanaged Win32 code to provide support for global hotkeys, which is not cross-platform even if I ported it to Mono. Plus, it's really not very pretty...
Ideally, I'd like to build the UI using traditional web technologies like XHTML/CSS and use JavaScript/AJAX to communicate with the remote API, which is why I thought Adobe AIR would be a good solution—but unfortunately it still doesn't support global hotkeys. I've also looked at XULRunner but I'm not sure I properly understand what that's intended for.
So the basic requirements for whichever combination of tools I will use are:
Allow me to create the user interface in XHTML/CSS/JavaScript
JavaScript to remotely communicate with the web API via AJAX
Allow the app to show—and be accessible via—a tray icon (in whatever OS it's running on)
Allow the app to respond to global hotkeys (again, in whatever OS it's running on)
Does anyone have any advice for me on this? I'm open to any suggestions and examples, no matter the language or tool.
Edit: I just stumbled across Nokia's Qt Toolkit, does anyone have any experience with this?
I think AIR application is a good solution. For the global hotkeys there are some "alternatives" Can I assign a global hotkey to an Adobe AIR app?

Making a Background Service Somewhat Like Apple's Spotlight in VIsual Studio C#

I am about to start working on an application that runs in the background waiting for a certain user input somewhat like apple's spotlight.
Basically the user will give the service a certain key combination that will bring it up (i.e. CTRL + Space or CTRL + p) and the application main GUI will be brought up.
Now my questions:
First, I want this application to have a very small footprint and not draw on many system resources, and not interfere with the operation of other applications.
I also would like to write this application in C#. So far the best idea I have had would be to write a service that listened for key strokes and threw away stroke that were not either the control or following a control key.
This does not seem optimal is there a better way, anyone know how spotlight works?
Second, I am concerned that this kind of service might be identified as mall ware.
What steps might I take to ensure that my software is not targeted by applications such as Avast and Spysweeper?
Would I need to contact all of the manufacturers of these software packages and explain the purpose of my application?
Finally, if anyone could link to resources about how to set up such a service I would greatly appreciate it.
Services are not supposed to interact with the desktop user, as such they aren't supposed to be able to hook and watch for keystrokes. This may work on XP but you will likely have many problems on Vista/7 and later OS's.
You really need a userspace program that runs at user startup to do this that runs as the same user as the logged in user.
Also, if you are concerned about minimal footprint and resource usage, you don't want to be using .NET because it needs to load a fairly large runtime library and creates a fairly big working set. Usually this isn't a problem, but for something like a watcher program, it's best to write it in low footprint C using a low footbring minimal CRT startup.
My suggestion would be to create a winforms application, add the system tray icon using NotificationIcon to the main form of the application. Then hide the main form. The application can receive key strokes, particularly if you set the FormsPreview property to true. You might also need to hook into the windows api keypress events.
You should be safe from Malware scanners.
You may want to take a look at this link for setting up a system tray/win forms app.
How can I make a .NET Windows Forms application that only runs in the System Tray?

Categories