Skip to content

Commit

Permalink
Overhaul.
Browse files Browse the repository at this point in the history
  • Loading branch information
Amir Grozki authored and Amir Grozki committed Jan 2, 2022
0 parents commit cb0f44b
Show file tree
Hide file tree
Showing 34 changed files with 1,999 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.idea/
.vscode/
.vs/

bin/
obj/

*.user
9 changes: 9 additions & 0 deletions App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Application x:Class="HocrEditor.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:HocrEditor"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
17 changes: 17 additions & 0 deletions App.xaml.cs
Original file line number Diff line number Diff line change
@@ -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 HocrEditor
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
10 changes: 10 additions & 0 deletions AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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)
)]
46 changes: 46 additions & 0 deletions BindingHelpers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;

namespace HocrEditor;

public static class BindingHelpers
{
public static void SubscribeItemPropertyChanged<T>(
this ObservableCollection<T> collection,
PropertyChangedEventHandler handler
)
where T : INotifyPropertyChanged
{
void CollectionOnCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
if (e.OldItems != null)
{
foreach (var oldItem in e.OldItems)
{
((INotifyPropertyChanged)oldItem).PropertyChanged -= ItemOnPropertyChanged;
}
}

if (e.NewItems != null)
{
foreach (var newItem in e.NewItems)
{
((INotifyPropertyChanged)newItem).PropertyChanged += ItemOnPropertyChanged;
}
}
}

void ItemOnPropertyChanged(object? sender, PropertyChangedEventArgs e)
{
handler.Invoke(sender, e);
}

collection.CollectionChanged += CollectionOnCollectionChanged;

foreach (var item in collection)
{
item.PropertyChanged += ItemOnPropertyChanged;
}
}
}
15 changes: 15 additions & 0 deletions Controls/DocumentCanvas.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<av:UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
mc:Ignorable="d"
d:DesignWidth="800"
d:DesignHeight="450"
xmlns:skia="clr-namespace:SkiaSharp.Views.WPF;assembly=SkiaSharp.Views.WPF"
x:Class="HocrEditor.Controls.DocumentCanvas">
<av:Grid>
<skia:SKElement Name="Canvas"
PaintSurface="Canvas_OnPaintSurface" />
</av:Grid>
</av:UserControl>
Loading

0 comments on commit cb0f44b

Please sign in to comment.