Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
proj: FontAwesome.Wpf : icons from http://www.fontawesome.com.cn/
proj: MapEditor.Controls : custom controls for mapeditor
proj: MapEditor.Grpc :  grpc base model
proj: MapEditor.Grpc.Server : grpc server impl
proj: MapEditor.Models : models in solution
proj: MapEditor.WpfShell :  UI of mapeditor
  • Loading branch information
uj95170 committed Jan 21, 2022
1 parent df67f80 commit be7cbb4
Show file tree
Hide file tree
Showing 60 changed files with 4,793 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/FontAwesome.Wpf/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)
)]
16 changes: 16 additions & 0 deletions src/FontAwesome.Wpf/FontAwesome.Wpf.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>

<ItemGroup>
<None Remove="FontAwesome\fontawesome-webfont.ttf" />
</ItemGroup>

<ItemGroup>
<Resource Include="FontAwesome\fontawesome-webfont.ttf" />
</ItemGroup>

</Project>
Binary file not shown.
699 changes: 699 additions & 0 deletions src/FontAwesome.Wpf/IconDictionary.xaml

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/MapEditor.Controls/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)
)]
227 changes: 227 additions & 0 deletions src/MapEditor.Controls/BusyIndicator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
using System;
using System.Drawing;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Threading;

namespace MapEditor.Controls
{
/// <summary>
/// BusyIndicator
/// </summary>
[StyleTypedProperty(Property = "ProgressBarStyle", StyleTargetType = typeof(ProgressBar))]
[StyleTypedProperty(Property = "OverlayStyle", StyleTargetType = typeof(Rectangle))]
[TemplateVisualState(Name = "Hidden", GroupName = "VisibilityStates")]
[TemplateVisualState(Name = "Visible", GroupName = "VisibilityStates")]
[TemplateVisualState(Name = "Idle", GroupName = "BusyStatusStates")]
[TemplateVisualState(Name = "Busy", GroupName = "BusyStatusStates")]
public class BusyIndicator : ContentControl
{
private DispatcherTimer m_DisplayAfterTimer;

#region DependencyProperties

public static readonly DependencyProperty IsBusyProperty =
DependencyProperty.Register(
"IsBusy",
typeof(bool),
typeof(BusyIndicator),
new PropertyMetadata(false, new PropertyChangedCallback(OnIsBusyChanged)));

public static readonly DependencyProperty BusyContentProperty =
DependencyProperty.Register(
"BusyContent",
typeof(object),
typeof(BusyIndicator),
new PropertyMetadata(null));

public static readonly DependencyProperty BusyContentTemplateProperty =
DependencyProperty.Register(
"BusyContentTemplate",
typeof(DataTemplate),
typeof(BusyIndicator),
new PropertyMetadata(null));

public static readonly DependencyProperty DisplayAfterProperty =
DependencyProperty.Register(
"DisplayAfter",
typeof(TimeSpan),
typeof(BusyIndicator),
new PropertyMetadata(TimeSpan.FromSeconds(0.1)));

public static readonly DependencyProperty OverlayStyleProperty =
DependencyProperty.Register(
"OverlayStyle",
typeof(Style),
typeof(BusyIndicator),
new PropertyMetadata(null));

public static readonly DependencyProperty ProgressBarStyleProperty =
DependencyProperty.Register(
"ProgressBarStyle",
typeof(Style),
typeof(BusyIndicator),
new PropertyMetadata(null));

#endregion

#region Properties

protected bool IsContentVisible
{
get;
set;
}

public bool IsBusy
{
get
{
return (bool)GetValue(IsBusyProperty);
}
set
{
SetValue(IsBusyProperty, value);
}
}

public object BusyContent
{
get
{
return GetValue(BusyContentProperty);
}
set
{
SetValue(BusyContentProperty, value);
}
}

public DataTemplate BusyContentTemplate
{
get
{
return (DataTemplate)GetValue(BusyContentTemplateProperty);
}
set
{
SetValue(BusyContentTemplateProperty, value);
}
}

public TimeSpan DisplayAfter
{
get
{
return (TimeSpan)GetValue(DisplayAfterProperty);
}
set
{
SetValue(DisplayAfterProperty, value);
}
}

public Style OverlayStyle
{
get
{
return (Style)GetValue(OverlayStyleProperty);
}
set
{
SetValue(OverlayStyleProperty, value);
}
}

public Style ProgressBarStyle
{
get
{
return (Style)GetValue(ProgressBarStyleProperty);
}
set
{
SetValue(ProgressBarStyleProperty, value);
}
}

#endregion

#region Constructors

static BusyIndicator()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(BusyIndicator), new FrameworkPropertyMetadata(typeof(BusyIndicator)));
}

public BusyIndicator()
{
m_DisplayAfterTimer = new DispatcherTimer();
Loaded += delegate
{
m_DisplayAfterTimer.Tick += new EventHandler(DisplayAfterTimerElapsed);
};
Unloaded -= delegate
{
m_DisplayAfterTimer.Tick -= new EventHandler(DisplayAfterTimerElapsed);
m_DisplayAfterTimer.Stop();
};
}

#endregion

#region Overrides

public override void OnApplyTemplate()
{
base.OnApplyTemplate();
ChangeVisualState(false);
}

#endregion

#region methods

private void DisplayAfterTimerElapsed(object sender, EventArgs e)
{
m_DisplayAfterTimer.Stop();
IsContentVisible = true;
ChangeVisualState(true);
}

private static void OnIsBusyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((BusyIndicator)d).OnIsBusyChanged(e);
}

protected virtual void OnIsBusyChanged(DependencyPropertyChangedEventArgs e)
{
if (IsBusy)
{
if (DisplayAfter.Equals(TimeSpan.Zero))
{
IsContentVisible = true;
}
else
{
m_DisplayAfterTimer.Interval = DisplayAfter;
m_DisplayAfterTimer.Start();
}
}
else
{
m_DisplayAfterTimer.Stop();
IsContentVisible = false;
}
ChangeVisualState(true);
}

protected virtual void ChangeVisualState(bool useTransitions)
{
VisualStateManager.GoToState(this, IsBusy ? "Busy" : "Idle", useTransitions);
VisualStateManager.GoToState(this, IsContentVisible ? "Visible" : "Hidden", useTransitions);
}

#endregion
}
}
26 changes: 26 additions & 0 deletions src/MapEditor.Controls/ErrorEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;

namespace MapEditor.Controls
{
public class ErrorEventArgs : EventArgs
{
protected Exception m_ErrorException;

public Exception ErrorException
{
get
{
return m_ErrorException;
}
protected set
{
m_ErrorException = value;
}
}

public ErrorEventArgs(Exception errorExcetion) : base()
{
m_ErrorException = errorExcetion;
}
}
}
58 changes: 58 additions & 0 deletions src/MapEditor.Controls/MapControl.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit be7cbb4

Please sign in to comment.