📄 filebrowser.cs
字号:
//Filename : FileBrowser.cs
//Part of : Phone Navigator C# example
//Description : Main dialog of CSFileBrowser.NET example application
//Version : 3.2
//
//This example is only to be used with PC Connectivity API version 3.2.
//Compability ("as is") with future versions is not quaranteed.
//
//Copyright (c) 2007 Nokia Corporation.
//
//This material, including but not limited to documentation and any related
//computer programs, is protected by intellectual property rights of Nokia
//Corporation and/or its licensors.
//All rights are reserved. Reproducing, modifying, translating, or
//distributing any or all of this material requires the prior written consent
//of Nokia Corporation. Nokia Corporation retains the right to make changes
//to this material at any time without notice. A copyright license is hereby
//granted to download and print a copy of this material for personal use only.
//No other license to any other intellectual property rights is granted. The
//material is provided "as is" without warranty of any kind, either express or
//implied, including without limitation, any warranty of non-infringement,
//merchantability and fitness for a particular purpose. In no event shall
//Nokia Corporation be liable for any direct, indirect, special, incidental,
//or consequential loss or damages, including but not limited to, lost profits
//or revenue,loss of use, cost of substitute program, or loss of data or
//equipment arising out of the use or inability to use the material, even if
//Nokia Corporation has been advised of the likelihood of such damages occurring.
using System.Runtime.InteropServices;
namespace CSFileBrowser.NET
{
using PCCSErrors;
using PCCAPIUtils;
using CONADefinitions;
using CONADeviceManagement;
using CONAFileSystem;
using System.Windows.Forms;
public class FileBrowser : System.Windows.Forms.Form
{
private bool m_bCancelled;
internal System.Windows.Forms.Timer Timer1;
private bool m_bDisposed = false;
private Button BTN_ItemInfo;
private CheckBox checkBoxUseCache;
public bool bRefreshPhoneListBox = false;
#region " Windows Form Designer generated code "
public FileBrowser()
: base()
{
// Initialize Nokia PC Connectivity API
// Initialize Device Management APi
int iRet = CONADeviceManagement.DMAPI_Initialize(CONADeviceManagement.DMAPI_VERSION_32, 0);
if (iRet != PCCSErrors.CONA_OK) PCCAPIUtils.ShowErrorMessage("DMAPI_Initialize", iRet);
// Initialize File System API
iRet = CONAFileSystem.FSAPI_Initialize(CONAFileSystem.FSAPI_VERSION_32, System.IntPtr.Zero);
if (iRet != PCCSErrors.CONA_OK) PCCAPIUtils.ShowErrorMessage("FSAPI_Initialize", iRet);
//This call is required by the Windows Form Designer.
InitializeComponent();
//Add any initialization after the InitializeComponent() call
}
//Form overrides dispose to clean up the component list.
protected override void Dispose(bool disposing)
{
if (!m_bDisposed)
{
base.Dispose(disposing);
}
m_bDisposed = true;
// Terminate Device Management APi
int iRet = CONADeviceManagement.DMAPI_Terminate(0);
if (iRet != PCCSErrors.CONA_OK) PCCAPIUtils.ShowErrorMessage("DMAPI_Terminate", iRet);
// Terminate File Ssytem API
iRet = CONAFileSystem.FSAPI_Terminate(System.IntPtr.Zero);
if (iRet != PCCSErrors.CONA_OK) PCCAPIUtils.ShowErrorMessage("FSAPI_Terminate", iRet);
Application.Exit();
}
//Required by the Windows Form Designer
private System.ComponentModel.IContainer components;
//NOTE: The following procedure is required by the Windows Form Designer
//It can be modified using the Windows Form Designer.
//Do not modify it using the code editor.
internal FileListBox LBX_PCFiles;
internal PhoneListBox LBX_PhoneFiles;
internal System.Windows.Forms.Button BTN_CopyPCToPhone;
internal System.Windows.Forms.Button BTN_CopyPhoneToPC;
internal System.Windows.Forms.Button BTN_MovePCToPhone;
internal System.Windows.Forms.Button BTN_MovePhoneToPC;
internal System.Windows.Forms.Button BTN_Close;
internal System.Windows.Forms.Button BTN_Delete;
internal System.Windows.Forms.Button BTN_Rename;
internal System.Windows.Forms.Button BTN_Create;
internal System.Windows.Forms.Label LBL_PCFiles;
internal System.Windows.Forms.Label LBL_PhoneFiles;
internal System.Windows.Forms.Button BTN_Cancel;
internal System.Windows.Forms.ProgressBar ProgressBar1;
[System.Diagnostics.DebuggerStepThrough()]
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FileBrowser));
this.BTN_CopyPCToPhone = new System.Windows.Forms.Button();
this.BTN_CopyPhoneToPC = new System.Windows.Forms.Button();
this.BTN_MovePCToPhone = new System.Windows.Forms.Button();
this.BTN_MovePhoneToPC = new System.Windows.Forms.Button();
this.BTN_Close = new System.Windows.Forms.Button();
this.BTN_Delete = new System.Windows.Forms.Button();
this.BTN_Rename = new System.Windows.Forms.Button();
this.BTN_Create = new System.Windows.Forms.Button();
this.LBL_PCFiles = new System.Windows.Forms.Label();
this.LBL_PhoneFiles = new System.Windows.Forms.Label();
this.BTN_Cancel = new System.Windows.Forms.Button();
this.ProgressBar1 = new System.Windows.Forms.ProgressBar();
this.Timer1 = new System.Windows.Forms.Timer(this.components);
this.BTN_ItemInfo = new System.Windows.Forms.Button();
this.checkBoxUseCache = new System.Windows.Forms.CheckBox();
this.LBX_PCFiles = new CSFileBrowser.NET.FileListBox();
this.LBX_PhoneFiles = new CSFileBrowser.NET.PhoneListBox();
this.SuspendLayout();
//
// BTN_CopyPCToPhone
//
this.BTN_CopyPCToPhone.Location = new System.Drawing.Point(246, 25);
this.BTN_CopyPCToPhone.Name = "BTN_CopyPCToPhone";
this.BTN_CopyPCToPhone.Size = new System.Drawing.Size(80, 24);
this.BTN_CopyPCToPhone.TabIndex = 2;
this.BTN_CopyPCToPhone.Text = "Copy >>";
this.BTN_CopyPCToPhone.Click += new System.EventHandler(this.BTN_CopyPCToPhone_Click);
//
// BTN_CopyPhoneToPC
//
this.BTN_CopyPhoneToPC.Location = new System.Drawing.Point(246, 55);
this.BTN_CopyPhoneToPC.Name = "BTN_CopyPhoneToPC";
this.BTN_CopyPhoneToPC.Size = new System.Drawing.Size(80, 24);
this.BTN_CopyPhoneToPC.TabIndex = 3;
this.BTN_CopyPhoneToPC.Text = "<< Copy";
this.BTN_CopyPhoneToPC.Click += new System.EventHandler(this.BTN_CopyPhoneToPC_Click);
//
// BTN_MovePCToPhone
//
this.BTN_MovePCToPhone.Location = new System.Drawing.Point(246, 85);
this.BTN_MovePCToPhone.Name = "BTN_MovePCToPhone";
this.BTN_MovePCToPhone.Size = new System.Drawing.Size(80, 24);
this.BTN_MovePCToPhone.TabIndex = 4;
this.BTN_MovePCToPhone.Text = "Move >>";
this.BTN_MovePCToPhone.Click += new System.EventHandler(this.BTN_MovePCToPhone_Click);
//
// BTN_MovePhoneToPC
//
this.BTN_MovePhoneToPC.Location = new System.Drawing.Point(246, 115);
this.BTN_MovePhoneToPC.Name = "BTN_MovePhoneToPC";
this.BTN_MovePhoneToPC.Size = new System.Drawing.Size(80, 24);
this.BTN_MovePhoneToPC.TabIndex = 5;
this.BTN_MovePhoneToPC.Text = "<< Move";
this.BTN_MovePhoneToPC.Click += new System.EventHandler(this.BTN_MovePhoneToPC_Click);
//
// BTN_Close
//
this.BTN_Close.Location = new System.Drawing.Point(246, 250);
this.BTN_Close.Name = "BTN_Close";
this.BTN_Close.Size = new System.Drawing.Size(80, 24);
this.BTN_Close.TabIndex = 6;
this.BTN_Close.Text = "Close";
this.BTN_Close.Click += new System.EventHandler(this.BTN_Close_Click);
//
// BTN_Delete
//
this.BTN_Delete.Location = new System.Drawing.Point(510, 288);
this.BTN_Delete.Name = "BTN_Delete";
this.BTN_Delete.Size = new System.Drawing.Size(72, 24);
this.BTN_Delete.TabIndex = 7;
this.BTN_Delete.Text = "Delete";
this.BTN_Delete.Click += new System.EventHandler(this.BTN_Delete_Click);
//
// BTN_Rename
//
this.BTN_Rename.Location = new System.Drawing.Point(425, 288);
this.BTN_Rename.Name = "BTN_Rename";
this.BTN_Rename.Size = new System.Drawing.Size(72, 24);
this.BTN_Rename.TabIndex = 8;
this.BTN_Rename.Text = "Rename";
this.BTN_Rename.Click += new System.EventHandler(this.BTN_Rename_Click);
//
// BTN_Create
//
this.BTN_Create.Location = new System.Drawing.Point(339, 288);
this.BTN_Create.Name = "BTN_Create";
this.BTN_Create.Size = new System.Drawing.Size(72, 24);
this.BTN_Create.TabIndex = 9;
this.BTN_Create.Text = "Create";
this.BTN_Create.Click += new System.EventHandler(this.BTN_Create_Click);
//
// LBL_PCFiles
//
this.LBL_PCFiles.Location = new System.Drawing.Point(8, 8);
this.LBL_PCFiles.Name = "LBL_PCFiles";
this.LBL_PCFiles.Size = new System.Drawing.Size(320, 16);
this.LBL_PCFiles.TabIndex = 10;
this.LBL_PCFiles.Text = "Local folders:";
//
// LBL_PhoneFiles
//
this.LBL_PhoneFiles.Location = new System.Drawing.Point(341, 8);
this.LBL_PhoneFiles.Name = "LBL_PhoneFiles";
this.LBL_PhoneFiles.Size = new System.Drawing.Size(232, 16);
this.LBL_PhoneFiles.TabIndex = 11;
this.LBL_PhoneFiles.Text = "Connected Devices:";
//
// BTN_Cancel
//
this.BTN_Cancel.Location = new System.Drawing.Point(246, 219);
this.BTN_Cancel.Name = "BTN_Cancel";
this.BTN_Cancel.Size = new System.Drawing.Size(80, 24);
this.BTN_Cancel.TabIndex = 12;
this.BTN_Cancel.Text = "Cancel";
this.BTN_Cancel.Visible = false;
this.BTN_Cancel.Click += new System.EventHandler(this.BTN_Cancel_Click);
//
// ProgressBar1
//
this.ProgressBar1.Location = new System.Drawing.Point(8, 288);
this.ProgressBar1.Name = "ProgressBar1";
this.ProgressBar1.Size = new System.Drawing.Size(656, 16);
this.ProgressBar1.TabIndex = 13;
this.ProgressBar1.Visible = false;
//
// Timer1
//
this.Timer1.Tick += new System.EventHandler(this.Timer1_Tick);
//
// BTN_ItemInfo
//
this.BTN_ItemInfo.Location = new System.Drawing.Point(597, 288);
this.BTN_ItemInfo.Name = "BTN_ItemInfo";
this.BTN_ItemInfo.Size = new System.Drawing.Size(75, 23);
this.BTN_ItemInfo.TabIndex = 14;
this.BTN_ItemInfo.Text = "Item Info";
this.BTN_ItemInfo.UseVisualStyleBackColor = true;
this.BTN_ItemInfo.Click += new System.EventHandler(this.BTN_FolderInfo_Click);
//
// checkBoxUseCache
//
this.checkBoxUseCache.AutoSize = true;
this.checkBoxUseCache.Location = new System.Drawing.Point(249, 288);
this.checkBoxUseCache.Name = "checkBoxUseCache";
this.checkBoxUseCache.Size = new System.Drawing.Size(79, 17);
this.checkBoxUseCache.TabIndex = 15;
this.checkBoxUseCache.Text = "Use Cache";
this.checkBoxUseCache.UseVisualStyleBackColor = true;
//
// LBX_PCFiles
//
this.LBX_PCFiles.Location = new System.Drawing.Point(8, 24);
this.LBX_PCFiles.Name = "LBX_PCFiles";
this.LBX_PCFiles.Size = new System.Drawing.Size(227, 251);
this.LBX_PCFiles.TabIndex = 0;
//
// LBX_PhoneFiles
//
this.LBX_PhoneFiles.Location = new System.Drawing.Point(339, 24);
this.LBX_PhoneFiles.Name = "LBX_PhoneFiles";
this.LBX_PhoneFiles.Size = new System.Drawing.Size(333, 251);
this.LBX_PhoneFiles.TabIndex = 0;
//
// FileBrowser
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(677, 318);
this.Controls.Add(this.checkBoxUseCache);
this.Controls.Add(this.BTN_ItemInfo);
this.Controls.Add(this.BTN_Cancel);
this.Controls.Add(this.LBL_PhoneFiles);
this.Controls.Add(this.LBL_PCFiles);
this.Controls.Add(this.BTN_Create);
this.Controls.Add(this.BTN_Rename);
this.Controls.Add(this.BTN_Delete);
this.Controls.Add(this.BTN_Close);
this.Controls.Add(this.BTN_MovePhoneToPC);
this.Controls.Add(this.BTN_MovePCToPhone);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -