Ver código fonte

调整datagrid

样式分支
fyf 2 anos atrás
pai
commit
f435fb9e1d
7 arquivos alterados com 118 adições e 28 exclusões
  1. +11
    -1
      BPASmartClient.SCADAControl/CustomerControls/TheAPI.xaml.cs
  2. +40
    -6
      BPASmartClient.SCADAControl/CustomerControls/TheDataGrid.xaml.cs
  3. +24
    -1
      BPASmartClient.SCADAControl/CustomerControls/TheMQTT.xaml.cs
  4. +24
    -1
      BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs
  5. +12
    -13
      BeDesignerSCADA/Controls/CanvasPanel.cs
  6. +6
    -5
      BeDesignerSCADA/Controls/MainCanvasPanel.xaml
  7. +1
    -1
      BeDesignerSCADA/ViewModel/MainViewModelNew.cs

+ 11
- 1
BPASmartClient.SCADAControl/CustomerControls/TheAPI.xaml.cs Ver arquivo

@@ -166,6 +166,9 @@ namespace BPASmartClient.SCADAControl.CustomerControls
public void Dispose()
{
timer.Stop();
Direction=0;
FDataSouce = "";
if (IsRun) IsRun = false;
}

#region 属性
@@ -275,7 +278,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
try
{
if (!string.IsNullOrEmpty(FDataSouce))
//if (!string.IsNullOrEmpty(FDataSouce))
{
GenerateData = (string)CSharpConfig.GetInstance().RunCSharp(Code,new object[] { FDataSouce });
Class_DataBus.GetInstance().Dic_APIData[this.Name] = GenerateData;
@@ -311,6 +314,13 @@ namespace BPASmartClient.SCADAControl.CustomerControls
public void IsRunRefresh()
{
//测试运行
if (IsRun)
IsExecuteState = true;
else
{
IsExecuteState = false;
Dispose();
}
}
[Category("数据绑定")]
public string GenerateData


+ 40
- 6
BPASmartClient.SCADAControl/CustomerControls/TheDataGrid.xaml.cs Ver arquivo

@@ -28,7 +28,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
/// <summary>
/// TheDataGrid.xaml 的交互逻辑
/// </summary>
public partial class TheDataGrid :DataGrid, IExecutable
public partial class TheDataGrid :DataGrid, IExecutable, IDisposable
{
public TheDataGrid()
{
@@ -36,8 +36,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls
//ResourceDictionary languageResDic = new ResourceDictionary();
//languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml", UriKind.RelativeOrAbsolute);
//this.Resources.MergedDictionaries.Add(languageResDic);
MinWidth = 100;
MinHeight = 100;
//MinWidth = 100;
//MinHeight = 100;
Width = 100;
Height = 100;
this.Loaded += TheDataGrid_Loaded; ;
@@ -55,6 +55,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
try
{
TabItemsStr = JsonConvert.SerializeObject(TabItems);
GenerateDataRefresh();
}
catch (Exception ex)
{
@@ -96,6 +97,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls

}
}
Style = null;

if (DataSouceType == DataTypeEnum.API接口)
{
@@ -105,6 +107,14 @@ namespace BPASmartClient.SCADAControl.CustomerControls
}
}

public void Dispose()
{
timer.Stop();
FDataSouce = "";
if (IsRun) IsRun = false;
GenerateDataRefresh();
}

private void Timer_Tick(object? sender,EventArgs e)
{
if (!string.IsNullOrEmpty(DataSouceInformation))
@@ -172,7 +182,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
try
{
if (!string.IsNullOrEmpty(FDataSouce))
//if (!string.IsNullOrEmpty(FDataSouce))
{
GenerateData = (string)CSharpConfig.GetInstance().RunCSharp(Code,new object[] { FDataSouce });
if (PropertyChange != null)
@@ -196,6 +206,26 @@ namespace BPASmartClient.SCADAControl.CustomerControls
public static readonly DependencyProperty CodeProperty =
DependencyProperty.Register("Code",typeof(string),typeof(TheDataGrid),new PropertyMetadata(_code));
[Category("数据绑定")]
public bool IsRun
{
get { return (bool)GetValue(RunProperty); }
set { SetValue(RunProperty, value); }
}
public static readonly DependencyProperty RunProperty =
DependencyProperty.Register("IsRun", typeof(bool), typeof(TheDataGrid), new PropertyMetadata(false, new PropertyChangedCallback(onIsRunChanged)));
private static void onIsRunChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as TheDataGrid)?.IsRunRefresh();
public void IsRunRefresh()
{
//测试运行
if (IsRun)
IsExecuteState = true;
else
{
IsExecuteState = false;
Dispose();
}
}
[Category("数据绑定")]
public string GenerateData
{
get { return (string)GetValue(GenerateDataProperty); }
@@ -210,7 +240,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
try
{
Dictionary<string, object> keys= JsonConvert.DeserializeObject<Dictionary<string, object>>(GenerateData);
Dictionary<string, object> keys = JsonConvert.DeserializeObject<Dictionary<string, object>>(GenerateData);
List<Dictionary<string, object>> obj2 = JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(keys["data"].ToString());
//ItemsString = JsonConvert.DeserializeObject<DataSouceModel>(GenerateData);
// 运行时进行项目绑定
@@ -219,7 +249,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
this.CanUserDeleteRows = false;
this.RowHeaderWidth = 0;
this.GridLinesVisibility = DataGridGridLinesVisibility.None;
//this.BorderThickness = new Thickness(0);
this.BorderThickness = new Thickness(0);
this.ItemsSource = ListToDataTable(obj2).DefaultView;
}
catch (Exception ex)
@@ -227,6 +257,10 @@ namespace BPASmartClient.SCADAControl.CustomerControls

}
}
else
{
this.ItemsSource = new DataTable().DefaultView;
}
}



+ 24
- 1
BPASmartClient.SCADAControl/CustomerControls/TheMQTT.xaml.cs Ver arquivo

@@ -185,6 +185,9 @@ namespace BPASmartClient.SCADAControl.CustomerControls
public void Dispose()
{
timer.Stop();
Direction = 0;
FDataSouce = "";
if (IsRun) IsRun = false;
}

#region 属性
@@ -308,7 +311,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
try
{
if (!string.IsNullOrEmpty(FDataSouce))
//if (!string.IsNullOrEmpty(FDataSouce))
{
GenerateData = (string)CSharpConfig.GetInstance().RunCSharp(Code,new object[] { FDataSouce });

@@ -329,6 +332,26 @@ namespace BPASmartClient.SCADAControl.CustomerControls
public static readonly DependencyProperty CodeProperty =
DependencyProperty.Register("Code",typeof(string),typeof(TheMQTT),new PropertyMetadata(_code));
[Category("数据绑定")]
public bool IsRun
{
get { return (bool)GetValue(RunProperty); }
set { SetValue(RunProperty, value); }
}
public static readonly DependencyProperty RunProperty =
DependencyProperty.Register("IsRun", typeof(bool), typeof(TheMQTT), new PropertyMetadata(false, new PropertyChangedCallback(onIsRunChanged)));
private static void onIsRunChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as TheMQTT)?.IsRunRefresh();
public void IsRunRefresh()
{
//测试运行
if (IsRun)
IsExecuteState = true;
else
{
IsExecuteState = false;
Dispose();
}
}
[Category("数据绑定")]
public string GenerateData
{
get { return (string)GetValue(GenerateDataProperty); }


+ 24
- 1
BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs Ver arquivo

@@ -200,6 +200,9 @@ namespace BPASmartClient.SCADAControl.CustomerControls
public void Dispose()
{
timer.Stop();
Direction = 0;
FDataSouce = "";
if (IsRun) IsRun = false;
}

#region 属性
@@ -301,7 +304,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
try
{
if (!string.IsNullOrEmpty(FDataSouce))
//if (!string.IsNullOrEmpty(FDataSouce))
{
GenerateData = (string)CSharpConfig.GetInstance().RunCSharp(Code,new object[] { FDataSouce });
@@ -322,6 +325,26 @@ namespace BPASmartClient.SCADAControl.CustomerControls
public static readonly DependencyProperty CodeProperty =
DependencyProperty.Register("Code",typeof(string),typeof(TheRedis),new PropertyMetadata(_code));
[Category("数据绑定")]
public bool IsRun
{
get { return (bool)GetValue(RunProperty); }
set { SetValue(RunProperty, value); }
}
public static readonly DependencyProperty RunProperty =
DependencyProperty.Register("IsRun", typeof(bool), typeof(TheRedis), new PropertyMetadata(false, new PropertyChangedCallback(onIsRunChanged)));
private static void onIsRunChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as TheRedis)?.IsRunRefresh();
public void IsRunRefresh()
{
//测试运行
if (IsRun)
IsExecuteState = true;
else
{
IsExecuteState = false;
Dispose();
}
}
[Category("数据绑定")]
public string GenerateData
{
get { return (string)GetValue(GenerateDataProperty); }


+ 12
- 13
BeDesignerSCADA/Controls/CanvasPanel.cs Ver arquivo

@@ -929,7 +929,7 @@ namespace BeDesignerSCADA.Controls
// 排除非自定义的控件们
if (!(item is IExecutable))
continue;
if(item is IDisposable) (item as IDisposable).Dispose();
var xml = XamlWriter.Save(item);
var ele = XamlReader.Parse(xml) as FrameworkElement;
elements.Add(ele);
@@ -947,7 +947,10 @@ namespace BeDesignerSCADA.Controls

foreach (var item in Children)
{

// 排除非自定义的控件们
if (!(item is IExecutable))
continue;
if (item is IDisposable) (item as IDisposable).Dispose();
var xml = XamlWriter.Save(item);
sb.Append(xml + "\r\n");
}
@@ -967,20 +970,16 @@ namespace BeDesignerSCADA.Controls
while (sr.Peek() > -1)
{
string str = sr.ReadLine();
//if (!str.Contains("NewConveyorBelt"))
try
{
var ele = XamlReader.Parse(str) as FrameworkElement;
Children.Add(ele);
}
catch (Exception ex)
{
try
{
var ele = XamlReader.Parse(str) as FrameworkElement;
Children.Add(ele);
}
catch (Exception ex)
{

}
}

}
}



+ 6
- 5
BeDesignerSCADA/Controls/MainCanvasPanel.xaml Ver arquivo

@@ -241,8 +241,11 @@
<mypro:PropertyDefinition DisplayName="接口参数" Category="数据绑定模块" DisplayOrder="2" Name="InterfaceParameters"/>
<mypro:PropertyDefinition DisplayName="连接信息" Category="数据绑定模块" DisplayOrder="3" Name="DataSouceInformation"/>
<mypro:PropertyDefinition DisplayName="设备解析变量" Category="数据绑定模块" DisplayOrder="4" Name="DeviceValuleName"/>
<mypro:PropertyDefinition DisplayName="模拟运行" Category="数据绑定模块" DisplayOrder="4" Name="IsRun"/>
<mypro:PropertyDefinition DisplayName="数据源" Category="数据绑定模块" DisplayOrder="5" Name="FDataSouce"/>
<mypro:PropertyDefinition DisplayName="代码过滤脚本" Category="数据绑定模块" DisplayOrder="6" Name="Code"/>

<mypro:PropertyDefinition DisplayName="数据结果" Category="数据绑定模块" DisplayOrder="7" Name="GenerateData"/>
<mypro:PropertyDefinition DisplayName="定时间隔" Category="数据绑定模块" DisplayOrder="8" Name="TimeCount"/>

@@ -326,15 +329,13 @@
</mypro:EditorTemplateDefinition.EditingTemplate>
</mypro:EditorTemplateDefinition>

<!--<mypro:EditorTemplateDefinition TargetProperties="DeviceValuleName" >
<mypro:EditorTemplateDefinition TargetProperties="IsRun" >
<mypro:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<ComboBox Grid.Column="1" Height="25" Width="{Binding Width, ElementName=com}" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=DataContext.DevValueList}"
></ComboBox>
<CheckBox IsChecked="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">定时业务</CheckBox>
</DataTemplate>
</mypro:EditorTemplateDefinition.EditingTemplate>
</mypro:EditorTemplateDefinition>-->
</mypro:EditorTemplateDefinition>

<mypro:EditorTemplateDefinition TargetProperties="DeviceName" >
<mypro:EditorTemplateDefinition.EditingTemplate>


+ 1
- 1
BeDesignerSCADA/ViewModel/MainViewModelNew.cs Ver arquivo

@@ -37,7 +37,7 @@ namespace BeDesignerSCADA.ViewModel
{
IsRunning = !IsRunning;
});
DevNameList = new ObservableCollection<string>() { "qqqq", "wewew" };
//DevNameList = new ObservableCollection<string>() { "qqqq", "wewew" };
//DataBusModel.GetInstance().RefreshTheVariableManagerAction += RefreshTheVariableManagerActionHader;
}



Carregando…
Cancelar
Salvar