程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> C#生成code128條形碼的辦法

C#生成code128條形碼的辦法

編輯:C#入門知識

C#生成code128條形碼的辦法。本站提示廣大學習愛好者:(C#生成code128條形碼的辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是C#生成code128條形碼的辦法正文


本文實例引見了Android若何畫出觸摸軌跡的辦法,分享給年夜家供年夜家參考,詳細內容以下

後果圖:

完成代碼:

package com.android.gameview5;

import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceHolder.Callback;
import android.view.SurfaceView;
import android.view.Window;
import android.view.WindowManager;

public class SurfaceViewActivity3 extends Activity {
  public void onCreate(Bundle s){
  super.onCreate(s);
  //全屏顯示
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
  WindowManager.LayoutParams.FLAG_FULLSCREEN);
  setContentView(new MyView(this));
  }
  public class MyView extends SurfaceView implements Callback,Runnable{

  
  public static final int TIME_IN_FRAME =50;
  
  Paint mPaint = null;
  Paint mTextPaint = null;
  SurfaceHolder mSurfaceHolder = null;
  
  
  boolean mRunning = false;
  
  
  Canvas mCanvas = null;
  
  
  private Path mPath;
  
  private float mPosX,mPosY;
  
public MyView(Context context){
super(context);
this.setFocusable(true);
this.setFocusableInTouchMode(true);
  mSurfaceHolder = this.getHolder();
  mSurfaceHolder.addCallback(this);
  mCanvas = new Canvas();
      
  mPaint = new Paint();
  mPaint.setColor(Color.BLACK);
  
  
  mPaint.setAntiAlias(true);
  
  mPaint.setStyle(Paint.Style.STROKE);
  
  
  mPaint.setStrokeCap(Paint.Cap.ROUND);
  
  
  mPaint.setStrokeWidth(6);
  
  mPath = new Path();
  
  
  mTextPaint = new Paint();
  
  mTextPaint.setColor(Color.BLACK);
  
  mTextPaint.setTextSize(15);
  
}
public boolean onTouchEvent(MotionEvent event){
  int action = event.getAction();
  float x = event.getX();
  float y = event.getY();
  switch(action){
  case MotionEvent.ACTION_DOWN:
  mPath.moveTo(x, y);
  break;
  case MotionEvent.ACTION_MOVE:
  mPath.quadTo(mPosX, mPosY, x, y);
  break;
  case MotionEvent.ACTION_UP:
  //mPath.reset();
  break;
  }
  //記載以後觸摸點適合前得坐標
  mPosX = x;
  mPosY = y;
return true;
}
private void onDraw(){
mCanvas.drawColor(Color.WHITE);
//繪制曲線
mCanvas.drawPath(mPath, mPaint);
mCanvas.drawText("以後觸筆X:"+mPosX,0,20,mTextPaint);
mCanvas.drawText("以後觸筆Y:"+mPosY,0,40,mTextPaint);
}
public void run() {
// TODO Auto-generated method stub
while(mRunning){
long startTime = System.currentTimeMillis();
synchronized(mSurfaceHolder){
mCanvas = mSurfaceHolder.lockCanvas();
onDraw();
mSurfaceHolder.unlockCanvasAndPost(mCanvas);
}
long endTime = System.currentTimeMillis();
int diffTime = (int) (endTime - startTime);
while(diffTime<=TIME_IN_FRAME){
diffTime =(int)(System.currentTimeMillis()-startTime);
Thread.yield();
}
}
}

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
// TODO Auto-generated method stub
}

@Override
public void surfaceCreated(SurfaceHolder holder) {
mRunning = true;
new Thread(this).start();
}

@Override
public void surfaceDestroyed(SurfaceHolder holder) {
// TODO Auto-generated method stub
mRunning = false;
}
  
  }
}

以上就是Android輕松畫出觸摸軌跡的詳細辦法,願望對年夜家的進修有所贊助。

  1. 上一頁:
  2. 下一頁: