Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
EJocys committed Sep 19, 2021
1 parent 615b1ad commit 477a4fe
Show file tree
Hide file tree
Showing 76 changed files with 9,401 additions and 0 deletions.
56 changes: 56 additions & 0 deletions Clear_Builds.ps1
@@ -0,0 +1,56 @@
<#
.SYNOPSIS
Removes temporary bin and obj folders.
.NOTES
Author: Evaldas Jocys <evaldas@jocys.com>
Modified: 2021-08-31
.LINK
http://www.jocys.com
#>
# ----------------------------------------------------------------------------
# Get current command path.
[string]$current = $MyInvocation.MyCommand.Path
# Get calling command path.
[string]$calling = @(Get-PSCallStack)[1].InvocationInfo.MyCommand.Path
# If executed directly then...
if ($calling -ne "") {
$current = $calling
}

$file = Get-Item $current
# Working folder.
$wdir = $file.Directory.FullName;

# ----------------------------------------------------------------------------

$global:removeCount = 0;
$global:skipCount = 0;

Function RemoveDirectories
{
# Parameters.
Param ($pattern)
# Function.
$items = Get-ChildItem $wdir -Filter $pattern -Recurse -Force | Where-Object {$_ -is [System.IO.DirectoryInfo]};
foreach ($item in $items)
{
[System.IO.DirectoryInfo] $parent = $item.Parent;
$projects = $parent.GetFiles("*.*proj", [System.IO.SearchOption]::TopDirectoryOnly);
# If project file was found in parent folder then...
if ($projects.length -gt 0){
Write-Output "Remove: $($item.FullName)";
$global:removeCount += 1;
Remove-Item -LiteralPath $item.FullName -Force -Recurse
}
else
{
Write-Output "Skip: $($item.FullName)";
$global:skipCount += 1;
}
}
}
# Remove 'obj' folders first, because it can contain 'bin' inside.
RemoveDirectories "obj"
RemoveDirectories "bin"
Write-Output "Skipped: $global:skipCount, Removed: $global:removeCount";
pause
96 changes: 96 additions & 0 deletions Clear_Cache.ps1
@@ -0,0 +1,96 @@
<#
.SYNOPSIS
Kill and clear IIS Express. Removes temporary and user specific solution files.
.NOTES
Author: Evaldas Jocys <evaldas@jocys.com>
Modified: 2021-04-14
.LINK
http://www.jocys.com
#>
# ----------------------------------------------------------------------------
# Get current command path.
[string]$current = $MyInvocation.MyCommand.Path;
# Get calling command path.
[string]$calling = @(Get-PSCallStack)[1].InvocationInfo.MyCommand.Path;
# If executed directly then...
if ($calling -ne "") {
$current = $calling;
}
$file = Get-Item $current;
# Working folder.
$wdir = $file.Directory.FullName;
# ----------------------------------------------------------------------------
Function RemoveDirectories
{
# Parameters.
param($pattern);
# Function.
$items = Get-ChildItem $wdir -Filter $pattern -Recurse -Force | Where-Object {$_ -is [System.IO.DirectoryInfo]};
foreach ($item in $items)
{
Write-Output $item.FullName;
Remove-Item -LiteralPath $item.FullName -Force -Recurse;
}
}
# ----------------------------------------------------------------------------
Function RemoveSubDirectories
{
# Parameters.
param($path);
# Function.
$dirs = Get-Item $path -ErrorAction SilentlyContinue;
foreach ($dir in $dirs)
{
Write-Output "Clear: $($dir.FullName)";
$items = Get-ChildItem -LiteralPath $dir.FullName -Force | Where-Object {$_ -is [System.IO.DirectoryInfo]};
foreach ($item in $items)
{
Write-Output " - $($item.Name)";
Remove-Item -LiteralPath $item.FullName -Force -Recurse;
}
}
}
# ----------------------------------------------------------------------------
Function RemoveFiles
{
# Parameters.
param($pattern);
# Function.
$items = Get-ChildItem $wdir -Filter $pattern -Recurse -Force | Where-Object {$_ -is [System.IO.FileInfo]};
foreach ($item in $items)
{
Write-Output $item.FullName;
Remove-Item -LiteralPath $item.FullName -Force;
}
}
# ----------------------------------------------------------------------------
Function KillProcess
{
# Parameters.
param($pattern);
# Function.
$procs = Get-Process;
foreach ($proc in $procs)
{
if ($proc.Path)
{
$item = Get-Item $proc.Path;
if ($item.Name -eq $pattern)
{
Write-Output "Stopping process: $($item.Name)";
Stop-Process $proc;
}
}
}
}
# ----------------------------------------------------------------------------
# Clear IIS Express configuration.
KillProcess "iisexpress.exe";
KillProcess "iisexpresstray.exe";
RemoveSubDirectories "$($env:USERPROFILE)\Documents\My Web Sites";
# Clear directories and files.
RemoveDirectories ".vs";
RemoveFiles "*.dbmdl";
RemoveFiles "*.user";
RemoveFiles "*.suo";
pause;
77 changes: 77 additions & 0 deletions Clear_Cache_VS.ps1
@@ -0,0 +1,77 @@
<#
.SYNOPSIS
Clear Visual Studio cache files.
.NOTES
Author: Evaldas Jocys <evaldas@jocys.com>
Modified: 2021-04-14
.LINK
http://www.jocys.com
#>
#----------------------------------------------------------------------------
# Run as administrator.
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$arguments = "& '" + $myinvocation.mycommand.definition + "'";
Start-Process powershell -Verb runAs -ArgumentList $arguments;
break;
}
#----------------------------------------------------------------------------
# Get current command path.
[string]$current = $MyInvocation.MyCommand.Path;
# Get calling command path.
[string]$calling = @(Get-PSCallStack)[1].InvocationInfo.MyCommand.Path;
# If executed directly then...
if ($calling -ne "") {
$current = $calling;
}
$file = Get-Item $current;
# Working folder.
$wdir = $file.Directory.FullName;
# ----------------------------------------------------------------------------
function RemoveSubFoldersAndFiles
{
# Parameters.
param($path);
# Function.
$dirs = Get-Item $path -ErrorAction SilentlyContinue;
foreach ($dir in $dirs)
{
Write-Output "Clear: $($dir.FullName)";
$items = Get-ChildItem -LiteralPath $dir.FullName -Force;
foreach ($item in $items)
{
Write-Output " - $($item.Name)";
Remove-Item -LiteralPath $item.FullName -Force -Recurse;
}
}
}
# ----------------------------------------------------------------------------
# Fix Visual Studio "Windows Form Designer: Could not load file or assembly" designer error by
# clearing temporary compiled assemblies inside dynamically created folders by Visual Studio.
# Visual studio must be closed for this batch script to succeed.
#
# Clear Visual Studio.
RemoveSubFoldersAndFiles "$($env:USERPROFILE)\AppData\Local\Microsoft\VisualStudio\12.*\ProjectAssemblies";
RemoveSubFoldersAndFiles "$($env:USERPROFILE)\AppData\Local\Microsoft\VisualStudio\13.*\ProjectAssemblies";
RemoveSubFoldersAndFiles "$($env:USERPROFILE)\AppData\Local\Microsoft\VisualStudio\14.*\ProjectAssemblies";
RemoveSubFoldersAndFiles "$($env:USERPROFILE)\AppData\Local\Microsoft\VisualStudio\15.*\ProjectAssemblies";
RemoveSubFoldersAndFiles "$($env:USERPROFILE)\AppData\Local\Microsoft\VisualStudio\16.*\ProjectAssemblies";
# Clear IIS Express.
RemoveSubFoldersAndFiles "$($env:LOCALAPPDATA)\Temp\iisexpress";
RemoveSubFoldersAndFiles "$($env:LOCALAPPDATA)\Temp\Temporary ASP.NET Files";
# Clear Xamarin.
RemoveSubFoldersAndFiles "$($env:LOCALAPPDATA)\Temp\Xamarin";
RemoveSubFoldersAndFiles "$($env:LOCALAPPDATA)\Xamarin\iOS\Provisioning";
# Clear .NET Framework.
RemoveSubFoldersAndFiles "$($env:SystemRoot)\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files";
RemoveSubFoldersAndFiles "$($env:SystemRoot)\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files";
#
# Solution Explorer, right-click Solution
# Properties -> Common Properties -> Debug Source Files -> clean "Do not look for these source files" box.
#
# Tools -> Options -> Projects and Solutions -> Build and Run
# Set "On Run, when build or deployment errors occur:" Prompt to Launch
#
# .EditorConfig file.
# "charset=utf-8" option can trigger "The source file is different from when the module was built." warning when debugging.
pause;
Binary file added FocusLogger/App.ico
Binary file not shown.
16 changes: 16 additions & 0 deletions FocusLogger/App.xaml
@@ -0,0 +1,16 @@
<Application
x:Class="JocysCom.FocusLogger.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:JocysCom.FocusLogger"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="JocysCom/Controls/Themes/Default.xaml" />
<ResourceDictionary Source="JocysCom/Controls/Themes/Icons.xaml" />
<ResourceDictionary Source="Resources/Icons/Icons_Default.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
17 changes: 17 additions & 0 deletions FocusLogger/App.xaml.cs
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace JocysCom.FocusLogger
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
10 changes: 10 additions & 0 deletions FocusLogger/AssemblyInfo.cs
@@ -0,0 +1,10 @@
using System.Windows;

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
57 changes: 57 additions & 0 deletions FocusLogger/Common/DataItem.cs
@@ -0,0 +1,57 @@
using JocysCom.ClassLibrary.Configuration;
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace JocysCom.FocusLogger
{
public class DataItem : ISettingsItem, INotifyPropertyChanged
{

public DateTime Date { get => _Date; set => SetProperty(ref _Date, value); }
DateTime _Date;

public int ProcessId { get => _ProcessId; set => SetProperty(ref _ProcessId, value); }
int _ProcessId;

public string ProcessName { get => _ProcessName; set => SetProperty(ref _ProcessName, value); }
string _ProcessName;

public string ProcessPath { get => _ProcessPath; set => SetProperty(ref _ProcessPath, value); }
string _ProcessPath;

public string WindowTitle { get => _WindowTitle; set => SetProperty(ref _WindowTitle, value); }
string _WindowTitle;

public System.Windows.MessageBoxImage StatusCode { get => _StatusCode; set => SetProperty(ref _StatusCode, value); }
System.Windows.MessageBoxImage _StatusCode;

#region ■ ISettingsItem

bool ISettingsItem.Enabled { get => IsEnabled; set => IsEnabled = value; }
private bool IsEnabled;

public bool IsEmpty =>
string.IsNullOrEmpty(ProcessName);

#endregion

#region ■ INotifyPropertyChanged

public event PropertyChangedEventHandler PropertyChanged;

protected void SetProperty<T>(ref T property, T value, [CallerMemberName] string propertyName = null)
{
property = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

#endregion

}
}
7 changes: 7 additions & 0 deletions FocusLogger/Common/DataItemType.cs
@@ -0,0 +1,7 @@
namespace JocysCom.FocusLogger
{
public enum DataItemType
{
None = 0,
}
}

0 comments on commit 477a4fe

Please sign in to comment.