zsh_root
2024-01-02 7b595546af704983dbafcd0d385c8768ddacefc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
package relloc;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import ColorAndFont.ChooseFont;
import ColorAndFont.UIColor;
import JNADell.Dell_usetaganchor;
import Method.ControTag;
import Method.GetNowTime;
import PbuliClass.JButtonModel;
import PbuliClass.ShowMessage;
import tag.Tag;
import tag.Tag_Dell;
import urt.Control_urt;
public class Sendmessage extends JDialog implements WindowListener {
 
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    JTextField text=null;//Îı¾¿ò
    JPanel mb=null;//ÉêÃ÷Ò»¸öÃæ°å
    JButtonModel serch=null;//²éÕÒ±êÇ©
    boolean sou=false;
    JComboBox<String> tagAll=null;//ËùÓбêÇ©µÄ¼¯ºÏ
    JTextArea textArea=null;
    JScrollPane gd2=null;
 
    /**»ñÈ¡¶Ô»°¿ò·½·¨*/
    public Sendmessage(String title) {        
        super();
        this.setAlwaysOnTop(true);//×ÜÊÇÖö¥
        this.setTitle(title);
        Toolkit toolkit = getToolkit();// »ñµÃ´°Ì幤¾ß°ü
        Dimension screenSize = toolkit.getScreenSize();// »ñÈ¡ÆÁÄ»´óС
        int width = (int) (screenSize.width* 0.5);// ¼ÆËã´°Ìåпí¶È
        int height = (int) (screenSize.height * 0.5);// ¼ÆËã´°Ìåпí¶È
        int w=500;
        int h=350;
        int x0=width-w/2;//´°Ìåx0×ø±ê
        int y0=height-h/2;//´°Ìåy0×ø±ê
        Container rq=getContentPane();        
        rq.add(getMb());
        this.setBounds(x0, y0,w,h);
        this.addWindowListener((WindowListener) this);
        this.setVisible(true);
    }
 
    /**»ñÈ¡Ãæ°å*/
    public JPanel getMb() {
        if(mb==null){
            mb=new JPanel();
            mb.setLayout(null);
            mb.setBackground(Color.white);
            mb.add(gettext());
            mb.add(getTagAll());
            mb.add(getGd2());
            int x=10;
            int y=20;
            int height=30;
            tagAll.setBounds(x, y,100, height);
            text.setBounds(x+120, y,250, height);            
            mb.add(getserch());
            serch.setBounds(x+373, y,80, height);
            gd2.setBounds(x, y+50,460, 200);
 
        }
        return mb;
    }
 
    public JTextField gettext() {
        if(text==null) {
            text=new JTextField(10);
            text.setFont(ChooseFont.getFont(14));
            text.setForeground(Color.red);
        }
        return text;
    }
 
    /**ËÑË÷°´Å¥*/
    public JButtonModel getserch() {
        if(serch==null) {
            serch=new JButtonModel("·¢ËÍ");
            serch.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    String tagid=(String) tagAll.getSelectedItem();
                    String message=text.getText();                    
                    if(message.length()<1) {
                        ShowMessage.zidingyi("Ï·¢ÄÚÈݲ»ÄÜΪ¿Õ");
                        return;
                    }
                    String a=GetNowTime.now2()+":"+tagid+","+message;
                    Tag  tag=Tag_Dell.get_tag(tagid);
                    if(tag==null) {
                        ShowMessage.zidingyi(tagid+"²»´æÔÚgetserch");
                        return;
                    }
                    String tagtype=tag.getTagtype();                
                    if(tagid.equals("ËùÓбêÇ©")) {
                        Dell_usetaganchor.alltagtomessge(message,"ϵͳĬÈÏ");
                    }else {
                        if(tagtype.equals("ÐÄÂÊ´øÆÁ")) {
                            Dell_usetaganchor.message_to_oled(tagid, message,"ϵͳĬÈÏ");
                        }else if(tagtype.equals("³µÔØ´øÆÁ")) {
                            Dell_usetaganchor.USERINFO(tagid, message);
                        }else if(tagtype.equals("ϵͳĬÈÏ")) {
                            ControTag.konghzitag(10, tagid,(byte)0x10,"Õñ¶¯","SendmessageÕð¶¯");
                        }else if(tagtype.equals("URT+CO")) {
                            Control_urt.say_voice(tagid, message,1,3);
                        }else if(tagtype.equals("ÈÚºÏÖÕ¶Ë")) {
                            Control_urt.say_voice(tagid, message,1,3);
                            ControTag.konghzitag(10, tagid,(byte)0x10,"Õñ¶¯","SendmessageÕð¶¯");
                        }else if (tagtype.equals("¹¤ÅÆ´øÆÁ")){
                            Dell_usetaganchor.message_to_Lora(tagid,message,"¹¤ÅÆ´øÆÁ","66");
                        }
                        else {
                            ControTag.konghzitag(10, tagid,(byte)0x10,"Õñ¶¯","SendmessageÕð¶¯");
                        }
                    }
                    textArea.append(a+"£¬±êÇ©ÀàÐÍ"+tagtype+"\n");
                    textArea.setCaretPosition(textArea.getText().length());
                }
            });
        }
        return serch;
    }
 
 
    @Override
    public void windowOpened(WindowEvent e) {
        // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
 
    }
 
    @Override
    public void windowClosing(WindowEvent e) {
 
    }
 
    @Override
    public void windowClosed(WindowEvent e) {
 
 
    }
 
    @Override
    public void windowIconified(WindowEvent e) {        
    }
 
    @Override
    public void windowDeiconified(WindowEvent e) {
        // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
 
    }
 
    @Override
    public void windowActivated(WindowEvent e) {
        // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
 
    }
 
    @Override
    public void windowDeactivated(WindowEvent e) {
        // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
 
    }
 
    public JComboBox<String> getTagAll() { 
        if(tagAll==null) {
            tagAll=new JComboBox<String>() ;
            tagAll.setFont(new Font("΢ÈíÑźÚ", Font.PLAIN, 12));//ÉèÖÃ×ÖÌå
            ComboBoxModel<String > coModel=new DefaultComboBoxModel<>(Tag_Dell.GetTagAllstr());//ÏÂÀ­ÁбíÄ£ÐÍ            
            tagAll.setModel(coModel);
            tagAll.setEnabled(true);
            //ÏÂÀ­¿ò¿ÉÒÔÊäÈë
            tagAll.setEditable(true);
        }
        return tagAll;
    }
 
    public  JTextArea get_text_area() {
        if(textArea==null) {
            textArea=new JTextArea(10,10);
            textArea.setBackground(UIColor.getNorth_color());
            textArea.setForeground(UIColor.getTable_font());
            textArea.setFont(ChooseFont.getFont(13));
        }
        return textArea;
    }
 
    /**»ñÈ¡¹ö¶¯Ãæ°å*/
    public JScrollPane getGd2() {
        if(gd2==null) {
            gd2=new JScrollPane(get_text_area());
        }
        return gd2;
    }
}