亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? snapshotdialog.java

?? SWT編程 實(shí)現(xiàn)抓屏操作
?? JAVA
字號(hào):
/*
* LumaQQ - Java QQ Client
*
* Copyright (C) 2004 luma <stubma@163.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package edu.tsinghua.lumaqq.ui.dialogs;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Decorations;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Spinner;

/**
 * 抓屏對(duì)話框,用戶在這里設(shè)置需要抓的屏大小和延時(shí)
 *
 * @author luma
 */
public class SnapshotDialog extends Dialog {
	private int delaySecond;
	private int x, y, w, h;
	private Image snapshot;
	private Rectangle screenBound;
	
	private Button rdoFull;
	private Spinner spinDelay;
	private Composite simScreen;
	private Decorations areaSlider;
	private Button rdoPart;
	private Spinner spinX, spinY, spinW, spinH; 
	
	private int downX, downY;
	private boolean moving;
	private Button btnShow;
	
	private Runnable snapAction = new Runnable() {
		public void run() {
			GC gc = new GC(getShell().getDisplay());
			int actW = Math.min(w, screenBound.width - x);
			int actH = Math.min(h, screenBound.height - y);
			snapshot = new Image(getShell().getDisplay(), actW, actH);
			gc.copyArea(snapshot, x, y);
			gc.dispose();
			
			postSnap();
		}
	};
	private static final int SHOW_AREA_ID = 999;
	private Image screen;

	public SnapshotDialog(Shell parentShell) {
		super(parentShell);
	}

	@Override
	protected void configureShell(Shell newShell) {
		super.configureShell(newShell);
		newShell.setText("JSnapshot");
		newShell.addDisposeListener(new DisposeListener() {
			public void widgetDisposed(DisposeEvent e) {
				screen.dispose();				
			}
		});
	}
	
	@Override
	protected int getShellStyle() {
		return SWT.SHELL_TRIM ^ (SWT.MAX | SWT.RESIZE);
	}
	
	@Override
	protected Control createDialogArea(Composite parent) {
		Composite control = (Composite)super.createDialogArea(parent);
		screenBound = getShell().getDisplay().getBounds();
		control.addPaintListener(new PaintListener() {
			public void paintControl(PaintEvent e) {
				Rectangle rect = simScreen.getBounds();
				rect.x--;
				rect.y--;
				rect.width++;
				rect.height++;
				e.gc.drawRectangle(rect);
			}
		});
		
		// 延遲時(shí)間
		Composite container = new Composite(control, SWT.NONE);
		container.setLayoutData(new GridData());
		container.setLayout(new GridLayout(2, false));
		Label lblDelay = new Label(container, SWT.LEFT);
		lblDelay.setLayoutData(new GridData());
		lblDelay.setText("Delay Second:");
		spinDelay = new Spinner(container, SWT.BORDER);
		spinDelay.setLayoutData(new GridData());
		spinDelay.setMinimum(0);
		spinDelay.setMaximum(Integer.MAX_VALUE);
		spinDelay.setIncrement(1);
		spinDelay.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				delaySecond = spinDelay.getSelection();
			}
		});
		
		// separator
		new Label(control, SWT.SEPARATOR | SWT.HORIZONTAL).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		
		// 抓全部
		rdoFull = new Button(control, SWT.RADIO);
		rdoFull.setText("Full Screen (" + screenBound.width + 'x' + screenBound.height + ')');
		rdoFull.setLayoutData(new GridData());
		rdoFull.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				x = y = 0;
				w = screenBound.width;
				h = screenBound.height;
				simScreen.setBackground(simScreen.getParent().getBackground());
			}
		});
		// 抓部分
		rdoPart = new Button(control, SWT.RADIO);
		rdoPart.setText("Part of Screen");
		rdoPart.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		rdoPart.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				getAreaSize();
				updateAreaBound();
				simScreen.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE));
			}
		});
		// x, y, w, h的spinner,本來(lái)不想要,但是descorations在linux下面有點(diǎn)不正常,只好加上這個(gè)功能
		Composite spinContainer = new Composite(control, SWT.NONE);
		spinContainer.setLayoutData(new GridData());
		GridLayout layout = new GridLayout(8, false);
		layout.marginHeight = layout.marginWidth = 0;
		spinContainer.setLayout(layout);
		Label lbl = new Label(spinContainer, SWT.LEFT);
		lbl.setLayoutData(new GridData());
		lbl.setText("X:");
		spinX = new Spinner(spinContainer, SWT.NONE);
		spinX.setLayoutData(new GridData());
		spinX.setMinimum(0);
		spinX.setMaximum(screenBound.width);
		spinX.setIncrement(3);
		spinX.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				x = spinX.getSelection();
				updateSliderBound();
			}
		});
		lbl = new Label(spinContainer, SWT.LEFT);
		lbl.setLayoutData(new GridData());
		lbl.setText("Y:");
		spinY = new Spinner(spinContainer, SWT.NONE);
		spinY.setLayoutData(new GridData());
		spinY.setMinimum(0);
		spinY.setMaximum(screenBound.height);
		spinY.setIncrement(3);
		spinY.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				y = spinY.getSelection();
				updateSliderBound();
			}
		});
		lbl = new Label(spinContainer, SWT.LEFT);
		lbl.setLayoutData(new GridData());
		lbl.setText("Width:");
		spinW = new Spinner(spinContainer, SWT.NONE);
		spinW.setLayoutData(new GridData());
		spinW.setMinimum(0);
		spinW.setMaximum(Integer.MAX_VALUE);
		spinW.setIncrement(3);
		spinW.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				w = spinW.getSelection();
				updateSliderBound();
			}
		});
		lbl = new Label(spinContainer, SWT.LEFT);
		lbl.setLayoutData(new GridData());
		lbl.setText("Height:");
		spinH = new Spinner(spinContainer, SWT.NONE);
		spinH.setLayoutData(new GridData());
		spinH.setMinimum(0);
		spinH.setMaximum(Integer.MAX_VALUE);
		spinH.setIncrement(3);
		spinH.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				h = spinH.getSelection();
				updateSliderBound();
			}
		});
		
		// 模擬屏幕,1/3大小
		simScreen = new Composite(control, SWT.NONE);
		GridData gd = new GridData();
		gd.widthHint = screenBound.width / 3;
		gd.heightHint = screenBound.height / 3;
		simScreen.setLayoutData(gd);
		layout = new GridLayout();
		layout.marginHeight = layout.marginWidth = 0;
		simScreen.setLayout(layout);
		simScreen.addPaintListener(new PaintListener() {
			public void paintControl(PaintEvent e) {
				e.gc.drawImage(screen, 0, 0);
			}
		});
		
		// 抓屏區(qū)域滑塊
		areaSlider = new Decorations(simScreen, SWT.BORDER | SWT.RESIZE);
		areaSlider.setLocation(0, 0);
		areaSlider.setCursor(getShell().getDisplay().getSystemCursor(SWT.CURSOR_SIZEALL));
		areaSlider.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseDown(MouseEvent e) {
				downX = e.x;
				downY = e.y;
				moving = true;
			}
			@Override
			public void mouseUp(MouseEvent e) {
				moving = false;
			}
		});
		areaSlider.addMouseMoveListener(new MouseMoveListener() {
			public void mouseMove(MouseEvent e) {
				if(moving && rdoPart.getSelection()) {
					Point loc = areaSlider.getLocation();
					int x = loc.x + e.x - downX;
					int y = loc.y + e.y - downY;
					areaSlider.setLocation(x, y);	
				}
			}
		});
		areaSlider.addControlListener(new ControlListener() {
			public void controlMoved(ControlEvent e) {
				if(rdoPart.getSelection()) {
					getAreaSize();
					updateAreaBound();
				}
			}
			public void controlResized(ControlEvent e) {
				if(rdoPart.getSelection()) {
					getAreaSize();
					updateAreaBound();					
				}
			}
		});

		initialize();
		
		return control;
	}
	
	@Override
	protected void createButtonsForButtonBar(Composite parent) {
		btnShow = createButton(parent, SHOW_AREA_ID , "Show Area", false);
		btnShow.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseDown(MouseEvent e) {
				drawAreaXOR();
			}
			@Override
			public void mouseUp(MouseEvent e) {
				drawAreaXOR();
				
				// 區(qū)域邊框如果和button有些重疊,則重疊的部分會(huì)留下殘影,為了消除這些,這里重畫所有button
				Composite bar = (Composite)getButtonBar();
				for(Control child : bar.getChildren())
					child.redraw();
			}
		});
		super.createButtonsForButtonBar(parent);
	}
	
	/**
	 * 在屏幕上畫矩形
	 */
	private void drawAreaXOR() {
		GC gc = new GC(getShell().getDisplay());
		gc.setXORMode(true);
		gc.setLineWidth(5);
		gc.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_GREEN));
		gc.drawRectangle(x, y, w, h);
		gc.dispose();
	}
	
	/**
	 * 得到抓屏區(qū)域大小
	 */
	private void getAreaSize() {
		Rectangle rect = areaSlider.getBounds();
		x = rect.x * 3;
		y = rect.y * 3;
		w = rect.width * 3;
		h = rect.height * 3;
	}

	/**
	 * 初始化控件和變量
	 */
	private void initialize() {		
		rdoFull.setSelection(true);
		spinDelay.setSelection(0);
		Image temp = new Image(getShell().getDisplay(), screenBound.width, screenBound.height);
		GC gc = new GC(getShell().getDisplay());
		gc.copyArea(temp, 0, 0);
		gc.dispose();
		ImageData data = temp.getImageData().scaledTo(screenBound.width / 3, screenBound.height / 3);
		screen = new Image(getShell().getDisplay(), data);
		temp.dispose();
		
		delaySecond = 0;
		x = y = 0;
		w = screenBound.width;
		h = screenBound.height;
		
		moving = false;
	}	
	
	/**
	 * 抓圖完成后執(zhí)行的動(dòng)作
	 */
	protected void postSnap() {
		getShell().setVisible(true);
		getShell().setMinimized(false);
		getShell().setActive();
		
		SnapshotPreviewDialog dialog = new SnapshotPreviewDialog(getShell(), snapshot);
		if(dialog.open() == IDialogConstants.OK_ID)
			close();
	}
	
	@Override
	protected void okPressed() {
		getShell().setVisible(false);
		getShell().getDisplay().timerExec(delaySecond * 1000, snapAction);
	}
	
	/**
	 * 更新radiobutton的文本
	 */
	private void updateAreaBound() {
		spinX.setSelection(x);
		spinY.setSelection(y);
		spinW.setSelection(w);
		spinH.setSelection(h);
	}
	
	/**
	 * 設(shè)置滑塊的位置大小
	 */
	private void updateSliderBound() {
		areaSlider.setBounds(x / 3, y / 3, w / 3, h / 3);
	}

	/**
	 * @return the snapshot
	 */
	public Image getSnapshot() {
		return snapshot;
	}
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品对白交换视频| 日韩精品一区二区三区四区 | 日本伊人午夜精品| 国产91精品在线观看| 538在线一区二区精品国产| 成人欧美一区二区三区| 国内精品伊人久久久久影院对白| 91黄色激情网站| 国产欧美综合在线观看第十页| 日韩vs国产vs欧美| 色婷婷综合中文久久一本| 国产亚洲综合av| 另类小说欧美激情| 欧美日韩一区二区三区四区| 中文字幕一区二区三区四区| 国产精品主播直播| 欧美成人a∨高清免费观看| 亚洲成人免费观看| 91成人免费在线| 亚洲免费av在线| 成人18视频在线播放| 久久精品网站免费观看| 久久精品999| 欧美一区二区三区小说| 亚洲福中文字幕伊人影院| 色综合久久88色综合天天免费| 中文一区在线播放| 国产福利精品一区| 精品少妇一区二区三区日产乱码 | 久久网站热最新地址| 日韩精品成人一区二区在线| 欧美日韩一区二区三区在线看| 亚洲精品写真福利| 92国产精品观看| 国产精品久久久久影院亚瑟| 成人夜色视频网站在线观看| 久久久久久久久久久久久久久99| 精品影院一区二区久久久| 日韩一级免费观看| 免费成人性网站| 欧美一区二区三区白人| 日本成人超碰在线观看| 6080午夜不卡| 免费日韩伦理电影| 日韩一区二区三区视频| 日韩电影免费在线| 欧美成人精品1314www| 激情五月激情综合网| 精品捆绑美女sm三区| 国产在线国偷精品免费看| 精品1区2区在线观看| 精品制服美女丁香| 久久久另类综合| 成人在线视频首页| 日韩理论片网站| 一本到三区不卡视频| 伊人夜夜躁av伊人久久| 欧美日韩精品一区视频| 三级在线观看一区二区| 欧美v亚洲v综合ⅴ国产v| 国产精品一区二区无线| 国产精品麻豆99久久久久久| 91一区一区三区| 亚洲永久精品国产| 制服丝袜中文字幕亚洲| 久久国产麻豆精品| 国产欧美一区二区精品秋霞影院| 成人国产免费视频| 亚洲激情欧美激情| 91精选在线观看| 国产美女主播视频一区| 国产精品久久综合| 欧美午夜视频网站| 久久er99热精品一区二区| 久久精品免视看| 色婷婷综合五月| 日本aⅴ精品一区二区三区| 精品国产乱码久久久久久蜜臀| 成人免费观看av| 亚洲国产综合人成综合网站| 日韩视频永久免费| 99综合电影在线视频| 亚洲高清免费一级二级三级| 2021中文字幕一区亚洲| 91小视频在线免费看| 男人的j进女人的j一区| 中文字幕精品一区二区精品绿巨人 | 久久精品亚洲精品国产欧美 | 国产盗摄女厕一区二区三区| 亚洲欧洲无码一区二区三区| 在线播放/欧美激情| 国产精品一二三四区| 一区二区三区自拍| 精品国产123| 色视频欧美一区二区三区| 久久精品国产成人一区二区三区| 中文字幕欧美激情| 9191成人精品久久| 成人午夜视频免费看| 天天操天天色综合| 国产精品电影一区二区三区| 日韩一区和二区| 91免费版在线| 国产综合久久久久久鬼色 | 国产性做久久久久久| 在线国产电影不卡| 国产呦精品一区二区三区网站| 一区二区三区不卡视频| 久久久久久电影| 欧美日韩精品一区二区| av在线这里只有精品| 蜜臀av性久久久久蜜臀av麻豆| 亚洲男人的天堂在线观看| 精品粉嫩超白一线天av| 欧美色图免费看| 成人黄色a**站在线观看| 久久成人久久鬼色| 亚洲成人一区二区在线观看| 中文字幕日本乱码精品影院| 欧美sm极限捆绑bd| 欧美日韩国产区一| 91在线精品一区二区| 国产激情一区二区三区四区| 日韩国产成人精品| 亚洲永久免费av| 亚洲欧美另类在线| 亚洲国产精品ⅴa在线观看| 日韩一区二区在线免费观看| 色噜噜狠狠成人网p站| 风间由美一区二区av101| 美女精品自拍一二三四| 亚洲国产精品一区二区www| 综合久久久久久久| 欧美激情一区二区在线| 精品国产乱码久久久久久图片| 欧美久久高跟鞋激| 91黄色免费看| 色美美综合视频| 91在线观看高清| www.66久久| 成人网在线免费视频| 国产一区二区三区国产| 免费观看一级欧美片| 日本强好片久久久久久aaa| 亚洲国产成人高清精品| 亚洲人成电影网站色mp4| 国产精品久久久一本精品 | 91精品国产91热久久久做人人| 欧美日韩午夜在线| 欧美午夜电影网| 欧美日韩中文字幕一区| 欧洲av在线精品| 日本精品一区二区三区高清| 91麻豆国产精品久久| 不卡免费追剧大全电视剧网站| 粉嫩高潮美女一区二区三区| 国产福利一区在线| 成人黄色免费短视频| 99精品热视频| 91视频在线观看免费| 色综合视频一区二区三区高清| 色哟哟一区二区在线观看| 色噜噜狠狠色综合中国| 在线观看国产日韩| 欧美日韩一区久久| 91精品黄色片免费大全| 日韩欧美在线观看一区二区三区| 制服丝袜一区二区三区| 欧美成人一区二区三区片免费 | 在线一区二区观看| 欧美色偷偷大香| 91 com成人网| 欧美tk—视频vk| 国产日韩欧美综合在线| 国产精品免费看片| 亚洲色图视频网站| 亚洲va欧美va天堂v国产综合| 青青草国产精品亚洲专区无| 精品一区二区三区欧美| 国产高清一区日本| 成人国产视频在线观看| 色婷婷av一区二区三区gif| 欧美精品丝袜中出| 欧美大片顶级少妇| 国产欧美一区二区精品婷婷| 亚洲欧美国产毛片在线| 午夜欧美电影在线观看| 极品少妇一区二区三区精品视频 | 青青草97国产精品免费观看| 久久99精品一区二区三区| 国产成人av电影在线播放| 91视频在线观看免费| 欧美日本在线一区| 2欧美一区二区三区在线观看视频| 国产亚洲欧美一级| 一区二区三区在线视频观看58| 日本伊人精品一区二区三区观看方式| 精品一区二区在线视频| 99这里都是精品| 884aa四虎影成人精品一区|