WPF相对于Winform而言,在WPF中是用不同的容器安排布局。每个容器都有各自的布局逻辑,有的以堆栈方式布置有的以单元格排列元素。这也是WPF中比较有意思的,更容易入门。通过了解WPF布局之后能有个大概的WPF乐趣之处。
区别于Winform而言,Winform中使用刻板的基于坐标的布局将控件放到正确位置。在WPF中,使用流布局(flow)。能创建与显示分辨率和窗口大小无关的,在不同显示器正确缩放。
WPF窗口只能包含单个元素。在窗口放置一个容器,然后在该容器中添加其他元素。
WPF中,需要遵循以下几条重要原则:
WPF应该遵循这些原则,如果不遵循这些原则,最终将得到不是很适合WPF的并且难以维护的用户界面。
包含两个阶段:测量和排列。
测量阶段:容器遍历所有子元素,并询问子元素他们所期望的尺寸。
排列阶段:容器在合适的位置放置子元素。
所有WPF布局容器都派生于System.Windows.Controls.Panel抽象类的面板
WPF中提供了大量继承于Panel的类。这些类都位于System.Windows.Controls命名空间中
|
名 称 |
说 明 |
|
StackPanel |
在水平或垂直的堆栈中放置元素。通常用于更大、更复杂窗口中的一些小区域。 |
|
WrapPanel |
在一系列中可换行的行中放置元素 |
|
DockPanel |
根据元素的整个边界调整元素 |
|
Grid |
根据不可见的表格在行列中排列元素,也是最灵活最常用的容器之一 |
|
UniformGrid |
在不可见但是强制所在单元格具有相同尺寸放置元素,不常见 |
|
Canvas |
使用固定坐标绝对定位元素与Winform相似,没有提供锚定或停靠功能。 |
除了这些容器外,还有几个更专业的面板。如TabPanel面板、ToolbarPanel面板和VirtualizingStackPanel面板、InkCanvas控件等等。
StackPanel面板是嘴贱的布局容器之一。在单行或者单列中以堆栈方式放置其子元素。
<Window x:Class="Demo_Layout.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:Demo_Layout"
mc:Ignorable="d"
Title="MainWindow" Height="150" Width="200">
<StackPanel>
<Label Content="这个是StackPanel布局"/>
<Button Content="第一个按钮"/>
<Button Content="第二个按钮"/>
<Button Content="第三个按钮"/>
<Button Content="第四个按钮"/>
</StackPanel>
</Window>
界面如下

默认情况下,StackPanel面板按照自上而下顺序排列元素,使每个元素的高度适合它的内容。在上个Demo中,所有元素都被拉伸到整个程序的宽度,如果加宽从窗口,StackPanel也会变宽,里边对应的元素也会拉伸自身。
Orientation属性:可以使面板水平排列元素
<StackPanel Orientation="Horizontal">
界面如下

根据窗口的当前大小可能导致一些元素不适应、
|
名 称 |
说 明 |
|
HorizontalAlignment |
水平方向有额外空间时,该属性决定了子元素在布局容器中如何定位,可选有Center Left Right Stretch等属性 |
|
VerticalAlignment |
垂直方向有额外空间时,该属性决定了子元素在布局容器中如何定位,可选有Center Left Right Stretch等属性 |
|
Margin |
设置对应边距,顺序分别为左上右下,如果两个的话为左右、上下 |
|
MinWidth和MinHeight |
设置元素的最小尺寸 |
|
MaxWidth和MaxHeight |
设置元素的最大尺寸 |
|
Width和Height |
设置元素的尺寸,宽度和高度,不能超过设置的最大值和最小值 |
所有的属性都从FrameworkElement基类继承而来。所以在WPF窗口中所使用的的所有图形小组件都支持这些属性。
对齐方式可以通过下述代码来实现,对齐方式可以分为Left Right Center Stretch
<StackPanel>
<Label HorizontalAlignment="Center" Content="这个是StackPanel布局"/>
<Button HorizontalAlignment="Left" Content="第一个按钮"/>
<Button HorizontalAlignment="Right" Content="第二个按钮"/>
<Button Content="第三个按钮"/>
<Button Content="第四个按钮"/>
</StackPanel>
界面如下

可以看到第一个元素居中,第二个元素居左,第三个元素居右。
当我们设置对应第四个元素的Margin属性时,可以看到对应边距
<Button Margin="10" Content="第三个按钮"/>
上下左右边距分别为10个元素

当设置为10,5时
<Button Margin="10,5" Content="第三个按钮"/>
界面如下

当设置为四个元素时
<Button Margin="20,15,10,5" Content="第三个按钮"/>
界面如下

综上所述,当我们这只对应边距(Margin)时,可以分别设置为1,2,4时分别为:
一个时:上下左右分别为对应间距
两个时:左右为第一个、上下为第二个
四个时:分别为左上右下
最小尺寸设置为100时,最大尺寸设置为150时,代码和界面
<Button MinWidth="100" MaxWidth="150" Content="第四个按钮"/>


最小尺寸为每个按钮的尺寸始终不能小于最小尺寸
最大尺寸为不能超过最大尺寸
如果最小宽度大于容器宽度时,按钮一部分将被裁剪掉。否则不允许按钮比Panel面板更宽
WrapPanel面板以一次一行或者一列方式部署控件。默认情况下,WrapPanel的Orientation属性为Horizontal,控件从左向右进行排列,再在下一行中排列。将其属性设置为Vertical,从而在多个列中放置元素。
代码和界面
<Window x:Class="Demo_Layout.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:Demo_Layout"
mc:Ignorable="d"
Title="MainWindow" Height="250" Width="400">
<WrapPanel Margin="3">
<Button VerticalAlignment="Top" Content="第一个按钮"/>
<Button MinHeight="50" Content="第二个按钮"/>
<Button VerticalAlignment="Bottom" Content="第三个按钮"/>
<Button Content="第四个按钮"/>
<Button VerticalAlignment="Center" Content="第五个按钮"/>
</WrapPanel>
</Window>
界面如下

WrapPanel是唯一一个不能通过灵活使用Grid面板代替的容器
DockPanel沿着一条外边缘来拉伸所包含的控件。通过对应的附加属性选择靠边,可将对应属性设置为Left,Right,Top,和Bottom。放在DockPanel面板的每个元素都会自动获取该属性。
代码和界面如下
<Window x:Class="Demo_Layout.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:Demo_Layout"
mc:Ignorable="d"
Title="MainWindow" Height="250" Width="400">
<DockPanel>
<Button DockPanel.Dock="Top" Content="上边按钮"/>
<Button DockPanel.Dock="Left" Content="左边按钮"/>
<Button DockPanel.Dock="Right" Content="右边按钮"/>
<Button DockPanel.Dock="Bottom" Content="下边按钮"/>
<Button Content="默认充满的按钮"/>
</DockPanel>
</Window>
界面如下

如果说对应一个里边包含了多个元素可以分别设置
<Window x:Class="Demo_Layout.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:Demo_Layout"
mc:Ignorable="d"
Title="MainWindow" Height="250" Width="400">
<DockPanel>
<StackPanel DockPanel.Dock="Top">
<Button Content="上边按钮"/>
<Button HorizontalAlignment="Left" Content="上边按钮2"/>
<Button HorizontalAlignment="Right" Content="上边按钮3"/>
</StackPanel>
<Button DockPanel.Dock="Left" Content="左边按钮"/>
<Button DockPanel.Dock="Right" Content="右边按钮"/>
<Button DockPanel.Dock="Bottom" Content="下边按钮"/>
<Button Content="默认充满的按钮"/>
</DockPanel>
</Window>
界面如下

布局容器也是可以嵌套的。如创建一个标准对话框,右下角为确认和返回按钮,并在剩余部分创建对应文字说明。
1 - 创建StackPanel,将亮哥按钮放置一块
2 - 在DockPanel放置StackPanel 并停靠下边
3 - 将DockPanel的LastChildFill设置为True
4 - 设置边距属性,提供一定的空白空间
如下代码
<Window x:Class="Demo_Layout.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:Demo_Layout"
mc:Ignorable="d"
Title="MainWindow" Height="150" Width="200">
<DockPanel LastChildFill="True">
<Border Margin="10" DockPanel.Dock="Top" BorderBrush="Orange" BorderThickness="2" >
<TextBlock TextWrapping="Wrap" Height="80" Text="月明星稀,乌鹊南飞,此非曹孟德之诗乎?"/>
</Border>
<StackPanel DockPanel.Dock="Bottom" HorizontalAlignment="Right" Orientation="Horizontal">
<Button Padding="3" Content="确认"/>
<Button Padding="3" Content="取消"/>
</StackPanel>
</DockPanel>
</Window>
界面如下

Grid是WPF中最强大的布局容器。很多使用其他完成的用Grid都可以完成。Grid是可以将面板分为几行几列的网格。Grid虽然不可见但是可以将Grid.ShowGridLines属性设置为True。方便调试。
创建Grid需要设置对应的行列,随后填充对应内容。
<Window x:Class="Demo_Layout.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:Demo_Layout"
mc:Ignorable="d"
Title="MainWindow" Height="150" Width="200">
<Grid ShowGridLines="True">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
</Grid>
</Window>
界面如下

这是Grid的布局,此时我们可以开始向Grid中填充元素。比如我们向第二行第三列中添加一个显示内容为"点击我"的按钮
<Button Content="点击我" Grid.Column="2" Grid.Row="1"/>
界面如下

调整行和列
Grid面板支持三种设置尺寸的方式:
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="1.5*"/>
<RowDefinition Height="2.5*"/>
</Grid.RowDefinitions>

自动设置
<Window x:Class="Demo_Layout.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:Demo_Layout"
mc:Ignorable="d"
Title="MainWindow" Height="150" Width="200">
<Grid ShowGridLines="True">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBox Margin="10" Grid.Row="0" Text="这是一个测试的"/>
<StackPanel Grid.Row="1" HorizontalAlignment="Right" Orientation="Horizontal">
<Button Margin="10,10,2,10" Padding="3" Content="确 认"/>
<Button Margin="2,10,10,10" Padding="3" Content="取 消"/>
</StackPanel>
</Grid>
</Window>
界面如下

UniformGrid不同于Grid 不需要设置对应行列,设置简单Rows和Columns来设置尺寸即可。
比如:
<Window x:Class="Demo_Layout.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:Demo_Layout"
mc:Ignorable="d"
Title="MainWindow" Height="150" Width="200">
<UniformGrid Rows="3" Columns="3">
<Button Content="1"/>
<Button Content="2"/>
<Button Content="3"/>
<Button Content="4"/>
<Button Content="5"/>
<Button Content="6"/>
<Button Content="7"/>
<Button Content="8"/>
<Button Content="9"/>
</UniformGrid>
</Window>
界面如下

Canvas面板允许使用精确的坐标放置元素。需要设置Canvas.Left和Canvas.Top附加属性,Left属性设置元素左边和Canvas面板左边之间的单位数。从左上角(0,0)开始到右下角分别为X,Y。
如下代码:
<Window x:Class="Demo_Layout.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:Demo_Layout"
mc:Ignorable="d"
Title="MainWindow" Height="150" Width="240">
<Canvas>
<Button Canvas.Left="10" Canvas.Top="10" Content="(10,10)"/>
<Button Canvas.Left="40" Canvas.Top="60" Content="(40,60)"/>
<Button Canvas.Left="100" Canvas.Top="20" Content="(100,20)"/>
<Button Canvas.Left="140" Canvas.Top="90" Content="(140,90)"/>
</Canvas>
</Window>
界面如下:

按照画布的坐标点布局。
其中Z顺序
<Button Canvas.Left="10" Panel.ZIndex="0" Canvas.Top="10" Content="(10,10)1"/>
<Button Canvas.Left="10" Panel.ZIndex="1" Canvas.Top="10" Content="(10,10)2"/>
同样的坐标体系,当ZIndex较大时,才会显示在最顶层。当设置第一个元素的ZIndex为2时,界面显示的名称是“(10,10)1”
行列设置:
<Window x:Class="Demo_Layout.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:Demo_Layout"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="300">
<Grid Margin="10,3,10,10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<!--第一行-->
<Label Grid.Row="0" Grid.Column="0" Margin="3" Content="主页:" VerticalAlignment="Center"/>
<TextBox Grid.Row="0" Grid.Column="1" Margin="3" Height="Auto" VerticalAlignment="Center"/>
<Button Grid.Column="2" Grid.Row="0" Content="选择路径" Margin="3" Padding="2" Height="Auto" VerticalAlignment="Center"/>
<!--第二行-->
<Label Grid.Row="1" Grid.Column="0" Margin="3" Content="系统设置表:" VerticalAlignment="Center"/>
<TextBox Grid.Row="1" Grid.Column="1" Margin="3" Height="Auto" VerticalAlignment="Center"/>
<Button Grid.Column="2" Grid.Row="1" Content="选择路径" Margin="3" Padding="2" Height="Auto" VerticalAlignment="Center"/>
<!--第三行-->
<Label Grid.Row="2" Grid.Column="0" Margin="3" Content="人员信息表:" VerticalAlignment="Center"/>
<TextBox Grid.Row="2" Grid.Column="1" Margin="3" Height="Auto" VerticalAlignment="Center"/>
<Button Grid.Column="2" Grid.Row="2" Content="选择路径" Margin="3" Padding="2" Height="Auto" VerticalAlignment="Center"/>
<!--第四行-->
<Label Grid.Row="3" Grid.Column="0" Margin="3" Content="权限信息表:" VerticalAlignment="Center"/>
<TextBox Grid.Row="3" Grid.Column="1" Margin="3" Height="Auto" VerticalAlignment="Center"/>
<Button Grid.Column="2" Grid.Row="3" Content="选择路径" Margin="3" Padding="2" Height="Auto" VerticalAlignment="Center"/>
</Grid>
</Window>
界面如下:

Demo2
<Window x:Class="Demo_Layout.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:Demo_Layout"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="300">
<Grid Margin="10,3,10,10">
<TabControl>
<TabItem Header="第一页">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="7*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0">
<Label Content="住院号:" VerticalAlignment="Center"/>
<TextBox Height="Auto" HorizontalAlignment="Center" Width="150" Margin="0,5"/>
<Button VerticalAlignment="Center" Content="查 询" Height="Auto" Margin="5,5" Width="50"/>
</StackPanel>
<DataGrid Grid.Row="1">
<DataGrid.Columns>
<DataGridTextColumn Header="住院号" Width="80"/>
<DataGridTextColumn Header="姓名" Width="90"/>
<DataGridTextColumn Header="是否启用" Width="Auto"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
</TabItem>
<TabItem Header="第二页"/>
</TabControl>
</Grid>
</Window>
界面

是否可以为特定(或所有)项目使用多个布局?例如,我有几个项目,我想对其应用两种不同的布局。一个是绿色的,一个是蓝色的(但是)。我想将它们编译到我的输出目录中的两个不同文件夹中(例如v1和v2)。我一直在玩弄规则和编译block,但我不知道这是怎么回事。因为,每个项目在编译过程中只编译一次,我不能告诉nanoc第一次用layout1编译,第二次用layout2编译。我试过这样的东西,但它导致输出文件损坏。compile'*'doifitem.binary?#don’tfilterbinaryitemselsefilter:erblayout'layout1'layout'layout2'
目录前言滤波电路科普主要分类实际情况单位的概念常用评价参数函数型滤波器简单分析滤波电路构成低通滤波器RC低通滤波器RL低通滤波器高通滤波器RC高通滤波器RL高通滤波器部分摘自《LC滤波器设计与制作》,侵权删。前言最近需要学习放大电路和滤波电路,但是由于只在之前做音乐频谱分析仪的时候简单了解过一点点运放,所以也是相当从零开始学习了。滤波电路科普主要分类滤波器:主要是从不同频率的成分中提取出特定频率的信号。有源滤波器:由RC元件与运算放大器组成的滤波器。可滤除某一次或多次谐波,最普通易于采用的无源滤波器结构是将电感与电容串联,可对主要次谐波(3、5、7)构成低阻抗旁路。无源滤波器:无源滤波器,又称
最近在学习CAN,记录一下,也供大家参考交流。推荐几个我觉得很好的CAN学习,本文也是在看了他们的好文之后做的笔记首先是瑞萨的CAN入门,真的通透;秀!靠这篇我竟然2天理解了CAN协议!实战STM32F4CAN!原文链接:https://blog.csdn.net/XiaoXiaoPengBo/article/details/116206252CAN详解(小白教程)原文链接:https://blog.csdn.net/xwwwj/article/details/105372234一篇易懂的CAN通讯协议指南1一篇易懂的CAN通讯协议指南1-知乎(zhihu.com)视频推荐CAN总线个人知识总
深度学习部署:Windows安装pycocotools报错解决方法1.pycocotools库的简介2.pycocotools安装的坑3.解决办法更多Ai资讯:公主号AiCharm本系列是作者在跑一些深度学习实例时,遇到的各种各样的问题及解决办法,希望能够帮助到大家。ERROR:Commanderroredoutwithexitstatus1:'D:\Anaconda3\python.exe'-u-c'importsys,setuptools,tokenize;sys.argv[0]='"'"'C:\\Users\\46653\\AppData\\Local\\Temp\\pip-instal
我完全不是程序员,正在学习使用Ruby和Rails框架进行编程。我目前正在使用Ruby1.8.7和Rails3.0.3,但我想知道我是否应该升级到Ruby1.9,因为我真的没有任何升级的“遗留”成本。缺点是什么?我是否会遇到与普通gem的兼容性问题,或者甚至其他我不太了解甚至无法预料的问题? 最佳答案 你应该升级。不要坚持从1.8.7开始。如果您发现不支持1.9.2的gem,请避免使用它们(因为它们很可能不被维护)。如果您对gem是否兼容1.9.2有任何疑问,您可以在以下位置查看:http://www.railsplugins.or
如何学习ruby的正则表达式?(对于假人) 最佳答案 http://www.rubular.com/在Ruby中使用正则表达式时是一个很棒的工具,因为它可以立即将结果可视化。 关于ruby-我如何学习ruby的正则表达式?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/1881231/
深度学习12.CNN经典网络VGG16一、简介1.VGG来源2.VGG分类3.不同模型的参数数量4.3x3卷积核的好处5.关于学习率调度6.批归一化二、VGG16层分析1.层划分2.参数展开过程图解3.参数传递示例4.VGG16各层参数数量三、代码分析1.VGG16模型定义2.训练3.测试一、简介1.VGG来源VGG(VisualGeometryGroup)是一个视觉几何组在2014年提出的深度卷积神经网络架构。VGG在2014年ImageNet图像分类竞赛亚军,定位竞赛冠军;VGG网络采用连续的小卷积核(3x3)和池化层构建深度神经网络,网络深度可以达到16层或19层,其中VGG16和VGG
文章目录1、自相关函数ACF2、偏自相关函数PACF3、ARIMA(p,d,q)的阶数判断4、代码实现1、引入所需依赖2、数据读取与处理3、一阶差分与绘图4、ACF5、PACF1、自相关函数ACF自相关函数反映了同一序列在不同时序的取值之间的相关性。公式:ACF(k)=ρk=Cov(yt,yt−k)Var(yt)ACF(k)=\rho_{k}=\frac{Cov(y_{t},y_{t-k})}{Var(y_{t})}ACF(k)=ρk=Var(yt)Cov(yt,yt−k)其中分子用于求协方差矩阵,分母用于计算样本方差。求出的ACF值为[-1,1]。但对于一个平稳的AR模型,求出其滞
写在之前Shader变体、Shader属性定义技巧、自定义材质面板,这三个知识点任何一个单拿出来都是一套知识体系,不能一概而论,本文章目的在于将学习和实际工作中遇见的问题进行总结,类似于网络笔记之用,方便后续回顾查看,如有以偏概全、不祥不尽之处,还望海涵。1、Shader变体先看一段代码......Properties{ [KeywordEnum(on,off)]USL_USE_COL("IsUseColorMixTex?",int)=0 [Toggle(IS_RED_ON)]_IsRed("IsRed?",int)=0}......//中间省略,后续会有完整代码 #pragmamulti_c
TCL脚本语言简介•TCL(ToolCommandLanguage)是一种解释执行的脚本语言(ScriptingLanguage),它提供了通用的编程能力:支持变量、过程和控制结构;同时TCL还拥有一个功能强大的固有的核心命令集。TCL经常被用于快速原型开发,脚本编程,GUI和测试等方面。•实际上包含了两个部分:一个语言和一个库。首先,Tcl是一种简单的脚本语言,主要使用于发布命令给一些互交程序如文本编辑器、调试器和shell。由于TCL的解释器是用C\C++语言的过程库实现的,因此在某种意义上我们又可以把TCL看作C库,这个库中有丰富的用于扩展TCL命令的C\C++过程和函数,所以,Tcl是