瀏覽代碼

添加项目文件。

ToiletMaster 7 月之前
父節點
當前提交
f6c38f2428

+ 25 - 0
ColorfulEditor.sln

@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.9.34728.123
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorfulEditor", "ColorfulEditor\ColorfulEditor.csproj", "{F89FDF79-108D-46FA-A4C2-47007D607869}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{F89FDF79-108D-46FA-A4C2-47007D607869}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{F89FDF79-108D-46FA-A4C2-47007D607869}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{F89FDF79-108D-46FA-A4C2-47007D607869}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{F89FDF79-108D-46FA-A4C2-47007D607869}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {C393F8F7-16B3-4D61-9209-2976FF28FF81}
+	EndGlobalSection
+EndGlobal

+ 9 - 0
ColorfulEditor/App.xaml

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

+ 12 - 0
ColorfulEditor/App.xaml.cs

@@ -0,0 +1,12 @@
+using System.Configuration;
+using System.Data;
+using System.Windows;
+
+namespace ColorfulEditor {
+	/// <summary>
+	/// Interaction logic for App.xaml
+	/// </summary>
+	public partial class App : Application {
+	}
+
+}

+ 10 - 0
ColorfulEditor/AssemblyInfo.cs

@@ -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)
+)]

+ 11 - 0
ColorfulEditor/ColorfulEditor.csproj

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

+ 22 - 0
ColorfulEditor/CustomControl/BlockEditor.cs

@@ -0,0 +1,22 @@
+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 ColorfulEditor.CustomControl {
+	public class BlockEditor : ItemsControl {
+		static BlockEditor() {
+			DefaultStyleKeyProperty.OverrideMetadata(typeof(BlockEditor), new FrameworkPropertyMetadata(typeof(BlockEditor)));
+		}
+	}
+}

+ 46 - 0
ColorfulEditor/CustomControl/ItemBlock.cs

@@ -0,0 +1,46 @@
+using System.Collections.ObjectModel;
+using System.Runtime.CompilerServices;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+
+namespace ColorfulEditor.CustomControl {
+	public class ItemBlock : ItemsControl {
+		static int debug_counter = 6;
+		static ItemBlock() {
+			DefaultStyleKeyProperty.OverrideMetadata(typeof(ItemBlock), new FrameworkPropertyMetadata(typeof(ItemBlock)));
+		}
+
+		public ItemBlock() {
+			// TBD Debug
+			SubBlockCollection = new List<ItemsControl>();
+			Text = $"<Block{debug_counter}";
+			if (debug_counter > 0) {
+				debug_counter -= 1;
+				if (debug_counter == 5) {
+					SubBlockCollection.Add(new ItemBlock());
+					SubBlockCollection.Add(new ItemBlock());
+				}
+				SubBlockCollection.Add(new ItemBlock());
+			}
+			else {
+
+			}
+			ItemsSource = SubBlockCollection;
+		}
+
+		public string Text {
+			get { return (string)GetValue(TextProperty); }
+			set { SetValue(TextProperty, value); }
+		}
+
+		public static readonly DependencyProperty TextProperty =
+			DependencyProperty.Register("Text", typeof(string), typeof(ItemBlock), new PropertyMetadata(""));
+
+		public ICollection<ItemsControl> SubBlockCollection { get; set; }
+
+		public override void OnApplyTemplate() {
+			base.OnApplyTemplate();
+		}
+	}
+}

+ 47 - 0
ColorfulEditor/CustomControl/MessageBlock.cs

@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+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 ColorfulEditor.CustomControl {
+	public class MessageBlock : Control {
+		static MessageBlock() {
+			DefaultStyleKeyProperty.OverrideMetadata(typeof(MessageBlock), new FrameworkPropertyMetadata(typeof(MessageBlock)));
+		}
+
+		public MessageBlock() {
+			// TBD Debug
+			MessageBodyBlock = new ItemBlock();
+		}
+
+		public string Text {
+			get { return (string)GetValue(TextProperty); }
+			set { SetValue(TextProperty, value); }
+		}
+		public static readonly DependencyProperty TextProperty =
+			DependencyProperty.Register("Text", typeof(string), typeof(MessageBlock), new PropertyMetadata(""));
+
+		public ItemsControl MessageBodyBlock {
+			get { return (ItemsControl)GetValue(MessageBodyBlockProperty); }
+			set { SetValue(MessageBodyBlockProperty, value); }
+		}
+
+		// Using a DependencyProperty as the backing store for MessageBodyBlock.  This enables animation, styling, binding, etc...
+		public static readonly DependencyProperty MessageBodyBlockProperty =
+			DependencyProperty.Register("MessageBodyBlock", typeof(ItemsControl), typeof(MessageBlock), new PropertyMetadata(null));
+
+
+
+	}
+}

+ 11 - 0
ColorfulEditor/MainWindow.xaml

@@ -0,0 +1,11 @@
+<Window x:Class="ColorfulEditor.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:cc="clr-namespace:ColorfulEditor.CustomControl"
+        xmlns:local="clr-namespace:ColorfulEditor"
+        mc:Ignorable="d"
+        Title="MainWindow" Height="450" Width="800">
+    <cc:MessageBlock/>
+</Window>

+ 26 - 0
ColorfulEditor/MainWindow.xaml.cs

@@ -0,0 +1,26 @@
+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.Navigation;
+using System.Windows.Shapes;
+
+namespace ColorfulEditor {
+	/// <summary>
+	/// Interaction logic for MainWindow.xaml
+	/// </summary>
+	public partial class MainWindow : Window {
+		public MainWindow() {
+			InitializeComponent();
+
+		}
+
+		private void editor_TextChanged(object sender, TextChangedEventArgs e) {
+
+		}
+	}
+}

+ 66 - 0
ColorfulEditor/Themes/Generic.xaml

@@ -0,0 +1,66 @@
+<ResourceDictionary
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:cc="clr-namespace:ColorfulEditor.CustomControl">
+
+    <Style TargetType="{x:Type cc:ItemBlock}">
+        <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="{x:Type cc:ItemBlock}">
+                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
+                        <Grid>
+                            <Grid.RowDefinitions>
+                                <RowDefinition Height="auto"/>
+                                <RowDefinition Height="auto"/>
+                                <RowDefinition Height="auto"/>
+                            </Grid.RowDefinitions>
+                            <TextBox Grid.Row="0" DockPanel.Dock="Top" Background="Yellow" Text="{TemplateBinding Text}"></TextBox>
+                            <DockPanel Grid.Row="1" LastChildFill="True">
+                                <Border DockPanel.Dock="Left" Width="20" Background="Green"/>
+                                <ItemsPresenter DockPanel.Dock="Left"/>
+                            </DockPanel>
+                            <TextBox Grid.Row="2" DockPanel.Dock="Bottom" Background="blue">></TextBox>
+                        </Grid>
+                    </Border>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
+
+
+    <Style TargetType="{x:Type cc:MessageBlock}">
+        <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="{x:Type cc:MessageBlock}">
+                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
+                        <Grid>
+                            <Grid.RowDefinitions>
+                                <RowDefinition Height="auto"/>
+                                <RowDefinition Height="auto"/>
+                                <RowDefinition Height="auto"/>
+                            </Grid.RowDefinitions>
+                            <TextBox Grid.Row="0" DockPanel.Dock="Top" Background="Yellow" Text="{TemplateBinding Text}"></TextBox>
+                            <DockPanel Grid.Row="1" LastChildFill="True">
+                                <Border DockPanel.Dock="Left" Width="20" Background="Green"/>
+                                <ContentPresenter DockPanel.Dock="Left" Content="{TemplateBinding MessageBodyBlock}"/>
+                            </DockPanel>
+                            <TextBox Grid.Row="2" DockPanel.Dock="Bottom" Background="blue">></TextBox>
+                        </Grid>
+                    </Border>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
+
+    <Style TargetType="{x:Type cc:BlockEditor}">
+        <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="{x:Type cc:BlockEditor}">
+                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
+
+                    </Border>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
+</ResourceDictionary>