@@ -57,7 +57,7 @@ namespace BPASmartClient.CustomResource.Pages.View | |||
} | |||
Task.Factory.StartNew(() => | |||
{ | |||
Thread.Sleep(500); | |||
Thread.Sleep(100); | |||
Application.Current.Dispatcher.Invoke(() => { Username.Focus(); }); | |||
//grid.Visibility = Visibility.Visible; | |||
}); | |||
@@ -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; | |||
@@ -98,10 +98,16 @@ | |||
<TabItem Header="组件列表"> | |||
<Border BorderThickness="1" BorderBrush="#FFA9A9A9" Background="Transparent"> | |||
<ListBox x:Name="CtlList" Grid.Row="2" Background="Transparent" ScrollViewer.VerticalScrollBarVisibility="Auto" | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="35"/> | |||
<RowDefinition/> | |||
</Grid.RowDefinitions> | |||
<TextBox Margin="5" TextChanged="TextBox_TextChanged" FontSize="16"></TextBox> | |||
<ListBox x:Name="CtlList" Grid.Row="2" Background="Transparent" ScrollViewer.VerticalScrollBarVisibility="Auto" | |||
ItemTemplate="{DynamicResource ToolBoxStyle}" FontSize="14" BorderThickness="0" | |||
PreviewMouseMove="CtlList_PreviewMouseMove" | |||
/> | |||
PreviewMouseMove="CtlList_PreviewMouseMove"/> | |||
</Grid> | |||
</Border> | |||
</TabItem> | |||
@@ -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 执行操作事件 | |||
/// <summary> | |||
/// 查询输入框 | |||
/// </summary> | |||
/// <param name="sender"></param> | |||
/// <param name="e"></param> | |||
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) | |||
{ | |||
} | |||
} | |||
/// <summary> | |||
/// 运行 | |||
/// </summary> | |||
/// <param name="sender"></param> | |||
@@ -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 | |||
/// <summary> | |||
/// 垂直方向滚动到顶部 | |||
/// </summary> | |||
/// <param name="element"></param> | |||
/// <param name="scrollViewer"></param> | |||
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); | |||
} | |||
/// <summary> | |||
/// 水平方向滚动到右侧 | |||
/// </summary> | |||
/// <param name="element"></param> | |||
/// <param name="scrollViewer"></param> | |||
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)] | |||
@@ -155,7 +155,48 @@ namespace BeDesignerSCADA.ViewModel | |||
OnPropertyChanged("MenuModel"); | |||
} | |||
} | |||
/// <summary> | |||
/// 控件集合名称映射 | |||
/// </summary> | |||
public Dictionary<string, string> ControlsNameValues = new Dictionary<string, string>() { | |||
{"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); | |||
} | |||
} | |||
} | |||
} | |||