Added 37th post.
|
@ -0,0 +1,49 @@
|
|||
<Page
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Presenter.Title"
|
||||
x:Name="Page"
|
||||
WindowTitle="Page"
|
||||
FlowDirection="LeftToRight"
|
||||
Width="1000" Height="600">
|
||||
|
||||
<Grid x:Name="LayoutRoot">
|
||||
|
||||
<Ellipse RenderTransformOrigin="0.5,0.5" Fill="#33628FB2" StrokeThickness="3" Margin="-494,274.5,-148,-230.5">
|
||||
<Ellipse.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform ScaleX="1" ScaleY="1"/>
|
||||
<SkewTransform AngleX="0" AngleY="0"/>
|
||||
<RotateTransform Angle="-9.455"/>
|
||||
<TranslateTransform X="0" Y="0"/>
|
||||
</TransformGroup>
|
||||
</Ellipse.RenderTransform>
|
||||
</Ellipse>
|
||||
<Ellipse RenderTransformOrigin="0.5,0.5" Fill="#33628FB2" Stroke="{x:Null}" StrokeThickness="3" Margin="-446.5,0,-401.5,-345.5" VerticalAlignment="Bottom" Height="513.5">
|
||||
<Ellipse.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform ScaleX="1" ScaleY="1"/>
|
||||
<SkewTransform AngleX="0" AngleY="0"/>
|
||||
<RotateTransform Angle="-23.748"/>
|
||||
<TranslateTransform X="0" Y="0"/>
|
||||
</TransformGroup>
|
||||
</Ellipse.RenderTransform>
|
||||
</Ellipse>
|
||||
<Ellipse RenderTransformOrigin="0.5,0.5" Fill="#33628FB2" Stroke="{x:Null}" StrokeThickness="3" Margin="-342,0,-598,-136.563" VerticalAlignment="Bottom" Height="424">
|
||||
<Ellipse.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform ScaleX="1" ScaleY="1"/>
|
||||
<SkewTransform AngleX="0" AngleY="14.911"/>
|
||||
<RotateTransform Angle="0"/>
|
||||
<TranslateTransform X="0" Y="93.734"/>
|
||||
</TransformGroup>
|
||||
</Ellipse.RenderTransform>
|
||||
</Ellipse>
|
||||
<TextBlock HorizontalAlignment="Center" Margin="0,123,0,0" VerticalAlignment="Top" Height="113" FontSize="72" FontWeight="Bold" Text="Data Binding in WPF" TextAlignment="Center" TextWrapping="Wrap"/>
|
||||
<TextBlock Margin="499,0,150.213,170" VerticalAlignment="Bottom" Height="65" FontSize="36" Text="Bea Costa" TextAlignment="Right" TextWrapping="Wrap"/>
|
||||
<TextBlock Margin="499,0,150.213,127" VerticalAlignment="Bottom" Height="63" FontSize="36" Text="Test Lead in WPF" TextAlignment="Right" TextWrapping="Wrap"/>
|
||||
<Path Fill="{x:Null}" Stretch="Fill" Stroke="#FFEA6830" StrokeThickness="3" HorizontalAlignment="Right" Margin="0,251.5,125.5,123.5" Width="311" Data="M875,253 L875,477 565,477"/>
|
||||
<Path Fill="{x:Null}" Stretch="Fill" Stroke="#FFEA6830" StrokeThickness="3" Width="309" Data="M872.98701,253 L872.98701,477 565,477" HorizontalAlignment="Right" Margin="0,259.5,117.5,115.5"/>
|
||||
|
||||
</Grid>
|
||||
</Page>
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace Presenter
|
||||
{
|
||||
public partial class Title
|
||||
{
|
||||
public Title()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
// Insert code required on object creation below this point.
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
<Page
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:System="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
|
||||
x:Class="Presenter.WhatIsDataBinding"
|
||||
x:Name="Page"
|
||||
WindowTitle="Page"
|
||||
FlowDirection="LeftToRight"
|
||||
Width="1000" Height="600"
|
||||
Background="#FFFFFFFF" Title="What is Data Binding?">
|
||||
|
||||
<Page.Resources>
|
||||
<Style x:Key="TextBlockStyle1" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="FontSize" Value="22"/>
|
||||
<Setter Property="FontWeight" Value="Bold"/>
|
||||
<Setter Property="Foreground" Value="#FF72A1AE"/>
|
||||
<Setter Property="Background" Value="{x:Null}"/>
|
||||
</Style>
|
||||
</Page.Resources>
|
||||
|
||||
<Grid x:Name="LayoutRoot">
|
||||
<TextBlock HorizontalAlignment="Left" Margin="128,0,0,239.5" Style="{DynamicResource TextBlockStyle1}" Width="Auto" Height="Auto" Text="DependencyObject" TextWrapping="Wrap" d:LayoutOverrides="Height" VerticalAlignment="Bottom" FontSize="24" Foreground="#B272A1AE"/>
|
||||
<TextBlock HorizontalAlignment="Right" Margin="0,300.737,99,0" Style="{DynamicResource TextBlockStyle1}" Width="Auto" Height="Auto" Text="XML" TextWrapping="Wrap" RenderTransformOrigin="-0.269,1.52" d:LayoutOverrides="VerticalAlignment, Height" VerticalAlignment="Top" FontSize="36" FontWeight="Normal" Foreground="#CC72A1AE"/>
|
||||
<TextBlock HorizontalAlignment="Right" Margin="0,0,150,194" Style="{DynamicResource TextBlockStyle1}" VerticalAlignment="Bottom" Width="Auto" Height="Auto" Text="Object" TextWrapping="Wrap" RenderTransformOrigin="0.322,1.276" FontSize="30"/>
|
||||
<TextBlock HorizontalAlignment="Right" Margin="0,0,191.717,230.5" Style="{DynamicResource TextBlockStyle1}" VerticalAlignment="Bottom" Width="Auto" Height="Auto" Text="WebService" TextWrapping="Wrap" FontSize="36" Foreground="#4C72A1AE"/>
|
||||
<TextBlock HorizontalAlignment="Right" Margin="0,270.56,58.217,0" Style="{DynamicResource TextBlockStyle1}" Width="Auto" Height="Auto" Text="ADO.NET" TextWrapping="Wrap" d:LayoutOverrides="Height" VerticalAlignment="Top" FontSize="18"/>
|
||||
<TextBlock HorizontalAlignment="Right" Margin="0,196,74.173,0" Style="{DynamicResource TextBlockStyle1}" Width="Auto" Height="Auto" Text="Linq" TextWrapping="Wrap" d:LayoutOverrides="Height" VerticalAlignment="Top" FontSize="36" Foreground="#9972A1AE"/>
|
||||
<TextBlock HorizontalAlignment="Right" Margin="0,0,299,194" Style="{DynamicResource TextBlockStyle1}" VerticalAlignment="Bottom" Width="Auto" Height="Auto" Text="WPF Element" TextWrapping="Wrap" FontSize="20" FontWeight="Normal"/>
|
||||
<Grid HorizontalAlignment="Center" Margin="0,117.38,0,0" VerticalAlignment="Top" Height="177.62">
|
||||
<Grid>
|
||||
<Rectangle Fill="#FF72A1AE" Stroke="#FF000000" RadiusX="12.5" RadiusY="12.5" Width="120" HorizontalAlignment="Left" Margin="0,57.62,0,0"/>
|
||||
<Rectangle Fill="#FF72A1AE" Stroke="#FF000000" RadiusX="12.5" RadiusY="12.5" Width="120" HorizontalAlignment="Right" Margin="0,57.62,0,0"/>
|
||||
<TextBlock Width="Auto" Height="Auto" FontSize="36" Text="Target" TextWrapping="Wrap" HorizontalAlignment="Left" Margin="6.001,0,0,0" VerticalAlignment="Top"/>
|
||||
<TextBlock Width="Auto" Height="Auto" FontSize="36" Text="Source" TextWrapping="Wrap" RenderTransformOrigin="0.558,0.125" HorizontalAlignment="Right" Margin="0,0,1.433,0" VerticalAlignment="Top"/>
|
||||
</Grid>
|
||||
<Rectangle Fill="#FFFCFEFE" Stroke="#FF000000" StrokeThickness="2" RadiusX="12.5" RadiusY="12.5" Height="43" Margin="126,0,124.834,43" VerticalAlignment="Bottom">
|
||||
<Rectangle.StrokeDashArray>
|
||||
<System:Double>5</System:Double>
|
||||
</Rectangle.StrokeDashArray>
|
||||
</Rectangle>
|
||||
<TextBlock Height="Auto" FontSize="24" TextAlignment="Center" TextWrapping="Wrap" d:LayoutOverrides="HorizontalAlignment" Margin="150.092,0,410.092,49" VerticalAlignment="Bottom">Binding</TextBlock>
|
||||
<TextBlock d:LayoutOverrides="VerticalAlignment" HorizontalAlignment="Left" Margin="16.5,0,0,43" VerticalAlignment="Bottom" Width="Auto" Height="Auto" FontSize="16" TextAlignment="Right" TextWrapping="Wrap">Dependency<LineBreak/>Property</TextBlock>
|
||||
</Grid>
|
||||
<Rectangle Fill="#FF000000" Stroke="#FF000000" StrokeThickness="2" RadiusX="0" RadiusY="0" HorizontalAlignment="Left" Margin="293.5,224.5,0,0" VerticalAlignment="Top" Width="14" Height="14"/>
|
||||
<Rectangle Fill="#FF000000" Stroke="#FF000000" StrokeThickness="2" RadiusX="0" RadiusY="0" Height="14" HorizontalAlignment="Right" Margin="0,224.5,292.5,0" VerticalAlignment="Top" Width="14"/>
|
||||
<TextBlock Width="Auto" Height="Auto" FontSize="16" TextAlignment="Right" TextWrapping="Wrap" d:LayoutOverrides="Width" HorizontalAlignment="Right" Margin="0,218.553,220.384,0" VerticalAlignment="Top" Text="Property"/>
|
||||
</Grid>
|
||||
</Page>
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace Presenter
|
||||
{
|
||||
public partial class WhatIsDataBinding
|
||||
{
|
||||
public WhatIsDataBinding()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
// Insert code required on object creation below this point.
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
<Page
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Presenter"
|
||||
x:Class="Presenter.SimpleBinding"
|
||||
x:Name="Page"
|
||||
WindowTitle="Page"
|
||||
FlowDirection="LeftToRight"
|
||||
Width="1000" Height="600"
|
||||
Title="Binding to a single object">
|
||||
|
||||
<Page.Resources>
|
||||
|
||||
<XmlDataProvider x:Key="xdp" XPath="SolarSystemObject">
|
||||
<x:XData>
|
||||
<SolarSystemObject Name="Sun" xmlns="">
|
||||
<ImageFileName>Images\sun.jpg</ImageFileName>
|
||||
<Diameter>1380000</Diameter>
|
||||
<!-- In Kilometers -->
|
||||
</SolarSystemObject>
|
||||
</x:XData>
|
||||
</XmlDataProvider>
|
||||
|
||||
<local:ConvertKilometersToMiles x:Key="converter"/>
|
||||
</Page.Resources>
|
||||
|
||||
<StackPanel x:Name="LayoutRoot" Width="200">
|
||||
<!-- One-Way, Bind text to static XML -->
|
||||
<TextBlock Text="{Binding Source={StaticResource xdp},
|
||||
XPath=@Name}"
|
||||
FontSize="30" FontWeight="Bold"
|
||||
HorizontalAlignment="Center"/>
|
||||
|
||||
<!-- One-Way, Bind Image to static XML -->
|
||||
<!--<Image Source="{Binding Source={StaticResource xdp},
|
||||
XPath=ImageFileName}"
|
||||
Margin="0,60,0,60"/>-->
|
||||
|
||||
<!-- One-Way, Bind to a WPF element that changes
|
||||
(comment previous section) -->
|
||||
<Image Source="{Binding Source={StaticResource xdp},
|
||||
XPath=ImageFileName}"
|
||||
RenderTransformOrigin="0.5, 0.5" Margin="0,60,0,60">
|
||||
<Image.RenderTransform>
|
||||
<RotateTransform Angle="{Binding ElementName=MySlider,
|
||||
Path=Value}" />
|
||||
</Image.RenderTransform>
|
||||
</Image>
|
||||
<Slider Value="0" Minimum="0" Maximum="360"
|
||||
HorizontalAlignment="Center" Margin="0,0,0,30"
|
||||
Width="150" Focusable="False" Name="MySlider"/>
|
||||
|
||||
<!-- Two-Way, Bind to a WPF element that changes -->
|
||||
<!--<TextBox Text="{Binding ElementName=MySlider, Path=Value,
|
||||
Mode=TwoWay,
|
||||
UpdateSourceTrigger=PropertyChanged}" />-->
|
||||
|
||||
<!-- Two-Way, Bind to a WPF element that changes, with Validation
|
||||
(comment previous section) -->
|
||||
<TextBox>
|
||||
<TextBox.Text>
|
||||
<Binding ElementName="MySlider" Path="Value"
|
||||
Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
|
||||
<Binding.ValidationRules>
|
||||
<local:MinMaxValidationRule Minimum="0" Maximum="360"/>
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</TextBox.Text>
|
||||
</TextBox>
|
||||
|
||||
<!-- One-Way, Converter -->
|
||||
<StackPanel Orientation="Horizontal" TextBlock.FontSize="16"
|
||||
HorizontalAlignment="Center" Margin="0,30,0,30">
|
||||
<TextBlock Text="Diameter: " FontWeight="Bold"/>
|
||||
<TextBlock Text="{Binding Source={StaticResource xdp},
|
||||
XPath=Diameter,
|
||||
Converter={StaticResource converter}}" />
|
||||
<TextBlock Text=" miles" />
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
</Page>
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Navigation;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Presenter
|
||||
{
|
||||
public partial class SimpleBinding
|
||||
{
|
||||
public SimpleBinding()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
// Insert code required on object creation below this point.
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
<Page
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Presenter"
|
||||
x:Class="Presenter.PropertyChangeNotifications"
|
||||
x:Name="Page"
|
||||
WindowTitle="Page"
|
||||
FlowDirection="LeftToRight"
|
||||
Width="640" Height="480"
|
||||
Title="Property Change Notifications">
|
||||
|
||||
<Page.Resources>
|
||||
<local:Saturn ImageFileName="Images\2moons_2.gif" Temperature="103" x:Key="saturn"/>
|
||||
</Page.Resources>
|
||||
|
||||
<Grid x:Name="LayoutRoot" DataContext="{StaticResource saturn}" HorizontalAlignment="Center">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="20"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="20"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="20"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Image Source="{Binding Path=ImageFileName}" Width="300"
|
||||
VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
|
||||
<TextBlock Text="Temperature (in Kelvin):" Grid.Row="2"
|
||||
HorizontalAlignment="Right" FontSize="20"/>
|
||||
<Rectangle Height="{Binding Path=Temperature}" Fill="#FF8A2525"
|
||||
Width="40" VerticalAlignment="Bottom" Grid.Column="2"/>
|
||||
<TextBlock Text="{Binding Path=Temperature}" Grid.Row="2"
|
||||
Grid.Column="2" FontSize="20"/>
|
||||
<Button Content="Probe atmosphere" Click="Connect" Grid.Row="4"
|
||||
HorizontalAlignment="Right" Height="30" Width="150" />
|
||||
</Grid>
|
||||
</Page>
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace Presenter
|
||||
{
|
||||
public partial class PropertyChangeNotifications
|
||||
{
|
||||
public PropertyChangeNotifications()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void Connect(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Saturn saturn = this.Resources["saturn"] as Saturn;
|
||||
Random random = new Random();
|
||||
saturn.Temperature = random.Next(300);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
<Page
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Presenter"
|
||||
x:Class="Presenter.BindToCollections"
|
||||
x:Name="Page"
|
||||
WindowTitle="Page"
|
||||
FlowDirection="LeftToRight"
|
||||
Width="1000" Height="600"
|
||||
Title="Binding to a collection"
|
||||
FontSize="16">
|
||||
|
||||
<Page.Resources>
|
||||
<local:SolarSystem x:Key="solarSystem" />
|
||||
|
||||
<DataTemplate DataType="{x:Type local:SolarSystemObject}">
|
||||
<StackPanel Orientation="Horizontal" Margin="3" TextBlock.FontSize="11">
|
||||
<Image Source="{Binding Path=Image}" Margin="0,0,3,0" Width="55" Height="55"/>
|
||||
<StackPanel Width="250" >
|
||||
<TextBlock FontWeight="Bold" Text="{Binding Path=Name}" />
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="Orbit: " />
|
||||
<TextBlock Text="{Binding Path=Orbit}" />
|
||||
<TextBlock Text=" AU" />
|
||||
</StackPanel>
|
||||
<TextBlock Text="{Binding Path=Details}" TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
</Page.Resources>
|
||||
|
||||
<StackPanel Margin="40" HorizontalAlignment="Center"
|
||||
VerticalAlignment="Top">
|
||||
<ListBox MaxHeight="390"
|
||||
ItemsSource="{Binding Source={StaticResource solarSystem},
|
||||
Path=SolarSystemObjects}" />
|
||||
<!--<ComboBox SelectedIndex="0"
|
||||
ItemsSource="{Binding Source={StaticResource solarSystem},
|
||||
Path=SolarSystemObjects}" />-->
|
||||
|
||||
<!-- Collection Change Notifications -->
|
||||
<Button Click="AddPlanetX" Content="Add Planet X" Margin="30"/>
|
||||
</StackPanel>
|
||||
|
||||
</Page>
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace Presenter
|
||||
{
|
||||
public partial class BindToCollections
|
||||
{
|
||||
public BindToCollections()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void AddPlanetX(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SolarSystem system = this.Resources["solarSystem"] as SolarSystem;
|
||||
system.SolarSystemObjects.Add(new SolarSystemObject("Planet X", 3, 50000, new Uri(@"Images\planetx.jpg", UriKind.Relative), "This planet inhabited by aliens is cloaked so that humans can't see it."));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
<Page
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2006"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
x:Class="Presenter.DataTemplateDiagram"
|
||||
x:Name="Page"
|
||||
WindowTitle="Page"
|
||||
FlowDirection="LeftToRight"
|
||||
Width="1000" Height="600"
|
||||
Title="DataTemplate" Background="#FFFFFFFF">
|
||||
|
||||
<Page.Resources>
|
||||
<ControlTemplate x:Key="buttonTemplate" TargetType="Button">
|
||||
<Grid Background="#FFC0C0C0">
|
||||
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<DataTemplate x:Key="jupiterTemplate">
|
||||
<TextBlock Text="{Binding}" Background="#FFF0E68C" Padding="5" FontWeight="Bold" FontSize="16"/>
|
||||
</DataTemplate>
|
||||
</Page.Resources>
|
||||
|
||||
<Grid x:Name="LayoutRoot">
|
||||
|
||||
|
||||
<Grid RenderTransformOrigin="0.5,0.5" Margin="191.5,151.5,181,0" VerticalAlignment="Top" Height="110">
|
||||
<Grid.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform ScaleX="1.5" ScaleY="1.5"/>
|
||||
<SkewTransform AngleX="0" AngleY="0"/>
|
||||
<RotateTransform Angle="0"/>
|
||||
<TranslateTransform X="0" Y="0"/>
|
||||
</TransformGroup>
|
||||
</Grid.RenderTransform>
|
||||
<Border HorizontalAlignment="Left" Width="264" BorderBrush="#FF000000" BorderThickness="1,1,1,1">
|
||||
<TextBlock Width="264" Height="110" Background="#FFD3D1D1" FontSize="16" TextWrapping="Wrap" xml:space="preserve"><Run Foreground="#FF0000FF"><</Run><Span Foreground="#FF800000">ControlTemplate</Span><Run Foreground="#FF0000FF" xml:space="preserve"> ></Run><LineBreak/><Run Foreground="#FF0000FF" xml:space="preserve"> <</Run><Span Foreground="#FF800000">Grid</Span><Span Foreground="#FF0000FF" xml:space="preserve"> </Span><Span Foreground="#FFFF0000">Background</Span><Span Foreground="#FF0000FF">=</Span>"<Run Foreground="#FF0000FF">Silver</Run><Span>"</Span><Span Foreground="#FF0000FF">></Span><LineBreak/> <Run Background="#FFFAFBBA" Foreground="#FF0000FF"><</Run><Run Background="#FFFAFBBA" Foreground="#FF800000">ContentPresenter</Run><Run Background="#FFFAFBBA" Foreground="#FF0000FF"> /></Run><LineBreak/><Run Foreground="#FF0000FF"> </</Run><Span Foreground="#FF800000">Grid</Span><Span Foreground="#FF0000FF">></Span><LineBreak/><Run Foreground="#FF0000FF"></</Run><Span Foreground="#FF800000">ControlTemplate</Span><Span Foreground="#FF0000FF">></Span><LineBreak/></TextBlock>
|
||||
</Border>
|
||||
<Border HorizontalAlignment="Right" Margin="0,9,0,9" Width="254" BorderBrush="#FF000000" BorderThickness="0,1,1,1">
|
||||
<TextBlock Width="Auto" Height="Auto" Background="#FFFAFBBA" FontSize="16" TextWrapping="Wrap"><Run Foreground="#FF0000FF"><</Run><Span Foreground="#FF800000">DataTemplate</Span><Run Foreground="#FF0000FF">></Run><LineBreak/><Run Foreground="#FF0000FF" xml:space="preserve"> <</Run><Span Foreground="#FF800000">TextBlock</Span><Span Foreground="#FF0000FF" xml:space="preserve"> </Span><Span Foreground="#FFFF0000">Text</Span><Span Foreground="#FF0000FF">=</Span><Span>"</Span><Span Foreground="#FF0000FF">{Binding}</Span>"<Run Foreground="#FF0000FF"></Run><LineBreak/><Run Foreground="#FF0000FF"></Run><Run Foreground="#FFFF0000" xml:space="preserve"> Background</Run><Span Foreground="#FF0000FF">=</Span>"<Run Foreground="#FF0000FF">Khaki</Run><Span>"</Span><Run Foreground="#FF0000FF" xml:space="preserve"> /></Run><LineBreak/><Run Foreground="#FF0000FF"></</Run><Span Foreground="#FF800000">DataTemplate</Span><Span Foreground="#FF0000FF">></Span><LineBreak/></TextBlock>
|
||||
</Border>
|
||||
<Path Fill="#FFFAFBBA" Stretch="Fill" Stroke="#FF000000" Margin="223,9,253.212,9.001" Data="M470.56402,167.00072 C470.56402,167.00072 460.61076,205.30319 446.81219,205.75086 L417.16968,205.5 418.24368,196 406,213 418.24368,231.5 417.38448,222.5 446.47464,223.75047 C460.48803,224.08564 470.52837,258.00005 470.52837,258.00005"/>
|
||||
</Grid>
|
||||
|
||||
|
||||
<Button Content="Jupiter" Template="{StaticResource buttonTemplate}" ContentTemplate="{StaticResource jupiterTemplate}" Margin="396,0,404,153" VerticalAlignment="Bottom" Width="200" Height="60" RenderTransformOrigin="0.5,0.5">
|
||||
<Button.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform ScaleX="1.5" ScaleY="1.5"/>
|
||||
<SkewTransform AngleX="0" AngleY="0"/>
|
||||
<RotateTransform Angle="0"/>
|
||||
<TranslateTransform X="0" Y="0"/>
|
||||
</TransformGroup>
|
||||
</Button.RenderTransform>
|
||||
</Button>
|
||||
<TextBlock Margin="333,0,342,82" VerticalAlignment="Bottom" Height="41" TextWrapping="Wrap" FontSize="24"><Run Foreground="#FF0000FF"><</Run><Run Foreground="#FF800000">Button</Run><Run Foreground="#FF0000FF" xml:space="preserve"> </Run><Run Foreground="#FFFF0000">Content</Run><Run Foreground="#FF0000FF">=</Run>"<Run Foreground="#FF0000FF">Jupiter</Run>"<Run Foreground="#FF0000FF" xml:space="preserve"> /></Run></TextBlock>
|
||||
</Grid>
|
||||
</Page>
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace Presenter
|
||||
{
|
||||
public partial class DataTemplateDiagram
|
||||
{
|
||||
public DataTemplateDiagram()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
// Insert code required on object creation below this point.
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
<Page
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Presenter"
|
||||
x:Class="Presenter.FancyDataTemplate"
|
||||
x:Name="Page"
|
||||
WindowTitle="Page"
|
||||
FlowDirection="LeftToRight"
|
||||
Width="1000" Height="600"
|
||||
Title="Fancy DataTemplate">
|
||||
|
||||
<Page.Resources>
|
||||
<local:SolarSystem x:Key="solarSystem" />
|
||||
<local:ConvertOrbit x:Key="convertOrbit" />
|
||||
|
||||
<DataTemplate DataType="{x:Type local:SolarSystemObject}">
|
||||
<Canvas Width="20" Height="20" >
|
||||
<Ellipse Canvas.Left="{Binding Path=Orbit, Converter={StaticResource convertOrbit}, ConverterParameter=-1.707}" Canvas.Top="{Binding Path=Orbit, Converter={StaticResource convertOrbit}, ConverterParameter=-0.293}" Width="{Binding Path=Orbit, Converter={StaticResource convertOrbit}, ConverterParameter=2}" Height="{Binding Path=Orbit, Converter={StaticResource convertOrbit}, ConverterParameter=2}" Stroke="White" StrokeThickness="1"/>
|
||||
<Image Source="{Binding Path=Image}" Width="20" Height="20">
|
||||
<Image.ToolTip>
|
||||
<StackPanel Width="250" TextBlock.FontSize="16">
|
||||
<TextBlock FontWeight="Bold" Text="{Binding Path=Name}" />
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="Orbit: " />
|
||||
<TextBlock Text="{Binding Path=Orbit}" />
|
||||
<TextBlock Text=" AU" />
|
||||
</StackPanel>
|
||||
<TextBlock Text="{Binding Path=Details}" TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
</Image.ToolTip>
|
||||
</Image>
|
||||
</Canvas>
|
||||
</DataTemplate>
|
||||
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="Canvas.Left" Value="{Binding Path=Orbit, Converter={StaticResource convertOrbit}, ConverterParameter=0.707}"/>
|
||||
<Setter Property="Canvas.Bottom" Value="{Binding Path=Orbit, Converter={StaticResource convertOrbit}, ConverterParameter=0.707}"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ListBoxItem}">
|
||||
<Grid>
|
||||
<Ellipse x:Name="selectedPlanet" Margin="-10" StrokeThickness="2"/>
|
||||
<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsSelected" Value="true">
|
||||
<Setter Property="Stroke" TargetName="selectedPlanet" Value="Yellow"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="ListBox">
|
||||
<Setter Property="ItemsPanel">
|
||||
<Setter.Value>
|
||||
<ItemsPanelTemplate>
|
||||
<Canvas Width="590" Height="590" Background="Black" />
|
||||
</ItemsPanelTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Page.Resources>
|
||||
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" ClipToBounds="True">
|
||||
<ListBox ItemsSource="{Binding Source={StaticResource solarSystem}, Path=SolarSystemObjects}" Focusable="False" />
|
||||
</Grid>
|
||||
</Page>
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace Presenter
|
||||
{
|
||||
public partial class FancyDataTemplate
|
||||
{
|
||||
public FancyDataTemplate()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
// Insert code required on object creation below this point.
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
<Page
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Presenter"
|
||||
x:Class="Presenter.MasterDetail"
|
||||
x:Name="Page"
|
||||
WindowTitle="Page"
|
||||
FlowDirection="LeftToRight"
|
||||
Width="1000" Height="600"
|
||||
Title="Master Detail Scenario">
|
||||
|
||||
<Page.Resources>
|
||||
<local:SolarSystem x:Key="solarSystem" />
|
||||
|
||||
<DataTemplate x:Key="masterData">
|
||||
<StackPanel Orientation="Horizontal" Margin="3" TextBlock.FontSize="11">
|
||||
<Image Source="{Binding Path=Image}" Margin="0,0,3,0" Width="25" Height="25"/>
|
||||
<TextBlock FontSize="16" Text="{Binding Path=Name}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="detailData">
|
||||
<StackPanel Width="200" TextBlock.FontSize="14">
|
||||
<Image Source="{Binding Path=Image}" Margin="0,0,0,5" Width="200" Height="200"/>
|
||||
<TextBlock FontWeight="Bold" Text="{Binding Path=Name}" />
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="Orbit: " />
|
||||
<TextBlock Text="{Binding Path=Orbit}" />
|
||||
<TextBlock Text=" AU" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="Diameter: " />
|
||||
<TextBlock Text="{Binding Path=Diameter}" />
|
||||
<TextBlock Text=" Km" />
|
||||
</StackPanel>
|
||||
<TextBlock Text="{Binding Path=Details}" TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</Page.Resources>
|
||||
|
||||
<Grid x:Name="LayoutRoot" HorizontalAlignment="Center" Height="320">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="170"/>
|
||||
<ColumnDefinition Width="40"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ListBox ItemsSource="{Binding
|
||||
Source={StaticResource solarSystem},
|
||||
Path=SolarSystemObjects}"
|
||||
ItemTemplate="{StaticResource masterData}"
|
||||
IsSynchronizedWithCurrentItem="true" />
|
||||
|
||||
<ContentPresenter Content="{Binding
|
||||
Source={StaticResource solarSystem},
|
||||
Path=SolarSystemObjects}"
|
||||
ContentTemplate="{StaticResource detailData}"
|
||||
Grid.Column="2" />
|
||||
|
||||
</Grid>
|
||||
</Page>
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace Presenter
|
||||
{
|
||||
public partial class MasterDetail
|
||||
{
|
||||
public MasterDetail()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
// Insert code required on object creation below this point.
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
<Page
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Presenter"
|
||||
x:Class="Presenter.Views"
|
||||
x:Name="Page"
|
||||
WindowTitle="Page"
|
||||
FlowDirection="LeftToRight"
|
||||
Width="1000" Height="600"
|
||||
Title="Views">
|
||||
|
||||
<Page.Resources>
|
||||
<local:SolarSystem x:Key="solarSystem" />
|
||||
|
||||
<DataTemplate DataType="{x:Type local:SolarSystemObject}">
|
||||
<StackPanel Orientation="Horizontal" Margin="3" TextBlock.FontSize="11">
|
||||
<Image Source="{Binding Path=Image}" Margin="0,0,3,0" Width="55" Height="55"/>
|
||||
<StackPanel Width="250" >
|
||||
<TextBlock FontWeight="Bold" Text="{Binding Path=Name}" />
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="Diameter: " />
|
||||
<TextBlock Text="{Binding Path=Diameter}" />
|
||||
<TextBlock Text=" km" />
|
||||
</StackPanel>
|
||||
<TextBlock Text="{Binding Path=Details}" TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="groupingHeaderTemplate">
|
||||
<TextBlock Text="{Binding Path=Name}" FontWeight="Bold" FontSize="14" Background="#FF565AA0" Foreground="White" Padding="3"/>
|
||||
</DataTemplate>
|
||||
</Page.Resources>
|
||||
|
||||
<StackPanel x:Name="LayoutRoot" HorizontalAlignment="Center" Width="350">
|
||||
<CheckBox Content="Sort by diameter" Checked="AddSorting" Unchecked="RemoveSorting" Margin="0,0,0,5"/>
|
||||
<CheckBox Content="Filter out small planets" Checked="AddFiltering" Unchecked="RemoveFiltering" Margin="0,0,0,5"/>
|
||||
<CheckBox Content="Group by size" Checked="AddGrouping" Unchecked="RemoveGrouping" Margin="0,0,0,5"/>
|
||||
|
||||
<ListBox ItemsSource="{Binding Source={StaticResource solarSystem}, Path=SolarSystemObjects}" Height="390">
|
||||
<ListBox.GroupStyle>
|
||||
<GroupStyle HeaderTemplate="{StaticResource groupingHeaderTemplate}" />
|
||||
</ListBox.GroupStyle>
|
||||
</ListBox>
|
||||
|
||||
</StackPanel>
|
||||
</Page>
|
|
@ -0,0 +1,88 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Navigation;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Presenter
|
||||
{
|
||||
public partial class Views
|
||||
{
|
||||
SolarSystem solarSystem;
|
||||
ListCollectionView view;
|
||||
|
||||
public Views()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
solarSystem = this.Resources["solarSystem"] as SolarSystem;
|
||||
view = CollectionViewSource.GetDefaultView(solarSystem.SolarSystemObjects) as ListCollectionView;
|
||||
}
|
||||
|
||||
private void AddSorting(object sender, RoutedEventArgs e)
|
||||
{
|
||||
view.SortDescriptions.Add(new SortDescription("Diameter",
|
||||
ListSortDirection.Ascending));
|
||||
}
|
||||
|
||||
private void RemoveSorting(object sender, RoutedEventArgs e)
|
||||
{
|
||||
view.SortDescriptions.Clear();
|
||||
}
|
||||
|
||||
private void AddFiltering(object sender, RoutedEventArgs e)
|
||||
{
|
||||
view.Filter = new Predicate<object>(FilterOutSmallPlanets);
|
||||
}
|
||||
|
||||
private bool FilterOutSmallPlanets(object item)
|
||||
{
|
||||
SolarSystemObject solarSystemObject = item as SolarSystemObject;
|
||||
if (solarSystemObject.Diameter < 70000)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void RemoveFiltering(object sender, RoutedEventArgs e)
|
||||
{
|
||||
view.Filter = null;
|
||||
}
|
||||
|
||||
private void AddGrouping(object sender, RoutedEventArgs e)
|
||||
{
|
||||
view.GroupDescriptions.Add(
|
||||
new PropertyGroupDescription("Diameter",
|
||||
new GroupConverter()));
|
||||
}
|
||||
|
||||
private void RemoveGrouping(object sender, RoutedEventArgs e)
|
||||
{
|
||||
view.GroupDescriptions.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public class GroupConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
double diameter = (double)value;
|
||||
if (diameter < 70000)
|
||||
{
|
||||
return "Small";
|
||||
}
|
||||
return "Large";
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
throw new NotSupportedException("This method should never be called.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<Page
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Presenter.TipsDataBinding"
|
||||
x:Name="Page"
|
||||
WindowTitle="Page"
|
||||
FlowDirection="LeftToRight"
|
||||
Width="1000" Height="600"
|
||||
Title="Tips for data binding in the real world">
|
||||
|
||||
<Grid x:Name="LayoutRoot">
|
||||
<Image HorizontalAlignment="Center" VerticalAlignment="Center" Source="Images\screenShotBlend.png" />
|
||||
</Grid>
|
||||
</Page>
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace Presenter
|
||||
{
|
||||
public partial class TipsDataBinding
|
||||
{
|
||||
public TipsDataBinding()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
// Insert code required on object creation below this point.
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
<Page
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Presenter.Questions"
|
||||
x:Name="Page"
|
||||
WindowTitle="Page"
|
||||
FlowDirection="LeftToRight"
|
||||
Width="640" Height="480"
|
||||
WindowWidth="640" WindowHeight="480" Title="Resources" xmlns:d="http://schemas.microsoft.com/expression/blend/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
|
||||
|
||||
<Page.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="PooSniffer.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Page.Resources>
|
||||
|
||||
<Grid x:Name="LayoutRoot">
|
||||
<TextBlock HorizontalAlignment="Center" Margin="0,0,0,26" VerticalAlignment="Bottom" Height="Auto" FontSize="48" Foreground="#FF72A1AE" Text="Questions?" TextWrapping="Wrap"/>
|
||||
<Grid HorizontalAlignment="Center" Margin="0,0.514,0,134.843">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="90"/>
|
||||
<ColumnDefinition Width="0.768*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Rectangle Fill="#FF000000" Stroke="#FF000000" Margin="0,0,0,0" VerticalAlignment="Center" Width="90" Height="90" Grid.Row="2"/>
|
||||
<TextBlock d:LayoutOverrides="Height" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Center" Height="Auto" FontSize="24" TextWrapping="Wrap" Grid.Column="1">My blog:<LineBreak/><Hyperlink NavigateUri="http://www.beacosta.com">http://www.beacosta.com</Hyperlink></TextBlock>
|
||||
<TextBlock xml:space="preserve" FontSize="24" TextWrapping="Wrap" d:LayoutOverrides="Width, Height" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Center" Height="Auto" Grid.Column="1" Grid.Row="2">Snoop:<LineBreak/><Hyperlink NavigateUri="http://www.blois.us/Snoop/">http://www.blois.us/Snoop/</Hyperlink></TextBlock>
|
||||
<TextBlock xml:space="preserve" FontSize="24" TextWrapping="Wrap" d:LayoutOverrides="Width" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Center" Grid.Column="1" Grid.Row="1">Kevin's blog:<LineBreak/><Hyperlink NavigateUri="http://blogs.msdn.com/okoboji/">http://blogs.msdn.com/okoboji/</Hyperlink></TextBlock>
|
||||
<Image HorizontalAlignment="Center" Margin="0,0,0,0" VerticalAlignment="Center" Width="90" Height="90" Grid.Row="1" Source="Images\Kevin.jpg" Stretch="Fill"/>
|
||||
<Image HorizontalAlignment="Center" Margin="0,0,0,0" VerticalAlignment="Center" Width="90" Height="90" Source="Images\Bea.jpg" Stretch="Fill"/>
|
||||
<Rectangle Fill="{DynamicResource poo_sniffer_xpr}" Stroke="{x:Null}" Margin="0,0,0,0" Grid.Row="2"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Page>
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace Presenter
|
||||
{
|
||||
public partial class Questions
|
||||
{
|
||||
public Questions()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
// Insert code required on object creation below this point.
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<Application
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Presenter"
|
||||
x:Class="Presenter.App"
|
||||
StartupUri="Window1.xaml">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="PooSniffer.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Security;
|
||||
using System.Security.Permissions;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace Presenter
|
||||
{
|
||||
public partial class App: System.Windows.Application
|
||||
{
|
||||
}
|
||||
}
|
После Ширина: | Высота: | Размер: 49 KiB |
|
@ -0,0 +1,6 @@
|
|||
//
|
||||
// This file was auto-generated by a tool. Do not modify.
|
||||
//
|
||||
using System.Resources;
|
||||
|
||||
[assembly: NeutralResourcesLanguageAttribute("en-US" , UltimateResourceFallbackLocation.MainAssembly)]
|
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Data;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Presenter
|
||||
{
|
||||
public class ConvertKilometersToMiles : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return System.Convert.ToDouble(value) * 0.62;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return System.Convert.ToDouble(value) / 0.62;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Data;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Presenter
|
||||
{
|
||||
public class ConvertOrbit : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
double orbit = (double)value;
|
||||
double factor = System.Convert.ToDouble(parameter);
|
||||
return Math.Pow(orbit / 40, 0.4) * 770 * factor;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotSupportedException("This method should never be called");
|
||||
}
|
||||
}
|
||||
}
|
После Ширина: | Высота: | Размер: 3.9 KiB |
После Ширина: | Высота: | Размер: 41 KiB |
После Ширина: | Высота: | Размер: 40 KiB |
После Ширина: | Высота: | Размер: 5.0 KiB |
После Ширина: | Высота: | Размер: 4.8 KiB |
После Ширина: | Высота: | Размер: 4.4 KiB |
После Ширина: | Высота: | Размер: 2.7 KiB |
После Ширина: | Высота: | Размер: 3.7 KiB |
После Ширина: | Высота: | Размер: 3.2 KiB |
После Ширина: | Высота: | Размер: 946 B |
После Ширина: | Высота: | Размер: 192 KiB |
После Ширина: | Высота: | Размер: 4.2 KiB |
После Ширина: | Высота: | Размер: 4.1 KiB |
После Ширина: | Высота: | Размер: 3.5 KiB |
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Presenter
|
||||
{
|
||||
class MinMaxValidationRule : ValidationRule
|
||||
{
|
||||
private double minimum;
|
||||
|
||||
public double Minimum
|
||||
{
|
||||
get { return minimum; }
|
||||
set { minimum = value; }
|
||||
}
|
||||
|
||||
private double maximum;
|
||||
|
||||
public double Maximum
|
||||
{
|
||||
get { return maximum; }
|
||||
set { maximum = value; }
|
||||
}
|
||||
|
||||
|
||||
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
|
||||
{
|
||||
double valueTyped;
|
||||
bool isDouble = Double.TryParse((string)value, out valueTyped);
|
||||
if (isDouble && (minimum <= valueTyped) &&
|
||||
(valueTyped <= maximum))
|
||||
{
|
||||
return new ValidationResult(true, null);
|
||||
}
|
||||
return new ValidationResult(false, "The value typed should be between " + minimum + " and " + maximum + ".");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
<Page
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Presenter.Page1"
|
||||
x:Name="Page"
|
||||
WindowTitle="Page"
|
||||
FlowDirection="LeftToRight"
|
||||
Width="640" Height="480"
|
||||
WindowWidth="640" WindowHeight="480">
|
||||
|
||||
<Page.Resources>
|
||||
<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
|
||||
<Setter Property="Padding" Value="2,0,0,0"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ListBoxItem}">
|
||||
<Border SnapsToDevicePixels="true" x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsSelected" Value="true">
|
||||
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsSelected" Value="true"/>
|
||||
<Condition Property="Selector.IsSelectionActive" Value="false"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
|
||||
</MultiTrigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Page.Resources>
|
||||
|
||||
<Grid x:Name="LayoutRoot">
|
||||
<ListBox Margin="109,138,316,227" IsSynchronizedWithCurrentItem="True">
|
||||
<ListBoxItem Style="{DynamicResource ListBoxItemStyle1}" Content="ListBoxItem"/>
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</Page>
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<ResourceDictionary xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
|
||||
<DrawingBrush x:Key='poo_sniffer_xpr' Stretch='Uniform'
|
||||
>
|
||||
<DrawingBrush.Drawing>
|
||||
<DrawingGroup>
|
||||
<DrawingGroup.Children>
|
||||
<GeometryDrawing Brush='#FFE8E8E8' Geometry='F1 M 484.543,121.78C 484.543,121.78 455.087,132.661 444.988,159.592C 434.889,186.523 407.959,199.988 391.127,220.186C 374.295,240.384 300.236,280.78 280.038,304.345C 259.84,327.909 236.275,354.84 232.909,381.77C 229.543,408.701 226.176,449.097 236.275,465.929L 273.305,492.859C 273.305,492.859 300.236,482.76 310.335,465.929C 320.434,449.097 364.196,469.295 364.196,469.295C 364.196,469.295 414.691,412.067 444.988,388.503L 474.444,359.107C 462.294,371.232 520.886,343.958 586.375,321.176C 586.375,321.176 640.236,274.048 636.87,213.453L 604.048,150.394L 541.771,115.047L 484.543,121.78 Z '/>
|
||||
|
||||
<GeometryDrawing Brush='#FFE8E8E8' Geometry='F1 M 343.998,314.444C 344.987,315.033 424.79,297.612 431.523,361.572C 438.256,425.533 407.959,445.731 387.761,465.929L 357.464,486.127C 357.464,486.127 365.038,489.774 372.612,490.615C 380.186,491.457 394.493,488.09 394.493,488.09L 407.959,483.041C 407.959,483.041 434.048,485.566 439.939,485.566C 445.83,485.566 459.295,478.833 469.394,478.833C 479.493,478.833 494.642,473.784 498.008,484.724C 501.375,495.665 511.473,503.239 503.899,507.447C 503.899,507.447 480.335,511.655 470.236,509.972C 460.137,508.288 460.137,514.18 443.305,515.021C 426.474,515.863 380.186,520.071 365.879,523.437C 351.573,526.803 347.365,525.962 347.365,525.962C 347.365,525.962 346.523,527.645 335.582,523.437C 324.642,519.229 308.652,514.18 301.919,514.18C 295.186,514.18 282.563,509.13 288.454,495.665C 288.454,495.665 295.186,479.675 301.077,473.784C 301.077,473.784 307.81,466.209 306.969,454.427C 306.969,454.427 245.533,368.585 343.998,314.444 Z '/>
|
||||
|
||||
<GeometryDrawing Brush='#FFE8E8E8' Geometry='F1 M 531.672,245.714C 532.137,246.002 514.84,328.189 515.681,350.071C 516.523,371.952 523.256,372.793 524.939,387.1C 526.622,401.407 525.78,424.13 525.78,424.13C 525.78,424.13 547.662,457.793 549.345,488.932C 551.028,520.071 541.771,500.714 546.82,509.13C 551.87,517.546 570.384,521.754 582.167,519.229C 593.949,516.704 600.681,524.279 590.582,504.922C 580.483,485.566 588.058,493.982 575.434,481.358C 562.81,468.734 562.81,462.001 560.285,437.595C 557.761,413.189 550.186,409.823 552.711,392.15C 555.236,374.477 583.008,356.803 585.533,316.407C 588.058,276.011 596.473,263.387 583.85,233.09C 571.226,202.793 536.721,232.249 531.672,245.714 Z '/>
|
||||
|
||||
<GeometryDrawing Brush='#FFE8E8E8' Geometry='F1 M 439.097,179.568C 439.097,179.568 475.915,101.771 564.774,127.951C 653.633,154.131 713.842,241.316 721.233,245.343C 728.623,249.369 743.581,235.284 743.581,235.284L 753.299,220.262L 752.313,295.246C 752.313,295.246 765.46,315.443 766.706,335.673C 767.951,355.903 755.354,362.84 757.295,376.165C 759.235,389.49 778.592,417.287 778.382,427.523C 778.172,437.759 759.883,452.33 751.07,450.211C 742.256,448.093 716.512,434.833 716.512,434.833C 716.512,434.833 711.693,413.423 704.756,400.826C 697.818,388.229 659.655,359.768 650.017,316.948C 640.378,274.128 608.522,288.973 596.895,302.573L 439.097,179.568 Z '/>
|
||||
|
||||
<GeometryDrawing Brush='#FFE8E8E8' Geometry='F1 M 238.8,453.364C 238.8,453.364 211.87,473.562 211.87,502.176C 211.87,530.79 223.652,673.859 450.879,626.73C 450.879,626.73 486.226,608.216 489.592,596.433C 489.592,596.433 418.899,604.849 365.038,589.701C 311.176,574.552 302.761,591.384 264.048,544.255C 225.335,497.126 294.345,490.394 275.83,483.661L 238.8,453.364 Z '/>
|
||||
|
||||
<GeometryDrawing Brush='#FFE8E8E8' Geometry='F1 M 491.275,198.586C 491.741,198.873 474.444,281.061 475.285,302.942C 476.127,324.823 482.86,325.665 484.543,339.972C 486.226,354.279 485.384,377.001 485.384,377.001C 485.384,377.001 507.266,410.665 508.949,441.803C 510.632,472.942 501.375,453.586 506.424,462.001C 511.473,470.417 529.988,474.625 541.771,472.1C 553.553,469.576 560.285,477.15 550.186,457.793C 540.087,438.437 547.662,446.853 535.038,434.229C 522.414,421.605 522.414,414.873 519.889,390.467C 517.365,366.061 509.79,362.694 512.315,345.021C 514.84,327.348 542.612,309.675 545.137,269.279C 547.662,228.883 556.077,216.259 543.454,185.962C 530.83,155.665 496.325,185.12 491.275,198.586 Z '/>
|
||||
|
||||
<GeometryDrawing Brush='#FFE8E8E8' Geometry='F1 M 306.969,277.414C 307.957,278.004 387.761,260.582 394.493,324.543C 401.226,388.503 370.929,408.701 350.731,428.899L 320.434,449.097C 320.434,449.097 328.008,452.744 335.582,453.586C 343.157,454.427 357.464,451.061 357.464,451.061L 370.929,446.011C 370.929,446.011 397.018,448.536 402.909,448.536C 408.8,448.536 422.266,441.803 432.365,441.803C 442.464,441.803 457.612,436.754 460.978,447.694C 464.345,458.635 474.444,466.209 466.87,470.417C 466.87,470.417 443.305,474.625 433.206,472.942C 423.107,471.259 423.107,477.15 406.275,477.991C 389.444,478.833 343.157,483.041 328.85,486.407C 314.543,489.774 310.335,488.932 310.335,488.932C 310.335,488.932 309.493,490.615 298.553,486.407C 287.612,482.199 271.622,477.15 264.889,477.15C 258.157,477.15 245.533,472.1 251.424,458.635C 251.424,458.635 258.157,442.645 264.048,436.754C 264.048,436.754 270.78,429.18 269.939,417.397C 269.939,417.397 208.503,331.556 306.969,277.414 Z '/>
|
||||
|
||||
<GeometryDrawing Brush='#FFE8E8E8' Geometry='F1 M 826.602,432.841C 817.867,427.767 806.796,433.03 797.462,436.367C 790.163,438.976 780.871,442.236 778.035,450.473C 775.478,457.898 780.306,468.932 786.534,472.337C 804.273,482.035 827.668,471.164 844.208,458.936C 847.034,456.847 850.794,456.562 853.315,453.999C 856.528,450.733 855.702,441.851 852.101,439.188C 844.767,433.767 834.377,437.357 826.602,432.841 Z '/>
|
||||
|
||||
<GeometryDrawing Brush='#FFE8E8E8' Geometry='F1 M 806.568,464.579C 792.903,462.002 778.882,470.081 766.5,477.274C 762.835,479.403 772.268,472.731 772.592,475.972C 772.875,478.804 764.317,496.412 767.714,497.727C 783.458,503.824 801.029,499.413 817.496,497.022C 833.771,494.658 853.805,500.512 866.064,487.853C 871.308,482.438 881.317,474.312 877.599,467.4C 875.726,463.918 870.6,465.091 867.885,462.463C 865.229,459.891 867.057,453.513 864.243,451.178C 860.949,448.445 856.136,450.817 852.101,451.178C 843.474,451.949 834.509,452.738 826.602,456.82C 820.17,460.142 813.517,465.889 806.568,464.579 Z '/>
|
||||
|
||||
<GeometryDrawing Brush='#FFE8E8E8' Geometry='F1 M 830.852,430.725C 832.16,423.201 822.241,416.761 815.675,415.914C 810.241,415.212 802.841,420.031 799.283,415.208C 796.636,411.621 795.628,404.883 798.069,401.103C 798.756,400.039 799.636,399.157 800.497,398.281C 801.259,397.507 802.337,397.122 802.926,396.166C 803.411,395.377 803.429,394.306 803.533,393.344C 803.633,392.411 804.342,390.523 803.533,390.523C 802.521,390.523 802.427,392.513 801.711,393.344C 800.996,394.176 800.093,394.755 799.283,395.46C 794.698,399.455 790.311,404.316 787.748,410.271C 784.985,416.691 795.292,421.889 797.462,428.609C 797.755,429.516 798.25,430.484 798.069,431.43C 797.813,432.768 796.727,433.704 796.248,434.956C 794.996,438.229 796.868,444.128 799.89,444.83C 807.304,446.553 815.334,442.433 821.746,437.778C 824.839,435.531 830.13,434.879 830.852,430.725 Z '/>
|
||||
|
||||
</DrawingGroup.Children>
|
||||
</DrawingGroup>
|
||||
</DrawingBrush.Drawing>
|
||||
</DrawingBrush>
|
||||
</ResourceDictionary>
|
|
@ -0,0 +1,74 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Presenter
|
||||
{
|
||||
public class Presentation : INotifyPropertyChanged
|
||||
{
|
||||
private string[] slides = { "01Title.xaml", "02WhatIsDataBinding.xaml", "03SimpleBinding.xaml", "04PropertyChangeNotifications.xaml", "05BindToCollections.xaml", "06DataTemplateDiagram.xaml", "07FancyDataTemplate.xaml", "08MasterDetail.xaml", "09Views.xaml", "10TipsDataBinding.xaml", "11Questions.xaml"};
|
||||
private int currentIndex = 0;
|
||||
|
||||
public string[] Slides
|
||||
{
|
||||
get { return this.slides; }
|
||||
}
|
||||
|
||||
public string CurrentSlide
|
||||
{
|
||||
get { return this.slides[this.currentIndex]; }
|
||||
}
|
||||
|
||||
public int CurrentIndex
|
||||
{
|
||||
get { return this.currentIndex; }
|
||||
set
|
||||
{
|
||||
if (this.currentIndex != value)
|
||||
{
|
||||
this.currentIndex = value;
|
||||
this.OnPropertyChanged("CurrentSlide");
|
||||
this.OnPropertyChanged("CanGoBack");
|
||||
this.OnPropertyChanged("CanGoNext");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanGoBack
|
||||
{
|
||||
get { return this.currentIndex > 0; }
|
||||
}
|
||||
|
||||
public bool CanGoNext
|
||||
{
|
||||
get { return this.currentIndex < this.slides.Length - 1; }
|
||||
}
|
||||
|
||||
public void GoBack()
|
||||
{
|
||||
if (this.CanGoBack)
|
||||
{
|
||||
this.CurrentIndex--;
|
||||
}
|
||||
}
|
||||
|
||||
public void GoNext()
|
||||
{
|
||||
if (this.CanGoNext)
|
||||
{
|
||||
this.CurrentIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
if (this.PropertyChanged != null)
|
||||
{
|
||||
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
|
||||
<DefaultClrNameSpace>Presenter</DefaultClrNameSpace>
|
||||
<AssemblyName>Presenter</AssemblyName>
|
||||
<OutputPath>bin\$(Configuration)\</OutputPath>
|
||||
<ApplicationVersion>1.0.0.*</ApplicationVersion>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<AlwaysCompileMarkupFilesInSeparateDomain>false</AlwaysCompileMarkupFilesInSeparateDomain>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>Presenter</RootNamespace>
|
||||
<ApplicationIcon>Application.ico</ApplicationIcon>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ProjectGuid>{A1ED1BFE-ED19-4224-BDEC-4B964D2BA43C}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />
|
||||
<ItemGroup>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<ApplicationDefinition Include="App.xaml" />
|
||||
<Compile Include="03SimpleBinding.xaml.cs">
|
||||
<DependentUpon>03SimpleBinding.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="08MasterDetail.xaml.cs">
|
||||
<DependentUpon>08MasterDetail.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="09Views.xaml.cs">
|
||||
<DependentUpon>09Views.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="04PropertyChangeNotifications.xaml.cs">
|
||||
<DependentUpon>04PropertyChangeNotifications.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="11Questions.xaml.cs">
|
||||
<DependentUpon>11Questions.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
<Compile Include="ConvertKmToM.cs" />
|
||||
<Compile Include="ConvertOrbit.cs" />
|
||||
<Compile Include="01Title.xaml.cs">
|
||||
<DependentUpon>01Title.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="05BindToCollections.xaml.cs">
|
||||
<DependentUpon>05BindToCollections.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="07FancyDataTemplate.xaml.cs">
|
||||
<DependentUpon>07FancyDataTemplate.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="06DataTemplateDiagram.xaml.cs">
|
||||
<DependentUpon>06DataTemplateDiagram.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MinMaxValidationRule.cs" />
|
||||
<Compile Include="Presentation.cs" />
|
||||
<Compile Include="Saturn.cs" />
|
||||
<Compile Include="SolarSystem.cs" />
|
||||
<Compile Include="SolarSystemObject.cs" />
|
||||
<Compile Include="02WhatIsDataBinding.xaml.cs">
|
||||
<DependentUpon>02WhatIsDataBinding.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="10TipsDataBinding.xaml.cs">
|
||||
<DependentUpon>10TipsDataBinding.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Window1.xaml.cs">
|
||||
<DependentUpon>Window1.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Page Include="01Title.xaml" />
|
||||
<Page Include="05BindToCollections.xaml" />
|
||||
<Page Include="03SimpleBinding.xaml" />
|
||||
<Page Include="07FancyDataTemplate.xaml" />
|
||||
<Page Include="02WhatIsDataBinding.xaml" />
|
||||
<Page Include="08MasterDetail.xaml" />
|
||||
<Page Include="06DataTemplateDiagram.xaml" />
|
||||
<Page Include="09Views.xaml" />
|
||||
<Page Include="11Questions.xaml" />
|
||||
<Page Include="10TipsDataBinding.xaml" />
|
||||
<Page Include="04PropertyChangeNotifications.xaml" />
|
||||
<Page Include="PooSniffer.xaml" />
|
||||
<Page Include="Window1.xaml" />
|
||||
<Resource Include="Images\2moons_2.gif" />
|
||||
<Resource Include="Images\Bea.jpg" />
|
||||
<Resource Include="Images\earglobe.gif" />
|
||||
<Resource Include="Images\jupglobe.gif" />
|
||||
<Resource Include="Images\Kevin.jpg" />
|
||||
<Resource Include="Images\marglobe.gif" />
|
||||
<Resource Include="Images\merglobe.gif" />
|
||||
<Resource Include="Images\nepglobe.gif" />
|
||||
<Resource Include="Images\planetx.jpg" />
|
||||
<Resource Include="Images\plutoch_2.gif" />
|
||||
<Resource Include="Images\screenShotBlend.png" />
|
||||
<Resource Include="Images\sun.jpg" />
|
||||
<Resource Include="Images\uraglobe.gif" />
|
||||
<Resource Include="Images\venglobe.gif" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Presenter", "Presenter.csproj", "{A1ED1BFE-ED19-4224-BDEC-4B964D2BA43C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{A1ED1BFE-ED19-4224-BDEC-4B964D2BA43C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A1ED1BFE-ED19-4224-BDEC-4B964D2BA43C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Presenter
|
||||
{
|
||||
public class Saturn : INotifyPropertyChanged
|
||||
{
|
||||
private Uri imageFileName;
|
||||
|
||||
public Uri ImageFileName
|
||||
{
|
||||
get { return imageFileName; }
|
||||
set
|
||||
{
|
||||
imageFileName = value;
|
||||
OnPropertyChanged("ImageFileName");
|
||||
}
|
||||
}
|
||||
|
||||
private double temperature;
|
||||
|
||||
public double Temperature
|
||||
{
|
||||
get { return temperature; }
|
||||
set
|
||||
{
|
||||
temperature = value;
|
||||
OnPropertyChanged("Temperature");
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
if (this.PropertyChanged != null)
|
||||
{
|
||||
this.PropertyChanged(this,
|
||||
new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Presenter
|
||||
{
|
||||
class SolarSystem
|
||||
{
|
||||
private ObservableCollection<SolarSystemObject> solarSystemObjects;
|
||||
|
||||
public ObservableCollection<SolarSystemObject> SolarSystemObjects
|
||||
{
|
||||
get { return solarSystemObjects; }
|
||||
}
|
||||
|
||||
|
||||
public SolarSystem()
|
||||
{
|
||||
this.solarSystemObjects = new ObservableCollection<SolarSystemObject>();
|
||||
this.solarSystemObjects.Add(new SolarSystemObject("Sun", 0, 1380000, new Uri(@"Images\sun.jpg", UriKind.Relative), "The yellow dwarf star in the center of our solar system."));
|
||||
this.solarSystemObjects.Add(new SolarSystemObject("Mercury", 0.38, 4880, new Uri(@"Images\merglobe.gif", UriKind.Relative), "The small and rocky planet Mercury is the closest planet to the Sun."));
|
||||
this.solarSystemObjects.Add(new SolarSystemObject("Venus", 0.72, 12103.6, new Uri(@"Images\venglobe.gif", UriKind.Relative), "At first glance, if Earth had a twin, it would be Venus."));
|
||||
this.solarSystemObjects.Add(new SolarSystemObject("Earth", 1, 12756.3, new Uri(@"Images\earglobe.gif", UriKind.Relative), "Earth, our home planet, is the only planet in our solar system known to harbor life."));
|
||||
this.solarSystemObjects.Add(new SolarSystemObject("Mars", 1.52, 6794, new Uri(@"Images\marglobe.gif", UriKind.Relative), "The red planet Mars has inspired wild flights of imagination over the centuries."));
|
||||
this.solarSystemObjects.Add(new SolarSystemObject("Jupiter", 5.20, 142984, new Uri(@"Images\jupglobe.gif", UriKind.Relative), "With its numerous moons and several rings, the Jupiter system is a \"mini-solar system.\""));
|
||||
this.solarSystemObjects.Add(new SolarSystemObject("Saturn", 9.54, 120536, new Uri(@"Images\2moons_2.gif", UriKind.Relative), "Saturn is the most distant of the five planets known to ancient stargazers."));
|
||||
this.solarSystemObjects.Add(new SolarSystemObject("Uranus", 19.218, 51118, new Uri(@"Images\uraglobe.gif", UriKind.Relative), "Uranus gets its blue-green color from methane gas above the deeper cloud layers."));
|
||||
this.solarSystemObjects.Add(new SolarSystemObject("Neptune", 30.06, 49532, new Uri(@"Images\nepglobe.gif", UriKind.Relative), "Neptune was the first planet located through mathematical predictions."));
|
||||
this.solarSystemObjects.Add(new SolarSystemObject("Pluto", 39.5, 2274, new Uri(@"Images\plutoch_2.gif", UriKind.Relative), "Long considered to be the smallest, coldest, and most distant planet from the Sun."));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Presenter
|
||||
{
|
||||
public class SolarSystemObject
|
||||
{
|
||||
private string name;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set { name = value; }
|
||||
}
|
||||
|
||||
// In Astronomic Units (AU)
|
||||
private double orbit;
|
||||
|
||||
public double Orbit
|
||||
{
|
||||
get { return orbit; }
|
||||
set { orbit = value; }
|
||||
}
|
||||
|
||||
// In Km
|
||||
private double diameter;
|
||||
|
||||
public double Diameter
|
||||
{
|
||||
get { return diameter; }
|
||||
set { diameter = value; }
|
||||
}
|
||||
|
||||
private Uri image;
|
||||
|
||||
public Uri Image
|
||||
{
|
||||
get { return image; }
|
||||
set { image = value; }
|
||||
}
|
||||
|
||||
private string details;
|
||||
|
||||
public string Details
|
||||
{
|
||||
get { return details; }
|
||||
set { details = value; }
|
||||
}
|
||||
|
||||
public SolarSystemObject(string name, double orbit, double diameter, Uri image, string details)
|
||||
{
|
||||
this.name = name;
|
||||
this.orbit = orbit;
|
||||
this.diameter = diameter;
|
||||
this.image = image;
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
<Window
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
|
||||
xmlns:Presenter="clr-namespace:Presenter"
|
||||
x:Class="Presenter.Window1"
|
||||
x:Name="Window"
|
||||
Title="Window1"
|
||||
Width="800" Height="600" ResizeMode="NoResize" WindowState="Maximized" WindowStyle="None" KeyDown="Window_KeyDown">
|
||||
|
||||
<Window.Resources>
|
||||
<DataTemplate x:Key="SlideTemplate">
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding Mode=OneWay, XPath=@File}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="SlideTemplate1">
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding Mode=OneWay, XPath=@File}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
<Presenter:Presentation x:Key="presentation"/>
|
||||
<Style x:Key="NextButtonStyle" BasedOn="{x:Null}" TargetType="{x:Type Button}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Path Fill="#FF565AA0" Stretch="Fill" Stroke="{x:Null}" x:Name="path" Width="63.684" Height="36.709" Data="M577.71929,30.267953 L574,71 C574,71 623.50421,61.738613 623.50421,61.738613 L621.74723,74.696597 647.68857,47.340314 621,20 622,35 C622,35 577.71929,30.267953 577.71929,30.267953 z"/>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="MinWidth" Value="0"/>
|
||||
<Trigger Property="IsFocused" Value="True"/>
|
||||
<Trigger Property="IsDefaulted" Value="True"/>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Fill" TargetName="path" Value="#FFB0B4EE"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Fill" TargetName="path" Value="#FF34365D"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Fill" TargetName="path" Value="{x:Null}"/>
|
||||
<Setter Property="Stroke" TargetName="path" Value="#FFE1E1E1"/>
|
||||
<Setter Property="StrokeThickness" TargetName="path" Value="1"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid x:Name="LayoutRoot">
|
||||
<Viewbox Margin="10,104,10,40" Stretch="Uniform">
|
||||
<Frame Width="1000" Height="600" Source="{Binding Path=CurrentSlide, Source={StaticResource presentation}}" x:Name="Frame" NavigationUIVisibility="Hidden" Background="{x:Null}" Focusable="False"/>
|
||||
</Viewbox>
|
||||
<TextBlock Margin="10,20,10,0" VerticalAlignment="Top" Height="84" FontFamily="Calibri" FontSize="72" FontWeight="Bold" Text="{Binding Path=Content.Title, ElementName=Frame, Mode=Default}" TextAlignment="Center" TextWrapping="Wrap"/>
|
||||
<Button Style="{DynamicResource NextButtonStyle}" Width="63.684" Height="36.709" Content="Button" Click="Back_Click" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" Margin="10,0,0,10" VerticalAlignment="Bottom" IsEnabled="{Binding Path=CanGoBack, Source={StaticResource presentation}}">
|
||||
<Button.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform ScaleX="-1" ScaleY="-1"/>
|
||||
<SkewTransform AngleX="0" AngleY="0"/>
|
||||
<RotateTransform Angle="0"/>
|
||||
<TranslateTransform X="0" Y="0"/>
|
||||
</TransformGroup>
|
||||
</Button.RenderTransform>
|
||||
</Button>
|
||||
<Button HorizontalAlignment="Right" Margin="0,0,10,10" Style="{DynamicResource NextButtonStyle}" VerticalAlignment="Bottom" Width="63.684" Height="36.709" Content="Button" Click="Next_Click" IsEnabled="{Binding Path=CanGoNext, Source={StaticResource presentation}}">
|
||||
<Button.Background>
|
||||
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
|
||||
<GradientStop Color="#FFF3F3F3" Offset="0"/>
|
||||
<GradientStop Color="#FFEBEBEB" Offset="0.5"/>
|
||||
<GradientStop Color="#FFDDDDDD" Offset="0.5"/>
|
||||
<GradientStop Color="#FF9BACD8" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
</Button.Background>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Window>
|
|
@ -0,0 +1,63 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Navigation;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Presenter
|
||||
{
|
||||
public partial class Window1
|
||||
{
|
||||
private Presentation presentation;
|
||||
|
||||
public Window1()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
presentation = (Presentation)this.FindResource("presentation");
|
||||
|
||||
int indexLastWritten = 0;
|
||||
DateTime latestDateTimeWritten = DateTime.MinValue;
|
||||
for(int i=0; i<presentation.Slides.Length; i++)
|
||||
{
|
||||
string slide = presentation.Slides[i];
|
||||
DateTime dateLastWritten = File.GetLastWriteTime(@"..\..\" + slide);
|
||||
if (dateLastWritten.CompareTo(latestDateTimeWritten) > 0)
|
||||
{
|
||||
latestDateTimeWritten = dateLastWritten;
|
||||
indexLastWritten = i;
|
||||
}
|
||||
}
|
||||
presentation.CurrentIndex = indexLastWritten;
|
||||
}
|
||||
|
||||
private void Back_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
presentation.GoBack();
|
||||
}
|
||||
|
||||
private void Next_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
presentation.GoNext();
|
||||
}
|
||||
|
||||
private void Window_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Left)
|
||||
{
|
||||
presentation.GoBack();
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.Key == Key.Right)
|
||||
{
|
||||
presentation.GoNext();
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
После Ширина: | Высота: | Размер: 2.2 KiB |
После Ширина: | Высота: | Размер: 46 KiB |
|
@ -0,0 +1,9 @@
|
|||
<Application x:Class="PlanetsListBox.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
StartupUri="Window1.xaml"
|
||||
>
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Windows;
|
||||
using System.Data;
|
||||
using System.Xml;
|
||||
using System.Configuration;
|
||||
|
||||
namespace PlanetsListBox
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
|
||||
public partial class App : System.Windows.Application
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Data;
|
||||
using System.Globalization;
|
||||
|
||||
namespace PlanetsListBox
|
||||
{
|
||||
public class ConvertOrbit : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
double orbit = (double)value;
|
||||
double factor = System.Convert.ToDouble(parameter);
|
||||
return Math.Pow(orbit / 40, 0.4) * 770 * factor;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotSupportedException("This method should never be called");
|
||||
}
|
||||
}
|
||||
}
|
После Ширина: | Высота: | Размер: 3.9 KiB |
После Ширина: | Высота: | Размер: 5.0 KiB |
После Ширина: | Высота: | Размер: 4.8 KiB |
После Ширина: | Высота: | Размер: 4.4 KiB |
После Ширина: | Высота: | Размер: 2.7 KiB |
После Ширина: | Высота: | Размер: 3.7 KiB |
После Ширина: | Высота: | Размер: 3.2 KiB |
После Ширина: | Высота: | Размер: 946 B |
После Ширина: | Высота: | Размер: 4.2 KiB |
После Ширина: | Высота: | Размер: 4.1 KiB |
После Ширина: | Высота: | Размер: 3.5 KiB |
|
@ -0,0 +1,106 @@
|
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{E772577D-8416-494D-8E7B-298641798F70}</ProjectGuid>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<RootNamespace>PlanetsListBox</RootNamespace>
|
||||
<AssemblyName>PlanetsListBox</AssemblyName>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<OutputType>winexe</OutputType>
|
||||
<MinFrameworkVersionRequired>3.0</MinFrameworkVersionRequired>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Web</InstallFrom>
|
||||
<UpdateEnabled>true</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>false</MapFileExtensions>
|
||||
<ApplicationVersion>1.0.0.*</ApplicationVersion>
|
||||
<IsWebBootstrapper>true</IsWebBootstrapper>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<PublishUrl>Publish\</PublishUrl>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>.\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>.\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="UIAutomationProvider" />
|
||||
<Reference Include="UIAutomationTypes" />
|
||||
<Reference Include="ReachFramework" />
|
||||
<Reference Include="System.Printing" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.IdentityModel" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml" />
|
||||
<Page Include="Window1.xaml" />
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Window1.xaml.cs">
|
||||
<DependentUpon>Window1.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ConvertOrbit.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SolarSystem.cs" />
|
||||
<Compile Include="SolarSystemObject.cs" />
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Images\2moons_2.gif" />
|
||||
<Resource Include="Images\earglobe.gif" />
|
||||
<Resource Include="Images\jupglobe.gif" />
|
||||
<Resource Include="Images\marglobe.gif" />
|
||||
<Resource Include="Images\merglobe.gif" />
|
||||
<Resource Include="Images\nepglobe.gif" />
|
||||
<Resource Include="Images\planetx.jpg" />
|
||||
<Resource Include="Images\plutoch_2.gif" />
|
||||
<Resource Include="Images\sun.jpg" />
|
||||
<Resource Include="Images\uraglobe.gif" />
|
||||
<Resource Include="Images\venglobe.gif" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlanetsListBox", "PlanetsListBox.csproj", "{E772577D-8416-494D-8E7B-298641798F70}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E772577D-8416-494D-8E7B-298641798F70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E772577D-8416-494D-8E7B-298641798F70}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E772577D-8416-494D-8E7B-298641798F70}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E772577D-8416-494D-8E7B-298641798F70}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,54 @@
|
|||
#region Using directives
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Resources;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#endregion
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("PlanetsListBox")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("PlanetsListBox")]
|
||||
[assembly: AssemblyCopyright("Copyright @ 2007")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//In order to begin building localizable applications, set
|
||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
//the line below to match the UICulture setting in the project file.
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
|
@ -0,0 +1,70 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.42
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </autogenerated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace PlanetsListBox.Properties
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Resources;
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the Strongly Typed Resource Builder
|
||||
// class via a tool like ResGen or Visual Studio.NET.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
class Resources
|
||||
{
|
||||
|
||||
private static System.Resources.ResourceManager _resMgr;
|
||||
|
||||
private static System.Globalization.CultureInfo _resCulture;
|
||||
|
||||
/*FamANDAssem*/
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((_resMgr == null))
|
||||
{
|
||||
System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Resources", typeof(Resources).Assembly);
|
||||
_resMgr = temp;
|
||||
}
|
||||
return _resMgr;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return _resCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
_resCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
|
@ -0,0 +1,42 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.42
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </autogenerated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace PlanetsListBox.Properties
|
||||
{
|
||||
public partial class Settings : System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
private static Settings m_Value;
|
||||
|
||||
private static object m_SyncObject = new object();
|
||||
|
||||
public static Settings Value
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((Settings.m_Value == null))
|
||||
{
|
||||
System.Threading.Monitor.Enter(Settings.m_SyncObject);
|
||||
if ((Settings.m_Value == null))
|
||||
{
|
||||
try
|
||||
{
|
||||
Settings.m_Value = new Settings();
|
||||
}
|
||||
finally
|
||||
{
|
||||
System.Threading.Monitor.Exit(Settings.m_SyncObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Settings.m_Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version='1.0' encoding='iso-8859-1'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace PlanetsListBox
|
||||
{
|
||||
public class SolarSystem
|
||||
{
|
||||
private ObservableCollection<SolarSystemObject> solarSystemObjects;
|
||||
|
||||
public ObservableCollection<SolarSystemObject> SolarSystemObjects
|
||||
{
|
||||
get { return solarSystemObjects; }
|
||||
}
|
||||
|
||||
|
||||
public SolarSystem()
|
||||
{
|
||||
this.solarSystemObjects = new ObservableCollection<SolarSystemObject>();
|
||||
this.solarSystemObjects.Add(new SolarSystemObject("Sun", 0, 1380000, new Uri(@"Images\sun.jpg", UriKind.Relative), "The yellow dwarf star in the center of our solar system."));
|
||||
this.solarSystemObjects.Add(new SolarSystemObject("Mercury", 0.38, 4880, new Uri(@"Images\merglobe.gif", UriKind.Relative), "The small and rocky planet Mercury is the closest planet to the Sun."));
|
||||
this.solarSystemObjects.Add(new SolarSystemObject("Venus", 0.72, 12103.6, new Uri(@"Images\venglobe.gif", UriKind.Relative), "At first glance, if Earth had a twin, it would be Venus."));
|
||||
this.solarSystemObjects.Add(new SolarSystemObject("Earth", 1, 12756.3, new Uri(@"Images\earglobe.gif", UriKind.Relative), "Earth, our home planet, is the only planet in our solar system known to harbor life."));
|
||||
this.solarSystemObjects.Add(new SolarSystemObject("Mars", 1.52, 6794, new Uri(@"Images\marglobe.gif", UriKind.Relative), "The red planet Mars has inspired wild flights of imagination over the centuries."));
|
||||
this.solarSystemObjects.Add(new SolarSystemObject("Jupiter", 5.20, 142984, new Uri(@"Images\jupglobe.gif", UriKind.Relative), "With its numerous moons and several rings, the Jupiter system is a \"mini-solar system.\""));
|
||||
this.solarSystemObjects.Add(new SolarSystemObject("Saturn", 9.54, 120536, new Uri(@"Images\2moons_2.gif", UriKind.Relative), "Saturn is the most distant of the five planets known to ancient stargazers."));
|
||||
this.solarSystemObjects.Add(new SolarSystemObject("Uranus", 19.218, 51118, new Uri(@"Images\uraglobe.gif", UriKind.Relative), "Uranus gets its blue-green color from methane gas above the deeper cloud layers."));
|
||||
this.solarSystemObjects.Add(new SolarSystemObject("Neptune", 30.06, 49532, new Uri(@"Images\nepglobe.gif", UriKind.Relative), "Neptune was the first planet located through mathematical predictions."));
|
||||
this.solarSystemObjects.Add(new SolarSystemObject("Pluto", 39.5, 2274, new Uri(@"Images\plutoch_2.gif", UriKind.Relative), "Long considered to be the smallest, coldest, and most distant planet from the Sun."));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace PlanetsListBox
|
||||
{
|
||||
public class SolarSystemObject
|
||||
{
|
||||
private string name;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set { name = value; }
|
||||
}
|
||||
|
||||
// In Astronomic Units (AU)
|
||||
private double orbit;
|
||||
|
||||
public double Orbit
|
||||
{
|
||||
get { return orbit; }
|
||||
set { orbit = value; }
|
||||
}
|
||||
|
||||
// In Km
|
||||
private double diameter;
|
||||
|
||||
public double Diameter
|
||||
{
|
||||
get { return diameter; }
|
||||
set { diameter = value; }
|
||||
}
|
||||
|
||||
private Uri image;
|
||||
|
||||
public Uri Image
|
||||
{
|
||||
get { return image; }
|
||||
set { image = value; }
|
||||
}
|
||||
|
||||
private string details;
|
||||
|
||||
public string Details
|
||||
{
|
||||
get { return details; }
|
||||
set { details = value; }
|
||||
}
|
||||
|
||||
public SolarSystemObject(string name, double orbit, double diameter, Uri image, string details)
|
||||
{
|
||||
this.name = name;
|
||||
this.orbit = orbit;
|
||||
this.diameter = diameter;
|
||||
this.image = image;
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
<Window x:Class="PlanetsListBox.Window1"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:PlanetsListBox"
|
||||
Title="PlanetsListBox" Height="700" Width="700"
|
||||
>
|
||||
<Window.Resources>
|
||||
<local:SolarSystem x:Key="solarSystem" />
|
||||
<local:ConvertOrbit x:Key="convertOrbit" />
|
||||
|
||||
<DataTemplate DataType="{x:Type local:SolarSystemObject}">
|
||||
<Canvas Width="20" Height="20" >
|
||||
<Ellipse
|
||||
Canvas.Left="{Binding Path=Orbit, Converter={StaticResource convertOrbit}, ConverterParameter=-1.707}"
|
||||
Canvas.Top="{Binding Path=Orbit, Converter={StaticResource convertOrbit}, ConverterParameter=-0.293}"
|
||||
Width="{Binding Path=Orbit, Converter={StaticResource convertOrbit}, ConverterParameter=2}"
|
||||
Height="{Binding Path=Orbit, Converter={StaticResource convertOrbit}, ConverterParameter=2}"
|
||||
Stroke="White"
|
||||
StrokeThickness="1"/>
|
||||
<Image Source="{Binding Path=Image}" Width="20" Height="20">
|
||||
<Image.ToolTip>
|
||||
<StackPanel Width="250" TextBlock.FontSize="12">
|
||||
<TextBlock FontWeight="Bold" Text="{Binding Path=Name}" />
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="Orbit: " />
|
||||
<TextBlock Text="{Binding Path=Orbit}" />
|
||||
<TextBlock Text=" AU" />
|
||||
</StackPanel>
|
||||
<TextBlock Text="{Binding Path=Details}" TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
</Image.ToolTip>
|
||||
</Image>
|
||||
</Canvas>
|
||||
</DataTemplate>
|
||||
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="Canvas.Left" Value="{Binding Path=Orbit, Converter={StaticResource convertOrbit}, ConverterParameter=0.707}"/>
|
||||
<Setter Property="Canvas.Bottom" Value="{Binding Path=Orbit, Converter={StaticResource convertOrbit}, ConverterParameter=0.707}"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ListBoxItem}">
|
||||
<Grid>
|
||||
<Ellipse x:Name="selectedPlanet" Margin="-10" StrokeThickness="2"/>
|
||||
<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsSelected" Value="true">
|
||||
<Setter Property="Stroke" TargetName="selectedPlanet" Value="Yellow"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="ListBox">
|
||||
<Setter Property="ItemsPanel">
|
||||
<Setter.Value>
|
||||
<ItemsPanelTemplate>
|
||||
<Canvas Width="590" Height="590" Background="Black" />
|
||||
</ItemsPanelTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" ClipToBounds="True">
|
||||
<ListBox ItemsSource="{Binding Source={StaticResource solarSystem}, Path=SolarSystemObjects}" Focusable="False" />
|
||||
</Grid>
|
||||
</Window>
|
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
|
||||
namespace PlanetsListBox
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Window1.xaml
|
||||
/// </summary>
|
||||
|
||||
public partial class Window1 : System.Windows.Window
|
||||
{
|
||||
|
||||
public Window1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
# The power of Styles and Templates in WPF
|
||||
|
||||
In WPF, there is a very clean separation between the behavior of a Control and the look of a Control. For example, a Button's behavior consists only of listening to Click events, but its look can be anything - you can make a Button look like an arrow, a fish, or whatever else suits your application. Redefining the look of a Control is very easy to do in VS with Styles and Templates, and even easier if you have Blend. In this sample, I will show you how I redefined the look of a ListBox representing a list of planets.
|
||||
|
||||
I started out by implementing a data source with planets and the sun. I defined a class called "SolarSystemObject" with several properties (Name, Orbit, Diameter, Image and Details). I overrode the ToString(...) method in this class to return the name of the solar system object. Then I added a class called "SolarSystem" with a property called "SolarSystemObjects" of type ObservableCollection<SolarSystemObject>. In the constructor for the "SolarSystem" class, I added the sun and the nine planets to the "SolarSystemObjects" collection.
|
||||
|
||||
Once I had my source defined, I was ready to add a ListBox to the Window, bound to this collection:
|
||||
|
||||
<Window.Resources>
|
||||
<local:SolarSystem x:Key="solarSystem" />
|
||||
(...)
|
||||
</Window.Resources>
|
||||
|
||||
<ListBox ItemsSource="{Binding Source={StaticResource solarSystem}, Path=SolarSystemObjects}" />
|
||||
|
||||
The ListBox displays the planets, but visually this is still a little plain:
|
||||
|
||||
![](Images/37PlanetsListBox1.PNG)
|
||||
|
||||
At this point, I started brainstorming ways to display the planets in a more realistic way - my goal was to achieve a look similar to the solar system diagrams in school books. The first step was to change the layout of the ListBoxItems. The default layout for a ListBox is a StackPanel, which causes the ListBoxItems to be displayed one above another (to be more precise, it's a VirtualizingStackPanel, which adds virtualization to the traditional StackPanel). In order to display the planets the way I wanted, I needed a Canvas, which allows me to position the items within it by specifying the number of pixels to the Top and Left of that Canvas. There is an ItemsPanel property on ListBox of type ItemsPanelTemplate that can be used to change the layout of the ListBox, which is what I used in my sample. Here is how I did that:
|
||||
|
||||
<Style TargetType="ListBox">
|
||||
<Setter Property="ItemsPanel">
|
||||
<Setter.Value>
|
||||
<ItemsPanelTemplate>
|
||||
<Canvas Width="590" Height="590" Background="Black" />
|
||||
</ItemsPanelTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
My next step was to define the look of each planet, which I did by using a DataTemplate. I decided to represent each planet by its image, with a white ellipse simulating its orbit around the sun. I also added a tooltip with more information about the planet, which appears when you hover over the image.
|
||||
|
||||
<DataTemplate DataType="{x:Type local:SolarSystemObject}">
|
||||
<Canvas Width="20" Height="20" >
|
||||
<Ellipse
|
||||
Canvas.Left="{Binding Path=Orbit, Converter={StaticResource convertOrbit}, ConverterParameter=-1.707}"
|
||||
Canvas.Top="{Binding Path=Orbit, Converter={StaticResource convertOrbit}, ConverterParameter=-0.293}"
|
||||
Width="{Binding Path=Orbit, Converter={StaticResource convertOrbit}, ConverterParameter=2}"
|
||||
Height="{Binding Path=Orbit, Converter={StaticResource convertOrbit}, ConverterParameter=2}"
|
||||
Stroke="White"
|
||||
StrokeThickness="1"/>
|
||||
<Image Source="{Binding Path=Image}" Width="20" Height="20">
|
||||
<Image.ToolTip>
|
||||
<StackPanel Width="250" TextBlock.FontSize="12">
|
||||
<TextBlock FontWeight="Bold" Text="{Binding Path=Name}" />
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="Orbit: " />
|
||||
<TextBlock Text="{Binding Path=Orbit}" />
|
||||
<TextBlock Text=" AU" />
|
||||
</StackPanel>
|
||||
<TextBlock Text="{Binding Path=Details}" TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
</Image.ToolTip>
|
||||
</Image>
|
||||
</Canvas>
|
||||
</DataTemplate>
|
||||
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="Canvas.Left" Value="{Binding Path=Orbit, Converter={StaticResource convertOrbit}, ConverterParameter=0.707}"/>
|
||||
<Setter Property="Canvas.Bottom" Value="{Binding Path=Orbit, Converter={StaticResource convertOrbit}, ConverterParameter=0.707}"/>
|
||||
(...)
|
||||
</Style>
|
||||
|
||||
As you can see in the template and style above, the properties that specify the position of the ListBoxItem and the position and size of the Ellipse depend on the orbit of the planet, and all use the same converter with different parameters. The converter's job is to transform distances between solar system objects to distances in device independent pixels within the canvas. My original implementation of this converter simply multiplied the orbit value by a constant, but I found that the inner planets were too crowded together, so I changed the math a little to make it non-linear. I also decided to have the converter take a parameter that scales the result by a factor, so I could reuse this logic.
|
||||
|
||||
public class ConvertOrbit : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
double orbit = (double)value;
|
||||
double factor = System.Convert.ToDouble(parameter);
|
||||
return Math.Pow(orbit / 40, 0.4) * 770 * factor;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotSupportedException("This method should never be called");
|
||||
}
|
||||
}
|
||||
|
||||
If you run the application now, you will see that the planets are all correctly positioned in relation to the sun. If you hover over them, you will get more detailed information about the planet. If you click on a planet, the default ListBoxItem template assigns a blue background to the selected item, which shows a little bit around the image. This is not the effect I was looking for, so I decided to change the look of the selected item.
|
||||
|
||||
In order to change that style, I figured it would be easier to use Expression Blend to look at the default template, and then tweak it to the look I had in mind. I started by selecting the ListBox in Blend, then I went to the "Object" menu, selected "Edit Other Styles", "Edit ItemContainerStyle", and "Edit a Copy". Then I gave the style a name, and clicked "OK". If you go to the XAML tab at this point, you will see the full default Style for the ListBoxItems, which includes the following template:
|
||||
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ListBoxItem}">
|
||||
<Border SnapsToDevicePixels="true" x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsSelected" Value="true">
|
||||
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsSelected" Value="true"/>
|
||||
<Condition Property="Selector.IsSelectionActive" Value="false"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
|
||||
</MultiTrigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
|
||||
Using this as a base, I came up with a simpler template that adds a yellow ellipse around a planet when selected:
|
||||
|
||||
<Style TargetType="ListBoxItem">
|
||||
(...)
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ListBoxItem}">
|
||||
<Grid>
|
||||
<Ellipse x:Name="selectedPlanet" Margin="-10" StrokeThickness="2"/>
|
||||
<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsSelected" Value="true">
|
||||
<Setter Property="Stroke" TargetName="selectedPlanet" Value="Yellow"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
Below is a screenshot of the final application. If you hover over the images of the planets, you will get more information about them. If you click on a planet, a yellow ellipse will encircle it.
|
||||
|
||||
![](Images/37PlanetsListBox2.PNG)
|
||||
|
||||
This sample is part of a talk I presented last Tuesday, in an event here at Microsoft in Redmond where several customers came to learn more about WPF. It was a lot of fun to talk directly to customers and reply to their questions.
|