Skip to content

Commit c97cc01

Browse files
author
Peter
committed
Add project files.
1 parent 524a889 commit c97cc01

12 files changed

+1060
-0
lines changed

CustomControlBaseLib.sln

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29728.190
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CustomControlBaseLib", "CustomControlBaseLib\CustomControlBaseLib.csproj", "{404C2727-E2C6-467D-8B5B-A6E2941B8EE0}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CustomControlSample", "CustomControlSample\CustomControlSample.csproj", "{1D32FDF8-5FE8-414C-80CB-4113FEB05474}"
9+
EndProject
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CustomControlSampleLib", "CustomControlSampleLib\CustomControlSampleLib.csproj", "{086A3184-0414-49C5-8EDE-22769BDFC569}"
11+
EndProject
12+
Global
13+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14+
Debug|Any CPU = Debug|Any CPU
15+
Release|Any CPU = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{404C2727-E2C6-467D-8B5B-A6E2941B8EE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{404C2727-E2C6-467D-8B5B-A6E2941B8EE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{404C2727-E2C6-467D-8B5B-A6E2941B8EE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{404C2727-E2C6-467D-8B5B-A6E2941B8EE0}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{1D32FDF8-5FE8-414C-80CB-4113FEB05474}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{1D32FDF8-5FE8-414C-80CB-4113FEB05474}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{1D32FDF8-5FE8-414C-80CB-4113FEB05474}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{1D32FDF8-5FE8-414C-80CB-4113FEB05474}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{086A3184-0414-49C5-8EDE-22769BDFC569}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{086A3184-0414-49C5-8EDE-22769BDFC569}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{086A3184-0414-49C5-8EDE-22769BDFC569}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{086A3184-0414-49C5-8EDE-22769BDFC569}.Release|Any CPU.Build.0 = Release|Any CPU
30+
EndGlobalSection
31+
GlobalSection(SolutionProperties) = preSolution
32+
HideSolutionNode = FALSE
33+
EndGlobalSection
34+
GlobalSection(ExtensibilityGlobals) = postSolution
35+
SolutionGuid = {52D3BCFD-23A0-45C0-BC3C-8F8E183063E5}
36+
EndGlobalSection
37+
EndGlobal

CustomControlBaseLib/CustomControlBase.cs

+579
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<UseWPF>true</UseWPF>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
</Project>

CustomControlSample/App.xaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="CustomControlSample.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:CustomControlSample"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>

CustomControlSample/App.xaml.cs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
9+
namespace CustomControlSample {
10+
/// <summary>
11+
/// Interaction logic for App.xaml
12+
/// </summary>
13+
public partial class App: Application {
14+
}
15+
}

CustomControlSample/AssemblyInfo.cs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Windows;
2+
3+
[assembly: ThemeInfo(
4+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5+
//(used if a resource is not found in the page,
6+
// or application resource dictionaries)
7+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8+
//(used if a resource is not found in the page,
9+
// app, or any theme specific resource dictionaries)
10+
)]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
6+
<UseWPF>true</UseWPF>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<ProjectReference Include="..\CustomControlBaseLib\CustomControlBaseLib.csproj" />
12+
<ProjectReference Include="..\CustomControlSampleLib\CustomControlSampleLib.csproj" />
13+
</ItemGroup>
14+
15+
</Project>

CustomControlSample/MainWindow.xaml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<Window x:Class="CustomControlSample.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:CustomControlSample"
7+
xmlns:CustomControlSampleLib="clr-namespace:CustomControlSampleLib;assembly=CustomControlSampleLib"
8+
mc:Ignorable="d"
9+
Title="MainWindow" Width="500" Height="400">
10+
<Grid>
11+
<Grid.RowDefinitions>
12+
<RowDefinition/>
13+
<RowDefinition Height="Auto"/>
14+
<RowDefinition Height="Auto"/>
15+
<RowDefinition Height="Auto"/>
16+
</Grid.RowDefinitions>
17+
<Grid.ColumnDefinitions>
18+
<ColumnDefinition Width="Auto"/>
19+
<ColumnDefinition Width="200"/>
20+
<ColumnDefinition Width="50"/>
21+
<ColumnDefinition/>
22+
</Grid.ColumnDefinitions>
23+
<Rectangle Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" Fill="WhiteSmoke"/>
24+
<CustomControlSampleLib:CustomControlSample Grid.Row="0" Grid.ColumnSpan="4" Name="TestCustomControlSample"/>
25+
<Rectangle Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" Grid.RowSpan="3" Fill="Gainsboro"/>
26+
<Label Grid.Row="1" Grid.Column="0" Content="_Font Size" Target="{Binding ElementName=FontSizeTextBox}"/>
27+
<ScrollBar Grid.Row="1" Grid.Column="1 " x:Name="FontsizeScrollBar" Orientation="Horizontal"
28+
Minimum="5" Maximum="100" />
29+
<TextBox Grid.Row="1" Grid.Column="2" x:Name="FontSizeTextBox" Text="20"/>
30+
<Label Grid.Row="2" Grid.Column="0" Content="_Horizontal Alignment" Target="{Binding ElementName=HorizontalAlignmentComboBox}"/>
31+
<ComboBox Grid.Row="2" Grid.Column="1" x:Name="HorizontalAlignmentComboBox" />
32+
<Label Grid.Row="3" Grid.Column="0" Content="_Vertical Alignment" Target="{Binding ElementName=VerticalAlignmentComboBox}"/>
33+
<ComboBox Grid.Row="3" Grid.Column="1" x:Name="VerticalAlignmentComboBox" />
34+
35+
</Grid>
36+
</Window>
+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
17+
namespace CustomControlSample {
18+
19+
20+
/// <summary>
21+
/// Interaction logic for MainWindow.xaml
22+
/// </summary>
23+
public partial class MainWindow: Window {
24+
public MainWindow() {
25+
InitializeComponent();
26+
27+
TestCustomControlSample.FontSize = toInt(FontSizeTextBox);
28+
FontSizeTextBox.LostFocus += fontSizeTextBox_LostFocus;
29+
FontsizeScrollBar.Value = toInt(FontSizeTextBox);
30+
FontsizeScrollBar.Scroll += fontsizeScrollBar_Scroll;
31+
32+
HorizontalAlignmentComboBox.Items.Add(new ComboBoxItem { Content= "Left", Tag=HorizontalAlignment.Left, IsSelected=true });
33+
HorizontalAlignmentComboBox.Items.Add(new ComboBoxItem { Content= "Center", Tag=HorizontalAlignment.Center });
34+
HorizontalAlignmentComboBox.Items.Add(new ComboBoxItem { Content= "Right", Tag=HorizontalAlignment.Right });
35+
HorizontalAlignmentComboBox.Items.Add(new ComboBoxItem { Content= "Stretch", Tag=HorizontalAlignment.Stretch });
36+
TestCustomControlSample.HorizontalAlignment = HorizontalAlignment.Left;
37+
HorizontalAlignmentComboBox.SelectionChanged += horizontalAlignmentComboBox_SelectionChanged;
38+
39+
VerticalAlignmentComboBox.Items.Add(new ComboBoxItem { Content= "Top", Tag=VerticalAlignment.Top, IsSelected=true });
40+
VerticalAlignmentComboBox.Items.Add(new ComboBoxItem { Content= "Center", Tag=VerticalAlignment.Center });
41+
VerticalAlignmentComboBox.Items.Add(new ComboBoxItem { Content= "Bottom", Tag=VerticalAlignment.Bottom });
42+
VerticalAlignmentComboBox.Items.Add(new ComboBoxItem { Content= "Stretch", Tag=VerticalAlignment.Stretch });
43+
TestCustomControlSample.VerticalAlignment = VerticalAlignment.Top;
44+
VerticalAlignmentComboBox.SelectionChanged += verticalAlignmentComboBox_SelectionChanged;
45+
}
46+
47+
48+
private double toInt(TextBox textBox) {
49+
if (int.TryParse(textBox.Text, out var result)) {
50+
return result;
51+
}
52+
return 20;
53+
}
54+
55+
private void fontSizeTextBox_LostFocus(object sender, RoutedEventArgs e) {
56+
var newValue = toInt(FontSizeTextBox);
57+
//if (newValue) {
58+
59+
//}
60+
TestCustomControlSample.FontSize = newValue;
61+
FontsizeScrollBar.Value = newValue;
62+
}
63+
64+
65+
private void fontsizeScrollBar_Scroll(object sender, System.Windows.Controls.Primitives.ScrollEventArgs e) {
66+
FontSizeTextBox.Text = ((int)FontsizeScrollBar.Value).ToString();
67+
TestCustomControlSample.FontSize = (int)FontsizeScrollBar.Value;
68+
}
69+
70+
71+
private void horizontalAlignmentComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) {
72+
TestCustomControlSample.HorizontalAlignment = (HorizontalAlignment)((ComboBoxItem)HorizontalAlignmentComboBox.SelectedItem).Tag;
73+
}
74+
75+
private void verticalAlignmentComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) {
76+
TestCustomControlSample.VerticalAlignment = (VerticalAlignment)((ComboBoxItem)VerticalAlignmentComboBox.SelectedItem).Tag;
77+
}
78+
}
79+
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Windows;
2+
3+
[assembly: ThemeInfo(
4+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5+
//(used if a resource is not found in the page,
6+
// or application resource dictionaries)
7+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8+
//(used if a resource is not found in the page,
9+
// app, or any theme specific resource dictionaries)
10+
)]

0 commit comments

Comments
 (0)