Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Another Screensaver with WPF

, 27 Jan 2012 CDDL
Lessons learnt from writing a screensaver with WPF
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using RZWScreenSaver.Properties;

namespace RZWScreenSaver {
    /// <summary>
    /// Interaction logic for AboutRZ.xaml
    /// </summary>
    public partial class AboutRZ{
        public AboutRZ() {
            InitializeComponent();
        }
        internal AboutRZ(ScreenSaverEngine.ISaverEngine engine) {
            InitializeComponent();
            saverEngine = engine;
            showTitleMenu.IsChecked = Settings.Default.ShowTitle;
        }
        protected override void OnSourceInitialized(EventArgs e) {
            base.OnSourceInitialized(e);
            new GlassHelper(this).ExtendGlassFrame();
        }
        protected override void OnClosing(System.ComponentModel.CancelEventArgs e) {
            base.OnClosing(e);
            e.Cancel = !allowClose;
        }
        protected override void OnClosed(EventArgs e) {
            base.OnClosed(e);
            trayIcon.Dispose();
            trayIcon = null;
            Application.Current.Shutdown();
        }
        void onHideWindow(object sender, RoutedEventArgs e){
            e.Handled = true;
            Hide();
        }
        void onQuitApplications(object sender, RoutedEventArgs e){
            e.Handled = true;
            allowClose = true;
            Close();
        }
        void onShowAboutWindow(object sender, RoutedEventArgs e){
            e.Handled = true;
            Show();
        }
        bool allowClose;
        void onShowConfigDialog(object sender, RoutedEventArgs e){
            Debug.WriteLine(e.Handled);
            e.Handled = true;
            new ConfigDialog().ShowDialog();
        }
        void onSwitchSet(object sender, RoutedEventArgs e){
            var menuItem = (MenuItem) sender;
            var setIndex = Int32.Parse(menuItem.Tag.ToString());
            saverEngine.SwitchToSet(setIndex);
        }
        ScreenSaverEngine.ISaverEngine saverEngine;
        void onToggleShowTitle(object sender, RoutedEventArgs e){
            saverEngine.ToggleShowTitle();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)

Share

About the Author

Ruxo Zheng
Technical Lead
Thailand Thailand
C/C++ and C# programmer.

| Advertise | Privacy | Mobile
Web01 | 2.8.141022.1 | Last Updated 27 Jan 2012
Article Copyright 2009 by Ruxo Zheng
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid