@@ -0,0 +1,8 @@ | |||
<Application x:Class="BPASmart.MenuLoad.App" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:local="clr-namespace:BPASmart.MenuLoad"> | |||
<Application.Resources> | |||
</Application.Resources> | |||
</Application> |
@@ -0,0 +1,74 @@ | |||
using BeDesignerSCADA.Helper; | |||
using BeDesignerSCADA.View; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Configuration; | |||
using System.Data; | |||
using System.Diagnostics; | |||
using System.IO; | |||
using System.Linq; | |||
using System.Runtime.InteropServices; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
namespace BPASmart.MenuLoad | |||
{ | |||
/// <summary> | |||
/// Interaction logic for App.xaml | |||
/// </summary> | |||
public partial class App : Application | |||
{ | |||
bool isShow = false; | |||
[DllImport("kernel32.dll")] | |||
private static extern bool SetProcessWorkingSetSize(IntPtr proc, int min, int max); | |||
string _path = $"{System.AppDomain.CurrentDomain.BaseDirectory}Layouts\\可视化界面菜单布局.yf"; | |||
private void FlushMemory() | |||
{ | |||
GC.Collect(); | |||
GC.WaitForPendingFinalizers(); | |||
if (Environment.OSVersion.Platform == PlatformID.Win32NT) | |||
SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1); | |||
} | |||
protected override void OnStartup(StartupEventArgs e) | |||
{ | |||
base.OnStartup(e); | |||
RunWindows run = new RunWindows(); | |||
_ = Task.Factory.StartNew(delegate | |||
{ | |||
while (true) | |||
{ | |||
try | |||
{ | |||
if (!isShow) | |||
{ | |||
this.Dispatcher.Invoke(() => { | |||
if (File.Exists(_path)) | |||
{ | |||
SystemHelperNew.GetInstance.CreateShortcutOnDesktop(); | |||
SystemHelperNew.GetInstance.CreateShortcutOnDesktop("可视化配置工具"); | |||
//SystemHelperNew.GetInstance.CreateDesktopShortcut(); | |||
run.LoadingData(_path); | |||
run.Show(); | |||
isShow = true; | |||
} | |||
else | |||
{ | |||
MessageBox.Show("未布局应用程序!"); | |||
System.Windows.Application.Current.Shutdown(0); | |||
} | |||
}); | |||
} | |||
FlushMemory(); | |||
Thread.Sleep(TimeSpan.FromSeconds((double)1000)); | |||
} | |||
catch { } | |||
} | |||
}); | |||
} | |||
} | |||
} |
@@ -0,0 +1,10 @@ | |||
using System.Windows; | |||
[assembly: ThemeInfo( | |||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | |||
//(used if a resource is not found in the page, | |||
// or application resource dictionaries) | |||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | |||
//(used if a resource is not found in the page, | |||
// app, or any theme specific resource dictionaries) | |||
)] |
@@ -0,0 +1,28 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<OutputType>WinExe</OutputType> | |||
<TargetFramework>net6.0-windows</TargetFramework> | |||
<Nullable>enable</Nullable> | |||
<UseWPF>true</UseWPF> | |||
<AssemblyName>可视化应用</AssemblyName> | |||
<ApplicationIcon>fyf.ico</ApplicationIcon> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<None Remove="fyf.ico" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Content Include="fyf.ico" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BeDesignerSCADA\BeDesignerSCADA.csproj" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Resource Include="fyf.ico" /> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,12 @@ | |||
<Window x:Class="BPASmart.MenuLoad.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:BPASmart.MenuLoad" | |||
mc:Ignorable="d" | |||
Title="MainWindow" Height="450" Width="800"> | |||
<Grid> | |||
</Grid> | |||
</Window> |
@@ -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 BPASmart.MenuLoad | |||
{ | |||
/// <summary> | |||
/// Interaction logic for MainWindow.xaml | |||
/// </summary> | |||
public partial class MainWindow : Window | |||
{ | |||
public MainWindow() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -2,7 +2,7 @@ | |||
x:Class="BPASmart.PageLoad.MainWindow" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:ctrl="clr-namespace:BeDesignerSCADA.Controls;assembly=BeDesignerSCADA" | |||
xmlns:ctrl="clr-namespace:BeDesignerSCADA.Controls;assembly=可视化配置工具" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmart.PageLoad" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
@@ -13,7 +13,7 @@ | |||
mc:Ignorable="d"> | |||
<Grid> | |||
<Grid.Background> | |||
<ImageBrush ImageSource="/BeDesignerSCADA;component/Images/bj.png" /> | |||
<ImageBrush ImageSource="/可视化配置工具;component/Images/bj.png" /> | |||
</Grid.Background> | |||
<ctrl:RunCanvas x:Name="runCanvas" /> | |||
</Grid> | |||
@@ -11,8 +11,8 @@ namespace BPASmartClient.AGV | |||
/// </summary> | |||
internal class AGVLoadInteracteModel | |||
{ | |||
private static AGVLoadInteracteModel _instance; | |||
public static AGVLoadInteracteModel GetInstance=>_instance ??= new AGVLoadInteracteModel(); | |||
//private static AGVLoadInteracteModel _instance; | |||
//public static AGVLoadInteracteModel GetInstance=>_instance ??= new AGVLoadInteracteModel(); | |||
public string agvCode { get; set;} | |||
public string jobId { get; set; } | |||
public string msgId { get; set; } | |||
@@ -11,8 +11,8 @@ namespace BPASmartClient.AGV | |||
/// </summary> | |||
internal class AGVModel | |||
{ | |||
private static AGVModel _instance; | |||
public static AGVModel GetInstance => _instance ??= new AGVModel(); | |||
//private static AGVModel _instance; | |||
//public static AGVModel GetInstance => _instance ??= new AGVModel(); | |||
/// <summary> | |||
/// 必填项 | |||
@@ -11,8 +11,8 @@ namespace BPASmartClient.AGV | |||
/// </summary> | |||
internal class AGVTaskCancelModel | |||
{ | |||
private static AGVTaskCancelModel _instance; | |||
public static AGVTaskCancelModel GetInstance => _instance ??= new AGVTaskCancelModel(); | |||
//private static AGVTaskCancelModel _instance; | |||
//public static AGVTaskCancelModel GetInstance => _instance ??= new AGVTaskCancelModel(); | |||
public string robotJobId { get; set; } | |||
public long warehouseId { get; set; } | |||
public string? executeMode { get; set; } | |||
@@ -11,8 +11,8 @@ namespace BPASmartClient.AGV | |||
/// </summary> | |||
internal class AGVTaskCompleteNotifyModel | |||
{ | |||
private static AGVTaskCompleteNotifyModel _instance; | |||
public static AGVTaskCompleteNotifyModel GetInstance=>_instance ??= new AGVTaskCompleteNotifyModel(); | |||
//private static AGVTaskCompleteNotifyModel _instance; | |||
//public static AGVTaskCompleteNotifyModel GetInstance=>_instance ??= new AGVTaskCompleteNotifyModel(); | |||
public string? robotJobId { get; set; } | |||
public string? bucketCode { get; set; } | |||
public string? bucketslotCode { get; set; } | |||
@@ -11,8 +11,8 @@ namespace BPASmartClient.AGV | |||
/// </summary> | |||
internal class AGV_PointRollerJobData:IJobData | |||
{ | |||
private static AGV_PointRollerJobData _instance; | |||
public static AGV_PointRollerJobData GetInstance => _instance ??= new AGV_PointRollerJobData(); | |||
//private static AGV_PointRollerJobData _instance; | |||
//public static AGV_PointRollerJobData GetInstance => _instance ??= new AGV_PointRollerJobData(); | |||
public string? containerCode { get; set; } | |||
public string startPoint { get; set; } | |||
public string endPoint { get; set; } | |||
@@ -11,8 +11,8 @@ namespace BPASmartClient.AGV | |||
/// </summary> | |||
internal class AGV_SlotRollerJobData:IJobData | |||
{ | |||
private static AGV_SlotRollerJobData _instance; | |||
public static AGV_SlotRollerJobData GetInstance => _instance ??= new AGV_SlotRollerJobData(); | |||
//private static AGV_SlotRollerJobData _instance; | |||
//public static AGV_SlotRollerJobData GetInstance => _instance ??= new AGV_SlotRollerJobData(); | |||
public string? containerCode { get; set; } | |||
public string startSlotCode { get; set; } | |||
public string endSlotCode { get; set; } | |||
@@ -8,8 +8,8 @@ namespace BPASmartClient.AGV | |||
{ | |||
internal class HttpRequestHeaderModel | |||
{ | |||
private static HttpRequestHeaderModel _instance; | |||
public static HttpRequestHeaderModel GetInstance => _instance ??= new HttpRequestHeaderModel(); | |||
//private static HttpRequestHeaderModel _instance; | |||
//public static HttpRequestHeaderModel GetInstance => _instance ??= new HttpRequestHeaderModel(); | |||
public string? appKey { get; set; } | |||
public string? appSecret { get; set; } | |||
public string? requestId { get; set; } | |||
@@ -24,6 +24,7 @@ | |||
<None Remove="Fonts\iconfont.ttf" /> | |||
<None Remove="Fonts\MT\iconfont.ttf" /> | |||
<None Remove="Fonts\naicha.ttf" /> | |||
<None Remove="Fonts\new\iconfont.ttf" /> | |||
<None Remove="Fonts\Quartz Regular.ttf" /> | |||
<None Remove="Image\AGV\agv.png" /> | |||
<None Remove="Image\AGV\AGV小车.png" /> | |||
@@ -87,6 +88,10 @@ | |||
<None Remove="Image\WindowImages.png" /> | |||
<None Remove="Image\上箭头.png" /> | |||
<None Remove="Image\不规则矩形.png" /> | |||
<None Remove="Image\不锈钢纹理.jpg" /> | |||
<None Remove="Image\不锈钢纹理1.png" /> | |||
<None Remove="Image\不锈钢纹理2.jpeg" /> | |||
<None Remove="Image\不锈钢纹理3.jpeg" /> | |||
<None Remove="Image\个人信息.png" /> | |||
<None Remove="Image\中间.png" /> | |||
<None Remove="Image\临时模板.png" /> | |||
@@ -276,6 +281,7 @@ | |||
<Resource Include="Fonts\iconfont.ttf" /> | |||
<Resource Include="Fonts\MT\iconfont.ttf" /> | |||
<Resource Include="Fonts\naicha.ttf" /> | |||
<Resource Include="Fonts\new\iconfont.ttf" /> | |||
<Resource Include="Fonts\Quartz Regular.ttf" /> | |||
<Resource Include="Image\AGV\agv.png" /> | |||
<Resource Include="Image\AGV\AGV小车.png" /> | |||
@@ -301,6 +307,10 @@ | |||
<Resource Include="Image\textBox.png" /> | |||
<Resource Include="Image\WindowImages.png" /> | |||
<Resource Include="Image\上箭头.png" /> | |||
<Resource Include="Image\不锈钢纹理.jpg" /> | |||
<Resource Include="Image\不锈钢纹理1.png" /> | |||
<Resource Include="Image\不锈钢纹理2.jpeg" /> | |||
<Resource Include="Image\不锈钢纹理3.jpeg" /> | |||
<Resource Include="Image\中间.png" /> | |||
<Resource Include="Image\临时模板.png" /> | |||
<Resource Include="Image\产品制作.png" /> | |||
@@ -0,0 +1,276 @@ | |||
<!DOCTYPE html> | |||
<html> | |||
<head> | |||
<meta charset="utf-8"/> | |||
<title>iconfont Demo</title> | |||
<link rel="shortcut icon" href="//img.alicdn.com/imgextra/i4/O1CN01Z5paLz1O0zuCC7osS_!!6000000001644-55-tps-83-82.svg" type="image/x-icon"/> | |||
<link rel="icon" type="image/svg+xml" href="//img.alicdn.com/imgextra/i4/O1CN01Z5paLz1O0zuCC7osS_!!6000000001644-55-tps-83-82.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"></span> | |||
<div class="name">open-l</div> | |||
<div class="code-name">&#xe79e;</div> | |||
</li> | |||
<li class="dib"> | |||
<span class="icon iconfont"></span> | |||
<div class="name">进行中</div> | |||
<div class="code-name">&#xe63f;</div> | |||
</li> | |||
<li class="dib"> | |||
<span class="icon iconfont"></span> | |||
<div class="name">启动</div> | |||
<div class="code-name">&#xe746;</div> | |||
</li> | |||
<li class="dib"> | |||
<span class="icon iconfont"></span> | |||
<div class="name">停止刷新</div> | |||
<div class="code-name">&#xe631;</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=1665539385316') 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" | |||
><span class="iconfont">&#x33;</span> | |||
</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-openl"></span> | |||
<div class="name"> | |||
open-l | |||
</div> | |||
<div class="code-name">.icon-openl | |||
</div> | |||
</li> | |||
<li class="dib"> | |||
<span class="icon iconfont icon-shouye"></span> | |||
<div class="name"> | |||
进行中 | |||
</div> | |||
<div class="code-name">.icon-shouye | |||
</div> | |||
</li> | |||
<li class="dib"> | |||
<span class="icon iconfont icon-qidong"></span> | |||
<div class="name"> | |||
启动 | |||
</div> | |||
<div class="code-name">.icon-qidong | |||
</div> | |||
</li> | |||
<li class="dib"> | |||
<span class="icon iconfont icon-tingzhishuaxin"></span> | |||
<div class="name"> | |||
停止刷新 | |||
</div> | |||
<div class="code-name">.icon-tingzhishuaxin | |||
</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"><link rel="stylesheet" href="./iconfont.css"> | |||
</code></pre> | |||
<h3 id="-">第二步:挑选相应图标并获取类名,应用于页面:</h3> | |||
<pre><code class="language-html"><span class="iconfont icon-xxx"></span> | |||
</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-openl"></use> | |||
</svg> | |||
<div class="name">open-l</div> | |||
<div class="code-name">#icon-openl</div> | |||
</li> | |||
<li class="dib"> | |||
<svg class="icon svg-icon" aria-hidden="true"> | |||
<use xlink:href="#icon-shouye"></use> | |||
</svg> | |||
<div class="name">进行中</div> | |||
<div class="code-name">#icon-shouye</div> | |||
</li> | |||
<li class="dib"> | |||
<svg class="icon svg-icon" aria-hidden="true"> | |||
<use xlink:href="#icon-qidong"></use> | |||
</svg> | |||
<div class="name">启动</div> | |||
<div class="code-name">#icon-qidong</div> | |||
</li> | |||
<li class="dib"> | |||
<svg class="icon svg-icon" aria-hidden="true"> | |||
<use xlink:href="#icon-tingzhishuaxin"></use> | |||
</svg> | |||
<div class="name">停止刷新</div> | |||
<div class="code-name">#icon-tingzhishuaxin</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"><script src="./iconfont.js"></script> | |||
</code></pre> | |||
<h3 id="-css-">第二步:加入通用 CSS 代码(引入一次就行):</h3> | |||
<pre><code class="language-html"><style> | |||
.icon { | |||
width: 1em; | |||
height: 1em; | |||
vertical-align: -0.15em; | |||
fill: currentColor; | |||
overflow: hidden; | |||
} | |||
</style> | |||
</code></pre> | |||
<h3 id="-">第三步:挑选相应图标并获取类名,应用于页面:</h3> | |||
<pre><code class="language-html"><svg class="icon" aria-hidden="true"> | |||
<use xlink:href="#icon-xxx"></use> | |||
</svg> | |||
</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> |
@@ -30,7 +30,7 @@ namespace BPASmartClient.CustomResource.Pages.View | |||
this.WindowState = WindowState.Maximized; | |||
this.ButMin.Click += (o, e) => { this.WindowState = WindowState.Minimized; }; | |||
this.ButMax.Click += (o, e) => { this.WindowState = this.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; }; | |||
this.ButClose.Click += (o, e) => { this.Close(); }; | |||
this.ButClose.Click += (o, e) => { this.Close(); Application.Current.Shutdown(); }; | |||
this.MoveBorder.MouseLeftButtonDown += (o, e) => | |||
{ | |||
if (e.ClickCount > 1) | |||
@@ -59,7 +59,7 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel | |||
} | |||
else | |||
{ | |||
MessageBox.Show("用户名为空或输入后未回车确认", "提示", MessageBoxButton.OK, MessageBoxImage.Information); | |||
MessageBox.Show("保存失败,用户名为空或输入后未回车确认", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); | |||
} | |||
}); | |||
DeleteCommand = new RelayCommand<string>((str) => | |||
@@ -0,0 +1,84 @@ | |||
<UserControl x:Class="BPASmartClient.CustomResource.UserControls.ConveyBelt2" | |||
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:BPASmartClient.CustomResource.UserControls" | |||
mc:Ignorable="d" | |||
d:DesignHeight="450" d:DesignWidth="800"> | |||
<Border x:Name="br" > | |||
<VisualStateManager.VisualStateGroups> | |||
<VisualStateGroup Name="StockGroup"> | |||
<VisualState Name="RunState"> | |||
<Storyboard RepeatBehavior="Forever"> | |||
<DoubleAnimation | |||
Storyboard.TargetName="belt" | |||
Storyboard.TargetProperty="StrokeDashOffset" | |||
From="0" | |||
To="-100" | |||
Duration="0:0:20" /> | |||
</Storyboard> | |||
</VisualState> | |||
<VisualState Name="Stop"> | |||
</VisualState> | |||
</VisualStateGroup> | |||
<VisualStateGroup Name="DirectionGroup"> | |||
<VisualState Name="LeftState"> | |||
<Storyboard RepeatBehavior="Forever"> | |||
<DoubleAnimation | |||
Storyboard.TargetName="belt" | |||
Storyboard.TargetProperty="StrokeDashOffset" | |||
From="0" | |||
To="100" | |||
Duration="0:0:20" /> | |||
</Storyboard> | |||
</VisualState> | |||
<VisualState Name="RightState"> | |||
<Storyboard RepeatBehavior="Forever"> | |||
<DoubleAnimation | |||
Storyboard.TargetName="belt" | |||
Storyboard.TargetProperty="StrokeDashOffset" | |||
From="0" | |||
To="-100" | |||
Duration="0:0:20" /> | |||
</Storyboard> | |||
</VisualState> | |||
</VisualStateGroup> | |||
</VisualStateManager.VisualStateGroups> | |||
<Viewbox HorizontalAlignment="Center" VerticalAlignment="Center"> | |||
<Canvas Width="{Binding ElementName=br, Path=ActualWidth}" Height="{Binding ElementName=br, Path=ActualHeight}" Margin="5"> | |||
<Rectangle HorizontalAlignment="Center" Width="{Binding ElementName=br, Path=ActualWidth}" Height="5" Canvas.Top="20" RadiusX="1" RadiusY="1"> | |||
<Rectangle.Fill> | |||
<LinearGradientBrush > | |||
<GradientStop Color="LightGray" Offset="0"/> | |||
<GradientStop Color="White" Offset="0.5"/> | |||
<GradientStop Color="LightGray" Offset="1"/> | |||
</LinearGradientBrush> | |||
</Rectangle.Fill> | |||
</Rectangle> | |||
<Rectangle HorizontalAlignment="Center" x:Name="recDown" Width="{Binding ElementName=br, Path=ActualWidth}" Height="5" RadiusX="1" RadiusY="1" Margin="0,80,0,0"> | |||
<Rectangle.Fill> | |||
<LinearGradientBrush > | |||
<GradientStop Color="LightGray" Offset="0"/> | |||
<GradientStop Color="White" Offset="0.5"/> | |||
<GradientStop Color="LightGray" Offset="1"/> | |||
</LinearGradientBrush> | |||
</Rectangle.Fill> | |||
</Rectangle> | |||
<Path x:Name="belt" Canvas.Top="20" Canvas.Left="10" | |||
StrokeDashArray="2" StrokeThickness="20"> | |||
<Path.Stroke> | |||
<LinearGradientBrush> | |||
<GradientStop Color="SlateGray" Offset="0"/> | |||
<GradientStop Color="White" Offset="0.5"/> | |||
<GradientStop Color="SlateGray" Offset="1"/> | |||
</LinearGradientBrush> | |||
</Path.Stroke> | |||
</Path> | |||
</Canvas> | |||
</Viewbox> | |||
</Border> | |||
</UserControl> |
@@ -0,0 +1,130 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.ComponentModel; | |||
using System.Linq; | |||
using System.Runtime.CompilerServices; | |||
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 BPASmartClient.CustomResource.UserControls | |||
{ | |||
/// <summary> | |||
/// ConveyBelt2.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class ConveyBelt2 : UserControl | |||
{ | |||
public ConveyBelt2() | |||
{ | |||
InitializeComponent(); | |||
} | |||
[Category("运行状态")] | |||
public bool IsRun | |||
{ | |||
get { return (bool)GetValue(IsRunProperty); } | |||
set { SetValue(IsRunProperty, value); } | |||
} | |||
public static readonly DependencyProperty IsRunProperty = | |||
DependencyProperty.Register("IsRun", typeof(bool), typeof(ConveyBelt2), new PropertyMetadata(default(bool), new PropertyChangedCallback(OnRunningChanged))); | |||
private static void OnRunningChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |||
{ | |||
VisualStateManager.GoToState(d as ConveyBelt2, (bool)e.NewValue ? "RunState" : "Stop", false); | |||
} | |||
public double BeltWidth | |||
{ | |||
get { return (double)GetValue(BeltWidthProperty); } | |||
set { SetValue(BeltWidthProperty, value); } | |||
} | |||
public static readonly DependencyProperty BeltWidthProperty = | |||
DependencyProperty.Register("BeltWidth", typeof(double), typeof(ConveyBelt2), new PropertyMetadata(default(double), new PropertyChangedCallback(OnPropertyChanged))); | |||
private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |||
{ | |||
(d as ConveyBelt2)?.Refresh(); | |||
} | |||
public void Refresh() | |||
{ | |||
PathGeometry geometry = new PathGeometry(); | |||
PathFigure pathFigure = new PathFigure(); | |||
if (BeltHeight > 100) | |||
{ | |||
pathFigure.StartPoint = new Point(0, 35 + (BeltHeight - 100) / 2); | |||
pathFigure.Segments.Add(new LineSegment(new Point(BeltWidth - 10, 35 + (BeltHeight - 100)/2), true)); | |||
} | |||
else | |||
{ | |||
pathFigure.StartPoint = new Point(0, 35); | |||
pathFigure.Segments.Add(new LineSegment(new Point(BeltWidth - 10, 35), true)); | |||
} | |||
geometry.Figures.Add(pathFigure); | |||
this.belt.Data = geometry; | |||
this.belt.StrokeDashOffset = BeltDashOffset; | |||
this.br.Width = BeltWidth; | |||
if (BeltHeight > 100) | |||
{ | |||
this.recDown.Margin = new Thickness(0, BeltHeight - 20, 0, 0); | |||
} | |||
else | |||
{ | |||
this.recDown.Margin = new Thickness(0, 80, 0, 0); | |||
} | |||
this.belt.StrokeThickness = BeltDashThickess; | |||
} | |||
public double BeltHeight | |||
{ | |||
get { return (double)GetValue(BeltHeightProperty); } | |||
set { SetValue(BeltHeightProperty, value); } | |||
} | |||
public static readonly DependencyProperty BeltHeightProperty = | |||
DependencyProperty.Register("BeltHeight", typeof(double), typeof(ConveyBelt2), new PropertyMetadata(default(double), new PropertyChangedCallback(OnPropertyChanged))); | |||
public double BeltDashOffset | |||
{ | |||
get { return (double)GetValue(BeltDashOffsetProperty); } | |||
set { SetValue(BeltDashOffsetProperty, value); } | |||
} | |||
public static readonly DependencyProperty BeltDashOffsetProperty = | |||
DependencyProperty.Register("BeltDashOffset", typeof(double), typeof(ConveyBelt2), new PropertyMetadata(default(double), new PropertyChangedCallback(OnPropertyChanged))); | |||
public double BeltDashThickess | |||
{ | |||
get { return (double)GetValue(BeltDashThickessProperty); } | |||
set { SetValue(BeltDashThickessProperty, value); } | |||
} | |||
public static readonly DependencyProperty BeltDashThickessProperty = | |||
DependencyProperty.Register("BeltDashThickess", typeof(double), typeof(ConveyBelt2), new PropertyMetadata(default(double), new PropertyChangedCallback(OnPropertyChanged))); | |||
public int BeltDirection | |||
{ | |||
get { return (int)GetValue(BeltDirectionProperty); } | |||
set { SetValue(BeltDirectionProperty, value); } | |||
} | |||
public static readonly DependencyProperty BeltDirectionProperty = | |||
DependencyProperty.Register("BeltDirection", typeof(int), typeof(ConveyBelt2), new PropertyMetadata(default(int), new PropertyChangedCallback(OnDirectionChanged))); | |||
private static void OnDirectionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |||
{ | |||
if ((d as ConveyBelt2)?.BeltDirection == 0) | |||
{ | |||
VisualStateManager.GoToState(d as ConveyBelt2, "RightState", false); | |||
} | |||
else | |||
{ | |||
VisualStateManager.GoToState(d as ConveyBelt2, "LeftState", false); | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,287 @@ | |||
<UserControl x:Class="BPASmartClient.CustomResource.UserControls.MaterialStock" | |||
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:BPASmartClient.CustomResource.UserControls" | |||
mc:Ignorable="d" | |||
d:DesignHeight="450" d:DesignWidth="800"> | |||
<UserControl.Resources> | |||
<PathGeometry x:Key="move" Figures="M 0,0 L 0,10"/> | |||
</UserControl.Resources> | |||
<Border HorizontalAlignment="Center"> | |||
<VisualStateManager.VisualStateGroups> | |||
<VisualStateGroup Name="StockGroup"> | |||
<VisualState Name="OpenState"> | |||
<Storyboard> | |||
<DoubleAnimation Duration="00:0:1" From="0" To="200" | |||
Storyboard.TargetProperty="Width" | |||
Storyboard.TargetName="stock"/> | |||
<DoubleAnimation Duration="00:0:1" From="0" To="70" | |||
Storyboard.TargetProperty="Height" | |||
Storyboard.TargetName="stock"/> | |||
</Storyboard> | |||
</VisualState> | |||
<VisualState Name="CloseState"> | |||
<Storyboard> | |||
<DoubleAnimation Duration="00:0:1" From="200" To="0" | |||
Storyboard.TargetProperty="Width" | |||
Storyboard.TargetName="stock"/> | |||
<DoubleAnimation Duration="00:0:1" From="70" To="0" | |||
Storyboard.TargetProperty="Height" | |||
Storyboard.TargetName="stock"/> | |||
</Storyboard> | |||
</VisualState> | |||
</VisualStateGroup> | |||
<VisualStateGroup Name="RunStateGroup"> | |||
<VisualState Name="RunState"> | |||
<Storyboard> | |||
<ColorAnimationUsingKeyFrames | |||
Storyboard.TargetName="gsGreen" | |||
Storyboard.TargetProperty="Color"> | |||
<DiscreteColorKeyFrame Value="Green" KeyTime="0"/> | |||
</ColorAnimationUsingKeyFrames> | |||
</Storyboard> | |||
</VisualState> | |||
<VisualState Name="Stop"/> | |||
</VisualStateGroup> | |||
<VisualStateGroup x:Name="FaultStateGroup"> | |||
<VisualState Name="FaultState"> | |||
<Storyboard> | |||
<ColorAnimationUsingKeyFrames RepeatBehavior="Forever" | |||
Storyboard.TargetName="gsRed1" | |||
Storyboard.TargetProperty="Color"> | |||
<DiscreteColorKeyFrame Value="Red" KeyTime="0:0:0.5"/> | |||
<DiscreteColorKeyFrame Value="Gray" KeyTime="0:0:1"/> | |||
</ColorAnimationUsingKeyFrames> | |||
</Storyboard> | |||
</VisualState> | |||
<VisualState Name="NormalState"/> | |||
</VisualStateGroup> | |||
<VisualStateGroup x:Name="LayOffStateGroup"> | |||
<VisualState Name="LayOffState"> | |||
<Storyboard> | |||
<DoubleAnimationUsingPath Duration="0:0:1" PathGeometry="{StaticResource move}" RepeatBehavior="Forever" | |||
Storyboard.TargetName="arrow" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(Y)" Source="Y"></DoubleAnimationUsingPath> | |||
</Storyboard> | |||
</VisualState> | |||
<VisualState Name="LayStopState"> | |||
</VisualState> | |||
</VisualStateGroup> | |||
</VisualStateManager.VisualStateGroups> | |||
<Viewbox VerticalAlignment="Center" HorizontalAlignment="Center"> | |||
<Canvas Width="205" Height="245" Margin="5"> | |||
<Polygon Points="0,80 20,40 205,40 185,80" Canvas.Left="67"> | |||
<Polygon.RenderTransform> | |||
<SkewTransform AngleX="-40" /> | |||
</Polygon.RenderTransform> | |||
<Polygon.Fill> | |||
<!--<LinearGradientBrush StartPoint="1,0" EndPoint="1,1"> | |||
<GradientStop Color="LightGray" Offset="0"/> | |||
<GradientStop Color="WhiteSmoke" Offset="0.85"/> | |||
<GradientStop Color="LightGray" Offset="1"/> | |||
</LinearGradientBrush>--> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/不锈钢纹理2.jpeg" Stretch="Fill"/> | |||
</Polygon.Fill> | |||
</Polygon> | |||
<Polygon Width="200" Height="70" Points="45,70 60,50 170,50 155,70" Stroke="Gray" StrokeThickness="2" Canvas.Left="67"> | |||
<Polygon.RenderTransform> | |||
<SkewTransform AngleX="-40" /> | |||
</Polygon.RenderTransform> | |||
</Polygon> | |||
<Polygon x:Name="stock" Width="0" Height="0" Points="45,70 60,50 170,50 155,70" Canvas.Left="67" > | |||
<Polygon.Fill> | |||
<SolidColorBrush Color="DimGray"/> | |||
</Polygon.Fill> | |||
<Polygon.RenderTransform> | |||
<SkewTransform AngleX="-40" /> | |||
</Polygon.RenderTransform> | |||
</Polygon> | |||
<Polygon Points="-5,90 0,80 185,80 180,90" Panel.ZIndex="1" > | |||
<Polygon.Fill> | |||
<LinearGradientBrush> | |||
<GradientStop Color="LightGray" Offset="0"/> | |||
<GradientStop Color="White" Offset="0.66"/> | |||
<GradientStop Color="LightGray" Offset="0.95"/> | |||
</LinearGradientBrush> | |||
</Polygon.Fill> | |||
</Polygon> | |||
<Grid Width="185" Height="160" Canvas.Top="80"> | |||
<Grid.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/不锈钢纹理.jpg" Stretch="Fill"/> | |||
</Grid.Background> | |||
<!--<Grid VerticalAlignment="Bottom" Height="20" Margin="5"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition/> | |||
<ColumnDefinition/> | |||
</Grid.ColumnDefinitions> | |||
<Button Width="60"> | |||
<Button.Template> | |||
<ControlTemplate TargetType="{x:Type Button}"> | |||
<Border x:Name="br" BorderThickness="2" BorderBrush="DimGray" CornerRadius="5" Background="Orange"> | |||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" > | |||
<TextBlock VerticalAlignment="Center" Text="" FontFamily="/BPASmartClient.CustomResource;component/Fonts/new/#iconfont" Margin="0,0,5,0"/> | |||
<TextBlock Text="开盖" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="14"/> | |||
</StackPanel> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsPressed" Value="True"> | |||
<Setter Property="Background" Value="yellow" TargetName="br"/> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Button.Template> | |||
</Button> | |||
<Button Width="60" Grid.Column="1"> | |||
<Button.Template> | |||
<ControlTemplate TargetType="{x:Type Button}"> | |||
<Border x:Name="br1" BorderThickness="2" BorderBrush="DimGray" CornerRadius="5" Background="yellowgreen"> | |||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" > | |||
<TextBlock VerticalAlignment="Center" Text="" FontFamily="/BPASmartClient.CustomResource;component/Fonts/new/#iconfont" Margin="0,0,5,0"/> | |||
<TextBlock Text="出料" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="14"/> | |||
</StackPanel> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsPressed" Value="True"> | |||
<Setter Property="Background" Value="lawngreen" TargetName="br1"/> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Button.Template> | |||
</Button> | |||
</Grid>--> | |||
</Grid> | |||
<Grid Width="185" Height="60" Canvas.Top="90"> | |||
<Grid.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/不锈钢纹理2.jpeg"/> | |||
</Grid.Background> | |||
<Grid.RenderTransform> | |||
<TranslateTransform X="-5"/> | |||
</Grid.RenderTransform> | |||
<TextBox x:Name="stockName" Width="58" Height="50" HorizontalAlignment="Left" HorizontalContentAlignment="Center" Background="Transparent" | |||
BorderThickness="0" VerticalContentAlignment="Center" FontSize="13" Foreground="DarkSlateGray"> | |||
</TextBox> | |||
<Border Width="80" Height="50" BorderBrush="DimGray " BorderThickness="2" CornerRadius="5" Margin="15,0,0,0"> | |||
<StackPanel > | |||
<TextBlock HorizontalAlignment="Center" FontSize="12" Text="剩余重量" FontFamily="幼圆" Margin="0,2,0,5"/> | |||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"> | |||
<TextBlock x:Name="stockWeight" HorizontalAlignment="Center" FontSize="16" /> | |||
<TextBlock Text="Kg" FontSize="16"/> | |||
</StackPanel> | |||
</StackPanel> | |||
</Border> | |||
</Grid> | |||
<Grid Width="40" Height="60" Canvas.Top="90" Canvas.Left="180"> | |||
<Grid.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/不锈钢纹理3.jpeg" Stretch="UniformToFill"/> | |||
</Grid.Background> | |||
<Grid.RenderTransform> | |||
<TransformGroup> | |||
<ScaleTransform ScaleX="0.119"/> | |||
<SkewTransform AngleY="-65.5"/> | |||
</TransformGroup> | |||
</Grid.RenderTransform> | |||
<!--<Border VerticalAlignment="Top" Height="140" BorderThickness="10"> | |||
<Border.Background> | |||
<SolidColorBrush Color="BlueViolet"/> | |||
</Border.Background> | |||
</Border>--> | |||
<!--<Grid VerticalAlignment="Bottom" Height="40" Margin="5"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition/> | |||
<ColumnDefinition/> | |||
</Grid.ColumnDefinitions> | |||
<Border Background="#FFAAAAAA" Margin="2"/> | |||
<Border Background="#FFAAAAAA" Margin="2" Grid.Column="1"/> | |||
</Grid>--> | |||
</Grid > | |||
<Path x:Name="arrow" Canvas.Top="175" Canvas.Left="113" Visibility="Collapsed" Data="M -15,8 L 17,17 C 17,17 19,18 17,19 L 17,19 L -15,28 C -15,28 -17,28.2 -16,26 L -16,26 L -5,18 L -16,10 C -16,10 -17,8.5 -15,8 Z"> | |||
<Path.RenderTransform> | |||
<TransformGroup> | |||
<RotateTransform Angle="90"/> | |||
<TranslateTransform Y="0"/> | |||
</TransformGroup> | |||
</Path.RenderTransform> | |||
<Path.Fill> | |||
<LinearGradientBrush> | |||
<LinearGradientBrush.RelativeTransform> | |||
<RotateTransform Angle="-15"/> | |||
</LinearGradientBrush.RelativeTransform> | |||
<GradientStop Color="LightGray" Offset="0"/> | |||
<GradientStop Color="White" Offset="0.4"/> | |||
<GradientStop Color="AntiqueWhite" Offset="1"/> | |||
</LinearGradientBrush> | |||
</Path.Fill> | |||
</Path> | |||
<!--<Path Data="M 95,190 L 95,200" Stroke="Red"/>--> | |||
<Grid Width="185" Height="160" Canvas.Top="80" Canvas.Left="185"> | |||
<Grid.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/不锈钢纹理.jpg"/> | |||
</Grid.Background> | |||
<Grid.RenderTransform> | |||
<TransformGroup> | |||
<ScaleTransform ScaleX="0.288"/> | |||
<SkewTransform AngleY="-36.8"/> | |||
</TransformGroup> | |||
</Grid.RenderTransform> | |||
<!--<Border VerticalAlignment="Top" Height="140" BorderThickness="10"> | |||
<Border.Background> | |||
<DrawingBrush TileMode="Tile" ViewportUnits="Absolute" Viewport="1,0,25,1"> | |||
<DrawingBrush.Drawing> | |||
<GeometryDrawing> | |||
<GeometryDrawing.Pen> | |||
<Pen Brush="#EEE"/> | |||
</GeometryDrawing.Pen> | |||
<GeometryDrawing.Geometry> | |||
<PathGeometry> | |||
<PathFigure> | |||
<LineSegment Point="10,0"/> | |||
<LineSegment Point="10,10"/> | |||
</PathFigure> | |||
</PathGeometry> | |||
</GeometryDrawing.Geometry> | |||
</GeometryDrawing> | |||
</DrawingBrush.Drawing> | |||
</DrawingBrush> | |||
</Border.Background> | |||
</Border>--> | |||
<!--<Grid VerticalAlignment="Bottom" Height="40" Margin="5"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition/> | |||
<ColumnDefinition/> | |||
</Grid.ColumnDefinitions> | |||
<Border Background="#FFAAAAAA" Margin="2"/> | |||
<Border Background="#FFAAAAAA" Margin="2" Grid.Column="1"/> | |||
</Grid>--> | |||
</Grid> | |||
<Border Width="18" Height="18" CornerRadius="10" Canvas.Left="150" Canvas.Top="100"> | |||
<Border.Background> | |||
<RadialGradientBrush> | |||
<GradientStop Color="Gray" Offset="0.6" x:Name="gsGreen"/> | |||
<GradientStop Color="White"/> | |||
</RadialGradientBrush> | |||
</Border.Background> | |||
</Border> | |||
<Border Width="18" Height="18" CornerRadius="10" Canvas.Left="150" Canvas.Top="125" > | |||
<Border.Background> | |||
<RadialGradientBrush> | |||
<GradientStop Color="Gray" Offset="0.6" x:Name="gsRed1"/> | |||
<GradientStop Color="White"/> | |||
</RadialGradientBrush> | |||
</Border.Background> | |||
</Border> | |||
</Canvas> | |||
</Viewbox> | |||
</Border> | |||
</UserControl> |
@@ -0,0 +1,120 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.ComponentModel; | |||
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 BPASmartClient.CustomResource.UserControls | |||
{ | |||
/// <summary> | |||
/// MaterialStock.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class MaterialStock : UserControl | |||
{ | |||
public MaterialStock() | |||
{ | |||
InitializeComponent(); | |||
} | |||
[Category("运行状态")] | |||
public bool IsRunning | |||
{ | |||
get { return (bool)GetValue(IsRunningProperty); } | |||
set { SetValue(IsRunningProperty, value); } | |||
} | |||
public static readonly DependencyProperty IsRunningProperty = | |||
DependencyProperty.Register("IsRunning", typeof(bool), typeof(MaterialStock), new PropertyMetadata(default(bool), new PropertyChangedCallback(OnRunningChanged))); | |||
private static void OnRunningChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |||
{ | |||
VisualStateManager.GoToState(d as MaterialStock, (bool)e.NewValue ? "RunState" : "Stop", false); | |||
} | |||
[Category("报警状态")] | |||
public bool IsFaultState | |||
{ | |||
get { return (bool)GetValue(IsFaultStateProperty); } | |||
set { SetValue(IsFaultStateProperty, value); } | |||
} | |||
public static readonly DependencyProperty IsFaultStateProperty = | |||
DependencyProperty.Register("IsFaultState", typeof(bool), typeof(MaterialStock), new PropertyMetadata(default(bool), new PropertyChangedCallback(OnFaultStateChanged))); | |||
private static void OnFaultStateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |||
{ | |||
VisualStateManager.GoToState(d as MaterialStock, (bool)e.NewValue ? "FaultState" : "NormalState", false); | |||
} | |||
[Category("料仓打开状态")] | |||
public bool IsOpenState | |||
{ | |||
get { return (bool)GetValue(IsOpenStateProperty); } | |||
set { SetValue(IsOpenStateProperty, value); } | |||
} | |||
public static readonly DependencyProperty IsOpenStateProperty = | |||
DependencyProperty.Register("IsOpenState", typeof(bool), typeof(MaterialStock), new PropertyMetadata(default(bool), new PropertyChangedCallback(OnOpenStateChanged))); | |||
private static void OnOpenStateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |||
{ | |||
VisualStateManager.GoToState(d as MaterialStock, (bool)e.NewValue ? "OpenState" : "CloseState", false); | |||
} | |||
[Category("下料状态")] | |||
public bool IsLayOffState | |||
{ | |||
get { return (bool)GetValue(IsLayOffStateProperty); } | |||
set { SetValue(IsLayOffStateProperty, value); } | |||
} | |||
public static readonly DependencyProperty IsLayOffStateProperty = | |||
DependencyProperty.Register("IsLayOffState", typeof(bool), typeof(MaterialStock), new PropertyMetadata(default(bool), new PropertyChangedCallback(OnLayOffStateChanged))); | |||
private static void OnLayOffStateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |||
{ | |||
VisualStateManager.GoToState(d as MaterialStock, (bool)e.NewValue ? "LayOffState" : "LayStopState", false); | |||
if ((d as MaterialStock)?.IsLayOffState == true) | |||
{ | |||
(d as MaterialStock).arrow.Visibility = Visibility.Visible; | |||
} | |||
else if ((d as MaterialStock)?.IsLayOffState == false) | |||
{ | |||
(d as MaterialStock).arrow.Visibility = Visibility.Collapsed; | |||
} | |||
} | |||
[Category("物料重量")] | |||
public double MaterialWeight | |||
{ | |||
get { return (double)GetValue(MaterialWeightProperty); } | |||
set { SetValue(MaterialWeightProperty, value); } | |||
} | |||
public static readonly DependencyProperty MaterialWeightProperty = | |||
DependencyProperty.Register("MaterialWeight", typeof(double), typeof(MaterialStock), new PropertyMetadata(default(double), new PropertyChangedCallback(OnWeightChanged))); | |||
private static void OnWeightChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |||
{ | |||
(d as MaterialStock).stockWeight.Text = e.NewValue.ToString(); | |||
} | |||
[Category("物料名称")] | |||
public string MaterialName | |||
{ | |||
get { return (string)GetValue(MaterialNameProperty); } | |||
set { SetValue(MaterialNameProperty, value); } | |||
} | |||
public static readonly DependencyProperty MaterialNameProperty = | |||
DependencyProperty.Register("MaterialName", typeof(string), typeof(MaterialStock), new PropertyMetadata(default(string), new PropertyChangedCallback(OnNameChanged))); | |||
private static void OnNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |||
{ | |||
(d as MaterialStock).stockName.Text = e.NewValue.ToString(); | |||
} | |||
} | |||
} |
@@ -1,4 +1,5 @@ | |||
using BPASmartClient.DosingHKProject.Model.Siemens; | |||
using BPASmartClient.DosingHKProject.Model.HK_PLC; | |||
using BPASmartClient.DosingHKProject.Model.Siemens; | |||
using System; | |||
using System.Collections.Concurrent; | |||
using System.Collections.Generic; | |||
@@ -75,7 +76,8 @@ namespace BPASmartClient.DosingHKProject.Model | |||
/// </summary> | |||
public bool IsOccupationTray2 { get; set; } = true; | |||
public HKPlcCommRead plcRead = new HKPlcCommRead(); | |||
public HKPlcCommWrite plcWrite = new HKPlcCommWrite(); | |||
#region 本地模拟配方 | |||
/// <summary> | |||
/// 是否使用本地模拟配方 | |||
@@ -7,6 +7,7 @@ using System.Text; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.S7Net; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using System.Threading; | |||
namespace BPASmartClient.DosingHKProject.Model.HK_PLC | |||
{ | |||
@@ -20,7 +21,12 @@ namespace BPASmartClient.DosingHKProject.Model.HK_PLC | |||
{ | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
var res = this.HK_PLC_S7.ReadClass<HKPlcCommRead>(1); | |||
if (res != null && res is HKPlcCommRead data) | |||
{ | |||
GVL_SmallStation.GetInstance.plcRead = data; | |||
} | |||
Thread.Sleep(10); | |||
}),"信号交互"); | |||
} | |||
} | |||
@@ -1,13 +0,0 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingHKProject.Model.HK_PLC | |||
{ | |||
public class HKPlcCommAddress | |||
{ | |||
} | |||
} |
@@ -0,0 +1,63 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingHKProject.Model.HK_PLC | |||
{ | |||
/// <summary> | |||
/// DB1 ReadOnly模块 | |||
/// </summary> | |||
public class HKPlcCommRead | |||
{ | |||
public bool LocalEStop { get; set; } | |||
public bool RemoteEStop { get; set; } | |||
public bool Sensor_Load { get; set; } | |||
public bool Sensor_Station1 { get; set; } | |||
public bool Sensor_Station2 { get; set; } | |||
public bool Sensor_Station3 { get; set; } | |||
public bool Sensor_Station4 { get; set; } | |||
public bool Sensor_Station5 { get; set; } | |||
public bool Sensor_Station6 { get; set; } | |||
public bool Sensor_Unload { get; set; } | |||
public bool Reserve1 { get; set; } | |||
public bool Reserve2 { get; set; } | |||
public bool Reserve3 { get; set; } | |||
public bool Reserve4 { get; set; } | |||
public bool Reserve5 { get; set; } | |||
public bool Reserve6 { get; set; } | |||
public bool Cylinder_LoadBase { get; set; } | |||
public bool Cylinder_Station1Base { get; set; } | |||
public bool Cylinder_Station2Base { get; set; } | |||
public bool Cylinder_Station3Base { get; set; } | |||
public bool Cylinder_Station4Base { get; set; } | |||
public bool Cylinder_Station5Base { get; set; } | |||
public bool Cylinder_Station6Base { get; set; } | |||
public bool Cylinder_UnloadBase { get; set; } | |||
public bool Cylinder_LoadWork { get; set; } | |||
public bool Cylinder_Station1Work { get; set; } | |||
public bool Cylinder_Station2Work { get; set; } | |||
public bool Cylinder_Station3Work { get; set; } | |||
public bool Cylinder_Station4Work { get; set; } | |||
public bool Cylinder_Station5Work { get; set; } | |||
public bool Cylinder_Station6Work { get; set; } | |||
public bool Cylinder_UnloadWork { get; set; } | |||
public bool Reserve7 { get; set; } | |||
public bool Reserve8 { get; set; } | |||
public bool Reserve9 { get; set; } | |||
public bool Reserve10 { get; set; } | |||
public bool Reserve11 { get; set; } | |||
public bool Reserve12 { get; set; } | |||
public bool Reserve13 { get; set; } | |||
public bool Reserve14 { get; set; } | |||
public bool Axis1_Alarm { get; set; } | |||
public bool Axis2_Alarm { get; set; } | |||
public bool Reserve15 { get; set; } | |||
public bool Reserve16 { get; set; } | |||
public bool Reserve17 { get; set; } | |||
public bool Reserve18 { get; set; } | |||
public bool Reserve19 { get; set; } | |||
public bool Reserve20 { get; set; } | |||
} | |||
} |
@@ -0,0 +1,49 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingHKProject.Model.HK_PLC | |||
{ | |||
/// <summary> | |||
/// DB1 Write模块 | |||
/// </summary> | |||
public class HKPlcCommWrite | |||
{ | |||
public bool Reserve1 { get; set; } | |||
public bool Reserve2{ get; set; } | |||
public bool Cylinder_LoadOutput{ get; set; } | |||
public bool Cylinder_Station1Output{ get; set; } | |||
public bool Cylinder_Station2Output{ get; set; } | |||
public bool Cylinder_Station3Output{ get; set; } | |||
public bool Cylinder_Station4Output{ get; set; } | |||
public bool Cylinder_Station5Output{ get; set; } | |||
public bool Cylinder_Station6Output{ get; set; } | |||
public bool Cylinder_UnloadOutput{ get; set; } | |||
public bool Reserve3{ get; set; } | |||
public bool Reserve4{ get; set; } | |||
public bool Reserve5{ get; set; } | |||
public bool Reserve6{ get; set; } | |||
public bool Reserve7{ get; set; } | |||
public bool Reserve8{ get; set; } | |||
public bool TriColourLight_Yellow{ get; set; } | |||
public bool TriColourLight_Green{ get; set; } | |||
public bool TriColourLight_Red{ get; set; } | |||
public bool Buzzer{ get; set; } | |||
public bool Reserve9{ get; set; } | |||
public bool Reserve10{ get; set; } | |||
public bool Reserve11{ get; set; } | |||
public bool Reserve12{ get; set; } | |||
public bool Axis1_Start{ get; set; } | |||
public bool Axis2_Start{ get; set; } | |||
public bool Axis1_Stop{ get; set; } | |||
public bool Axis2_Stop{ get; set; } | |||
public bool Axis1_Reset{ get; set; } | |||
public bool Axis2_Reset{ get; set; } | |||
public bool Reserve13{ get; set; } | |||
public bool Reserve14{ get; set; } | |||
public short Axis1_Speed{ get; set; } | |||
public short Axis2_Speed{ get; set; } | |||
} | |||
} |
@@ -202,20 +202,24 @@ namespace BPASmartClient.DosingHKProject.Model | |||
int trayCode = RemoteRecipes.ElementAt(index).TrayCode; | |||
string recipeName = RemoteRecipes.ElementAt(index).RecipeName; | |||
string windSend = RemoteRecipes.ElementAt(index).ToString(); | |||
if (GVL_SmallStation.GetInstance.RecipeStatusID == 0) | |||
if (GVL_SmallStation.GetInstance.RecipeStatusID == 0) | |||
{ | |||
HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true); | |||
GVL_SmallStation.GetInstance.RecipeStatusID = 1; | |||
MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},下发完成"); | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX1.3", true); | |||
RunInit(); | |||
} | |||
if (HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX1.3") && GVL_SmallStation.GetInstance.RecipeStatusID == 1) | |||
if (GVL_SmallStation.GetInstance.RecipeStatusID == 1) | |||
{ | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX1.3", false); | |||
HKDevice.HK_PLC_S7.Write<bool>("DB2.DBX3.0", true); | |||
HKDevice.HK_PLC_S7.Write<bool>("DB2.DBX3.1", true); | |||
GVL_SmallStation.GetInstance.RecipeStatusID = 2; | |||
MessageLog.GetInstance.ShowRunLog($"托盘1,{ recipeName}plc端 配方接收完成"); | |||
} | |||
if (GVL_SmallStation.GetInstance.RecipeStatusID == 2) | |||
if (HKDevice.HK_PLC_S7.Read<bool>("DB2.DBX3.0") && HKDevice.HK_PLC_S7.Read<bool>("DB2.DBX3.1") && GVL_SmallStation.GetInstance.RecipeStatusID == 2) | |||
{ | |||
if (GVL_SmallStation.GetInstance.plcRead.Sensor_Load) | |||
{ | |||
} | |||
} | |||
if (GVL_SmallStation.GetInstance.RecipeStatusID == 3) | |||
{ | |||
if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read<bool>("DB3.DBX50.0"))) | |||
{ | |||
@@ -223,7 +227,6 @@ namespace BPASmartClient.DosingHKProject.Model | |||
MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{res}料仓,允许配料"); | |||
if (res > 0 && res is float loc) | |||
{ | |||
//int decimalNum = Convert.ToInt32(loc.ToString().Substring(loc.ToString().IndexOf(".") + 1)); | |||
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); | |||
float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; | |||
if (loc_index >= 0) | |||
@@ -324,5 +327,24 @@ namespace BPASmartClient.DosingHKProject.Model | |||
} | |||
} | |||
} | |||
private int RunInit() | |||
{ | |||
if (HKDevice.IsConnected) | |||
{ | |||
try | |||
{ | |||
HKPlcCommWrite signReset = new HKPlcCommWrite(); | |||
HKDevice.HK_PLC_S7.WriteClass<HKPlcCommWrite>(signReset, 2); | |||
return 1; | |||
} | |||
catch (Exception ex) | |||
{ | |||
return 2; | |||
} | |||
}else | |||
{ | |||
return 2; | |||
} | |||
} | |||
} | |||
} |
@@ -28,9 +28,6 @@ namespace BPASmartClient.DosingHKProject.ViewModel | |||
//ObservableCollection<RemoteRecipeRawMaterial> RawMaterials { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>(); | |||
public RecipeReceiveViewModel() | |||
{ | |||
IsUseLocalRecipe = GVL_SmallStation.GetInstance.IsUseLocalRecipe; | |||
IsUseWindSendDosing = GVL_SmallStation.GetInstance.IsUseLocalRecipe; | |||
//Json<LocaPar>.Read(); | |||
Recipes = Json<LocalRecipeDataColl>.Data.Recipes; | |||
NewRecipe = new RelayCommand(() => | |||
@@ -67,20 +64,13 @@ namespace BPASmartClient.DosingHKProject.ViewModel | |||
}); | |||
IssueRecipe = new RelayCommand<object>((o) => | |||
{ | |||
if (IsUseLocalRecipe == false) | |||
{ | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "错误", $"未处于本地模拟配方状态!"); | |||
return; | |||
} | |||
else | |||
if (o != null && o is string cnt) | |||
{ | |||
if (o != null && o is string cnt) | |||
var res = Json<LocalRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == cnt); | |||
if (res != null) | |||
{ | |||
var res = Json<LocalRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == cnt); | |||
if (res != null) | |||
{ | |||
MessageLog.GetInstance.ShowUserLog($"下发配方——{res.RecipeName}"); | |||
} | |||
Json<RemoteRecipeDataColl>.Data.Recipes.Add(res); | |||
MessageLog.GetInstance.ShowUserLog($"下发配方——{res.RecipeName}"); | |||
} | |||
} | |||
}); | |||
@@ -126,12 +116,6 @@ namespace BPASmartClient.DosingHKProject.ViewModel | |||
Json<LocalRecipeDataColl>.Data.Recipes.Clear(); | |||
}); | |||
} | |||
public bool IsUseLocalRecipe { get { return _mIsUseLocalRecipe; }set { _mIsUseLocalRecipe = value; OnPropertyChanged(); } } | |||
private bool _mIsUseLocalRecipe = GVL_SmallStation.GetInstance.IsUseLocalRecipe; | |||
public bool IsUseWindSendDosing { get { return _mIsUseWindSendDosing; } set { _mIsUseWindSendDosing = value;OnPropertyChanged(); } } | |||
private bool _mIsUseWindSendDosing = GVL_SmallStation.GetInstance.IsUseLocalRecipe; | |||
public RelayCommand<object> DetailsCommand { get; set; } | |||
public RelayCommand<object> IssueRecipe { get; set; } | |||
public RelayCommand<object> RemoveRecipe { get; set; } | |||
@@ -85,6 +85,10 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
/// </summary> | |||
public bool IsOccupationTray2 { get; set; } = true; | |||
/// <summary> | |||
/// 顶升气缸的信号 | |||
/// </summary> | |||
public bool[] Cylinder_JackInfo = new bool[15]; | |||
#region 本地模拟配方 | |||
/// <summary> | |||
@@ -80,7 +80,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
} | |||
else | |||
{ | |||
//报警,配方的原料名称下发和设备不一致 | |||
MessageLog.GetInstance.AlarmLog("配方名称与本地不符合"); | |||
} | |||
} | |||
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData() | |||
@@ -101,7 +101,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
ActionManage.GetInstance.CancelRegister("LocalSimulationRecipeIssue"); | |||
ActionManage.GetInstance.Register(new Action<Object>((res) => | |||
{ | |||
if (res!=null && res is RemoteRecipeData recipe) | |||
if (res != null && res is RemoteRecipeData recipe) | |||
{ | |||
Json<RemoteRecipeDataColl>.Data.Recipes.Add(recipe); | |||
} | |||
@@ -167,12 +167,20 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
for (int i = 0; i < 8; i++) | |||
{ | |||
HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX0." + i); | |||
GVL_SmallStation.GetInstance.Cylinder_JackInfo[i] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX0." + i); | |||
} | |||
for (int i = 0; i < 8; i++) | |||
for (int i = 0; i < 7; i++) | |||
{ | |||
HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX1." + i); | |||
GVL_SmallStation.GetInstance.Cylinder_JackInfo[i + 8] = HKDevice.HK_PLC_S7.Read<bool>("DB5.DBX0." + i); | |||
} | |||
ActionManage.GetInstance.Register(new Action(() => | |||
{ | |||
HKDevice.HK_PLC_S7.Write<bool>("M10.0", true); | |||
}), "ManualEStop", true); | |||
ActionManage.GetInstance.Register(new Action(() => | |||
{ | |||
HKDevice.HK_PLC_S7.Write<bool>("M10.0", false); | |||
}), "ManualEReset", true); | |||
} | |||
private void ManualOpen() | |||
{ | |||
@@ -674,7 +682,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
MessageLog.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{res}料仓,允许配料"); | |||
if (res > 0 && res is float loc) | |||
{ | |||
//int decimalNum = Convert.ToInt32(loc.ToString().Substring(loc.ToString().IndexOf(".") + 1)); | |||
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); | |||
float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; | |||
if (loc_index >= 0) | |||
@@ -55,8 +55,8 @@ | |||
<Grid Margin="8"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="1*"/> | |||
<RowDefinition Height="3*"/> | |||
<RowDefinition Height="2*"/> | |||
<RowDefinition Height="2*"/> | |||
<RowDefinition Height="3*"/> | |||
<RowDefinition Height="2*"/> | |||
</Grid.RowDefinitions> | |||
@@ -83,37 +83,46 @@ | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Text="总控制" /> | |||
<Grid Grid.Row="1"> | |||
<Grid Grid.Row="1"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="1*"></ColumnDefinition> | |||
<ColumnDefinition Width="1*"></ColumnDefinition> | |||
<ColumnDefinition Width="1*"></ColumnDefinition> | |||
<ColumnDefinition Width="6*"/> | |||
<ColumnDefinition Width="4*"/> | |||
</Grid.ColumnDefinitions> | |||
<Grid.RowDefinitions> | |||
<RowDefinition></RowDefinition> | |||
<RowDefinition></RowDefinition> | |||
</Grid.RowDefinitions> | |||
<WrapPanel VerticalAlignment="Center" HorizontalAlignment="Center" > | |||
<TextBlock Margin="0,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center" | |||
FontSize="24" Foreground="Aqua" Text="当前系统模式:"/> | |||
<RadioButton Content="Auto模式" IsChecked="True" Margin="15" FontSize="16" | |||
Foreground="Aqua" Command="{Binding AutoMode}"></RadioButton> | |||
<RadioButton Content="Debug模式" IsChecked="false" Margin="15" FontSize="16" | |||
Foreground="Aqua" Command="{Binding DebugMode}"></RadioButton> | |||
</WrapPanel> | |||
<Grid | |||
Grid.Column="3" > | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition></ColumnDefinition> | |||
<ColumnDefinition></ColumnDefinition> | |||
</Grid.ColumnDefinitions> | |||
<pry:IcoButton | |||
Command="{Binding EStopCommand}" | |||
Grid.Column="0" | |||
Margin="15" | |||
Content="急停" | |||
FontSize="40" | |||
Foreground="Aqua" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
<pry:IcoButton | |||
Command="{Binding EResetCommand}" | |||
Grid.Column="1" | |||
Margin="15" | |||
Content="复位" | |||
FontSize="40" | |||
Foreground="Aqua" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
</Grid> | |||
</Grid> | |||
<RadioButton | |||
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType={x:Type ListView}, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Name}" | |||
Content="启动" | |||
Foreground="Aqua" | |||
IsChecked="False" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
<RadioButton | |||
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType={x:Type ListView}, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Name}" | |||
Content="停止" | |||
Foreground="Aqua" | |||
IsChecked="False" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
</Grid> | |||
<!--#region 升降气缸--> | |||
<Grid | |||
Name="cy" | |||
Name="zd" | |||
Grid.Row="1" | |||
Margin="5"> | |||
<Grid.RowDefinitions> | |||
@@ -122,8 +131,8 @@ | |||
</Grid.RowDefinitions> | |||
<pry:ImageBorder | |||
Grid.RowSpan="2" | |||
Width="{Binding ElementName=cy, Path=ActualWidth}" | |||
Height="{Binding ElementName=cy, Path=ActualHeight}" /> | |||
Width="{Binding ElementName=zd, Path=ActualWidth}" | |||
Height="{Binding ElementName=zd, Path=ActualHeight}" /> | |||
<Image | |||
Margin="2,3,0,0" | |||
@@ -134,88 +143,180 @@ | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Text="升降气缸控制" /> | |||
<ListView | |||
Grid.Row="1" | |||
Background="Transparent" | |||
BorderBrush="#00BEFA" | |||
BorderThickness="0" | |||
ItemsSource="{Binding cylinderModels}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<UniformGrid | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Top" | |||
Columns="8" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<Grid | |||
Width="200" | |||
Height="100" | |||
Margin="0,0,0,15" | |||
Background="Transparent"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition /> | |||
<RowDefinition Height="30" /> | |||
</Grid.RowDefinitions> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.5*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="1" | |||
Grid.ColumnSpan="2" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Foreground="Aqua" | |||
Text="{Binding Name}" /> | |||
<pry:Cylinder | |||
Grid.Row="1" | |||
Grid.ColumnSpan="3" | |||
Width="200" | |||
Height="50" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
LeftTogIsChecked="{Binding LeftTog}" | |||
RightTogIsChecked="{Binding RightTog}" /> | |||
<RadioButton | |||
Grid.Row="2" | |||
Grid.Column="1" | |||
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Name}" | |||
Content="伸出" | |||
Foreground="Aqua" | |||
IsChecked="True" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
<RadioButton | |||
Grid.Row="2" | |||
Grid.Column="2" | |||
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Name}" | |||
Content="缩回" | |||
Foreground="Aqua" | |||
IsChecked="False" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
</Grid> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
Text="线体控制" /> | |||
<Grid Grid.Row="1"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="1*"></ColumnDefinition> | |||
<ColumnDefinition Width="1*"></ColumnDefinition> | |||
<ColumnDefinition Width="1*"></ColumnDefinition> | |||
<ColumnDefinition Width="1*"></ColumnDefinition> | |||
<ColumnDefinition Width="1*"></ColumnDefinition> | |||
</Grid.ColumnDefinitions> | |||
<Grid.RowDefinitions> | |||
<RowDefinition></RowDefinition> | |||
</Grid.RowDefinitions> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition></ColumnDefinition> | |||
<ColumnDefinition></ColumnDefinition> | |||
</Grid.ColumnDefinitions> | |||
<Grid.RowDefinitions> | |||
<RowDefinition></RowDefinition> | |||
<RowDefinition></RowDefinition> | |||
</Grid.RowDefinitions> | |||
<TextBlock Grid.ColumnSpan="2" Margin="0,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center" | |||
FontSize="16" Foreground="Aqua" Text="进桶侧调速电机"/> | |||
<pry:IcoButton | |||
Margin="10" | |||
Grid.Row="1" | |||
Grid.Column="0" | |||
Command="{Binding StartCommand}" | |||
Content="启动" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
<pry:IcoButton | |||
Grid.Row="1" | |||
Grid.Column="1" | |||
Margin="10" | |||
Command="{Binding CloseCommand}" | |||
Content="停止" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
</Grid> | |||
<Border | |||
BorderThickness="1,0,1,0" /> | |||
<Grid Grid.Column="1"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition></ColumnDefinition> | |||
<ColumnDefinition></ColumnDefinition> | |||
</Grid.ColumnDefinitions> | |||
<Grid.RowDefinitions> | |||
<RowDefinition></RowDefinition> | |||
<RowDefinition></RowDefinition> | |||
</Grid.RowDefinitions> | |||
<TextBlock Grid.ColumnSpan="2" Margin="0,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center" | |||
FontSize="16" Foreground="Aqua" Text="过渡段调速电机"/> | |||
<pry:IcoButton | |||
Margin="10" | |||
Grid.Row="1" | |||
Grid.Column="0" | |||
Command="{Binding StartCommand}" | |||
CommandParameter="{Binding }" | |||
Content="启动" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
<pry:IcoButton | |||
Grid.Row="1" | |||
Grid.Column="1" | |||
Margin="10" | |||
Command="{Binding StopCommand}" | |||
Content="停止" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
</Grid> | |||
<Grid Grid.Column="2"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition></ColumnDefinition> | |||
<ColumnDefinition></ColumnDefinition> | |||
</Grid.ColumnDefinitions> | |||
<Grid.RowDefinitions> | |||
<RowDefinition></RowDefinition> | |||
<RowDefinition></RowDefinition> | |||
</Grid.RowDefinitions> | |||
<TextBlock Grid.ColumnSpan="2" Margin="0,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center" | |||
FontSize="16" Foreground="Aqua" Text="出桶侧调速电机"/> | |||
<pry:IcoButton | |||
Margin="10" | |||
Grid.Row="1" | |||
Grid.Column="0" | |||
Command="{Binding StartCommand}" | |||
Content="启动" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
<pry:IcoButton | |||
Grid.Row="1" | |||
Grid.Column="1" | |||
Margin="10" | |||
Command="{Binding CloseCommand}" | |||
Content="停止" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
</Grid> | |||
<Border | |||
BorderThickness="1,0,1,0" /> | |||
<Grid Grid.Column="3"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition></ColumnDefinition> | |||
<ColumnDefinition></ColumnDefinition> | |||
</Grid.ColumnDefinitions> | |||
<Grid.RowDefinitions> | |||
<RowDefinition></RowDefinition> | |||
<RowDefinition></RowDefinition> | |||
</Grid.RowDefinitions> | |||
<TextBlock Grid.ColumnSpan="2" Margin="0,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center" | |||
FontSize="16" Foreground="Aqua" Text="伺服1调速电机"/> | |||
<pry:IcoButton | |||
Margin="10" | |||
Grid.Row="1" | |||
Grid.Column="0" | |||
Command="{Binding StartCommand}" | |||
Content="启动" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
<pry:IcoButton | |||
Grid.Row="1" | |||
Grid.Column="1" | |||
Margin="10" | |||
Command="{Binding CloseCommand}" | |||
Content="停止" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
</Grid> | |||
<Grid Grid.Column="4"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition></ColumnDefinition> | |||
<ColumnDefinition></ColumnDefinition> | |||
</Grid.ColumnDefinitions> | |||
<Grid.RowDefinitions> | |||
<RowDefinition></RowDefinition> | |||
<RowDefinition></RowDefinition> | |||
</Grid.RowDefinitions> | |||
<TextBlock Grid.ColumnSpan="2" Margin="0,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center" | |||
FontSize="16" Foreground="Aqua" Text="伺服2调速电机"/> | |||
<pry:IcoButton | |||
Margin="10" | |||
Grid.Row="1" | |||
Grid.Column="0" | |||
Command="{Binding StartCommand}" | |||
Content="启动" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
<pry:IcoButton | |||
Grid.Row="1" | |||
Grid.Column="1" | |||
Margin="10" | |||
Command="{Binding CloseCommand}" | |||
Content="停止" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
</Grid> | |||
</Grid> | |||
</Grid> | |||
<!--#endregion--> | |||
<!--#region 阻挡气缸--> | |||
<!--#region 升降气缸--> | |||
<Grid | |||
Name="zd" | |||
Name="cy" | |||
Grid.Row="2" | |||
Margin="5"> | |||
<Grid.RowDefinitions> | |||
@@ -224,8 +325,8 @@ | |||
</Grid.RowDefinitions> | |||
<pry:ImageBorder | |||
Grid.RowSpan="2" | |||
Width="{Binding ElementName=zd, Path=ActualWidth}" | |||
Height="{Binding ElementName=zd, Path=ActualHeight}" /> | |||
Width="{Binding ElementName=cy, Path=ActualWidth}" | |||
Height="{Binding ElementName=cy, Path=ActualHeight}" /> | |||
<Image | |||
Margin="2,3,0,0" | |||
@@ -236,14 +337,13 @@ | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Text="阻挡气缸控制" /> | |||
Text="升降气缸控制" /> | |||
<ListView | |||
Grid.Row="1" | |||
Margin="10" | |||
Background="Transparent" | |||
BorderBrush="#00BEFA" | |||
BorderThickness="0" | |||
ItemsSource="{Binding BlockCylinders}" | |||
ItemsSource="{Binding cylinderModels}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
@@ -299,6 +399,7 @@ | |||
Foreground="Aqua" | |||
IsChecked="True" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
<RadioButton | |||
Grid.Row="2" | |||
Grid.Column="2" | |||
@@ -315,6 +416,10 @@ | |||
</Grid> | |||
<!--#endregion--> | |||
<!--#region 阻挡气缸--> | |||
<!--#endregion--> | |||
<!--#region 托盘气缸--> | |||
<Grid | |||
Name="tp" | |||
@@ -78,6 +78,14 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
{ | |||
ActionManage.GetInstance.Send("ManualClose", o); | |||
}); | |||
EStopCommand = new RelayCommand(() => | |||
{ | |||
ActionManage.GetInstance.Send("ManualEStop"); | |||
}); | |||
EResetCommand = new RelayCommand(() => | |||
{ | |||
ActionManage.GetInstance.Send("ManualEReset"); | |||
}); | |||
} | |||
/// <summary> | |||
@@ -100,6 +108,9 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
public RelayCommand<object> Close { get; set; } | |||
public RelayCommand EStopCommand { get; set; } | |||
public RelayCommand EResetCommand { get; set; } | |||
} | |||
public class CylinderModel : ObservableObject | |||
@@ -9,6 +9,9 @@ | |||
<ItemGroup> | |||
<None Remove="Fonts\ds-digib.ttf" /> | |||
<None Remove="Fonts\Quartz Regular.ttf" /> | |||
<None Remove="Images\03.png" /> | |||
<None Remove="Images\1.png" /> | |||
<None Remove="Images\2609.png" /> | |||
<None Remove="Images\api.png" /> | |||
<None Remove="Images\biogebj.png" /> | |||
@@ -25,6 +28,7 @@ | |||
<None Remove="Images\mqttrun.png" /> | |||
<None Remove="Images\mqttstop.png" /> | |||
<None Remove="Images\nbbj.png" /> | |||
<None Remove="Images\Pop_bg.png" /> | |||
<None Remove="Images\redis.png" /> | |||
<None Remove="Images\redisrun.png" /> | |||
<None Remove="Images\redisstop.png" /> | |||
@@ -42,7 +46,19 @@ | |||
<None Remove="Images\上箭头.png" /> | |||
<None Remove="Images\借出.png" /> | |||
<None Remove="Images\光柱.png" /> | |||
<None Remove="Images\右1.png" /> | |||
<None Remove="Images\右2.png" /> | |||
<None Remove="Images\左1.png" /> | |||
<None Remove="Images\左2.png" /> | |||
<None Remove="Images\拉出.png" /> | |||
<None Remove="Images\收缩.png" /> | |||
<None Remove="Images\日期1.png" /> | |||
<None Remove="Images\矩形边框.png" /> | |||
<None Remove="Images\矩形边框1.png" /> | |||
<None Remove="Images\系统名称.png" /> | |||
<None Remove="Images\返回按钮1.png" /> | |||
<None Remove="Images\返回按钮2.png" /> | |||
<None Remove="Images\返回按钮图标.png" /> | |||
<None Remove="Images\退出.png" /> | |||
<None Remove="Images\顶部线条.png" /> | |||
</ItemGroup> | |||
@@ -75,6 +91,15 @@ | |||
<ItemGroup> | |||
<Resource Include="Fonts\ds-digib.ttf" /> | |||
<Resource Include="Fonts\Quartz Regular.ttf"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
<Resource Include="Images\03.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
<Resource Include="Images\1.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
<Resource Include="Images\2609.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
@@ -114,6 +139,9 @@ | |||
<Resource Include="Images\nbbj.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
<Resource Include="Images\Pop_bg.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
<Resource Include="Images\redis.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
@@ -174,9 +202,45 @@ | |||
<Resource Include="Images\button2.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
<Resource Include="Images\右1.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
<Resource Include="Images\右2.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
<Resource Include="Images\左1.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
<Resource Include="Images\左2.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
<Resource Include="Images\拉出.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
<Resource Include="Images\收缩.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
<Resource Include="Images\日期1.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
<Resource Include="Images\矩形边框.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
<Resource Include="Images\矩形边框1.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
<Resource Include="Images\系统名称.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
<Resource Include="Images\返回按钮1.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
<Resource Include="Images\返回按钮2.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
<Resource Include="Images\返回按钮图标.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
<Resource Include="Images\退出.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
@@ -0,0 +1,48 @@ | |||
<UserControl x:Class="BPASmartClient.SCADAControl.CustomerControls.DateTimeUI" | |||
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:BPASmartClient.SCADAControl.CustomerControls" | |||
mc:Ignorable="d" | |||
x:Name="main" | |||
d:DesignHeight="30" d:DesignWidth="100"> | |||
<UserControl.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" /> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
</UserControl.Resources> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="20" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<StackPanel Grid.Row="0" Orientation="Horizontal"> | |||
<TextBlock | |||
x:Name="time" | |||
FontFamily="../Fonts/#Quartz M" | |||
FontSize="16" Foreground="{Binding Foreground, ElementName=main}"> | |||
14:48:30 | |||
</TextBlock> | |||
<Image Margin="10,0,0,0" Style="{DynamicResource timeImage}" /> | |||
</StackPanel> | |||
<StackPanel Grid.Row="1" Orientation="Horizontal"> | |||
<TextBlock | |||
x:Name="dateRL" Foreground="{Binding Foreground, ElementName=main}" | |||
FontFamily="../Fonts/#Quartz M" | |||
FontSize="10"> | |||
星期一 | |||
</TextBlock> | |||
<TextBlock | |||
x:Name="date" | |||
Margin="10,0,0,0" Foreground="{Binding Foreground, ElementName=main}" | |||
FontFamily="../Fonts/#Quartz M" | |||
FontSize="10"> | |||
2021-11-13 | |||
</TextBlock> | |||
</StackPanel> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,56 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading; | |||
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 BPASmartClient.SCADAControl.CustomerControls | |||
{ | |||
/// <summary> | |||
/// DateTimeUI.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class DateTimeUI : UserControl | |||
{ | |||
public DateTimeUI() | |||
{ | |||
InitializeComponent(); | |||
Task.Run(new Action(() => | |||
{ | |||
while (true) | |||
{ | |||
this.Dispatcher.Invoke(new Action(() => | |||
{ | |||
time.Text = DateTime.Now.ToString("HH:mm:ss"); | |||
date.Text = DateTime.Now.ToString("yyyy-MM-dd"); | |||
if (DateTime.Now.DayOfWeek == DayOfWeek.Monday) | |||
dateRL.Text = "星期一"; | |||
else if (DateTime.Now.DayOfWeek == DayOfWeek.Tuesday) | |||
dateRL.Text = "星期二"; | |||
else if (DateTime.Now.DayOfWeek == DayOfWeek.Wednesday) | |||
dateRL.Text = "星期三"; | |||
else if (DateTime.Now.DayOfWeek == DayOfWeek.Thursday) | |||
dateRL.Text = "星期四"; | |||
else if (DateTime.Now.DayOfWeek == DayOfWeek.Friday) | |||
dateRL.Text = "星期五"; | |||
else if (DateTime.Now.DayOfWeek == DayOfWeek.Saturday) | |||
dateRL.Text = "星期六"; | |||
else if (DateTime.Now.DayOfWeek == DayOfWeek.Sunday) | |||
dateRL.Text = "星期天"; | |||
})); | |||
Thread.Sleep(500); | |||
} | |||
})); | |||
} | |||
} | |||
} |
@@ -35,6 +35,9 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
public SwitchButton() | |||
{ | |||
ResourceDictionary languageResDic = new ResourceDictionary(); | |||
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml", UriKind.RelativeOrAbsolute); | |||
this.Resources.MergedDictionaries.Add(languageResDic); | |||
SetCurrentValue(WidthProperty, 120d); | |||
SetCurrentValue(HeightProperty, 40d); | |||
} | |||
@@ -100,7 +103,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
public static readonly DependencyProperty DKColorProperty = | |||
DependencyProperty.Register("DKColor", typeof(Brush), typeof(SwitchButton), new PropertyMetadata(new SolidColorBrush(Colors.Transparent))); | |||
TranslateTransform transX; | |||
Ellipse ellipse; | |||
public Ellipse ellipse; | |||
public override void OnApplyTemplate() | |||
{ | |||
base.OnApplyTemplate(); | |||
@@ -119,6 +122,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
} | |||
void Refresh() | |||
{ | |||
if (ellipse == null) | |||
{ | |||
return; | |||
@@ -160,6 +164,9 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
{ | |||
Class_DataBus.GetInstance().BindingAction += BindingActionHeader; | |||
this.Click += SwitchButton_Click; | |||
if (this.IsChecked == true) Config.GetInstance().RunJsScipt(CheckedExec); | |||
else Config.GetInstance().RunJsScipt(UnCheckedExec); | |||
Refresh(); | |||
} | |||
public void BindingActionHeader(object sender, EventArgs e) | |||
{ | |||
@@ -197,6 +197,40 @@ | |||
</Setter> | |||
</Style> | |||
<Style x:Key="swith_button" TargetType="{x:Type ctrl:SwitchButton}"> | |||
<Setter Property="Background" Value="{StaticResource ControlBackground}" /> | |||
<Setter Property="BorderBrush" Value="LightGray" /> | |||
<Setter Property="Foreground" Value="Gray" /> | |||
<Setter Property="BorderThickness" Value="0" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="ctrl:SwitchButton"> | |||
<Border | |||
Background="{TemplateBinding Background}" | |||
BorderBrush="{TemplateBinding BorderBrush}" | |||
BorderThickness="{TemplateBinding BorderThickness}" | |||
CornerRadius="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ActualHeight, Converter={StaticResource HalfNumber}}"> | |||
<Grid> | |||
<Ellipse | |||
x:Name="ELLIPSE" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
Fill="Gray" | |||
RenderTransformOrigin="0.5,0.5" | |||
Stroke="{StaticResource ControlBorderBrush}" | |||
StrokeThickness="1"> | |||
<Ellipse.RenderTransform> | |||
<TransformGroup> | |||
<TranslateTransform x:Name="TranslateX" X="2" /> | |||
</TransformGroup> | |||
</Ellipse.RenderTransform> | |||
</Ellipse> | |||
</Grid> | |||
</Border> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<Style TargetType="ctrl:DigitalNumber"> | |||
<Setter Property="Background" Value="#FF1A1E22" /> | |||
<Setter Property="Foreground" Value="#FF0AA74D" /> | |||
@@ -3030,30 +3064,41 @@ | |||
</Style> | |||
<DataTemplate x:Key="X_PageBoxStyle"> | |||
<Button x:Name="dsd" Background="Transparent" BorderBrush="Transparent" BorderThickness="0" CommandParameter="{Binding .}" Command="{Binding DataContext.MenSelectPageCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"> | |||
<Grid > | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="auto"/> | |||
<RowDefinition Height="auto"/> | |||
</Grid.RowDefinitions> | |||
<Grid Height="50" Width="100" > | |||
<Grid.Background> | |||
<ImageBrush ImageSource="../Images/bj.png" Stretch="UniformToFill"/> | |||
</Grid.Background> | |||
</Grid> | |||
<Rectangle Height="50" Width="100" Stroke="CadetBlue" StrokeThickness="1"> | |||
<Rectangle.Fill> | |||
<VisualBrush Visual="{Binding visual,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> | |||
</Rectangle.Fill> | |||
</Rectangle> | |||
<Rectangle Width="100" Height="20" Grid.Row="1" Fill="Transparent" Stroke="CadetBlue" StrokeThickness="1,0,1,1"/> | |||
<TextBlock FontWeight="Bold" Margin="5,0,0,0" FontSize="14" Foreground="#FFFFA500" | |||
<Button x:Name="dsd" HorizontalAlignment="Center" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" VerticalAlignment="Center" Background="Transparent" BorderBrush="Transparent" BorderThickness="0" CommandParameter="{Binding .}" Command="{Binding DataContext.MenSelectPageCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"> | |||
<Button.Template> | |||
<ControlTemplate> | |||
<Grid Margin="0"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="auto"/> | |||
<RowDefinition Height="auto"/> | |||
</Grid.RowDefinitions> | |||
<Grid Height="50" Width="100" > | |||
<Grid.Background> | |||
<ImageBrush ImageSource="../Images/bj.png" Stretch="UniformToFill"/> | |||
</Grid.Background> | |||
</Grid> | |||
<Rectangle Height="50" Width="100" Stroke="#4818659B" StrokeThickness="1"> | |||
<Rectangle.Fill> | |||
<VisualBrush Visual="{Binding visual,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> | |||
</Rectangle.Fill> | |||
</Rectangle> | |||
<Rectangle Width="100" Height="20" Grid.Row="1" Fill="Transparent" Stroke="#4818659B" StrokeThickness="1,0,1,1"/> | |||
<TextBlock FontWeight="Normal" Margin="5,0,0,0" FontSize="12" Foreground="#a2c2e8" | |||
x:Name="txt" | |||
Grid.Row="2" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Bottom" | |||
VerticalAlignment="Center" | |||
FontFamily="../Fonts/#Quartz M" | |||
Text="{Binding Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> | |||
</Grid> | |||
<TextBlock FontWeight="Bold" Margin="5,0,5,0" FontSize="8" Foreground="{TemplateBinding Foreground}" | |||
Grid.Row="2" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Bottom" Visibility="Collapsed" | |||
Text="{Binding Sort,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> | |||
</Grid> | |||
</ControlTemplate> | |||
</Button.Template> | |||
</Button> | |||
@@ -3063,7 +3108,49 @@ | |||
</DataTemplate> | |||
<Style x:Key="ItemContainerStyle1" TargetType="ListBoxItem"> | |||
<Setter Property="HorizontalAlignment" Value="Left"/> | |||
<Setter Property="VerticalAlignment" Value="Top"/> | |||
<Setter Property="Cursor" Value="Hand"/> | |||
<Setter Property="HorizontalContentAlignment" Value="Left"/> | |||
<Setter Property="VerticalContentAlignment" Value="Top"/> | |||
<Setter Property="FocusVisualStyle" Value="{x:Null}"/> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="ListBoxItem"> | |||
<Border Name="Border" | |||
Margin="5" | |||
Background="Transparent" | |||
BorderBrush="Transparent" | |||
BorderThickness="1" | |||
SnapsToDevicePixels="True"> | |||
<ContentPresenter /> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="Border" Property="Background" Value="#EA18979B"/> | |||
<Setter TargetName="Border" Property="BorderBrush" Value="#EA18979B"/> | |||
<Setter Property="Foreground" Value="#a2c2e8"/> | |||
</Trigger> | |||
<Trigger Property="IsMouseOver" Value="False"> | |||
<Setter TargetName="Border" Property="Background" Value="#EA18659B"/> | |||
<Setter TargetName="Border" Property="BorderBrush" Value="#EA18659B"/> | |||
<Setter Property="Foreground" Value="#a2c2e8"/> | |||
</Trigger> | |||
<Trigger Property="IsSelected" Value="true"> | |||
<Setter TargetName="Border" Property="Background" Value="#EA18979B"/> | |||
<Setter TargetName="Border" Property="BorderBrush" Value="#EA18979B"/> | |||
<Setter Property="Foreground" Value="#a2c2e8"/> | |||
</Trigger> | |||
<Trigger Property="IsEnabled" Value="false"> | |||
<Setter Property="Foreground" Value="LightGray"/> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<!--#endregion--> | |||
<Style x:Key="image矩阵框" TargetType="Image"> | |||
<Style.Setters> | |||
@@ -3073,15 +3160,193 @@ | |||
</Style.Setters> | |||
</Style> | |||
<Style x:Key="image矩阵框1" TargetType="WrapPanel"> | |||
<Style x:Key="image系统名称" TargetType="Image"> | |||
<Style.Setters> | |||
<Setter Property="VerticalAlignment" Value="Stretch" /> | |||
<Setter Property="HorizontalAlignment" Value="Stretch" /> | |||
<Setter Property="Source" Value="../Images/系统名称.png" /> | |||
</Style.Setters> | |||
</Style> | |||
<Style x:Key="image矩阵框1" TargetType="Grid"> | |||
<Style.Setters> | |||
<Setter Property="Background"> | |||
<Setter.Value> | |||
<ImageBrush ImageSource="../Images/Pop_bg.png" Stretch="Fill" Opacity="1" ></ImageBrush> | |||
</Setter.Value> | |||
</Setter> | |||
</Style.Setters> | |||
</Style> | |||
<Style x:Key="imageTextBlock" TargetType="TextBlock"> | |||
<Style.Setters> | |||
<Setter Property="Background"> | |||
<Setter.Value> | |||
<ImageBrush ImageSource="../Images/系统名称.png" Stretch="Fill" ></ImageBrush> | |||
</Setter.Value> | |||
</Setter> | |||
</Style.Setters> | |||
</Style> | |||
<Style x:Key="image拉出" TargetType="Grid"> | |||
<Style.Setters> | |||
<Setter Property="Background"> | |||
<Setter.Value> | |||
<ImageBrush ImageSource="../Images/拉出.png" Stretch="Fill" ></ImageBrush> | |||
</Setter.Value> | |||
</Setter> | |||
</Style.Setters> | |||
</Style> | |||
<Style x:Key="image收缩" TargetType="Grid"> | |||
<Style.Setters> | |||
<Setter Property="Background"> | |||
<Setter.Value> | |||
<ImageBrush ImageSource="../Images/收缩.png" Stretch="Fill" ></ImageBrush> | |||
</Setter.Value> | |||
</Setter> | |||
</Style.Setters> | |||
</Style> | |||
<Style x:Key="image右1" TargetType="Image"> | |||
<Style.Setters> | |||
<Setter Property="VerticalAlignment" Value="Stretch" /> | |||
<Setter Property="HorizontalAlignment" Value="Stretch" /> | |||
<Setter Property="Source" Value="../Images/右1.png" /> | |||
</Style.Setters> | |||
</Style> | |||
<Style x:Key="image右2" TargetType="Image"> | |||
<Style.Setters> | |||
<Setter Property="VerticalAlignment" Value="Stretch" /> | |||
<Setter Property="HorizontalAlignment" Value="Stretch" /> | |||
<Setter Property="Source" Value="../Images/右2.png" /> | |||
</Style.Setters> | |||
</Style> | |||
<Style x:Key="image左1" TargetType="Image"> | |||
<Style.Setters> | |||
<Setter Property="VerticalAlignment" Value="Stretch" /> | |||
<Setter Property="HorizontalAlignment" Value="Stretch" /> | |||
<Setter Property="Source" Value="../Images/左1.png" /> | |||
</Style.Setters> | |||
</Style> | |||
<Style x:Key="image左2" TargetType="Image"> | |||
<Style.Setters> | |||
<Setter Property="VerticalAlignment" Value="Stretch" /> | |||
<Setter Property="HorizontalAlignment" Value="Stretch" /> | |||
<Setter Property="Source" Value="../Images/左2.png" /> | |||
</Style.Setters> | |||
</Style> | |||
<Style x:Key="borderSplider" TargetType="Border"> | |||
<Style.Setters> | |||
<Setter Property="Height" Value="1" /> | |||
<Setter Property="VerticalAlignment" Value="Top" /> | |||
<Setter Property="HorizontalAlignment" Value="Stretch" /> | |||
<Setter Property="Background"> | |||
<Setter.Value> | |||
<ImageBrush ImageSource="../Images/矩形边框.png" Stretch="UniformToFill" ></ImageBrush> | |||
<ImageBrush ImageSource="../Images/1.png" ></ImageBrush> | |||
</Setter.Value> | |||
</Setter> | |||
</Style.Setters> | |||
</Style> | |||
<Style x:Key="CommonBtn_返回" TargetType="Button"> | |||
<Style.Setters> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="Cursor" Value="Hand" /> | |||
<Setter Property="Foreground" Value="{DynamicResource ButtonSelectForeground}" /> | |||
<Setter Property="Width" Value="68" /> | |||
<Setter Property="Height" Value="25" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="Button"> | |||
<Border x:Name="BD" Cursor="Hand"> | |||
<StackPanel | |||
Margin="5,0,10,0" | |||
HorizontalAlignment="Right" | |||
Orientation="Horizontal"> | |||
<Border Width="16" Margin="5"> | |||
<Border.Background> | |||
<ImageBrush ImageSource="../Images/返回按钮图标.png" /> | |||
</Border.Background> | |||
</Border> | |||
<TextBlock | |||
x:Name="textBlock" | |||
VerticalAlignment="Center" | |||
FontSize="14" | |||
Foreground="{DynamicResource ButtonSelectForeground}" | |||
Text="{TemplateBinding Content}" /> | |||
<!-- Text="{TemplateBinding Content}" --> | |||
</StackPanel> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="BD" Property="Background"> | |||
<Setter.Value> | |||
<ImageBrush ImageSource="../Images/返回按钮2.png" /> | |||
</Setter.Value> | |||
</Setter> | |||
<Setter TargetName="textBlock" Property="Foreground" Value="{DynamicResource ButtonSelectForeground}" /> | |||
</Trigger> | |||
<Trigger Property="IsMouseOver" Value="False"> | |||
<Setter TargetName="BD" Property="Background"> | |||
<Setter.Value> | |||
<ImageBrush ImageSource="../Images/返回按钮1.png" /> | |||
</Setter.Value> | |||
</Setter> | |||
<Setter TargetName="textBlock" Property="Foreground" Value="{DynamicResource ButtonSelectForeground}" /> | |||
</Trigger> | |||
<Trigger Property="IsEnabled" Value="False"> | |||
<Setter TargetName="BD" Property="Background"> | |||
<Setter.Value> | |||
<ImageBrush ImageSource="../Images/返回按钮1.png" /> | |||
</Setter.Value> | |||
</Setter> | |||
<Setter TargetName="textBlock" Property="Foreground" Value="{DynamicResource ButtonUnSelectForeground}" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style.Setters> | |||
</Style> | |||
<Style x:Key="BtnNull" TargetType="Button"> | |||
<Style.Setters> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="Cursor" Value="Hand"/> | |||
<Setter Property="Background" Value="Transparent"/> | |||
<Setter Property="Foreground" Value="{DynamicResource ButtonSelectForeground}" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="Button"> | |||
<Border x:Name="BD" Cursor="Hand"/> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="BD" Property="Background" Value="Transparent"/> | |||
</Trigger> | |||
<Trigger Property="IsMouseOver" Value="False"> | |||
<Setter TargetName="BD" Property="Background" Value="Transparent"/> | |||
</Trigger> | |||
<Trigger Property="IsEnabled" Value="False"> | |||
<Setter TargetName="BD" Property="Background" Value="Transparent"/> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style.Setters> | |||
</Style> | |||
<Style x:Key="timeImage" TargetType="Image"> | |||
<Style.Setters> | |||
<Setter Property="Width" Value="20" /> | |||
<Setter Property="Source" Value="../Images/日期1.png" /> | |||
</Style.Setters> | |||
</Style> | |||
</ResourceDictionary> |
@@ -5,10 +5,21 @@ | |||
<TargetFramework>net6.0-windows</TargetFramework> | |||
<Nullable>enable</Nullable> | |||
<UseWPF>true</UseWPF> | |||
<ApplicationIcon>Images\fyf.ico</ApplicationIcon> | |||
<ApplicationIcon>Images\配置.ico</ApplicationIcon> | |||
<AssemblyName>可视化配置工具</AssemblyName> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<COMReference Include="IWshRuntimeLibrary"> | |||
<WrapperTool>tlbimp</WrapperTool> | |||
<VersionMinor>0</VersionMinor> | |||
<VersionMajor>1</VersionMajor> | |||
<Guid>f935dc20-1cf0-11d0-adb9-00c04fd58a0b</Guid> | |||
<Lcid>0</Lcid> | |||
<Isolated>false</Isolated> | |||
<EmbedInteropTypes>true</EmbedInteropTypes> | |||
<UseWindowsForms>true</UseWindowsForms> | |||
</COMReference> | |||
<Compile Remove="Adorners\**" /> | |||
<Compile Remove="CustomerControls\**" /> | |||
<EmbeddedResource Remove="Adorners\**" /> | |||
@@ -64,10 +75,7 @@ | |||
<None Remove="Images\wx.jpg" /> | |||
<None Remove="Images\zfb.jpg" /> | |||
<None Remove="Images\光柱.png" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Content Include="Images\fyf.ico" /> | |||
<None Remove="Images\配置.ico" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
@@ -99,7 +107,12 @@ | |||
<Resource Include="Images\win.png" /> | |||
<Resource Include="Images\wx.jpg" /> | |||
<Resource Include="Images\zfb.jpg" /> | |||
<Resource Include="Images\光柱.png" /> | |||
<Resource Include="Images\光柱.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
<Resource Include="Images\配置.ico"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
</ItemGroup> | |||
<ItemGroup> | |||
@@ -119,8 +132,4 @@ | |||
</Reference> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Folder Include="Helper\" /> | |||
</ItemGroup> | |||
</Project> |
@@ -1,4 +1,5 @@ | |||
using BPASmartClient.Compiler; | |||
using BeDesignerSCADA.Controls; | |||
using BPASmartClient.Compiler; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System; | |||
using System.Collections.Generic; | |||
@@ -205,6 +206,11 @@ namespace BeDesignerSCADA.Common | |||
OnPropertyChanged("visual"); | |||
} | |||
} | |||
/// <summary> | |||
/// 运行Canvas | |||
/// </summary> | |||
[Newtonsoft.Json.JsonIgnore] | |||
public RunCanvas runCanvas { get; set; } | |||
public PageModel() | |||
{ | |||
ChildrenStr = new List<string>(); | |||
@@ -15,7 +15,8 @@ | |||
<UserControl.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" /> | |||
<!--<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" />--> | |||
<ResourceDictionary Source="/可视化配置工具;component/Themes/Styles.xaml"></ResourceDictionary> | |||
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" /> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
@@ -28,61 +29,84 @@ | |||
</Grid.ColumnDefinitions> | |||
<!--左侧选择区域--> | |||
<TabControl SelectedIndex="0"> | |||
<TabControl x:Name="LeftSelectTab" SelectedIndex="0" SelectionChanged="TabControl_SelectionChanged"> | |||
<TabItem Header="页面编辑"> | |||
<Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Background="Transparent" > | |||
<ListBox x:Name="PageList" Grid.Row="0" Margin="0,5,0,0" HorizontalAlignment="Center" SelectedItem="{Binding MenuModel.SelectPageModels,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding MenuModel.pageModels,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Background="Transparent" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemTemplate="{DynamicResource PageBoxStyle}" FontSize="14" BorderThickness="0" > | |||
<ListBox.ContextMenu> | |||
<ContextMenu> | |||
<MenuItem Header="设置首页" Command="{Binding SetHomePageCommand}"> | |||
<MenuItem.Icon> | |||
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Home" /> | |||
</MenuItem.Icon> | |||
</MenuItem> | |||
<MenuItem Header="向上移动" Command="{Binding SetTopPageCommand}"> | |||
<MenuItem.Icon> | |||
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Upload" /> | |||
</MenuItem.Icon> | |||
</MenuItem> | |||
<MenuItem Header="向下移动" Command="{Binding SetBottomPageCommand}"> | |||
<MenuItem.Icon> | |||
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Download" /> | |||
</MenuItem.Icon> | |||
</MenuItem> | |||
<MenuItem Header="删除该页" Command="{Binding DeletePageCommand}"> | |||
<MenuItem.Icon> | |||
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Delete" /> | |||
</MenuItem.Icon> | |||
</MenuItem> | |||
<MenuItem Header="导出页面文件" Command="{Binding SaveAllPageCommand}"> | |||
<MenuItem.Icon> | |||
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Save" /> | |||
</MenuItem.Icon> | |||
</MenuItem> | |||
<MenuItem Header="加载页面文件" Command="{Binding LoadAllPageCommand}"> | |||
<MenuItem.Icon> | |||
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="DiskDownload" /> | |||
</MenuItem.Icon> | |||
</MenuItem> | |||
<MenuItem Header="加载变量文件" Command="{Binding LoadValuesCommand}"> | |||
<MenuItem.Icon> | |||
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="DiskDownload" /> | |||
</MenuItem.Icon> | |||
</MenuItem> | |||
</ContextMenu> | |||
</ListBox.ContextMenu> | |||
</ListBox> | |||
</Border> | |||
<Border BorderThickness="1" BorderBrush="#FFA9A9A9" Background="Transparent" > | |||
<Grid > | |||
<ListBox x:Name="PageList" | |||
ItemContainerStyle="{StaticResource ItemContainerStyle1}" Grid.Row="0" Margin="0,5,0,0" | |||
HorizontalAlignment="Center" | |||
SelectedItem="{Binding MenuModel.SelectPageModels,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" | |||
ItemsSource="{Binding MenuModel.pageModels,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" | |||
Background="Transparent" | |||
ScrollViewer.VerticalScrollBarVisibility="Auto" | |||
ItemTemplate="{DynamicResource PageBoxStyle}" | |||
FontSize="14" BorderThickness="0" > | |||
<ListBox.ContextMenu> | |||
<ContextMenu> | |||
<MenuItem Header="增加一页" Command="{Binding AddPageCommand}" CommandParameter="{Binding MenuModel.SelectPageModels}"> | |||
<MenuItem.Icon> | |||
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Add" /> | |||
</MenuItem.Icon> | |||
</MenuItem> | |||
<MenuItem Header="设置首页" Command="{Binding SetHomePageCommand}"> | |||
<MenuItem.Icon> | |||
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Home" /> | |||
</MenuItem.Icon> | |||
</MenuItem> | |||
<MenuItem Header="向上移动" Command="{Binding SetTopPageCommand}"> | |||
<MenuItem.Icon> | |||
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Upload" /> | |||
</MenuItem.Icon> | |||
</MenuItem> | |||
<MenuItem Header="向下移动" Command="{Binding SetBottomPageCommand}"> | |||
<MenuItem.Icon> | |||
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Download" /> | |||
</MenuItem.Icon> | |||
</MenuItem> | |||
<MenuItem Header="删除该页" Command="{Binding DeletePageCommand}" CommandParameter="{Binding MenuModel.SelectPageModels}"> | |||
<MenuItem.Icon> | |||
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Delete" /> | |||
</MenuItem.Icon> | |||
</MenuItem> | |||
<MenuItem Header="(加载)页面" Command="{Binding LoadAllPageCommand}"> | |||
<MenuItem.Icon> | |||
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="DiskDownload" /> | |||
</MenuItem.Icon> | |||
</MenuItem> | |||
<MenuItem Header="(保存)页面" Command="{Binding SaveAllPageCommand}"> | |||
<MenuItem.Icon> | |||
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Save" /> | |||
</MenuItem.Icon> | |||
</MenuItem> | |||
<MenuItem Header="(另存)页面" Command="{Binding LWSaveAllPageCommand}"> | |||
<MenuItem.Icon> | |||
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="Save" /> | |||
</MenuItem.Icon> | |||
</MenuItem> | |||
<MenuItem Header="变量管理器" Command="{Binding LoadValuesCommand}"> | |||
<MenuItem.Icon> | |||
<icon:PackIconModern Width="10" HorizontalAlignment="Center" Kind="DiskDownload" /> | |||
</MenuItem.Icon> | |||
</MenuItem> | |||
</ContextMenu> | |||
</ListBox.ContextMenu> | |||
</ListBox> | |||
</Grid> | |||
</Border> | |||
</TabItem> | |||
<TabItem Header="组件列表"> | |||
<Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Background="Transparent"> | |||
<ListBox x:Name="CtlList" Grid.Row="2" Background="Transparent" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemTemplate="{DynamicResource ToolBoxStyle}" FontSize="14" BorderThickness="0" PreviewMouseMove="CtlList_PreviewMouseMove" /> | |||
<Border BorderThickness="1" BorderBrush="#FFA9A9A9" Background="Transparent"> | |||
<ListBox x:Name="CtlList" Grid.Row="2" Background="Transparent" ScrollViewer.VerticalScrollBarVisibility="Auto" | |||
ItemTemplate="{DynamicResource ToolBoxStyle}" FontSize="14" BorderThickness="0" | |||
PreviewMouseMove="CtlList_PreviewMouseMove" | |||
/> | |||
</Border> | |||
</TabItem> | |||
<TabItem Header="菜单布局"> | |||
<Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Background="Transparent"> | |||
<Border BorderThickness="1" BorderBrush="#FFA9A9A9" Background="Transparent"> | |||
<mypro:PropertyGrid Margin="10" ShowAdvancedOptions="True" ShowDescriptionByTooltip="True" | |||
FontSize="14" ShowTitle="False" ShowSortOptions="False" ShowSearchBox="False" | |||
AutoGenerateProperties="False" | |||
@@ -190,6 +214,7 @@ | |||
<TextBlock Text="同步" Margin="4 0" VerticalAlignment="Center"/> | |||
</StackPanel> | |||
</Button> | |||
<TextBlock HorizontalAlignment="Center" Margin="4 0 0 0" MaxWidth="200" TextWrapping="Wrap" Height="25" FontSize="10" VerticalAlignment="Bottom" Foreground="Red">温馨提示:布局完成点击“同步”按钮,保存布局到菜单页面,菜单页面“右键”可导出整体布局!</TextBlock> | |||
<ToggleButton x:Name="showCode" Click="showCode_Click" DockPanel.Dock="Right" Margin="4 0 0 0" Padding="4 0"> | |||
<icon:Material Kind="FileCode"/> | |||
@@ -258,7 +283,7 @@ | |||
<!--右侧属性栏--> | |||
<Grid Grid.Column="2"> | |||
<TabControl SelectedIndex="0"> | |||
<TabControl x:Name="ReditSeleceTab" SelectedIndex="0"> | |||
<TabItem Header="页面设置"> | |||
<mypro:PropertyGrid Margin="10" ShowAdvancedOptions="True" ShowDescriptionByTooltip="True" | |||
FontSize="14" ShowTitle="False" ShowSortOptions="False" ShowSearchBox="False" | |||
@@ -27,6 +27,7 @@ using System.Windows.Media.Animation; | |||
using System.Windows.Media.Imaging; | |||
using System.Windows.Navigation; | |||
using System.Windows.Shapes; | |||
using System.Windows.Media.Effects; | |||
namespace BeDesignerSCADA.Controls | |||
{ | |||
@@ -43,7 +44,6 @@ namespace BeDesignerSCADA.Controls | |||
viewModel.LayoutsPath = _Path; | |||
this.DataContext = viewModel; | |||
viewModel.Loaded(cav, runCanvas); | |||
//控件加载 | |||
Assembly assembly = Assembly.LoadFile($"{System.AppDomain.CurrentDomain.BaseDirectory}\\BPASmartClient.SCADAControl.dll"); //Assembly.GetExecutingAssembly(); | |||
CtlList.ItemsSource = assembly.GetTypes().Where(t => t.GetInterface("IExecutable") != null).OrderBy(o => o.Name)?.ToList(); | |||
@@ -138,10 +138,10 @@ namespace BeDesignerSCADA.Controls | |||
/// </summary> | |||
public void FileSave() | |||
{ | |||
SaveBtn_Click(null, null); | |||
viewModel.SaveAllPageHeaderPath(viewModel.LayoutsPath); | |||
} | |||
/// <summary> | |||
/// 读取文件 | |||
/// 读取文件,加载布局 | |||
/// </summary> | |||
/// <param name="path"></param> | |||
public void FileRead(string path) | |||
@@ -150,59 +150,14 @@ namespace BeDesignerSCADA.Controls | |||
{ | |||
if (File.Exists(path)) | |||
{ | |||
cav.Load(path); | |||
DoubleAnimation da = new DoubleAnimation(-200, 0, new Duration(TimeSpan.FromMilliseconds(250))); | |||
da.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }; | |||
CanvasTranslate.BeginAnimation(TranslateTransform.XProperty, da); | |||
DoubleAnimation daop = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(250))); | |||
daop.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }; | |||
cav.BeginAnimation(OpacityProperty, daop); | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
/// <summary> | |||
/// 根据流加载数据 | |||
/// </summary> | |||
public void LoadFrameworkElement(UIElementCollection frameworks) | |||
{ | |||
try | |||
{ | |||
cav.Children.Clear(); | |||
foreach (FrameworkElement element in frameworks) | |||
{ | |||
string xamlText = XamlWriter.Save(element); | |||
FrameworkElement item = XamlReader.Parse(xamlText) as FrameworkElement; | |||
cav.Children.Add(item); | |||
viewModel.LoadAllPageHeaderPath(path); | |||
} | |||
cav.SelectedItems?.Clear(); | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
/// <summary> | |||
/// 获取所有控件 | |||
/// </summary> | |||
/// <returns></returns> | |||
public List<FrameworkElement> GetChildren() | |||
{ | |||
List<FrameworkElement> frameworks = new List<FrameworkElement>(); | |||
foreach (FrameworkElement child in cav.Children) | |||
{ | |||
string xamlText = XamlWriter.Save(child); | |||
FrameworkElement item = XamlReader.Parse(xamlText) as FrameworkElement; | |||
frameworks.Add(item); | |||
} | |||
return frameworks; | |||
} | |||
/// <summary> | |||
/// 运行程序 | |||
/// </summary> | |||
public void Run() | |||
@@ -302,40 +257,60 @@ namespace BeDesignerSCADA.Controls | |||
/// <param name="e"></param> | |||
private void SaveBtn_Click(object sender, RoutedEventArgs e) | |||
{ | |||
if (File.Exists(viewModel.LayoutsPath)) | |||
SaveFileDialog sfd = new SaveFileDialog(); | |||
sfd.Filter = "布局文件|*.lay"; | |||
if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) | |||
{ | |||
string str = cav.Save(); | |||
File.WriteAllText(viewModel.LayoutsPath, str, Encoding.Unicode); | |||
File.WriteAllText(sfd.FileName, str, Encoding.Unicode); | |||
} | |||
else | |||
} | |||
/// <summary> | |||
/// 保存页面 | |||
/// </summary> | |||
/// <param name="sender"></param> | |||
/// <param name="e"></param> | |||
private void SavePage_Click(object sender, RoutedEventArgs e) | |||
{ | |||
try | |||
{ | |||
SaveFileDialog sfd = new SaveFileDialog(); | |||
sfd.Filter = "布局文件|*.lay"; | |||
if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) | |||
LeftSelectTab.SelectedIndex = 0; | |||
if (viewModel.MenuModel.SelectPageModels == null) | |||
viewModel.MenuModel.SelectPageModels = viewModel.MenuModel.pageModels[0]; | |||
viewModel.MenuModel.SelectPageModels.visual?.Children.Clear(); | |||
foreach (FrameworkElement element in cav.Children) | |||
{ | |||
string str = cav.Save(); | |||
File.WriteAllText(sfd.FileName, str, Encoding.Unicode); | |||
string xamlText = XamlWriter.Save(element); | |||
FrameworkElement item = XamlReader.Parse(xamlText) as FrameworkElement; | |||
viewModel.MenuModel.SelectPageModels.visual.Children.Add(item); | |||
} | |||
viewModel.UpdatePageBase(viewModel.MenuModel.SelectPageModels); | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
/// <summary> | |||
/// 保存页面 | |||
/// 选中Tab改变事件 | |||
/// </summary> | |||
/// <param name="sender"></param> | |||
/// <param name="e"></param> | |||
private void SavePage_Click(object sender, RoutedEventArgs e) | |||
private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) | |||
{ | |||
if (viewModel.MenuModel.SelectPageModels == null) | |||
viewModel.MenuModel.SelectPageModels = viewModel.MenuModel.pageModels[0]; | |||
viewModel.MenuModel.SelectPageModels.visual?.Children.Clear(); | |||
foreach (FrameworkElement element in cav.Children) | |||
try | |||
{ | |||
string xamlText = XamlWriter.Save(element); | |||
FrameworkElement item = XamlReader.Parse(xamlText) as FrameworkElement; | |||
viewModel.MenuModel.SelectPageModels.visual.Children.Add(item); | |||
if (LeftSelectTab.SelectedIndex <= 1 && ReditSeleceTab != null) | |||
{ | |||
ReditSeleceTab.SelectedIndex = LeftSelectTab.SelectedIndex; | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
viewModel.UpdatePageBase(viewModel.MenuModel.SelectPageModels); | |||
} | |||
#endregion | |||
@@ -16,7 +16,7 @@ | |||
<UserControl.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" /> | |||
<ResourceDictionary Source="/可视化配置工具;component/Themes/Styles.xaml"/> | |||
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" /> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
@@ -4,6 +4,7 @@ | |||
xmlns:con="clr-namespace:BeDesignerSCADA.Converters" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:controls="clr-namespace:BPASmartClient.SCADAControl.CustomerControls;assembly=BPASmartClient.SCADAControl" | |||
xmlns:local="clr-namespace:BeDesignerSCADA.Controls" | |||
mc:Ignorable="d" | |||
d:DesignHeight="450" d:DesignWidth="800"> | |||
@@ -12,61 +13,65 @@ | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" /> | |||
</ResourceDictionary.MergedDictionaries> | |||
<con:ZoomConverter x:Key="ZoomX" IsHeight="False" /> | |||
<con:ZoomConverter x:Key="ZoomY" IsHeight="True" /> | |||
</ResourceDictionary> | |||
</UserControl.Resources> | |||
<Grid ClipToBounds="True"> | |||
<Grid> | |||
<Border x:Name="main" > | |||
<Grid> | |||
<Canvas | |||
Tag="{Binding SelectId,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" | |||
x:Name="RootCanvas" | |||
Background="Transparent" | |||
ClipToBounds="True" | |||
MouseLeftButtonDown="RootCanvas_MouseLeftButtoDown" | |||
MouseLeftButtonUp="RootCanvas_MouseLeftButtonUp" | |||
MouseMove="RootCanvas_MouseMove" | |||
MouseWheel="RootCanvas_MouseWheel"> | |||
<Canvas.RenderTransform> | |||
<TransformGroup> | |||
<ScaleTransform x:Name="Scale" /> | |||
<TranslateTransform x:Name="Translate" /> | |||
</TransformGroup> | |||
</Canvas.RenderTransform> | |||
</Canvas> | |||
</Grid> | |||
</Border> | |||
<Grid VerticalAlignment="Bottom" Background="#4B959595"> | |||
<StackPanel | |||
Margin="8,0" | |||
HorizontalAlignment="Right" | |||
Orientation="Horizontal"> | |||
<CheckBox | |||
x:Name="DragEnable" | |||
Margin="4" | |||
Content="拖动" /> | |||
<CheckBox | |||
x:Name="ZoomEnable" | |||
Margin="4" | |||
Content="缩放" /> | |||
</StackPanel> | |||
</Grid> | |||
<WrapPanel x:Name="wrapanl_main" Orientation="Vertical" Style="{DynamicResource image矩阵框1}" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="0,5,0,25"> | |||
<TextBlock x:Name="TitleName" Foreground="#FFFFA500" FontSize="18" Width="100" TextWrapping="Wrap" MaxHeight="20" HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding MenuModel.Name}" FontFamily="{DynamicResource Digital}"></TextBlock> | |||
<ListBox x:Name="PageList" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Bottom" | |||
SelectedItem="{Binding MenuModel.SelectPageModels,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" | |||
ItemsSource="{Binding MenuModel.pageModels,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" | |||
Background="Transparent" | |||
<StackPanel x:Name="waibustack" Cursor="Hand" Orientation="Horizontal" MouseMove="wrapanl_main_MouseMove" MouseLeave="wrapanl_main_MouseLeave" > | |||
<Grid Style="{DynamicResource image矩阵框1}" Margin="0,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Stretch" x:Name="wrapanl_main" > | |||
<TextBlock x:Name="TitleName" FontWeight="Bold" Style="{DynamicResource imageTextBlock}" Padding="10" FontSize="18" TextWrapping="Wrap" MaxWidth="118" HorizontalAlignment="Center" VerticalAlignment="Top" Text="{Binding MenuModel.Name}" FontFamily="{DynamicResource Digital}"> | |||
<TextBlock.Foreground> | |||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> | |||
<GradientStop Color="#FF08A1E0"/> | |||
<GradientStop Color="#FF08A1E0" Offset="0.25"/> | |||
<GradientStop Color="#FF08A1E0" Offset="0.5"/> | |||
<GradientStop Color="#FF7FCEEF" Offset="0.75"/> | |||
<GradientStop Color="#FF08A1E0" Offset="1"/> | |||
</LinearGradientBrush> | |||
</TextBlock.Foreground> | |||
</TextBlock> | |||
<Border x:Name="border0" Margin="0,60,0,0" Style="{DynamicResource borderSplider}"></Border> | |||
<ListBox x:Name="PageList" Margin="0,60,0,100" Padding="10,0,0,0" BorderThickness="0" HorizontalAlignment="Left" VerticalAlignment="Top" | |||
SelectedItem="{Binding MenuModel.SelectPageModels,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" | |||
ItemsSource="{Binding MenuModel.pageModels,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" | |||
Background="Transparent" | |||
ItemContainerStyle="{StaticResource ItemContainerStyle1}" | |||
ScrollViewer.VerticalScrollBarVisibility="Auto" | |||
ScrollViewer.HorizontalScrollBarVisibility="Auto" | |||
ItemTemplate="{DynamicResource X_PageBoxStyle}" FontSize="14" BorderThickness="0" > | |||
</ListBox> | |||
</WrapPanel> | |||
ItemTemplate="{DynamicResource X_PageBoxStyle}" > | |||
</ListBox> | |||
<Border x:Name="border1" Margin="0,0,0,80" VerticalAlignment="Bottom" Style="{DynamicResource borderSplider}"/> | |||
<StackPanel x:Name="closeGrid" Height="80" Background="Transparent" Margin="0,0,0,0" Width="100" VerticalAlignment="Bottom" HorizontalAlignment="Center"> | |||
<controls:DateTimeUI Foreground="#a2c2e8" HorizontalAlignment="Center" Margin="5,5,5,5"></controls:DateTimeUI> | |||
<Border x:Name="border2" Style="{DynamicResource borderSplider}"></Border> | |||
<Button | |||
x:Name="ButClose" | |||
Margin="0,5,0,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Top" | |||
Content="退出程序" | |||
Cursor="Hand" | |||
Width="90" | |||
Style="{DynamicResource CommonBtn_返回}" | |||
ToolTip="退出程序" /> | |||
</StackPanel> | |||
</Grid> | |||
<Border x:Name="lachu" Background="Transparent" Width="30" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="0,0,0,25" BorderThickness="1,0,0,0"> | |||
<Border.BorderBrush> | |||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> | |||
<GradientStop Color="Transparent"/> | |||
<GradientStop Color="#FF21B7B7" Offset="0.25"/> | |||
<GradientStop Color="Aqua" Offset="0.5"/> | |||
<GradientStop Color="#FF21B7B7" Offset="0.75"/> | |||
<GradientStop Color="Transparent" Offset="1"/> | |||
</LinearGradientBrush> | |||
</Border.BorderBrush> | |||
<Image x:Name="lachuStyle" Style="{DynamicResource image右1}" Cursor="Hand" Width="70" Height="30"></Image> | |||
</Border> | |||
</StackPanel> | |||
</Grid> | |||
</UserControl> |
@@ -16,9 +16,11 @@ using System.Windows.Documents; | |||
using System.Windows.Input; | |||
using System.Windows.Markup; | |||
using System.Windows.Media; | |||
using System.Windows.Media.Animation; | |||
using System.Windows.Media.Imaging; | |||
using System.Windows.Navigation; | |||
using System.Windows.Shapes; | |||
using System.Windows.Threading; | |||
namespace BeDesignerSCADA.Controls | |||
{ | |||
@@ -28,27 +30,52 @@ namespace BeDesignerSCADA.Controls | |||
public partial class MenuRunCanvas : UserControl | |||
{ | |||
MenuRunCanvasModel menuRunCanvasModel = null; | |||
ResourceDictionary languageResDic = new ResourceDictionary(); | |||
DispatcherTimer timer1;//控制菜单显示隐藏功能 | |||
public MenuRunCanvas() | |||
{ | |||
InitializeComponent(); | |||
menuRunCanvasModel=new MenuRunCanvasModel(); | |||
languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml", UriKind.RelativeOrAbsolute); | |||
menuRunCanvasModel =new MenuRunCanvasModel(); | |||
this.DataContext=menuRunCanvasModel; | |||
Unloaded += (s, e) => Destory(); | |||
timer1 = new DispatcherTimer(); | |||
timer1.Tick += new System.EventHandler(timer1_Tick); | |||
timer1.Interval = new TimeSpan(0, 0, 0, 0, 1000); | |||
timer1.Start(); | |||
this.Loaded += MenuRunCanvas_Loaded; | |||
} | |||
/// <summary> | |||
/// 停止 | |||
/// </summary> | |||
public void Destory() | |||
private void MenuRunCanvas_Loaded(object sender, RoutedEventArgs e) | |||
{ | |||
foreach (var item in RootCanvas.Children) | |||
if (menuRunCanvasModel.MenuModel != null) | |||
{ | |||
if (item is IDisposable disposable) | |||
switch (menuRunCanvasModel.MenuModel.Alignment) | |||
{ | |||
disposable.Dispose(); | |||
case MenuAlignment.左边: | |||
menuWidth = wrapanl_main.ActualWidth; | |||
break; | |||
case MenuAlignment.顶部: | |||
menuWidth = wrapanl_main.ActualHeight; | |||
break; | |||
case MenuAlignment.右边: | |||
menuWidth = wrapanl_main.ActualWidth; | |||
break; | |||
case MenuAlignment.底部: | |||
menuWidth = wrapanl_main.ActualHeight; | |||
break; | |||
default: | |||
break; | |||
} | |||
MenuSmall(); | |||
} | |||
} | |||
private void timer1_Tick(object sender, EventArgs e) | |||
{ | |||
times += 1; | |||
} | |||
/// <summary> | |||
/// 根据路径运行程序 | |||
/// </summary> | |||
@@ -56,213 +83,317 @@ namespace BeDesignerSCADA.Controls | |||
{ | |||
RunMenu(BinaryFile.ReadBinary<MenuModel>(path) as MenuModel); | |||
} | |||
/// <summary> | |||
/// 运行菜单 | |||
/// </summary> | |||
/// <param name="canvas"></param> | |||
public void RunMenu(MenuModel canvas) | |||
{ | |||
int k = 0; | |||
ItemsPanelTemplate itemsPanelTemplate = new ItemsPanelTemplate(); | |||
FrameworkElementFactory _StackPanel = new FrameworkElementFactory(typeof(StackPanel)); | |||
switch (canvas.Alignment) | |||
{ | |||
case MenuAlignment.左边: | |||
PageList.HorizontalAlignment = HorizontalAlignment.Left; | |||
if(!string.IsNullOrEmpty(canvas.Name)) | |||
k = (canvas.Name.Length / 5 -1+ (canvas.Name.Length % 5 > 0 ? 1 : 0))*15; | |||
//左边菜单栏 | |||
PageList.HorizontalAlignment = HorizontalAlignment.Stretch; | |||
PageList.VerticalAlignment = VerticalAlignment.Top; | |||
PageList.Margin = new Thickness(10,70+ k, 10,110); | |||
PageList.Padding = new Thickness(0,0,0,0); | |||
_StackPanel.SetValue(StackPanel.OrientationProperty, Orientation.Vertical); | |||
wrapanl_main.Orientation = Orientation.Vertical; | |||
//标题栏 | |||
TitleName.Margin = new Thickness(0, 10, 0, 10); | |||
TitleName.HorizontalAlignment = HorizontalAlignment.Stretch; | |||
TitleName.VerticalAlignment = VerticalAlignment.Top; | |||
border0.Margin = new Thickness(0, 60+k, 0, 0); | |||
border0.LayoutTransform = new RotateTransform() { Angle = 0 }; | |||
border0.HorizontalAlignment = HorizontalAlignment.Stretch; | |||
border0.VerticalAlignment = VerticalAlignment.Top; | |||
border1.Margin = new Thickness(0, 0, 0, 100); | |||
border1.LayoutTransform = new RotateTransform() { Angle = 0 }; | |||
border1.HorizontalAlignment = HorizontalAlignment.Stretch; | |||
border1.VerticalAlignment = VerticalAlignment.Bottom; | |||
//内部Grid | |||
wrapanl_main.HorizontalAlignment = HorizontalAlignment.Left; | |||
wrapanl_main.VerticalAlignment = VerticalAlignment.Stretch; | |||
TitleName.Margin = new Thickness(0, 10, 0, 10); | |||
wrapanl_main.Margin = new Thickness(0, 0, 0, 25); | |||
//外部Stackpanl | |||
waibustack.Orientation = Orientation.Horizontal; | |||
waibustack.HorizontalAlignment = HorizontalAlignment.Left; | |||
//拉出按钮 | |||
lachu.HorizontalAlignment = HorizontalAlignment.Left; | |||
lachu.VerticalAlignment = VerticalAlignment.Stretch; | |||
lachu.BorderThickness = new Thickness(1, 0, 0, 0); | |||
//closeGrid | |||
closeGrid.HorizontalAlignment = HorizontalAlignment.Center; | |||
closeGrid.VerticalAlignment = VerticalAlignment.Bottom; | |||
closeGrid.Margin = new Thickness(10); | |||
ButClose.Margin = new Thickness(0, 5, 0, 0); | |||
break; | |||
case MenuAlignment.顶部: | |||
PageList.HorizontalAlignment = HorizontalAlignment.Left; | |||
//左边菜单栏 | |||
PageList.HorizontalAlignment = HorizontalAlignment.Stretch; | |||
PageList.VerticalAlignment = VerticalAlignment.Top; | |||
PageList.Margin = new Thickness(140,0 , 120, 0); | |||
PageList.Padding = new Thickness(0, 0, 0, 0); | |||
_StackPanel.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal); | |||
wrapanl_main.Orientation = Orientation.Horizontal; | |||
//标题栏 | |||
TitleName.LayoutTransform = new RotateTransform() { Angle = 0 }; | |||
TitleName.Margin = new Thickness(10, 10, 10, 10); | |||
TitleName.HorizontalAlignment = HorizontalAlignment.Left; | |||
TitleName.VerticalAlignment = VerticalAlignment.Center; | |||
TitleName.Width = 110; | |||
border0.Margin = new Thickness(130, 0, 0, 0); | |||
border0.HorizontalAlignment = HorizontalAlignment.Left; | |||
border0.VerticalAlignment = VerticalAlignment.Stretch; | |||
border0.LayoutTransform = new RotateTransform() { Angle = 90 }; | |||
border1.Margin = new Thickness(0, 0, 110,0 ); | |||
border1.HorizontalAlignment = HorizontalAlignment.Right; | |||
border1.VerticalAlignment = VerticalAlignment.Stretch; | |||
border1.LayoutTransform = new RotateTransform() { Angle = 90 }; | |||
//内部Grid | |||
wrapanl_main.HorizontalAlignment = HorizontalAlignment.Stretch; | |||
wrapanl_main.VerticalAlignment = VerticalAlignment.Top; | |||
TitleName.LayoutTransform = new RotateTransform(){ Angle = 270 }; | |||
TitleName.Margin = new Thickness(10, 0,10, 0); | |||
wrapanl_main.Margin = new Thickness(0, 0, 0, 0); | |||
//外部Stackpanl | |||
waibustack.Orientation = Orientation.Vertical; | |||
waibustack.VerticalAlignment = VerticalAlignment.Top; | |||
//拉出按钮 | |||
lachu.HorizontalAlignment = HorizontalAlignment.Stretch; | |||
lachu.VerticalAlignment = VerticalAlignment.Top; | |||
lachu.LayoutTransform = new RotateTransform() { Angle = 270 }; | |||
lachu.BorderThickness = new Thickness(0, 0, 1, 0); | |||
//closeGrid | |||
closeGrid.HorizontalAlignment = HorizontalAlignment.Right; | |||
closeGrid.VerticalAlignment = VerticalAlignment.Center; | |||
closeGrid.Margin = new Thickness(10, 0, 10, 0); | |||
ButClose.Margin = new Thickness(0,5, 0, 0); | |||
break; | |||
case MenuAlignment.右边: | |||
k = (canvas.Name.Length / 5 - 1 + (canvas.Name.Length % 5 > 0 ? 1 : 0)) * 15; | |||
//左边菜单栏 | |||
PageList.HorizontalAlignment = HorizontalAlignment.Right; | |||
PageList.VerticalAlignment = VerticalAlignment.Top; | |||
PageList.VerticalAlignment = VerticalAlignment.Stretch; | |||
PageList.Margin = new Thickness(10, 70 + k, 10, 110); | |||
PageList.Padding = new Thickness(0, 0, 0, 0); | |||
_StackPanel.SetValue(StackPanel.OrientationProperty, Orientation.Vertical); | |||
wrapanl_main.Orientation = Orientation.Vertical; | |||
//标题栏 | |||
TitleName.Margin = new Thickness(0, 10, 0, 10); | |||
TitleName.HorizontalAlignment = HorizontalAlignment.Stretch; | |||
TitleName.VerticalAlignment = VerticalAlignment.Top; | |||
border0.Margin = new Thickness(0, 60 + k, 0, 0); | |||
border0.LayoutTransform = new RotateTransform() { Angle = 0 }; | |||
border0.HorizontalAlignment = HorizontalAlignment.Stretch; | |||
border0.VerticalAlignment = VerticalAlignment.Top; | |||
border1.Margin = new Thickness(0, 0, 0, 100); | |||
border1.LayoutTransform = new RotateTransform() { Angle = 0 }; | |||
border1.HorizontalAlignment = HorizontalAlignment.Stretch; | |||
border1.VerticalAlignment = VerticalAlignment.Bottom; | |||
//内部Grid | |||
wrapanl_main.HorizontalAlignment = HorizontalAlignment.Right; | |||
wrapanl_main.VerticalAlignment = VerticalAlignment.Stretch; | |||
TitleName.Margin = new Thickness(0, 10, 0, 10); | |||
wrapanl_main.Margin = new Thickness(0, 0, 0, 25); | |||
//外部Stackpanl | |||
waibustack.Orientation = Orientation.Horizontal; | |||
waibustack.HorizontalAlignment = HorizontalAlignment.Right; | |||
//拉出按钮 | |||
lachu.HorizontalAlignment = HorizontalAlignment.Right; | |||
lachu.VerticalAlignment = VerticalAlignment.Stretch; | |||
lachu.BorderThickness = new Thickness(1, 0, 0, 0); | |||
//closeGrid | |||
closeGrid.HorizontalAlignment = HorizontalAlignment.Center; | |||
closeGrid.VerticalAlignment = VerticalAlignment.Bottom; | |||
closeGrid.Margin = new Thickness(10); | |||
ButClose.Margin = new Thickness(0, 5, 0, 0); | |||
break; | |||
case MenuAlignment.底部: | |||
PageList.HorizontalAlignment = HorizontalAlignment.Left; | |||
//左边菜单栏 | |||
PageList.HorizontalAlignment = HorizontalAlignment.Stretch; | |||
PageList.VerticalAlignment = VerticalAlignment.Bottom; | |||
PageList.Margin = new Thickness(140, 0, 120, 0); | |||
PageList.Padding = new Thickness(0, 0, 0, 0); | |||
_StackPanel.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal); | |||
wrapanl_main.Orientation = Orientation.Horizontal; | |||
//标题栏 | |||
TitleName.LayoutTransform = new RotateTransform() { Angle = 0 }; | |||
TitleName.Margin = new Thickness(10, 10, 10, 10); | |||
TitleName.HorizontalAlignment = HorizontalAlignment.Left; | |||
TitleName.VerticalAlignment = VerticalAlignment.Center; | |||
TitleName.Width = 110; | |||
border0.Margin = new Thickness(130, 0, 0, 0); | |||
border0.HorizontalAlignment = HorizontalAlignment.Left; | |||
border0.VerticalAlignment = VerticalAlignment.Stretch; | |||
border0.LayoutTransform = new RotateTransform() { Angle = 90 }; | |||
border1.Margin = new Thickness(0, 0, 110, 0); | |||
border1.HorizontalAlignment = HorizontalAlignment.Right; | |||
border1.VerticalAlignment = VerticalAlignment.Stretch; | |||
border1.LayoutTransform = new RotateTransform() { Angle = 90 }; | |||
//内部Grid | |||
wrapanl_main.HorizontalAlignment = HorizontalAlignment.Stretch; | |||
wrapanl_main.VerticalAlignment = VerticalAlignment.Bottom; | |||
TitleName.LayoutTransform = new RotateTransform() { Angle = 270 }; | |||
TitleName.Margin = new Thickness(10, 0, 10, 0); | |||
wrapanl_main.Margin = new Thickness(0, 0, 0, 0); | |||
//外部Stackpanl | |||
waibustack.Orientation = Orientation.Vertical; | |||
waibustack.VerticalAlignment = VerticalAlignment.Bottom; | |||
//拉出按钮 | |||
lachu.HorizontalAlignment = HorizontalAlignment.Stretch; | |||
lachu.VerticalAlignment = VerticalAlignment.Bottom; | |||
lachu.LayoutTransform = new RotateTransform() { Angle = 270 }; | |||
lachu.BorderThickness = new Thickness(0, 0, 1, 0); | |||
//closeGrid | |||
closeGrid.HorizontalAlignment = HorizontalAlignment.Right; | |||
closeGrid.VerticalAlignment = VerticalAlignment.Center; | |||
closeGrid.Margin = new Thickness(10, 0, 10, 0); | |||
ButClose.Margin = new Thickness(0, 5, 0, 0); | |||
break; | |||
default: | |||
break; | |||
} | |||
if(canvas.IsVisibility) | |||
wrapanl_main.Visibility = Visibility.Visible; | |||
waibustack.Visibility = Visibility.Visible; | |||
else | |||
wrapanl_main.Visibility = Visibility.Collapsed; | |||
waibustack.Visibility = Visibility.Collapsed; | |||
itemsPanelTemplate.VisualTree = _StackPanel; | |||
PageList.ItemsPanel = itemsPanelTemplate; | |||
menuRunCanvasModel.canvas1 = RootCanvas; | |||
menuRunCanvasModel.MenuModel = canvas; | |||
menuRunCanvasModel.MenuModel = canvas; | |||
menuRunCanvasModel.border = main; | |||
menuRunCanvasModel.MenuModel?.pageModels?.ToList().ForEach(par => | |||
{ | |||
List<FrameworkElement> Children = new List<FrameworkElement>(); | |||
par.visual = new CanvasPanel(); | |||
par?.ChildrenStr?.ForEach(k => | |||
{ | |||
FrameworkElement item = XamlReader.Parse(k) as FrameworkElement; | |||
par.visual.Children.Add(item); | |||
FrameworkElement item1 = XamlReader.Parse(k) as FrameworkElement; | |||
Children.Add(item1); | |||
}); | |||
RunCanvas runCanvas = new RunCanvas(); | |||
runCanvas.Init(Children); | |||
par.runCanvas = runCanvas; | |||
}); | |||
if (menuRunCanvasModel.MenuModel.pageModels.Count > 0) | |||
{ | |||
menuRunCanvasModel.MenuModel.SelectPageModels = menuRunCanvasModel.MenuModel.pageModels[0]; | |||
menuRunCanvasModel.SelectId = menuRunCanvasModel.MenuModel.pageModels[0].Id; | |||
main.Child = menuRunCanvasModel.MenuModel.SelectPageModels.runCanvas; | |||
menuRunCanvasModel.MenuModel.SelectPageModels.runCanvas.RunSelect(); | |||
} | |||
SelectMenu(); | |||
} | |||
/// <summary> | |||
/// 选中菜单 | |||
/// 父窗体控制事件 | |||
/// </summary> | |||
public void SelectMenu() | |||
/// <param name="obj"></param> | |||
public void PandClick(Window obj) | |||
{ | |||
try | |||
this.ButClose.Click += (o, e) => | |||
{ | |||
List<FrameworkElement> Children = new List<FrameworkElement>(); | |||
if (menuRunCanvasModel.MenuModel.SelectPageModels != null) | |||
MessageBoxResult res = MessageBox.Show("确定关闭上位机软件?", "警告", MessageBoxButton.OKCancel); | |||
if (res == MessageBoxResult.OK) | |||
{ | |||
foreach (FrameworkElement element in (menuRunCanvasModel?.MenuModel.SelectPageModels?.visual as CanvasPanel).Children) | |||
{ | |||
string xamlText = XamlWriter.Save(element); | |||
FrameworkElement item = XamlReader.Parse(xamlText) as FrameworkElement; | |||
Children.Add(item); | |||
} | |||
obj.Close(); | |||
} | |||
Run(Children); | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
}; | |||
this.waibustack.MouseLeftButtonDown += (o, e) => | |||
{ | |||
if (e.ClickCount > 1) | |||
{ | |||
if (obj.WindowState == WindowState.Maximized) | |||
obj.WindowState = WindowState.Normal; | |||
else if (obj.WindowState == WindowState.Normal) | |||
obj.WindowState = WindowState.Maximized; | |||
} | |||
if (e.LeftButton == MouseButtonState.Pressed) obj.DragMove(); | |||
}; | |||
} | |||
bool ismove = true; | |||
int times = 0; | |||
/// <summary> | |||
/// 运行 | |||
/// 鼠标移动 | |||
/// </summary> | |||
/// <param name="canvas"></param> | |||
public void Run(List<FrameworkElement> canvas) | |||
/// <param name="sender"></param> | |||
/// <param name="e"></param> | |||
private void wrapanl_main_MouseMove(object sender, MouseEventArgs e) | |||
{ | |||
Config.GetInstance().Reset(); | |||
RootCanvas.Children.Clear(); | |||
foreach (FrameworkElement element in canvas) | |||
if (times < 1) | |||
{ | |||
if (element is IExecutable executable) | |||
executable.IsExecuteState = true; | |||
RootCanvas.Children.Add(element); | |||
RegisterJsName(element); | |||
return; | |||
} | |||
} | |||
if (ismove) | |||
{ | |||
ismove = false; | |||
MenuBig(); | |||
#region 拖动与缩放 | |||
// 注册名称到Js | |||
static void RegisterJsName(FrameworkElement element) | |||
} | |||
times = 0; | |||
} | |||
/// <summary> | |||
/// 鼠标离开 | |||
/// </summary> | |||
/// <param name="sender"></param> | |||
/// <param name="e"></param> | |||
private void wrapanl_main_MouseLeave(object sender, MouseEventArgs e) | |||
{ | |||
Config.GetInstance().SetVariable(element.Name, element); | |||
if (element is Panel panel) | |||
menuWidthDefault = 0; | |||
if (!ismove) | |||
{ | |||
foreach (var item in panel.Children) | |||
{ | |||
RegisterJsName(item as FrameworkElement); | |||
} | |||
ismove = true; | |||
MenuSmall(); | |||
} | |||
times = 0; | |||
} | |||
private void RootCanvas_MouseMove(object sender, MouseEventArgs e) | |||
private int menuWidthDefault = 0; | |||
private double menuWidth = 86; | |||
private void MenuBig() | |||
{ | |||
if (DragEnable.IsChecked == false) | |||
DoubleAnimation da = new DoubleAnimation(); | |||
da.From = menuWidthDefault; | |||
da.To = menuWidth; | |||
da.Duration = TimeSpan.FromSeconds(0.1); | |||
if (menuRunCanvasModel.MenuModel.Alignment == MenuAlignment.左边 || menuRunCanvasModel.MenuModel.Alignment == MenuAlignment.右边) | |||
{ | |||
return; | |||
wrapanl_main.BeginAnimation(WidthProperty, da); | |||
if (languageResDic.Contains("image左1")) | |||
lachuStyle.Style = languageResDic["image左1"] as Style; | |||
} | |||
if (e.LeftButton == MouseButtonState.Pressed && isPressed) | |||
else if (menuRunCanvasModel.MenuModel.Alignment == MenuAlignment.顶部 || menuRunCanvasModel.MenuModel.Alignment == MenuAlignment.底部) | |||
{ | |||
Point point = e.GetPosition(this); | |||
var movex = (point.X - last.X); | |||
var movey = (point.Y - last.Y); | |||
Translate.X += movex; | |||
Translate.Y += movey; | |||
last = point; | |||
wrapanl_main.BeginAnimation(HeightProperty, da); | |||
if (languageResDic.Contains("image右1")) | |||
lachuStyle.Style = languageResDic["image右1"] as Style; | |||
} | |||
} | |||
bool isPressed = false; | |||
Point last;//记录上次鼠标坐标位置 | |||
private void RootCanvas_MouseLeftButtoDown(object sender, MouseButtonEventArgs e) | |||
{ | |||
last = e.GetPosition(this); | |||
isPressed = true; | |||
} | |||
private void RootCanvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) | |||
{ | |||
isPressed = false; | |||
} | |||
// 缩放 | |||
private void RootCanvas_MouseWheel(object sender, MouseWheelEventArgs e) | |||
private void MenuSmall() | |||
{ | |||
if (ZoomEnable.IsChecked == false) | |||
DoubleAnimation da = new DoubleAnimation(); | |||
da.From = menuWidth; | |||
da.To = menuWidthDefault; | |||
da.Duration = TimeSpan.FromSeconds(0.1); | |||
if (menuRunCanvasModel.MenuModel.Alignment == MenuAlignment.左边 || menuRunCanvasModel.MenuModel.Alignment == MenuAlignment.右边) | |||
{ | |||
return; | |||
if (languageResDic.Contains("image右1")) | |||
lachuStyle.Style = languageResDic["image右1"] as Style; | |||
wrapanl_main.BeginAnimation(WidthProperty, da); | |||
} | |||
var zoomS = (e.Delta / 960d); | |||
var zoom = zoomS + Scale.ScaleX; | |||
if (zoom > 3 || zoom < 0.8) | |||
else if (menuRunCanvasModel.MenuModel.Alignment == MenuAlignment.顶部 || menuRunCanvasModel.MenuModel.Alignment == MenuAlignment.底部) | |||
{ | |||
return; | |||
wrapanl_main.BeginAnimation(HeightProperty, da); | |||
if (languageResDic.Contains("image左1")) | |||
lachuStyle.Style = languageResDic["image左1"] as Style; | |||
} | |||
Scale.ScaleX = Scale.ScaleY = zoom; | |||
Point mouse = e.GetPosition(RootCanvas); | |||
Point newMouse = new Point(mouse.X * zoomS, mouse.Y * zoomS); | |||
Translate.X -= newMouse.X; | |||
Translate.Y -= newMouse.Y; | |||
} | |||
#endregion | |||
} | |||
/// <summary> | |||
/// 运行Model | |||
/// </summary> | |||
public class MenuRunCanvasModel : ObservableObject | |||
{ | |||
/// <summary> | |||
/// 选中ID | |||
/// </summary> | |||
private string _SelectId; | |||
public string SelectId | |||
{ | |||
get | |||
{ | |||
return _SelectId; | |||
} | |||
set | |||
{ | |||
_SelectId = value; | |||
OnPropertyChanged("SelectId"); | |||
} | |||
} | |||
/// <summary> | |||
/// 菜单Model | |||
/// </summary> | |||
@@ -280,7 +411,7 @@ namespace BeDesignerSCADA.Controls | |||
} | |||
} | |||
public RelayCommand<object> MenSelectPageCommand { get; set; } | |||
public Canvas canvas1; | |||
public Border border { get; set; } | |||
public MenuRunCanvasModel() | |||
{ | |||
MenuModel = new MenuModel(); | |||
@@ -297,61 +428,15 @@ namespace BeDesignerSCADA.Controls | |||
{ | |||
try | |||
{ | |||
Rx(SelectId); | |||
//MenuModel.SelectPageModels.runCanvas.Destory(); | |||
MenuModel.SelectPageModels = obj as PageModel; | |||
SelectId = MenuModel.SelectPageModels.Id; | |||
List<FrameworkElement> Children = new List<FrameworkElement>(); | |||
if (MenuModel.SelectPageModels != null) | |||
{ | |||
foreach (FrameworkElement element in (MenuModel.SelectPageModels?.visual as CanvasPanel).Children) | |||
{ | |||
string xamlText = XamlWriter.Save(element); | |||
FrameworkElement item = XamlReader.Parse(xamlText) as FrameworkElement; | |||
Children.Add(item); | |||
} | |||
} | |||
Run(Children); | |||
border.Child = MenuModel.SelectPageModels.runCanvas; | |||
MenuModel.SelectPageModels.runCanvas.RunSelect(); | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
public void Rx(string id) | |||
{ | |||
//(MenuModel?.pageModels?.ToList().Find(par => par.Id == id).visual as CanvasPanel).Children.Clear(); | |||
//foreach (FrameworkElement element in canvas1.Children) | |||
//{ | |||
// string xamlText = XamlWriter.Save(element); | |||
// FrameworkElement item = XamlReader.Parse(xamlText) as FrameworkElement; | |||
// (MenuModel?.pageModels?.ToList().Find(par => par.Id == id).visual as CanvasPanel).Children.Add(item); | |||
//} | |||
} | |||
public void Run(List<FrameworkElement> canvas) | |||
{ | |||
Config.GetInstance().Reset(); | |||
canvas1.Children.Clear(); | |||
foreach (FrameworkElement element in canvas) | |||
{ | |||
if (element is IExecutable executable) | |||
executable.IsExecuteState = true; | |||
canvas1.Children.Add(element); | |||
RegisterJsName(element); | |||
} | |||
} | |||
static void RegisterJsName(FrameworkElement element) | |||
{ | |||
Config.GetInstance().SetVariable(element.Name, element); | |||
if (element is Panel panel) | |||
{ | |||
foreach (var item in panel.Children) | |||
{ | |||
RegisterJsName(item as FrameworkElement); | |||
} | |||
} | |||
} | |||
} | |||
} |
@@ -66,9 +66,36 @@ namespace BeDesignerSCADA.Controls | |||
{ | |||
Run(Children); | |||
} | |||
} | |||
/// <summary> | |||
/// 初始化 | |||
/// </summary> | |||
/// <param name="canvas"></param> | |||
public void Init(List<FrameworkElement> canvas) | |||
{ | |||
RootCanvas.Children.Clear(); | |||
foreach (FrameworkElement element in canvas) | |||
{ | |||
RootCanvas.Children.Add(element); | |||
} | |||
} | |||
public void RunSelect() | |||
{ | |||
Config.GetInstance().Reset(); | |||
foreach (FrameworkElement element in RootCanvas.Children) | |||
{ | |||
RegisterJsName(element);//注册rejs | |||
} | |||
foreach (FrameworkElement element in RootCanvas.Children) | |||
{ | |||
if (element is IExecutable executable) | |||
executable.IsExecuteState = true; | |||
} | |||
} | |||
public void Run(List<FrameworkElement> canvas) | |||
{ | |||
RootCanvas.Children.Clear(); | |||
@@ -0,0 +1,261 @@ | |||
using IWshRuntimeLibrary; | |||
using Microsoft.Win32; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Diagnostics; | |||
using System.IO; | |||
using System.Linq; | |||
using System.Runtime.InteropServices; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BeDesignerSCADA.Helper | |||
{ | |||
/// <summary> | |||
/// 系统操作类 | |||
/// </summary> | |||
public class SystemHelperNew | |||
{ | |||
private volatile static SystemHelperNew _Instance; | |||
public static SystemHelperNew GetInstance => _Instance ?? (_Instance = new SystemHelperNew()); | |||
private SystemHelperNew() { } | |||
/// <summary> | |||
/// 获取当前应用程序名称,包括后缀名 | |||
/// </summary> | |||
public string GetApplicationName => $"{AppDomain.CurrentDomain.FriendlyName}.exe"; | |||
/// <summary> | |||
/// 获取当前应用程序完整路径 | |||
/// </summary> | |||
public string GetApplicationPath => $"{AppDomain.CurrentDomain.BaseDirectory}{GetApplicationName}"; | |||
/// <summary> | |||
/// 创建桌面快捷方式 | |||
/// </summary> | |||
/// <returns>成功或失败</returns> | |||
public void CreateShortcutOnDesktop() | |||
{ | |||
//添加引用 (com->Windows Script Host Object Model),using IWshRuntimeLibrary; | |||
String shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), $"{AppDomain.CurrentDomain.FriendlyName}.lnk"); | |||
if (!System.IO.File.Exists(shortcutPath)) | |||
{ | |||
// 获取当前应用程序目录地址 | |||
String exePath = Process.GetCurrentProcess().MainModule.FileName; | |||
IWshShell shell = new WshShell(); | |||
// 确定是否已经创建的快捷键被改名了 | |||
foreach (var item in Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "*.lnk")) | |||
{ | |||
WshShortcut tempShortcut = (WshShortcut)shell.CreateShortcut(item); | |||
if (tempShortcut.TargetPath == exePath) | |||
{ | |||
return; | |||
} | |||
} | |||
WshShortcut shortcut = (WshShortcut)shell.CreateShortcut(shortcutPath); | |||
shortcut.TargetPath = exePath; | |||
shortcut.Arguments = "";// 参数 | |||
shortcut.Description = AppDomain.CurrentDomain.FriendlyName; | |||
shortcut.WorkingDirectory = Environment.CurrentDirectory;//程序所在文件夹,在快捷方式图标点击右键可以看到此属性 | |||
shortcut.IconLocation = exePath;//图标,该图标是应用程序的资源文件 | |||
//shortcut.Hotkey = "CTRL+SHIFT+W";//热键,发现没作用,大概需要注册一下 | |||
shortcut.WindowStyle = 1; | |||
shortcut.Save(); | |||
} | |||
} | |||
public void CreateShortcutOnDesktop(string Name) | |||
{ | |||
//添加引用 (com->Windows Script Host Object Model),using IWshRuntimeLibrary; | |||
String shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), $"{Name}.lnk"); | |||
if (!System.IO.File.Exists(shortcutPath)) | |||
{ | |||
// 获取当前应用程序目录地址 | |||
String exePath = $"{AppDomain.CurrentDomain.BaseDirectory}{Name}.exe";// Process.GetCurrentProcess().MainModule.FileName; | |||
IWshShell shell = new WshShell(); | |||
// 确定是否已经创建的快捷键被改名了 | |||
foreach (var item in Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "*.lnk")) | |||
{ | |||
WshShortcut tempShortcut = (WshShortcut)shell.CreateShortcut(item); | |||
if (tempShortcut.TargetPath == exePath) | |||
{ | |||
return; | |||
} | |||
} | |||
WshShortcut shortcut = (WshShortcut)shell.CreateShortcut(shortcutPath); | |||
shortcut.TargetPath = exePath; | |||
shortcut.Arguments = "";// 参数 | |||
shortcut.Description = AppDomain.CurrentDomain.FriendlyName; | |||
shortcut.WorkingDirectory = Environment.CurrentDirectory;//程序所在文件夹,在快捷方式图标点击右键可以看到此属性 | |||
shortcut.IconLocation = exePath;//图标,该图标是应用程序的资源文件 | |||
//shortcut.Hotkey = "CTRL+SHIFT+W";//热键,发现没作用,大概需要注册一下 | |||
shortcut.WindowStyle = 1; | |||
shortcut.Save(); | |||
} | |||
} | |||
/// <summary> | |||
/// 设置开机自启动 | |||
/// </summary> | |||
/// <param name="isAuto">true:开机启动,false:不开机自启</param> | |||
public void AutoStart(bool isAuto = true) | |||
{ | |||
if (isAuto == true) | |||
{ | |||
RegistryKey R_local = Registry.CurrentUser; | |||
RegistryKey R_run = R_local.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"); | |||
R_run.SetValue(GetApplicationName, GetApplicationPath); | |||
R_run.Close(); | |||
R_local.Close(); | |||
} | |||
else | |||
{ | |||
RegistryKey R_local = Registry.CurrentUser; | |||
RegistryKey R_run = R_local.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"); | |||
R_run.DeleteValue(GetApplicationName, false); | |||
R_run.Close(); | |||
R_local.Close(); | |||
} | |||
} | |||
/// <summary> | |||
/// 判断是否是自动启动 | |||
/// </summary> | |||
/// <returns></returns> | |||
public bool IsAutoStart() | |||
{ | |||
RegistryKey R_local = Registry.CurrentUser; | |||
RegistryKey R_run = R_local.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"); | |||
bool res = R_run.GetValueNames().Contains(GetApplicationName); | |||
R_run.Close(); | |||
R_local.Close(); | |||
return res; | |||
} | |||
#region U盘,串口插拔信息 | |||
private const int WM_DEVICECHANGE = 0x219; //设备改变 | |||
private const int DBT_DEVICEARRIVAL = 0x8000; //检测到新设备 | |||
private const int DBT_DEVICEREMOVECOMPLETE = 0x8004; //移除设备 | |||
public const int DBT_DEVTYP_PORT = 0x00000003; | |||
public const int DBT_DEVTYP_VOLUME = 0x00000002; | |||
public IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) | |||
{ | |||
if (msg == WM_DEVICECHANGE) | |||
{ | |||
//插入 | |||
if (wParam.ToInt32() == DBT_DEVICEARRIVAL) | |||
{ | |||
var volume = (DEV_BROADCAST_HDR)Marshal.PtrToStructure(lParam, typeof(DEV_BROADCAST_HDR)); | |||
switch (volume.dbch_devicetype) | |||
{ | |||
case DBT_DEVTYP_PORT://串口设备 | |||
string portName = Marshal.PtrToStringUni(lParam + Marshal.SizeOf(typeof(DEV_BROADCAST_PORT))); | |||
break; | |||
case DBT_DEVTYP_VOLUME: | |||
var drive = GetDrive(lParam); | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
//拔出 | |||
if (wParam.ToInt32() == DBT_DEVICEREMOVECOMPLETE) | |||
{ | |||
var volume = (DEV_BROADCAST_HDR)Marshal.PtrToStructure(lParam, typeof(DEV_BROADCAST_HDR)); | |||
switch (volume.dbch_devicetype) | |||
{ | |||
case DBT_DEVTYP_PORT://串口设备 | |||
string portName = Marshal.PtrToStringUni(lParam + Marshal.SizeOf(typeof(DEV_BROADCAST_PORT))); | |||
break; | |||
case DBT_DEVTYP_VOLUME: | |||
var drive = GetDrive(lParam); | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
} | |||
return IntPtr.Zero; | |||
} | |||
private static string GetDrive(IntPtr lParam) | |||
{ | |||
var volume = (DEV_BROADCAST_VOLUME)Marshal.PtrToStructure(lParam, typeof(DEV_BROADCAST_VOLUME)); | |||
var letter = GetLetter(volume.dbcv_unitmask); | |||
return string.Format("{0}:\\", letter); | |||
} | |||
/// <summary> | |||
/// 获得盘符 | |||
/// </summary> | |||
/// <param name="dbcvUnitmask"> | |||
/// 1 = A | |||
/// 2 = B | |||
/// 4 = C... | |||
/// </param> | |||
/// <returns>结果是A~Z的任意一个字符或者为'?'</returns> | |||
private static char GetLetter(uint dbcvUnitmask) | |||
{ | |||
const char nona = '?'; | |||
const string drives = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |||
if (dbcvUnitmask == 0) return nona; | |||
var i = 0; | |||
var pom = dbcvUnitmask >> 1; | |||
while (pom != 0) | |||
{ | |||
pom = pom >> 1; | |||
i++; | |||
} | |||
if (i < drives.Length) | |||
return drives[i]; | |||
return nona; | |||
} | |||
#endregion | |||
} | |||
[StructLayout(LayoutKind.Sequential)] | |||
struct DEV_BROADCAST_HDR | |||
{ | |||
public UInt32 dbch_size; | |||
public UInt32 dbch_devicetype; | |||
public UInt32 dbch_reserved; | |||
} | |||
[StructLayout(LayoutKind.Sequential)] | |||
struct DEV_BROADCAST_PORT | |||
{ | |||
public uint dbcp_size; | |||
public uint dbcp_devicetype; | |||
public uint dbcp_reserved; | |||
} | |||
[StructLayout(LayoutKind.Sequential)] | |||
struct DEV_BROADCAST_PORT_A | |||
{ | |||
public uint dbcp_size; | |||
public uint dbcp_devicetype; | |||
public uint dbcp_reserved; | |||
//public string dbcp_name; | |||
} | |||
[StructLayout(LayoutKind.Sequential)] | |||
struct DEV_BROADCAST_VOLUME | |||
{ | |||
/// DWORD->unsigned int | |||
public uint dbcv_size; | |||
/// DWORD->unsigned int | |||
public uint dbcv_devicetype; | |||
/// DWORD->unsigned int | |||
public uint dbcv_reserved; | |||
/// DWORD->unsigned int | |||
public uint dbcv_unitmask; | |||
/// WORD->unsigned short | |||
public ushort dbcv_flags; | |||
} | |||
} |
@@ -8,7 +8,7 @@ namespace BeDesignerSCADA | |||
/// </summary> | |||
public partial class MainWindow : Window | |||
{ | |||
CanvasPanelNew mainCanvas = new CanvasPanelNew(""); | |||
CanvasPanelNew mainCanvas = new CanvasPanelNew($"{System.AppDomain.CurrentDomain.BaseDirectory}Layouts\\可视化界面菜单布局.yf"); | |||
public MainWindow() | |||
{ | |||
InitializeComponent(); | |||
@@ -198,58 +198,68 @@ | |||
<!--#region 其他--> | |||
<DataTemplate x:Key="PageBoxStyle"> | |||
<Button x:Name="dsd" Background="Transparent" BorderBrush="DarkBlue" CommandParameter="{Binding .}" Command="{Binding DataContext.SelectPageCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"> | |||
<Grid x:Name="mains" Margin="2"> | |||
<Grid.Background> | |||
<ImageBrush ImageSource="../Images/bj.png" Stretch="UniformToFill"/> | |||
</Grid.Background> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="auto"/> | |||
<RowDefinition Height="auto"/> | |||
</Grid.RowDefinitions> | |||
<Rectangle Height="100" Width="200" Stroke="Cyan" StrokeThickness="1"> | |||
<Rectangle.Fill> | |||
<VisualBrush Visual="{Binding visual,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> | |||
</Rectangle.Fill> | |||
</Rectangle> | |||
<StackPanel Grid.Row="1" Orientation="Horizontal"> | |||
<icon:PackIconModern x:Name="Sort" Width="10" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,0,5,0" Foreground="#FFFFA500" Kind="Page" /> | |||
<TextBlock FontWeight="Bold" Margin="5,0,0,0" FontSize="14" Foreground="#FFFFA500" | |||
x:Name="txt" | |||
Grid.Column="1" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Bottom" | |||
Text="{Binding Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> | |||
</StackPanel> | |||
<StackPanel x:Name="stack" Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,10,0"> | |||
<Button Width="24" Cursor="Hand" BorderBrush="Transparent" Background="Transparent" CommandParameter="{Binding .}" Command="{Binding DataContext.AddPageCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" Padding="0" Margin="0,0,0,0" ToolTip="增加页"> | |||
<icon:PackIconModern ToolTip="增加页" Width="10" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FFFFA500" Kind="Add" /> | |||
</Button> | |||
<Button Width="24" Cursor="Hand" BorderBrush="Transparent" Background="Transparent" CommandParameter="{Binding .}" Command="{Binding DataContext.DeletePageCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" VerticalAlignment="Center" Padding="0" ToolTip="删除页"> | |||
<icon:PackIconModern ToolTip="删除页" Width="10" HorizontalAlignment="Center" Foreground="#FFFFA500" Kind="Delete" /> | |||
</Button> | |||
</StackPanel> | |||
</Grid> | |||
<Button x:Name="dsd" Background="#4818659B" BorderBrush="Transparent" CommandParameter="{Binding .}" Command="{Binding DataContext.SelectPageCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"> | |||
<Button.Template> | |||
<ControlTemplate> | |||
<Grid x:Name="mains" Margin="0"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="auto"/> | |||
<RowDefinition Height="auto"/> | |||
</Grid.RowDefinitions> | |||
<Grid> | |||
<Grid.Background> | |||
<ImageBrush ImageSource="../Images/bj.png" Stretch="UniformToFill"/> | |||
</Grid.Background> | |||
</Grid> | |||
<Grid Grid.Row="1" Background="#010AA74D"> | |||
</Grid> | |||
<Rectangle Height="100" Width="200" StrokeThickness="0"> | |||
<Rectangle.Fill> | |||
<VisualBrush Visual="{Binding visual,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> | |||
</Rectangle.Fill> | |||
</Rectangle> | |||
<StackPanel Grid.Row="1" Orientation="Horizontal"> | |||
<icon:PackIconModern x:Name="Sort" Width="10" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,0,5,0" Foreground="White" Kind="Page" /> | |||
<TextBlock Margin="5,0,0,0" Foreground="White" FontSize="12" HorizontalAlignment="Left" | |||
VerticalAlignment="Bottom" | |||
Text="{Binding Sort,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"></TextBlock> | |||
<TextBlock Foreground="White" FontSize="12" HorizontalAlignment="Left" | |||
VerticalAlignment="Bottom" | |||
Text="-"></TextBlock> | |||
<TextBlock Margin="0,0,0,0" FontSize="12" Foreground="White" | |||
x:Name="txt" Grid.Column="1" HorizontalAlignment="Left" | |||
VerticalAlignment="Bottom" | |||
Text="{Binding Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> | |||
</StackPanel> | |||
<StackPanel x:Name="stack" Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,10,0"> | |||
<Button Width="24" Cursor="Hand" BorderBrush="Transparent" Background="Transparent" CommandParameter="{Binding .}" Command="{Binding DataContext.AddPageCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" Padding="0" Margin="0,0,0,0" ToolTip="增加页"> | |||
<icon:PackIconModern ToolTip="增加页" Width="10" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White" Kind="Add" /> | |||
</Button> | |||
<Button Width="24" Cursor="Hand" BorderBrush="Transparent" Background="Transparent" CommandParameter="{Binding .}" Command="{Binding DataContext.DeletePageCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" VerticalAlignment="Center" Padding="0" ToolTip="删除页"> | |||
<icon:PackIconModern ToolTip="删除页" Width="10" HorizontalAlignment="Center" Foreground="White" Kind="Delete" /> | |||
</Button> | |||
</StackPanel> | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="True"> | |||
<Setter Property="Visibility" Value="Visible" TargetName="stack"></Setter> | |||
</Trigger> | |||
<Trigger Property="IsMouseOver" Value="false"> | |||
<Setter Property="Visibility" Value="Collapsed" TargetName="stack"></Setter> | |||
</Trigger> | |||
<DataTrigger Binding="{Binding IsHome,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Value="True"> | |||
<Setter TargetName="Sort" Property="Kind" Value="Home" /> | |||
</DataTrigger> | |||
<DataTrigger Binding="{Binding IsHome,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Value="False"> | |||
<Setter TargetName="Sort" Property="Kind" Value="Page" /> | |||
</DataTrigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Button.Template> | |||
</Button> | |||
<DataTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="True"> | |||
<Setter Property="Visibility" Value="Visible" TargetName="stack"></Setter> | |||
</Trigger> | |||
<Trigger Property="IsMouseOver" Value="false"> | |||
<Setter Property="Visibility" Value="Collapsed" TargetName="stack"></Setter> | |||
</Trigger> | |||
<!--<Trigger Property="IsSelected" Value="True"> | |||
<Setter Property="BorderBrush" Value="Red" TargetName="dsd"></Setter> | |||
</Trigger>--> | |||
<DataTrigger Binding="{Binding IsHome,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Value="True"> | |||
<Setter TargetName="Sort" Property="Kind" Value="Home" /> | |||
</DataTrigger> | |||
<DataTrigger Binding="{Binding IsHome,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Value="False"> | |||
<Setter TargetName="Sort" Property="Kind" Value="Page" /> | |||
</DataTrigger> | |||
</DataTemplate.Triggers> | |||
</DataTemplate> | |||
<DataTemplate x:Key="ToolBoxStyle"> | |||
@@ -14,7 +14,7 @@ | |||
<Window.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" /> | |||
<ResourceDictionary Source="/可视化配置工具;component/Themes/Styles.xaml"></ResourceDictionary> | |||
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" /> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
@@ -6,12 +6,13 @@ | |||
xmlns:local="clr-namespace:BeDesignerSCADA.View" | |||
xmlns:ctl="clr-namespace:BeDesignerSCADA.Controls" | |||
mc:Ignorable="d" | |||
WindowStyle="None" | |||
WindowState="Maximized" | |||
Title="模拟运行器" Height="450" Width="800"> | |||
<Window.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" /> | |||
<ResourceDictionary Source="/可视化配置工具;component/Themes/Styles.xaml"></ResourceDictionary> | |||
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" /> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
@@ -25,9 +25,24 @@ namespace BeDesignerSCADA.View | |||
InitializeComponent(); | |||
} | |||
public void LoadingData(MenuModel frameworks) | |||
/// <summary> | |||
/// 1.根据菜单Model加载界面 | |||
/// </summary> | |||
/// <param name="frameworks"></param> | |||
public void LoadingData(MenuModel menuModel) | |||
{ | |||
runCanvas.RunMenu(frameworks); | |||
runCanvas.RunMenu(menuModel); | |||
runCanvas.PandClick(this); | |||
} | |||
/// <summary> | |||
/// 2.根据路径加载界面 | |||
/// </summary> | |||
/// <param name="frameworks"></param> | |||
public void LoadingData(string _path) | |||
{ | |||
runCanvas.LoadingData(_path); | |||
runCanvas.PandClick(this); | |||
} | |||
} | |||
} |
@@ -11,7 +11,7 @@ | |||
<Window.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
<ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" /> | |||
<ResourceDictionary Source="/可视化配置工具;component/Themes/Styles.xaml"></ResourceDictionary> | |||
<ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" /> | |||
</ResourceDictionary.MergedDictionaries> | |||
</ResourceDictionary> | |||
@@ -384,6 +384,10 @@ namespace BeDesignerSCADA.ViewModel | |||
/// </summary> | |||
public RelayCommand SaveAllPageCommand { get; set; } | |||
/// <summary> | |||
/// 另存页面文件 | |||
/// </summary> | |||
public RelayCommand LWSaveAllPageCommand { get; set; } | |||
/// <summary> | |||
/// 加载页面文件 | |||
/// </summary> | |||
public RelayCommand LoadAllPageCommand { get; set; } | |||
@@ -403,6 +407,7 @@ namespace BeDesignerSCADA.ViewModel | |||
DeletePageCommand = new RelayCommand<object>(new Action<object?>(DeletePageHeader)); | |||
SelectPageCommand = new RelayCommand<object>(new Action<object?>(SelectPageHeader)); | |||
SaveAllPageCommand = new RelayCommand(new Action(SaveAllPageHeader)); | |||
LWSaveAllPageCommand=new RelayCommand(new Action(LWSaveAllPageHeader)); | |||
LoadAllPageCommand = new RelayCommand(new Action(LoadAllPageHeader)); | |||
LoadValuesCommand = new RelayCommand(new Action(LoadValuesHeader)); | |||
@@ -412,7 +417,6 @@ namespace BeDesignerSCADA.ViewModel | |||
MenuModel.SelectPageModels = MenuModel.pageModels[0]; | |||
GxSortTarget(); | |||
} | |||
/// <summary> | |||
/// 刷新排序 | |||
/// </summary> | |||
@@ -573,15 +577,37 @@ namespace BeDesignerSCADA.ViewModel | |||
/// 导出页面文件 | |||
/// </summary> | |||
public void SaveAllPageHeader() | |||
{ | |||
try | |||
{ | |||
string _path = $"{System.AppDomain.CurrentDomain.BaseDirectory}Layouts\\可视化界面菜单布局.yf"; | |||
if (!Directory.Exists($"{System.AppDomain.CurrentDomain.BaseDirectory}Layouts")) // 返回bool类型,存在返回true,不存在返回false | |||
{ | |||
Directory.CreateDirectory($"{System.AppDomain.CurrentDomain.BaseDirectory}Layouts"); //不存在则创建路径 | |||
} | |||
if (File.Exists(_path)) // 返回bool类型,存在返回true,不存在返回false | |||
{ | |||
File.Delete(_path); | |||
} | |||
SaveAllPageHeaderPath(_path); | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
/// <summary> | |||
/// 另存文件 | |||
/// </summary> | |||
public void LWSaveAllPageHeader() | |||
{ | |||
try | |||
{ | |||
SaveFileDialog sfd = new SaveFileDialog(); | |||
sfd.Filter = "页面布局|*.yf"; | |||
if (sfd.ShowDialog() == true) | |||
{ | |||
BinaryFile.SaveBinary(MenuModel, sfd.FileName); | |||
SaveAllPageHeaderPath(sfd.FileName); | |||
} | |||
} | |||
catch (Exception ex) | |||
@@ -589,6 +615,23 @@ namespace BeDesignerSCADA.ViewModel | |||
} | |||
} | |||
/// <summary> | |||
/// 根据路径保存菜单布局 | |||
/// </summary> | |||
/// <param name="path"></param> | |||
public void SaveAllPageHeaderPath(string path) | |||
{ | |||
try | |||
{ | |||
BinaryFile.SaveBinary(MenuModel, path); | |||
MessageBox.Show("保存成功!"); | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageBox.Show("保存失败!原因:" +ex.Message); | |||
} | |||
} | |||
/// <summary> | |||
/// 加载页面文件 | |||
/// </summary> | |||
@@ -600,17 +643,35 @@ namespace BeDesignerSCADA.ViewModel | |||
ofd.Filter = "页面布局|*.yf"; | |||
if (ofd.ShowDialog() == true) | |||
{ | |||
MenuModel = BinaryFile.ReadBinary<MenuModel>(ofd.FileName) as MenuModel; | |||
MenuModel?.pageModels?.ToList().ForEach(par => | |||
LoadAllPageHeaderPath(ofd.FileName); | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
/// <summary> | |||
/// 根据路径加载菜单布局 | |||
/// </summary> | |||
/// <param name="path"></param> | |||
public void LoadAllPageHeaderPath(string path) | |||
{ | |||
try | |||
{ | |||
MenuModel = BinaryFile.ReadBinary<MenuModel>(path) as MenuModel; | |||
MenuModel?.pageModels?.ToList().ForEach(par => | |||
{ | |||
par.visual = new CanvasPanel(); | |||
par?.ChildrenStr?.ForEach(k => | |||
{ | |||
par.visual = new CanvasPanel(); | |||
par?.ChildrenStr?.ForEach(k => | |||
{ | |||
FrameworkElement item = XamlReader.Parse(k) as FrameworkElement; | |||
par.visual.Children.Add(item); | |||
}); | |||
FrameworkElement item = XamlReader.Parse(k) as FrameworkElement; | |||
par.visual.Children.Add(item); | |||
}); | |||
}); | |||
if (MenuModel.pageModels != null && MenuModel.pageModels.Count > 0) | |||
{ | |||
SelectPageHeader(MenuModel.pageModels?.ToList()?[0]); | |||
} | |||
} | |||
catch (Exception ex) | |||
@@ -112,7 +112,13 @@ namespace BPASmartClient.DosingSystem | |||
AssemblyName = "BPASmartClient.DosingSystem", | |||
ToggleWindowPath = "View.ManualControlView" | |||
}); | |||
ManualControl.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "料仓控制", | |||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.DosingSystem", | |||
ToggleWindowPath = "View.StockControlView" | |||
}); | |||
MenuManage.GetInstance.menuModels.Add(new MenuModel() | |||
{ | |||
MainMenuIcon = "", | |||
@@ -0,0 +1,40 @@ | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem.Model | |||
{ | |||
internal class StockStatusModel:ObservableObject | |||
{ | |||
/// <summary> | |||
/// 料仓物料重量 | |||
/// </summary> | |||
private double _materialWeight; | |||
public double MaterialWeight { get { return _materialWeight; } set { _materialWeight = value;OnPropertyChanged(); } } | |||
/// <summary> | |||
/// 料仓物料名称 | |||
/// </summary> | |||
private string _materialName; | |||
public string MaterialName { get { return _materialName; } set { _materialName = value; OnPropertyChanged(); } } | |||
/// <summary> | |||
/// 是否真在运行 | |||
/// </summary> | |||
private bool _isRunning; | |||
public bool IsRunning { get { return _isRunning; } set { _isRunning = value; OnPropertyChanged(); } } | |||
/// <summary> | |||
/// 是否正在下料 | |||
/// </summary> | |||
private bool _isLayOff; | |||
public bool IsLayOff { get { return _isLayOff; } set { _isLayOff = value; OnPropertyChanged(); } } | |||
/// <summary> | |||
/// 是否故障报警 | |||
/// </summary> | |||
private bool _isFault; | |||
public bool IsFault { get { return _isFault; } set { _isFault = value; OnPropertyChanged(); } } | |||
} | |||
} |
@@ -0,0 +1,201 @@ | |||
<UserControl x:Class="BPASmartClient.DosingSystem.View.StockControlView" | |||
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:BPASmartClient.DosingSystem.View" | |||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | |||
xmlns:define="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
mc:Ignorable="d" | |||
d:DesignHeight="450" d:DesignWidth="800"> | |||
<UserControl.DataContext> | |||
<vm:StockControViewModel/> | |||
</UserControl.DataContext> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition/> | |||
<RowDefinition/> | |||
<RowDefinition/> | |||
</Grid.RowDefinitions> | |||
<Grid x:Name="TopGrid"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition/> | |||
<RowDefinition Height="0.2*"/> | |||
</Grid.RowDefinitions> | |||
<ListView | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
BorderThickness="0" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled" | |||
ScrollViewer.VerticalScrollBarVisibility="Disabled" ItemsSource="{Binding statusTop}"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<UniformGrid Columns="6" HorizontalAlignment="Left" | |||
VerticalAlignment="Top" | |||
Rows="1" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="0.8*"/> | |||
<RowDefinition Height="0.2*"/> | |||
</Grid.RowDefinitions> | |||
<define:MaterialStock Margin="0,0,70,0" IsOpenState="False" IsFaultState="False" IsRunning="False" IsLayOffState="False"/> | |||
<Grid VerticalAlignment="Bottom" Margin="5,5,70,0" Grid.Row="1" > | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition/> | |||
<ColumnDefinition/> | |||
</Grid.ColumnDefinitions> | |||
<Button Margin="0,0,10,0"> | |||
<Button.Template> | |||
<ControlTemplate TargetType="{x:Type Button}"> | |||
<Border x:Name="br3" BorderThickness="2" BorderBrush="DimGray" CornerRadius="5" Background="Orange"> | |||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"> | |||
<TextBlock VerticalAlignment="Center" Text="" FontFamily="/BPASmartClient.CustomResource;component/Fonts/new/#iconfont" Margin="0,0,5,0"/> | |||
<TextBlock Text="开盖" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="14"/> | |||
</StackPanel> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsPressed" Value="True"> | |||
<Setter Property="Background" Value="yellow" TargetName="br3"/> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Button.Template> | |||
</Button> | |||
<Button Grid.Column="1"> | |||
<Button.Template> | |||
<ControlTemplate TargetType="{x:Type Button}"> | |||
<Border x:Name="br2" BorderThickness="2" BorderBrush="DimGray" CornerRadius="5" Background="yellowgreen"> | |||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" > | |||
<TextBlock VerticalAlignment="Center" Text="" FontFamily="/BPASmartClient.CustomResource;component/Fonts/new/#iconfont" Margin="0,0,5,0"/> | |||
<TextBlock Text="出料" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="14"/> | |||
</StackPanel> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsPressed" Value="True"> | |||
<Setter Property="Background" Value="lawngreen" TargetName="br2"/> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Button.Template> | |||
</Button> | |||
</Grid> | |||
</Grid> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
</Grid> | |||
<Grid Grid.Row="1" x:Name="midGrid" Margin="0,0,0,0"> | |||
<define:ConveyBelt2 IsRun="True" BeltWidth="{Binding ElementName=midGrid, Path=ActualWidth}" BeltHeight="{Binding ElementName=midGrid, Path=ActualHeight}" Margin="-12,0,10,0" BeltDashThickess="50"/> | |||
</Grid> | |||
<Grid Grid.Row="2"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="0.2*"/> | |||
<RowDefinition/> | |||
</Grid.RowDefinitions> | |||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,40,0"> | |||
<Button HorizontalAlignment="Right" Margin="0,0,10,0"> | |||
<Button.Template> | |||
<ControlTemplate TargetType="{x:Type Button}"> | |||
<Border x:Name="br5" BorderThickness="2" BorderBrush="DimGray" CornerRadius="5" Background="yellowgreen"> | |||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" > | |||
<TextBlock VerticalAlignment="Center" Text="" FontFamily="/BPASmartClient.CustomResource;component/Fonts/new/#iconfont" Margin="0,0,5,0"/> | |||
<TextBlock Text="启动线体" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="14"/> | |||
</StackPanel> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsPressed" Value="True"> | |||
<Setter Property="Background" Value="lawngreen" TargetName="br5"/> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Button.Template> | |||
</Button> | |||
<Button HorizontalAlignment="Right" Margin="0,0,10,0"> | |||
<Button.Template> | |||
<ControlTemplate TargetType="{x:Type Button}"> | |||
<Border x:Name="br5" BorderThickness="2" BorderBrush="DimGray" CornerRadius="5" Background="Red"> | |||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" > | |||
<TextBlock VerticalAlignment="Center" Text="" FontFamily="/BPASmartClient.CustomResource;component/Fonts/new/#iconfont" Margin="0,0,5,0"/> | |||
<TextBlock Text="停止线体" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="14"/> | |||
</StackPanel> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsPressed" Value="True"> | |||
<Setter Property="Background" Value="PaleVioletRed" TargetName="br5"/> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Button.Template> | |||
</Button> | |||
</StackPanel> | |||
<ListView Grid.Row="1" Background="Transparent" VerticalAlignment="Center" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled" | |||
BorderThickness="0" ScrollViewer.VerticalScrollBarVisibility="Disabled" ItemsSource="{Binding statusDown}"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<UniformGrid Columns="6" HorizontalAlignment="Left" | |||
VerticalAlignment="Top" | |||
Rows="1" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="0.8*"/> | |||
<RowDefinition Height="0.2*"/> | |||
</Grid.RowDefinitions> | |||
<define:MaterialStock Margin="0,0,70,0" IsOpenState="False" IsFaultState="False" IsRunning="True" /> | |||
<Grid VerticalAlignment="Bottom" Margin="5,5,70,0" Grid.Row="1" > | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition/> | |||
<ColumnDefinition/> | |||
</Grid.ColumnDefinitions> | |||
<Button Margin="0,0,10,0"> | |||
<Button.Template> | |||
<ControlTemplate TargetType="{x:Type Button}"> | |||
<Border x:Name="br" BorderThickness="2" BorderBrush="DimGray" CornerRadius="5" Background="Orange"> | |||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"> | |||
<TextBlock VerticalAlignment="Center" Text="" FontFamily="/BPASmartClient.CustomResource;component/Fonts/new/#iconfont" Margin="0,0,5,0"/> | |||
<TextBlock Text="开盖" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="14"/> | |||
</StackPanel> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsPressed" Value="True"> | |||
<Setter Property="Background" Value="yellow" TargetName="br"/> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Button.Template> | |||
</Button> | |||
<Button Grid.Column="1"> | |||
<Button.Template> | |||
<ControlTemplate TargetType="{x:Type Button}"> | |||
<Border x:Name="br1" BorderThickness="2" BorderBrush="DimGray" CornerRadius="5" Background="yellowgreen"> | |||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" > | |||
<TextBlock VerticalAlignment="Center" Text="" FontFamily="/BPASmartClient.CustomResource;component/Fonts/new/#iconfont" Margin="0,0,5,0"/> | |||
<TextBlock Text="出料" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="14"/> | |||
</StackPanel> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsPressed" Value="True"> | |||
<Setter Property="Background" Value="lawngreen" TargetName="br1"/> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Button.Template> | |||
</Button> | |||
</Grid> | |||
</Grid> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
</Grid> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,30 @@ | |||
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 BPASmartClient.DosingSystem.View | |||
{ | |||
/// <summary> | |||
/// StockControlView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class StockControlView : UserControl | |||
{ | |||
public StockControlView() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,30 @@ | |||
using BPASmartClient.DosingSystem.Model; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
internal class StockControViewModel | |||
{ | |||
public StockControViewModel() | |||
{ | |||
for (int i = 0; i < 6; i++) | |||
{ | |||
statusTop.Add(new StockStatusModel { IsFault = false, IsLayOff = true, IsRunning = true, MaterialName = $"{i+1}号料仓", MaterialWeight = 85+i }); | |||
} | |||
for (int i =6; i < 12; i++) | |||
{ | |||
statusDown.Add(new StockStatusModel { IsFault = false, IsLayOff = true, IsRunning = true, MaterialName = $"{i+1}号料仓", MaterialWeight = 85 + i }); | |||
} | |||
} | |||
public ObservableCollection<StockStatusModel> statusTop { get; set; } = new ObservableCollection<StockStatusModel>(); | |||
public ObservableCollection<StockStatusModel> statusDown { get; set; } = new ObservableCollection<StockStatusModel>(); | |||
} | |||
} |
@@ -2,12 +2,11 @@ | |||
<configuration> | |||
<appSettings> | |||
<!--请求报文头--> | |||
<add key="appKey" value="132"/> | |||
<add key="appKey" value="true"/> | |||
<add key="appSecret" value="123"/> | |||
<add key="requestId" value="123"/> | |||
<add key="timestamp" value="123"/> | |||
<add key ="version" value="2.8"/> | |||
<!--请求报文体--> | |||
</appSettings> | |||
<!--请求报文体--> | |||
</configuration> |
@@ -25,7 +25,7 @@ namespace FryPot_DosingSystem | |||
public partial class App : Application | |||
{ | |||
public static Window MainWindow; | |||
protected override void OnStartup(StartupEventArgs e) | |||
protected override async void OnStartup(StartupEventArgs e) | |||
{ | |||
base.OnStartup(e); | |||
SystemHelper.GetInstance.CreateDesktopShortcut(); | |||
@@ -39,7 +39,7 @@ namespace FryPot_DosingSystem | |||
{ | |||
mv.Show(); | |||
MessageLog.GetInstance.ShowUserLog("用户登录"); | |||
DeviceOperate deviceOperate = DeviceOperate.GetInstance;//开启实时PLC数据读取 | |||
await Task.Run(()=> { DeviceOperate deviceOperate = DeviceOperate.GetInstance; });//开启实时PLC数据读取 | |||
DosingLogicControl logigControl = DosingLogicControl.GetInstance;//开启逻辑控制任务程序 | |||
HubHelper.GetInstance.Connect("192.168.1.20", 8089); | |||
AlarmHelper<AlarmInfo>.Init();//报警实时监控 | |||
@@ -18,7 +18,7 @@ namespace FryPot_DosingSystem.Control | |||
internal class DeviceOperate | |||
{ | |||
private static DeviceOperate _instance; | |||
public static DeviceOperate GetInstance => _instance ??= new DeviceOperate(); | |||
public static DeviceOperate GetInstance => _instance ??(_instance= new DeviceOperate()); | |||
public bool IsConfig { get; set; }//设备plc数据是否配置 | |||
ModbusTcp modbus = new ModbusTcp();//滚筒线Modbus通讯对象 | |||
ModbusTcp fryOneModbus = new ModbusTcp();//炒锅1Modbus通讯对象 | |||
@@ -54,7 +54,15 @@ namespace FryPot_DosingSystem.Control | |||
Init(); | |||
Connect(); | |||
ReadData(); | |||
ConnectStatusMonitor(); | |||
} | |||
private void ConnectStatusMonitor() | |||
{ | |||
} | |||
public void Init() | |||
{ | |||
Variables.Clear(); | |||
@@ -69,13 +77,13 @@ namespace FryPot_DosingSystem.Control | |||
{ | |||
try | |||
{ | |||
if (Json<PlcVariableInfoManage>.Data.VariablesInfo["滚筒输送线"].Count>0) | |||
if (Json<PlcVariableInfoManage>.Data.VariablesInfo["滚筒输送线"].Count > 0) | |||
{ | |||
//foreach (var item in Json<PlcVariableInfoManage>.Data.VariablesInfo["滚筒运输线"]) | |||
//{ | |||
// Variables.Add(new PlcVariableModel { Address = item.PlcAddress, Length = (ushort)(item.Length == null ? 0 : item.Length) }); | |||
//} | |||
foreach (KeyValuePair<string,ObservableCollection<PlcVariableInfoModel>> dic in Json<PlcVariableInfoManage>.Data.VariablesInfo) | |||
foreach (KeyValuePair<string, ObservableCollection<PlcVariableInfoModel>> dic in Json<PlcVariableInfoManage>.Data.VariablesInfo) | |||
{ | |||
if (string.Equals(dic.Key, "滚筒输送线")) | |||
{ | |||
@@ -122,19 +130,19 @@ namespace FryPot_DosingSystem.Control | |||
} | |||
} | |||
IsConfig = true; | |||
MessageLog.GetInstance.ShowRunLog("PLC变量配置成功"); | |||
MessageLog.GetInstance.ShowRunLog("PLC变量配置加载成功"); | |||
} | |||
catch (Exception) | |||
{ | |||
IsConfig = false; | |||
MessageLog.GetInstance.ShowRunLog("PLC变量配置错误,请重新配置并重启软件"); | |||
MessageLog.GetInstance.ShowRunLog("PLC变量配置加载错误,请重新配置并重启软件"); | |||
//throw; | |||
} | |||
} | |||
else | |||
{ | |||
IsConfig = false; | |||
MessageLog.GetInstance.ShowRunLog("PLC变量配置失败:文件无数据,请重新配置"); | |||
MessageLog.GetInstance.ShowRunLog("PLC变量配置加载失败:文件无数据,请重新配置并重启软件"); | |||
} | |||
//Variables.Add(new PlcVariableModel() { Address = "D2001", Length = 8 });//1号线体滚筒工位号 | |||
//Variables.Add(new PlcVariableModel() { Address = "D2011", Length = 8 });//2号线体滚筒工位号 | |||
@@ -162,6 +170,9 @@ namespace FryPot_DosingSystem.Control | |||
{ | |||
if (devices.Devices.Count > 0) | |||
{ | |||
for (int i = 0; i < devices.Devices.Count; i++) | |||
{ | |||
string Ip = devices.Devices[i].Ip; | |||
@@ -169,16 +180,17 @@ namespace FryPot_DosingSystem.Control | |||
string DeviceName = devices.Devices[i].DeviceName; | |||
switch (DeviceName) | |||
{ | |||
case "滚筒输送线": Task.Run(() => { modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("滚筒线PLC连接成功"); }); break; | |||
case "炒锅1": Task.Run(() => { fryOneModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("1号炒锅PLC连接成功"); }); break; | |||
case "炒锅2": Task.Run(() => { fryTwoModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("2号炒锅PLC连接成功"); }); break; | |||
case "炒锅3": Task.Run(() => { fryThreeModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("3号炒锅PLC连接成功"); }); break; | |||
case "炒锅4": Task.Run(() => { fryFourModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("4号炒锅PLC连接成功"); }); break; | |||
case "炒锅5": Task.Run(() => { fryFiveModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("5号炒锅PLC连接成功"); }); break; | |||
case "滚筒输送线": modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("滚筒线PLC连接成功"); break; | |||
case "炒锅1": fryOneModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("1号炒锅PLC连接成功"); break; | |||
case "炒锅2": fryTwoModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("2号炒锅PLC连接成功"); break; | |||
case "炒锅3": fryThreeModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("3号炒锅PLC连接成功"); break; | |||
case "炒锅4": fryFourModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("4号炒锅PLC连接成功"); break; | |||
case "炒锅5": fryFiveModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); MessageLog.GetInstance.ShowRunLog("5号炒锅PLC连接成功"); break; | |||
} | |||
} | |||
// Task.Run(() => { modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); App.Current.Dispatcher.Invoke(new Action(() => { BPASmartClient.CustomResource.Pages.Model.MessageLog.GetInstance.ShowRunLog("PLC连接成功"); })); }); | |||
} | |||
} | |||
} | |||
@@ -191,7 +203,7 @@ namespace FryPot_DosingSystem.Control | |||
{ | |||
//滚筒线 | |||
Connected = modbus.Connected; | |||
while (Connected) | |||
if (Connected) | |||
{ | |||
foreach (var item in Variables) | |||
{ | |||
@@ -205,106 +217,172 @@ namespace FryPot_DosingSystem.Control | |||
Data.TryAdd(item.Address, res); | |||
} | |||
} | |||
Thread.Sleep(50); | |||
} | |||
//炒锅1 | |||
FryOneConnected = fryOneModbus.Connected; | |||
while (FryOneConnected) | |||
{ | |||
foreach (var item in FryOneVariables) | |||
{ | |||
var res = fryOneModbus.Read(item.Address, item.Length);//读取plc数据 | |||
if (FryOneData.ContainsKey(item.Address)) | |||
{ | |||
FryOneData[item.Address] = res; | |||
} | |||
else | |||
{ | |||
FryOneData.TryAdd(item.Address, res); | |||
} | |||
} | |||
Thread.Sleep(50); | |||
} | |||
//炒锅2 | |||
FryTwoConnected = fryTwoModbus.Connected; | |||
while (FryTwoConnected) | |||
else | |||
{ | |||
foreach (var item in FryTwoVariables) | |||
{ | |||
var res = fryTwoModbus.Read(item.Address, item.Length);//读取plc数据 | |||
if (FryTwoData.ContainsKey(item.Address)) | |||
{ | |||
FryTwoData[item.Address] = res; | |||
} | |||
else | |||
{ | |||
FryTwoData.TryAdd(item.Address, res); | |||
} | |||
} | |||
Thread.Sleep(50); | |||
DeviceManage devices = Json<DeviceManage>.Data; | |||
var res = devices.Devices.FirstOrDefault(p => p.DeviceName == "滚筒输送线"); | |||
if (res != null) | |||
modbus.ModbusTcpConnect(res.Ip, Convert.ToInt32(res.Port)); MessageLog.GetInstance.ShowRunLog("滚筒线PLC重连成功"); | |||
} | |||
//炒锅3 | |||
FryThreeConnected = fryThreeModbus.Connected; | |||
while (FryThreeConnected) | |||
{ | |||
foreach (var item in FryThreeVariables) | |||
{ | |||
var res = fryThreeModbus.Read(item.Address, item.Length);//读取plc数据 | |||
if (FryThreeData.ContainsKey(item.Address)) | |||
{ | |||
FryThreeData[item.Address] = res; | |||
} | |||
else | |||
{ | |||
FryThreeData.TryAdd(item.Address, res); | |||
} | |||
} | |||
Thread.Sleep(50); | |||
Thread.Sleep(10); | |||
}), $"滚筒线实时数据读取线程"); | |||
} | |||
//炒锅4 | |||
FryFourConnected = fryFourModbus.Connected; | |||
while (FryFourConnected) | |||
{ | |||
foreach (var item in FryFourVariables) | |||
{ | |||
var res = fryFourModbus.Read(item.Address, item.Length);//读取plc数据 | |||
if (FryFourData.ContainsKey(item.Address)) | |||
{ | |||
FryFourData[item.Address] = res; | |||
} | |||
else | |||
{ | |||
FryFourData.TryAdd(item.Address, res); | |||
} | |||
} | |||
Thread.Sleep(50); | |||
} | |||
//炒锅5 | |||
FryFiveConnected = fryFiveModbus.Connected; | |||
while (FryFiveConnected) | |||
{ | |||
foreach (var item in FryFiveVariables) | |||
{ | |||
var res = fryFiveModbus.Read(item.Address, item.Length);//读取plc数据 | |||
if (FryFiveData.ContainsKey(item.Address)) | |||
{ | |||
FryFiveData[item.Address] = res; | |||
} | |||
else | |||
{ | |||
FryFiveData.TryAdd(item.Address, res); | |||
} | |||
} | |||
Thread.Sleep(50); | |||
} | |||
Thread.Sleep(500); | |||
}), $"PLC实时数据读取线程"); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
//炒锅1 | |||
FryOneConnected = fryOneModbus.Connected; | |||
if (FryOneConnected) | |||
{ | |||
foreach (var item in FryOneVariables) | |||
{ | |||
var res = fryOneModbus.Read(item.Address, item.Length);//读取plc数据 | |||
if (FryOneData.ContainsKey(item.Address)) | |||
{ | |||
FryOneData[item.Address] = res; | |||
} | |||
else | |||
{ | |||
FryOneData.TryAdd(item.Address, res); | |||
} | |||
} | |||
//Thread.Sleep(50); | |||
} | |||
else | |||
{ | |||
DeviceManage devices = Json<DeviceManage>.Data; | |||
var res = devices.Devices.FirstOrDefault(p => p.DeviceName == "炒锅1"); | |||
if (res != null) | |||
modbus.ModbusTcpConnect(res.Ip, Convert.ToInt32(res.Port)); MessageLog.GetInstance.ShowRunLog("1号炒锅PLC重连成功"); | |||
} | |||
Thread.Sleep(10); | |||
}), $"炒锅1实时数据读取线程"); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
//炒锅2 | |||
FryTwoConnected = fryTwoModbus.Connected; | |||
if (FryTwoConnected) | |||
{ | |||
foreach (var item in FryTwoVariables) | |||
{ | |||
var res = fryTwoModbus.Read(item.Address, item.Length);//读取plc数据 | |||
if (FryTwoData.ContainsKey(item.Address)) | |||
{ | |||
FryTwoData[item.Address] = res; | |||
} | |||
else | |||
{ | |||
FryTwoData.TryAdd(item.Address, res); | |||
} | |||
} | |||
} | |||
else | |||
{ | |||
DeviceManage devices = Json<DeviceManage>.Data; | |||
var res = devices.Devices.FirstOrDefault(p => p.DeviceName == "炒锅2"); | |||
if (res != null) | |||
modbus.ModbusTcpConnect(res.Ip, Convert.ToInt32(res.Port)); MessageLog.GetInstance.ShowRunLog("2号炒锅PLC重连成功"); | |||
} | |||
Thread.Sleep(10); | |||
}), $"炒锅2实时数据读取线程"); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
//炒锅3 | |||
FryThreeConnected = fryThreeModbus.Connected; | |||
if (FryThreeConnected) | |||
{ | |||
foreach (var item in FryThreeVariables) | |||
{ | |||
var res = fryThreeModbus.Read(item.Address, item.Length);//读取plc数据 | |||
if (FryThreeData.ContainsKey(item.Address)) | |||
{ | |||
FryThreeData[item.Address] = res; | |||
} | |||
else | |||
{ | |||
FryThreeData.TryAdd(item.Address, res); | |||
} | |||
} | |||
//Thread.Sleep(50); | |||
} | |||
else | |||
{ | |||
DeviceManage devices = Json<DeviceManage>.Data; | |||
var res = devices.Devices.FirstOrDefault(p => p.DeviceName == "炒锅3"); | |||
if (res != null) | |||
modbus.ModbusTcpConnect(res.Ip, Convert.ToInt32(res.Port)); MessageLog.GetInstance.ShowRunLog("3号炒锅PLC重连成功"); | |||
} | |||
Thread.Sleep(10); | |||
}), $"炒锅3实时数据读取线程"); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
//炒锅4 | |||
FryFourConnected = fryFourModbus.Connected; | |||
if (FryFourConnected) | |||
{ | |||
foreach (var item in FryFourVariables) | |||
{ | |||
var res = fryFourModbus.Read(item.Address, item.Length);//读取plc数据 | |||
if (FryFourData.ContainsKey(item.Address)) | |||
{ | |||
FryFourData[item.Address] = res; | |||
} | |||
else | |||
{ | |||
FryFourData.TryAdd(item.Address, res); | |||
} | |||
} | |||
//Thread.Sleep(50); | |||
} | |||
else | |||
{ | |||
DeviceManage devices = Json<DeviceManage>.Data; | |||
var res = devices.Devices.FirstOrDefault(p => p.DeviceName == "炒锅4"); | |||
if (res != null) | |||
modbus.ModbusTcpConnect(res.Ip, Convert.ToInt32(res.Port)); MessageLog.GetInstance.ShowRunLog("4号炒锅PLC重连成功"); | |||
} | |||
Thread.Sleep(10); | |||
}), $"炒锅4实时数据读取线程"); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
//炒锅5 | |||
FryFiveConnected = fryFiveModbus.Connected; | |||
if (FryFiveConnected) | |||
{ | |||
foreach (var item in FryFiveVariables) | |||
{ | |||
var res = fryFiveModbus.Read(item.Address, item.Length);//读取plc数据 | |||
if (FryFiveData.ContainsKey(item.Address)) | |||
{ | |||
FryFiveData[item.Address] = res; | |||
} | |||
else | |||
{ | |||
FryFiveData.TryAdd(item.Address, res); | |||
} | |||
} | |||
// Thread.Sleep(50); | |||
} | |||
else | |||
{ | |||
DeviceManage devices = Json<DeviceManage>.Data; | |||
var res = devices.Devices.FirstOrDefault(p => p.DeviceName == "炒锅5"); | |||
if (res != null) | |||
modbus.ModbusTcpConnect(res.Ip, Convert.ToInt32(res.Port)); MessageLog.GetInstance.ShowRunLog("5号炒锅PLC重连成功"); | |||
} | |||
Thread.Sleep(10); | |||
}), $"炒锅5实时数据读取线程"); | |||
} | |||
} | |||
public void WritePlcData(string address, ushort value) | |||
@@ -219,7 +219,7 @@ namespace FryPot_DosingSystem.Control | |||
ActionManage.GetInstance.Register(new Action(() => | |||
{ | |||
string id = Guid.NewGuid().ToString(); | |||
string errorCode = AGVHelper._Instance.AgvToLineOneLoadRoller(id); | |||
string errorCode = AGVHelper.GetInstance.AgvToLineOneLoadRoller(id); | |||
if (errorCode == "SUCCESS") | |||
{ | |||
MessageLog.GetInstance.ShowRunLog($"AGV任务下发成功"); | |||
@@ -436,77 +436,85 @@ namespace FryPot_DosingSystem.Control | |||
/// <exception cref="NotImplementedException"></exception> | |||
private void FileRegClean() | |||
{ | |||
int days = 5; //清除期限 | |||
string[] filesOne = Directory.GetDirectories("AccessFile//DB//炒锅1状态数据"); | |||
if (filesOne.Count() > 0) | |||
try | |||
{ | |||
foreach (var item in filesOne) | |||
int days = 5; //清除期限 | |||
string[] filesOne = Directory.GetDirectories("AccessFile//DB//炒锅1状态数据"); | |||
if (filesOne.Count() > 0) | |||
{ | |||
FileInfo info = new FileInfo(item); | |||
DateTime createTime = info.CreationTime; | |||
DateTime timeNow = DateTime.Now; | |||
if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days) | |||
foreach (var item in filesOne) | |||
{ | |||
Directory.Delete(item, true); | |||
FileInfo info = new FileInfo(item); | |||
DateTime createTime = info.CreationTime; | |||
DateTime timeNow = DateTime.Now; | |||
if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days) | |||
{ | |||
Directory.Delete(item, true); | |||
} | |||
} | |||
} | |||
} | |||
string[] filesTwo = Directory.GetDirectories("AccessFile//DB//炒锅2状态数据"); | |||
if (filesTwo.Count() > 0) | |||
{ | |||
foreach (var item in filesTwo) | |||
string[] filesTwo = Directory.GetDirectories("AccessFile//DB//炒锅2状态数据"); | |||
if (filesTwo.Count() > 0) | |||
{ | |||
FileInfo info = new FileInfo(item); | |||
DateTime createTime = info.CreationTime; | |||
DateTime timeNow = DateTime.Now; | |||
if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days) | |||
foreach (var item in filesTwo) | |||
{ | |||
Directory.Delete(item, true); | |||
FileInfo info = new FileInfo(item); | |||
DateTime createTime = info.CreationTime; | |||
DateTime timeNow = DateTime.Now; | |||
if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days) | |||
{ | |||
Directory.Delete(item, true); | |||
} | |||
} | |||
} | |||
} | |||
string[] filesThree = Directory.GetDirectories("AccessFile//DB//炒锅3状态数据"); | |||
if (filesThree.Count() > 0) | |||
{ | |||
foreach (var item in filesThree) | |||
string[] filesThree = Directory.GetDirectories("AccessFile//DB//炒锅3状态数据"); | |||
if (filesThree.Count() > 0) | |||
{ | |||
FileInfo info = new FileInfo(item); | |||
DateTime createTime = info.CreationTime; | |||
DateTime timeNow = DateTime.Now; | |||
if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days) | |||
foreach (var item in filesThree) | |||
{ | |||
Directory.Delete(item, true); | |||
FileInfo info = new FileInfo(item); | |||
DateTime createTime = info.CreationTime; | |||
DateTime timeNow = DateTime.Now; | |||
if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days) | |||
{ | |||
Directory.Delete(item, true); | |||
} | |||
} | |||
} | |||
} | |||
string[] filesFour = Directory.GetDirectories("AccessFile//DB//炒锅4状态数据"); | |||
if (filesFour.Count() > 0) | |||
{ | |||
foreach (var item in filesFour) | |||
string[] filesFour = Directory.GetDirectories("AccessFile//DB//炒锅4状态数据"); | |||
if (filesFour.Count() > 0) | |||
{ | |||
FileInfo info = new FileInfo(item); | |||
DateTime createTime = info.CreationTime; | |||
DateTime timeNow = DateTime.Now; | |||
if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days) | |||
foreach (var item in filesFour) | |||
{ | |||
Directory.Delete(item, true); | |||
FileInfo info = new FileInfo(item); | |||
DateTime createTime = info.CreationTime; | |||
DateTime timeNow = DateTime.Now; | |||
if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days) | |||
{ | |||
Directory.Delete(item, true); | |||
} | |||
} | |||
} | |||
} | |||
string[] filesFive = Directory.GetDirectories("AccessFile//DB//炒锅5状态数据"); | |||
if (filesFive.Count() > 0) | |||
{ | |||
foreach (var item in filesFive) | |||
string[] filesFive = Directory.GetDirectories("AccessFile//DB//炒锅5状态数据"); | |||
if (filesFive.Count() > 0) | |||
{ | |||
FileInfo info = new FileInfo(item); | |||
DateTime createTime = info.CreationTime; | |||
DateTime timeNow = DateTime.Now; | |||
if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days) | |||
foreach (var item in filesFive) | |||
{ | |||
Directory.Delete(item, true); | |||
FileInfo info = new FileInfo(item); | |||
DateTime createTime = info.CreationTime; | |||
DateTime timeNow = DateTime.Now; | |||
if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days) | |||
{ | |||
Directory.Delete(item, true); | |||
} | |||
} | |||
} | |||
} | |||
catch (Exception) | |||
{ | |||
// throw; | |||
} | |||
} | |||
/// <summary> | |||
/// 时间差计算 | |||
@@ -1565,7 +1573,9 @@ namespace FryPot_DosingSystem.Control | |||
}), "MainViewReadPlcData"); | |||
} | |||
/// <summary> | |||
/// 炒锅状态实时显示 | |||
/// </summary> | |||
private void FryPotStatusDisplay() | |||
{ | |||
FryPotInfoManage.GetInstance.variableInfos.FirstOrDefault(p => p.VarName == "FryPotOneTemp").CurrentValue = FryPotMonitorManage.GetInstance.fryOne.Temperature.ToString(); | |||
@@ -1623,10 +1633,10 @@ namespace FryPot_DosingSystem.Control | |||
{ | |||
#region 炒锅1状态数据保存 | |||
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅1状态数据")) | |||
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅1状态数据")) | |||
{ | |||
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅1状态数据"); | |||
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString())) | |||
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString())) | |||
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString()); | |||
if (globalVar.LOneFryPotSerial == 1 && fryOneRecipe != string.Empty) | |||
@@ -1643,7 +1653,7 @@ namespace FryPot_DosingSystem.Control | |||
} | |||
else | |||
{ | |||
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString())) | |||
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString())) | |||
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅1状态数据\\" + DateTime.Now.ToShortDateString()); | |||
if (globalVar.LOneFryPotSerial == 1 && fryOneRecipe != string.Empty) | |||
{ | |||
@@ -1659,10 +1669,10 @@ namespace FryPot_DosingSystem.Control | |||
} | |||
#endregion | |||
#region 炒锅2状态数据保存 | |||
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅2状态数据")) | |||
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅2状态数据")) | |||
{ | |||
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅2状态数据"); | |||
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString())) | |||
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString())) | |||
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString()); | |||
if (globalVar.LTwoFryPotSerial == 2 && fryTwoRecipe != string.Empty) | |||
@@ -1679,7 +1689,7 @@ namespace FryPot_DosingSystem.Control | |||
} | |||
else | |||
{ | |||
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString())) | |||
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString())) | |||
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅2状态数据\\" + DateTime.Now.ToShortDateString()); | |||
if (globalVar.LTwoFryPotSerial == 2 && fryTwoRecipe != string.Empty) | |||
{ | |||
@@ -1695,10 +1705,10 @@ namespace FryPot_DosingSystem.Control | |||
} | |||
#endregion | |||
#region 炒锅3状态数据保存 | |||
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅3状态数据")) | |||
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅3状态数据")) | |||
{ | |||
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅3状态数据"); | |||
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString())) | |||
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString())) | |||
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString()); | |||
if (globalVar.LThreeFryPotSerial == 3 && fryThreeRecipe != string.Empty) | |||
@@ -1715,7 +1725,7 @@ namespace FryPot_DosingSystem.Control | |||
} | |||
else | |||
{ | |||
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString())) | |||
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString())) | |||
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅3状态数据\\" + DateTime.Now.ToShortDateString()); | |||
if (globalVar.LThreeFryPotSerial == 3 && fryThreeRecipe != string.Empty) | |||
{ | |||
@@ -1731,10 +1741,10 @@ namespace FryPot_DosingSystem.Control | |||
} | |||
#endregion | |||
#region 炒锅4状态数据保存 | |||
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅4状态数据")) | |||
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅4状态数据")) | |||
{ | |||
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅4状态数据"); | |||
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString())) | |||
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString())) | |||
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString()); | |||
if (globalVar.LOneFryPotSerial == 4 && fryFourRecipe != string.Empty) | |||
@@ -1742,7 +1752,7 @@ namespace FryPot_DosingSystem.Control | |||
using (FileStream writeStream = new FileStream("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString() + "\\" + DateTime.Now.ToString("HH:mm").Replace(':', '.') + fryFourRecipe + ".bin", FileMode.OpenOrCreate, FileAccess.Write)) | |||
{ | |||
writeStream.Position = writeStream.Length; | |||
PotFourStatus p1 = new PotFourStatus { Temperature = FryPotMonitorManage.GetInstance.fryFour.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFour.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFour.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFour.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFour.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFour.TotalProduct, RecipeName = fryFourRecipe,Time= DateTime.Now.ToString("yyyy-MM-dd-HH-mm") }; | |||
PotFourStatus p1 = new PotFourStatus { Temperature = FryPotMonitorManage.GetInstance.fryFour.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFour.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFour.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFour.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFour.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFour.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFour.TotalProduct, RecipeName = fryFourRecipe, Time = DateTime.Now.ToString("yyyy-MM-dd-HH-mm") }; | |||
BinaryFormatter bf = new BinaryFormatter(); | |||
bf.Serialize(writeStream, p1); | |||
@@ -1751,7 +1761,7 @@ namespace FryPot_DosingSystem.Control | |||
} | |||
else | |||
{ | |||
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString())) | |||
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString())) | |||
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅4状态数据\\" + DateTime.Now.ToShortDateString()); | |||
if (globalVar.LOneFryPotSerial == 4 && fryFourRecipe != string.Empty) | |||
{ | |||
@@ -1767,10 +1777,10 @@ namespace FryPot_DosingSystem.Control | |||
} | |||
#endregion | |||
#region 炒锅5状态数据保存 | |||
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅5状态数据")) | |||
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅5状态数据")) | |||
{ | |||
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅5状态数据"); | |||
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString())) | |||
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString())) | |||
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString()); | |||
if (globalVar.LTwoFryPotSerial == 5 && fryFiveRecipe != string.Empty) | |||
@@ -1787,7 +1797,7 @@ namespace FryPot_DosingSystem.Control | |||
} | |||
else | |||
{ | |||
if (!Directory.Exists("AccessFile\\" + "DB" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString())) | |||
if (!Directory.Exists("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString())) | |||
Directory.CreateDirectory("AccessFile\\" + "DB\\" + "炒锅5状态数据\\" + DateTime.Now.ToShortDateString()); | |||
if (globalVar.LTwoFryPotSerial == 5 && fryFiveRecipe != string.Empty) | |||
{ | |||
@@ -2123,7 +2133,7 @@ namespace FryPot_DosingSystem.Control | |||
{ | |||
while (AlarmHelper<AlarmInfo>.Alarm.CleanOutputRollerRunning == 1) | |||
{ | |||
Thread.Sleep(5); | |||
Thread.Sleep(1000); | |||
if (globalVar.ExitLineOneTask) | |||
return; | |||
} | |||
@@ -2154,10 +2164,17 @@ namespace FryPot_DosingSystem.Control | |||
string info = AGVHelper.GetInstance.AgvLeaveLOneToClean(id);//1号线到洗桶处 | |||
LSevenrobotJobId.Add(id); | |||
Thread.Sleep(500); | |||
LineToCleanCarryTaskErrorCodeAnalysis(info, 1); | |||
globalVar.rollerLineOne.IsEpmtyBefore = true; | |||
// AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处 | |||
// Thread.Sleep(500); | |||
if (LineToCleanCarryTaskErrorCodeAnalysis(info, 1)) | |||
{ | |||
globalVar.rollerLineOne.IsEpmtyBefore = true; | |||
} | |||
else | |||
{ | |||
LSevenrobotJobId.Remove(id); | |||
} | |||
// AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处 | |||
} | |||
} | |||
else | |||
@@ -2189,10 +2206,17 @@ namespace FryPot_DosingSystem.Control | |||
string info = AGVHelper.GetInstance.AgvLeaveLTwoToClean(id);//2号线到洗桶处 | |||
LEightrobotJobId.Add(id); | |||
Thread.Sleep(500); | |||
LineToCleanCarryTaskErrorCodeAnalysis(info, 2); | |||
globalVar.rollerLineTwo.IsEpmtyBefore = true; | |||
//Thread.Sleep(500); | |||
if (LineToCleanCarryTaskErrorCodeAnalysis(info, 2)) | |||
{ | |||
globalVar.rollerLineTwo.IsEpmtyBefore = true; | |||
} | |||
else | |||
{ | |||
LEightrobotJobId.Remove(id); | |||
} | |||
//AgvFromLineTwoToClean(globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0));//AGV从线体2到清洗处 | |||
} | |||
} | |||
@@ -2224,10 +2248,17 @@ namespace FryPot_DosingSystem.Control | |||
string info = AGVHelper.GetInstance.AgvLeaveLThreeToClean(id);//3号线到洗桶处 | |||
LNinerobotJobId.Add(id); | |||
Thread.Sleep(500); | |||
LineToCleanCarryTaskErrorCodeAnalysis(info, 3); | |||
globalVar.rollerLineThree.IsEpmtyBefore = true; | |||
//Thread.Sleep(500); | |||
if (LineToCleanCarryTaskErrorCodeAnalysis(info, 3))//呼叫成功 | |||
{ | |||
globalVar.rollerLineThree.IsEpmtyBefore = true; | |||
} | |||
else//呼叫失败 | |||
{ | |||
LNinerobotJobId.Remove(id); | |||
} | |||
//AgvFromLineThreeToClean(globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0));//AGV从线体3到清洗处 | |||
} | |||
} | |||
@@ -2247,18 +2278,18 @@ namespace FryPot_DosingSystem.Control | |||
{ | |||
globalVar.rollerLineOne.agvArriveCleanUnLoad = false; | |||
MessageLog.GetInstance.ShowRunLog("空桶从线体1到达清洗位置,准备卸桶"); | |||
erp: if (AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning == 0) | |||
erp: if (AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning == 0) | |||
{ | |||
//plc交互 | |||
WritePlcData("D1065", 1);//AGV空桶洗桶就位信号下发PLC | |||
} | |||
else//有故障 | |||
{ | |||
while (AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning == 1) | |||
{ | |||
Thread.Sleep(5); | |||
Thread.Sleep(1000); | |||
if (globalVar.ExitLineOneTask) | |||
return; | |||
} | |||
@@ -2290,7 +2321,7 @@ namespace FryPot_DosingSystem.Control | |||
{ | |||
while (AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning == 1) | |||
{ | |||
Thread.Sleep(5); | |||
Thread.Sleep(1000); | |||
if (globalVar.ExitLineOneTask) | |||
return; | |||
} | |||
@@ -2321,7 +2352,7 @@ namespace FryPot_DosingSystem.Control | |||
{ | |||
while (AlarmHelper<AlarmInfo>.Alarm.CleanEnterRollerRunning == 1) | |||
{ | |||
Thread.Sleep(5); | |||
Thread.Sleep(1000); | |||
if (globalVar.ExitLineOneTask) | |||
return; | |||
} | |||
@@ -2353,9 +2384,13 @@ namespace FryPot_DosingSystem.Control | |||
string info = AGVHelper.GetInstance.AgvFromCleanToLineFourUnLoadRoller(id); | |||
LTenrobotJobId.Add(id); | |||
Thread.Sleep(500); | |||
//Thread.Sleep(500); | |||
MessageLog.GetInstance.ShowRunLog("清洗台呼叫AGV取桶"); | |||
CleanToLineCarryTaskErrorCodeAnalysis(info, 4); | |||
if (!CleanToLineCarryTaskErrorCodeAnalysis(info, 4)) | |||
{ | |||
LTenrobotJobId.Remove(id); | |||
MessageLog.GetInstance.ShowRunLog("清洗台呼叫AGV取桶失败"); | |||
} | |||
} | |||
} | |||
/// <summary> | |||
@@ -2853,7 +2888,7 @@ namespace FryPot_DosingSystem.Control | |||
// Sqlite<PotFourStatus>.GetInstance.Save();//保存数据 | |||
//} | |||
//FryPotOneRollerTroubleCheck(); | |||
if ((FryPotAlarm == 1 && globalVar.LOneFryPotSerial == 1 )|| (FryPotFourAlarm == 1&& globalVar.LOneFryPotSerial == 4))//炒锅滚筒无故障 | |||
if ((FryPotAlarm == 1 && globalVar.LOneFryPotSerial == 1) || (FryPotFourAlarm == 1 && globalVar.LOneFryPotSerial == 4))//炒锅滚筒无故障 | |||
{ | |||
if (globalVar.LOneFryPotSerial == 1) | |||
{ | |||
@@ -2867,10 +2902,14 @@ namespace FryPot_DosingSystem.Control | |||
//炒锅滚筒进料运行到位处理 | |||
FryPotOneOrFourInputMaterialRollerOperate(); | |||
AgvFromFryPotOneOrFourToClean();//上游下发搬运任务给AGV | |||
AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LOneFryPotSerial, IsRun.Start); | |||
globalVar.InOrOutputLock = true; | |||
globalVar.PotOneOutputRollerArrive = true; | |||
//上游下发搬运任务给AGV | |||
if (AgvFromFryPotOneOrFourToClean()) | |||
{ | |||
AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LOneFryPotSerial, IsRun.Start); | |||
globalVar.InOrOutputLock = true; | |||
globalVar.PotOneOutputRollerArrive = true; | |||
} | |||
} | |||
} | |||
@@ -2911,8 +2950,8 @@ namespace FryPot_DosingSystem.Control | |||
// Sqlite<PotFiveStatus>.GetInstance.Base.Add(new PotFiveStatus { Temperature = FryPotMonitorManage.GetInstance.fryFive.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryFive.HotPower, Speed = FryPotMonitorManage.GetInstance.fryFive.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryFive.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryFive.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryFive.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 | |||
// Sqlite<PotFiveStatus>.GetInstance.Save();//保存数据 | |||
//} | |||
if ((FryPotTwoAlarm == 1&& globalVar.LTwoFryPotSerial == 2) ||( FryPotFiveAlarm == 1&& globalVar.LTwoFryPotSerial == 5))//炒锅滚筒无故障 | |||
if ((FryPotTwoAlarm == 1 && globalVar.LTwoFryPotSerial == 2) || (FryPotFiveAlarm == 1 && globalVar.LTwoFryPotSerial == 5))//炒锅滚筒无故障 | |||
{ | |||
if (globalVar.LTwoFryPotSerial == 2) | |||
{ | |||
@@ -2928,10 +2967,14 @@ namespace FryPot_DosingSystem.Control | |||
//炒锅滚筒进料运行到位处理 | |||
FryPotTwoOrFiveInputMaterialRollerOperate(); | |||
AgvFromFryPotTwoOrFiveToClean();//上游下发搬运任务给AGV | |||
AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LTwoFryPotSerial, IsRun.Start); | |||
globalVar.LTwoInOrOutputLock = true; | |||
globalVar.LTwoPotOutputRollerArrive = true; | |||
//上游下发搬运任务给AGV | |||
if (AgvFromFryPotTwoOrFiveToClean()) | |||
{ | |||
AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LTwoFryPotSerial, IsRun.Start); | |||
globalVar.LTwoInOrOutputLock = true; | |||
globalVar.LTwoPotOutputRollerArrive = true; | |||
} | |||
} | |||
} | |||
} | |||
@@ -2957,18 +3000,21 @@ namespace FryPot_DosingSystem.Control | |||
{ | |||
//Sqlite<PotThreeStatus>.GetInstance.Base.Add(new PotThreeStatus { Temperature = FryPotMonitorManage.GetInstance.fryThree.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryThree.HotPower, Speed = FryPotMonitorManage.GetInstance.fryThree.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryThree.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryThree.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 | |||
//Sqlite<PotThreeStatus>.GetInstance.Save();//保存数据 | |||
if (FryPotThreeAlarm == 1)//炒锅滚筒无故障 | |||
{ | |||
Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.workflows.Add(new WorkflowModel { id = globalVar.LThreeCurrentCookingStep, Name = LThreeOutputMaterialQuene.ElementAt(0).materialType.MaterialName, isBool = IsBool.Yes }); })); | |||
//炒锅滚筒进料运行到位处理 | |||
FryPotThreeInputMaterialRollerOperate(); | |||
AgvFromFryPotThreeToClean();//上游下发搬运任务给AGV | |||
AgvViewModel.GetInstance().Set启动或停止炒锅(3, IsRun.Start); | |||
globalVar.LThreeInOrOutputLock = true; | |||
globalVar.LThreePotOutputRollerArrive = true; | |||
//上游下发搬运任务给AGV | |||
if (AgvFromFryPotThreeToClean()) | |||
{ | |||
AgvViewModel.GetInstance().Set启动或停止炒锅(3, IsRun.Start); | |||
globalVar.LThreeInOrOutputLock = true; | |||
globalVar.LThreePotOutputRollerArrive = true; | |||
} | |||
} | |||
} | |||
} | |||
@@ -3030,8 +3076,8 @@ namespace FryPot_DosingSystem.Control | |||
{ | |||
// FryPotOneRollerTroubleCheck(); | |||
if (FryPotAlarm == 1 || FryPotFourAlarm == 1)//无故障 | |||
{ | |||
//if (FryPotAlarm == 1 || FryPotFourAlarm == 1)//无故障 | |||
//{ | |||
if (globalVar.agvFryPotEmptyRollerArrive) | |||
{ | |||
FryPotOneOrFourOutEmpetyRollerOperate(); | |||
@@ -3059,7 +3105,7 @@ namespace FryPot_DosingSystem.Control | |||
} | |||
} | |||
} | |||
//} | |||
} | |||
@@ -3077,6 +3123,7 @@ namespace FryPot_DosingSystem.Control | |||
AgvArriveFryPotTwoOrFiveOutEmptyRollerSingleSetDown();//暂时考虑agv送完料后原地等待,不加条件,直接发送到位信号 | |||
globalVar.agvArriveLTwoUpLoad = false; | |||
globalVar.LTwoAgvArrivePot = true; | |||
FryPotTwoRollerTroubleCheck(); | |||
} | |||
} | |||
@@ -3084,9 +3131,9 @@ namespace FryPot_DosingSystem.Control | |||
{ | |||
if ((globalVar.fryPotTwo.EmptyBarrelArrivedSingle == 1 || globalVar.fryPotFive.EmptyBarrelArrivedSingle == 1) && LTwoOutputMaterialQuene.Count > 0 && globalVar.LTwoAgvArrivePot) | |||
{ | |||
FryPotTwoRollerTroubleCheck(); | |||
if (FryPotTwoAlarm == 1 || FryPotFiveAlarm == 1)//无故障 | |||
{ | |||
//if (FryPotTwoAlarm == 1 || FryPotFiveAlarm == 1)//无故障 | |||
//{ | |||
if (globalVar.LTwoagvFryPotEmptyRollerArrive) | |||
{ | |||
FryPotTwoOrFiveOutEmpetyRollerOperate(); | |||
@@ -3115,7 +3162,7 @@ namespace FryPot_DosingSystem.Control | |||
} | |||
} | |||
} | |||
//} | |||
} | |||
} | |||
@@ -3130,6 +3177,7 @@ namespace FryPot_DosingSystem.Control | |||
AgvArriveFryPotThreeOutEmptyRollerSingleSetDown();//暂时考虑agv送完料后原地等待,不加条件,直接发送到位信号 | |||
globalVar.agvArriveLThreeUpLoad = false; | |||
globalVar.LThreeAgvArrivePot = true; | |||
FryPotThreeRollerTroubleCheck(); | |||
} | |||
} | |||
@@ -3137,9 +3185,8 @@ namespace FryPot_DosingSystem.Control | |||
{ | |||
if (globalVar.fryPotThree.EmptyBarrelArrivedSingle == 1 && LThreeOutputMaterialQuene.Count > 0 && globalVar.LThreeAgvArrivePot) | |||
{ | |||
FryPotThreeRollerTroubleCheck(); | |||
if (FryPotThreeAlarm == 1)//无故障 | |||
{ | |||
//if (FryPotThreeAlarm == 1)//无故障 | |||
//{ | |||
if (globalVar.LThreeagvFryPotEmptyRollerArrive) | |||
{ | |||
FryPotThreeOutEmpetyRollerOperate(); | |||
@@ -3161,7 +3208,7 @@ namespace FryPot_DosingSystem.Control | |||
} | |||
} | |||
} | |||
// } | |||
} | |||
} | |||
@@ -3552,8 +3599,9 @@ namespace FryPot_DosingSystem.Control | |||
/// <summary> | |||
/// AGV离开炒锅1,4运送空桶任务 | |||
/// </summary> | |||
public void AgvFromFryPotOneOrFourToClean() | |||
public bool AgvFromFryPotOneOrFourToClean() | |||
{ | |||
bool result = true; | |||
switch (OutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100) | |||
{ | |||
case 1: | |||
@@ -3565,7 +3613,13 @@ namespace FryPot_DosingSystem.Control | |||
MessageLog.GetInstance.ShowRunLog("AGV执行【1】号炒锅空桶回收任务"); | |||
string info = AGVHelper.GetInstance.AgvLeaveFryPotOne(id); | |||
LFourrobotJobId = id; | |||
FryCarryTaskErrorCodeAnalysis(info, 1); break; | |||
if (!FryCarryTaskErrorCodeAnalysis(info, 1)) | |||
{ | |||
id = String.Empty; | |||
result = false; | |||
} | |||
break; | |||
case 4: | |||
erp3: string id3 = Guid.NewGuid().ToString("N");//上游唯一ID | |||
if (id3 == LOnerobotJobId || id3 == LTworobotJobId || id3 == LThreerobotJobId || id3 == LFourrobotJobId || id3 == LFiverobotJobId || id3 == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id3) != null || LEightrobotJobId.FirstOrDefault(p => p == id3) != null || LNinerobotJobId.FirstOrDefault(p => p == id3) != null || LTenrobotJobId.FirstOrDefault(p => p == id3) != null) | |||
@@ -3575,14 +3629,22 @@ namespace FryPot_DosingSystem.Control | |||
MessageLog.GetInstance.ShowRunLog("AGV执行【4】号炒锅空桶回收任务"); | |||
string info3 = AGVHelper.GetInstance.AgvLeaveFryPotFour(id3); | |||
LFourrobotJobId = id3; | |||
FryCarryTaskErrorCodeAnalysis(info3, 4); break; | |||
if (!FryCarryTaskErrorCodeAnalysis(info3, 4)) | |||
{ | |||
id3 = String.Empty; | |||
result = false; | |||
} | |||
break; | |||
} | |||
return result; | |||
} | |||
/// <summary> | |||
/// AGV离开炒锅2,5运送空桶任务 | |||
/// </summary> | |||
public void AgvFromFryPotTwoOrFiveToClean() | |||
public bool AgvFromFryPotTwoOrFiveToClean() | |||
{ | |||
bool result = true; | |||
switch (LTwoOutputMaterialQuene.ElementAt(0).materialType.MaterialLoc / 100) | |||
{ | |||
case 2: | |||
@@ -3594,7 +3656,13 @@ namespace FryPot_DosingSystem.Control | |||
MessageLog.GetInstance.ShowRunLog("AGV执行【2】号炒锅空桶回收任务"); | |||
string info1 = AGVHelper.GetInstance.AgvLeaveFryPotTwo(id1); | |||
LFiverobotJobId = id1; | |||
FryCarryTaskErrorCodeAnalysis(info1, 2); break; | |||
if (!FryCarryTaskErrorCodeAnalysis(info1, 2)) | |||
{ | |||
id1 = String.Empty; | |||
result = false; | |||
} | |||
break; | |||
case 5: | |||
erp4: string id4 = Guid.NewGuid().ToString("N");//上游唯一ID | |||
if (id4 == LOnerobotJobId || id4 == LTworobotJobId || id4 == LThreerobotJobId || id4 == LFourrobotJobId || id4 == LFiverobotJobId || id4 == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id4) != null || LEightrobotJobId.FirstOrDefault(p => p == id4) != null || LNinerobotJobId.FirstOrDefault(p => p == id4) != null || LTenrobotJobId.FirstOrDefault(p => p == id4) != null) | |||
@@ -3604,14 +3672,22 @@ namespace FryPot_DosingSystem.Control | |||
MessageLog.GetInstance.ShowRunLog("AGV执行【5】号炒锅空桶回收任务"); | |||
string info4 = AGVHelper.GetInstance.AgvLeaveFryPotFive(id4); | |||
LFiverobotJobId = id4; | |||
FryCarryTaskErrorCodeAnalysis(info4, 5); break; | |||
if (!FryCarryTaskErrorCodeAnalysis(info4, 5)) | |||
{ | |||
id4 = String.Empty; | |||
result = false; | |||
} | |||
break; | |||
} | |||
return result; | |||
} | |||
/// <summary> | |||
/// AGV离开炒锅3运送空桶任务 | |||
/// </summary> | |||
public void AgvFromFryPotThreeToClean() | |||
public bool AgvFromFryPotThreeToClean() | |||
{ | |||
bool result = true; | |||
erp2: string id2 = Guid.NewGuid().ToString("N");//上游唯一ID | |||
if (id2 == LOnerobotJobId || id2 == LTworobotJobId || id2 == LThreerobotJobId || id2 == LFourrobotJobId || id2 == LFiverobotJobId || id2 == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id2) != null || LEightrobotJobId.FirstOrDefault(p => p == id2) != null || LNinerobotJobId.FirstOrDefault(p => p == id2) != null || LTenrobotJobId.FirstOrDefault(p => p == id2) != null) | |||
{ | |||
@@ -3620,7 +3696,13 @@ namespace FryPot_DosingSystem.Control | |||
MessageLog.GetInstance.ShowRunLog("AGV执行【3】号炒锅空桶回收任务"); | |||
string info2 = AGVHelper.GetInstance.AgvLeaveFryPotThree(id2); | |||
LSixrobotJobId = id2; | |||
FryCarryTaskErrorCodeAnalysis(info2, 3); | |||
if (!FryCarryTaskErrorCodeAnalysis(info2, 3)) | |||
{ | |||
id2 = string.Empty; | |||
result = false; | |||
} | |||
return result; | |||
} | |||
/// <summary> | |||
/// 处理agv从线体1到送料到炒锅的条件 | |||
@@ -3652,7 +3734,7 @@ namespace FryPot_DosingSystem.Control | |||
{ | |||
while (AlarmHelper<AlarmInfo>.Alarm.LOneRollerTrouble == 1) | |||
{ | |||
Thread.Sleep(5); | |||
Thread.Sleep(1000); | |||
if (globalVar.ExitLineOneTask) | |||
return; | |||
} | |||
@@ -3690,7 +3772,7 @@ namespace FryPot_DosingSystem.Control | |||
{ | |||
while (AlarmHelper<AlarmInfo>.Alarm.LOneRollerTrouble == 1) | |||
{ | |||
Thread.Sleep(5); | |||
Thread.Sleep(1000); | |||
if (globalVar.ExitLineOneTask) | |||
return; | |||
} | |||
@@ -3731,7 +3813,7 @@ namespace FryPot_DosingSystem.Control | |||
{ | |||
while (AlarmHelper<AlarmInfo>.Alarm.LTwoRollerTrouble == 1) | |||
{ | |||
Thread.Sleep(5); | |||
Thread.Sleep(1000); | |||
if (globalVar.ExitLineTwoTask) | |||
return; | |||
} | |||
@@ -3770,7 +3852,7 @@ namespace FryPot_DosingSystem.Control | |||
{ | |||
while (AlarmHelper<AlarmInfo>.Alarm.LTwoRollerTrouble == 1) | |||
{ | |||
Thread.Sleep(5); | |||
Thread.Sleep(1000); | |||
if (globalVar.ExitLineOneTask) | |||
return; | |||
} | |||
@@ -3811,7 +3893,7 @@ namespace FryPot_DosingSystem.Control | |||
{ | |||
while (AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble == 1) | |||
{ | |||
Thread.Sleep(5); | |||
Thread.Sleep(1000); | |||
if (globalVar.ExitLineThreeTask) | |||
return; | |||
} | |||
@@ -3851,7 +3933,7 @@ namespace FryPot_DosingSystem.Control | |||
{ | |||
while (AlarmHelper<AlarmInfo>.Alarm.LThreeRollerTrouble == 1) | |||
{ | |||
Thread.Sleep(5); | |||
Thread.Sleep(1000); | |||
if (globalVar.ExitLineOneTask) | |||
return; | |||
} | |||
@@ -3866,20 +3948,22 @@ namespace FryPot_DosingSystem.Control | |||
/// </summary> | |||
/// <param name="errorCode"></param> | |||
/// <param name="num"></param> | |||
public void LineCarryTaskErrorCodeAnalysis(string errorCode, int num) | |||
public bool LineCarryTaskErrorCodeAnalysis(string errorCode, int num) | |||
{ | |||
if (errorCode == "SUCCESS") | |||
{ | |||
MessageLog.GetInstance.ShowRunLog($"AGV去{num}号滚筒线装桶"); | |||
globalVar.AllowAgvToLineLoadRoller = false; | |||
return true; | |||
} | |||
else if (errorCode == "Analysis Error") | |||
{ | |||
MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线API调用失败,请检查请求报文"); | |||
return false; | |||
} | |||
else | |||
{ | |||
MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线失败,错误码:{errorCode}"); | |||
return false; | |||
} | |||
} | |||
/// <summary> | |||
@@ -3887,20 +3971,22 @@ namespace FryPot_DosingSystem.Control | |||
/// </summary> | |||
/// <param name="errorCode"></param> | |||
/// <param name="num"></param> | |||
public void LineToCleanCarryTaskErrorCodeAnalysis(string errorCode, int num) | |||
public bool LineToCleanCarryTaskErrorCodeAnalysis(string errorCode, int num) | |||
{ | |||
if (errorCode == "SUCCESS") | |||
{ | |||
MessageLog.GetInstance.ShowRunLog($"AGV去{num}号滚筒线装桶"); | |||
MessageLog.GetInstance.ShowRunLog($"AGV去{num}号滚筒线装空桶"); | |||
return true; | |||
} | |||
else if (errorCode == "Analysis Error") | |||
{ | |||
MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线API调用失败,请检查请求报文"); | |||
return false; | |||
} | |||
else | |||
{ | |||
MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线失败,错误码:{errorCode}"); | |||
return false; | |||
} | |||
} | |||
/// <summary> | |||
@@ -3908,20 +3994,22 @@ namespace FryPot_DosingSystem.Control | |||
/// </summary> | |||
/// <param name="errorCode"></param> | |||
/// <param name="num"></param> | |||
public void CleanToLineCarryTaskErrorCodeAnalysis(string errorCode, int num) | |||
public bool CleanToLineCarryTaskErrorCodeAnalysis(string errorCode, int num) | |||
{ | |||
if (errorCode == "SUCCESS") | |||
{ | |||
MessageLog.GetInstance.ShowRunLog($"AGV去{num}号滚筒线卸桶"); | |||
MessageLog.GetInstance.ShowRunLog($"AGV从清洗台到{num}号滚筒线卸桶"); | |||
return true; | |||
} | |||
else if (errorCode == "Analysis Error") | |||
{ | |||
MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线API调用失败,请检查请求报文"); | |||
return false; | |||
} | |||
else | |||
{ | |||
MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线失败,错误码:{errorCode}"); | |||
return false; | |||
} | |||
} | |||
/// <summary> | |||
@@ -3929,19 +4017,22 @@ namespace FryPot_DosingSystem.Control | |||
/// </summary> | |||
/// <param name="errorCode"></param> | |||
/// <param name="num"></param> | |||
public void FryCarryTaskErrorCodeAnalysis(string errorCode, int num) | |||
public bool FryCarryTaskErrorCodeAnalysis(string errorCode, int num) | |||
{ | |||
if (errorCode == "SUCCESS") | |||
{ | |||
MessageLog.GetInstance.ShowRunLog($"AGV离开{num}号炒锅"); | |||
return true; | |||
} | |||
else if (errorCode == "Analysis Error") | |||
{ | |||
MessageLog.GetInstance.ShowRunLog($"提示:AGV离开{num}号炒锅接口调用失败,请检查"); | |||
return false; | |||
} | |||
else | |||
{ | |||
MessageLog.GetInstance.ShowRunLog($"提示:AGV离开{num}号炒锅失败,错误码:{errorCode}"); | |||
return false; | |||
} | |||
} | |||
@@ -3954,15 +4045,18 @@ namespace FryPot_DosingSystem.Control | |||
if (globalVar.rollerLineOne.StationEight == InputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.rollerLineOne.IsEpmtyBefore)//工位8上面是配方料桶 | |||
{ | |||
globalVar.rollerLineOne.CanRun = false; | |||
e: string id = Guid.NewGuid().ToString("N"); | |||
e: string id = Guid.NewGuid().ToString("N");//32位 | |||
if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || LSevenrobotJobId.FirstOrDefault(p => p == id) != null || LEightrobotJobId.FirstOrDefault(p => p == id) != null || LNinerobotJobId.FirstOrDefault(p => p == id) != null || LTenrobotJobId.FirstOrDefault(p => p == id) != null) | |||
goto e; | |||
string info = AGVHelper.GetInstance.AgvToLineOneLoadRoller(id); | |||
LOnerobotJobId = id; | |||
Thread.Sleep(500); | |||
LineCarryTaskErrorCodeAnalysis(info, 1); | |||
globalVar.LoadRoller = true; | |||
if (LineCarryTaskErrorCodeAnalysis(info, 1)) | |||
{ | |||
globalVar.AllowAgvToLineLoadRoller = false; | |||
globalVar.LoadRoller = true; | |||
} | |||
} | |||
//else if (globalVar.rollerLineOne.StationEight != InputMaterialQuene.ElementAt(0).materialType.MaterialLoc) | |||
//{ | |||
@@ -4018,9 +4112,13 @@ namespace FryPot_DosingSystem.Control | |||
string info = AGVHelper.GetInstance.AgvToLineTwoLoadRoller(id); | |||
LTworobotJobId = id; | |||
Thread.Sleep(500); | |||
LineCarryTaskErrorCodeAnalysis(info, 2); | |||
globalVar.LTwoLoadRoller = true; | |||
//Thread.Sleep(500); | |||
if (LineCarryTaskErrorCodeAnalysis(info, 2)) | |||
{ | |||
globalVar.LTwoLoadRoller = true; | |||
globalVar.AllowAgvToLineTwoLoadRoller = false; | |||
} | |||
} | |||
//else if (globalVar.rollerLineTwo.StationEight != LTwoInputMaterialQuene.ElementAt(0).materialType.MaterialLoc) | |||
//{ | |||
@@ -4069,9 +4167,13 @@ namespace FryPot_DosingSystem.Control | |||
string info = AGVHelper.GetInstance.AgvToLineThreeLoadRoller(id); | |||
LThreerobotJobId = id; | |||
Thread.Sleep(500); | |||
LineCarryTaskErrorCodeAnalysis(info, 3); | |||
globalVar.LThreeLoadRoller = true; | |||
//Thread.Sleep(500); | |||
if (LineCarryTaskErrorCodeAnalysis(info, 3)) | |||
{ | |||
globalVar.LThreeLoadRoller = true; | |||
globalVar.AllowAgvToLineThreeLoadRoller = false; | |||
} | |||
} | |||
//else if (globalVar.rollerLineThree.StationEight != LThreeInputMaterialQuene.ElementAt(0).materialType.MaterialLoc) | |||
//{ | |||
@@ -4361,7 +4463,7 @@ namespace FryPot_DosingSystem.Control | |||
} | |||
while (AlarmHelper<AlarmInfo>.Alarm.FryPotOneRollerTrouble == 1) | |||
{ | |||
Thread.Sleep(5); if (globalVar.ExitLineOneTask) | |||
Thread.Sleep(1000); if (globalVar.ExitLineOneTask) | |||
return; | |||
} | |||
MessageLog.GetInstance.ShowRunLog("炒锅【1】输送滚筒故障解除,继续运行"); | |||
@@ -4369,7 +4471,7 @@ namespace FryPot_DosingSystem.Control | |||
case 4: | |||
if (AlarmHelper<AlarmInfo>.Alarm.FryPotFourRollerTrouble == 1) { FryPotFourAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【4】输送滚筒发生故障"); } else { FryPotFourAlarm = 1; return; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotFourRollerTrouble == 1) | |||
{ | |||
Thread.Sleep(5); if (globalVar.ExitLineOneTask) | |||
Thread.Sleep(1000); if (globalVar.ExitLineOneTask) | |||
return; | |||
} | |||
MessageLog.GetInstance.ShowRunLog("炒锅【4】输送滚筒故障解除,继续运行"); | |||
@@ -4389,7 +4491,7 @@ namespace FryPot_DosingSystem.Control | |||
case 2: | |||
if (AlarmHelper<AlarmInfo>.Alarm.FryPotTwoRollerTrouble == 1) { FryPotTwoAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【1】输送滚筒发生故障"); } else { FryPotTwoAlarm = 1; return; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotTwoRollerTrouble == 1) | |||
{ | |||
Thread.Sleep(5); if (globalVar.ExitLineTwoTask) | |||
Thread.Sleep(1000); if (globalVar.ExitLineTwoTask) | |||
return; | |||
} | |||
MessageLog.GetInstance.ShowRunLog("炒锅【1】输送滚筒故障解除,继续运行"); | |||
@@ -4397,7 +4499,7 @@ namespace FryPot_DosingSystem.Control | |||
case 5: | |||
if (AlarmHelper<AlarmInfo>.Alarm.FryPotFiveRollerTrouble == 1) { FryPotFiveAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【4】输送滚筒发生故障"); } else { FryPotFiveAlarm = 1; return; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotFiveRollerTrouble == 1) | |||
{ | |||
Thread.Sleep(5); if (globalVar.ExitLineTwoTask) | |||
Thread.Sleep(1000); if (globalVar.ExitLineTwoTask) | |||
return; | |||
} | |||
MessageLog.GetInstance.ShowRunLog("炒锅【4】输送滚筒故障解除,继续运行"); | |||
@@ -4412,7 +4514,7 @@ namespace FryPot_DosingSystem.Control | |||
FryPotThreeAlarm = 0; | |||
if (AlarmHelper<AlarmInfo>.Alarm.FryPotThreeRollerTrouble == 1) { FryPotThreeAlarm = -1; MessageLog.GetInstance.ShowRunLog("警告:炒锅【3】输送滚筒发生故障"); } else { FryPotThreeAlarm = 1; return; } while (AlarmHelper<AlarmInfo>.Alarm.FryPotThreeRollerTrouble == 1) | |||
{ | |||
Thread.Sleep(5); if (globalVar.ExitLineThreeTask) | |||
Thread.Sleep(1000); if (globalVar.ExitLineThreeTask) | |||
return; | |||
} | |||
MessageLog.GetInstance.ShowRunLog("炒锅【3】输送滚筒故障解除,继续运行"); | |||
@@ -262,7 +262,7 @@ | |||
<ColumnDefinition Width="225"></ColumnDefinition> | |||
<ColumnDefinition></ColumnDefinition> | |||
</Grid.ColumnDefinitions> | |||
<ComboBox ItemsSource="{Binding DataContext.materialNames,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}" Text="{Binding MaterialName}" Margin="10,0,0,10" Width="190" FontSize="14" KeyUp="ComboBox_KeyUp" LostFocus="ComboBox_LostFocus" Style="{StaticResource ComboBoxStyle1}"> | |||
<ComboBox ItemsSource="{Binding DataContext.materialNames,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ItemsControl}}" Text="{Binding MaterialName}" Margin="10,0,0,10" Width="190" FontSize="14" KeyUp="ComboBox_KeyUp" LostFocus="ComboBox_LostFocus" Style="{StaticResource ComboBoxStyle1}" Height="30"> | |||
<ComboBox.ItemContainerStyle> | |||
<Style TargetType="{x:Type ComboBoxItem}"> | |||
<Setter Property="Background" Value="White" /> | |||
@@ -273,18 +273,19 @@ | |||
</ComboBox.ItemContainerStyle> | |||
</ComboBox> | |||
<StackPanel Grid.Column="1" Orientation="Horizontal" > | |||
<TextBox Text="{Binding MaterialLoc}" Background="Transparent" FontSize="14" | |||
<TextBox Text="{Binding MaterialLoc}" Background="Transparent" FontSize="14" Height="30" | |||
BorderBrush="#e69519" Foreground="LightGray" Width="170" Margin="35,0,0,10" ></TextBox> | |||
</StackPanel> | |||
<StackPanel Orientation="Horizontal" Grid.Column="2"> | |||
<TextBox Text="{Binding MaterialWeight}" Background="Transparent" FontSize="14" | |||
<TextBox Text="{Binding MaterialWeight}" Background="Transparent" FontSize="14" Height="30" | |||
BorderBrush="#e69519" Foreground="LightGray" Width="170" Margin="35,0,0,10" ></TextBox> | |||
<TextBlock VerticalAlignment="Center" Margin="4,0,0,10" Text="g" Foreground="#e69519" ></TextBlock> | |||
<TextBlock VerticalAlignment="Center" FontSize="14" Margin="4,0,0,10" Text="g" Foreground="#e69519" ></TextBlock> | |||
</StackPanel> | |||
<Button Grid.Column="3" | |||
Content="删除" | |||
Width="94" | |||
Height="30" | |||
FontSize="14" | |||
Margin="0,0,20,10" | |||
Background="Transparent" | |||
@@ -88,7 +88,7 @@ namespace FryPot_DosingSystem.ViewModel | |||
public MainViewModel() | |||
{ | |||
LogViewModel model = LogViewModel.GetInstance; | |||
DeviceOperate deviceOperate = DeviceOperate.GetInstance;//开启实时PLC数据读取 | |||
// DeviceOperate deviceOperate = DeviceOperate.GetInstance;//开启实时PLC数据读取 | |||
DosingLogicControl logigControl = DosingLogicControl.GetInstance;//开启逻辑控制任务程序 | |||
TogglePag = new RelayCommand<object>(DoNavChanged); | |||
Login = new RelayCommand(() => | |||
@@ -98,8 +98,22 @@ namespace FryPot_DosingSystem.ViewModel | |||
if (name == null) | |||
{ | |||
if (materials.Count<=8&& materials.Count> 0) | |||
{ | |||
int lineNum= materials.ElementAt(0).MaterialLoc / 100; | |||
//桶号正确性验证 | |||
for (int i = 0; i < materials.Count; i++) | |||
{ | |||
if (materials.ElementAt(i).MaterialLoc / 100 != lineNum|| materials.ElementAt(i).MaterialLoc % 100!=i+1||lineNum<=0||lineNum>5) | |||
{ | |||
MessageLog.GetInstance.ShowUserLog($"新建配方【{RecipeName}】无效:【配方中原料桶号异常】"); | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"新建配方【{RecipeName}】无效"); | |||
ActionManage.GetInstance.Send("CloseNewRecipeView"); | |||
return; | |||
} | |||
} | |||
prop: string recipeID = Guid.NewGuid().ToString();//配方唯一ID,后期根据实际要求更改 | |||
var res = Json<RecipeManage>.Data.Recipes.FirstOrDefault(p => p.RecipeId == recipeID); | |||
if (res == null) | |||
@@ -130,6 +144,18 @@ namespace FryPot_DosingSystem.ViewModel | |||
{ | |||
if (materials.Count > 0 && materials.Count <= 8) | |||
{ | |||
int lineNum = materials.ElementAt(0).MaterialLoc / 100; | |||
//桶号正确性验证 | |||
for (int i = 0; i < materials.Count; i++) | |||
{ | |||
if (materials.ElementAt(i).MaterialLoc / 100 != lineNum && materials.ElementAt(i).MaterialLoc % 100 != i + 1 || lineNum <= 0 || lineNum > 5) | |||
{ | |||
MessageLog.GetInstance.ShowUserLog($"另存配方【{RecipeName}】无效:【配方中原料桶号异常】"); | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"另存配方【{RecipeName}】无效"); | |||
ActionManage.GetInstance.Send("CloseNewRecipeView"); | |||
return; | |||
} | |||
} | |||
bom.materialCollection = materials; | |||
bom.RecipeName = RecipeName; | |||
bom.UpdateTime = DateTime.Now.ToShortDateString(); | |||
@@ -154,6 +180,19 @@ namespace FryPot_DosingSystem.ViewModel | |||
{ | |||
if (materials.Count>0&& materials.Count<=8)//验证配方中原料桶数 | |||
{ | |||
int lineNum = materials.ElementAt(0).MaterialLoc / 100; | |||
//桶号正确性验证 | |||
for (int i = 0; i < materials.Count; i++) | |||
{ | |||
if (materials.ElementAt(i).MaterialLoc / 100 != lineNum && materials.ElementAt(i).MaterialLoc % 100 != i + 1 || lineNum <= 0 || lineNum > 5) | |||
{ | |||
MessageLog.GetInstance.ShowUserLog($"另存配方【{RecipeName}】无效:【配方中原料桶号异常】"); | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "提示", $"另存配方【{RecipeName}】无效"); | |||
ActionManage.GetInstance.Send("CloseNewRecipeView"); | |||
return; | |||
} | |||
} | |||
prop: string recipeID = Guid.NewGuid().ToString();//配方唯一ID,后期根据实际要求更改 | |||
var res = Json<RecipeManage>.Data.Recipes.FirstOrDefault(p => p.RecipeId == recipeID); | |||
if (res == null) | |||
@@ -180,6 +180,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkMOC", "B | |||
EndProject | |||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.DosingHKProject", "BPASmartClient.DosingProject\BPASmartClient.DosingHKProject.csproj", "{6763F73A-555C-41E2-91F7-ADF26C59A946}" | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmart.MenuLoad", "BPASmart.MenuLoad\BPASmart.MenuLoad.csproj", "{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}" | |||
EndProject | |||
Global | |||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | |||
Debug|Any CPU = Debug|Any CPU | |||
@@ -1694,6 +1696,26 @@ Global | |||
{6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|x64.Build.0 = Release|Any CPU | |||
{6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|x86.ActiveCfg = Release|Any CPU | |||
{6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|x86.Build.0 = Release|Any CPU | |||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|ARM.ActiveCfg = Debug|Any CPU | |||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|ARM.Build.0 = Debug|Any CPU | |||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|ARM64.ActiveCfg = Debug|Any CPU | |||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|ARM64.Build.0 = Debug|Any CPU | |||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|x64.ActiveCfg = Debug|Any CPU | |||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|x64.Build.0 = Debug|Any CPU | |||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|x86.ActiveCfg = Debug|Any CPU | |||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|x86.Build.0 = Debug|Any CPU | |||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|Any CPU.Build.0 = Release|Any CPU | |||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|ARM.ActiveCfg = Release|Any CPU | |||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|ARM.Build.0 = Release|Any CPU | |||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|ARM64.ActiveCfg = Release|Any CPU | |||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|ARM64.Build.0 = Release|Any CPU | |||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|x64.ActiveCfg = Release|Any CPU | |||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|x64.Build.0 = Release|Any CPU | |||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|x86.ActiveCfg = Release|Any CPU | |||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Release|x86.Build.0 = Release|Any CPU | |||
EndGlobalSection | |||
GlobalSection(SolutionProperties) = preSolution | |||
HideSolutionNode = FALSE | |||
@@ -1777,6 +1799,7 @@ Global | |||
{BA588F22-87FB-4124-AF62-CA8DC492ED7D} = {8712125E-14CD-4E1B-A1CE-4BDE03805942} | |||
{D5081D7B-3EBB-42C7-8FB9-A889870D08C2} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} | |||
{6763F73A-555C-41E2-91F7-ADF26C59A946} = {8712125E-14CD-4E1B-A1CE-4BDE03805942} | |||
{7A7547D3-F2EF-4DA4-AD45-D1B49210082B} = {06F0B369-0483-46DD-82D2-70431FB505C1} | |||
EndGlobalSection | |||
GlobalSection(ExtensibilityGlobals) = postSolution | |||
SolutionGuid = {9AEC9B81-0222-4DE9-B642-D915C29222AC} | |||
@@ -8,6 +8,7 @@ | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<None Remove="bj.png" /> | |||
<None Remove="device.png" /> | |||
</ItemGroup> | |||
@@ -25,6 +26,7 @@ | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Resource Include="bj.png" /> | |||
<Resource Include="device.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
@@ -1,89 +1,38 @@ | |||
<Window | |||
x:Class="WPFDemo.Window2" | |||
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:local="clr-namespace:WPFDemo" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:pru="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
Title="Window2" | |||
Width="800" | |||
Height="450" | |||
Topmost="True" | |||
mc:Ignorable="d"> | |||
<Window x:Class="WPFDemo.Window2" | |||
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:WPFDemo" | |||
mc:Ignorable="d" | |||
Title="Window2" Height="450" Width="800"> | |||
<Grid> | |||
<pru:NumberTextBox Width="150" Height="30" /> | |||
<!--<Grid> | |||
<TextBox | |||
Name="outLoc" | |||
Width="180" | |||
Height="35" | |||
Margin="5,0,0,0" | |||
GotFocus="outLoc_GotFocus" | |||
FontSize="20" | |||
Text="{Binding OutletLoc}" /> | |||
<Popup | |||
Name="pp" | |||
AllowsTransparency="True" | |||
Focusable="False" | |||
Placement="Left" | |||
PlacementTarget="{Binding ElementName=outLoc}" | |||
StaysOpen="True"> | |||
<Border Background="#081424" ClipToBounds="True"> | |||
<Grid Margin="0" > | |||
<Grid.RowDefinitions> | |||
<RowDefinition/> | |||
<RowDefinition/> | |||
</Grid.RowDefinitions> | |||
<TextBox Text="125"/> | |||
<Grid Grid.Row="1"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition/> | |||
<RowDefinition/> | |||
<RowDefinition/> | |||
<RowDefinition/> | |||
</Grid.RowDefinitions> | |||
<Grid.ColumnDefinitions> | |||
<Grid.Background> | |||
<ImageBrush ImageSource="/bj.png"/> | |||
</Grid.Background> | |||
<ListView x:Name="lisbox" ItemsSource="{Binding ViewItems,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" | |||
Background="{x:Null}" Foreground="White" | |||
PreviewMouseMove="ListView_PreviewMouseMove" | |||
PreviewMouseLeftButtonUp="lisbox_PreviewMouseLeftButtonUp"> | |||
<ListBox.ItemTemplate> | |||
<ItemContainerTemplate> | |||
<Grid MouseLeftButtonDown="Grid_MouseLeftButtonDown" > | |||
<Border BorderBrush="Aquamarine" BorderThickness="1" Padding="5"> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition/> | |||
<ColumnDefinition/> | |||
<ColumnDefinition/> | |||
<ColumnDefinition/> | |||
<ColumnDefinition/> | |||
<ColumnDefinition/> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock Foreground="White" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Text="1"/> | |||
<TextBlock Foreground="White" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Text="2"/> | |||
<TextBlock Foreground="White" Grid.Row="0" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" Text="3"/> | |||
<TextBlock Foreground="White" Grid.Row="0" Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" Text="4"/> | |||
<TextBlock Foreground="White" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Text="5"/> | |||
<TextBlock Foreground="White" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Text="6"/> | |||
<TextBlock Foreground="White" Grid.Row="1" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" Text="7"/> | |||
<TextBlock Foreground="White" Grid.Row="1" Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" Text="8"/> | |||
<TextBlock Foreground="White" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Text="9"/> | |||
<TextBlock Foreground="White" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Text="0"/> | |||
<TextBlock Foreground="White" Grid.Row="2" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" Text="."/> | |||
<TextBlock Foreground="White" Grid.Row="2" Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" Text="br"/> | |||
<TextBlock Foreground="White" Grid.Row="3" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Text="enter"/> | |||
<TextBlock Foreground="White" Grid.Row="3" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Text="a"/> | |||
<TextBlock Foreground="White" Grid.Row="3" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" Text="b"/> | |||
<TextBlock Foreground="White" Grid.Row="3" Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" Text="c"/> | |||
</Grid> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock Grid.Column="0" Text="{Binding Name,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"></TextBlock> | |||
<TextBlock Grid.Column="1" Text="{Binding Ph,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"></TextBlock> | |||
</Grid> | |||
</Border> | |||
</Grid> | |||
</Border> | |||
</Popup> | |||
</Grid>--> | |||
</ItemContainerTemplate> | |||
</ListBox.ItemTemplate> | |||
</ListView> | |||
</Grid> | |||
</Window> |
@@ -1,14 +1,18 @@ | |||
using System; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using System.Windows.Controls; | |||
using System.Windows.Controls.Primitives; | |||
using System.Windows.Data; | |||
using System.Windows.Documents; | |||
using System.Windows.Input; | |||
using System.Windows.Media; | |||
using System.Windows.Media.Effects; | |||
using System.Windows.Media.Imaging; | |||
using System.Windows.Shapes; | |||
@@ -19,14 +23,307 @@ namespace WPFDemo | |||
/// </summary> | |||
public partial class Window2 : Window | |||
{ | |||
TestModel testModel=new TestModel(); | |||
public Window2() | |||
{ | |||
InitializeComponent(); | |||
this.DataContext = testModel; | |||
testModel.ViewItems.Add(new PageModel {Name="张三", Ph="125486545" }); | |||
testModel.ViewItems.Add(new PageModel { Name = "李四", Ph = "125486545" }); | |||
testModel.ViewItems.Add(new PageModel { Name = "王麻子", Ph = "125486545" }); | |||
testModel.ViewItems.Add(new PageModel { Name = "二货", Ph = "125486545" }); | |||
} | |||
#region 移动事件 | |||
/// <summary> | |||
/// 当前拖动子控件流 | |||
/// </summary> | |||
private UIElement ChildElement; | |||
/// <summary> | |||
/// 是否已经按下 | |||
/// </summary> | |||
private bool isDown = false; | |||
/// <summary> | |||
/// 按下记录初始鼠标点位 | |||
/// 鼠标相对与拖动子控件的位置(偏移量) | |||
/// </summary> | |||
private Point InitPoint; | |||
/// <summary> | |||
/// 当前拖动的Pop窗体 | |||
/// </summary> | |||
private Popup DropPopup = null; | |||
/// <summary> | |||
/// 鼠标按下事件 | |||
/// </summary> | |||
/// <param name="sender"></param> | |||
/// <param name="e"></param> | |||
private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) | |||
{ | |||
try | |||
{ | |||
//isDown变量是防止多次操作。 | |||
if (isDown) | |||
{ | |||
isDown = false; | |||
return; | |||
} | |||
ChildElement = (UIElement)sender; | |||
ChildElement.CaptureMouse();//设置了鼠标捕获,这样它可以不受到其它控件的影响。 | |||
InitPoint= new Point(e.GetPosition(ChildElement).X, e.GetPosition(ChildElement).Y); | |||
//加蒙层,表明已经开始拖动 | |||
//暂时未加 | |||
CreatePopup(ChildElement, e); | |||
isDown = true; | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
/// <summary> | |||
/// 鼠标抬起事件 | |||
/// </summary> | |||
/// <param name="sender"></param> | |||
/// <param name="e"></param> | |||
private void lisbox_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) | |||
{ | |||
try | |||
{ | |||
//鼠标未按下返回 | |||
if (!isDown) return; | |||
isDown = false; | |||
//关闭Pop窗体 | |||
if (this.DropPopup != null) | |||
{ | |||
this.DropPopup.IsOpen = false; | |||
this.DropPopup.Child = null; | |||
this.DropPopup = null; | |||
} | |||
//蒙层关闭 | |||
ChildElement.ReleaseMouseCapture();//当控件具有鼠标捕获的话,则释放该捕获。 | |||
//double y = e.GetPosition(this).Y;//获取鼠标抬起时的控件的位置 Y值 | |||
//double start = 0.0; | |||
//int row = 0; | |||
//foreach (RowDefinition rd in myGrid.RowDefinitions) | |||
//{ | |||
// start += rd.ActualHeight; | |||
// if (y < start) | |||
// { | |||
// break; | |||
// } | |||
// row++; | |||
//} | |||
//double x = e.GetPosition(myGrid).X;//获取鼠标抬起时的控件的位置 X值 | |||
//double cstart = 0.0; | |||
//int column = 0; | |||
//foreach (ColumnDefinition cd in myGrid.ColumnDefinitions) | |||
//{ | |||
// cstart += cd.ActualWidth; | |||
// if (x < cstart) | |||
// { | |||
// break; | |||
// } | |||
// column++; | |||
//} | |||
//var initRow = Grid.GetRow(ultUE);//找到控件所在的行 | |||
//var initCol = Grid.GetColumn(ultUE);//找到控件所在的列 | |||
//UIElement uIElement = null; | |||
//if (row != initRow || column != initCol) | |||
//{ | |||
// uIElement = GetChildren(myGrid, row, column); | |||
//} | |||
//if (uIElement != null) | |||
//{ | |||
// //下面是交换两个控件的位置 (需要先移除再加载) | |||
// myGrid.Children.Remove(uIElement); | |||
// Grid.SetColumn(ultUE, column);//指定控件在grid中哪行哪例 | |||
// Grid.SetRow(ultUE, row); | |||
// myGrid.Children.Add(uIElement); | |||
// Grid.SetColumn(uIElement, initCol); | |||
// Grid.SetRow(uIElement, initRow); | |||
//} | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
/// <summary> | |||
/// 鼠标移动事件 | |||
/// </summary> | |||
/// <param name="sender"></param> | |||
/// <param name="e"></param> | |||
private void ListView_PreviewMouseMove(object sender, MouseEventArgs e) | |||
{ | |||
try | |||
{ | |||
if (isDown == false) return; | |||
Point ptLeftUp = new Point(0, 0); | |||
Point ptRightDown = new Point(this.ActualWidth, this.ActualHeight); | |||
ptLeftUp = this.PointToScreen(ptLeftUp); | |||
ptRightDown = this.PointToScreen(ptRightDown); | |||
double y = e.GetPosition(lisbox).Y; | |||
double x = e.GetPosition(lisbox).X; | |||
if (DropPopup != null) | |||
{ | |||
//下面两句是设置Popup控件的位置除以2是想让鼠标在它的中心 | |||
DropPopup.HorizontalOffset = ptLeftUp.X + x - ((FrameworkElement)ChildElement).ActualWidth / 2; | |||
DropPopup.VerticalOffset = ptLeftUp.Y + y - ((FrameworkElement)ChildElement).ActualHeight / 2; | |||
} | |||
//double start = 0.0; | |||
//int row = 0; | |||
//foreach (RowDefinition rd in myGrid.RowDefinitions) | |||
//{ | |||
// start += rd.ActualHeight; | |||
// if (y < start) | |||
// { | |||
// break; | |||
// } | |||
// row++; | |||
//} | |||
//double cstart = 0.0; | |||
//int column = 0; | |||
//foreach (ColumnDefinition cd in myGrid.ColumnDefinitions) | |||
//{ | |||
// cstart += cd.ActualWidth; | |||
// if (x < cstart) | |||
// { | |||
// break; | |||
// } | |||
// column++; | |||
//} | |||
////下面的代码是当鼠标移动到哪个格子哪个格子就会亮起来。 | |||
//UIElement uIElement = GetChildren(myGrid, row, column); | |||
//foreach (UIElement element in myGrid.Children) | |||
//{ | |||
// if (element != ultUE && element != uIElement) | |||
// { | |||
// element.Opacity = moveOpacity; | |||
// } | |||
// else | |||
// { | |||
// element.Opacity = 1; | |||
// } | |||
//} | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
/// <summary> | |||
/// 创建浮动窗口 | |||
/// </summary> | |||
/// <param name="dragElement"></param> | |||
/// <param name="e"></param> | |||
private void CreatePopup(Visual dragElement, MouseButtonEventArgs e) | |||
{ | |||
//使用PointToScreen函数可以将点转换为屏幕坐标 | |||
//首先获取当前窗体的左上角和右下角两点的坐标 | |||
Point ptLeftUp = new Point(0, 0); | |||
//转换获取到这个窗口相对于屏幕两个坐标 | |||
ptLeftUp = this.PointToScreen(ptLeftUp); | |||
//获取myGrid的实际宽高 | |||
double y = e.GetPosition(this).Y; | |||
double x = e.GetPosition(this).X; | |||
private void outLoc_GotFocus(object sender, RoutedEventArgs e) | |||
this.DropPopup = new Popup(); | |||
Border border = new Border(); | |||
border.Margin = new Thickness(0, 0, 8, 8); | |||
DropShadowEffect effect = new DropShadowEffect(); | |||
effect.Opacity = 1; | |||
effect.ShadowDepth = -14; | |||
effect.BlurRadius = 9; | |||
effect.Color = Color.FromArgb(100, 0, 0, 0); | |||
border.Effect = effect; | |||
Rectangle r = new Rectangle(); | |||
r.Width = ((FrameworkElement)dragElement).ActualWidth; | |||
r.Height = ((FrameworkElement)dragElement).ActualHeight; | |||
r.Fill = new VisualBrush(dragElement); | |||
border.Child = r; | |||
this.DropPopup.Child = border; | |||
DropPopup.AllowsTransparency = true; | |||
DropPopup.HorizontalOffset = ptLeftUp.X + x - ((FrameworkElement)dragElement).ActualWidth / 2; | |||
DropPopup.VerticalOffset = ptLeftUp.Y + y - ((FrameworkElement)dragElement).ActualHeight / 2; | |||
this.DropPopup.IsOpen = true; | |||
} | |||
#endregion | |||
} | |||
public class TestModel : ObservableObject | |||
{ | |||
private ObservableCollection<PageModel> _pageModels; | |||
public ObservableCollection<PageModel> ViewItems | |||
{ | |||
get | |||
{ | |||
return _pageModels; | |||
} | |||
set | |||
{ | |||
_pageModels = value; | |||
OnPropertyChanged("ViewItems"); | |||
} | |||
} | |||
public TestModel() | |||
{ | |||
ViewItems=new ObservableCollection<PageModel>(); | |||
} | |||
} | |||
public class PageModel : ObservableObject | |||
{ | |||
private string _Name; | |||
public string Name | |||
{ | |||
//this.pp.IsOpen = this.outLoc.Focusable; | |||
get | |||
{ | |||
return _Name; | |||
} | |||
set | |||
{ | |||
_Name = value; | |||
OnPropertyChanged("Name"); | |||
} | |||
} | |||
private string _Ph; | |||
public string Ph | |||
{ | |||
get | |||
{ | |||
return _Ph; | |||
} | |||
set | |||
{ | |||
_Ph = value; | |||
OnPropertyChanged("Ph"); | |||
} | |||
} | |||
} | |||
} |