zoukankan      html  css  js  c++  java
  • 如何绘制与配置2D图形界面

    <Window x:Class="WpfApplication1.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="521.082" Width="525">
        <Grid Name="grid">
            <Line Name="line" X1="10" Y1="10" X2="100" Y2="100" Stroke="Black" VerticalAlignment="Center"></Line>
            <Ellipse Name="ellipse" Fill="Red" HorizontalAlignment="Left" Height="112" Margin="187,66,0,0" Stroke="Black" VerticalAlignment="Top" Width="167"/>
            <Button Content="Button" HorizontalAlignment="Left" Margin="53,73,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_1"/>
            <Canvas HorizontalAlignment="Left" Height="156" Margin="189,313,0,0" VerticalAlignment="Top" Width="158">
                <Ellipse Height="100" Canvas.Left="31" Stroke="Black" Canvas.Top="29" Width="100"/>
            </Canvas>
            <Path Stroke="Red" StrokeThickness="5" Data="M30,30 Q 60,30 30,90"></Path>
            <Polygon Stroke="Blue" StrokeThickness="4" Points="40,100 80,120 60,160">
                <Polygon.Fill>
                    <SolidColorBrush Color="Yellow"></SolidColorBrush>
                </Polygon.Fill>
            </Polygon>
            <Canvas Width="100" Height="100">
                <Ellipse Fill="Yellow" Stroke="Black"
                        StrokeThickness="7"
                        Width="100" Height="100"></Ellipse>
                <Ellipse Fill="Black" Width="10" Height="15"
                         Canvas.Left="28" Canvas.Top="28"></Ellipse>
                <Ellipse Fill="Black" x:Name="myEllipse"
                         Width="10" Height="15"
                         Canvas.Left="62" Canvas.Top="28"></Ellipse>
                <Path Stroke="Black" StrokeThickness="6" Data="M30,60 Q 50,90 70,60"></Path>
            </Canvas>
        </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.Navigation;
    using System.Windows.Shapes;
    
    namespace WpfApplication1
    {
        /// <summary>
        /// MainWindow.xaml 的交互逻辑
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }
    
            private void Button_Click_1(object sender, RoutedEventArgs e)
            {
                Line l1 = new Line();
                l1.X1 = 100;
                l1.Y1 = 100;
                l1.X2 = 500;
                l1.Y2 = 100;
                l1.Stroke = new SolidColorBrush(Color.FromRgb(0,0,225));
                l1.StrokeThickness = 2;
                grid.Children.Add(l1);
    
                ellipse.Height = 218;
                
            }
    
        }
    }

  • 相关阅读:
    linux删除目录的命令
    Windows XP下git通过代理下载android代码
    白话算法希尔排序
    操作系统——存储技术
    如何理解Linus Torvalds的“什么才是优秀程序员”的话
    程序员自我修养读书随笔——目标文件
    面试求职:大数据处理总结
    持久化与Session定义
    java中byte转换int时为何与0xff进行与运算
    OSI七层相关协议
  • 原文地址:https://www.cnblogs.com/hushzhang/p/5895414.html
Copyright © 2011-2022 走看看