|
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using GadgetLibrary;
using GadgetPrototype.Picture;
using GadgetPrototype.Weather;
namespace GadgetPrototype
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void OnGadgetClose(object sender, RoutedEventArgs e)
{
var gadgetContainer = sender as GadgetContainer;
if (gadgetContainer != null)
{
_SnapCanvas.Children.Remove(gadgetContainer);
}
}
private void _SolidColorMenu_Click(object sender, RoutedEventArgs e)
{
Background = new SolidColorBrush((Color) ColorConverter.ConvertFromString("#4d6a73"));
}
private void _AbstractBackgroundMenu_Click(object sender, RoutedEventArgs e)
{
var image = new BitmapImage();
image.BeginInit();
image.UriSource = new Uri("pack://application:,,,/GadgetPrototype;component/Resources/Images/abstract.png");
image.EndInit();
Background = new ImageBrush(image);
}
private void _NatureBackgroundMenu_Click(object sender, RoutedEventArgs e)
{
var image = new BitmapImage();
image.BeginInit();
image.UriSource = new Uri("pack://application:,,,/GadgetPrototype;component/Resources/Images/nature.png");
image.EndInit();
Background = new ImageBrush(image);
}
private void _AddWeatherGadget_Click(object sender, RoutedEventArgs e)
{
var gadgetContainer = new GadgetContainer();
Canvas.SetTop(gadgetContainer, 100);
Canvas.SetLeft(gadgetContainer, 100);
gadgetContainer.OptionButtonType = OptionButtonTypes.Settings;
gadgetContainer.Close += OnGadgetClose;
var weatherGadget = new WeatherGadget();
gadgetContainer.Gadget = weatherGadget;
_SnapCanvas.Children.Add(gadgetContainer);
}
private void _AddPictureGadget_Click(object sender, RoutedEventArgs e)
{
var gadgetContainer = new GadgetContainer();
Canvas.SetTop(gadgetContainer, 100);
Canvas.SetLeft(gadgetContainer, 100);
gadgetContainer.OptionButtonType = OptionButtonTypes.Resize;
gadgetContainer.Close += OnGadgetClose;
var pictureGadget = new PictureGadget();
gadgetContainer.Gadget = pictureGadget;
_SnapCanvas.Children.Add(gadgetContainer);
}
}
}
|
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.
I'm a software developer living in Northampton, UK, and enjoy working with the latest .Net technologies.