[WPF & C#] Covering van de screensaver

Pagina: 1
Acties:

  • Dannydekr
  • Registratie: Januari 2005
  • Laatst online: 24-11 21:27
Ik ben dus bezig met een WPF screensaver voor Net3.0 en Vista. Alles werkt perfect, heb alleen een probleem met de covering van de screensaver:

http://www.neowin.net/forum/index.php?showtopic=529249

Zoals je ziet, als je hem gebruikt, is er aan de rechterkant en de onderkant een border te zien. En dat terwijl de code er gewoon goed uitziet. Maar het lijkt er op alsof de code niet werkt

APP.XAML.CS
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using System;
using System.Windows;
using System.Data;
using System.Xml;
using System.Configuration;
using System.Globalization;

namespace MaterialGroupsScreenSaver
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>

    public partial class App : System.Windows.Application
    {

        void OnStartup(Object sender, StartupEventArgs e)
        {
            string[] args = e.Args;
            if (args.Length > 0)
            {
                // Get the 2 character command line argument
                string arg = args[0].ToLower(CultureInfo.InvariantCulture).Trim

().Substring(0, 2);
                switch (arg)
                {
                    case "/c":
                        // Show the options dialog
                        Settings settings = new Settings();
                        settings.Show();
                        break;
                    case "/p":
                        // Don't do anything for preview
                        Application.Current.Shutdown();
                        break;
                    case "/s":
                        // Show screensaver form
                        ShowScreensaver();
                        break;
                    default:
                        Application.Current.Shutdown();
                        break;
                }
            }
            else
            {
                // If no arguments were passed in, show the screensaver
                ShowScreensaver();
            }


        }

        /// <summary>
        /// Shows screen saver by creating one instance of Window1 for each 

monitor.
        /// 
        /// Note: uses WinForms's Screen class to get monitor info.
        /// </summary>
        void ShowScreensaver()
        {
//creates window on primary screen
            Window1 primaryWindow = new Window1();
            primaryWindow.WindowStartupLocation = WindowStartupLocation.Manual;
            System.Drawing.Rectangle location = 

System.Windows.Forms.Screen.PrimaryScreen.Bounds;
            primaryWindow.WindowState = WindowState.Maximized;

            //creates window on other screens
            foreach (System.Windows.Forms.Screen screen in 

System.Windows.Forms.Screen.AllScreens)
            {
                if (screen == System.Windows.Forms.Screen.PrimaryScreen)
                    continue;

                Window1 window = new Window1();
                window.WindowStartupLocation = WindowStartupLocation.Manual;
                location = screen.Bounds;

                //covers entire monitor
                window.Left = location.X - 7;
                window.Top = location.Y - 7;
                window.Width = location.Width + 14;
                window.Height = location.Height + 14;

            }

            //show non-primary screen windows
            foreach (Window window in System.Windows.Application.Current.Windows)
            {
                if (window != primaryWindow)
                    window.Show();
            }

            ///shows primary screen window last
            primaryWindow.Show();
        }


    }

}


Hier het wat ik denk dat de boosdoener is:


Window1 window = new Window1();
window.WindowStartupLocation = WindowStartupLocation.Manual;
location = screen.Bounds;


//covers entire monitor
window.Left = location.X - 7;
window.Top = location.Y - 7;
window.Width = location.Width + 14;
window.Height = location.Height + 14;

[ Voor 8% gewijzigd door Dannydekr op 12-01-2007 14:17 ]

Those who surrender freedom for security will not have, nor do they deserve, either one.