diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheImage.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheImage.xaml.cs
index 596df93f..72140c14 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/TheImage.xaml.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/TheImage.xaml.cs
@@ -58,9 +58,10 @@ namespace BPASmartClient.SCADAControl.CustomerControls
}
private void Refresh()
{
- if (!string.IsNullOrEmpty(ImageStartPath) && File.Exists(ImageStartPath))
+ string path = $"{System.AppDomain.CurrentDomain.BaseDirectory}Images\\{ImageStartPath}";
+ if (!string.IsNullOrEmpty(ImageStartPath) && File.Exists(path))
{
- Source = new BitmapImage(new Uri(ImageStartPath));
+ Source = new BitmapImage(new Uri(path));
}
}
public string ControlType => "控件";
@@ -83,11 +84,10 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
if (!string.IsNullOrEmpty(ImageStartPath))
{
- string path = $"{System.AppDomain.CurrentDomain.BaseDirectory}Images\\{System.IO.Path.GetFileName(ImageStartPath)}";
+ string path = $"{System.AppDomain.CurrentDomain.BaseDirectory}Images\\{ImageStartPath}";
if (File.Exists(path))
{
- ImageStartPath = path;
- Source = new BitmapImage(new Uri(ImageStartPath));
+ Source = new BitmapImage(new Uri(path));
}
}
this.MouseLeftButtonDown += TheImage_MouseLeftButtonDown;
diff --git a/BeDesignerSCADA/Controls/CanvasPanelNew.xaml b/BeDesignerSCADA/Controls/CanvasPanelNew.xaml
index acfceaa1..fddbac28 100644
--- a/BeDesignerSCADA/Controls/CanvasPanelNew.xaml
+++ b/BeDesignerSCADA/Controls/CanvasPanelNew.xaml
@@ -98,10 +98,16 @@
-
+
+
+
+
+
+
+ PreviewMouseMove="CtlList_PreviewMouseMove"/>
+
diff --git a/BeDesignerSCADA/Controls/CanvasPanelNew.xaml.cs b/BeDesignerSCADA/Controls/CanvasPanelNew.xaml.cs
index b92e4d0e..a7220f10 100644
--- a/BeDesignerSCADA/Controls/CanvasPanelNew.xaml.cs
+++ b/BeDesignerSCADA/Controls/CanvasPanelNew.xaml.cs
@@ -28,6 +28,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Effects;
+using BeDesignerSCADA.Helper;
namespace BeDesignerSCADA.Controls
{
@@ -191,6 +192,33 @@ namespace BeDesignerSCADA.Controls
#region 执行操作事件
///
+ /// 查询输入框
+ ///
+ ///
+ ///
+ private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ try
+ {
+ System.Windows.Controls.TextBox textBox = sender as System.Windows.Controls.TextBox;
+ var info = viewModel.ControlsNameValues?.ToList().Find(par => par.Value.ToLower().StartsWith(textBox.Text.ToLower()));
+ if (info.Value.Key != null)
+ {
+ foreach (var item in CtlList.Items)
+ {
+ if ((item as Type).Name== info.Value.Key)
+ {
+ CtlList.ScrollIntoView(item);
+ CtlList.SelectedItem = item;
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ }
+ }
+ ///
/// 运行
///
///
diff --git a/BeDesignerSCADA/Helper/SystemHelper.cs b/BeDesignerSCADA/Helper/SystemHelper.cs
index f48189fb..e8ec91ac 100644
--- a/BeDesignerSCADA/Helper/SystemHelper.cs
+++ b/BeDesignerSCADA/Helper/SystemHelper.cs
@@ -3,11 +3,14 @@ using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
namespace BeDesignerSCADA.Helper
{
@@ -217,6 +220,33 @@ namespace BeDesignerSCADA.Helper
#endregion
+
+ ///
+ /// 垂直方向滚动到顶部
+ ///
+ ///
+ ///
+ public static void ScrollViewToVerticalTop(FrameworkElement element, ScrollViewer scrollViewer)
+ {
+ var scrollViewerOffset = scrollViewer.VerticalOffset;
+ var point = new System.Windows.Point(0, scrollViewerOffset);
+ var tarPos = element.TransformToVisual(scrollViewer).Transform(point);
+ scrollViewer.ScrollToVerticalOffset(tarPos.Y);
+ }
+
+ ///
+ /// 水平方向滚动到右侧
+ ///
+ ///
+ ///
+ public static void ScrollViewToHorizontalRight(FrameworkElement element, ScrollViewer scrollViewer)
+ {
+ var scrollViewerOffset = scrollViewer.HorizontalOffset;
+ var point = new System.Windows.Point(scrollViewerOffset, 0);
+ var tarPos = element.TransformToVisual(scrollViewer).Transform(point);
+ scrollViewer.ScrollToHorizontalOffset(tarPos.X);
+ }
+
}
[StructLayout(LayoutKind.Sequential)]
diff --git a/BeDesignerSCADA/ViewModel/MainViewModelNew.cs b/BeDesignerSCADA/ViewModel/MainViewModelNew.cs
index 2ba8506e..448f20a1 100644
--- a/BeDesignerSCADA/ViewModel/MainViewModelNew.cs
+++ b/BeDesignerSCADA/ViewModel/MainViewModelNew.cs
@@ -155,7 +155,48 @@ namespace BeDesignerSCADA.ViewModel
OnPropertyChanged("MenuModel");
}
}
+ ///
+ /// 控件集合名称映射
+ ///
+ public Dictionary ControlsNameValues = new Dictionary() {
+ {"GestureTapButton","按钮" },
+ {"TheTimer","计时器" },
+ {"TheCheckBox","勾选框" },
+ {"DigitalNumber","液晶数字" },
+ {"TheComboBox","下拉框" },
+ {"TheImage","图片" },
+ {"TheTextBlock","文本块" },
+ {"ArcGauge","仪表盘" },
+ {"StatusLight","状态灯" },
+ {"TheToggleButton","开关按钮" },
+ {"TheGroupBox","分组" },
+ {"TheTextBox","文本框" },
+ {"NumberBox","数值框" },
+ {"GraphArrow","箭头" },
+ {"GraphStar","五角星" },
+ {"TheSlider","滑块" },
+ {"TheRadioButton","单选按钮" },
+ {"SwitchButton","开关" },
+ {"KnobButton","旋钮" },
+ {"Silos","物料仓" },
+ {"NewConveyorBelt","滚动线" },
+ {"TheDataGrid","表格" },
+ {"TheListBox","列表控件" },
+ {"TheRedis","Redis控件" },
+ {"WaveProgressBar","进度条波浪" },
+ {"TheProgressBar","进度条正常" },
+ {"TheRedProgressBar","进度条圆形红" },
+ {"TheBlueProgressBar","进度条圆形蓝" },
+ {"TheGreenProgressBar","进度条圆形绿" },
+ {"TheAPI","API接口" },
+ {"TheMQTT","MQTT" },
+ {"TheTabControl","选项卡控件" },
+ {"TheCylinder","气缸控件" },
+ {"TheRectangle","矩形" },
+ {"TheEllipse","圆形" },
+ {"TheWuLiaoControl","物料集合控件" },
+ };
#endregion
#region 命令
@@ -311,7 +352,7 @@ namespace BeDesignerSCADA.ViewModel
ofd.Filter = "图片|*.jpg;*.png;*.gif;*.jpeg;*.bmp";
if (ofd.ShowDialog() == true)
{
- ((Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem)obj).Value = ofd.FileName;
+
if (!string.IsNullOrEmpty(LayoutsPath))
{
@@ -324,17 +365,22 @@ namespace BeDesignerSCADA.ViewModel
FileInfo fi2 = new FileInfo(path2);
try
{
+ if (!Directory.Exists(qz.Replace("Layouts", "Images"))) // 返回bool类型,存在返回true,不存在返回false
+ {
+ Directory.CreateDirectory(qz.Replace("Layouts", "Images")); //不存在则创建路径
+ }
if (File.Exists(path2))
{
fi2.Delete();
}
fi1.CopyTo(path2);
+
+ ((Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem)obj).Value = System.IO.Path.GetFileName(ofd.FileName);
}
catch (IOException ioex)
{
Console.WriteLine(ioex.Message);
}
-
}
}
}