• 口袋微薄源码

    package wyf.wpf; import static wyf.wpf.ConstantUtil.IMAGESWITCHER_HEIGHT; import static wyf.wpf.ConstantUtil.PHOTO_HEIGHT; import static wyf.wpf.ConstantUtil.PHOTO_WIDTH; import static wyf.wpf.ConstantUtil.SERVER_ADDRESS; import static wyf.wpf.ConstantUtil.SERVER_PORT; import java.util.ArrayList; import java.util.List; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Color; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.opengl.Visibility; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.view.View; import android.view.ViewGroup; import android.view.animation.AnimationUtils; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.Button; import android.widget.Gallery; import android.widget.ImageSwitcher; import android.widget.ImageView; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; import android.widget.ViewSwitcher; import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemSelectedListener; public class AlbumActivity extends Activity implements ViewSwitcher.ViewFactory{ List<String []> photoInfoList = new ArrayList<String []>(); Bitmap [] photoList; //存放图片的数组 Gallery gl = null; //Gallery对象的引用 ImageSwitcher is = null; //ImageSwitcher对象的引用 Spinner sp = null; //Spinner对象的引用 MyConnector mc = null; //MyConnector对象的引用 String xid = ""; //存放相册的ID String uno = ""; //存放用户ID String visitor = ""; //存放访问者的ID String pid = ""; //存放当前显示的照片ID int from = -1; //启动该Activity的来源,0为MyAlbumListActivity,1为AlbumListActivity List<String []> albumInfoList = new ArrayList<String []>(); //存放相册信息,id和相册名称 //Spinner的Adapter BaseAdapter baSpinner = new BaseAdapter() { @Override public View getView(int position, View convertView, ViewGroup parent) { TextView tv = new TextView(AlbumActivity.this); tv.setTextSize(18.5f); tv.setTextColor(Color.DKGRAY); String [] sa = albumInfoList.get(position); tv.setText(sa[1]); return tv; } @Override public long getItemId(int position) { return 0; } @Override public Object getItem(int position) { return null; } @Override public int getCount() { return albumInfoList.size(); } }; //Gallery的Adapter BaseAdapter baGallery= new BaseAdapter() { @Override public View getView(int position, View convertView, ViewGroup parent) { ImageView iv = new ImageView(AlbumActivity.this); iv.setAdjustViewBounds(true); iv.setLayoutParams(new Gallery.LayoutParams(PHOTO_WIDTH, PHOTO_HEIGHT)); iv.setMaxHeight(PHOTO_HEIGHT); //设置ImageView显示的高度 iv.setMaxWidth(PHOTO_WIDTH); //设置ImageView显示的宽度 iv.setImageBitmap(photoList[position]); //设置ImageView显示的内容 return iv; } @Override public long getItemId(int position) { return 0; } @Override public Object getItem(int position) { return null; } @Override public int getCount() { if(photoList != null){ return photoList.length; } else{ return 0; } } }; //点下Gallery中的图片后触发的事件监听器 OnItemClickListener myListener = new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View v, int position, long id) { if(is != null){ //如果ImageSwitcher不为空 Drawable d = new BitmapDrawable(photoList[position]); is.setImageDrawable(d); } } }; Handler myHandler = new Handler(){ @Override public void handleMessage(Message msg) { switch(msg.what){ case 0: gl.setAdapter(baGallery); is.setImageDrawable(new BitmapDrawable(photoList[0])); break; } super.handleMessage(msg); } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.album); //设置当前屏幕 Intent intent = getIntent(); //获取启动该Activity的Intent uno = intent.getStringExtra("uno"); //获得Extra字段的uno visitor = intent.getStringExtra("visitor"); from = intent.getIntExtra("from", -1); //获得Extra字段的from int position = intent.getIntExtra("position", 0); //获得被选中的相册 String [] albumInfoArray = intent.getStringArrayExtra("albumlist"); //获得相册信息数组 xid = intent.getStringExtra("xid"); //获得被选中的相册编号 albumInfoList = new ArrayList<String []>(); for(String s:albumInfoArray){ //遍历信息数组 String [] sa = s.split("\\|"); albumInfoList.add(sa); //构建相册信息列表 } sp = (Spinner)findViewById(R.id.spAlbum); //获得Spinner对象 sp.setAdapter(baSpinner); //设置Spinner对象的Adapter sp.setSelection(position); //选中在前一个Activity中被选中的相册 sp.setOnItemSelectedListener(new OnItemSelectedListener() { //为Spinner添加监听器 @Override public void onItemSelected(AdapterView&lt;?&gt; parent, View v, int position, long id) { xid = albumInfoList.get(position)[0]; //修改存储相册ID的成员变量 getPhotoList(); //获得相册中的相片列表 } @Override public void onNothingSelected(AdapterView&lt;?&gt; parent) {} }); gl = (Gallery)findViewById(R.id.galleryPhoto); //获得Gallery对象 gl.setOnItemClickListener(myListener); //设置Gallery的OnItemClickListener监听器 is = (ImageSwitcher)findViewById(R.id.isPhoto); //获得ImageSwitcher对象 is.setFactory(this); //设置ImageSwitcher的Factory is.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in)); //设置ImageSwitcher的In动画 is.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));//设置ImageSwitcher的Out动画 Button btnBack = (Button)findViewById(R.id.btnAlbumBack); //获得返回按钮btnBack btnBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { switch(from){ //判断启动该Activity的来源 case 0: //有MyAlbumListActivity启动 Intent intent1 = new Intent(AlbumActivity.this,FunctionTabActivity.class); intent1.putExtra("uno", uno); intent1.putExtra("tab", "tab5"); startActivity(intent1); finish(); break; case 1: //由AlbumListActivity启动 Intent intent2 = new Intent(AlbumActivity.this,HomePageActivity.class); intent2.putExtra("uno", uno); intent2.putExtra("visitor", visitor); intent2.putExtra("tab", "tab2"); startActivity(intent2); finish(); break; } } }); Button btnDeletePhoto = (Button)findViewById(R.id.btnDeletePhoto); if(visitor != null){ //不是查看自己的相册 btnDeletePhoto.setVisibility(View.GONE); //如果不是自己的相册,隐藏删除按钮 } btnDeletePhoto.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new AlertDialog.Builder(AlbumActivity.this) .setTitle("提示") .setIcon(R.drawable.alert_icon) .setMessage("确认删除该照片?") .setPositiveButton( "确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { int pos = gl.getSelectedItemPosition(); pid = photoInfoList.get(pos)[0]; deletePhoto(); } }) .setNegativeButton( "取消", null) .show(); } }); } public void getPhotoList(){ new Thread(){ public void run(){ Looper.prepare(); try{ mc = null; mc = new MyConnector(SERVER_ADDRESS, SERVER_PORT); mc.dout.writeUTF("<#GET_ALBUM#>"+xid); int size = 0; //获得相册长度 size = mc.din.readInt(); //读取相册的长度 if(size == 0){ Toast.makeText(AlbumActivity.this, "该相册还未上传照片", Toast.LENGTH_LONG).show(); Looper.loop(); return; } photoInfoList = new ArrayList<String []>(size); photoList = new Bitmap[size]; for(int i=0;i<size;i++){ //循环获取图片数据 String photoInfo = mc.din.readUTF(); //读取相片信息 String [] sa = photoInfo.split("\\|"); //切割字符串 photoInfoList.add(sa); //将相片信息添加到列表中 int photoLength = mc.din.readInt(); //读取相片长度 byte [] buf = new byte[photoLength]; //创建相应长度的数组 mc.din.read(buf); //读入图片数据 photoList[i] = BitmapFactory.decodeByteArray(buf, 0, photoLength); //创建Bitmap } myHandler.sendEmptyMessage(0); }catch(Exception e){ e.printStackTrace(); } } }.start(); } //方法:删除指定照片 public void deletePhoto(){ new Thread(){ public void run(){ Looper.prepare(); try{ if(mc ==null){ mc = new MyConnector(SERVER_ADDRESS, SERVER_PORT); } String msg = "<#DELETE_PHOTO#>"+pid; mc.dout.writeUTF(msg); String reply = mc.din.readUTF(); if(reply.equals("<#DELETE_PHOTO_SUCCESS#>")){ Toast.makeText(AlbumActivity.this, "照片删除成功!", Toast.LENGTH_LONG).show(); } else { Toast.makeText(AlbumActivity.this, "删除失败,请重试!", Toast.LENGTH_LONG).show(); } getPhotoList(); Looper.loop(); }catch(Exception e){ e.printStackTrace(); } } }.start(); } @Override public View makeView() { ImageView iv = new ImageView(this); iv.setScaleType(ImageView.ScaleType.CENTER_INSIDE); iv.setLayoutParams(new ImageSwitcher.LayoutParams(IMAGESWITCHER_HEIGHT,IMAGESWITCHER_HEIGHT)); return iv; } @Override protected void onDestroy() { if(mc != null){ mc.sayBye(); mc = null; } super.onDestroy(); } }

    3
    46
    781KB
    2012-12-06
    2
  • cocos2d-x入门基础

    eclipse已经有10年的历史了,它有许多插件可以支持其它语言的开发,这当然就包括c/C++语言的插件啦。先让我们来安装这个插件吧。打开eclipse,然后执行以下步骤: · 从Eclipse IDE的主工具栏上面,选择Help/Install New Software。 · 打开Work With复选框,并从中选择一个包含你的eclipse版本名称的项(如果是最新版的eclipse的话,就选择indigo) · 在插件树里面找到Programming Languages (只有当你复选中“Group items by category”时,你才可以看到插件树。)并打开它. · 选择CDT插件,然后安装下列组件。(但是,请注意,你如果直接就点击C/C++ Development Tools的话,你是得不到下图所示的样子的,你还需要在“Mobile Development”里面去查找相关的项)(译者:我没找了,直接就选择了C/C++ Development Tools就Next安装了)

    5
    111
    497KB
    2012-11-29
    10
  • 游戏编程中的人工智能技术

    //----------------------------------------------------------------------- // // Name: HelloWorld4 example project // // Author: Mat Buckland 2002 // // Desc: Code to demonstrate basic keyboard handling // // NOTE: Don't forget to include the library winmm.lib in your project // settings. //------------------------------------------------------------------------ #include <windows.h> #include "defines.h" //--------------------------------- Globals ------------------------------ // //------------------------------------------------------------------------ char* g_szApplicationName = "HelloWorld4"; char* g_szWindowClassName = "MyWindowClass"; //---------------------------- WindowProc --------------------------------- // // This is the callback function which handles all the windows messages //------------------------------------------------------------------------- LRESULT CALLBACK WindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { //A WM_CREATE msg is sent when your application window is first //created case WM_CREATE: { PlaySound("window_open.wav", NULL, SND_FILENAME | SND_ASYNC); } break; case WM_KEYUP: { switch(wParam) { case VK_ESCAPE: { PostQuitMessage(0); } break; } } case WM_PAINT: { PAINTSTRUCT ps; BeginPaint (hwnd, &ps;); //**this is where we do any drawing to the screen** EndPaint (hwnd, &ps;); } break; case WM_DESTROY: { // kill the application, this sends a WM_QUIT message PostQuitMessage (0); } break; }//end switch //this is where all the messages not specifically handled by our //winproc are sent to be processed return DefWindowProc (hwnd, msg, wParam, lParam); } //-------------------------------- WinMain ------------------------------- // // The entry point of the windows program //------------------------------------------------------------------------ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow) { //handle to our window HWND hWnd; //our window class structure WNDCLASSEX winclass; // first fill in the window class stucture winclass.cbSize = sizeof(WNDCLASSEX); winclass.style = CS_HREDRAW | CS_VREDRAW; winclass.lpfnWndProc = WindowProc; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hInstance; winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); winclass.hCursor = LoadCursor(NULL, IDC_ARROW); winclass.hbrBackground = (HBRUSH)GetStockObject (WHITE_BRUSH); winclass.lpszMenuName = NULL; winclass.lpszClassName = g_szWindowClassName; winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); //register the window class if (!RegisterClassEx(&winclass;)) { MessageBox(NULL, "Registration Failed!", "Error", 0); //exit the application return 0; } //create the window and assign its ID to hwnd hWnd = CreateWindowEx (NULL, // extended style g_szWindowClassName, // window class name g_szApplicationName, // window caption WS_OVERLAPPEDWINDOW, // window style 0, // initial x position 0, // initial y position WINDOW_WIDTH, // initial x size WINDOW_HEIGHT, // initial y size NULL, // parent window handle NULL, // window menu handle hInstance, // program instance handle NULL); // creation parameters //make sure the window creation has gone OK if(!hWnd) { MessageBox(NULL, "CreateWindowEx Failed!", "Error!", 0); } //make the window visible ShowWindow (hWnd, iCmdShow); UpdateWindow (hWnd); //this will hold any windows messages MSG msg; //entry point of our message handler while (GetMessage (&msg;, NULL, 0, 0)) { TranslateMessage (&msg;); DispatchMessage (&msg;); } return msg.wParam; }

    5
    0
    6.31MB
    2012-11-17
    3
  • 水果对对碰(源码)

    package whu.iss.sric.android; import whu.iss.sric.view.GameView; import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.view.View; import android.view.View.OnClickListener; import android.widget.ImageButton; import android.widget.TextView; public class MyDialog extends Dialog implements OnClickListener{ private GameView gameview; private Context context; public MyDialog(Context context, GameView gameview, String msg, int time) { super(context,R.style.dialog); this.gameview = gameview; this.context = context; this.setContentView(R.layout.dialog_view); TextView text_msg = (TextView) findViewById(R.id.text_message); TextView text_time = (TextView) findViewById(R.id.text_time); ImageButton btn_menu = (ImageButton) findViewById(R.id.menu_imgbtn); ImageButton btn_next = (ImageButton) findViewById(R.id.next_imgbtn); ImageButton btn_replay = (ImageButton) findViewById(R.id.replay_imgbtn); text_msg.setText(msg); text_time.setText(text_time.getText().toString().replace("$", String.valueOf(time))); btn_menu.setOnClickListener(this); btn_next.setOnClickListener(this); btn_replay.setOnClickListener(this); this.setCancelable(false); } @Override public void onClick(View v) { this.dismiss(); switch(v.getId()){ case R.id.menu_imgbtn: Dialog dialog = new AlertDialog.Builder(context) .setIcon(R.drawable.buttons_bg20) .setTitle(R.string.quit) .setMessage(R.string.sure_quit) .setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { ((WelActivity)context).quit(); } }) .setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }) .create(); dialog.show(); // gameview.startPlay(); // Toast.makeText(context, text, duration); break; case R.id.replay_imgbtn: gameview.startPlay(); break; case R.id.next_imgbtn: gameview.startNextPlay(); break; } } }

    5
    106
    3.67MB
    2012-11-15
    4
  • 植物大战僵尸(源码)

    一款经典的手机游戏(植物大战僵尸)的源码 package FreeIMUST.PvZ_Online.PvZ; import FreeIMUST.PvZ_Online.PvZ.PvZ_OnlineActivity.MusicFactory; import FreeIMUST.PvZ_Online.PvZ.PvZ_OnlineActivity.OtherFactory; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; import android.os.Handler; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.SurfaceHolder; import android.view.SurfaceView; public class AboutView extends SurfaceView implements SurfaceHolder.Callback { Bitmap aboutImage_ = null; PvZ_OnlineActivity activity_ = null; RefreshThread refreshThread_ = null; Paint paint_ = new Paint(); Handler handler_ = null; ProcessView processView_ = null; private MIDIPlayer menu_view_mMIDIPlayer = null; public AboutView(PvZ_OnlineActivity activity) { super(activity); activity_ = activity; initBitmap(); getHolder().addCallback(this); this.refreshThread_ = new RefreshThread(getHolder(), this); if(this.activity_.hasBackgroundMusic()) { menu_view_mMIDIPlayer = this.activity_.musicFactory_.getMusicPlayer( MusicFactory.Background_MenuView); menu_view_mMIDIPlayer.PlayMusic(); } } private void initBitmap() { aboutImage_ = activity_.otherFactory_.getImage(OtherFactory.Background_MainMenu_About); } protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.drawBitmap(this.aboutImage_, 0, 0, paint_); } public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { } public void surfaceCreated(SurfaceHolder holder) { this.refreshThread_.setFlag(true); this.refreshThread_.start(); } public void surfaceDestroyed(SurfaceHolder holder) { boolean retry = true; refreshThread_.setFlag(false); while (retry) { try { refreshThread_.join(); retry = false; } catch (InterruptedException e) { } } } public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if(this.activity_.hasBackgroundMusic()) this.menu_view_mMIDIPlayer.FreeMusic(); int x = (int) event.getX(); int y = (int) event.getY(); if (x >=0 && x <= 480 && y >= 140 && y <= 190) activity_.myHandler_.sendEmptyMessage(PvZ_OnlineActivity.Message_MainMenu_VisitWeb); activity_.myHandler_.sendEmptyMessage(PvZ_OnlineActivity.Message_MainMenu); } return super.onTouchEvent(event); } public boolean onKeyDown(int keyCode, KeyEvent event) { if (KeyEvent.KEYCODE_BACK == keyCode) { if(this.activity_.hasBackgroundMusic()) this.menu_view_mMIDIPlayer.FreeMusic(); activity_.myHandler_.sendEmptyMessage(PvZ_OnlineActivity.Message_MainMenu); } return super.onKeyDown(keyCode, event); } /////////////////////////////////////////////////////////////////////////////// class RefreshThread extends Thread { SurfaceHolder surfaceHolder_ = null; AboutView aboutView_ = null; boolean flag_ = false; public RefreshThread(SurfaceHolder surfaceHolder, AboutView aboutView) { this.surfaceHolder_ = surfaceHolder; this.aboutView_ = aboutView; } public void setFlag(boolean flag) { this.flag_ = flag; } public void run() { Canvas canvas; while (this.flag_) { canvas = null; try { // 锁定整个画布,在内存要求比较高的情况下,建议参数不要为null canvas = this.surfaceHolder_.lockCanvas(null); synchronized (this.surfaceHolder_) { aboutView_.onDraw(canvas); } } finally { if (canvas != null) this.surfaceHolder_.unlockCanvasAndPost(canvas); } } } } // RefreshThread }

    4
    909
    9.04MB
    2012-11-13
    10
  • HTML5和CSS3入门

    HTML5和css3入门开发资料 HTML5新增和移除的元素 HTML5基本布局 HTML5对表单的支持 HTML5 DOM变化 HTML5的Javascript APIs Canvas Video/Audio Drag&Drop; Geolocation Application Cache Database Storage X-Document Messaging

    0
    53
    678KB
    2012-11-11
    10
  • HTML5 在游戏开发中的应用

    html5是时下最流行的一种编程技术,它不仅可以用来开发游戏,还可以开发不错的界面,是一种不错的语言,希望这份资料可以对研究html5的兄弟姐妹们有所帮助

    0
    43
    1.21MB
    2012-11-08
    0
  • android 开发UI设计大全 PDF

    android页面切换西效果 android菜单动画效果 android布局属性 android翻页等一系列UI的设计代码

    5
    189
    4.03MB
    2012-06-19
    11
  • 基于RTP的实时视频传输系统

    实时视频流在可视电话,远程教育,视频点播等方面得到广泛运用,网络实时视频系统一般分为四大模块:采集子系统,编码压缩子系统传输控制子系统和输出子系统。其中传输控制系统是实时视频流的一项关键核心技术,提出了基于RTP/RTCP协议构建实时传输视频传输控制子系统,传输层通信使用UDP SOCKET完成

    5
    138
    110KB
    2012-06-19
    0
上传资源赚积分or赚钱