首页 > 其他分享 >WPF draw ellipse as array or matrix

WPF draw ellipse as array or matrix

时间:2024-06-03 20:00:17浏览次数:13  
标签:matrix Windows System MainWindow int Loaded using WPF array

<Window x:Class="WpfApp133.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:WpfApp133"
        mc:Ignorable="d" WindowState="Maximized"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <Canvas x:Name="cvs" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
    </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 WpfApp133
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            Loaded += MainWindow_Loaded;
            DrawEllipse();
        }

        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            int width = (int)this.ActualWidth;  
            int height = (int)this.ActualHeight;
            for(int i=0;i<width;i+=100)
            {
                for(int j=0;j<height;j+=100)
                {
                    Ellipse elp = new Ellipse();
                    elp.Width = 10;
                    elp.Height = 10;
                    elp.Fill = new SolidColorBrush(Colors.Red);
                    Canvas.SetLeft(elp, i);
                    Canvas.SetTop(elp, j);
                    cvs.Children.Add(elp);
                } 
            } 
        }

        private void DrawEllipse()
        {
           
        }
    }
}

 

标签:matrix,Windows,System,MainWindow,int,Loaded,using,WPF,array
From: https://www.cnblogs.com/Fred1987/p/18229527

相关文章

  • WPF DataGrid自动增长序号列
    ///<summary>///自动增长序号列///</summary>publicclassDataGridRowIndexColumn:DataGridTextColumn{///<summary>///可以指定开始序号///</summary>publicintStartIndex{get{return(int)GetValue(StartIndex......
  • WPF RenderTransform TransformGroup ScaleTransform TranslateTransform
    <Windowx:Class="WpfApp132.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft......
  • Leetcode 3171. Find Subarray With Bitwise AND Closest to K
    Leetcode3171.FindSubarrayWithBitwiseANDClosesttoK1.解题思路2.代码实现题目链接:3171.FindSubarrayWithBitwiseANDClosesttoK1.解题思路这道题坦率地说让我感觉很挫败,又一次没有自力搞定,是看了大佬们的答案才搞定的……知道比没有搞定更难受的......
  • 集合类源码浅析のArrayList
    源码分析路线图:初级部分:ArrayList->LinkedList->Vector->HashMap(红黑树数据结构,如何翻转,变色,手写红黑树)->ConcurrentHashMap中级部分:Spring->SpringMVC->SpringBoot->Mybatis核心类源码高级部分:中间件源码(有生之年系列)第一篇,从最简单的ArrayList入手分析1、成员变量......
  • Wpf 使用 Prism 开发MyToDo应用程序
    MyToDo是使用WPF,并且塔配Prism框架进行开发的项目。项目中进行了前后端分离设计,客户端所有的数据均通过API接口获取。适合新手入门学习WPF以及Prism框架使用。首页统计以及点击导航到相关模块功能待办事项增删改查功能备忘录增删改查功能登录注册功能系统设备主题颜......
  • wpf 中阿里图标库的使用
    阿里图标库的使用阿里图标库iconfont1.进入阿里图标库主界面后,根据需要搜索自己要用的图标,然后加入到购物车中2.打开“资源管理-我的项目”,进入我的项目界面,然后点击"下载至本地",把资源文件下载到本地3.引用资源(通过编码"&#xefdc"和ttf字体文件实现效果)效果......
  • C#WPF数字大屏项目实战06--报警信息
    1、ItemsControl简介 ItemsControl是用来表示一些条目集合的控件,所以它叫条目控件,它的成员是一些其它控件的集合,其继承关系如下:     其常用的派生控件为:ListBox、ListView、ComboBox,为ItemsControl的具体实现。   ItemsControl的成员条目可以为不同的类型,如自......
  • WPF快速创建绑定属性
    快速添加一个绑定属性,例如privatedouble_CurrentFontSize=12;publicdoubleCurrentFontSize{get{return_CurrentFontSize;}set{_CurrentFontSize=value;OnPropertyChanged("Cu......
  • WPF MVVM如何在ViewModel直接操作控件对象
    早些年在WPF中使用COM组件时,需要在ViewModel中操作COM组件中的控件对象,但是这个控件对象又不支持绑定,后面的解决办法是在窗口加载时,将控件对象以参数传递到Loaded事件的处理命令中,然后将这个对象记录下来,后面就可以直接操作这个控件了。今天同事在使用WebView2的时候,又遇到这个......
  • 在 Python 中转换为 np.array 时的内存饱和与内核重启
    在将处理过的数据转换为numpy数组时,我遇到了内存问题。我有57GB内存,但内存很快就饱和了,内核会在np.array(processed_X)处重启。以下是我的代码:importnumpyasnp导入scipy.signalfromskimage.transformimportresizefromtqdmimporttqdmdefapply_stft(signal,n......