The new Windows 7 taskbar features, like jump lists, previews, etc. are really cool, and I want to allow my C# applications to use them. I have two questions:
First of all, how can I use these functions (in general)? I found two articles by Microsoft about this, but I'm not really sure what to do. Could you provide links to a library, as well as some sample code?
Next, let's say that I figure out how to use these Taskbar functions. My question is, is there some built-in way of checking whether the OS is Windows 7, and thus enabling the taskbar functions? If I didn't have this logic in my app, would it have problems if it was run on a non-Win7 machine?
Thanks!
In the first article you link to there is a sample library that you can download that makes use of the new Windows 7 features.
This article shows how to check the version of Windows your application is running on.
As always, if you call an API that isn't in existence, then yes, your app will experience some turbulence. Remember, it's (almost) always better to check for a condition and act accordingly once (as in application startup) than to try something over and over in code and catch exceptions.
Windows API Code Pack for .NET Framework is your one stop shop for a ton of .NET API for Windows programming, including Taskbar. This library gives you a complete API set to work with Windows 7 Taskbar and then some. It also includes samples for WPF, and Winform.
Another good source for Windows 7 content is the Windows Team Blog
Related
Short backstory, I need to create an App for my computing coursework, and since I'm quite the procrastinator I wanted to make an app that shuts down processes that users waste time on.
Therefore I looked up how to make Windows 10 apps and stumbled across Microsoft's own "C# Fundamentals for Absolute Beginners" and "Windows 10 Development" for absolute beginners. I spent over 20 hours watching these videos over the past few weeks.
Now I have designed nearly all the UI in XAML over the past few days and now when working on the Code behind in c# I noticed that System.Diagnostics.Process could not be found, I tried to work out why and eventually stumbled across this answer which made my jaw drop (TLDR it's because it's a UWP app): Missing reference to System.Diagnostics.Process
I do not need my app to run on the Windows Store, all it needs to run on is my computer however messy the solution may be, but I really need access to that class to shutdown processes. I really want to make the app in C# and XAML though and I'm not sure if I can do this whilst having access to the System.Diagnostics.Process class.
I am really running out of time for this project and I can't just change my idea as the problem definition essay has already been marked, etc and that would take forever to rewrite.
I am open to the idea of just writing the application fully in C# if there's really no way I can use XAML without making a UWP app. But I'm not sure what's the easiest way of doing this/what project type so any help would be appreciated.
I feel very angry at Microsoft for not making it clear that "Windows 10 Development for absolute beginners is" actually "Windows Store Development for absolute beginners". I do not want my app on the Windows Store so if I could force reference the process class that would be great!
You need to develop a Desktop app (WPF). With WPF you also use C# and XAML, however you can use all .Net Framework.
UWP (Store apps) need to run in devices like Surface RT (Windows RT), Lumia 920 (Windows 10 Mobile), XBOX and Hololens so they use only a part of the full .Net Framework (they use the .Net Core Framework). UWPs run in a sandboxing so they usually don't have access to system APIs (low level access like create a IP package). In this case you should use WPF.
Your problem is one of the reason, I think that StackOverflow use the tag uwps and win-universal-app.
When I create new Windows Phone project I have an option to create a "Windows Phone" or "Windows Phone Silverlight" app. I know that they have different runtimes and different APIs.
I was under the impression that Microsoft wants to unify Windows and Windows Phone platforms so why is there even a Silverlight version? What benefits does it bring?
Also, if I want to create an app just for Windows Phone and never have plans to bring it to Windows, what should I choose, Silverlight or Windows Phone?
I'd suggest you go with "Windows Phone" (non-Silverlight). It's the new API, which works for both Windows and Windows Phone. At some point you may want to port the app or create a new one for Windows and you'll already know the API (and porting will be way easier). Also, the new API will most likely get more updates and features added, and at some point you may even be forced to update to it (either because the old one is no longer supported, or because it does not have some features that you need).
As it was said in the other answers - the Silverlight option is there only for backward compatibility and is likely to be phased out in time. That is - it's good if you already know the API and have many libraries (yours or others) for WP Silverlight, but if you're just starting - you'd better go for the new technology.
Edit
There is one other thing to consider before choosing between the two types of apps. Some features are only available in a Silverlight app, and others (smaller amount) - only in a Xaml app. Here's an article with some info on the differences: Migrating your Windows Phone 8 app to a Windows Runtime XAML app
Windows RT Xaml is quite new and People have to generate some knowledge first.
Silverlight for phone has been around for years and there's a load of tools available: Phone Toolkit, diverse Controls, etc.
Just killing it off would have hurt many developers who built up intellectual property over a long time forcing them to start over.
When starting a project with Silverlight you will have more things around that help you get stuff done.
When starting with WinRT Xaml, you will have better performance, but will have to figure a lot out by yourself.
So the Silverlight option is there to not throw of Silverlight developers.
I recently started a new project on WinRT Xaml and my experience was that I had to recreate a lot of common tools like Caches, etc. But also a lot of things that were in Toolkits previously are now part of the platform itself. Also, when moving over to Windows 8, you get to share a lot of code which is nice.
Unifying the environment(s) would be ideal. In my opinion, it hasn't been very successful. At one point in time, you could only develop under Silverlight, so what you are seeing is just a newer version of the same thing to keep backwards compatibility as well as to keep Silverlight's developers happy. In the future, it will probably be phased out. Plus if you want to support older Phones, Silverlight is basically your only choice (you'll be surprise, how many WP users haven't updated their 8.0 to 8.1)
There really isn't any other real benefit of Silverlight other than maybe the Windows Phone Toolkit which has been tremendously useful (you can see how many SO's answers rely on this simple addon). Once the universal runtime gets fleshed out to the point where the documentation reflects what's actually available -- then I think it would be the default project for developing in Windows going forward.
If you're just starting, I would use Silverlight the knowledge based is much greater. After you get use to the WP environment then switch to runtime.
I am trying to build a Windows 8 "metro-style" app that will operate as a "app killer". For those of you who have used Win8 (Tech Preview) you'll notice that once you open a metro-style app you cannot close it (without going into Task Manager and ending the process).
My challenge is that I cannot access 'System.Diagnostics.Process' from my metro-style app, nor do I know if there is an comparable alternative within the WinRT. I also thought of building a separate app that hosts a service for my metro app to interface with, but I'd like to do this with a single app.
Fundamentally, I am looking for a pattern for building Metro-style apps that leverage .NET 4.0 components, specifically to be able to enumerate and kill other processes running on the PC.
CLARIFICATION: I am less concerned with this specific application than I am with access that type of .NET functionality within a Metro-style app
Thanks
To your specific question, this functionality is not available. Apps are not allowed to interact or interfere with other apps.
To answer your more general question, the APIs available to Metro style applications is limited compared to what is available to desktop applications. C# has a subset of the .Net library available, much like Silverlight does. The same is true for C++ where a subset of the desktop Win32/COM APIs are available.
From what I understand (watching Build2011 videos) a Metro App won't be able to do that...
Interaction between processes is severally limited to specific Contracts (the charms on the right: Search, Send-to).
Think Phone, not Desktop.
You might be able to build a non-Metro Win8 app though.
Don't waste too much time on this. I expect that in a beta a close option (perhaps even a charm) will be included. Until then use a keyboard Alt-F4 or the Task Manager
C++:
Window::Current->CoreWindow->Close();
or
Window::Current->Close();
I haven't explored the difference between these two (more precisely, I don't know how CoreWindow differs from Current. I could assume though...
I'm using an Oracle VBox with Win8 on my Win7 machine to develop a C++ Metro App using VS 11. I used both of the above methods. I verified in Task Manager the app was not running on both Win8 and the Simulator.
As there are those gadgets available for the Windows Vista Sidebar and for Windows 7, I'd really like to know if you can integrate those into your .NET app. I want a similar feature and possibly use already existing gadgets into my app.
Can it be done?
This is likely possible but is not going to be very easy. You're application will need to do everything that the OS would normally do to host them, including parsing the gadget manifests, setting up a web container for each to run in, calling each gadget's event handlers correctly, etc.
Basically, everything that a gadget is supposed to do to integrate with the OS, you'll need to support. See http://msdn.microsoft.com/en-us/library/aa965850%28v=VS.85%29.aspx
This is not a project for the faint of heart but would be pretty cool if you can get it to work.
Have fun!
BTW, there is a W3C draft standard for widgets but it's not really practical yet. See http://www.w3.org/TR/widgets/1
I want to use windows 7 features like icon overlay, and thumbnail tasks but my question is that can i do it without using any other API on just my plain .net 3.5. i recently enabled jumplists on an application in my c#.net 3.5 using the Shell routine so can something like that be done for icon overlay and other windows 7 taskbar features.
And can old application like notepad which i am sure was made years ago use these new feaures?
I guess it depends on the meaning of "use". You get jumplists for free if you use the Common Files Dialog. If your app is WPF or MFC, you get some Windows 7 stuff in the latest version of those libraries (not 3.5). Failing that, you will need to either ask Windows directly (use an API) or use a library that isn't part of .NET 3.5 that will ask Windows for you. I recommend you use the Code Pack. One line of code for an overlay icon, for example. It also has non-visual Windows 7 features like Restart and Recovery, Power Awareness (.NET events when the machine goes on battery etc). It was last updated November 18th 2009 and I am expecting a new release any day now.
If you really don't want to use .NET wrapped taskbar functionalities,
you can try this link that calls overlay via PInvoke. For other W7 taskbar options you can check on the same site.
Anyway I suggest you to use the .NET managed API