/// <summary> /// CreateFile wrapper that attempts to use CreateFile2 if running as Windows Store app. /// </summary> public static SafeFileHandle CreateFile( StringSpan path, CreationDisposition creationDisposition, DesiredAccess desiredAccess = DesiredAccess.GenericReadWrite, ShareModes shareMode = ShareModes.ReadWrite, FileAttributes fileAttributes = FileAttributes.None, FileFlags fileFlags = FileFlags.None, SecurityQosFlags securityQosFlags = SecurityQosFlags.None) { // Prefer CreateFile2, falling back to CreateFileEx if we can if (s_createFileDelegate == null) { s_createFileDelegate = CreateFile2; try { return(s_createFileDelegate(path, desiredAccess, shareMode, creationDisposition, fileAttributes, fileFlags, securityQosFlags)); } catch (EntryPointNotFoundException) { s_createFileDelegate = Delegates.CreateDelegate <CreateFileDelegate>( "WInterop.Storage.Desktop.NativeMethods, " + Delegates.DesktopLibrary, "CreateFileW"); } } return(s_createFileDelegate(path, desiredAccess, shareMode, creationDisposition, fileAttributes, fileFlags, securityQosFlags)); }
/// <summary> /// CreateFile wrapper that attempts to use CreateFile2 if running as Windows Store app. /// </summary> public static SafeFileHandle CreateFile( string path, DesiredAccess desiredAccess, ShareMode shareMode, CreationDisposition creationDisposition, FileAttributes fileAttributes = FileAttributes.NONE, FileFlags fileFlags = FileFlags.NONE, SecurityQosFlags securityQosFlags = SecurityQosFlags.NONE) { // Prefer CreateFile2, falling back to CreateFileEx if we can if (s_createFileDelegate == null) { s_createFileDelegate = CreateFile2; try { return(s_createFileDelegate(path, desiredAccess, shareMode, creationDisposition, fileAttributes, fileFlags, securityQosFlags)); } catch (Exception exception) { // Any error other than EntryPointNotFound we've found CreateFile2, rethrow if (!ErrorHelper.IsEntryPointNotFoundException(exception)) { throw; } s_createFileDelegate = Delegates.CreateDelegate <CreateFileDelegate>( "WInterop.FileManagement.Desktop.NativeMethods, " + Delegates.DesktopLibrary, "CreateFileW"); } } return(s_createFileDelegate(path, desiredAccess, shareMode, creationDisposition, fileAttributes, fileFlags, securityQosFlags)); }
protected DokanDefaultImplementation(CreateFileDelegate onCreateFile = null, OpenDirectoryDelegate onOpenDirectory = null, CreateDirectoryDelegate onCreateDirectory = null, CleanupDelegate onCleanup = null, CloseFileDelegate onCloseFile = null, ReadFileDelegate onReadFile = null, WriteFileDelegate onWriteFile = null, FlushFileBuffersDelegate onFlushFileBuffers = null, GetFileInformationDelegate onGetFileInformation = null, FindFilesDelegate onFindFiles = null, SetFileAttributesDelegate onSetFileAttributes = null, SetFileTimeDelegate onSetFileTime = null, DeleteFileDelegate onDeleteFile = null, DeleteDirectoryDelegate onDeleteDirectory = null, MoveFileDelegate onMoveFile = null, SetEndOfFileDelegate onSetEndOfFile = null, SetAllocationSizeDelegate onSetAllocationSize = null, LockFileDelegate onLockFile = null, UnlockFileDelegate onUnlockFile = null, GetDiskFreeSpaceDelegate onGetDiskFreeSpace = null, UnmountDelegate onUnmount = null) { OnCreateFile = onCreateFile; OnOpenDirectory = onOpenDirectory; OnCreateDirectory = onCreateDirectory; OnCleanup = onCleanup; OnCloseFile = onCloseFile; OnReadFile = onReadFile; OnWriteFile = onWriteFile; OnFlushFileBuffers = onFlushFileBuffers; OnGetFileInformation = onGetFileInformation; OnFindFiles = onFindFiles; OnSetFileAttributes = onSetFileAttributes; OnSetFileTime = onSetFileTime; OnDeleteFile = onDeleteFile; OnDeleteDirectory = onDeleteDirectory; OnMoveFile = onMoveFile; OnSetEndOfFile = onSetEndOfFile; OnSetAllocationSize = onSetAllocationSize; OnLockFile = onLockFile; OnUnlockFile = onUnlockFile; OnGetDiskFreeSpace = onGetDiskFreeSpace; OnUnmount = onUnmount; }
private void CreateFiles(String path, String dir, String type, String extension, CreateFileDelegate CreateFile) { for (int i = 0; i < ds.Tables["Entity"].Rows.Count; i++) { String pathName = ""; if (dir == "Repository") pathName = path + "\\" + dir + "\\" + ds.Tables["Entity"].Rows[i][type] + "Repository" + extension; else if (dir == "Operation") pathName = path + "\\" + dir + "\\" + ds.Tables["Entity"].Rows[i][type] + "Operation" + extension; else pathName = path + "\\" + dir + "\\" + ds.Tables["Entity"].Rows[i][type] + extension; FileInfo fi = new FileInfo(pathName); if (!fi.Exists)//如果文件不存在 { CreateFile(pathName, i); } else { File.Delete(pathName); CreateFile(pathName, i); } } }
//protected override CreateParams CreateParams //{ // get // { // CreateParams cp = base.CreateParams; // cp.ExStyle |= 0x02000000; // Turn on WS_EX_COMPOSITED // //return cp; // } //} /// <summary> /// Construction of Main Form /// </summary> public FrmMain() { try { InitializeComponent();//INITILIZE METHODS AND VARIABLE this.Size = new Size(910, 738); //this.BackgroundImageLayout = ImageLayout.Stretch; double w = btnSet.Location.X + btnSet.Width; double x = w - ClearAllGraphsbutton.Width; //ClearAllGraphsbutton.Location = new Point((int)x, 17); xDisplayRange = Convert.ToInt32(ConfigurationManager.AppSettings["xDisplayRange"]); graphRefreshTime = Convert.ToInt32(ConfigurationManager.AppSettings["graphRefreshTime"]); //panel1.Width = panel3.Width = panel4.Width = panel5.Width = 302; //TODO:Testing. next and prev- START //ApplicationUtil.ApplicationUtil.addFileNameToList(2, "27-Feb-2013_19_10_32_181.csv"); //ApplicationUtil.ApplicationUtil.addFileNameToList(4, "27-Feb-2013_19_10_32_184.csv"); //ApplicationUtil.ApplicationUtil.addFileNameToList(4, "27-Feb-2013_19_10_32_188.csv"); //ApplicationUtil.ApplicationUtil.addFileNameToList(4, "27-Feb-2013_19_10_32_189.csv"); //ApplicationUtil.ApplicationUtil.addFileNameToList(2, "27-Feb-2013_19_10_32_183.csv"); //ApplicationUtil.ApplicationUtil.addFileNameToList(2048, "27-Feb-2013_19_10_32_187.csv"); //END txtXRange.Text = xDisplayRange.ToString(); txtXRange.Enabled = false; btnSet.Enabled = false; plotterDisplayEx1.Load+=new EventHandler(plotterDisplayEx1_Load); plotterDisplayEx2.Load += new EventHandler(plotterDisplayEx1_Load); plotterDisplayEx3.Load += new EventHandler(plotterDisplayEx1_Load); plotterDisplayEx4.Load += new EventHandler(plotterDisplayEx1_Load); plotterDisplayEx5.Load += new EventHandler(plotterDisplayEx1_Load); plotterDisplayEx6.Load += new EventHandler(plotterDisplayEx1_Load); plotterDisplayEx7.Load += new EventHandler(plotterDisplayEx1_Load); plotterDisplayEx8.Load += new EventHandler(plotterDisplayEx1_Load); plotterDisplayEx9.Load += new EventHandler(plotterDisplayEx1_Load); plotterDisplayEx10.Load += new EventHandler(plotterDisplayEx1_Load); plotterDisplayEx11.Load += new EventHandler(plotterDisplayEx1_Load); plotterDisplayEx12.Load += new EventHandler(plotterDisplayEx1_Load); // RendeRTestGraph(); setDelegateStatus = new setDeviceStatus(SetHHUMessage); //drawGraphdelegate = new drawGraph(DrawLiveGraph); button5.Visible = false; PlotterDisplayEx graph = new PlotterDisplayEx(); graphdelegate = new Graphdelegate(RenderGraph); createFileDelegate = new CreateFileDelegate(createCSVFile); if (Program.communicator == null || Program.communicator.serialPort == null || Program.communicator.serialPort.IsOpen == false) { deviceCon(); } SetHeightOfGraph(); SetDefaultUI(); VOManager.DASCommunicator.SetStatusEvent += new VOManager.SetDACStatusDelegate(DASCommunicator_SetStatusEvent); VOManager.DASCommunicator.DirectoryCreationErrorEvent+=new VOManager.DirectoryCreationError(DASCommunicator_DirectoryCreationErrorEvent); //GraphInitialiser(); //SetDirectoryPath Configuration oConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); string DirectoryPath = ConfigurationManager.AppSettings["DirectoryPath"]; if (changedpath == null) { lblDirectorypath.Text = ApplicationUtil.ApplicationUtil.GetApplicationPath(); String path = ApplicationUtil.ApplicationUtil.GetApplicationPath(); filenames = ApplicationUtil.ApplicationUtil.GetSubDirectoryFiles(path, ".csv"); changedpath = lblDirectorypath.Text; } else { lblDirectorypath.Text = changedpath; filenames = ApplicationUtil.ApplicationUtil.GetSubDirectoryFiles(changedpath, ".csv"); } if (DirectoryPath != null && DirectoryPath != "") { changedpath = DirectoryPath; lblDirectorypath.Text = changedpath; } ///Map for ADC resolution samplingRateMap = new Dictionary<int, double>(); samplingRateMap.Add(0, 1); samplingRateMap.Add(1, 2); samplingRateMap.Add(2, 3); samplingRateMap.Add(3, 4); samplingRateMap.Add(4, 5); samplingRateMap.Add(5, 6); samplingRateMap.Add(6, 10); samplingRateMap.Add(7, 12.5); samplingRateMap.Add(8, 15); backgroundWorker = new BackgroundWorker(); backgroundWorker.WorkerSupportsCancellation = true; backgroundWorker.DoWork += backgroundWorker_DoWork; backgroundWorker.RunWorkerCompleted +=new RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted); PlotterDisplayEx graphControl = new PlotterDisplayEx(); //thread = new Thread(DoGraphActivity); //thread.IsBackground = true; // thread.Start(); DASCommunicator.FileLoggingQueue = new RequestQ.QueueThread<object>(); DASCommunicator. FileLoggingQueue.ProcessThreadObjectEvent += new RequestQ.QueueThread<object>.DelegateProcessThreadObject(FileLoggingQueue_ProcessThreadObjectEvent); DASCommunicator.FileLoggingQueue.Start(); lblVersion.Text += Assembly.GetExecutingAssembly().GetName().Version.ToString(); SetHHUMessage(false, false); timerStatusMsg.Start(); } catch (Exception ex) { m_logger.Error(ex); } }