Skip to content

Commit

Permalink
cl: misc clean
Browse files Browse the repository at this point in the history
  • Loading branch information
ngtuonghy committed Mar 22, 2024
1 parent ed72b16 commit 2d3091e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
1 change: 0 additions & 1 deletion MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
mc:Ignorable="d">

<Grid>

<view:SettingsView />
</Grid>
</Window>
18 changes: 5 additions & 13 deletions ViewModel/SettingsViewVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class SettingsViewVM : Util.ViewModelBase
readonly Util.FileHandler _fileHandler;
private DisplaySpecs _displaySpecs;
public static int _previousBatteryState = 0; // 1 is battery | 2 is plugin | 0 reset check

public enum ChargingStatus
{
Charging, // Đang sạc
Expand Down Expand Up @@ -121,7 +121,7 @@ public bool cbRefreshRate
}
}
}


private bool _cbStartup;
public bool cbStartup
Expand All @@ -141,19 +141,15 @@ public bool cbStartup
}


// System.Windows.Threading.DispatcherTimer timer = new DispatcherTimer();
private bool _labelfistLaunch = false;
public SettingsViewVM()
{
// Avoiding Errors https://learn.microsoft.com/en-us/archive/technet-wiki/29874#avoiding-errors
// Avoiding Errors see: https://learn.microsoft.com/en-us/archive/technet-wiki/29874#avoiding-errors
if (DesignerProperties.GetIsInDesignMode(new DependencyObject())) return;

_displaySpecs = new DisplaySpecs();
_fileHandler = new Util.FileHandler();

// timer.Tick += new EventHandler(timerTick);
// timer.Interval = TimeSpan.FromSeconds(1);

comboBoxItemsBattery = new ObservableCollection<ComboBoxItem>();
comboBoxItemsPlugged = new ObservableCollection<ComboBoxItem>();

Expand All @@ -174,12 +170,11 @@ private void OnDisplaySettingsChanged(object sender, EventArgs e)
}
private void updateRefresh()
{
string currentRefreshRate = getCurrentRefreshRate();
string currentRefreshRate = getCurrentRefreshRate();

if (currentRefreshRate + " Hz" != refreshRate)
{
bool canConvert = int.TryParse(currentRefreshRate, out int result);
// MessageBox.Show(refreshRate);
refreshRate = canConvert ? result + " Hz" : currentRefreshRate + " Hz";
}
}
Expand Down Expand Up @@ -299,7 +294,6 @@ private void setConfigApp()
private void initializeItemsFromConfiguration()
{
setSave = "Save";
// _previousBatteryState = getBatteryStatus(_appPath);
if (!_labelfistLaunch)
{
string[] displayArray = ConfigurationManager.AppSettings["display"].Split(',');
Expand All @@ -326,7 +320,6 @@ private void initializeItemsFromConfiguration()

cbRefreshRate = _fileHandler.getBooleanSetting("cbRefreshRate");
cbStartup = _fileHandler.getBooleanSetting("cbStartup");
// timer.Start();
updatePowerStatusAndIcon();
updateRefresh();
}
Expand Down Expand Up @@ -360,8 +353,6 @@ public PackIconMaterialDesignKind IconKind
public async void changeRefeshRate(ChargingStatus powerStatus)
{
if (_fileHandler.getBooleanSetting("cbRefreshRate") == false) return;

// MessageBox.Show("test");
string filePath = _appPath + @"/log.txt";
string configPluggedItem = ConfigurationManager.AppSettings["comboBoxItemsPluggedSelected"] ?? "";
string configBatteryItem = ConfigurationManager.AppSettings["comboBoxItemsBatterySelected"] ?? "";
Expand Down Expand Up @@ -400,6 +391,7 @@ public async void changeRefeshRate(ChargingStatus powerStatus)
public Util.RelayCommand saveCommand => new RelayCommand(execute => { save(); });
public Util.RelayCommand defautBtnCommand => new RelayCommand(execute => { setDefault(); });
public Util.RelayCommand getDisplay => new RelayCommand(execute => { get(); });

void get()
{
_fileHandler.setFileDisplay(_appPath);
Expand Down

0 comments on commit 2d3091e

Please sign in to comment.