![]() |
Apr 27 2008, 02:49 PM
Post
#1
|
![]() |
|
![]() Genius ![]() Group: Member Posts: 1,673 Joined: 15-July 07 From: England, Ashton Member No.: 17,296 OS: Windows 7 70xx |
This is a tutorial for extending glass into the client area in C# with WPF
1. Start with going "file" then "new project", slect WPF Appliation and click ok. 2. Then download the DWM wrapper .dll here. Then click "project" and then "add reference". Navigate to browse along the tab bar and find the place were you have put the .dll and double click it. It will then be added to the references but dont move the .dll till you have done at least 1 compile. 3. Then add "using GlassLib;" like shown by simply typeing it in.
usingglasslib.jpg ( 150.33K )
Number of downloads: 1004. Next go into the .xaml, you will see "Title="Window1"" if you havent renamed it already
Window_Loaded.jpg ( 171.28K )
Number of downloads: 1095. Then pop into the .xaml.cs and paste this inbetween the brackets that will have been created >>
Bracket.jpg ( 176.31K )
Number of downloads: 72This is what needs pasteing CODE Dwm.Glass[this].Enabled = true; Thickness foo = new Thickness(5, 30, 5, 20); Dwm.Glass[this].Margins = foo; In this code the margins 5, 30, 5, 20 are Left, Right, Top, Bottom. The code will then look like this >>
DWM.jpg ( 180.71K )
Number of downloads: 68This is the end of the tutorial for implementing glass. If you would like to know how to extend the area that can be dragged into the glass area... read on... 6. Go into the .xaml design and create a lable that covers the whole of the glass area, then remove the text in it that will by default say "label". 7. Then go into the .xaml area and find the "label" line. Replace what it is on the label line with CODE <Label MouseDown="Extend_Grabber" MouseDoubleClick="Extend_MouseDoubleClick" /> It should then look like this >>
grabber_xaml.jpg ( 176.08K )
Number of downloads: 658. Right click on "Extend_Grabber " then click "navigate to even handler". You will be then be taken to the .xaml.cs code and inside the brackets copy and paste this CODE try { DragMove(); } catch (System.InvalidOperationException) { return; } It should then look like this >>
grabber_cs.jpg ( 162.67K )
Number of downloads: 51] 9. Next go back to the .xaml and right click "Extend_MouseDoubleClick" on the label line, then click "navigate to event handler". Again you will be taken to the .cs code and inside the brackets copy and paste this CODE if (this.WindowState == WindowState.Maximized) { this.WindowState = WindowState.Normal; } else { this.WindowState = WindowState.Maximized; } It should then look like this >>
double_click_cs.jpg ( 176.1K )
Number of downloads: 9810. Then go back to the .xaml design and drag the label back to the full size. 11. Give yourself a pat on the back you've done it Note:Remember to change the margins of the glass to suit your application Credits to Panda X for telling me how to do it, then i wrote the tut. -------------------- |
||
|
|
![]() |
May 16 2008, 05:48 PM
Post
#2
|
![]() |
|
![]() Genius ![]() Group: Member Posts: 1,673 Joined: 15-July 07 From: England, Ashton Member No.: 17,296 OS: Windows 7 70xx |
Bump... Sorry but someone must have liked this xD
-------------------- |
||
|
|
![]() |
May 24 2008, 01:29 AM
Post
#3
|
![]() |
|
![]() Member ![]() Group: Member Posts: 50 Joined: 29-June 07 From: Pittsburgh, PA Member No.: 16,700 OS: Windows 7 Beta 1, Mac OS X 10.5.6 |
I do.
-------------------- ![]() |
||
|
|
![]() |
May 24 2008, 12:29 PM
Post
#4
|
![]() |
|
![]() Genius ![]() Group: Member Posts: 1,673 Joined: 15-July 07 From: England, Ashton Member No.: 17,296 OS: Windows 7 70xx |
Yay some one
Glad to help -------------------- |
||
|
|
![]() |
Jun 10 2008, 08:03 PM
Post
#5
|
![]() |
|
![]() Member ![]() Group: Member Posts: 83 Joined: 9-October 07 From: Houston, Texas USA Member No.: 19,749 OS: Windows Vista Ultimate x64 SP1 |
This is a great tutorial. I was wondering however if this is the same steps in Visual Basic?
|
||
|
|
![]() |
Jun 10 2008, 08:06 PM
Post
#6
|
![]() |
|
![]() Genius ![]() Group: Member Posts: 1,673 Joined: 15-July 07 From: England, Ashton Member No.: 17,296 OS: Windows 7 70xx |
CODE Imports GlassLib CODE Dwm.Glass(Me).Enabled = True Dim foo As New Thickness(5, 30, 5, 20) Dwm.Glass(Me).Margins = foo Using them piecs of code instead -------------------- |
||
|
|
![]() |
Jun 11 2008, 03:33 AM
Post
#7
|
![]() |
|
![]() Member ![]() Group: Member Posts: 83 Joined: 9-October 07 From: Houston, Texas USA Member No.: 19,749 OS: Windows Vista Ultimate x64 SP1 |
Awesome! Worked like a charm. Thanks. I have other VB questions but I'll save that for another time. However I do have one more question. For the margins, what should I use if I want the program to be full glass with no black. I'm using 1000 for each right now and it works but not sure if it will for higher resolutions. Using 1680x1050.
This post has been edited by Zanpluktou: Jun 11 2008, 03:33 AM |
||
|
|
![]() |
Sep 1 2008, 04:12 PM
Post
#8
|
![]() |
|
|
g0dl1k3 ![]() Group: News PosterPosts: 3,762 Joined: 23-September 06 From: Vienna, Austria Member No.: 4,502 OS: 6.1.7600 |
Awesome! Worked like a charm. Thanks. I have other VB questions but I'll save that for another time. However I do have one more question. For the margins, what should I use if I want the program to be full glass with no black. I'm using 1000 for each right now and it works but not sure if it will for higher resolutions. Using 1680x1050. bump: -1 -------------------- |
||
|
|
![]() |
Sep 1 2008, 04:16 PM
Post
#9
|
![]() |
|
![]() Genius ![]() Group: Member Posts: 1,673 Joined: 15-July 07 From: England, Ashton Member No.: 17,296 OS: Windows 7 70xx |
-1 for full glass borders and the code in VB is...
Imports GlassLib and... Dwm.Glass(Me).Enabled = True Dim foo As New Thickness(5, 30, 5, 20) Dwm.Glass(Me).Margins = foo -------------------- |
||
|
|
![]() |
|
Lo-Fi Version | Time is now: 9th February 2010 - 03:37 PM |