Readjust design, and add touchscreen

This commit is contained in:
2024-12-14 16:07:53 +07:00
parent 721d397671
commit add2bb0590
4 changed files with 138 additions and 129 deletions

View File

@@ -213,6 +213,7 @@ namespace FAtoPA.Net
String json = JsonSerializer.Serialize(ModbusTranslationTable);
File.WriteAllText("ModbusTranslationTable.json", json);
Debug.WriteLine("ModbusTranslationTable saved");
FSMtoModbusTranslationTable.ItemsSource = ModbusTranslationTable;
} catch (Exception e)
{
Debug.WriteLine("Error saving ModbusTranslationTable : " + e.Message);
@@ -302,6 +303,7 @@ namespace FAtoPA.Net
String json = JsonSerializer.Serialize(FSMConditionTable);
File.WriteAllText("FSMConditionTable.json", json);
Debug.WriteLine("FSMConditionTable saved");
ConditionTable.ItemsSource = FSMConditionTable;
}
catch (Exception e)
{
@@ -403,7 +405,7 @@ namespace FAtoPA.Net
fsm.AddListener(new FSMTableUpdater(FsmTableMember, DetectedSIID, DetectedSIIDCount));
fsm.AddListener(new ModbusTriggerFromFSM(FsmTableMember, ModbusTableMember, modbusSlave, ModbusTranslationTable));
fsm.AddListener(new VXTriggerFromFSM(FsmTableMember, VXTableMember, vx3k, ConditionON, ConditionOFF));
VerifyDataGridBinding(ConditionTable);
}
private void Timer1s_Tick(object sender, EventArgs e)
@@ -1329,6 +1331,8 @@ namespace FAtoPA.Net
var result = MessageBox.Show($"Reset FSM to Modbus Translation Table ?", "Reset FSM to Modbus Translation Table", MessageBoxButton.YesNo);
if (result == MessageBoxResult.Yes)
{
if (ModbusTranslationTable != null) ModbusTranslationTable.Clear();
Create_Default_ModbusTranslationTable();
}
@@ -1363,6 +1367,7 @@ namespace FAtoPA.Net
var result = MessageBox.Show($"Reset FSM Condition Table ?", "Reset FSM Condition Table", MessageBoxButton.YesNo);
if (result == MessageBoxResult.Yes)
{
if (FSMConditionTable != null) FSMConditionTable.Clear();
Create_Default_ConditionTable();
}
}
@@ -1375,31 +1380,30 @@ namespace FAtoPA.Net
Save_ConditionTable();
}
}
// Method to verify if the DataGrid is correctly bound to the data source
private void VerifyDataGridBinding(DataGrid dataGrid)
private void btnStartStopFSM_TouchEnter(object sender, TouchEventArgs e)
{
if (dataGrid.ItemsSource == null)
{
Debug.WriteLine("DataGrid is not bound to any data source.");
return;
}
btnStartStopFSM_Click(sender, e);
}
var dataSourceType = dataGrid.ItemsSource.GetType();
Debug.WriteLine($"DataGrid is bound to data source of type: {dataSourceType.Name}");
// Check if the data source is an ObservableCollection
if (dataSourceType.IsGenericType && dataSourceType.GetGenericTypeDefinition() == typeof(ObservableCollection<>))
private void TabItem_TouchDown(object sender, TouchEventArgs e)
{
if (sender is TabItem touchedTabItem)
{
Debug.WriteLine("DataGrid is bound to an ObservableCollection.");
}
else
{
Debug.WriteLine("DataGrid is bound to a different type of collection.");
// Set the touched TabItem as the selected one
mainTab.SelectedItem = touchedTabItem;
e.Handled = true; // Mark the event as handled
}
}
private void mainTab_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
}
/// <summary>
/// <summary>e
/// Event Handler for VX3K
/// </summary>
class VX3KEvent : EventInterface