syneffort 2 years ago
parent 1381578890
commit 962dad5522
  1. 18
      PacticeSolution/ControlTemplateSample/MainWindow.xaml
  2. 10
      PacticeSolution/DelegateEventFuncAction/DelegateEventFuncAction.csproj
  3. 57
      PacticeSolution/DelegateEventFuncAction/DelegateTest.cs
  4. 29
      PacticeSolution/DelegateEventFuncAction/EventTest.cs
  5. 26
      PacticeSolution/DelegateEventFuncAction/Program.cs
  6. 9
      PacticeSolution/ListViewEditSample/App.xaml
  7. 17
      PacticeSolution/ListViewEditSample/App.xaml.cs
  8. 10
      PacticeSolution/ListViewEditSample/AssemblyInfo.cs
  9. 14
      PacticeSolution/ListViewEditSample/CompanyInfo.cs
  10. 24
      PacticeSolution/ListViewEditSample/CompanyList.cs
  11. 28
      PacticeSolution/ListViewEditSample/DateConverter.cs
  12. 10
      PacticeSolution/ListViewEditSample/ListViewEditSample.csproj
  13. 27
      PacticeSolution/ListViewEditSample/MainWindow.xaml
  14. 28
      PacticeSolution/ListViewEditSample/MainWindow.xaml.cs
  15. 16
      PacticeSolution/PacticeSolution.sln

@ -7,7 +7,12 @@
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Button Content="OK" FontSize="30" FontWeight="Bold" Click="Button_Click">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Button Grid.Row="0" Content="OK" FontSize="30" FontWeight="Bold" Click="Button_Click">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
@ -17,5 +22,16 @@
</ControlTemplate>
</Button.Template>
</Button>
<Button Grid.Row="1" Content="Click" Foreground="Salmon" FontWeight="Bold" FontSize="20">
<Button.Template>
<ControlTemplate TargetType="Button">
<Grid>
<Ellipse Width="350" Fill="CadetBlue"/>
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
</Window>

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DelegateEventFuncAction
{
public class DelegateTest
{
public delegate void FunctionPointer();
private static void Print1()
{
Console.WriteLine("Print 1");
}
private static void Print2()
{
Console.WriteLine("Print 2");
}
private static void Print3()
{
Console.WriteLine("Print 3");
}
private static void Print4()
{
Console.WriteLine("Print 4");
}
private static void Execute(FunctionPointer fp)
{
fp();
}
public static void DoTest1()
{
Execute(Print1);
Execute(Print2);
Execute(Print3);
Execute(Print4);
}
public static void DoTest2()
{
// delegate chain
FunctionPointer fp = new FunctionPointer(Print1);
fp += Print2;
fp += Print3;
fp += Print4;
fp();
}
}
}

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DelegateEventFuncAction
{
public class EventTest
{
public delegate void CustomEventHandler(string message);
public event CustomEventHandler Trigger;
public event Action<string> TriggerByAction;
public void Notify()
{
Random rnd = new Random();
int r = rnd.Next(0, 10);
if (r <= 7 && this.Trigger != null)
this.Trigger("70% probability");
if (r <= 5 && this.TriggerByAction != null)
this.TriggerByAction("50% probability");
}
}
}

@ -0,0 +1,26 @@
namespace DelegateEventFuncAction
{
internal class Program
{
static void Main(string[] args)
{
//DelegateTest.DoTest1();
//DelegateTest.DoTest2();
EventTest et = new EventTest();
et.Trigger += (message) =>
{
Console.WriteLine($"[Delegate] {message}");
};
et.TriggerByAction += (message) =>
{
Console.WriteLine($"[Action] {message}");
};
et.Notify();
et.Notify();
et.Notify();
et.Notify();
et.Notify();
}
}
}

@ -0,0 +1,9 @@
<Application x:Class="ListViewEditSample.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ListViewEditSample"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace ListViewEditSample
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

@ -0,0 +1,10 @@
using System.Windows;
[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)
)]

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ListViewEditSample
{
public class CompanyInfo
{
public string Name { get; set; }
public DateTime Date { get; set; }
}
}

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ListViewEditSample
{
internal class CompanyList : List<CompanyInfo>
{
public CompanyList()
{
InitInstance();
}
private void InitInstance()
{
this.Add(new CompanyInfo() { Name = "Google", Date = DateTime.Now });
this.Add(new CompanyInfo() { Name = "Hoogle", Date = DateTime.Now });
this.Add(new CompanyInfo() { Name = "Ioogle", Date = DateTime.Now });
this.Add(new CompanyInfo() { Name = "Joogle", Date = DateTime.Now });
}
}
}

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace ListViewEditSample
{
internal class DateConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is DateTime))
return "";
DateTime date = (DateTime)value;
return date.ToString("yyyy년 MM월 dd일 HH시 mm분 ss초 fff밀리세컨드");
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>
</Project>

@ -0,0 +1,27 @@
<Window x:Class="ListViewEditSample.MainWindow"
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/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ListViewEditSample"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.DataContext>
<local:CompanyList/>
</Window.DataContext>
<Window.Resources>
<local:DateConverter x:Key="cvtDateToString"/>
</Window.Resources>
<ListView x:Name="lvMain" ItemsSource="{Binding}" HorizontalContentAlignment="Center">
<ListView.View>
<GridView>
<GridViewColumn Header="Company name" Width="Auto"
DisplayMemberBinding="{Binding Name}"/>
<GridViewColumn Header="Add date" Width="Auto"
DisplayMemberBinding="{Binding Date, Converter={StaticResource cvtDateToString}}"/>
</GridView>
</ListView.View>
</ListView>
</Window>

@ -0,0 +1,28 @@
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 ListViewEditSample
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}

@ -103,9 +103,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AnonymousMethod", "Anonymou
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TabContorlLightSample", "TabContorlLightSample\TabContorlLightSample.csproj", "{BB27AD88-D070-4095-BB8B-E2049F7DB0EC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StaticResourceSample", "StaticResourceSample\StaticResourceSample.csproj", "{6206E9C9-4449-42CC-A0A5-E54C4B15AA53}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StaticResourceSample", "StaticResourceSample\StaticResourceSample.csproj", "{6206E9C9-4449-42CC-A0A5-E54C4B15AA53}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HowToUseStyle", "HowToUseStyle\HowToUseStyle.csproj", "{6E182894-D2F1-4D2C-B991-51B01A2E3223}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HowToUseStyle", "HowToUseStyle\HowToUseStyle.csproj", "{6E182894-D2F1-4D2C-B991-51B01A2E3223}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ListViewEditSample", "ListViewEditSample\ListViewEditSample.csproj", "{87E66D9A-4E6C-43E8-B23A-AB2A2E9F67D5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DelegateEventFuncAction", "DelegateEventFuncAction\DelegateEventFuncAction.csproj", "{52E7C139-F78C-4947-BB09-58D4BFF72435}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -321,6 +325,14 @@ Global
{6E182894-D2F1-4D2C-B991-51B01A2E3223}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6E182894-D2F1-4D2C-B991-51B01A2E3223}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6E182894-D2F1-4D2C-B991-51B01A2E3223}.Release|Any CPU.Build.0 = Release|Any CPU
{87E66D9A-4E6C-43E8-B23A-AB2A2E9F67D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{87E66D9A-4E6C-43E8-B23A-AB2A2E9F67D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{87E66D9A-4E6C-43E8-B23A-AB2A2E9F67D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{87E66D9A-4E6C-43E8-B23A-AB2A2E9F67D5}.Release|Any CPU.Build.0 = Release|Any CPU
{52E7C139-F78C-4947-BB09-58D4BFF72435}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{52E7C139-F78C-4947-BB09-58D4BFF72435}.Debug|Any CPU.Build.0 = Debug|Any CPU
{52E7C139-F78C-4947-BB09-58D4BFF72435}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52E7C139-F78C-4947-BB09-58D4BFF72435}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Loading…
Cancel
Save