diff --git a/.idea/misc.xml b/.idea/misc.xml index 56c7380..e1c7304 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,5 +8,5 @@ - + \ No newline at end of file diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000..b438863 --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: CN.UI.Main + diff --git a/README.md b/README.md index 81a7087..0d792f7 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,12 @@ ![](https://img.shields.io/github/last-commit/chenpuhao/desktopaide) ![](https://img.shields.io/github/release-date/chenpuhao/desktopaide) +注意 +== +从3.4.3版本起,DesktopAide更名为DesktopAide community且因高三的学业压力,目前只支持中文(其余语言安装包请耐心等待。。。。) + +Starting from version 3.4.3, DesktopAide is renamed DesktopAide community. Due to the academic pressure of senior high school, only Chinese is currently supported (please wait patiently for installation packages of other languages...). + 针对无网或弱网用户 == 请加入[QQ群](https://qm.qq.com/cgi-bin/qm/qr?k=f9bsc0Rw7_9i7cCWgKMcSNgrWohzmI5z&authKey=ScZtpf95RkpFWGgxsefyO2WzMPYNsBcxuoTWRfVaBl4A5HfbKNrruAw4K75ljQa7&noverify=0&personal_qrcode_source=0)获取下载安装包,也适用于出现Connection timed out错误的用户 @@ -41,10 +47,6 @@ == [简体中文](src/main/java/CN/README-CN.md) -
-[English](src/main/java/EN/README-EN.md) -
-[русск(В настоящее время файлы README недоступны)](#) 注意 == @@ -54,10 +56,3 @@ All content is machine translation, if there are errors, criticism and correctio
Весь контент является машинным переводом, если есть ошибки, критика и исправление приветствуются -翻译原则 -== -该国访问主站的数目达到500 -
-The number of visits to the main site in the country reached 500 -
-Количество посещений главной площадки в стране достигло 500 diff --git a/src/main/java/CN/Function/Update/CheckUpdate.java b/src/main/java/CN/Function/Update/CheckUpdate.java index 55817c7..bf61063 100644 --- a/src/main/java/CN/Function/Update/CheckUpdate.java +++ b/src/main/java/CN/Function/Update/CheckUpdate.java @@ -51,7 +51,7 @@ public String CheckUpdate() throws IOException { downloadUsingStream("https://desktopaide.chenpuhao.me/update.txt",file.toString()); readAppointedLineNumber(file); file.delete(); - if(result.equals("3.4.1")){ + if(result.equals("3.4.3")){ result = "true"; } return result; diff --git a/src/main/java/CN/UI/FunctionPanel/CollationPanel.java b/src/main/java/CN/UI/FunctionPanel/CollationPanel.java index 26cd31b..98c09bf 100644 --- a/src/main/java/CN/UI/FunctionPanel/CollationPanel.java +++ b/src/main/java/CN/UI/FunctionPanel/CollationPanel.java @@ -1,6 +1,7 @@ package CN.UI.FunctionPanel; import javax.swing.*; +import javax.swing.filechooser.FileSystemView; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -36,38 +37,17 @@ public CollationPanel() throws IOException { //桌面路径 JPanel path = new JPanel(); path.setLayout(new GridLayout(4,1)); - JLabel desktopPath = new JLabel("选择您的桌面路径:"); + JLabel desktopPath = new JLabel(); + FileSystemView view = FileSystemView.getFileSystemView(); + File file = view.getHomeDirectory(); + String getDesktopPath = file.getPath(); + desktopPath.setText("您的桌面路径为"+getDesktopPath); ButtonGroup pathButtonGroup = new ButtonGroup(); Map map = System.getenv(); String userName = map.get("USERNAME"); - JRadioButton desktop = new JRadioButton("C:\\Users\\" + userName + "\\Desktop"); - JRadioButton oneDrive = new JRadioButton("C:\\Users\\" + userName + "\\OneDrive\\Desktop"); - JRadioButton other = new JRadioButton("其他:"); - pathButtonGroup.add(desktop); - pathButtonGroup.add(oneDrive); - pathButtonGroup.add(other); - JTextField otherTxt = new JTextField(); File folderPath = new File("C:\\Users\\" + userName + "\\.DesktopAide\\collation"); File filePath = new File(folderPath + "\\path.da"); - if(filePath.exists()) { - readAppointedLineNumber(filePath); - if (data.equals("C:\\Users\\" + userName + "\\Desktop")) { - desktop.setSelected(true); - } else if (data.equals("C:\\Users\\" + userName + "\\OneDrive\\Desktop")) { - oneDrive.setSelected(true); - } else { - other.setSelected(true); - otherTxt.setText(data); - } - } - JPanel otherPanel = new JPanel(); - otherPanel.setLayout(new BorderLayout()); - otherPanel.add(other,BorderLayout.WEST); - otherPanel.add(otherTxt,BorderLayout.CENTER); path.add(desktopPath); - path.add(desktop); - path.add(oneDrive); - path.add(otherPanel); //配置后缀 JPanel methodPanel = new JPanel(); methodPanel.setLayout(new BorderLayout()); @@ -94,9 +74,6 @@ public CollationPanel() throws IOException { methodSave.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - if (!desktop.isSelected() && !oneDrive.isSelected() && !other.isSelected()) { - JOptionPane.showMessageDialog(null,"选择一个桌面路径","错误",JOptionPane.ERROR_MESSAGE); - } else { Map map = System.getenv(); String userName = map.get("USERNAME"); File folderPath = new File("C:\\Users\\" + userName + "\\.DesktopAide\\collation"); @@ -111,39 +88,15 @@ public void mouseClicked(MouseEvent e) { throw new RuntimeException(ex); } } - if (desktop.isSelected()) { - FileOutputStream fileOutputStream; - try { - fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write(desktop.getText().getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - if (oneDrive.isSelected()) { FileOutputStream fileOutputStream; try { fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write(oneDrive.getText().getBytes(StandardCharsets.UTF_8)); + fileOutputStream.write(getDesktopPath.getBytes(StandardCharsets.UTF_8)); fileOutputStream.flush(); fileOutputStream.close(); } catch (IOException ex) { throw new RuntimeException(ex); } - } - if (other.isSelected()) { - FileOutputStream fileOutputStream; - try { - fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write(otherTxt.getText().getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } filePath = new File(folderPath + "\\data.da"); if(!filePath.exists()){ try { @@ -152,7 +105,6 @@ public void mouseClicked(MouseEvent e) { throw new RuntimeException(ex); } } - FileOutputStream fileOutputStream; try { fileOutputStream = new FileOutputStream(filePath); fileOutputStream.write(methodArea.getText().getBytes(StandardCharsets.UTF_8)); @@ -162,7 +114,6 @@ public void mouseClicked(MouseEvent e) { throw new RuntimeException(ex); } JOptionPane.showMessageDialog(null,"保存成功!","成功!",JOptionPane.PLAIN_MESSAGE); - } } }); JButton methodClean = new JButton("清空"); diff --git a/src/main/java/EN/Function/Collation/Collation.java b/src/main/java/EN/Function/Collation/Collation.java deleted file mode 100644 index 7d3cbb5..0000000 --- a/src/main/java/EN/Function/Collation/Collation.java +++ /dev/null @@ -1,86 +0,0 @@ -package EN.Function.Collation; - -import java.io.*; -import java.util.Map; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -@SuppressWarnings("ResultOfMethodCallIgnored") -public class Collation { - static String name; - static String data; - static void readAppointedLineNumber(File sourceFile) - throws IOException { - FileReader in = new FileReader(sourceFile); - LineNumberReader reader = new LineNumberReader(in); - String s = ""; - int lines = 0; - while (s != null) { - lines++; - s = reader.readLine(); - if((lines - 1) == 0) { - data = s; - } - } - reader.close(); - in.close(); - } - - public static void findEndsWith(File file, String sword) throws IOException { - //将父文件下的所有文件夹以及文件存入File[]中 - File[] files = file.listFiles(); - //遍历所有文件夹以及文件 - assert files != null; - for(File i : files) { - //判断是否是文件夹 - if(i.isDirectory()) { - //是文件夹,递归 - //findEndsWith(i,sword); - }else { - //是文件,判断是否是以.后缀名结尾 - if(i.getPath().endsWith(sword)) { - Map map = System.getenv(); - String userName = map.get("USERNAME"); - File folderPath = new File("C:\\Users\\"+userName+"\\.DesktopAide\\collation"); - File filePath = new File(folderPath+"\\path.da"); - readAppointedLineNumber(filePath); - File doc = new File(data+"\\"+name+"\\"+i.getName()); - File docp = new File(i.getPath()); - docp.renameTo(doc); - } - - } - } - } - public static void Collation() throws IOException { - BufferedReader reader; - Map map = System.getenv(); - String userName = map.get("USERNAME"); - File folderPath = new File("C:\\Users\\"+userName+"\\.DesktopAide\\collation"); - File filePath = new File(folderPath+"\\path.da"); - readAppointedLineNumber(filePath); - try { - reader = new BufferedReader(new FileReader( - folderPath+"\\data.da")); - String line = reader.readLine(); - while (line != null) { - int a = line.indexOf(" "); - name = line.substring(0,a); - String sword = line.substring(a+1); - File desktopFolder = new File(data+"\\"+name); - if (!desktopFolder.exists()){ - desktopFolder.mkdirs(); - } - findEndsWith(new File(data),sword); - // read next line - line = reader.readLine(); - } - reader.close(); - } catch (IOException e) { - e.printStackTrace(); - } - - } -} diff --git a/src/main/java/EN/Function/Growth/Growth.java b/src/main/java/EN/Function/Growth/Growth.java deleted file mode 100644 index f0fac9a..0000000 --- a/src/main/java/EN/Function/Growth/Growth.java +++ /dev/null @@ -1,50 +0,0 @@ -package EN.Function.Growth; - -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.util.Map; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -@SuppressWarnings("ResultOfMethodCallIgnored") -public class Growth { - static String result; - static void readAppointedLineNumber(File sourceFile, int lineNumber) - throws IOException { - FileReader in = new FileReader(sourceFile); - LineNumberReader reader = new LineNumberReader(in); - String s = ""; - int lines = 0; - while (s != null) { - lines++; - s = reader.readLine(); - if((lines - lineNumber) == 0) { - result = s; - } - } - reader.close(); - in.close(); - } - public String growth() throws IOException { - - Map map = System.getenv(); - String userName = map.get("USERNAME"); - File folderPath = new File("C:\\Users\\"+userName+"\\.DesktopAide\\growth"); - File filePath = new File(folderPath+"\\growth.da"); - if(!folderPath.exists()) { - folderPath.mkdirs(); - } - if(!filePath.exists()){ - filePath.createNewFile(); - FileOutputStream fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write("0".getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } - int needReadLine = 1; - readAppointedLineNumber(filePath,needReadLine); - return result; - } -} diff --git a/src/main/java/EN/Function/Puppet/Puppet.java b/src/main/java/EN/Function/Puppet/Puppet.java deleted file mode 100644 index 106b6eb..0000000 --- a/src/main/java/EN/Function/Puppet/Puppet.java +++ /dev/null @@ -1,23 +0,0 @@ -package EN.Function.Puppet; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class Puppet extends JFrame { - public Puppet(){ - this.setSize(250,180); - ImageIcon puppetImage = new ImageIcon("Icon/Function/Puppet/1.png"); - JLabel puppet = new JLabel(puppetImage); - this.add(puppet); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setUndecorated(true); - this.setBackground(new Color(0, 0, 0, 0)); - this.setType(Type.UTILITY); - this.setAlwaysOnTop(true); - } - } diff --git a/src/main/java/EN/Function/Puppet/PuppetRun.java b/src/main/java/EN/Function/Puppet/PuppetRun.java deleted file mode 100644 index f99e0a8..0000000 --- a/src/main/java/EN/Function/Puppet/PuppetRun.java +++ /dev/null @@ -1,23 +0,0 @@ -package EN.Function.Puppet; - -import java.awt.*; - -import static CN.UI.FunctionPanel.puppetPanel.puppet; - -/** - * @author chenpuhao - * @version 3.2.x - * @Date 2023/2/4 - */ -public class PuppetRun extends Thread{ - public static boolean exit = false; - public void run(){ - while (!exit){ - puppet.setVisible(true); - PointerInfo pInfo = MouseInfo.getPointerInfo(); - Point p = pInfo.getLocation(); - puppet.setLocation((int) p.getX()-110, (int) p.getY()); - } - puppet.setVisible(false); - } -} diff --git a/src/main/java/EN/Function/Update/CheckUpdate.java b/src/main/java/EN/Function/Update/CheckUpdate.java deleted file mode 100644 index d2317bc..0000000 --- a/src/main/java/EN/Function/Update/CheckUpdate.java +++ /dev/null @@ -1,57 +0,0 @@ -package EN.Function.Update; - -import java.io.*; -import java.net.URL; - -/** - * @author chenpuhao - * @Date 2023/2/6 - */ -public class CheckUpdate { - - private static void downloadUsingStream(String urlStr, String file) throws IOException{ - URL url = new URL(urlStr); - BufferedInputStream bis = new BufferedInputStream(url.openStream()); - FileOutputStream fis = new FileOutputStream(file); - byte[] buffer = new byte[1024]; - int count=0; - while((count = bis.read(buffer,0,1024)) != -1) - { - fis.write(buffer, 0, count); - } - fis.close(); - bis.close(); - } - static String result; - static void readAppointedLineNumber(File sourceFile) - throws IOException { - FileReader in = new FileReader(sourceFile); - LineNumberReader reader = new LineNumberReader(in); - String s = ""; - int lines = 0; - while (s != null) { - lines++; - s = reader.readLine(); - if((lines - 1) == 0) { - result = s; - } - } - reader.close(); - in.close(); - } - - public String CheckUpdate() throws IOException { - File file = new File("update.txt"); - if(!file.exists()){ - file.createNewFile(); - } - downloadUsingStream("https://desktopaide.chenpuhao.me/update.txt",file.toString()); - readAppointedLineNumber(file); - file.delete(); - if(result.equals("3.4.1")){ - result = "true"; - } - return result; - } - } - diff --git a/src/main/java/EN/Function/Update/Update.java b/src/main/java/EN/Function/Update/Update.java deleted file mode 100644 index c468df6..0000000 --- a/src/main/java/EN/Function/Update/Update.java +++ /dev/null @@ -1,120 +0,0 @@ -package EN.Function.Update; - -import javax.net.ssl.*; -import javax.swing.*; -import java.awt.*; -import java.io.*; -import java.net.URI; -import java.net.URL; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; - -/** - * @author chenpuhao - * @Date 2023/2/6 - */ -public class Update { - private static void downloadUsingStream(String urlStr, String file) throws IOException{ - URL url = new URL(urlStr); - BufferedInputStream bis = new BufferedInputStream(url.openStream()); - FileOutputStream fis = new FileOutputStream(file); - byte[] buffer = new byte[10240000]; - int count=0; - while((count = bis.read(buffer,0,10240000)) != -1) - { - fis.write(buffer, 0, count); - } - fis.close(); - bis.close(); - } - public static byte[] readInputStream(InputStream inputStream) throws IOException { - byte[] buffer = new byte[10240]; - int len = 0; - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - while((len = inputStream.read(buffer)) != -1) { - bos.write(buffer, 0, len); - } - bos.close(); - return bos.toByteArray(); - } - public static void trustAllHttpsCertificates() throws Exception { - TrustManager[] trustAllCerts = new TrustManager[1]; - TrustManager tm = new miTM(); - trustAllCerts[0] = tm; - SSLContext sc = SSLContext.getInstance("SSL"); - sc.init(null, trustAllCerts, null); - HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); - } - - static class miTM implements TrustManager,X509TrustManager { - public X509Certificate[] getAcceptedIssuers() { - return null; - } - - public boolean isServerTrusted(X509Certificate[] certs) { - return true; - } - - public boolean isClientTrusted(X509Certificate[] certs) { - return true; - } - - public void checkServerTrusted(X509Certificate[] certs, String authType) - throws CertificateException { - return; - } - - public void checkClientTrusted(X509Certificate[] certs, String authType) throws CertificateException{ - return; - } - } - - /** - * 忽略HTTPS请求的SSL证书,必须在openConnection之前调用 - * @throws Exception - */ - public static void ignoreSsl() throws Exception{ - HostnameVerifier hv = new HostnameVerifier() { - public boolean verify(String urlHostName, SSLSession session) { - return true; - } - }; - trustAllHttpsCertificates(); - HttpsURLConnection.setDefaultHostnameVerifier(hv); - } - private static void browse2(String url) throws Exception { - Desktop desktop = Desktop.getDesktop(); - if (Desktop.isDesktopSupported() && desktop.isSupported(Desktop.Action.BROWSE)) { - URI uri = new URI(url); - desktop.browse(uri); - } - } - - public Update() throws Exception { - Update.ignoreSsl(); - System.setProperty("https.protocols", "TLSv1.2,TLSv1.1,SSLv3"); - CheckUpdate checkUpdate = new CheckUpdate(); - String result = checkUpdate.CheckUpdate(); - File filePath = new File("download"); - if(!filePath.exists()){ - filePath.mkdirs(); - } - if(!result.equals("true")){ - File file = new File("download/DesktopAide-en-"+result+"-beta-setup.exe"); - if(!file.exists()){ - file.createNewFile(); - } - int n = JOptionPane.showConfirmDialog(null,"If a version update is detected, select Yes to use the software to download the installation package, the estimated time is 15-20min, otherwise jump to the official website to download","A version update is available",JOptionPane.YES_NO_OPTION); - if(n == 0) { - - downloadUsingStream("https://github.com/chenpuhao/DesktopAide/releases/download/V" + result + "/DesktopAide-en-" + result + "-setup.exe", String.valueOf(file)); - JOptionPane.showMessageDialog(null, "The download is complete and the installer will open for you later", "The download is complete", JOptionPane.PLAIN_MESSAGE); - Desktop.getDesktop().open(file); - System.exit(0); - }else{ - browse2("https://desktopaide.chenpuhao.me/download.html"); - System.exit(0); - } - } - } -} diff --git a/src/main/java/EN/README-EN.md b/src/main/java/EN/README-EN.md deleted file mode 100644 index eb4c331..0000000 --- a/src/main/java/EN/README-EN.md +++ /dev/null @@ -1,94 +0,0 @@ -
- -

- -Logo - - -

DesktopAide

-

-Welcome to DesktopAide -
- Participate in our research -
- website -
- download the installation package -, - alternate download channel -, - Report bugs -

- -![](https://img.shields.io/github/license/chenpuhao/desktopaide) -![](https://img.shields.io/github/languages/count/chenpuhao/DesktopAide) -![](https://img.shields.io/github/languages/top/chenpuhao/desktopaide) -![](https://img.shields.io/github/languages/code-size/chenpuhao/desktopaide) -![](https://img.shields.io/github/repo-size/chenpuhao/desktopaide) -![](https://img.shields.io/github/downloads/chenpuhao/desktopaide/total) -![](https://img.shields.io/github/stars/chenpuhao/desktopaide) -![](https://img.shields.io/github/watchers/chenpuhao/desktopaide) -![](https://img.shields.io/github/last-commit/chenpuhao/desktopaide) -![](https://img.shields.io/github/release-date/chenpuhao/desktopaide) - -Pay attention -=== -Run the program in administrator mode - -directory -=== - -* [Pay attention](#pay-attention) -* [directory](#directory) - * [DesktopAide Introduction](#desktopaide-introduction) - * [Copyright description](#copyright-description) - * [Known problem](#known-problem) - * [Attention](#attention) - * [Donation](#donation) - * [Future plans](#future-plans) - * [Release version](#release-version) - * [V3.4.0 Updated](#v340-updated) - * [V3.3.1 update](#v331-update) - * [V3.3.0 Updated](#v330-updated) - - - -## DesktopAide Introduction -DeskAide is an open source Windows-based desktop program -It can help you organize your desktop, find files, especially suitable for school teachers - -### Copyright description -The project is licensed under the GPL-3.0 LICENSE. For details, see [LICENSE](LICENSE). -### Known problem -1. ~~Collate The default type is not available on the desktop. Please use custom type~~ -### Attention -1. If you can help me modify the code, please use IntelliJ IDEA, thank you! No IDEA? Let me go to download] [(https://www.jetbrains.com/zh-cn/idea/download/) -2. The Java development front end will be abandoned and C# will be used (as soon as the author remembers) -3. ~~So far we do not provide English installation package, if necessary, please clone to the local run~~ - -### Donation -If you like this product, please in [aifadian] (https://afdian.net/a/desktopaide) power for me, thank you - - -### Future plans -- [x] Completion of Version 3 (Completion date :2022/12/01) -- [x] Fix the default mode for Collation (completion date :2022/12/26) -- [x] Complete the new UI of the Organize desktop function (Completion date :2023/2/4) -- [ ] ~~Develop in C# (completion date :)~~ - -## Release version -### V3.4.0 Updated -1. Greatly modify the UI -2. Download the link to Release - - -### V3.3.1 update -1. Fix the default type is unavailable on the desktop and add an English page -2. [Cn](https://github.com/chenpuhao/DesktopAide/releases/download/V3.3.1/DesktopAide-withjre-3.3.1-cn-setup.exe) -3. [en](https://github.com/chenpuhao/DesktopAide/releases/download/V3.3.1/DesktopAide-withjre-3.3.1-en-setup.exe) - -### V3.3.0 Updated -1. New UI -2. Optimize most features -3. Disable the chat function -4. [download link ](https://github.com/chenpuhao/DesktopAide/releases/download/DesktopAide/DesktopAide-withjre-3.3-setup.exe) diff --git a/src/main/java/EN/UI/FunctionPanel/CollationPanel.java b/src/main/java/EN/UI/FunctionPanel/CollationPanel.java deleted file mode 100644 index 41701cb..0000000 --- a/src/main/java/EN/UI/FunctionPanel/CollationPanel.java +++ /dev/null @@ -1,184 +0,0 @@ -package EN.UI.FunctionPanel; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.util.Map; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -@SuppressWarnings("ResultOfMethodCallIgnored") -public class CollationPanel extends JPanel { - static String data; - static void readAppointedLineNumber(File sourceFile) - throws IOException { - FileReader in = new FileReader(sourceFile); - LineNumberReader reader = new LineNumberReader(in); - String s = ""; - int lines = 0; - while (s != null) { - lines++; - s = reader.readLine(); - if((lines - 1) == 0) { - data = s; - } - } - reader.close(); - in.close(); - } - public CollationPanel() throws IOException { - this.setLayout(new BorderLayout()); - //定义组件 - //桌面路径 - JPanel path = new JPanel(); - path.setLayout(new GridLayout(4,1)); - JLabel desktopPath = new JLabel("Select your desktop path:"); - ButtonGroup pathButtonGroup = new ButtonGroup(); - Map map = System.getenv(); - String userName = map.get("USERNAME"); - JRadioButton desktop = new JRadioButton("C:\\Users\\" + userName + "\\Desktop"); - JRadioButton oneDrive = new JRadioButton("C:\\Users\\" + userName + "\\OneDrive\\Desktop"); - JRadioButton other = new JRadioButton("other:"); - pathButtonGroup.add(desktop); - pathButtonGroup.add(oneDrive); - pathButtonGroup.add(other); - JTextField otherTxt = new JTextField(); - File folderPath = new File("C:\\Users\\" + userName + "\\.DesktopAide\\collation"); - File filePath = new File(folderPath + "\\path.da"); - if(filePath.exists()) { - readAppointedLineNumber(filePath); - if (data.equals("C:\\Users\\" + userName + "\\Desktop")) { - desktop.setSelected(true); - } else if (data.equals("C:\\Users\\" + userName + "\\OneDrive\\Desktop")) { - oneDrive.setSelected(true); - } else { - other.setSelected(true); - otherTxt.setText(data); - } - } - JPanel otherPanel = new JPanel(); - otherPanel.setLayout(new BorderLayout()); - otherPanel.add(other,BorderLayout.WEST); - otherPanel.add(otherTxt,BorderLayout.CENTER); - path.add(desktopPath); - path.add(desktop); - path.add(oneDrive); - path.add(otherPanel); - //配置后缀 - JPanel methodPanel = new JPanel(); - methodPanel.setLayout(new BorderLayout()); - JLabel method = new JLabel("The format of file suffix \n folder name [space] suffix, for example, ppt .ppt"); - JTextArea methodArea = new JTextArea(); - filePath = new File(folderPath + "\\data.da"); - if (filePath.exists()){ - long fileLengthLong = filePath.length(); - byte[] fileContent = new byte[(int) fileLengthLong]; - try { - FileInputStream inputStream = new FileInputStream(filePath); - inputStream.read(fileContent); - inputStream.close(); - } catch (Exception e) { - // TODO: handle exception - } - String string = new String(fileContent); - methodArea.setText(string); - } - JScrollPane methodJSP = new JScrollPane(methodArea); - JPanel methodCheck = new JPanel(); - methodCheck.setLayout(new GridLayout(1,2)); - JButton methodSave = new JButton("save"); - methodSave.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - if (!desktop.isSelected() && !oneDrive.isSelected() && !other.isSelected()) { - JOptionPane.showMessageDialog(null,"Select a desktop path "," Error",JOptionPane.ERROR_MESSAGE); - } else { - Map map = System.getenv(); - String userName = map.get("USERNAME"); - File folderPath = new File("C:\\Users\\" + userName + "\\.DesktopAide\\collation"); - File filePath = new File(folderPath + "\\path.da"); - if(!folderPath.exists()){ - folderPath.mkdirs(); - } - if (!filePath.exists()) { - try { - filePath.createNewFile(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - if (desktop.isSelected()) { - FileOutputStream fileOutputStream; - try { - fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write(desktop.getText().getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - if (oneDrive.isSelected()) { - FileOutputStream fileOutputStream; - try { - fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write(oneDrive.getText().getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - if (other.isSelected()) { - FileOutputStream fileOutputStream; - try { - fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write(otherTxt.getText().getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - filePath = new File(folderPath + "\\data.da"); - if(!filePath.exists()){ - try { - filePath.createNewFile(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - FileOutputStream fileOutputStream; - try { - fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write(methodArea.getText().getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - JOptionPane.showMessageDialog(null,"Save successfully!" ," Success!",JOptionPane.PLAIN_MESSAGE); - } - } - }); - JButton methodClean = new JButton("clean"); - methodClean.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - methodArea.setText(""); - } - }); - methodCheck.add(methodSave); - methodCheck.add(methodClean); - methodPanel.add(method,BorderLayout.NORTH); - methodPanel.add(methodJSP,BorderLayout.CENTER); - methodPanel.add(methodCheck,BorderLayout.SOUTH); - this.add(path,BorderLayout.NORTH); - this.add(methodPanel,BorderLayout.CENTER); - } -} diff --git a/src/main/java/EN/UI/FunctionPanel/FindPanel.java b/src/main/java/EN/UI/FunctionPanel/FindPanel.java deleted file mode 100644 index 862048d..0000000 --- a/src/main/java/EN/UI/FunctionPanel/FindPanel.java +++ /dev/null @@ -1,86 +0,0 @@ -package EN.UI.FunctionPanel; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * @author chenpuhao - * @version 3.2.x - * @Date 2023/2/4 - */ -public class FindPanel extends JPanel { - static JTextField pathField = new JTextField(); - static JTextField nameField = new JTextField(); - static File file = new File(pathField.getText()); - static String keyWord = nameField.getText(); - public static List searchFiles(File folder, final String keyword) { - List result = new ArrayList<>(); - if (folder.isFile()) - result.add(folder); - File[] subFolders = folder.listFiles(file -> { - if (file.isDirectory()) { - return true; - } - return file.getName().toLowerCase().contains(keyword); - }); - if (subFolders != null) { - for (File file : subFolders) { - if (file.isFile()) { - // 如果是文件则将文件添加到结果列表中 - result.add(file); - } else { - // 如果是文件夹,则递归调用本方法,然后把所有的文件加到结果列表中 - result.addAll(searchFiles(file, keyword)); - } - } - } - return result; - } - public FindPanel(){ - this.setLayout(new BorderLayout()); - Map map = System.getenv(); - String userName = map.get("USERNAME"); - JLabel pathLabel = new JLabel("The directory to look for,such as C:\\Users\\" + userName + "\\Desktop"); - JLabel fileLabel = new JLabel("The keyword of the file name to look for, such as DesktopAide"); - JButton check = new JButton("determine"); - check.addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent e) { - file = new File(pathField.getText()); - File file3 = new File(file.toURI()); - keyWord = nameField.getText(); - List files = searchFiles(file3, keyWord); - StringBuilder filePath = new StringBuilder(); - for (File file : files) { - File file1 = new File(file.getAbsolutePath()); - filePath.append("\n").append(file1); - try { - Desktop.getDesktop().open(file1); - } catch (IOException e1) { - - e1.printStackTrace(); - } - } - if (filePath.toString().equals("")) { - JOptionPane.showMessageDialog(null, "No file with this keyword found in this directory ", "search complete!", JOptionPane.ERROR_MESSAGE); - } else { - JOptionPane.showMessageDialog(null, "The following file is found :" + filePath, "search is complete!", JOptionPane.PLAIN_MESSAGE); - } - } - }); - JPanel findPanel = new JPanel(); - findPanel.setLayout(new GridLayout (5 , 1 )); - findPanel.add(pathLabel); - findPanel.add(pathField); - findPanel.add(fileLabel); - findPanel.add(nameField); - findPanel.add(check); - this.add(findPanel); - } -} diff --git a/src/main/java/EN/UI/FunctionPanel/puppetPanel.java b/src/main/java/EN/UI/FunctionPanel/puppetPanel.java deleted file mode 100644 index 9a213da..0000000 --- a/src/main/java/EN/UI/FunctionPanel/puppetPanel.java +++ /dev/null @@ -1,94 +0,0 @@ -package EN.UI.FunctionPanel; - -import EN.Function.Puppet.Puppet; -import EN.Function.Puppet.PuppetRun; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.util.Map; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -@SuppressWarnings("ResultOfMethodCallIgnored") -public class puppetPanel extends JPanel { - public static JRadioButton yes = new JRadioButton("open"); - static String result; - public static PuppetRun puppetRun ; - - static void readAppointedLineNumber(File sourceFile, int lineNumber) - throws IOException { - FileReader in = new FileReader(sourceFile); - LineNumberReader reader = new LineNumberReader(in); - String s = ""; - int lines = 0; - while (s != null) { - lines++; - s = reader.readLine(); - if((lines - lineNumber) == 0) { - result = s; - } - } - reader.close(); - in.close(); - } - public static Puppet puppet = new Puppet(); - public puppetPanel() throws IOException { - Map map = System.getenv(); - String userName = map.get("USERNAME"); - File folderPath = new File("C:\\Users\\"+userName+"\\.DesktopAide\\puppet"); - File filePath = new File(folderPath+"\\puppet.da"); - if(!folderPath.exists()) { - folderPath.mkdirs(); - } - if(!filePath.exists()){ - filePath.createNewFile(); - FileOutputStream fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write("false".getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } - //定义组件 - JLabel introduce = new JLabel("Turn on or off the mouse puppet function"); - ButtonGroup buttonGroup = new ButtonGroup(); - JRadioButton no = new JRadioButton("Shut down"); - buttonGroup.add(yes); - buttonGroup.add(no); - JPanel buttonPanel = new JPanel(); - buttonPanel.setLayout(new GridLayout(1,2)); - buttonPanel.add(yes); - buttonPanel.add(no); - JButton save = new JButton("save"); - - save.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - - if(yes.isSelected()){ - PuppetRun.exit = false; - puppetRun = new PuppetRun(); - puppetRun.start(); - }else{ - PuppetRun.exit = true; - - } - } - }); - this.setLayout(new GridLayout(3,1)); - this.add(introduce); - this.add(buttonPanel); - this.add(save); - int line = 1; - readAppointedLineNumber(filePath,line); - if(result.equals("true")){ - yes.setSelected(true); - }else{ - no.setSelected(true); - } - } -} diff --git a/src/main/java/EN/UI/FunctionUI/MoreUI.java b/src/main/java/EN/UI/FunctionUI/MoreUI.java deleted file mode 100644 index 4223295..0000000 --- a/src/main/java/EN/UI/FunctionUI/MoreUI.java +++ /dev/null @@ -1,98 +0,0 @@ -package EN.UI.FunctionUI; - -import EN.UI.FunctionPanel.CollationPanel; -import EN.UI.FunctionPanel.FindPanel; -import EN.UI.FunctionPanel.puppetPanel; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.IOException; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class MoreUI extends JFrame { - public MoreUI(){ - //获取桌面大小 - Dimension getScreenSize = Toolkit.getDefaultToolkit().getScreenSize(); - //基本设置 - this.setBounds((getScreenSize.width-600)/2,(getScreenSize.height-500)/2,600,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - JPanel moreUIPanel = new JPanel(); - moreUIPanel.setLayout(new BorderLayout()); - ImageIcon title = new ImageIcon("Icon/MoreUI/favicon.png"); - this.setIconImage(title.getImage()); - JScrollPane jsp = new JScrollPane(); - JPanel leftSetting = new JPanel(); - jsp.setViewportView(leftSetting); - leftSetting.setLayout(new GridLayout(3,1)); - //添加整理的设置 - ImageIcon collationImage = new ImageIcon("Icon/MoreUI/collation.png"); - JButton collation = new JButton("Collate file Settings"); - collation.setIcon(collationImage); - collation.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - moreUIPanel.removeAll(); - moreUIPanel.setLayout(new BorderLayout()); - moreUIPanel.add(leftSetting,BorderLayout.WEST); - CollationPanel collationPanel; - try { - collationPanel = new CollationPanel(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - moreUIPanel.add(collationPanel,BorderLayout.CENTER); - MoreUI.this.revalidate(); - MoreUI.this.repaint(); - } - }); - leftSetting.add(collation); - //添加QQ机器人设置 - ImageIcon qqImage = new ImageIcon("Icon/MoreUI/hand.png"); - JButton qq = new JButton("Mouse puppet"); - qq.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - moreUIPanel.removeAll(); - moreUIPanel.setLayout(new BorderLayout()); - moreUIPanel.add(leftSetting,BorderLayout.WEST); - puppetPanel handPanel; - try { - handPanel = new puppetPanel(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - moreUIPanel.add(handPanel,BorderLayout.CENTER); - MoreUI.this.revalidate(); - MoreUI.this.repaint(); - } - }); - qq.setIcon(qqImage); - leftSetting.add(qq); - //查找文件 - ImageIcon searchImage = new ImageIcon("Icon/MoreUI/search.png"); - JButton search = new JButton("Find file"); - search.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - moreUIPanel.removeAll(); - moreUIPanel.setLayout(new BorderLayout()); - moreUIPanel.add(leftSetting,BorderLayout.WEST); - FindPanel findPanel; - findPanel = new FindPanel(); - moreUIPanel.add(findPanel,BorderLayout.CENTER); - MoreUI.this.revalidate(); - MoreUI.this.repaint(); - } - }); - search.setIcon(searchImage); - leftSetting.add(search); - moreUIPanel.add(jsp,BorderLayout.WEST); - this.add(moreUIPanel); - } -} diff --git a/src/main/java/EN/UI/FunctionUI/UserUI.java b/src/main/java/EN/UI/FunctionUI/UserUI.java deleted file mode 100644 index 9831ef3..0000000 --- a/src/main/java/EN/UI/FunctionUI/UserUI.java +++ /dev/null @@ -1,151 +0,0 @@ -package EN.UI.FunctionUI; - -import EN.UI.IntroduceUI.*; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.*; -import java.util.Map; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UserUI extends JFrame { - static String result; - static void readAppointedLineNumber(File sourceFile) - throws IOException { - FileReader in = new FileReader(sourceFile); - LineNumberReader reader = new LineNumberReader(in); - String s = ""; - int lines = 0; - while (s != null) { - lines++; - s = reader.readLine(); - if((lines - 1) == 0) { - result = s; - } - } - reader.close(); - in.close(); - } - static int getTotalLines(File file) throws IOException { - FileReader in = new FileReader(file); - LineNumberReader reader = new LineNumberReader(in); - String s = reader.readLine(); - int lines = 0; - while (s != null) { - lines++; - s = reader.readLine(); - } - reader.close(); - in.close(); - return lines; - } - public UserUI() throws IOException { - //获取屏幕大小 - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width - 300) / 2, (getDesktopSize.height - 500) / 2, 300, 500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setLayout(new BorderLayout()); - this.setResizable(false); - this.setType(Type.UTILITY); - //用户姓名 - Map map = System.getenv(); - String userName = map.get("USERNAME"); - File folderPath = new File("C:\\Users\\" + userName + "\\.DesktopAide\\user"); - File filePath = new File(folderPath + "\\user.da"); - readAppointedLineNumber(filePath); - JLabel UserName = new JLabel("Welcome:"+result); - JLabel userData = new JLabel("You have planted the following plants so far (click for more information)"); - JPanel jp = new JPanel(); - jp.setLayout(new GridLayout(2,1)); - jp.add(UserName); - jp.add(userData); - filePath = new File(folderPath + "\\success.da"); - int total = getTotalLines(filePath); - JScrollPane jsp = new JScrollPane(); - jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - JPanel success = new JPanel(); - jsp.setViewportView(success); - success.setLayout(new GridLayout(total,1)); - BufferedReader reader; - try { - reader = new BufferedReader(new FileReader( - filePath)); - String line = reader.readLine(); - while (line != null) { - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/"+line); - JButton jb = new JButton(img); - success.add(jb); - String finalLine = line; - jb.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - switch (finalLine) { - case "0.png" -> { - UI0 ui = new UI0(); - ui.setVisible(true); - } - case "1.png" -> { - UI1 ui = new UI1(); - ui.setVisible(true); - } - case "2.png" -> { - UI2 ui = new UI2(); - ui.setVisible(true); - } - case "3.png" -> { - UI3 ui = new UI3(); - ui.setVisible(true); - } - case "4.png" -> { - UI4 ui = new UI4(); - ui.setVisible(true); - } - case "5.png" -> { - UI5 ui = new UI5(); - ui.setVisible(true); - } - case "6.png" -> { - UI6 ui = new UI6(); - ui.setVisible(true); - } - case "7.png" -> { - UI7 ui = new UI7(); - ui.setVisible(true); - } - case "8.png" -> { - UI8 ui = new UI8(); - ui.setVisible(true); - } - case "9.png" -> { - UI9 ui = new UI9(); - ui.setVisible(true); - } - case "10.png" -> { - UI10 ui = new UI10(); - ui.setVisible(true); - } - case "11.png" -> { - UI11 ui = new UI11(); - ui.setVisible(true); - } - } - } - }); - // read next line - line = reader.readLine(); - } - reader.close(); - } catch (IOException e) { - e.printStackTrace(); - } - this.add(jp,BorderLayout.NORTH); - this.add(jsp); - } - - -} diff --git a/src/main/java/EN/UI/IntroduceUI/UI0.java b/src/main/java/EN/UI/IntroduceUI/UI0.java deleted file mode 100644 index e60b287..0000000 --- a/src/main/java/EN/UI/IntroduceUI/UI0.java +++ /dev/null @@ -1,29 +0,0 @@ -package EN.UI.IntroduceUI; -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI0 extends JFrame { - public UI0(){ - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this. setTitle ("detailed description -- cactus"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/0.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce =new JLabel ("a cactus with good growth. The thorn on its body resists external attack"); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} \ No newline at end of file diff --git a/src/main/java/EN/UI/IntroduceUI/UI1.java b/src/main/java/EN/UI/IntroduceUI/UI1.java deleted file mode 100644 index 61c94a4..0000000 --- a/src/main/java/EN/UI/IntroduceUI/UI1.java +++ /dev/null @@ -1,29 +0,0 @@ -package EN.UI.IntroduceUI; -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI1 extends JFrame { - public UI1(){ - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this. setTitle ("Detailed description -- four-leaf clover"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/1.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce=new JLabel ("The four-leaf clover symbolizes luck. Maybe there will be good luck today?"); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} \ No newline at end of file diff --git a/src/main/java/EN/UI/IntroduceUI/UI10.java b/src/main/java/EN/UI/IntroduceUI/UI10.java deleted file mode 100644 index 54d50f1..0000000 --- a/src/main/java/EN/UI/IntroduceUI/UI10.java +++ /dev/null @@ -1,31 +0,0 @@ -package EN.UI.IntroduceUI; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI10 extends JFrame { - public UI10(){ - - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this.setTitle("Details -- Rose"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/10.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce = new JLabel("Bright roses, Valentine's Day must-have artifact"); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} diff --git a/src/main/java/EN/UI/IntroduceUI/UI11.java b/src/main/java/EN/UI/IntroduceUI/UI11.java deleted file mode 100644 index b38f9bc..0000000 --- a/src/main/java/EN/UI/IntroduceUI/UI11.java +++ /dev/null @@ -1,31 +0,0 @@ -package EN.UI.IntroduceUI; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI11 extends JFrame { - public UI11(){ - - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this.setTitle("Detailed description - ears of wheat"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/11.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce = new JLabel("Come with me to read: hoe Herday afternoon, sweat drip Wo......"); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} diff --git a/src/main/java/EN/UI/IntroduceUI/UI2.java b/src/main/java/EN/UI/IntroduceUI/UI2.java deleted file mode 100644 index ccb5097..0000000 --- a/src/main/java/EN/UI/IntroduceUI/UI2.java +++ /dev/null @@ -1,29 +0,0 @@ -package EN.UI.IntroduceUI; -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI2 extends JFrame { - public UI2(){ - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this. setTitle ("Detailed description -- corn"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/2.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce=new JLabel ("Golden corn, green oil shell, boiled or fried?"); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} \ No newline at end of file diff --git a/src/main/java/EN/UI/IntroduceUI/UI3.java b/src/main/java/EN/UI/IntroduceUI/UI3.java deleted file mode 100644 index f9440eb..0000000 --- a/src/main/java/EN/UI/IntroduceUI/UI3.java +++ /dev/null @@ -1,31 +0,0 @@ -package EN.UI.IntroduceUI; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI3 extends JFrame { - public UI3(){ - - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this.setTitle("Details -- eggplant"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/3.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce = new JLabel("Fat eggplant, its owner must have put a lot of effort"); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} diff --git a/src/main/java/EN/UI/IntroduceUI/UI4.java b/src/main/java/EN/UI/IntroduceUI/UI4.java deleted file mode 100644 index e43539d..0000000 --- a/src/main/java/EN/UI/IntroduceUI/UI4.java +++ /dev/null @@ -1,31 +0,0 @@ -package EN.UI.IntroduceUI; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI4 extends JFrame { - public UI4(){ - - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this.setTitle("Details -- grass"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/4.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce = new JLabel("Perhaps, it is a pot of grass......"); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} diff --git a/src/main/java/EN/UI/IntroduceUI/UI5.java b/src/main/java/EN/UI/IntroduceUI/UI5.java deleted file mode 100644 index a01fac2..0000000 --- a/src/main/java/EN/UI/IntroduceUI/UI5.java +++ /dev/null @@ -1,31 +0,0 @@ -package EN.UI.IntroduceUI; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI5 extends JFrame { - public UI5(){ - - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this.setTitle("Details -- Leaves"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/5.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce = new JLabel("This is no ordinary leaf, this is a leaf from Wang Wei's poem"); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} diff --git a/src/main/java/EN/UI/IntroduceUI/UI6.java b/src/main/java/EN/UI/IntroduceUI/UI6.java deleted file mode 100644 index f6c09f4..0000000 --- a/src/main/java/EN/UI/IntroduceUI/UI6.java +++ /dev/null @@ -1,31 +0,0 @@ -package EN.UI.IntroduceUI; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI6 extends JFrame { - public UI6(){ - - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this.setTitle("Details -- cabbage"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/6.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce = new JLabel("Plump cabbage, what can be in it?"); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} diff --git a/src/main/java/EN/UI/IntroduceUI/UI7.java b/src/main/java/EN/UI/IntroduceUI/UI7.java deleted file mode 100644 index dcb7aa9..0000000 --- a/src/main/java/EN/UI/IntroduceUI/UI7.java +++ /dev/null @@ -1,31 +0,0 @@ -package EN.UI.IntroduceUI; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI7 extends JFrame { - public UI7(){ - - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this.setTitle("Details -- Pumpkin"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/7.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce = new JLabel("This pumpkin would be great for a jack-o \'-lantern for Halloween"); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} diff --git a/src/main/java/EN/UI/IntroduceUI/UI8.java b/src/main/java/EN/UI/IntroduceUI/UI8.java deleted file mode 100644 index aa9a423..0000000 --- a/src/main/java/EN/UI/IntroduceUI/UI8.java +++ /dev/null @@ -1,31 +0,0 @@ -package EN.UI.IntroduceUI; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI8 extends JFrame { - public UI8(){ - - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this.setTitle("Details - Radish"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/8.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce = new JLabel("This radish is just a regular radish. Nothing to tell you about it"); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} diff --git a/src/main/java/EN/UI/IntroduceUI/UI9.java b/src/main/java/EN/UI/IntroduceUI/UI9.java deleted file mode 100644 index e41d0dd..0000000 --- a/src/main/java/EN/UI/IntroduceUI/UI9.java +++ /dev/null @@ -1,31 +0,0 @@ -package EN.UI.IntroduceUI; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI9 extends JFrame { - public UI9(){ - - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this.setTitle("Details -- tomatoes"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/9.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce = new JLabel("Scrambled eggs with tomatoes? What about eggs? Looking forward to the future ~"); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} diff --git a/src/main/java/EN/UI/Main.java b/src/main/java/EN/UI/Main.java deleted file mode 100644 index 4cbf953..0000000 --- a/src/main/java/EN/UI/Main.java +++ /dev/null @@ -1,156 +0,0 @@ -package EN.UI; - -import EN.Function.Update.Update; -import EN.Function.Collation.Collation; -import EN.Function.Growth.Growth; -import EN.UI.MainUI.HelloUI; -import EN.UI.MainUI.MainUI; -import com.formdev.flatlaf.FlatDarculaLaf; -import com.formdev.flatlaf.FlatDarkLaf; -import com.formdev.flatlaf.intellijthemes.FlatDarkFlatIJTheme; - -import javax.swing.*; -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.util.Map; -import java.util.Random; - -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ - -@SuppressWarnings({"ResultOfMethodCallIgnored", "InfiniteLoopStatement"}) -public class Main { - public static String readToString(String fileName) { - String encoding = "UTF-8"; - File file = new File(fileName); - long filelength = file.length(); - byte[] filecontent = new byte[(int) filelength]; - try { - FileInputStream in = new FileInputStream(file); - in.read(filecontent); - in.close(); - } catch (IOException e) { - e.printStackTrace(); - } - try { - return new String(filecontent, encoding); - } catch (UnsupportedEncodingException e) { - System.err.println("The OS does not support " + encoding); - e.printStackTrace(); - return null; - } - } - public static void main(String[] args) throws Exception { - //使用look and feel - FlatDarkLaf.setup(); - FlatDarculaLaf.setup(); - FlatDarkFlatIJTheme.setup(); - new Update(); - Map map = System.getenv(); - String userName = map.get("USERNAME"); - File folderPath = new File("C:\\Users\\" + userName + "\\.DesktopAide\\collation"); - File filePath = new File(folderPath + "\\path.da"); - if(!folderPath.exists()){ - folderPath.mkdirs(); - } - if (!filePath.exists()) { - try { - filePath.createNewFile(); - FileOutputStream fileOutputStream = new FileOutputStream(filePath); - String path = "C:\\Users\\" + userName + "\\Desktop"; - fileOutputStream.write(path.getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - folderPath = new File("C:\\Users\\"+userName+"\\.DesktopAide\\growth"); - filePath = new File(folderPath+"\\growth.da"); - if(!folderPath.exists()) { - folderPath.mkdirs(); - } - if(!filePath.exists()){ - filePath.createNewFile(); - FileOutputStream fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write("0".getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } - folderPath = new File("C:\\Users\\"+userName+"\\.DesktopAide\\puppet"); - filePath = new File(folderPath+"\\puppet.da"); - if(!folderPath.exists()) { - folderPath.mkdirs(); - } - if(!filePath.exists()){ - filePath.createNewFile(); - FileOutputStream fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write("false".getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } - folderPath = new File("C:\\Users\\" + userName + "\\.DesktopAide\\user"); - filePath = new File(folderPath + "\\user.da"); - if(!filePath.exists()){ - HelloUI helloUI = new HelloUI(); - helloUI.setVisible(true); - } - MainUI mainUI = new MainUI(); - mainUI.setVisible(true); - while (true) { - if(MainUI.isInCollation){ - Collation.Collation(); - } - //桌宠 - ImageIcon petImage; - Growth growth = new Growth(); - int growthInt = Integer.parseInt(growth.growth()); - if (growthInt == 100) { - folderPath = new File("Icon/MainUI/plant/success"); - File[] list = folderPath.listFiles(); - int fileCount = 0; - assert list != null; - for (File file : list) { - if (file.isFile()) { - fileCount++; - } - } - Random getSuccessPlant = new Random(); - int successPlantInt = getSuccessPlant.nextInt(fileCount-1); - petImage = new ImageIcon(folderPath+"/"+successPlantInt+".png"); - MainUI.tablePet.setIcon(petImage); - JOptionPane.showMessageDialog(null,"Congratulations on your successful planting. After closing this pop-up window, the next round of planting will be conducted. The planting record can be viewed in the user interface "," planting success",JOptionPane.PLAIN_MESSAGE,petImage); - File path = new File("C:\\Users\\"+userName+"\\.DesktopAide\\growth"); - filePath = new File(path+"\\growth.da"); - FileOutputStream fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write("0".getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - path = new File("C:\\Users\\"+userName+"\\.DesktopAide\\user"); - filePath = new File(path+"\\success.da"); - String result = readToString(String.valueOf(filePath)); - if(!(result ==null)) { - result = result + "\n" + successPlantInt + ".png"; - }else{ - result = successPlantInt + ".png"; - } - fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write(result.getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } else if (growthInt < 100 && growthInt >=50) { - petImage = new ImageIcon("Icon/MainUI/plant/growing/100of100.png"); - }else{ - petImage = new ImageIcon("Icon/MainUI/plant/growing/50of100.png"); - } - MainUI.tablePet.setIcon(petImage); - mainUI.revalidate(); - mainUI.repaint(); - Thread.sleep(500); - } - } - -} diff --git a/src/main/java/EN/UI/MainUI/HelloUI.java b/src/main/java/EN/UI/MainUI/HelloUI.java deleted file mode 100644 index 05d6ea3..0000000 --- a/src/main/java/EN/UI/MainUI/HelloUI.java +++ /dev/null @@ -1,127 +0,0 @@ -package EN.UI.MainUI; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.Map; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -@SuppressWarnings("ResultOfMethodCallIgnored") -public class HelloUI extends JFrame { - static int num = 1; - public HelloUI(){ - - //获取屏幕大小 - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-200)/2,300,200); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setLayout(new BorderLayout()); - //用户姓名 - JPanel panel1 = new JPanel(); - JLabel userNameLabel = new JLabel("Enter your nickname here and don't worry, you can modify it later"); - JTextField userNameField = new JTextField(); - panel1.setLayout(new GridLayout(2,1)); - panel1.add(userNameLabel); - panel1.add(userNameField); - this.add(panel1); - this.setResizable(false); - this.setType(Type.UTILITY); - //介绍 - JPanel panel2 = new JPanel(); - panel2.setLayout(new GridLayout(3,1)); - JLabel introduceUser = new JLabel("Welcome",JLabel.CENTER); - JLabel introduce = new JLabel("",JLabel.CENTER); - JLabel introduceNext = new JLabel("The following pages will introduce you to the main features of this program",JLabel.CENTER); - panel2.add(introduceUser); - panel2.add(introduce); - panel2.add(introduceNext); - //介绍1 - JPanel panel3 = new JPanel(); - JTextArea introduce1 = new JTextArea(" Believed? How could such a small window hold so much text\n" + - "Use the method to view the pdf file, in the Documents under the installation directory"); - panel3.setLayout(new BorderLayout()); - panel3.add(introduce1); - introduce1.setEditable(false); - introduce1.setLineWrap(true); - //下一页按钮 - JPanel nextPanel = new JPanel(); - nextPanel.setLayout(new GridLayout(1,2)); - JButton last = new JButton("Previous"); - JButton next = new JButton("Next"); - last.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - if(num == 2){ - HelloUI.this.remove(panel2); - HelloUI.this.add(panel1); - next.setText("Previous"); - HelloUI.this.revalidate(); - HelloUI.this.repaint(); - num --; - } - else if(num ==3){ - HelloUI.this.remove(panel3); - HelloUI.this.add(panel2); - next.setText("Previous"); - HelloUI.this.revalidate(); - HelloUI.this.repaint(); - num--; - } - } - }); - - next.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - if(num == 1){ - introduce.setText(userNameField.getText()); - HelloUI.this.remove(panel1); - HelloUI.this.add(panel2); - next.setText("Previous"); - HelloUI.this.revalidate(); - HelloUI.this.repaint(); - num ++; - } - else if(num == 2){ - HelloUI.this.remove(panel2); - HelloUI.this.add(panel3); - next.setText("finish"); - HelloUI.this.revalidate(); - HelloUI.this.repaint(); - num ++; - } - else{ - Map map = System.getenv(); - String userName = map.get("USERNAME"); - File folderPath = new File("C:\\Users\\" + userName + "\\.DesktopAide\\user"); - File filePath = new File(folderPath + "\\user.da"); - folderPath.mkdirs(); - try { - filePath.createNewFile(); - FileOutputStream fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write(userNameField.getText().getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - filePath = new File(folderPath + "\\success.da"); - filePath.createNewFile(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - HelloUI.this.setVisible(false); - } - } - }); - nextPanel.add(last); - nextPanel.add(next); - this.add(nextPanel,BorderLayout.SOUTH); - } - -} diff --git a/src/main/java/EN/UI/MainUI/MainUI.java b/src/main/java/EN/UI/MainUI/MainUI.java deleted file mode 100644 index 22c57ea..0000000 --- a/src/main/java/EN/UI/MainUI/MainUI.java +++ /dev/null @@ -1,272 +0,0 @@ -package EN.UI.MainUI; - - -import EN.UI.FunctionUI.MoreUI; -import EN.UI.FunctionUI.UserUI; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.util.Map; -import java.util.Random; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class MainUI extends JFrame { - public static boolean isInCollation = false; - public static JButton tablePet = new JButton(); - //获取X和Y值 - public static double X; - public static double Y; - //收起按钮 - public static ImageIcon lockImage = new ImageIcon("Icon/MainUI/function/unlock.png"); - public static JButton lock = new JButton(lockImage); - //判断是否收起 - public static Boolean isLocked = false; - //判断左侧功能是否展开 - public static Boolean isRelease = false; - - public static Boolean isInEating = false; - static String result; - static void readAppointedLineNumber(File sourceFile, int lineNumber) - throws IOException { - FileReader in = new FileReader(sourceFile); - LineNumberReader reader = new LineNumberReader(in); - String s = ""; - int lines = 0; - while (s != null) { - lines++; - s = reader.readLine(); - if((lines - lineNumber) == 0) { - result = s; - } - } - reader.close(); - in.close(); - } - public MainUI() { - - //获取toolkit - Dimension getScreenSize = Toolkit.getDefaultToolkit().getScreenSize(); - //基本设置 - this.setBounds(getScreenSize.width - 250, getScreenSize.height - 220, 230, 200); - this.setDefaultCloseOperation(EXIT_ON_CLOSE); - this.setResizable(false); - this.setUndecorated(true); - this.setBackground(new Color(0, 0, 0, 0)); - this.setLayout(new BorderLayout()); - this.setType(Type.UTILITY); - //右侧功能界面 - JPanel function = new JPanel(); - function.setPreferredSize(new Dimension(30, 200)); - function.setBackground(new Color(0, 0, 0, 0)); - function.setLayout(new BorderLayout()); - //移动按钮 - ImageIcon moveImage = new ImageIcon("Icon/MainUI/function/move.png"); - JLabel move = new JLabel(moveImage); - move.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - X = e.getPoint().getX(); - Y = e.getPoint().getY(); - - } - }); - move.addMouseMotionListener(new MouseAdapter() { - @Override - public void mouseDragged(MouseEvent e) { - MainUI.this.setLocation((int) (e.getXOnScreen() - X - 200), (int) (e.getYOnScreen() - Y)); - - } - }); - //收起按钮 - lock.setContentAreaFilled(false); - lock.setBorderPainted(false); - //整理按钮 - ImageIcon collationImage = new ImageIcon("Icon/MainUI/function/collation.png"); - JButton collation = new JButton(collationImage); - - collation.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - if(isInCollation){ - isInCollation = false; - JOptionPane.showMessageDialog(null,"已成功关闭","整理功能",JOptionPane.INFORMATION_MESSAGE); - }else{ - isInCollation = true; - JOptionPane.showMessageDialog(null,"已成功开启","整理功能",JOptionPane.INFORMATION_MESSAGE); - } - } - }); - collation.setContentAreaFilled(false); - collation.setBorderPainted(false); - //更多按钮 - ImageIcon moreImage = new ImageIcon("Icon/MainUI/function/more.png"); - JButton more = new JButton(moreImage); - more.setContentAreaFilled(false); - more.setBorderPainted(false); - more.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - MoreUI moreUI = new MoreUI(); - moreUI.setVisible(true); - } - }); - //退出按钮 - ImageIcon exitImage = new ImageIcon("Icon/MainUI/function/exit.png"); - JButton exit = new JButton(exitImage); - exit.setContentAreaFilled(false); - exit.setBorderPainted(false); - exit.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - System.exit(0); - } - }); - //将收起的整合到一起 - JPanel lockPanel = new JPanel(); - lockPanel.setBackground(new Color(0, 0, 0, 0)); - lockPanel.setLayout(new GridLayout(3, 1)); - lockPanel.add(collation); - lockPanel.add(more); - lockPanel.add(exit); - //将收起和移动合并为一个Panel - JPanel moveAndLock = new JPanel(); - moveAndLock.setLayout(new GridLayout(2, 1)); - moveAndLock.setBackground(new Color(0, 0, 0, 0)); - moveAndLock.add(move); - moveAndLock.add(lock); - //lock的监听函数 - lock.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - if (isLocked) { - lockImage = new ImageIcon("Icon/MainUI/function/unlock.png"); - lock.setIcon(lockImage); - function.add(lockPanel, BorderLayout.CENTER); - isLocked = false; - } else { - lockImage = new ImageIcon("Icon/MainUI/function/lock.png"); - lock.setIcon(lockImage); - function.remove(lockPanel); - isLocked = true; - } - MainUI.this.revalidate(); - MainUI.this.repaint(); - } - }); - //将所有组件加入到function中 - function.add(moveAndLock, BorderLayout.NORTH); - function.add(lockPanel, BorderLayout.CENTER); - //将function加入到UI中 - this.add(function, BorderLayout.EAST); - //添加桌宠 - - tablePet.setContentAreaFilled(false); - tablePet.setBorderPainted(false); - this.add(tablePet, BorderLayout.CENTER); - //添加桌宠左侧选项卡 - JPanel petPanel = new JPanel(); - petPanel.setLayout(new GridLayout(3, 1)); - petPanel.setBackground(new Color(0, 0, 0, 0)); - //添加图标 - ImageIcon petEatImage = new ImageIcon("Icon/MainUI/action/eat.png"); - JButton petEat = new JButton(petEatImage); - petEat.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - Toolkit toolkit = Toolkit.getDefaultToolkit(); - Random whatToEat = new Random(); - int eat = whatToEat.nextInt(5); - ImageIcon eatImageIcon; - if (eat == 0) { - eatImageIcon = new ImageIcon("Icon/MainUI/food/hot dog.png"); - } else if (eat == 1) { - eatImageIcon = new ImageIcon("Icon/MainUI/food/ice.png"); - } else if (eat == 2) { - eatImageIcon = new ImageIcon("Icon/MainUI/food/meat.png"); - } else if (eat == 3) { - eatImageIcon = new ImageIcon("Icon/MainUI/food/spring roll.png"); - } else { - eatImageIcon = new ImageIcon("Icon/MainUI/food/taco.png"); - } - Image eatImage = eatImageIcon.getImage(); - Cursor cu = toolkit.createCustomCursor(eatImage, new Point(10, 10), "eat"); - MainUI.this.setCursor(cu); - isInEating = true; - } - }); - petEat.setContentAreaFilled(false); - petEat.setBorderPainted(false); - petPanel.add(petEat); - ImageIcon petChatImage = new ImageIcon("Icon/MainUI/action/chat.png"); - JButton petChat = new JButton(petChatImage); - petChat.setContentAreaFilled(false); - petChat.setBorderPainted(false); - petPanel.add(petChat); - ImageIcon petUserImage = new ImageIcon("Icon/MainUI/action/user.png"); - JButton petUser = new JButton(petUserImage); - petUser.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - UserUI userUI; - try { - userUI = new UserUI(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - userUI.setVisible(true); - } - }); - petUser.setContentAreaFilled(false); - petUser.setBorderPainted(false); - petPanel.add(petUser); - //给桌宠添加单击事件 - tablePet.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - if (isInEating) { - //noinspection deprecation - MainUI.this.setCursor(0); - Map map = System.getenv(); - String userName = map.get("USERNAME"); - File folderPath = new File("C:\\Users\\"+userName+"\\.DesktopAide\\growth"); - File filePath = new File(folderPath+"\\growth.da"); - int line = 1; - try { - readAppointedLineNumber(filePath,line); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - int growth = Integer.parseInt(result)+5; - FileOutputStream fileOutputStream; - try { - fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write(String.valueOf(growth).getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - - isInEating = false; - } else { - if (isRelease) { - MainUI.this.remove(petPanel); - isRelease = false; - } else { - MainUI.this.add(petPanel, BorderLayout.WEST); - isRelease = true; - } - MainUI.this.revalidate(); - MainUI.this.repaint(); - } - } - }); - } -} diff --git a/src/main/java/RUS/Function/Collation/Collation.java b/src/main/java/RUS/Function/Collation/Collation.java deleted file mode 100644 index 30ce47d..0000000 --- a/src/main/java/RUS/Function/Collation/Collation.java +++ /dev/null @@ -1,86 +0,0 @@ -package RUS.Function.Collation; - -import java.io.*; -import java.util.Map; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -@SuppressWarnings("ResultOfMethodCallIgnored") -public class Collation { - static String name; - static String data; - static void readAppointedLineNumber(File sourceFile) - throws IOException { - FileReader in = new FileReader(sourceFile); - LineNumberReader reader = new LineNumberReader(in); - String s = ""; - int lines = 0; - while (s != null) { - lines++; - s = reader.readLine(); - if((lines - 1) == 0) { - data = s; - } - } - reader.close(); - in.close(); - } - - public static void findEndsWith(File file, String sword) throws IOException { - //将父文件下的所有文件夹以及文件存入File[]中 - File[] files = file.listFiles(); - //遍历所有文件夹以及文件 - assert files != null; - for(File i : files) { - //判断是否是文件夹 - if(i.isDirectory()) { - //是文件夹,递归 - //findEndsWith(i,sword); - }else { - //是文件,判断是否是以.后缀名结尾 - if(i.getPath().endsWith(sword)) { - Map map = System.getenv(); - String userName = map.get("USERNAME"); - File folderPath = new File("C:\\Users\\"+userName+"\\.DesktopAide\\collation"); - File filePath = new File(folderPath+"\\path.da"); - readAppointedLineNumber(filePath); - File doc = new File(data+"\\"+name+"\\"+i.getName()); - File docp = new File(i.getPath()); - docp.renameTo(doc); - } - - } - } - } - public static void Collation() throws IOException { - BufferedReader reader; - Map map = System.getenv(); - String userName = map.get("USERNAME"); - File folderPath = new File("C:\\Users\\"+userName+"\\.DesktopAide\\collation"); - File filePath = new File(folderPath+"\\path.da"); - readAppointedLineNumber(filePath); - try { - reader = new BufferedReader(new FileReader( - folderPath+"\\data.da")); - String line = reader.readLine(); - while (line != null) { - int a = line.indexOf(" "); - name = line.substring(0,a); - String sword = line.substring(a+1); - File desktopFolder = new File(data+"\\"+name); - if (!desktopFolder.exists()){ - desktopFolder.mkdirs(); - } - findEndsWith(new File(data),sword); - // read next line - line = reader.readLine(); - } - reader.close(); - } catch (IOException e) { - e.printStackTrace(); - } - - } -} diff --git a/src/main/java/RUS/Function/Growth/Growth.java b/src/main/java/RUS/Function/Growth/Growth.java deleted file mode 100644 index 8120413..0000000 --- a/src/main/java/RUS/Function/Growth/Growth.java +++ /dev/null @@ -1,50 +0,0 @@ -package RUS.Function.Growth; - -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.util.Map; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -@SuppressWarnings("ResultOfMethodCallIgnored") -public class Growth { - static String result; - static void readAppointedLineNumber(File sourceFile, int lineNumber) - throws IOException { - FileReader in = new FileReader(sourceFile); - LineNumberReader reader = new LineNumberReader(in); - String s = ""; - int lines = 0; - while (s != null) { - lines++; - s = reader.readLine(); - if((lines - lineNumber) == 0) { - result = s; - } - } - reader.close(); - in.close(); - } - public String growth() throws IOException { - - Map map = System.getenv(); - String userName = map.get("USERNAME"); - File folderPath = new File("C:\\Users\\"+userName+"\\.DesktopAide\\growth"); - File filePath = new File(folderPath+"\\growth.da"); - if(!folderPath.exists()) { - folderPath.mkdirs(); - } - if(!filePath.exists()){ - filePath.createNewFile(); - FileOutputStream fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write("0".getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } - int needReadLine = 1; - readAppointedLineNumber(filePath,needReadLine); - return result; - } -} diff --git a/src/main/java/RUS/Function/Puppet/Puppet.java b/src/main/java/RUS/Function/Puppet/Puppet.java deleted file mode 100644 index c42c366..0000000 --- a/src/main/java/RUS/Function/Puppet/Puppet.java +++ /dev/null @@ -1,23 +0,0 @@ -package RUS.Function.Puppet; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class Puppet extends JFrame { - public Puppet(){ - this.setSize(250,180); - ImageIcon puppetImage = new ImageIcon("Icon/Function/Puppet/1.png"); - JLabel puppet = new JLabel(puppetImage); - this.add(puppet); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setUndecorated(true); - this.setBackground(new Color(0, 0, 0, 0)); - this.setType(Type.UTILITY); - this.setAlwaysOnTop(true); - } - } diff --git a/src/main/java/RUS/Function/Puppet/PuppetRun.java b/src/main/java/RUS/Function/Puppet/PuppetRun.java deleted file mode 100644 index 754886d..0000000 --- a/src/main/java/RUS/Function/Puppet/PuppetRun.java +++ /dev/null @@ -1,23 +0,0 @@ -package RUS.Function.Puppet; - -import java.awt.*; - -import static CN.UI.FunctionPanel.puppetPanel.puppet; - -/** - * @author chenpuhao - * @version 3.2.x - * @Date 2023/2/4 - */ -public class PuppetRun extends Thread{ - public static boolean exit = false; - public void run(){ - while (!exit){ - puppet.setVisible(true); - PointerInfo pInfo = MouseInfo.getPointerInfo(); - Point p = pInfo.getLocation(); - puppet.setLocation((int) p.getX()-110, (int) p.getY()); - } - puppet.setVisible(false); - } -} diff --git a/src/main/java/RUS/Function/Update/CheckUpdate.java b/src/main/java/RUS/Function/Update/CheckUpdate.java deleted file mode 100644 index 74ad49e..0000000 --- a/src/main/java/RUS/Function/Update/CheckUpdate.java +++ /dev/null @@ -1,57 +0,0 @@ -package RUS.Function.Update; - -import java.io.*; -import java.net.URL; - -/** - * @author chenpuhao - * @Date 2023/2/6 - */ -public class CheckUpdate { - - private static void downloadUsingStream(String urlStr, String file) throws IOException{ - URL url = new URL(urlStr); - BufferedInputStream bis = new BufferedInputStream(url.openStream()); - FileOutputStream fis = new FileOutputStream(file); - byte[] buffer = new byte[1024]; - int count=0; - while((count = bis.read(buffer,0,1024)) != -1) - { - fis.write(buffer, 0, count); - } - fis.close(); - bis.close(); - } - static String result; - static void readAppointedLineNumber(File sourceFile) - throws IOException { - FileReader in = new FileReader(sourceFile); - LineNumberReader reader = new LineNumberReader(in); - String s = ""; - int lines = 0; - while (s != null) { - lines++; - s = reader.readLine(); - if((lines - 1) == 0) { - result = s; - } - } - reader.close(); - in.close(); - } - - public String CheckUpdate() throws IOException { - File file = new File("update.txt"); - if(!file.exists()){ - file.createNewFile(); - } - downloadUsingStream("https://desktopaide.chenpuhao.me/update.txt",file.toString()); - readAppointedLineNumber(file); - file.delete(); - if(result.equals("3.4.1")){ - result = "true"; - } - return result; - } - } - diff --git a/src/main/java/RUS/Function/Update/Update.java b/src/main/java/RUS/Function/Update/Update.java deleted file mode 100644 index 8deec70..0000000 --- a/src/main/java/RUS/Function/Update/Update.java +++ /dev/null @@ -1,120 +0,0 @@ -package RUS.Function.Update; - -import javax.net.ssl.*; -import javax.swing.*; -import java.awt.*; -import java.io.*; -import java.net.URI; -import java.net.URL; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; - -/** - * @author chenpuhao - * @Date 2023/2/6 - */ -public class Update { - private static void downloadUsingStream(String urlStr, String file) throws IOException{ - URL url = new URL(urlStr); - BufferedInputStream bis = new BufferedInputStream(url.openStream()); - FileOutputStream fis = new FileOutputStream(file); - byte[] buffer = new byte[10240000]; - int count=0; - while((count = bis.read(buffer,0,10240000)) != -1) - { - fis.write(buffer, 0, count); - } - fis.close(); - bis.close(); - } - public static byte[] readInputStream(InputStream inputStream) throws IOException { - byte[] buffer = new byte[10240]; - int len = 0; - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - while((len = inputStream.read(buffer)) != -1) { - bos.write(buffer, 0, len); - } - bos.close(); - return bos.toByteArray(); - } - public static void trustAllHttpsCertificates() throws Exception { - TrustManager[] trustAllCerts = new TrustManager[1]; - TrustManager tm = new miTM(); - trustAllCerts[0] = tm; - SSLContext sc = SSLContext.getInstance("SSL"); - sc.init(null, trustAllCerts, null); - HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); - } - - static class miTM implements TrustManager,X509TrustManager { - public X509Certificate[] getAcceptedIssuers() { - return null; - } - - public boolean isServerTrusted(X509Certificate[] certs) { - return true; - } - - public boolean isClientTrusted(X509Certificate[] certs) { - return true; - } - - public void checkServerTrusted(X509Certificate[] certs, String authType) - throws CertificateException { - return; - } - - public void checkClientTrusted(X509Certificate[] certs, String authType) throws CertificateException{ - return; - } - } - - /** - * 忽略HTTPS请求的SSL证书,必须在openConnection之前调用 - * @throws Exception - */ - public static void ignoreSsl() throws Exception{ - HostnameVerifier hv = new HostnameVerifier() { - public boolean verify(String urlHostName, SSLSession session) { - return true; - } - }; - trustAllHttpsCertificates(); - HttpsURLConnection.setDefaultHostnameVerifier(hv); - } - private static void browse2(String url) throws Exception { - Desktop desktop = Desktop.getDesktop(); - if (Desktop.isDesktopSupported() && desktop.isSupported(Desktop.Action.BROWSE)) { - URI uri = new URI(url); - desktop.browse(uri); - } - } - - public Update() throws Exception { - Update.ignoreSsl(); - System.setProperty("https.protocols", "TLSv1.2,TLSv1.1,SSLv3"); - CheckUpdate checkUpdate = new CheckUpdate(); - String result = checkUpdate.CheckUpdate(); - File filePath = new File("download"); - if(!filePath.exists()){ - filePath.mkdirs(); - } - if(!result.equals("true")){ - File file = new File("download/DesktopAide-rus-"+result+"-beta-setup.exe"); - if(!file.exists()){ - file.createNewFile(); - } - int n = JOptionPane.showConfirmDialog(null,"При обнаружении обновления версии выберите Да, чтобы использовать программное обеспечение для загрузки инсталляционного пакета, предполагаемое время составляет 15-20 мин, в противном случае перейдите на официальный сайт для загрузки","Доступно обновление версии",JOptionPane.YES_NO_OPTION); - if(n == 0) { - - downloadUsingStream("https://github.com/chenpuhao/DesktopAide/releases/download/V" + result + "/DesktopAide-rus-" + result + "-setup.exe", String.valueOf(file)); - JOptionPane.showMessageDialog(null, "Загрузка завершена, и установщик откроется для вас позже", "Загрузка завершена", JOptionPane.PLAIN_MESSAGE); - Desktop.getDesktop().open(file); - System.exit(0); - }else{ - browse2("https://desktopaide.chenpuhao.me/download.html"); - System.exit(0); - } - } - } -} diff --git a/src/main/java/RUS/UI/FunctionPanel/CollationPanel.java b/src/main/java/RUS/UI/FunctionPanel/CollationPanel.java deleted file mode 100644 index 4f4bb6a..0000000 --- a/src/main/java/RUS/UI/FunctionPanel/CollationPanel.java +++ /dev/null @@ -1,184 +0,0 @@ -package RUS.UI.FunctionPanel; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.util.Map; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -@SuppressWarnings("ResultOfMethodCallIgnored") -public class CollationPanel extends JPanel { - static String data; - static void readAppointedLineNumber(File sourceFile) - throws IOException { - FileReader in = new FileReader(sourceFile); - LineNumberReader reader = new LineNumberReader(in); - String s = ""; - int lines = 0; - while (s != null) { - lines++; - s = reader.readLine(); - if((lines - 1) == 0) { - data = s; - } - } - reader.close(); - in.close(); - } - public CollationPanel() throws IOException { - this.setLayout(new BorderLayout()); - //定义组件 - //桌面路径 - JPanel path = new JPanel(); - path.setLayout(new GridLayout(4,1)); - JLabel desktopPath = new JLabel("Выберите свой рабочий путь:"); - ButtonGroup pathButtonGroup = new ButtonGroup(); - Map map = System.getenv(); - String userName = map.get("USERNAME"); - JRadioButton desktop = new JRadioButton("C:\\Users\\" + userName + "\\Desktop"); - JRadioButton oneDrive = new JRadioButton("C:\\Users\\" + userName + "\\OneDrive\\Desktop"); - JRadioButton other = new JRadioButton("друг:"); - pathButtonGroup.add(desktop); - pathButtonGroup.add(oneDrive); - pathButtonGroup.add(other); - JTextField otherTxt = new JTextField(); - File folderPath = new File("C:\\Users\\" + userName + "\\.DesktopAide\\collation"); - File filePath = new File(folderPath + "\\path.da"); - if(filePath.exists()) { - readAppointedLineNumber(filePath); - if (data.equals("C:\\Users\\" + userName + "\\Desktop")) { - desktop.setSelected(true); - } else if (data.equals("C:\\Users\\" + userName + "\\OneDrive\\Desktop")) { - oneDrive.setSelected(true); - } else { - other.setSelected(true); - otherTxt.setText(data); - } - } - JPanel otherPanel = new JPanel(); - otherPanel.setLayout(new BorderLayout()); - otherPanel.add(other,BorderLayout.WEST); - otherPanel.add(otherTxt,BorderLayout.CENTER); - path.add(desktopPath); - path.add(desktop); - path.add(oneDrive); - path.add(otherPanel); - //配置后缀 - JPanel methodPanel = new JPanel(); - methodPanel.setLayout(new BorderLayout()); - JLabel method = new JLabel("Файловая фиксация/n, которая должна быть собрана для конфигурации, состоит из: имя папки (пустой) суффикс, например: PPT"); - JTextArea methodArea = new JTextArea(); - filePath = new File(folderPath + "\\data.da"); - if (filePath.exists()){ - long fileLengthLong = filePath.length(); - byte[] fileContent = new byte[(int) fileLengthLong]; - try { - FileInputStream inputStream = new FileInputStream(filePath); - inputStream.read(fileContent); - inputStream.close(); - } catch (Exception e) { - // TODO: handle exception - } - String string = new String(fileContent); - methodArea.setText(string); - } - JScrollPane methodJSP = new JScrollPane(methodArea); - JPanel methodCheck = new JPanel(); - methodCheck.setLayout(new GridLayout(1,2)); - JButton methodSave = new JButton("сохран"); - methodSave.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - if (!desktop.isSelected() && !oneDrive.isSelected() && !other.isSelected()) { - JOptionPane.showMessageDialog(null,"Выберите рабочий путь","ошибк",JOptionPane.ERROR_MESSAGE); - } else { - Map map = System.getenv(); - String userName = map.get("USERNAME"); - File folderPath = new File("C:\\Users\\" + userName + "\\.DesktopAide\\collation"); - File filePath = new File(folderPath + "\\path.da"); - if(!folderPath.exists()){ - folderPath.mkdirs(); - } - if (!filePath.exists()) { - try { - filePath.createNewFile(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - if (desktop.isSelected()) { - FileOutputStream fileOutputStream; - try { - fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write(desktop.getText().getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - if (oneDrive.isSelected()) { - FileOutputStream fileOutputStream; - try { - fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write(oneDrive.getText().getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - if (other.isSelected()) { - FileOutputStream fileOutputStream; - try { - fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write(otherTxt.getText().getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - filePath = new File(folderPath + "\\data.da"); - if(!filePath.exists()){ - try { - filePath.createNewFile(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - FileOutputStream fileOutputStream; - try { - fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write(methodArea.getText().getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - JOptionPane.showMessageDialog(null,"Спасти!","Получилось!",JOptionPane.PLAIN_MESSAGE); - } - } - }); - JButton methodClean = new JButton("очист"); - methodClean.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - methodArea.setText(""); - } - }); - methodCheck.add(methodSave); - methodCheck.add(methodClean); - methodPanel.add(method,BorderLayout.NORTH); - methodPanel.add(methodJSP,BorderLayout.CENTER); - methodPanel.add(methodCheck,BorderLayout.SOUTH); - this.add(path,BorderLayout.NORTH); - this.add(methodPanel,BorderLayout.CENTER); - } -} diff --git a/src/main/java/RUS/UI/FunctionPanel/FindPanel.java b/src/main/java/RUS/UI/FunctionPanel/FindPanel.java deleted file mode 100644 index a08eaf1..0000000 --- a/src/main/java/RUS/UI/FunctionPanel/FindPanel.java +++ /dev/null @@ -1,86 +0,0 @@ -package RUS.UI.FunctionPanel; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * @author chenpuhao - * @version 3.2.x - * @Date 2023/2/4 - */ -public class FindPanel extends JPanel { - static JTextField pathField = new JTextField(); - static JTextField nameField = new JTextField(); - static File file = new File(pathField.getText()); - static String keyWord = nameField.getText(); - public static List searchFiles(File folder, final String keyword) { - List result = new ArrayList<>(); - if (folder.isFile()) - result.add(folder); - File[] subFolders = folder.listFiles(file -> { - if (file.isDirectory()) { - return true; - } - return file.getName().toLowerCase().contains(keyword); - }); - if (subFolders != null) { - for (File file : subFolders) { - if (file.isFile()) { - // 如果是文件则将文件添加到结果列表中 - result.add(file); - } else { - // 如果是文件夹,则递归调用本方法,然后把所有的文件加到结果列表中 - result.addAll(searchFiles(file, keyword)); - } - } - } - return result; - } - public FindPanel(){ - this.setLayout(new BorderLayout()); - Map map = System.getenv(); - String userName = map.get("USERNAME"); - JLabel pathLabel = new JLabel("Каталог, который нужно найти, например :C:\\Users\\" + userName + "\\Desktop"); - JLabel fileLabel = new JLabel("Ключевые слова в названии файла, которые необходимо найти, например :DesktopAide"); - JButton check = new JButton("увер"); - check.addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent e) { - file = new File(pathField.getText()); - File file3 = new File(file.toURI()); - keyWord = nameField.getText(); - List files = searchFiles(file3, keyWord); - StringBuilder filePath = new StringBuilder(); - for (File file : files) { - File file1 = new File(file.getAbsolutePath()); - filePath.append("\n").append(file1); - try { - Desktop.getDesktop().open(file1); - } catch (IOException e1) { - - e1.printStackTrace(); - } - } - if (filePath.toString().equals("")) { - JOptionPane.showMessageDialog(null, "В этом каталоге нет документов с этим ключевым словом", "Поиск завершен!", JOptionPane.ERROR_MESSAGE); - } else { - JOptionPane.showMessageDialog(null, "В общей сложности были найдены следующие документы:" + filePath, "Поиск завершен!", JOptionPane.PLAIN_MESSAGE); - } - } - }); - JPanel findPanel = new JPanel(); - findPanel.setLayout(new GridLayout (5 , 1 )); - findPanel.add(pathLabel); - findPanel.add(pathField); - findPanel.add(fileLabel); - findPanel.add(nameField); - findPanel.add(check); - this.add(findPanel); - } -} diff --git a/src/main/java/RUS/UI/FunctionPanel/puppetPanel.java b/src/main/java/RUS/UI/FunctionPanel/puppetPanel.java deleted file mode 100644 index f80c350..0000000 --- a/src/main/java/RUS/UI/FunctionPanel/puppetPanel.java +++ /dev/null @@ -1,94 +0,0 @@ -package RUS.UI.FunctionPanel; - -import RUS.Function.Puppet.Puppet; -import RUS.Function.Puppet.PuppetRun; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.util.Map; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -@SuppressWarnings("ResultOfMethodCallIgnored") -public class puppetPanel extends JPanel { - public static JRadioButton yes = new JRadioButton("нача"); - static String result; - public static PuppetRun puppetRun ; - - static void readAppointedLineNumber(File sourceFile, int lineNumber) - throws IOException { - FileReader in = new FileReader(sourceFile); - LineNumberReader reader = new LineNumberReader(in); - String s = ""; - int lines = 0; - while (s != null) { - lines++; - s = reader.readLine(); - if((lines - lineNumber) == 0) { - result = s; - } - } - reader.close(); - in.close(); - } - public static Puppet puppet = new Puppet(); - public puppetPanel() throws IOException { - Map map = System.getenv(); - String userName = map.get("USERNAME"); - File folderPath = new File("C:\\Users\\"+userName+"\\.DesktopAide\\puppet"); - File filePath = new File(folderPath+"\\puppet.da"); - if(!folderPath.exists()) { - folderPath.mkdirs(); - } - if(!filePath.exists()){ - filePath.createNewFile(); - FileOutputStream fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write("false".getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } - //定义组件 - JLabel introduce = new JLabel("Открыть или выключить функцию марионетки мыши"); - ButtonGroup buttonGroup = new ButtonGroup(); - JRadioButton no = new JRadioButton("закр"); - buttonGroup.add(yes); - buttonGroup.add(no); - JPanel buttonPanel = new JPanel(); - buttonPanel.setLayout(new GridLayout(1,2)); - buttonPanel.add(yes); - buttonPanel.add(no); - JButton save = new JButton("сохран"); - - save.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - - if(yes.isSelected()){ - PuppetRun.exit = false; - puppetRun = new PuppetRun(); - puppetRun.start(); - }else{ - PuppetRun.exit = true; - - } - } - }); - this.setLayout(new GridLayout(3,1)); - this.add(introduce); - this.add(buttonPanel); - this.add(save); - int line = 1; - readAppointedLineNumber(filePath,line); - if(result.equals("true")){ - yes.setSelected(true); - }else{ - no.setSelected(true); - } - } -} diff --git a/src/main/java/RUS/UI/FunctionUI/MoreUI.java b/src/main/java/RUS/UI/FunctionUI/MoreUI.java deleted file mode 100644 index 28961e6..0000000 --- a/src/main/java/RUS/UI/FunctionUI/MoreUI.java +++ /dev/null @@ -1,98 +0,0 @@ -package RUS.UI.FunctionUI; - -import RUS.UI.FunctionPanel.CollationPanel; -import RUS.UI.FunctionPanel.FindPanel; -import RUS.UI.FunctionPanel.puppetPanel; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.IOException; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class MoreUI extends JFrame { - public MoreUI(){ - //获取桌面大小 - Dimension getScreenSize = Toolkit.getDefaultToolkit().getScreenSize(); - //基本设置 - this.setBounds((getScreenSize.width-600)/2,(getScreenSize.height-500)/2,600,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - JPanel moreUIPanel = new JPanel(); - moreUIPanel.setLayout(new BorderLayout()); - ImageIcon title = new ImageIcon("Icon/MoreUI/favicon.png"); - this.setIconImage(title.getImage()); - JScrollPane jsp = new JScrollPane(); - JPanel leftSetting = new JPanel(); - jsp.setViewportView(leftSetting); - leftSetting.setLayout(new GridLayout(3,1)); - //添加整理的设置 - ImageIcon collationImage = new ImageIcon("Icon/MoreUI/collation.png"); - JButton collation = new JButton("Настройка функции сортировки"); - collation.setIcon(collationImage); - collation.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - moreUIPanel.removeAll(); - moreUIPanel.setLayout(new BorderLayout()); - moreUIPanel.add(leftSetting,BorderLayout.WEST); - CollationPanel collationPanel; - try { - collationPanel = new CollationPanel(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - moreUIPanel.add(collationPanel,BorderLayout.CENTER); - MoreUI.this.revalidate(); - MoreUI.this.repaint(); - } - }); - leftSetting.add(collation); - //添加QQ机器人设置 - ImageIcon qqImage = new ImageIcon("Icon/MoreUI/hand.png"); - JButton qq = new JButton("Мышонок."); - qq.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - moreUIPanel.removeAll(); - moreUIPanel.setLayout(new BorderLayout()); - moreUIPanel.add(leftSetting,BorderLayout.WEST); - puppetPanel handPanel; - try { - handPanel = new puppetPanel(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - moreUIPanel.add(handPanel,BorderLayout.CENTER); - MoreUI.this.revalidate(); - MoreUI.this.repaint(); - } - }); - qq.setIcon(qqImage); - leftSetting.add(qq); - //查找文件 - ImageIcon searchImage = new ImageIcon("Icon/MoreUI/search.png"); - JButton search = new JButton("Найди файл."); - search.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - moreUIPanel.removeAll(); - moreUIPanel.setLayout(new BorderLayout()); - moreUIPanel.add(leftSetting,BorderLayout.WEST); - FindPanel findPanel; - findPanel = new FindPanel(); - moreUIPanel.add(findPanel,BorderLayout.CENTER); - MoreUI.this.revalidate(); - MoreUI.this.repaint(); - } - }); - search.setIcon(searchImage); - leftSetting.add(search); - moreUIPanel.add(jsp,BorderLayout.WEST); - this.add(moreUIPanel); - } -} diff --git a/src/main/java/RUS/UI/FunctionUI/UserUI.java b/src/main/java/RUS/UI/FunctionUI/UserUI.java deleted file mode 100644 index 70c5d8f..0000000 --- a/src/main/java/RUS/UI/FunctionUI/UserUI.java +++ /dev/null @@ -1,151 +0,0 @@ -package RUS.UI.FunctionUI; - -import RUS.UI.IntroduceUI.*; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.*; -import java.util.Map; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UserUI extends JFrame { - static String result; - static void readAppointedLineNumber(File sourceFile) - throws IOException { - FileReader in = new FileReader(sourceFile); - LineNumberReader reader = new LineNumberReader(in); - String s = ""; - int lines = 0; - while (s != null) { - lines++; - s = reader.readLine(); - if((lines - 1) == 0) { - result = s; - } - } - reader.close(); - in.close(); - } - static int getTotalLines(File file) throws IOException { - FileReader in = new FileReader(file); - LineNumberReader reader = new LineNumberReader(in); - String s = reader.readLine(); - int lines = 0; - while (s != null) { - lines++; - s = reader.readLine(); - } - reader.close(); - in.close(); - return lines; - } - public UserUI() throws IOException { - //获取屏幕大小 - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width - 300) / 2, (getDesktopSize.height - 500) / 2, 300, 500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setLayout(new BorderLayout()); - this.setResizable(false); - this.setType(Type.UTILITY); - //用户姓名 - Map map = System.getenv(); - String userName = map.get("USERNAME"); - File folderPath = new File("C:\\Users\\" + userName + "\\.DesktopAide\\user"); - File filePath = new File(folderPath + "\\user.da"); - readAppointedLineNumber(filePath); - JLabel UserName = new JLabel("Добр пожалова "+result); - JLabel userData = new JLabel("Вы посадили следующие растения."); - JPanel jp = new JPanel(); - jp.setLayout(new GridLayout(2,1)); - jp.add(UserName); - jp.add(userData); - filePath = new File(folderPath + "\\success.da"); - int total = getTotalLines(filePath); - JScrollPane jsp = new JScrollPane(); - jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - JPanel success = new JPanel(); - jsp.setViewportView(success); - success.setLayout(new GridLayout(total,1)); - BufferedReader reader; - try { - reader = new BufferedReader(new FileReader( - filePath)); - String line = reader.readLine(); - while (line != null) { - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/"+line); - JButton jb = new JButton(img); - success.add(jb); - String finalLine = line; - jb.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - switch (finalLine) { - case "0.png" -> { - UI0 ui = new UI0(); - ui.setVisible(true); - } - case "1.png" -> { - UI1 ui = new UI1(); - ui.setVisible(true); - } - case "2.png" -> { - UI2 ui = new UI2(); - ui.setVisible(true); - } - case "3.png" -> { - UI3 ui = new UI3(); - ui.setVisible(true); - } - case "4.png" -> { - UI4 ui = new UI4(); - ui.setVisible(true); - } - case "5.png" -> { - UI5 ui = new UI5(); - ui.setVisible(true); - } - case "6.png" -> { - UI6 ui = new UI6(); - ui.setVisible(true); - } - case "7.png" -> { - UI7 ui = new UI7(); - ui.setVisible(true); - } - case "8.png" -> { - UI8 ui = new UI8(); - ui.setVisible(true); - } - case "9.png" -> { - UI9 ui = new UI9(); - ui.setVisible(true); - } - case "10.png" -> { - UI10 ui = new UI10(); - ui.setVisible(true); - } - case "11.png" -> { - UI11 ui = new UI11(); - ui.setVisible(true); - } - } - } - }); - // read next line - line = reader.readLine(); - } - reader.close(); - } catch (IOException e) { - e.printStackTrace(); - } - this.add(jp,BorderLayout.NORTH); - this.add(jsp); - } - - -} diff --git a/src/main/java/RUS/UI/IntroduceUI/UI0.java b/src/main/java/RUS/UI/IntroduceUI/UI0.java deleted file mode 100644 index e04f385..0000000 --- a/src/main/java/RUS/UI/IntroduceUI/UI0.java +++ /dev/null @@ -1,31 +0,0 @@ -package RUS.UI.IntroduceUI; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI0 extends JFrame { - public UI0(){ - - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this.setTitle("Подробнее-кактус"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/0.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce = new JLabel("Кактус великого человека, шип которого защищает его от внешних атак"); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} diff --git a/src/main/java/RUS/UI/IntroduceUI/UI1.java b/src/main/java/RUS/UI/IntroduceUI/UI1.java deleted file mode 100644 index a2bea9b..0000000 --- a/src/main/java/RUS/UI/IntroduceUI/UI1.java +++ /dev/null @@ -1,32 +0,0 @@ -package RUS.UI.IntroduceUI; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI1 extends JFrame { - public UI1(){ - - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this.setTitle("Подробности-четырехлистник"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/1.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce = new JLabel("Может быть, сегодня нам повезет?"); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} - diff --git a/src/main/java/RUS/UI/IntroduceUI/UI10.java b/src/main/java/RUS/UI/IntroduceUI/UI10.java deleted file mode 100644 index 0f2af90..0000000 --- a/src/main/java/RUS/UI/IntroduceUI/UI10.java +++ /dev/null @@ -1,31 +0,0 @@ -package RUS.UI.IntroduceUI; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI10 extends JFrame { - public UI10(){ - - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this.setTitle("Подробнее-розы"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/10.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce = new JLabel("Яркие розы, обязательный артефакт на день святого валентина"); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} diff --git a/src/main/java/RUS/UI/IntroduceUI/UI11.java b/src/main/java/RUS/UI/IntroduceUI/UI11.java deleted file mode 100644 index 953685f..0000000 --- a/src/main/java/RUS/UI/IntroduceUI/UI11.java +++ /dev/null @@ -1,31 +0,0 @@ -package RUS.UI.IntroduceUI; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI11 extends JFrame { - public UI11(){ - - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this.setTitle("Подробности-пшеница"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/11.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce = new JLabel("Повторяй за мной: полдень злаков, капли пота..."); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} diff --git a/src/main/java/RUS/UI/IntroduceUI/UI2.java b/src/main/java/RUS/UI/IntroduceUI/UI2.java deleted file mode 100644 index 14639de..0000000 --- a/src/main/java/RUS/UI/IntroduceUI/UI2.java +++ /dev/null @@ -1,31 +0,0 @@ -package RUS.UI.IntroduceUI; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI2 extends JFrame { - public UI2(){ - - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this.setTitle("Подробнее-кукуруза"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/2.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce = new JLabel("Золотая чан-чан кукуруза и зелёная оболочка, кипящая или жареная?"); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} diff --git a/src/main/java/RUS/UI/IntroduceUI/UI3.java b/src/main/java/RUS/UI/IntroduceUI/UI3.java deleted file mode 100644 index 6193f52..0000000 --- a/src/main/java/RUS/UI/IntroduceUI/UI3.java +++ /dev/null @@ -1,31 +0,0 @@ -package RUS.UI.IntroduceUI; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI3 extends JFrame { - public UI3(){ - - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this.setTitle("В деталях-баклажаны"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/3.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce = new JLabel("Жирные баклажаны, которые должны были стоить владельцу целого состояния"); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} diff --git a/src/main/java/RUS/UI/IntroduceUI/UI4.java b/src/main/java/RUS/UI/IntroduceUI/UI4.java deleted file mode 100644 index 58659fd..0000000 --- a/src/main/java/RUS/UI/IntroduceUI/UI4.java +++ /dev/null @@ -1,31 +0,0 @@ -package RUS.UI.IntroduceUI; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI4 extends JFrame { - public UI4(){ - - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this.setTitle("Подробнее-трава"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/4.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce = new JLabel("Может, это просто трава..."); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} diff --git a/src/main/java/RUS/UI/IntroduceUI/UI5.java b/src/main/java/RUS/UI/IntroduceUI/UI5.java deleted file mode 100644 index 7816978..0000000 --- a/src/main/java/RUS/UI/IntroduceUI/UI5.java +++ /dev/null @@ -1,31 +0,0 @@ -package RUS.UI.IntroduceUI; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI5 extends JFrame { - public UI5(){ - - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this.setTitle("Подробнее-листья"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/5.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce = new JLabel("Это не обычный лист, это лист из королевской поэмы"); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} diff --git a/src/main/java/RUS/UI/IntroduceUI/UI6.java b/src/main/java/RUS/UI/IntroduceUI/UI6.java deleted file mode 100644 index 69e7d9a..0000000 --- a/src/main/java/RUS/UI/IntroduceUI/UI6.java +++ /dev/null @@ -1,31 +0,0 @@ -package RUS.UI.IntroduceUI; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI6 extends JFrame { - public UI6(){ - - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this.setTitle("Подробнее-капуста"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/6.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce = new JLabel("Капуста в барабане, что там может быть?"); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} diff --git a/src/main/java/RUS/UI/IntroduceUI/UI7.java b/src/main/java/RUS/UI/IntroduceUI/UI7.java deleted file mode 100644 index a906718..0000000 --- a/src/main/java/RUS/UI/IntroduceUI/UI7.java +++ /dev/null @@ -1,31 +0,0 @@ -package RUS.UI.IntroduceUI; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI7 extends JFrame { - public UI7(){ - - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this.setTitle("Подробнее-тыква"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/7.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce = new JLabel("Тыква для хэллоуина должна быть хорошей"); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} diff --git a/src/main/java/RUS/UI/IntroduceUI/UI8.java b/src/main/java/RUS/UI/IntroduceUI/UI8.java deleted file mode 100644 index 4e25bc1..0000000 --- a/src/main/java/RUS/UI/IntroduceUI/UI8.java +++ /dev/null @@ -1,31 +0,0 @@ -package RUS.UI.IntroduceUI; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI8 extends JFrame { - public UI8(){ - - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this.setTitle("Подробнее-редиска"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/8.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce = new JLabel("Эта репа-обычная редиска, и нечего тут представлять"); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} diff --git a/src/main/java/RUS/UI/IntroduceUI/UI9.java b/src/main/java/RUS/UI/IntroduceUI/UI9.java deleted file mode 100644 index cd8c3f9..0000000 --- a/src/main/java/RUS/UI/IntroduceUI/UI9.java +++ /dev/null @@ -1,31 +0,0 @@ -package RUS.UI.IntroduceUI; - -import javax.swing.*; -import java.awt.*; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class UI9 extends JFrame { - public UI9(){ - - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-500)/2,300,500); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setResizable(false); - this.setType(Type.UTILITY); - this.setTitle("Подробнее-помидоры"); - this.setLayout(new BorderLayout()); - ImageIcon img = new ImageIcon("Icon/MainUI/plant/success/9.png"); - JLabel label = new JLabel(img); - JPanel imgPanel = new JPanel(); - imgPanel.setLayout(new BorderLayout()); - imgPanel.add(label); - JPanel panel = new JPanel(); - JLabel introduce = new JLabel("Омлет с помидорами? Где яйца? Жду с нетерпением."); - panel.add(introduce); - this.add(imgPanel,BorderLayout.NORTH); - this.add(panel); - } -} diff --git a/src/main/java/RUS/UI/Main.java b/src/main/java/RUS/UI/Main.java deleted file mode 100644 index a1b081f..0000000 --- a/src/main/java/RUS/UI/Main.java +++ /dev/null @@ -1,156 +0,0 @@ -package RUS.UI; - -import RUS.Function.Collation.Collation; -import RUS.Function.Growth.Growth; -import RUS.Function.Update.Update; -import RUS.UI.MainUI.HelloUI; -import RUS.UI.MainUI.MainUI; -import com.formdev.flatlaf.FlatDarculaLaf; -import com.formdev.flatlaf.FlatDarkLaf; -import com.formdev.flatlaf.intellijthemes.FlatDarkFlatIJTheme; - -import javax.swing.*; -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.util.Map; -import java.util.Random; - -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ - -@SuppressWarnings({"ResultOfMethodCallIgnored", "InfiniteLoopStatement"}) -public class Main { - public static String readToString(String fileName) { - String encoding = "UTF-8"; - File file = new File(fileName); - long filelength = file.length(); - byte[] filecontent = new byte[(int) filelength]; - try { - FileInputStream in = new FileInputStream(file); - in.read(filecontent); - in.close(); - } catch (IOException e) { - e.printStackTrace(); - } - try { - return new String(filecontent, encoding); - } catch (UnsupportedEncodingException e) { - System.err.println("The OS does not support " + encoding); - e.printStackTrace(); - return null; - } - } - public static void main(String[] args) throws Exception { - //使用look and feel - FlatDarkLaf.setup(); - FlatDarculaLaf.setup(); - FlatDarkFlatIJTheme.setup(); - new Update(); - Map map = System.getenv(); - String userName = map.get("USERNAME"); - File folderPath = new File("C:\\Users\\" + userName + "\\.DesktopAide\\collation"); - File filePath = new File(folderPath + "\\path.da"); - if(!folderPath.exists()){ - folderPath.mkdirs(); - } - if (!filePath.exists()) { - try { - filePath.createNewFile(); - FileOutputStream fileOutputStream = new FileOutputStream(filePath); - String path = "C:\\Users\\" + userName + "\\Desktop"; - fileOutputStream.write(path.getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - folderPath = new File("C:\\Users\\"+userName+"\\.DesktopAide\\growth"); - filePath = new File(folderPath+"\\growth.da"); - if(!folderPath.exists()) { - folderPath.mkdirs(); - } - if(!filePath.exists()){ - filePath.createNewFile(); - FileOutputStream fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write("0".getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } - folderPath = new File("C:\\Users\\"+userName+"\\.DesktopAide\\puppet"); - filePath = new File(folderPath+"\\puppet.da"); - if(!folderPath.exists()) { - folderPath.mkdirs(); - } - if(!filePath.exists()){ - filePath.createNewFile(); - FileOutputStream fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write("false".getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } - folderPath = new File("C:\\Users\\" + userName + "\\.DesktopAide\\user"); - filePath = new File(folderPath + "\\user.da"); - if(!filePath.exists()){ - HelloUI helloUI = new HelloUI(); - helloUI.setVisible(true); - } - MainUI mainUI = new MainUI(); - mainUI.setVisible(true); - while (true) { - if(MainUI.isInCollation){ - Collation.Collation(); - } - //桌宠 - ImageIcon petImage; - Growth growth = new Growth(); - int growthInt = Integer.parseInt(growth.growth()); - if (growthInt == 100) { - folderPath = new File("Icon/MainUI/plant/success"); - File[] list = folderPath.listFiles(); - int fileCount = 0; - assert list != null; - for (File file : list) { - if (file.isFile()) { - fileCount++; - } - } - Random getSuccessPlant = new Random(); - int successPlantInt = getSuccessPlant.nextInt(fileCount-1); - petImage = new ImageIcon(folderPath+"/"+successPlantInt+".png"); - MainUI.tablePet.setIcon(petImage); - JOptionPane.showMessageDialog(null,"Поздравляю с успешными посадами, следующий раунд будет проведен после закрытия этого окна, и записи о посадах можно посмотреть в пользовательском интерфейсе","Успешно посажено.",JOptionPane.PLAIN_MESSAGE,petImage); - File path = new File("C:\\Users\\"+userName+"\\.DesktopAide\\growth"); - filePath = new File(path+"\\growth.da"); - FileOutputStream fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write("0".getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - path = new File("C:\\Users\\"+userName+"\\.DesktopAide\\user"); - filePath = new File(path+"\\success.da"); - String result = readToString(String.valueOf(filePath)); - if(!(result ==null)) { - result = result + "\n" + successPlantInt + ".png"; - }else{ - result = successPlantInt + ".png"; - } - fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write(result.getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } else if (growthInt < 100 && growthInt >=50) { - petImage = new ImageIcon("Icon/MainUI/plant/growing/100of100.png"); - }else{ - petImage = new ImageIcon("Icon/MainUI/plant/growing/50of100.png"); - } - MainUI.tablePet.setIcon(petImage); - mainUI.revalidate(); - mainUI.repaint(); - Thread.sleep(500); - } - } - -} diff --git a/src/main/java/RUS/UI/MainUI/HelloUI.java b/src/main/java/RUS/UI/MainUI/HelloUI.java deleted file mode 100644 index 540afd5..0000000 --- a/src/main/java/RUS/UI/MainUI/HelloUI.java +++ /dev/null @@ -1,126 +0,0 @@ -package RUS.UI.MainUI; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.Map; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -@SuppressWarnings("ResultOfMethodCallIgnored") -public class HelloUI extends JFrame { - static int num = 1; - public HelloUI(){ - - //获取屏幕大小 - Dimension getDesktopSize = Toolkit.getDefaultToolkit().getScreenSize(); - this.setBounds((getDesktopSize.width-300)/2,(getDesktopSize.height-200)/2,300,200); - this.setDefaultCloseOperation(HIDE_ON_CLOSE); - this.setLayout(new BorderLayout()); - //用户姓名 - JPanel panel1 = new JPanel(); - JLabel userNameLabel = new JLabel("Введите свое прозвище здесь"); - JTextField userNameField = new JTextField(); - panel1.setLayout(new GridLayout(2,1)); - panel1.add(userNameLabel); - panel1.add(userNameField); - this.add(panel1); - this.setResizable(false); - this.setType(Type.UTILITY); - //介绍 - JPanel panel2 = new JPanel(); - panel2.setLayout(new GridLayout(3,1)); - JLabel introduceUser = new JLabel("Добр пожалова",JLabel.CENTER); - JLabel introduce = new JLabel("",JLabel.CENTER); - JLabel introduceNext = new JLabel("Следующие страницы покажут вам основные функции программы",JLabel.CENTER); - panel2.add(introduceUser); - panel2.add(introduce); - panel2.add(introduceNext); - //介绍1 - JPanel panel3 = new JPanel(); - JTextArea introduce1 = new JTextArea(" Да? Как может такое маленькое окно содержать так много текста/n методов для просмотра PDF файлов внутри документов в каталоге установки"); - panel3.setLayout(new BorderLayout()); - panel3.add(introduce1); - introduce1.setEditable(false); - introduce1.setLineWrap(true); - //На следующей странице.按钮 - JPanel nextPanel = new JPanel(); - nextPanel.setLayout(new GridLayout(1,2)); - JButton last = new JButton("На последней странице."); - JButton next = new JButton("На следующей странице."); - last.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - if(num == 2){ - HelloUI.this.remove(panel2); - HelloUI.this.add(panel1); - next.setText("На следующей странице."); - HelloUI.this.revalidate(); - HelloUI.this.repaint(); - num --; - } - else if(num ==3){ - HelloUI.this.remove(panel3); - HelloUI.this.add(panel2); - next.setText("На следующей странице."); - HelloUI.this.revalidate(); - HelloUI.this.repaint(); - num--; - } - } - }); - - next.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - if(num == 1){ - introduce.setText(userNameField.getText()); - HelloUI.this.remove(panel1); - HelloUI.this.add(panel2); - next.setText("На следующей странице."); - HelloUI.this.revalidate(); - HelloUI.this.repaint(); - num ++; - } - else if(num == 2){ - HelloUI.this.remove(panel2); - HelloUI.this.add(panel3); - next.setText("законч"); - HelloUI.this.revalidate(); - HelloUI.this.repaint(); - num ++; - } - else{ - Map map = System.getenv(); - String userName = map.get("USERNAME"); - File folderPath = new File("C:\\Users\\" + userName + "\\.DesktopAide\\user"); - File filePath = new File(folderPath + "\\user.da"); - folderPath.mkdirs(); - try { - filePath.createNewFile(); - FileOutputStream fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write(userNameField.getText().getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - filePath = new File(folderPath + "\\success.da"); - filePath.createNewFile(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - HelloUI.this.setVisible(false); - } - } - }); - nextPanel.add(last); - nextPanel.add(next); - this.add(nextPanel,BorderLayout.SOUTH); - } - -} diff --git a/src/main/java/RUS/UI/MainUI/MainUI.java b/src/main/java/RUS/UI/MainUI/MainUI.java deleted file mode 100644 index 05baa20..0000000 --- a/src/main/java/RUS/UI/MainUI/MainUI.java +++ /dev/null @@ -1,272 +0,0 @@ -package RUS.UI.MainUI; - - -import RUS.UI.FunctionUI.MoreUI; -import RUS.UI.FunctionUI.UserUI; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.util.Map; -import java.util.Random; -/** - * @version 3.2.x - * @author chenpuhao - * @Date 2023/2/4 - */ -public class MainUI extends JFrame { - public static boolean isInCollation = false; - public static JButton tablePet = new JButton(); - //获取X和Y值 - public static double X; - public static double Y; - //收起按钮 - public static ImageIcon lockImage = new ImageIcon("Icon/MainUI/function/unlock.png"); - public static JButton lock = new JButton(lockImage); - //判断是否收起 - public static Boolean isLocked = false; - //判断左侧功能是否展开 - public static Boolean isRelease = false; - - public static Boolean isInEating = false; - static String result; - static void readAppointedLineNumber(File sourceFile, int lineNumber) - throws IOException { - FileReader in = new FileReader(sourceFile); - LineNumberReader reader = new LineNumberReader(in); - String s = ""; - int lines = 0; - while (s != null) { - lines++; - s = reader.readLine(); - if((lines - lineNumber) == 0) { - result = s; - } - } - reader.close(); - in.close(); - } - public MainUI() { - - //获取toolkit - Dimension getScreenSize = Toolkit.getDefaultToolkit().getScreenSize(); - //基本设置 - this.setBounds(getScreenSize.width - 250, getScreenSize.height - 220, 230, 200); - this.setDefaultCloseOperation(EXIT_ON_CLOSE); - this.setResizable(false); - this.setUndecorated(true); - this.setBackground(new Color(0, 0, 0, 0)); - this.setLayout(new BorderLayout()); - this.setType(Type.UTILITY); - //右侧功能界面 - JPanel function = new JPanel(); - function.setPreferredSize(new Dimension(30, 200)); - function.setBackground(new Color(0, 0, 0, 0)); - function.setLayout(new BorderLayout()); - //移动按钮 - ImageIcon moveImage = new ImageIcon("Icon/MainUI/function/move.png"); - JLabel move = new JLabel(moveImage); - move.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - X = e.getPoint().getX(); - Y = e.getPoint().getY(); - - } - }); - move.addMouseMotionListener(new MouseAdapter() { - @Override - public void mouseDragged(MouseEvent e) { - MainUI.this.setLocation((int) (e.getXOnScreen() - X - 200), (int) (e.getYOnScreen() - Y)); - - } - }); - //收起按钮 - lock.setContentAreaFilled(false); - lock.setBorderPainted(false); - //整理按钮 - ImageIcon collationImage = new ImageIcon("Icon/MainUI/function/collation.png"); - JButton collation = new JButton(collationImage); - - collation.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - if(isInCollation){ - isInCollation = false; - JOptionPane.showMessageDialog(null,"Успешно закрыто.","Функция сортировки",JOptionPane.INFORMATION_MESSAGE); - }else{ - isInCollation = true; - JOptionPane.showMessageDialog(null,"Получилось.","Функция сортировки",JOptionPane.INFORMATION_MESSAGE); - } - } - }); - collation.setContentAreaFilled(false); - collation.setBorderPainted(false); - //更多按钮 - ImageIcon moreImage = new ImageIcon("Icon/MainUI/function/more.png"); - JButton more = new JButton(moreImage); - more.setContentAreaFilled(false); - more.setBorderPainted(false); - more.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - MoreUI moreUI = new MoreUI(); - moreUI.setVisible(true); - } - }); - //退出按钮 - ImageIcon exitImage = new ImageIcon("Icon/MainUI/function/exit.png"); - JButton exit = new JButton(exitImage); - exit.setContentAreaFilled(false); - exit.setBorderPainted(false); - exit.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - System.exit(0); - } - }); - //将收起的整合到一起 - JPanel lockPanel = new JPanel(); - lockPanel.setBackground(new Color(0, 0, 0, 0)); - lockPanel.setLayout(new GridLayout(3, 1)); - lockPanel.add(collation); - lockPanel.add(more); - lockPanel.add(exit); - //将收起和移动合并为一个Panel - JPanel moveAndLock = new JPanel(); - moveAndLock.setLayout(new GridLayout(2, 1)); - moveAndLock.setBackground(new Color(0, 0, 0, 0)); - moveAndLock.add(move); - moveAndLock.add(lock); - //lock的监听函数 - lock.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - if (isLocked) { - lockImage = new ImageIcon("Icon/MainUI/function/unlock.png"); - lock.setIcon(lockImage); - function.add(lockPanel, BorderLayout.CENTER); - isLocked = false; - } else { - lockImage = new ImageIcon("Icon/MainUI/function/lock.png"); - lock.setIcon(lockImage); - function.remove(lockPanel); - isLocked = true; - } - MainUI.this.revalidate(); - MainUI.this.repaint(); - } - }); - //将所有组件加入到function中 - function.add(moveAndLock, BorderLayout.NORTH); - function.add(lockPanel, BorderLayout.CENTER); - //将function加入到UI中 - this.add(function, BorderLayout.EAST); - //添加桌宠 - - tablePet.setContentAreaFilled(false); - tablePet.setBorderPainted(false); - this.add(tablePet, BorderLayout.CENTER); - //添加桌宠左侧选项卡 - JPanel petPanel = new JPanel(); - petPanel.setLayout(new GridLayout(3, 1)); - petPanel.setBackground(new Color(0, 0, 0, 0)); - //添加图标 - ImageIcon petEatImage = new ImageIcon("Icon/MainUI/action/eat.png"); - JButton petEat = new JButton(petEatImage); - petEat.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - Toolkit toolkit = Toolkit.getDefaultToolkit(); - Random whatToEat = new Random(); - int eat = whatToEat.nextInt(5); - ImageIcon eatImageIcon; - if (eat == 0) { - eatImageIcon = new ImageIcon("Icon/MainUI/food/hot dog.png"); - } else if (eat == 1) { - eatImageIcon = new ImageIcon("Icon/MainUI/food/ice.png"); - } else if (eat == 2) { - eatImageIcon = new ImageIcon("Icon/MainUI/food/meat.png"); - } else if (eat == 3) { - eatImageIcon = new ImageIcon("Icon/MainUI/food/spring roll.png"); - } else { - eatImageIcon = new ImageIcon("Icon/MainUI/food/taco.png"); - } - Image eatImage = eatImageIcon.getImage(); - Cursor cu = toolkit.createCustomCursor(eatImage, new Point(10, 10), "eat"); - MainUI.this.setCursor(cu); - isInEating = true; - } - }); - petEat.setContentAreaFilled(false); - petEat.setBorderPainted(false); - petPanel.add(petEat); - ImageIcon petChatImage = new ImageIcon("Icon/MainUI/action/chat.png"); - JButton petChat = new JButton(petChatImage); - petChat.setContentAreaFilled(false); - petChat.setBorderPainted(false); - petPanel.add(petChat); - ImageIcon petUserImage = new ImageIcon("Icon/MainUI/action/user.png"); - JButton petUser = new JButton(petUserImage); - petUser.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - UserUI userUI; - try { - userUI = new UserUI(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - userUI.setVisible(true); - } - }); - petUser.setContentAreaFilled(false); - petUser.setBorderPainted(false); - petPanel.add(petUser); - //给桌宠添加单击事件 - tablePet.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - if (isInEating) { - //noinspection deprecation - MainUI.this.setCursor(0); - Map map = System.getenv(); - String userName = map.get("USERNAME"); - File folderPath = new File("C:\\Users\\"+userName+"\\.DesktopAide\\growth"); - File filePath = new File(folderPath+"\\growth.da"); - int line = 1; - try { - readAppointedLineNumber(filePath,line); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - int growth = Integer.parseInt(result)+5; - FileOutputStream fileOutputStream; - try { - fileOutputStream = new FileOutputStream(filePath); - fileOutputStream.write(String.valueOf(growth).getBytes(StandardCharsets.UTF_8)); - fileOutputStream.flush(); - fileOutputStream.close(); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - - isInEating = false; - } else { - if (isRelease) { - MainUI.this.remove(petPanel); - isRelease = false; - } else { - MainUI.this.add(petPanel, BorderLayout.WEST); - isRelease = true; - } - MainUI.this.revalidate(); - MainUI.this.repaint(); - } - } - }); - } -} diff --git a/target/DesktopAide-3.4.0.jar b/target/DesktopAide-3.4.0.jar index 080e9d8..010f33e 100644 Binary files a/target/DesktopAide-3.4.0.jar and b/target/DesktopAide-3.4.0.jar differ diff --git a/target/classes/CN/Function/Update/CheckUpdate.class b/target/classes/CN/Function/Update/CheckUpdate.class index 85f57ac..c021634 100644 Binary files a/target/classes/CN/Function/Update/CheckUpdate.class and b/target/classes/CN/Function/Update/CheckUpdate.class differ diff --git a/target/classes/CN/UI/FunctionPanel/CollationPanel$1.class b/target/classes/CN/UI/FunctionPanel/CollationPanel$1.class index 267409c..70ae123 100644 Binary files a/target/classes/CN/UI/FunctionPanel/CollationPanel$1.class and b/target/classes/CN/UI/FunctionPanel/CollationPanel$1.class differ diff --git a/target/classes/CN/UI/FunctionPanel/CollationPanel$2.class b/target/classes/CN/UI/FunctionPanel/CollationPanel$2.class index 7bfca4c..fce0479 100644 Binary files a/target/classes/CN/UI/FunctionPanel/CollationPanel$2.class and b/target/classes/CN/UI/FunctionPanel/CollationPanel$2.class differ diff --git a/target/classes/CN/UI/FunctionPanel/CollationPanel.class b/target/classes/CN/UI/FunctionPanel/CollationPanel.class index b3938f4..99aa590 100644 Binary files a/target/classes/CN/UI/FunctionPanel/CollationPanel.class and b/target/classes/CN/UI/FunctionPanel/CollationPanel.class differ diff --git a/target/classes/EN/UI/Main.class b/target/classes/EN/UI/Main.class index b7db125..0a8567f 100644 Binary files a/target/classes/EN/UI/Main.class and b/target/classes/EN/UI/Main.class differ diff --git a/target/classes/RUS/UI/Main.class b/target/classes/RUS/UI/Main.class index 0fb257c..aac4a0e 100644 Binary files a/target/classes/RUS/UI/Main.class and b/target/classes/RUS/UI/Main.class differ