Skip to content

Commit

Permalink
Update shared files.
Browse files Browse the repository at this point in the history
  • Loading branch information
EJocys committed Aug 26, 2023
1 parent 6ecd6a5 commit 60f171a
Show file tree
Hide file tree
Showing 27 changed files with 1,806 additions and 879 deletions.
56 changes: 32 additions & 24 deletions FocusLogger/Controls/DataListControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,22 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ToolBarPanel Grid.Row="0" HorizontalAlignment="Right" Style="{StaticResource MainToolBarPanel}">
<ToolBar Style="{StaticResource MainToolBar}">
<Button
Name="ClearButton"
HorizontalAlignment="Right"
Click="ClearButton_Click"
Style="{StaticResource ToolBarButton}">
<StackPanel Style="{StaticResource ButtonStackPanel}">
<ContentControl Content="{StaticResource Icon_Delete}" Style="{StaticResource ButtonContentControl}" />
<Label Content="Clear" Style="{StaticResource ButtonLabel}" />
</StackPanel>
</Button>
</ToolBar>
<ToolBarPanel
Grid.Row="0"
HorizontalAlignment="Right"
Style="{StaticResource MainToolBarPanel}">
<Button
Name="ClearButton"
Margin="2"
Padding="3,0,3,0"
Background="Transparent"
Click="ClearButton_Click">
<StackPanel Style="{StaticResource ButtonStackPanel}">
<ContentControl Content="{StaticResource Icon_Delete}" Focusable="False" />
<Label Content="Clear" Style="{StaticResource ButtonLabel}" />
</StackPanel>
</Button>

</ToolBarPanel>
<DataGrid
x:Name="MainDataGrid"
Expand Down Expand Up @@ -85,15 +88,17 @@
CanUserResize="False"
IsReadOnly="True">
<DataGridTemplateColumn.Header>
<TextBlock HorizontalAlignment="Center" Text="A" ToolTip="Window is Active" />
<TextBlock
HorizontalAlignment="Center"
Text="A"
ToolTip="Window is Active" />
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ContentControl
x:Name="IsActiveIcon"
Width="12"
Height="12"
Style="{StaticResource ButtonContentControl}">
Height="12">
<ContentControl.Content>
<MultiBinding Converter="{StaticResource _MainDataGridFormattingConverter}">
<Binding RelativeSource="{RelativeSource Self}" />
Expand Down Expand Up @@ -125,15 +130,17 @@
CanUserResize="False"
IsReadOnly="True">
<DataGridTemplateColumn.Header>
<TextBlock HorizontalAlignment="Center" Text="M" ToolTip="Window has Mouse" />
<TextBlock
HorizontalAlignment="Center"
Text="M"
ToolTip="Window has Mouse" />
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ContentControl
x:Name="HasMouseIcon"
Width="12"
Height="12"
Style="{StaticResource ButtonContentControl}">
Height="12">
<ContentControl.Content>
<MultiBinding Converter="{StaticResource _MainDataGridFormattingConverter}">
<Binding RelativeSource="{RelativeSource Self}" />
Expand Down Expand Up @@ -172,8 +179,7 @@
<ContentControl
x:Name="HasKeyboardIcon"
Width="12"
Height="12"
Style="{StaticResource ButtonContentControl}">
Height="12">
<ContentControl.Content>
<MultiBinding Converter="{StaticResource _MainDataGridFormattingConverter}">
<Binding RelativeSource="{RelativeSource Self}" />
Expand Down Expand Up @@ -205,15 +211,17 @@
CanUserResize="False"
IsReadOnly="True">
<DataGridTemplateColumn.Header>
<TextBlock HorizontalAlignment="Center" Text="C" ToolTip="Window has Caret" />
<TextBlock
HorizontalAlignment="Center"
Text="C"
ToolTip="Window has Caret" />
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ContentControl
x:Name="HasCaretIcon"
Width="12"
Height="12"
Style="{StaticResource ButtonContentControl}">
Height="12">
<ContentControl.Content>
<MultiBinding Converter="{StaticResource _MainDataGridFormattingConverter}">
<Binding RelativeSource="{RelativeSource Self}" />
Expand Down
39 changes: 0 additions & 39 deletions FocusLogger/Documents/Step2_app_sign.bat

This file was deleted.

10 changes: 10 additions & 0 deletions FocusLogger/Documents/app_sign.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Import-Module "d:\_Backup\Configuration\SSL\Tools\app_signModule.ps1" -Force

[string[]]$appFiles = @(
"..\bin\Release\publish\JocysCom.FocusLogger.exe",
)
[string]$appName = "Jocys.com Focus Logger"
[string]$appLink = "https://www.jocys.com"

ProcessFiles $appName $appLink $appFiles
pause
30 changes: 30 additions & 0 deletions FocusLogger/Documents/app_zip.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@ECHO off
SET wra="%ProgramFiles%\WinRAR\winrar.exe"
IF NOT EXIST %wra% SET wra="%ProgramFiles(x86)%\WinRAR\winrar.exe"
IF NOT EXIST %wra% SET wra="%ProgramW6432%\WinRAR\winrar.exe"
IF NOT EXIST %wra% SET wra="D:\Program Files\WinRAR\winrar.exe"
SET zip=%wra% a -ep
:: ---------------------------------------------------------------------------
IF NOT EXIST Files\nul MKDIR Files
::-------------------------------------------------------------
:: Archive Files
CALL:CRE Files JocysCom.FocusLogger.exe .exe
ECHO.
pause
GOTO:EOF

::-------------------------------------------------------------
:CRE :: Archive
::-------------------------------------------------------------
SET src=%~1
SET arc=Files\%~2.zip
ECHO.
IF NOT EXIST "%src%\%~2%~3" (
ECHO "%src%\%~2%~3" not exist. Skipping.
GOTO:EOF
)
ECHO Creating: %arc%
:: Create Archive.
IF EXIST %arc% DEL %arc%
%zip% %arc% %src%\%~2%~3
GOTO:EOF
57 changes: 57 additions & 0 deletions FocusLogger/JocysCom/Collections/CollectionsHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System.Collections.Generic;
using System.Linq;

namespace JocysCom.ClassLibrary.Collections
{
public static partial class CollectionsHelper
{

/// <summary>
/// Synchronize source collection to destination.
/// </summary>
public static void Synchronize<T>(IList<T> source, IList<T> target, IEqualityComparer<T> comparer = null)
{
comparer = comparer ?? EqualityComparer<T>.Default;
// Create a dictionary for fast lookup in source list
var sourceSet = new Dictionary<T, int>();
for (int i = 0; i < source.Count; i++)
sourceSet[source[i]] = i;
// Iterate over the target, remove items not in source
for (int i = target.Count - 1; i >= 0; i--)
if (!sourceSet.Keys.Contains(target[i], comparer))
target.RemoveAt(i);
// Iterate over source
for (int si = 0; si < source.Count; si++)
{
// If item is not present in target, insert it.
// Note: Only check items that have not been synchornized in the target.
if (!target.Skip(si).Contains(source[si], comparer))
{
target.Insert(si, source[si]);
continue;
}
// If item is present in target but not at the right position, move it.
int ti = -1;
// Note: Only check items that have not been synchornized in the target.
for (int i = si; i < target.Count; i++)
{
if (comparer.Equals(target[i], source[si]))
{
ti = i;
break;
}
}
if (ti != si)
{
T temp = target[si];
target[si] = target[ti];
target[ti] = temp;
}
}
// Remove items at the end of target that exceed source's length
while (target.Count > source.Count)
target.RemoveAt(target.Count - 1);
}

}
}
2 changes: 1 addition & 1 deletion FocusLogger/JocysCom/ComponentModel/BindingListInvoked.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void AddRange(IEnumerable<T> list)
void Invoke(Delegate method, params object[] args)
{
var so = SynchronizingObject;
if (so == null || !JocysCom.ClassLibrary.Controls.ControlsHelper.InvokeRequired)
if (so is null || !JocysCom.ClassLibrary.Controls.ControlsHelper.InvokeRequired)
{
DynamicInvoke(method, args);
}
Expand Down
2 changes: 1 addition & 1 deletion FocusLogger/JocysCom/ComponentModel/PropertyComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected int Compare(T x, T y)
private int CompareValues(object xValue, object yValue, ListSortDirection direction)
{
int retValue;
if (xValue == null && yValue == null)
if (xValue is null && yValue is null)
retValue = 0;
else if (xValue is IComparable)
retValue = ((IComparable)xValue).CompareTo(yValue);
Expand Down
2 changes: 1 addition & 1 deletion FocusLogger/JocysCom/ComponentModel/SortableBindingList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private void ApplySortInternal(PropertyComparer<T> comparer)
if (_OriginalCollection.Count == 0)
_OriginalCollection.AddRange(this);
var listRef = Items as List<T>;
if (listRef == null)
if (listRef is null)
return;
listRef.Sort(comparer);
_Sorted = true;
Expand Down
8 changes: 4 additions & 4 deletions FocusLogger/JocysCom/Configuration/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static AssemblyInfo Entry
{
lock (_EntryLock)
{
if (_Entry == null)
if (_Entry is null)
_Entry = new AssemblyInfo();
return _Entry;
}
Expand Down Expand Up @@ -122,7 +122,7 @@ public string RunMode
{
get
{
if (_RunMode == null)
if (_RunMode is null)
// TODO: Standardize configuration provider XML, JSON, INI, Registry, etc...
// https://docs.microsoft.com/en-us/dotnet/core/extensions/configuration-providers
//_RunMode = SettingsParser.Current.Parse("RunMode", "");
Expand Down Expand Up @@ -309,7 +309,7 @@ public static DateTime GetBuildDateTime(string filePath)
/// </remarks>
public static DateTime GetBuildDateTime(Assembly assembly, TimeZoneInfo tzi = null)
{
if (assembly == null)
if (assembly is null)
throw new ArgumentNullException(nameof(assembly));
var names = assembly.GetManifestResourceNames();
var dt = default(DateTime);
Expand Down Expand Up @@ -388,7 +388,7 @@ public string AssemblyPath
string GetAttribute<T>(Func<T, string> value) where T : Attribute
{
T attribute = (T)Attribute.GetCustomAttribute(Assembly, typeof(T));
return attribute == null
return attribute is null
? ""
: value.Invoke(attribute);
}
Expand Down
39 changes: 39 additions & 0 deletions FocusLogger/JocysCom/Configuration/ISettingsItemFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;

namespace JocysCom.ClassLibrary.Configuration
{
public interface ISettingsItemFile
{
/// <summary>
/// Map to property which contains base file name.
/// </summary>
string BaseName { get; set; }

/// <summary>
/// Map to property which contains last time item was modified.
/// Update on INotifyPropertyChanged.
/// </summary>
DateTime WriteTime { get; set; }

/* Example:
#region ■ ISettingsItemFile
[XmlIgnore]
string ISettingsItemFile.BaseName { get => Name; set => Name = value; }
[XmlIgnore]
DateTime ISettingsItemFile.WriteTime { get; set; }
#endregion
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
((ISettingsItemFile)this).WriteTime = DateTime.Now;
}
*/

}
}

Loading

0 comments on commit 60f171a

Please sign in to comment.