Recent Custom Chrome in WPF? - c#

I am interested in implementing Custom Chrome into one of my C# Applications. As i kept searching the internet for libraries that already took care of the main code, i found this: http://wpfwindow.codeplex.com/ . However, this is from 2009 and we are now in year 2014. I am also using Visual Studio 2013 Express for Windows Desktop.
I wanted to know if this resource is outdated, or can it still be implemented today? I am trying to achieve an effect like this:
but, i would like the windows close, minimize, etc. buttons as well as the titlebar in place. Is there any way i can achieve this effect without having to completely rewrite the form?
Something like below, but with custom colors for the header, and the form buttons. I would also like to have the option to remove certain buttons (and keep only the close button)
I also noticed this "Warning" for the essential window: Complete customization of WPF window can be done only when AllowsTransparency is set to "True", which causes that the window is software rendered which might be not as fast GPU rendering. This also made me skeptical on if i should use it or not.
Recap
1) I wanted to know if this resource is outdated, or can it still be implemented today?
2) Is there any way i can achieve this effect without having to completely rewrite the form?
3) Would customizing the entire form make the rendering slower?

Related

How to make non-modal MessageBox pop-ups for Unity project

Gday,
I am currently doing a small Unity project where the game takes place on the desktop, we have a creature that communicates with the player. It is currently severely limited with how it acts/reacts due to the only way that I can figure out how to make popups in the windows system style is through the use of the MessageBox function which is Modal (it suspends the application from running until the MessageBox has been answered or closed).
So I was wondering if there was any way to get the same effect without it suspending the entire application, I've tried looking into Forms however I can't get it to recognise it as a thing in VisualStudios. I have also looked at GUI.Window however doesn't create a window that looks like a Windows style popup.
What do yall reckon?
(Thankyou in advance)
In general, trying to mix Unity and WinForms is a really bad idea. They were built around completely different design philosophies and if you keep going down this path, they're going to keep fighting each other.
The best option here would be to create your own lookalike windows in-game. That would require quite a bit of work and infrastructure to set up at the beginning, but it would also give you full control over the style and behaviour of the dialogs.
Browse the asset store for assets that solve the problem for you. There are a number of dialog type assets you can grab and plug into your unity project to get you running quickly. A lot of them mimic windows features like moving around, scrolling or X to close.

Borderless Window with full functionality

For a while now I have attempted to get into UI design with WPF. My main goal is to create a good-looking application in a borderless window, like for example:
I made this example using the MetroUI framework. While this framework does the trick on borderless window functionality, it also does way too much for my tastes, custom controls, skins, animations, etc. I just want a borderless window and decide everything else myself.
I've searched stackoverflow a lot, and tried a fair amount of frameworks, but nothing seems to suit my needs.
Basically, I would like to have a borderless window with FULL windows functionality (drag to sides to pin, only show shadow if operating system settings has it on, etc etc).
Putting WindowStyle to None but keeping AllowsTransparency at False in order to preserve the original window chrome makes most if not all of the functionality I am seeking for work. However, the obvious problem here is: the window chrome is still there.
This looks like this:
To finally ask my question:
Can we keep all the current functionality that this window chrome provides, but somehow make it invisible (yet keep the dropshadow it provides) ? I can live without the dropshadow but it would be a nice bonus.
Or to ask a more broad question: is there any framework / pre-made project, that simply ONLY handles making a borderless window work properly and no other additional controls, skinning, ... ?
The more time I put into this the more it seems making borderless windows with WPF is simply incredibly clunky and I am getting rather unmotivated on my entire project because of this.
Thank you
See my answer on the following thread, it pretty much sums up all the window issues at once. Hope it helps!
WPF Borderless Window issues: Aero Snap & Maximizing

How can I make a menu-like form stay on the screen, on top of all other apps?

I want to make a menubar like window taskbar in C# but I'm wondering how can I make the form stay on the top of the screen and other program will not taped over it just like the window taskbar and when the mouse hover on a icon it will show a form like this:
I have made it like this:
And This is what I want
Windows has a facility for this, allowing you to basically create pseudo-taskbars that dock to the side of the screen and are always visible. It was used by the Office team (possibly publically documented for the Office team?) a long, long time ago to create a desktop toolbar.
Anyway, they are called Application Desktop Toolbars (or "AppBars"), and the documentation is here. To register one, you call the SHAppBarMessage function with the ABM_NEW message. Complete sample code is available in the linked documentation, unfortunately it is in C++.
To use this from a C# application, you will have to P/Invoke. As far as I know, it is not wrapped by the .NET Framework anywhere, probably because it never gets used by anyone anymore. This CodeProject article appears to have the necessary P/Invoke definitions written out. I can't vouch for their correctness, but armed with the documentation and that as an example, you should be able to cook up a working demo.
There is another CodeProject article here, written by Arik Poznanski as part of a series on using shell features from C#. It looks much more thorough, probably more than you need.
Set the property Form.TopMost unless you have other programs creating topmost windows. Doh!

How can I create my own form designer?

I'm starting my first C# project, and I want to make a "form designer" (like the one in VS).
The idea is, there will be a visual form designer with a limited toolbox, which will generate Python code (later more) to create the same form.
Problem is, I have no idea how to even get started. First of all, I have the form designer in VS: how do I make a "form-within-a-form?"
Next... I have no idea how complicated this is going to be. I suppose I could just make little boxes appear beside each control created on the form when it is clicked, for resizing, and make a textbox appear on it when double clicked or something, to change the text in it... Things like this.
So another thing I would like to know is this:
I do have programming experience in C and C++, I've done PHP for a number of years and am starting with Python as of recently. I've generated forms dynamically in VB6. Given this experience, am I in way over my head with this project?
this looks like a really good place to start. It has a pretty good example to get you started. You can even download his source (registration required).
It sounds like you're aware it's non-trivial for a C# first-timer. If you keep it pretty simple, it sounds like you're heading in the right direction (although a web-based form designer might be easier).
SharpDevelop would be an example of a full-featured IDE that can be re-purposed, but that's way over the top.
Good luck!
For most people starting out in C#, this project would be too much. With your VB6 background, you may be able to pull it off, though.
Here's a hint: the Visual Studio Windows Forms designer draws controls on its surface - by asking the controls to draw themselves.

Creating custom forms in WPF?

I'm currently learning WPF. I really am enjoying it so far. I love how easy it is to make great looking apps, and would like to create an app that has a custom window border. I would like for it to look something like this:
I know I could just easily change the Window type to not have a boarder and go from there, but that seems to much like WinForms. Wouldn't it be better to just create a class that derived from Window and styled it? If so how can I do this? Thanks!
Here's a great article on customizing Window "chrome" with WPF:
Custom Window Chrome in WPF
It is accompanied by a Code Gallery project from which you can download the code:
WPF Chrome
To show non-standard borders you have to set AllowsTransparency=True and no Border from the window. Whether you want to do this in the class is up to you. You basically have to realize WPF is really just a DirectX application hosted in a standard window. So you if you want non-standard Windows behavior, you have to drop the standard window border and start re-wiring it based on the standard window events you want to handle. Dragging, minimize/maximize/restore, Title bar.
Really, it shouldn't take you more than 30 minutes to an hour to come up with something close to what you want, and you could certainly put your custom window in a base class for re-use on down the road.
I have a feeling, for most cases, this is going to be the better and quicker option than trying override default Windows drawing.
There is a product called "Blendables" which contains a ChromelessWindow control in their "Essentials Mix" bundle which makes this very easy to do. I've never actually used it myself, I just know it exists and thought it might be of use. At bare minimum it shows that you can do what you ask about creating reusable, templatable chrome.

Categories

Resources