Skip to content

Instantly share code, notes, and snippets.

@podhmo
Created February 19, 2014 06:20
Show Gist options
  • Save podhmo/9086956 to your computer and use it in GitHub Desktop.
Save podhmo/9086956 to your computer and use it in GitHub Desktop.
<Application x:Class="ScallableApplication.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<Style TargetType="Window" x:Key="FullScreenStyle">
<Setter Property="Height" Value="768"></Setter>
<Setter Property="Width" Value="1366"></Setter>
<Setter Property="WindowStyle" Value="None"></Setter>
<Setter Property="ResizeMode" Value="NoResize"></Setter>
<Setter Property="WindowState" Value="Maximized"></Setter>
</Style>
<Style TargetType="Window" x:Key="WindowStyle">
<Setter Property="Height" Value="460.7"></Setter>
<Setter Property="Width" Value="819.6"></Setter>
</Style>
<DrawingBrush x:Key="gridBackgroundBrush" Viewport="0,0,10,10" ViewportUnits="Absolute" TileMode="Tile">
<DrawingBrush.Drawing>
<DrawingGroup>
<DrawingGroup.Children>
<GeometryDrawing Geometry="M0,0 L1,0 1,0.1, 0,0.1Z" Brush="Beige" />
<GeometryDrawing Geometry="M0,0 L0,1 0.1,1, 0.1,0Z" Brush="Beige" />
</DrawingGroup.Children>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</Application.Resources>
</Application>
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace ScallableApplication
{
/// <summary>
/// App.xaml の相互作用ロジック
/// </summary>
public partial class App : Application
{
}
}
<Window x:Class="ScallableApplication.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<StackPanel>
<StackPanel.Resources>
<Style TargetType="Button">
<Setter Property="Height" Value="50"></Setter>
</Style>
</StackPanel.Resources>
<Button Click="Button_Click">全画面</Button>
<Button Click="Button_Click_1">ウィンドウ</Button>
</StackPanel>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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.Navigation;
using System.Windows.Shapes;
namespace ScallableApplication
{
/// <summary>
/// MainWindow.xaml の相互作用ロジック
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.PreviewKeyDown += HandleEsc;
}
private void HandleEsc(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
this.Close();
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
var w = new SubWindow() { Style = this.FindResource("FullScreenStyle") as Style };
w.Show();
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
var w = new SubWindow() { Style = this.FindResource("WindowStyle") as Style };
w.Show();
}
}
}
<Window x:Class="ScallableApplication.SubWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="SubWindow">
<Window.Resources>
<SolidColorBrush x:Key="MainBorderBrush">
<SolidColorBrush.Color>Blue</SolidColorBrush.Color>
</SolidColorBrush>
<Style x:Key="MainBorder" TargetType="Border">
<Setter Property="CornerRadius" Value="24.5"/>
<Setter Property="Height" Value="500"/>
<Setter Property="Width" Value="1260"/>
<Setter Property="BorderThickness" Value="10"/>
<Setter Property="BorderBrush" Value="{StaticResource MainBorderBrush}"/>
</Style>
</Window.Resources>
<Grid Background="{StaticResource gridBackgroundBrush}">
<Viewbox>
<Grid>
<Border Style="{StaticResource MainBorder}"/>
<Canvas>
<Canvas.RenderTransform>
<TranslateTransform X="100" Y="100"/>
</Canvas.RenderTransform>
<Rectangle Width="100" Height="100" Fill="Gray"></Rectangle>
<Rectangle
Canvas.Left="150"
Width="100" Height="100">
<Rectangle.Fill>
<SolidColorBrush Opacity="0.5" Color="Gray"/>
</Rectangle.Fill>
</Rectangle>
<Rectangle
Canvas.Left="300"
Width="100" Height="100">
<Rectangle.Fill>
<SolidColorBrush Opacity="0.2" Color="Gray"/>
</Rectangle.Fill>
</Rectangle>
<Rectangle
Canvas.Left="450"
Width="100" Height="100">
<Rectangle.Fill>
<SolidColorBrush Opacity="0.1" Color="Gray"/>
</Rectangle.Fill>
</Rectangle>
<Rectangle
Canvas.Left="600"
Width="100" Height="100">
<Rectangle.Fill>
<SolidColorBrush Opacity="0.05" Color="Gray"/>
</Rectangle.Fill>
</Rectangle>
</Canvas>
</Grid>
</Viewbox>
</Grid>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 ScallableApplication
{
/// <summary>
/// SubWindow.xaml の相互作用ロジック
/// </summary>
public partial class SubWindow : Window
{
public SubWindow()
{
InitializeComponent();
this.PreviewKeyDown += HandleEsc;
}
private void HandleEsc(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
this.Close();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment