Compare commits

...

2 Commits

Author SHA1 Message Date
652fba9b44 Add project 2024-01-10 00:43:27 -06:00
33e94d1e5c Add project 2024-01-10 00:43:25 -06:00
8 changed files with 851 additions and 0 deletions

226
.gitignore vendored Normal file
View File

@ -0,0 +1,226 @@
# The following command works for downloading when using Git for Windows:
# curl -LOf http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore
#
# Download this file using PowerShell v3 under Windows with the following comand:
# Invoke-WebRequest https://gist.githubusercontent.com/kmorcinek/2710267/raw/ -OutFile .gitignore
#
# or wget:
# wget --no-check-certificate http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
[Bb]in/
[Oo]bj/
# build folder is nowadays used for build scripts and should not be ignored
#build/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
modulesbin/
tempbin/
# EPiServer Site file (VPP)
AppData/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# vim
*.txt~
*.swp
*.swo
# Temp files when opening LibreOffice on ubuntu
.~lock.*
# svn
.svn
# CVS - Source Control
**/CVS/
# Remainings from resolving conflicts in Source Control
*.orig
# SQL Server files
**/App_Data/*.mdf
**/App_Data/*.ldf
**/App_Data/*.sdf
#LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml
# =========================
# Windows detritus
# =========================
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# OS generated files #
Icon?
# Mac desktop service store files
.DS_Store
# SASS Compiler cache
.sass-cache
# Visual Studio 2014 CTP
**/*.sln.ide
# Visual Studio temp something
.vs/
# dotnet stuff
project.lock.json
# VS 2015+
*.vc.vc.opendb
*.vc.db
# Rider
.idea/
# Visual Studio Code
.vscode/
# Output folder used by Webpack or other FE stuff
**/node_modules/*
**/wwwroot/*
# SpecFlow specific
*.feature.cs
*.feature.xlsx.*
*.Specs_*.html
# UWP Projects
AppPackages/
#####
# End of core ignore list, below put you custom 'per project' settings (patterns or path)
#####

226
src/.gitignore vendored Normal file
View File

@ -0,0 +1,226 @@
# The following command works for downloading when using Git for Windows:
# curl -LOf http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore
#
# Download this file using PowerShell v3 under Windows with the following comand:
# Invoke-WebRequest https://gist.githubusercontent.com/kmorcinek/2710267/raw/ -OutFile .gitignore
#
# or wget:
# wget --no-check-certificate http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
[Bb]in/
[Oo]bj/
# build folder is nowadays used for build scripts and should not be ignored
#build/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
modulesbin/
tempbin/
# EPiServer Site file (VPP)
AppData/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# vim
*.txt~
*.swp
*.swo
# Temp files when opening LibreOffice on ubuntu
.~lock.*
# svn
.svn
# CVS - Source Control
**/CVS/
# Remainings from resolving conflicts in Source Control
*.orig
# SQL Server files
**/App_Data/*.mdf
**/App_Data/*.ldf
**/App_Data/*.sdf
#LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml
# =========================
# Windows detritus
# =========================
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# OS generated files #
Icon?
# Mac desktop service store files
.DS_Store
# SASS Compiler cache
.sass-cache
# Visual Studio 2014 CTP
**/*.sln.ide
# Visual Studio temp something
.vs/
# dotnet stuff
project.lock.json
# VS 2015+
*.vc.vc.opendb
*.vc.db
# Rider
.idea/
# Visual Studio Code
.vscode/
# Output folder used by Webpack or other FE stuff
**/node_modules/*
**/wwwroot/*
# SpecFlow specific
*.feature.cs
*.feature.xlsx.*
*.Specs_*.html
# UWP Projects
AppPackages/
#####
# End of core ignore list, below put you custom 'per project' settings (patterns or path)
#####

132
src/Form1.Designer.cs generated Executable file
View File

@ -0,0 +1,132 @@

namespace SambaFileDetection
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.drivesTxt = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.drivesChangeApplyBtn = new System.Windows.Forms.Button();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.contextMenuStrip2 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.MuteCB = new System.Windows.Forms.CheckBox();
this.LoggerTxt = new System.Windows.Forms.RichTextBox();
this.SuspendLayout();
//
// drivesTxt
//
this.drivesTxt.Location = new System.Drawing.Point(12, 41);
this.drivesTxt.Name = "drivesTxt";
this.drivesTxt.Size = new System.Drawing.Size(100, 23);
this.drivesTxt.TabIndex = 0;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 23);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(98, 15);
this.label1.TabIndex = 100;
this.label1.Text = "CSV List of Drives";
//
// drivesChangeApplyBtn
//
this.drivesChangeApplyBtn.Location = new System.Drawing.Point(118, 40);
this.drivesChangeApplyBtn.Name = "drivesChangeApplyBtn";
this.drivesChangeApplyBtn.Size = new System.Drawing.Size(75, 23);
this.drivesChangeApplyBtn.TabIndex = 1;
this.drivesChangeApplyBtn.Text = "Apply";
this.drivesChangeApplyBtn.UseVisualStyleBackColor = true;
this.drivesChangeApplyBtn.Click += new System.EventHandler(this.drivesChangeApplyBtn_Click);
//
// contextMenuStrip1
//
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(61, 4);
//
// contextMenuStrip2
//
this.contextMenuStrip2.Name = "contextMenuStrip2";
this.contextMenuStrip2.Size = new System.Drawing.Size(61, 4);
//
// MuteCB
//
this.MuteCB.AutoSize = true;
this.MuteCB.Location = new System.Drawing.Point(212, 43);
this.MuteCB.Name = "MuteCB";
this.MuteCB.Size = new System.Drawing.Size(54, 19);
this.MuteCB.TabIndex = 2;
this.MuteCB.Text = "Mute";
this.MuteCB.UseVisualStyleBackColor = true;
//
// LoggerTxt
//
this.LoggerTxt.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.LoggerTxt.BackColor = System.Drawing.Color.White;
this.LoggerTxt.Location = new System.Drawing.Point(12, 70);
this.LoggerTxt.Name = "LoggerTxt";
this.LoggerTxt.ReadOnly = true;
this.LoggerTxt.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedVertical;
this.LoggerTxt.Size = new System.Drawing.Size(776, 368);
this.LoggerTxt.TabIndex = 3;
this.LoggerTxt.Text = "Debugger:";
this.LoggerTxt.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.LoggerTxt_LinkClicked);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.LoggerTxt);
this.Controls.Add(this.MuteCB);
this.Controls.Add(this.drivesChangeApplyBtn);
this.Controls.Add(this.label1);
this.Controls.Add(this.drivesTxt);
this.Name = "Form1";
this.Text = "SambaFileDetection";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox drivesTxt;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button drivesChangeApplyBtn;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip2;
private System.Windows.Forms.CheckBox MuteCB;
private System.Windows.Forms.RichTextBox LoggerTxt;
}
}

150
src/Form1.cs Executable file
View File

@ -0,0 +1,150 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SambaFileDetection
{
public partial class Form1 : Form
{
[DllImport("user32.dll")]
static extern bool FlashWindow(IntPtr hwnd, bool FlashStatus);
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.FormClosing += (s, eargs) => DrivesFSW.ForEach(d => d.Dispose());
}
void watcher_Error(object sender, ErrorEventArgs e)
{
Debug.WriteLine("error : " + e.GetException().Message);
Log($"Error: {e.GetException().Message}");
}
void watcher_Renamed(object sender, RenamedEventArgs e)
{
Debug.WriteLine($"rename success: {e.OldFullPath} {e.OldName} : {e.FullPath} : {e.Name}");
Log($"Rename: {e.OldFullPath} -> \"file:\\\\{e.FullPath}\"");
}
void watcher_Changed(object sender, FileSystemEventArgs e)
{
Debug.WriteLine($"change success: {e.FullPath} : {e.ChangeType} : {e.Name}");
Log($"Change: \"file:\\\\{e.FullPath}\" | {e.ChangeType}");
}
System.Media.SoundPlayer receiveFile = new System.Media.SoundPlayer(@"C:\Windows\Media\Windows Unlock.wav");
public void Log(string log)
{
this.Invoke((MethodInvoker) delegate
{
LoggerTxt.Text += "\r\n" + DateTime.Now.ToString("dd/MM/yy - HH:mm:ss") + " --- " + log;
LoggerTxt.SelectionStart = LoggerTxt.Text.Length;
LoggerTxt.ScrollToCaret();
});
if (!MuteCB.Checked)
{
receiveFile.Play();
}
this.Invoke((MethodInvoker) delegate { FlashWindow(this.Handle, true); });
}
public void BalloonClosed(object sender, EventArgs e)
{
Debug.WriteLine("Balloon Closed");
DisposeNotification((NotifyIcon)sender);
}
public void DisposeNotification(NotifyIcon ni)
{
FileNotifications.Remove(ni);
FileDict.Remove(ni);
ni.Dispose();
}
public void BalloonTipClicked(object sender, EventArgs e)
{
MessageBox.Show("explorer.exe", $"/select,\"\"{FileDict[(NotifyIcon)sender]}\"\"");
Process.Start("explorer.exe", $"/select,\"{FileDict[(NotifyIcon)sender]}\"");
}
List<FileSystemWatcher> DrivesFSW = new List<FileSystemWatcher>();
string[] drivePaths;
List<NotifyIcon> FileNotifications = new List<NotifyIcon>();
Dictionary<NotifyIcon, string> FileDict = new Dictionary<NotifyIcon, string>();
private void drivesChangeApplyBtn_Click(object sender, EventArgs e)
{
UnregisterWatchers();
drivePaths = drivesTxt.Text.Split(",");
RegisterNewWatchers(drivePaths);
}
public void RegisterNewWatchers(string[] drivePaths)
{
foreach (var drive in drivePaths)
{
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.IncludeSubdirectories = true;
watcher.Path = drive;
watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite;
watcher.Changed += watcher_Changed;
watcher.Created += watcher_Changed;
watcher.Deleted += watcher_Changed;
watcher.Renamed += watcher_Renamed;
watcher.Error += watcher_Error;
watcher.EnableRaisingEvents = true;
DrivesFSW.Add(watcher);
}
}
public void UnregisterWatchers()
{
Debug.WriteLine("Drives: " + DrivesFSW.Count);
foreach (var drive in DrivesFSW.ToList())
{
drive.Dispose();
DrivesFSW.Remove(drive);
}
Debug.WriteLine("Drives: " + DrivesFSW.Count);
}
private void LoggerTxt_LinkClicked(object sender, LinkClickedEventArgs e)
{
OpenInExplorer(e.LinkText);
}
public void OpenInExplorer(string link)
{
Process.Start("explorer.exe", $"/select,\"{link}\"");
}
}
}

60
src/Form1.resx Executable file
View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

23
src/Program.cs Executable file
View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SambaFileDetection
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

9
src/SambaFileDetection.csproj Executable file
View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
</Project>

25
src/SambaFileDetection.sln Executable file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31112.23
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SambaFileDetection", "SambaFileDetection.csproj", "{F2FF6564-9F61-4FB6-985B-DE9F002113AB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F2FF6564-9F61-4FB6-985B-DE9F002113AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2FF6564-9F61-4FB6-985B-DE9F002113AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2FF6564-9F61-4FB6-985B-DE9F002113AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2FF6564-9F61-4FB6-985B-DE9F002113AB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E504D1C4-3947-4A0D-8DAD-F0C3570BEF8D}
EndGlobalSection
EndGlobal