📄 fileoperationlistener.cs
字号:
//Filename : FileOperationListener.cs
//Part of : Phone Navigator
//Description : Implementation of phone navigators file operation listener
//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 CONAFileSystem;
//===================================================================
// FileOperationListener
public class FileOperationListener
{
private int m_hFS;
private CONADefinitions.FSNotifyCallbackDelegate pFSCallBack;
//===================================================================
// StartListening
//
// Start listening file operation notifications
//===================================================================
public void StartListening(System.IntPtr hwndParent, int hFS, string title, string line1, string line2)
{
m_hFS = hFS;
// Register file system notification callback function
pFSCallBack = FSNotifyCallback;
int iResult = CONAFileSystem.CONARegisterFSNotifyCallback(m_hFS, CONADefinitions.API_REGISTER, pFSCallBack);
if (iResult != PCCSErrors.CONA_OK) PCCAPIUtils.ShowErrorMessage("FileOperationListener::StartListening(): CONARegisterFSNotifyCallback", iResult);
Common.MainForm.LBX_PhoneFiles.ResetContent();
Common.MainForm.StartProgress(title, line1, line2);
}
//===================================================================
// FSNotifyCallback
//
// Call back function for file operation notifications
//===================================================================
public int FSNotifyCallback(int iOperation, int iStatus, int iTransferredBytes, int iAllBytes)
{
int functionReturnValue = 0;
functionReturnValue = PCCSErrors.CONA_OK;
Common.MainForm.SetProgress(iStatus);
if (Common.MainForm.IsCancelled())
{
functionReturnValue = PCCSErrors.ECONA_CANCELLED;
}
return functionReturnValue;
}
//===================================================================
// StopListening
//
// Stop listening file operation notifications
//===================================================================
public void StopListening()
{
// Unregister file system notification callback function
int iResult = CONAFileSystem.CONARegisterFSNotifyCallback(m_hFS, CONADefinitions.API_UNREGISTER, pFSCallBack);
if (iResult != PCCSErrors.CONA_OK) PCCAPIUtils.ShowErrorMessage("FileOperationListener::StopListening(): CONARegisterFSNotifyCallback", iResult);
Common.MainForm.StopProgress();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -