This repository has been archived by the owner on Dec 31, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrainer.xaml.cs
84 lines (77 loc) · 3.08 KB
/
Trainer.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// License: Apache-2.0
/*
* Trainer.xaml.cs: Back-end source code for trainer
*
* (C) Copyright 2024 Lithicsoft Organization
* Author: Bui Nguyen Tan Sang <[email protected]>
*/
using Lithicsoft_Trainer_Studio.CSharp;
using System.Windows;
using MessageBox = ModernWpf.MessageBox;
namespace Lithicsoft_Trainer_Studio
{
/// <summary>
/// Interaction logic for Trainer.xaml
/// </summary>
public partial class Trainer : Window
{
private readonly string projectName = string.Empty, projectLanguage = string.Empty, projectType = string.Empty;
public Trainer(string name, string language, string type)
{
InitializeComponent();
this.SizeToContent = SizeToContent.WidthAndHeight;
this.Title = $"{name} - {language} - {type}";
projectName = name;
projectLanguage = language;
projectType = type;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
try
{
if (projectLanguage == "CSharp")
{
if (projectType == "Image Classification")
{
ImageClassification imageClassification = new(projectName);
this.MainStackPanel.Children.Add(imageClassification);
}
else if (projectType == "Value Prediction")
{
ValuePrediction valuePrediction = new(projectName);
this.MainStackPanel.Children.Add(valuePrediction);
}
else
{
MessageBox.Show($"Cannot open project {projectName} ({projectType})", "Project Open");
}
}
else
{
Python.Python python = new(projectName);
this.MainStackPanel.Children.Add(python);
}
}
catch (Exception ex)
{
MessageBox.Show($"Error dectecting project type: {ex.Message}", "Exception Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (CSharp.IC.TrainModel.Instance.isTraining || CSharp.VP.TrainModel.Instance.isTraining || Python.PY.TrainModel.Instance.isTraining)
{
MessageBox.Show("You can't not exit Trainer Studio while training model!", "Prevent Closing", MessageBoxButton.OK, MessageBoxImage.Stop);
e.Cancel = true;
}
else
{
var result = MessageBox.Show("Do you want to exit Trainer Studio?", "Close Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
System.Windows.Application.Current.Shutdown();
else if (result == MessageBoxResult.No)
e.Cancel = true;
}
}
}
}