Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

Commit

Permalink
Updated logic
Browse files Browse the repository at this point in the history
  • Loading branch information
rnayabed committed Apr 17, 2020
1 parent 60e61e3 commit ef895b8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
5 changes: 2 additions & 3 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions src/PCHWRMClient/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,26 @@
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;

public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
public void start(Stage primaryStage)
{
Platform.setImplicitExit(false);
dash d = new dash(this, primaryStage);
Scene s = new Scene(d);
primaryStage.setScene(s);
primaryStage.getIcons().add(new Image(getClass().getResource("assets/icon.png").toExternalForm()));
primaryStage.setResizable(false);
primaryStage.setTitle("PCHWRM By github.com/dubbadhar <3");
primaryStage.setTitle("PCHWRM Client By github.com/dubbadhar <3");
primaryStage.show();
primaryStage.setOnCloseRequest(event->{
try
{
if(d.isConnected){
d.writeToOS("QUIT");
Thread.sleep(500);
d.isConnected=false;
}
Expand Down
4 changes: 3 additions & 1 deletion src/PCHWRMClient/dash.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,11 @@ public void minimizeToTraySetup()
exitItem.addActionListener(l->{
try {
if(isConnected){
writeToOS("QUIT");
Thread.sleep(500);
isConnected=false;
}
tray.remove(ti);
Platform.exit();
}
catch (Exception e)
Expand Down Expand Up @@ -519,7 +521,7 @@ public ArrayList<String[]> getValuesFromWMI() throws Exception
String out = io.getShellOutput("powershell.exe get-wmiobject -namespace root\\OpenHardwareMonitor -query 'SELECT Value,Name,SensorType FROM Sensor'").replace("\r\n\r\n__GENUS : 2\r\n__CLASS : Sensor\r\n__SUPERCLASS : \r\n__DYNASTY : \r\n__RELPATH : \r\n__PROPERTY_COUNT : 3\r\n__DERIVATION : {}\r\n__SERVER : \r\n__NAMESPACE : \r\n__PATH : \r\n","");
ArrayList<String[]> returnable = new ArrayList<>();

String[] x = out.split("PSComputerName :");
String[] x = out.split("PSComputerName {3}:");

for(int i =0;i<x.length - 1;i++)
{
Expand Down
2 changes: 1 addition & 1 deletion src/PCHWRMClient/io.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void writeToFile(String content,String fileName)
{
File f = new File(fileName);
if(!f.exists())
f.createNewFile();
if(!f.createNewFile()) throw new Exception("Insufficient Permissions to create "+fileName);
BufferedWriter bf = new BufferedWriter(new FileWriter(fileName));
bf.write(content);
bf.close();
Expand Down

0 comments on commit ef895b8

Please sign in to comment.