- 积分
- 6281
- 明经币
- 个
- 注册时间
- 2016-10-12
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
 - using System.Windows.Media;
- using HTJ.Arx.Service.Interface;
- using Point = System.Windows.Point;
- using Rect = System.Windows.Rect;
- namespace HTJ.Models;
- [AppHelper.Service]
- public partial class TestModel : ObservableObject, IUser
- {
- [NotifyPropertyChangedFor(nameof(NameStr))]
- [ObservableProperty] private string _name = "KZ";
- [NotifyPropertyChangedFor(nameof(NameStr))]
- [NotifyPropertyChangedFor(nameof(Geo))]
- [ObservableProperty] private double _value = 10;
-
- [NotifyPropertyChangedFor(nameof(RadiusCent))]
- [ObservableProperty] private double _radius = 10;
-
- [ObservableProperty] private double _thick = 10;
-
- [ObservableProperty] private double _ang = 10;
-
- [ObservableProperty] private double _x = 10;
- [ObservableProperty] private double _y = 10;
-
- public double RadiusCent => -0.5*Radius;
-
- public System.Windows.Media.Color Color { get; set; } = Colors.Blue;
- public string NameStr => Name + Value;
- public GeometryGroup Geo => GetGeo();
-
- private GeometryGroup GetGeo()
- {
- var geos = new GeometryGroup();
-
- // 添加多个几何图形到组中
- geos.Children.Add(new EllipseGeometry(new Point(50, 50), Value, 80));
-
-
- geos.Children.Add(new RectangleGeometry(new Rect(0, 0, 20, 20)));
-
- // 添加一条线
- var line = new LineGeometry(new Point(200, 200), new Point(300, 100));
- geos.Children.Add(line);
-
- // 添加自定义路径
- var customPath = new PathGeometry();
-
- var figure = new PathFigure();
- figure.StartPoint = new Point(150, 150);
- figure.Segments.Add(new LineSegment(new Point(200, 200), true));
- figure.Segments.Add(new LineSegment(new Point(100, 200), true));
- figure.IsClosed = true;
- figure.IsFilled = true;
- customPath.Figures.Add(figure);
-
- geos.Children.Add(customPath);
-
- return geos;
- }
- // 随机线条颜色
-
-
- }
 - <Window x:Class="HTJ.Views.TestView"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:vm="clr-namespace:HTJ.ViewModels"
- mc:Ignorable="d"
- Topmost="True"
- Title="TestView" Height="500" Width="400">
- <Window.DataContext>
- <vm:TestViewModel />
- </Window.DataContext>
- <Window.Resources>
- <ResourceDictionary>
- <ResourceDictionary.MergedDictionaries>
- <ResourceDictionary Source="..\styles\styles.xaml" />
- </ResourceDictionary.MergedDictionaries>
- </ResourceDictionary>
- </Window.Resources>
- <StackPanel Margin="10">
- <TextBox Margin="0,2" Text="{Binding VmData.Name,UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource LabelTextBox}" Height="30" Tag="字符串" />
- <TextBox Margin="0,2" Text="{Binding VmData.Value,UpdateSourceTrigger=PropertyChanged}" Height="30" Tag="100" />
- <Separator Height="20" Background="Red" />
- <StackPanel Orientation="Horizontal">
- <TextBlock Text="" FontSize="14" FontWeight="Bold" Margin="0,3" />
- <TextBlock Text="{Binding VmData.NameStr}" FontSize="14" FontWeight="Bold" Margin="0,3" HorizontalAlignment="Right" />
- </StackPanel>
- <Separator Height="20" Background="Red" />
- <StackPanel Orientation="Horizontal">
- <Button Content="拾取" Command="{Binding SelCommand}" />
- <Button Content="添加" Command="{Binding AddCommand}" />
- <Button Content="保存" Command="{Binding SaveCommand}" />
- <Button Content="重载" Command="{Binding ReadCommand}" />
- <Button Content="打开" Command="{Binding OpenCommand}" />
- <Button Content="渲染" Command="{Binding RenderCommand}" />
- <Button Content="停止" Command="{Binding StopCommand}" />
- </StackPanel>
- <Canvas Background="SandyBrown"
- Width="300" Height="300"
- HorizontalAlignment="Left"
- DataContext="{Binding VmData}">
- <TextBlock Text="{Binding NameStr}"
- Canvas.Left="{Binding X}"
- Canvas.Top="{Binding Y}"
- FontSize="15"
- FontStyle="Normal"
- FontWeight="Bold"
- Foreground="{Binding Color}">
- <TextBlock.RenderTransform>
- <RotateTransform Angle="{Binding Ang}"/>
- </TextBlock.RenderTransform>
- </TextBlock>
- <Ellipse Width="250" Height="250"
- Canvas.Left="150" Canvas.Top="150"
- StrokeThickness="1"
- Stroke="White">
- <Ellipse.RenderTransform>
- <TranslateTransform X="-125"
- Y="-125">
- </TranslateTransform>
- </Ellipse.RenderTransform>
- </Ellipse>
- <Ellipse Width="{Binding Radius}"
- Height="{Binding Radius}"
- Canvas.Left="150" Canvas.Top="150"
- StrokeThickness="{Binding Thick}"
- StrokeDashArray="1,4"
- Stroke="Red">
- <Ellipse.RenderTransform>
- <TranslateTransform X="{Binding RadiusCent}"
- Y="{Binding RadiusCent}">
- </TranslateTransform>
- </Ellipse.RenderTransform>
- </Ellipse>
- <Ellipse Width="2" Height="2"
- Canvas.Left="{Binding X}"
- Canvas.Top="{Binding Y}"
- StrokeThickness="5"
- Stroke="GreenYellow">
- <Ellipse.RenderTransform>
- <TranslateTransform X="-1"
- Y="-1">
- </TranslateTransform>
- </Ellipse.RenderTransform>
- </Ellipse>
- <Button Canvas.Right="10" Canvas.Top="10"
- Padding="10,5"
- BorderBrush="Transparent">
- </Button>
- <!-- <Path Data="{Binding Geo}" -->
- <!-- Stroke="Fuchsia" -->
- <!-- StrokeThickness="1" -->
- <!-- Fill="Red"></Path> -->
- </Canvas>
- </StackPanel>
- </Window>
 - namespace HTJ.Views;
- [AppHelper.Service]
- public partial class TestView
- {
- public TestView()
- {
- InitializeComponent();
- }
- //窗体关闭事件
- protected override void OnClosing(CancelEventArgs e)
- {
- e.Cancel = true;
- Hide();
- }
- }
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|