Pārlūkot izejas kodu

180更新

样式分支
taoye pirms 2 gadiem
vecāks
revīzija
67c1bf32ec
8 mainītis faili ar 886 papildinājumiem un 3 dzēšanām
  1. +2
    -1
      BPASmartClient.CustomResource/Pages/Model/UserManager.cs
  2. +7
    -1
      FryPot_DosingSystem/App.xaml.cs
  3. +2
    -1
      FryPot_DosingSystem/FryPot_DosingSystem.csproj
  4. +391
    -0
      FryPot_DosingSystem/Resources/fonts/demo_index.html
  5. Binārs
     
  6. +376
    -0
      FryPot_DosingSystem/View/UserManageView.xaml
  7. +28
    -0
      FryPot_DosingSystem/View/UserManageView.xaml.cs
  8. +80
    -0
      FryPot_DosingSystem/ViewModel/UserManageViewModel.cs

+ 2
- 1
BPASmartClient.CustomResource/Pages/Model/UserManager.cs Parādīt failu

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -8,6 +9,6 @@ namespace BPASmartClient.CustomResource.Pages.Model
{
public class UserManager
{
public List<UserInfo> userInfos { get; set; } = new List<UserInfo>();
public ObservableCollection<UserInfo> userInfos { get; set; } = new ObservableCollection<UserInfo>();
}
}

+ 7
- 1
FryPot_DosingSystem/App.xaml.cs Parādīt failu

@@ -184,7 +184,13 @@ namespace FryPot_DosingSystem
AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.PasswordChangeView"
});

UserManager.Add(new SubMenumodel()
{
SubMenuName = "账号管理",
SubMenuPermission = new Permission[] { Permission.管理员 },
AssemblyName = "FryPot_DosingSystem",
ToggleWindowPath = "View.UserManageView"
});

MenuManage.GetInstance.menuModels.Add(new MenuModel()
{


+ 2
- 1
FryPot_DosingSystem/FryPot_DosingSystem.csproj Parādīt failu

@@ -10,6 +10,7 @@

<ItemGroup>
<None Remove="hbl.ico" />
<None Remove="Resources\fonts\iconfont.ttf" />
</ItemGroup>

<ItemGroup>
@@ -32,7 +33,7 @@
</ItemGroup>

<ItemGroup>
<Folder Include="Images\" />
<Resource Include="Resources\fonts\iconfont.ttf" />
</ItemGroup>

</Project>

+ 391
- 0
FryPot_DosingSystem/Resources/fonts/demo_index.html Parādīt failu

@@ -0,0 +1,391 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>iconfont Demo</title>
<link rel="shortcut icon" href="//img.alicdn.com/imgextra/i2/O1CN01ZyAlrn1MwaMhqz36G_!!6000000001499-73-tps-64-64.ico" type="image/x-icon"/>
<link rel="icon" type="image/svg+xml" href="//img.alicdn.com/imgextra/i4/O1CN01EYTRnJ297D6vehehJ_!!6000000008020-55-tps-64-64.svg"/>
<link rel="stylesheet" href="https://g.alicdn.com/thx/cube/1.3.2/cube.min.css">
<link rel="stylesheet" href="demo.css">
<link rel="stylesheet" href="iconfont.css">
<script src="iconfont.js"></script>
<!-- jQuery -->
<script src="https://a1.alicdn.com/oss/uploads/2018/12/26/7bfddb60-08e8-11e9-9b04-53e73bb6408b.js"></script>
<!-- 代码高亮 -->
<script src="https://a1.alicdn.com/oss/uploads/2018/12/26/a3f714d0-08e6-11e9-8a15-ebf944d7534c.js"></script>
<style>
.main .logo {
margin-top: 0;
height: auto;
}

.main .logo a {
display: flex;
align-items: center;
}

.main .logo .sub-title {
margin-left: 0.5em;
font-size: 22px;
color: #fff;
background: linear-gradient(-45deg, #3967FF, #B500FE);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
</style>
</head>
<body>
<div class="main">
<h1 class="logo"><a href="https://www.iconfont.cn/" title="iconfont 首页" target="_blank">
<img width="200" src="https://img.alicdn.com/imgextra/i3/O1CN01Mn65HV1FfSEzR6DKv_!!6000000000514-55-tps-228-59.svg">
</a></h1>
<div class="nav-tabs">
<ul id="tabs" class="dib-box">
<li class="dib active"><span>Unicode</span></li>
<li class="dib"><span>Font class</span></li>
<li class="dib"><span>Symbol</span></li>
</ul>
</div>
<div class="tab-container">
<div class="content unicode" style="display: block;">
<ul class="icon_lists dib-box">
<li class="dib">
<span class="icon iconfont">&#xe668;</span>
<div class="name">账号信息</div>
<div class="code-name">&amp;#xe668;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe695;</span>
<div class="name">窗口-最大化_line</div>
<div class="code-name">&amp;#xe695;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe62b;</span>
<div class="name">密码</div>
<div class="code-name">&amp;#xe62b;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe62c;</span>
<div class="name">权限配置</div>
<div class="code-name">&amp;#xe62c;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe669;</span>
<div class="name">close</div>
<div class="code-name">&amp;#xe669;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe67a;</span>
<div class="name">minus</div>
<div class="code-name">&amp;#xe67a;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe6a0;</span>
<div class="name">账号中心 账号管理</div>
<div class="code-name">&amp;#xe6a0;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe979;</span>
<div class="name">齿轮,设置,设定</div>
<div class="code-name">&amp;#xe979;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe6b7;</span>
<div class="name">面性密码锁</div>
<div class="code-name">&amp;#xe6b7;</div>
</li>
</ul>
<div class="article markdown">
<h2 id="unicode-">Unicode 引用</h2>
<hr>

<p>Unicode 是字体在网页端最原始的应用方式,特点是:</p>
<ul>
<li>支持按字体的方式去动态调整图标大小,颜色等等。</li>
<li>默认情况下不支持多色,直接添加多色图标会自动去色。</li>
</ul>
<blockquote>
<p>注意:新版 iconfont 支持两种方式引用多色图标:SVG symbol 引用方式和彩色字体图标模式。(使用彩色字体图标需要在「编辑项目」中开启「彩色」选项后并重新生成。)</p>
</blockquote>
<p>Unicode 使用步骤如下:</p>
<h3 id="-font-face">第一步:拷贝项目下面生成的 <code>@font-face</code></h3>
<pre><code class="language-css"
>@font-face {
font-family: 'iconfont';
src: url('iconfont.ttf?t=1658305362348') format('truetype');
}
</code></pre>
<h3 id="-iconfont-">第二步:定义使用 iconfont 的样式</h3>
<pre><code class="language-css"
>.iconfont {
font-family: "iconfont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
</code></pre>
<h3 id="-">第三步:挑选相应图标并获取字体编码,应用于页面</h3>
<pre>
<code class="language-html"
>&lt;span class="iconfont"&gt;&amp;#x33;&lt;/span&gt;
</code></pre>
<blockquote>
<p>"iconfont" 是你项目下的 font-family。可以通过编辑项目查看,默认是 "iconfont"。</p>
</blockquote>
</div>
</div>
<div class="content font-class">
<ul class="icon_lists dib-box">
<li class="dib">
<span class="icon iconfont icon-zhanghaoxinxi"></span>
<div class="name">
账号信息
</div>
<div class="code-name">.icon-zhanghaoxinxi
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-window-max_line"></span>
<div class="name">
窗口-最大化_line
</div>
<div class="code-name">.icon-window-max_line
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-mima"></span>
<div class="name">
密码
</div>
<div class="code-name">.icon-mima
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-quanxianpeizhi"></span>
<div class="name">
权限配置
</div>
<div class="code-name">.icon-quanxianpeizhi
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-close"></span>
<div class="name">
close
</div>
<div class="code-name">.icon-close
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-minus"></span>
<div class="name">
minus
</div>
<div class="code-name">.icon-minus
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-zhanghaozhongxinzhanghaoguanli"></span>
<div class="name">
账号中心 账号管理
</div>
<div class="code-name">.icon-zhanghaozhongxinzhanghaoguanli
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-set"></span>
<div class="name">
齿轮,设置,设定
</div>
<div class="code-name">.icon-set
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-mianxingmima"></span>
<div class="name">
面性密码锁
</div>
<div class="code-name">.icon-mianxingmima
</div>
</li>
</ul>
<div class="article markdown">
<h2 id="font-class-">font-class 引用</h2>
<hr>

<p>font-class 是 Unicode 使用方式的一种变种,主要是解决 Unicode 书写不直观,语意不明确的问题。</p>
<p>与 Unicode 使用方式相比,具有如下特点:</p>
<ul>
<li>相比于 Unicode 语意明确,书写更直观。可以很容易分辨这个 icon 是什么。</li>
<li>因为使用 class 来定义图标,所以当要替换图标时,只需要修改 class 里面的 Unicode 引用。</li>
</ul>
<p>使用步骤如下:</p>
<h3 id="-fontclass-">第一步:引入项目下面生成的 fontclass 代码:</h3>
<pre><code class="language-html">&lt;link rel="stylesheet" href="./iconfont.css"&gt;
</code></pre>
<h3 id="-">第二步:挑选相应图标并获取类名,应用于页面:</h3>
<pre><code class="language-html">&lt;span class="iconfont icon-xxx"&gt;&lt;/span&gt;
</code></pre>
<blockquote>
<p>"
iconfont" 是你项目下的 font-family。可以通过编辑项目查看,默认是 "iconfont"。</p>
</blockquote>
</div>
</div>
<div class="content symbol">
<ul class="icon_lists dib-box">
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-zhanghaoxinxi"></use>
</svg>
<div class="name">账号信息</div>
<div class="code-name">#icon-zhanghaoxinxi</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-window-max_line"></use>
</svg>
<div class="name">窗口-最大化_line</div>
<div class="code-name">#icon-window-max_line</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-mima"></use>
</svg>
<div class="name">密码</div>
<div class="code-name">#icon-mima</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-quanxianpeizhi"></use>
</svg>
<div class="name">权限配置</div>
<div class="code-name">#icon-quanxianpeizhi</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-close"></use>
</svg>
<div class="name">close</div>
<div class="code-name">#icon-close</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-minus"></use>
</svg>
<div class="name">minus</div>
<div class="code-name">#icon-minus</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-zhanghaozhongxinzhanghaoguanli"></use>
</svg>
<div class="name">账号中心 账号管理</div>
<div class="code-name">#icon-zhanghaozhongxinzhanghaoguanli</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-set"></use>
</svg>
<div class="name">齿轮,设置,设定</div>
<div class="code-name">#icon-set</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-mianxingmima"></use>
</svg>
<div class="name">面性密码锁</div>
<div class="code-name">#icon-mianxingmima</div>
</li>
</ul>
<div class="article markdown">
<h2 id="symbol-">Symbol 引用</h2>
<hr>

<p>这是一种全新的使用方式,应该说这才是未来的主流,也是平台目前推荐的用法。相关介绍可以参考这篇<a href="">文章</a>
这种用法其实是做了一个 SVG 的集合,与另外两种相比具有如下特点:</p>
<ul>
<li>支持多色图标了,不再受单色限制。</li>
<li>通过一些技巧,支持像字体那样,通过 <code>font-size</code>, <code>color</code> 来调整样式。</li>
<li>兼容性较差,支持 IE9+,及现代浏览器。</li>
<li>浏览器渲染 SVG 的性能一般,还不如 png。</li>
</ul>
<p>使用步骤如下:</p>
<h3 id="-symbol-">第一步:引入项目下面生成的 symbol 代码:</h3>
<pre><code class="language-html">&lt;script src="./iconfont.js"&gt;&lt;/script&gt;
</code></pre>
<h3 id="-css-">第二步:加入通用 CSS 代码(引入一次就行):</h3>
<pre><code class="language-html">&lt;style&gt;
.icon {
width: 1em;
height: 1em;
vertical-align: -0.15em;
fill: currentColor;
overflow: hidden;
}
&lt;/style&gt;
</code></pre>
<h3 id="-">第三步:挑选相应图标并获取类名,应用于页面:</h3>
<pre><code class="language-html">&lt;svg class="icon" aria-hidden="true"&gt;
&lt;use xlink:href="#icon-xxx"&gt;&lt;/use&gt;
&lt;/svg&gt;
</code></pre>
</div>
</div>

</div>
</div>
<script>
$(document).ready(function () {
$('.tab-container .content:first').show()

$('#tabs li').click(function (e) {
var tabContent = $('.tab-container .content')
var index = $(this).index()

if ($(this).hasClass('active')) {
return
} else {
$('#tabs li').removeClass('active')
$(this).addClass('active')

tabContent.hide().eq(index).fadeIn()
}
})
})
</script>
</body>
</html>

Binārs
Parādīt failu


+ 376
- 0
FryPot_DosingSystem/View/UserManageView.xaml Parādīt failu

@@ -0,0 +1,376 @@
<UserControl x:Class="FryPot_DosingSystem.View.UserManageView"
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:local="clr-namespace:FryPot_DosingSystem.View"
xmlns:vm="clr-namespace:FryPot_DosingSystem.ViewModel"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
xmlns:theme="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero2">
<UserControl.DataContext>
<vm:UserManageViewModel/>
</UserControl.DataContext>
<UserControl.Resources>
<Style x:Key="dgCell" TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<Style x:Key="btnStyle" TargetType="Button">
<Setter Property="Width" Value="auto"/>
<Setter Property="FontSize" Value="16"/>
<Setter Property="Foreground" Value="SkyBlue"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="SkyBlue"/>
</Style>
<Style TargetType="DataGrid" x:Key="dataGrid">
<!--网格线颜色-->
<Setter Property="CanUserResizeColumns" Value="false"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"></Setter>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"></Setter>
<Setter Property="HeadersVisibility" Value="Column"/>
<Setter Property="HorizontalGridLinesBrush">
<Setter.Value>
<SolidColorBrush Color="#03ffea"/>
</Setter.Value>
</Setter>
<Setter Property="VerticalGridLinesBrush">
<Setter.Value>
<SolidColorBrush Color="#03ffea"/>
</Setter.Value>
</Setter>

</Style>

<Style x:Key="columsHeader" TargetType="DataGridColumnHeader">
<Setter Property="HorizontalContentAlignment" Value="Center"></Setter>
<Setter Property="Background" Value="Transparent"></Setter>
<Setter Property="Foreground" Value="#17acae"></Setter>
<Setter Property="BorderThickness" Value="1"></Setter>
<Setter Property="BorderBrush" Value="#03ffea"></Setter>
<Setter Property="Height" Value="45"/>
<Setter Property="FontSize" Value="22"/>
<Setter Property="FontWeight" Value="Heavy"/>

</Style>
<Style x:Key="rowStyle" TargetType="DataGridRow">
<Setter Property="Height" Value="35"/>
<Setter Property="Foreground" Value="SkyBlue"/>
<Style.Triggers>
<Trigger Property="AlternationIndex" Value="0">
<Setter Property="Background" Value="Transparent" />
</Trigger>
<Trigger Property="AlternationIndex" Value="1">
<Setter Property="Background" Value="Transparent" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#000066" />
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="cellStyle" TargetType="DataGridCell">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground"
Value="SkyBlue"/>
</Trigger>
<Trigger Property="IsSelected" Value="false">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground"
Value="SkyBlue"/>
</Trigger>
</Style.Triggers>
</Style>

<LinearGradientBrush x:Key="ComboBox.Static.Background" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#8080ff" Offset="0.0"/>
<GradientStop Color="#000066" Offset="1.0"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="ComboBox.Static.Border" Color="SkyBlue"/>
<SolidColorBrush x:Key="ComboBox.Static.Glyph" Color="SkyBlue"/>
<SolidColorBrush x:Key="ComboBox.Static.Editable.Background" Color="LightBlue"/>
<SolidColorBrush x:Key="ComboBox.Static.Editable.Border" Color="#FFABADB3"/>
<SolidColorBrush x:Key="ComboBox.Static.Editable.Button.Background" Color="Transparent"/>
<SolidColorBrush x:Key="ComboBox.Static.Editable.Button.Border" Color="Transparent"/>
<LinearGradientBrush x:Key="ComboBox.MouseOver.Background" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="SteelBlue" Offset="0.0"/>
<GradientStop Color="SteelBlue" Offset="1.0"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="ComboBox.MouseOver.Border" Color="#FF7EB4EA"/>
<SolidColorBrush x:Key="ComboBox.MouseOver.Glyph" Color="#FF000000"/>
<SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Background" Color="#FFFFFFFF"/>
<SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Border" Color="#FF7EB4EA"/>
<LinearGradientBrush x:Key="ComboBox.MouseOver.Editable.Button.Background" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFEBF4FC" Offset="0.0"/>
<GradientStop Color="#FFDCECFC" Offset="1.0"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Button.Border" Color="#FF7EB4EA"/>
<LinearGradientBrush x:Key="ComboBox.Pressed.Background" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFDAECFC" Offset="0.0"/>
<GradientStop Color="#FFC4E0FC" Offset="1.0"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="ComboBox.Pressed.Border" Color="#FF569DE5"/>
<SolidColorBrush x:Key="ComboBox.Pressed.Glyph" Color="#FF000000"/>
<SolidColorBrush x:Key="ComboBox.Pressed.Editable.Background" Color="#FFFFFFFF"/>
<SolidColorBrush x:Key="ComboBox.Pressed.Editable.Border" Color="#FF569DE5"/>
<LinearGradientBrush x:Key="ComboBox.Pressed.Editable.Button.Background" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFDAEBFC" Offset="0.0"/>
<GradientStop Color="#FFC4E0FC" Offset="1.0"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="ComboBox.Pressed.Editable.Button.Border" Color="#FF569DE5"/>
<SolidColorBrush x:Key="ComboBox.Disabled.Background" Color="#FFF0F0F0"/>
<SolidColorBrush x:Key="ComboBox.Disabled.Border" Color="#FFD9D9D9"/>
<SolidColorBrush x:Key="ComboBox.Disabled.Glyph" Color="#FFBFBFBF"/>
<SolidColorBrush x:Key="ComboBox.Disabled.Editable.Background" Color="#FFFFFFFF"/>
<SolidColorBrush x:Key="ComboBox.Disabled.Editable.Border" Color="#FFBFBFBF"/>
<SolidColorBrush x:Key="ComboBox.Disabled.Editable.Button.Background" Color="Transparent"/>
<SolidColorBrush x:Key="ComboBox.Disabled.Editable.Button.Border" Color="Transparent"/>
<Style x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="IsTabStop" Value="false"/>
<Setter Property="Focusable" Value="false"/>
<Setter Property="ClickMode" Value="Press"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border x:Name="templateRoot" Background="{StaticResource ComboBox.Static.Background}" BorderBrush="{StaticResource ComboBox.Static.Border}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="true">
<Border x:Name="splitBorder" BorderBrush="Transparent" BorderThickness="1" HorizontalAlignment="Right" Margin="0" SnapsToDevicePixels="true" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}">
<Path x:Name="arrow" Data="F1 M 0,0 L 2.667,2.66665 L 5.3334,0 L 5.3334,-1.78168 L 2.6667,0.88501 L0,-1.78168 L0,0 Z" Fill="{StaticResource ComboBox.Static.Glyph}" HorizontalAlignment="Center" Margin="0" VerticalAlignment="Center"/>
</Border>
</Border>
<ControlTemplate.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="true"/>
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="false"/>
<Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}" Value="false"/>
<Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="true"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.Static.Editable.Background}"/>
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.Static.Editable.Border}"/>
<Setter Property="Background" TargetName="splitBorder" Value="{StaticResource ComboBox.Static.Editable.Button.Background}"/>
<Setter Property="BorderBrush" TargetName="splitBorder" Value="{StaticResource ComboBox.Static.Editable.Button.Border}"/>
</MultiDataTrigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Fill" TargetName="arrow" Value="{StaticResource ComboBox.MouseOver.Glyph}"/>
</Trigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
<Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="false"/>
</MultiDataTrigger.Conditions>
<!--<Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.MouseOver.Background}"/>-->
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.MouseOver.Border}"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
<Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="true"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.MouseOver.Editable.Background}"/>
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.MouseOver.Editable.Border}"/>
<Setter Property="Background" TargetName="splitBorder" Value="{StaticResource ComboBox.MouseOver.Editable.Button.Background}"/>
<Setter Property="BorderBrush" TargetName="splitBorder" Value="{StaticResource ComboBox.MouseOver.Editable.Button.Border}"/>
</MultiDataTrigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Fill" TargetName="arrow" Value="{StaticResource ComboBox.Pressed.Glyph}"/>
</Trigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}" Value="true"/>
<Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="false"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.Pressed.Background}"/>
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.Pressed.Border}"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}" Value="true"/>
<Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="true"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.Pressed.Editable.Background}"/>
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.Pressed.Editable.Border}"/>
<Setter Property="Background" TargetName="splitBorder" Value="{StaticResource ComboBox.Pressed.Editable.Button.Background}"/>
<Setter Property="BorderBrush" TargetName="splitBorder" Value="{StaticResource ComboBox.Pressed.Editable.Button.Border}"/>
</MultiDataTrigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Fill" TargetName="arrow" Value="{StaticResource ComboBox.Disabled.Glyph}"/>
</Trigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
<Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="false"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.Disabled.Background}"/>
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.Disabled.Border}"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/>
<Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="true"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.Disabled.Editable.Background}"/>
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.Disabled.Editable.Border}"/>
<Setter Property="Background" TargetName="splitBorder" Value="{StaticResource ComboBox.Disabled.Editable.Button.Background}"/>
<Setter Property="BorderBrush" TargetName="splitBorder" Value="{StaticResource ComboBox.Disabled.Editable.Button.Border}"/>
</MultiDataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ControlTemplate x:Key="ComboBoxTemplate" TargetType="{x:Type ComboBox}">
<Grid x:Name="templateRoot" SnapsToDevicePixels="true">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/>
</Grid.ColumnDefinitions>
<Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" Placement="Bottom" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}">
<theme:SystemDropShadowChrome x:Name="shadow" Color="Transparent" MinWidth="{Binding ActualWidth, ElementName=templateRoot}" MaxHeight="{TemplateBinding MaxDropDownHeight}">
<Border x:Name="dropDownBorder" Background="SkyBlue" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1">
<ScrollViewer x:Name="DropDownScrollViewer">
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
<Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
<Rectangle x:Name="opaqueRect" Fill="{Binding Background, ElementName=dropDownBorder}" Height="{Binding ActualHeight, ElementName=dropDownBorder}" Width="{Binding ActualWidth, ElementName=dropDownBorder}"/>
</Canvas>
<ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Grid>
</ScrollViewer>
</Border>
</theme:SystemDropShadowChrome>
</Popup>
<ToggleButton x:Name="toggleButton" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="2" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ComboBoxToggleButton}"/>
<ContentPresenter x:Name="contentPresenter" ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" Content="{TemplateBinding SelectionBoxItem}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="false" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
<Setter Property="Margin" TargetName="shadow" Value="0,0,5,5"/>
<Setter Property="Color" TargetName="shadow" Value="#71000000"/>
</Trigger>
<Trigger Property="HasItems" Value="false">
<Setter Property="Height" TargetName="dropDownBorder" Value="95"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsGrouping" Value="true"/>
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
</MultiTrigger.Conditions>
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
</MultiTrigger>
<Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="false">
<Setter Property="Canvas.Top" TargetName="opaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}"/>
<Setter Property="Canvas.Left" TargetName="opaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<LinearGradientBrush x:Key="Button.Static.Background" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#8080ff" Offset="0.0"/>
<GradientStop Color="#000066" Offset="1.0"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="Button.MouseOver.Background" Color="#FFBEE6FD"/>
<SolidColorBrush x:Key="Button.MouseOver.Border" Color="#FF3C7FB1"/>
<SolidColorBrush x:Key="Button.Pressed.Background" Color="#FFC4E5F6"/>
<SolidColorBrush x:Key="Button.Pressed.Border" Color="#FF2C628B"/>
<SolidColorBrush x:Key="Button.Disabled.Background" Color="#FFF4F4F4"/>
<SolidColorBrush x:Key="Button.Disabled.Border" Color="#FFADB2B5"/>
<SolidColorBrush x:Key="Button.Disabled.Foreground" Color="#FF838383"/>
<ControlTemplate x:Key="ButtonTemplate1" TargetType="{x:Type ButtonBase}">
<Border x:Name="border" Background="{StaticResource Button.Static.Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="true">
<ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Button.IsDefaulted" Value="true">
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<!--<Setter Property="Background" TargetName="border" Value="#000066"/>-->
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.MouseOver.Border}"/>
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/>
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource Button.Disabled.Foreground}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</UserControl.Resources>
<Grid>
<ScrollViewer VerticalScrollBarVisibility="Hidden">
<DataGrid Name="dataGrid" ItemsSource="{Binding usersInfo}" GridLinesVisibility="All" Background="Transparent"
AutoGenerateColumns="False"
IsReadOnly="False" Style="{StaticResource dataGrid }"
ColumnHeaderStyle="{StaticResource columsHeader}" RowStyle="{StaticResource rowStyle}" CellStyle="{StaticResource cellStyle}">
<DataGrid.Columns>

<DataGridTextColumn FontSize="16" IsReadOnly="false" Width="0.2*" Binding="{Binding UserName}" ElementStyle="{StaticResource dgCell}">
<DataGridTextColumn.Header>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock FontFamily="../Resources/fonts/#iconfont" Foreground="Orange" Text="&#xe6a0;" FontSize="24" VerticalAlignment="Center" Margin="0,0,8,0"/>
<TextBlock Text="Account" />
</StackPanel>
</DataGridTextColumn.Header>
</DataGridTextColumn>
<DataGridTextColumn FontSize="16" IsReadOnly="False" Width="0.2*" Binding="{Binding Password}" ElementStyle="{StaticResource dgCell}" >
<DataGridTextColumn.Header>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock FontFamily="../Resources/fonts/#iconfont" Foreground="Orange" Text="&#xe62b;" VerticalAlignment="Center" Margin="0,0,8,0"/>
<TextBlock Text="Password"/>
</StackPanel>
</DataGridTextColumn.Header>
</DataGridTextColumn>
<DataGridTemplateColumn Width="0.2*">

<DataGridTemplateColumn.Header>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock FontFamily="../Resources/fonts/#iconfont" Foreground="Orange" Text="&#xe62c;" VerticalAlignment="Center" Margin="0,0,8,0"/>
<TextBlock Text="Authority"/>
</StackPanel>
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox Text="{Binding permission}" Template="{DynamicResource ComboBoxTemplate}" ItemsSource="{Binding DataContext.Authorities, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}, Mode=FindAncestor}}" IsEditable="False" Foreground="SkyBlue" VerticalContentAlignment="Center" Width="auto" FontSize="16" HorizontalContentAlignment="Center" >
<ComboBox.ItemContainerStyle>
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="FontSize" Value="16"/>
<Setter Property="Background" Value="SkyBlue" />
<Setter Property="Foreground" Value="Aqua"/>
</Style>
</ComboBox.ItemContainerStyle>
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="0.4*">

<DataGridTemplateColumn.Header>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock FontFamily="../Resources/fonts/#iconfont" Foreground="Orange" Text="&#xe979;" VerticalAlignment="Center" Margin="0,0,8,0"/>
<TextBlock Text="Operate"/>
</StackPanel>
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<!--<ColumnDefinition/>-->
</Grid.ColumnDefinitions>
<Button Command="{Binding DataContext.SaveCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
CommandParameter="{Binding Account}" Template="{DynamicResource ButtonTemplate1}" Style="{StaticResource btnStyle}" Content="Save" Margin="5,0"></Button>
<!--<Button Command="{Binding DataContext.UpdateCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}" Template="{DynamicResource ButtonTemplate1}" Style="{StaticResource btnStyle}" Content="Update" Grid.Column="1" Margin="5,0"></Button>-->
<Button Command="{Binding DataContext.DeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}" CommandParameter="{Binding Account}" Template="{DynamicResource ButtonTemplate1}" Style="{StaticResource btnStyle}" Content="Delete" Grid.Column="1" Margin="5,0"></Button>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</ScrollViewer>
</Grid>
</UserControl>

+ 28
- 0
FryPot_DosingSystem/View/UserManageView.xaml.cs Parādīt failu

@@ -0,0 +1,28 @@
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 FryPot_DosingSystem.View
{
/// <summary>
/// UserManageView.xaml 的交互逻辑
/// </summary>
public partial class UserManageView : UserControl
{
public UserManageView()
{
InitializeComponent();
}
}
}

+ 80
- 0
FryPot_DosingSystem/ViewModel/UserManageViewModel.cs Parādīt failu

@@ -0,0 +1,80 @@
using BPA.Message;
using BPASmartClient.CustomResource.Pages.Enums;
using BPASmartClient.CustomResource.Pages.Model;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace FryPot_DosingSystem.ViewModel
{
internal class UserManageViewModel:ObservableObject
{
public ObservableCollection<UserInfo> usersInfo { get; set; } = new ObservableCollection<UserInfo>();

public List<string> Authorities { get; set; } = new List<string>();

public RelayCommand<string> SaveCommand { get; set; }
public RelayCommand<string> UpdateCommand { get; set; }
public RelayCommand<string> DeleteCommand { get; set; }
public UserManageViewModel()
{
var userManager = JsonConvert.DeserializeObject<UserManager>(File.ReadAllText("up.hbl").AESDecrypt());
usersInfo = userManager.userInfos;
AddAuthorities();
SaveCommand = new RelayCommand<string>((str) =>
{
if (str != string.Empty && str != null)
{
int num = usersInfo.Where(p => p.UserName == str).Count();
if (num > 0 && num >= 2)
{
MessageBox.Show("用户名重复", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
}
else
{
Global.userManager.userInfos = usersInfo;
File.WriteAllText("UserInfo.jz", JsonConvert.SerializeObject(Global.userManager).AESEncrypt());
MessageBox.Show("保存成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
}

}
});
DeleteCommand = new RelayCommand<string>((str) =>
{
if (str != string.Empty && str != null)
{
var userInfo = usersInfo.FirstOrDefault(p => p.UserName == str);
if (userInfo != null)
{
if (usersInfo.Remove(userInfo))
{
Global.userManager.userInfos = usersInfo;
File.WriteAllText("UserInfo.jz", JsonConvert.SerializeObject(Global.userManager).AESEncrypt());
}
}
else
{
MessageBox.Show("未找到对应记录", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
}
}
});
}

private void AddAuthorities()
{
foreach (Permission aut in System.Enum.GetValues(typeof(Permission)))
{
Authorities.Add(aut.ToString());
}

}
}
}

Notiek ielāde…
Atcelt
Saglabāt