private static void RaiseStatusChanged(IntPtr cPtr, IntPtr sender, IntPtr e) { try { if (Noesis.Extend.Initialized) { if (sender == IntPtr.Zero && e == IntPtr.Zero) { _StatusChanged.Remove(cPtr); return; } StatusChangedHandler handler = null; if (!_StatusChanged.TryGetValue(cPtr, out handler)) { throw new System.InvalidOperationException("Delegate not registered for StatusChanged event"); } if (handler != null) { handler(Noesis.Extend.GetProxy(sender, false), new EventArgs(e, false)); } } } catch (Exception exception) { Noesis.Error.UnhandledException(exception); } }
public ProgressCounter(Thread workerThread, int maximumValue, int initialValue = 0, int incrementBy = 1) { _workerThread = workerThread; _childProgressChangedHandler = new ProgressChangedHandler(_childCounter_ProgressChanged); _childStatusChangedHandler = new StatusChangedHandler(_childCounter_StatusChanged); _value = initialValue; _incrementBy = incrementBy; _maximum = maximumValue; ProgressCounter parentCounter = Top; if (parentCounter == null) { // Set top level counter Top = this; } else { // Add to stack while (parentCounter._childCounter != null) { parentCounter = parentCounter._childCounter; } if (parentCounter != null) { parentCounter.AddChild(this); } } }
private static void RaiseStatusChanged(IntPtr cPtr, IntPtr sender, IntPtr e) { try { if (!_StatusChanged.ContainsKey(cPtr)) { throw new System.InvalidOperationException("Delegate not registered for StatusChanged event"); } if (sender == IntPtr.Zero && e == IntPtr.Zero) { _StatusChanged.Remove(cPtr); return; } if (Noesis.Extend.Initialized) { StatusChangedHandler handler = _StatusChanged[cPtr]; if (handler != null) { handler(Noesis.Extend.GetProxy(sender, false), new EventArgs(e, false)); } } } catch (Exception exception) { Noesis.Error.SetNativePendingError(exception); } }
public static void SendDirectory(FileInformation dir, string workingDir, StatusChangedHandler statusChanged) { if (FindXBox() == false) { return; } string dirname = Path.GetFileName(dir.Name); if (!XBox.FileExists(Path.Combine(workingDir, dirname))) { XBox.CreateDirectory(Path.Combine(workingDir, dirname)); } foreach (string s in Directory.GetFiles(dir.Name, "*", SearchOption.TopDirectoryOnly)) { FileInformation fi = new FileInformation(); fi.Name = s; SendFile(fi, Path.Combine(workingDir, dirname), statusChanged); } foreach (string s in Directory.GetDirectories(dir.Name, "*", SearchOption.TopDirectoryOnly)) { FileInformation fi = new FileInformation(); fi.Name = s; SendDirectory(fi, Path.Combine(workingDir, dirname), statusChanged); } }
public static void SendFile(FileInformation file, string workingDir, StatusChangedHandler statusChanged) { if (FindXBox() == false) { return; } string filename = Path.GetFileName(file.Name); string xboxFilename = Path.Combine(workingDir, filename); if (XBox.FileExists(xboxFilename) && MessageBox.Show(filename + "\n\nWould You Like To Overwrite The Old File?", "File Already Exists.", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } statusChanged(string.Concat("Sending File: ", filename)); XBox.SendFile(file.Name, xboxFilename); }
private void MainForm_Load(object sender, EventArgs e) { TraySettings.Load(); if (TraySettings.WindowVisible) { Restore(); } else { Minimize(); } toolStripMenuItemOptionsStartWithWindows.Checked = TraySettings.StartWithWindows; SetStartWithWindows(TraySettings.StartWithWindows); // ReSharper disable AssignNullToNotNullAttribute _statusRunning = Image.FromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("UnpakkDaemonTray.Resources.Status-Running-16.png")); _statusPaused = Image.FromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("UnpakkDaemonTray.Resources.Status-Paused-16.png")); _statusStopped = Image.FromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("UnpakkDaemonTray.Resources.Status-Stopped-16.png")); _record = Image.FromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("UnpakkDaemonTray.Resources.Record-48.png")); _recordRed = Image.FromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("UnpakkDaemonTray.Resources.Record-Red-48.png")); _subRecord = Image.FromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("UnpakkDaemonTray.Resources.SubRecord-48.png")); _subRecordRed = Image.FromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("UnpakkDaemonTray.Resources.SubRecord-Red-48.png")); // ReSharper restore AssignNullToNotNullAttribute pictureBoxRecord.Image = _record; pictureBoxSubRecord.Image = _subRecord; FileLogger.LogEntryRead += FileLogger_LogEntryRead; StatusChangedHandler statusChangedHandler = new StatusChangedHandler(); statusChangedHandler.ProgressChanged += StatusChangedHandler_ProgressChanged; statusChangedHandler.SubProgressChanged += StatusChangedHandler_SubProgressChanged; statusChangedHandler.RecordAdded += StatusChangedHandler_RecordAdded; statusChangedHandler.SubRecordAdded += StatusChangedHandler_SubRecordAdded; statusChangedHandler.LogEntryAdded += StatusChangedHandler_LogEntryAdded; ObjectPool.StatusServiceHandler = new StatusServiceHandler(statusChangedHandler); ObjectPool.StatusServiceHandler.Start(); ObjectPool.LogFilterDaysBack = 0; ObjectPool.LogFilterLeastLogType = LogType.Flow; SetupLogFilter(); EngineSettings.Load(); LoadRecords(); LoadLog(); }
public static void DeleteDirectory(FileInformation dir, string workingDir, StatusChangedHandler statusChanged) { if (FindXBox() == false) { return; } List <FileInformation> files = XBox.GetDirectoryList(Path.Combine(workingDir, dir.Name)); foreach (FileInformation fi in files) { statusChanged(string.Concat("Deleting: ", fi.Name)); if (fi.Attributes == FileAttributes.Directory) { DeleteDirectory(fi, Path.Combine(workingDir, dir.Name), statusChanged); } else { XBox.DeleteFile(Path.Combine(Path.Combine(workingDir, dir.Name), fi.Name)); } } XBox.DeleteDirectory(Path.Combine(workingDir, dir.Name)); }
public static void DownloadDirectory(FileInformation dir, string workingDir, StatusChangedHandler statusChanged) { if (FindXBox() == false) { return; } throw new NotImplementedException("Can Only Download Single Files!"); //string dirname = Path.GetFileName(dir.Name); //if (!Program.XBox.FileExists(Path.Combine(workingDir, dirname))) Program.XBox.CreateDirectory(Path.Combine(workingDir, dirname)); //foreach (string s in Directory.GetFiles(dir.Name, "*", SearchOption.TopDirectoryOnly)) //{ // FileInformation fi = new FileInformation(); // fi.Name = s; // SendFile(fi, Path.Combine(workingDir, dirname)); //} //foreach (string s in Directory.GetDirectories(dir.Name, "*", SearchOption.TopDirectoryOnly)) //{ // FileInformation fi = new FileInformation(); // fi.Name = s; // SendDirectory(fi, Path.Combine(workingDir, dirname)); //} }
public static void DownloadFile(FileInformation file, string workingDir, string destination, StatusChangedHandler statusChanged) { if (FindXBox() == false) { return; } string xboxFilename = Path.Combine(workingDir, file.Name); if (!XBox.FileExists(xboxFilename)) { return; } statusChanged(string.Concat("Downloading File: ", file.Name)); XBox.ReceiveFile(destination, xboxFilename); }