


对于工程密码的保护还有BUG,一不小心被我捣鼓出来了
/**
* AutoShape Clock
* Create at 1-1-2004, by Lenny Christmas
* Modify at 1-2-2004, by Lenny Christmas
* EIO Macro Editor 1.1-146-0
*/
/**
*Define Clock's size
*/
int D_CLOCK = 200;
int R_CLOCK = D_CLOCK/2;
int START_X = 300;
int START_Y = 200;
int DISTANTANCE = 10;
Date DATE = new Date();
Application.gotoProduct(1);
Shapes ss = Application.getWorkbooks().getActiveWorkbook().getActiveShapes();
/**
*Main Clock
*/
void clock(){
createClockPanel();
createClockPointer();
createDegree();
runPointer1();
runPointer2();
runPointer3();
}
/**
*Create Clock panel
*/
void createClockPanel(){
//Add Clock panel to WordProcessor
ss.addShape(ShapeConstants.SHAPE_OVAL,START_X,START_Y,START_X+D_CLOCK,START_Y+D_CLOCK);
//set Clock panel style
//ss.getRange().getFillFormat().getTextureInfo().setImageDescription("大理石");//reference image
ss.getRange().getFillFormat().getPatternInfo().setTextureIndex(29);
ss.getRange().getFillFormat().getPatternInfo().setForeground(new java.awt.Color(155,155,155));
ss.getRange().getFillFormat().getPatternInfo().setBackground(new java.awt.Color(235,245,255));
//ss.getRange().getFillFormat().getPictureInfo().setPath("C:/xx.jpg");//reference picture
ss.getRange().getLineFormat().getPatternFormat().setColor(new java.awt.Color(255,100,0));
ss.getRange().getLineFormat().setWidth(2.25);
}
/**
*Create Clock pointer
*/
void createClockPointer(){
//Add second pointer to Clock
ss.addLine(START_X+R_CLOCK,START_Y+R_CLOCK,START_X+R_CLOCK,START_Y+D_CLOCK-DISTANTANCE*2);
ss.getRange().getLineFormat().setEndArrowStyle(4);
ss.getRange().getLineFormat().setEndArrowWidth(2);
ss.getRange().getLineFormat().setWidth(0.5);
ss.getRange().getLineFormat().getPatternFormat().setNoColor();
ss.addLine(START_X+R_CLOCK,START_Y+R_CLOCK,START_X+R_CLOCK,START_Y+DISTANTANCE*2);
ss.getRange().getLineFormat().setEndArrowStyle(4);
ss.getRange().getLineFormat().setEndArrowWidth(2);
ss.getRange().getLineFormat().setWidth(0.5);
ss.getRange().getLineFormat().getPatternFormat().setColor(new java.awt.Color(255,0,0));
ss.getShape("直线 2").select(false);
ss.getRange().group();
//Add minute pointer to Clock
ss.addLine(START_X+R_CLOCK,START_Y+R_CLOCK,START_X+R_CLOCK,START_Y+D_CLOCK-DISTANTANCE*3);
ss.getRange().getLineFormat().getPatternFormat().setNoColor();
ss.getRange().getLineFormat().setWidth(1.0);
ss.addLine(START_X+R_CLOCK,START_Y+DISTANTANCE*3,START_X+R_CLOCK,START_Y+R_CLOCK);
ss.getRange().getLineFormat().setWidth(1.0);
ss.getRange().getLineFormat().getPatternFormat().setColor(new java.awt.Color(0,128,0));
ss.getShape("直线 2").select(false);
ss.getRange().group();
//Add hour pointer to Clock
ss.addLine(START_X+R_CLOCK,START_Y+R_CLOCK,START_X+R_CLOCK,START_Y+D_CLOCK-DISTANTANCE*5);
ss.getRange().getLineFormat().setWidth(2.0);
ss.getRange().getLineFormat().getPatternFormat().setNoColor();
ss.addLine(START_X+R_CLOCK,START_Y+DISTANTANCE*5,START_X+R_CLOCK,START_Y+R_CLOCK);
ss.getRange().getLineFormat().getPatternFormat().setColor(new java.awt.Color(0,0,255));
ss.getRange().getLineFormat().setWidth(2.0);
ss.getShape("直线 2").select(false);
ss.getRange().group();
}
/**
*Add degrees and center to Clock panel
**/
void createDegree(){
//Add center
ss.addShape(ShapeConstants.SHAPE_OVAL,START_X+R_CLOCK-DISTANTANCE,START_Y+R_CLOCK-DISTANTANCE,START_X+R_CLOCK+DISTANTANCE,START_Y+R_CLOCK+DISTANTANCE);
ss.getRange().getFillFormat().getGradientInfo().setColor(new java.awt.Color(255,255,0),new java.awt.Color(255,204,0));
ss.getRange().getFillFormat().getGradientInfo().setColorTypeIndex(1);
ss.getRange().getFillFormat().getGradientInfo().setGradientStyleIndex(5);
ss.getRange().getFillFormat().getGradientInfo().setTextureIndex(2);
//Add twelve/four degrees
ss.addLine(START_X,START_Y+R_CLOCK,START_X+DISTANTANCE,START_Y+R_CLOCK);
ss.getRange().getLineFormat().setWidth(4.0);
ss.addLine(START_X+R_CLOCK,START_Y,START_X+R_CLOCK,START_Y+DISTANTANCE);
ss.getRange().getLineFormat().setWidth(4.0);
ss.addLine(START_X+R_CLOCK,START_Y+D_CLOCK-DISTANTANCE,START_X+R_CLOCK,START_Y+D_CLOCK);
ss.getRange().getLineFormat().setWidth(4.0);
ss.addLine(START_X+D_CLOCK-DISTANTANCE,START_Y+R_CLOCK,START_X+D_CLOCK,START_Y+R_CLOCK);
ss.getRange().getLineFormat().setWidth(4.0);
//Group degrees and center
ss.getShape("椭圆 2").select(false);
ss.getShape("直线 3").select(false);
ss.getShape("直线 13").select(false);
ss.getShape("直线 14").select(false);
ss.getShape("直线 15").select(false);
ss.getRange().group();
}
/**
*Run pointer
*/
void runPointer1(){
//Run second pointer
Thread movePointer = new Thread(new Runnable(){
void run(){
int second = DATE.getSeconds()*6;
while(true){
for(int i = 0;i<360;i++){
ss.getShape("组 4").select(true);
ss.getRange().setRotateAngle(second+i*6);
ss.getShape("组 4").unSelect();
try{
movePointer.sleep(1000);
}catch(Exception e){
Macro.showMessageDialog("Error:1");
}
}
}
}
});
movePointer.start();
}
void runPointer2(){
//Run minute pointer
Thread movePointer = new Thread(new Runnable(){
void run(){
int minute = DATE.getMinutes()*6;
while(true){
for(int i = 0;i<360;i++){
ss.getShape("组 7").select(true);
ss.getRange().setRotateAngle(minute+i*6);
ss.getShape("组 7").unSelect();
try{
movePointer.sleep(60000);
}catch(Exception e){
Macro.showMessageDialog("Error:2");
}
}
}
}
});
movePointer.start();
}
void runPointer3(){
//Run hour pointer
Thread movePointer = new Thread(new Runnable(){
void run(){
//Set hour pointer's position
int hour = DATE.getHours();
if (hour>=12)
hour = (hour-12)*30;
else
hour = hour*30;
hour=hour+Math.round(DATE.getMinutes()/2);
//Move the hour pointer
while(true){
for(int i = 0;i<30;i++){
ss.getShape("组 10").select(true);
ss.getRange().setRotateAngle(hour+i);
ss.getShape("组 10").unSelect();
try{
movePointer.sleep(120000);
}catch(Exception e){
Macro.showMessageDialog("Error:3");
}
}
hour=hour+30;
if(hour>=360) hour=hour-360;
}
}
});
movePointer.start();
}
/**
* Clear the clock
* Before the binder is closed, delete Clock
*/
void delete(){
ss.getShape("组 4").select(true);
ss.getRange().delete();
ss.getShape("组 7").select(true);
ss.getRange().delete();
ss.getShape("组 10").select(true);
ss.getRange().delete();
ss.getShape("椭圆 1").select(true);
ss.getRange().delete();
ss.getShape("组 16").select(true);
ss.getRange().delete();
}