-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46ba7d3
commit 30b2596
Showing
8 changed files
with
178 additions
and
3 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
|
||
namespace Project1.UI.Controls | ||
{ | ||
public class Project1UIToast : Window | ||
{ | ||
#region 依赖属性 | ||
#region 消息 | ||
public static readonly DependencyProperty MessageProperty = DependencyProperty.Register("Message", typeof(string), typeof(Project1UIToast)); | ||
/// <summary> | ||
/// 消息 | ||
/// </summary> | ||
public string Message | ||
{ | ||
get { return (string)GetValue(MessageProperty); } | ||
set { SetValue(MessageProperty, value); } | ||
} | ||
#endregion | ||
#region 副标题 | ||
public static readonly DependencyProperty SubtitleProperty = DependencyProperty.Register("Subtitle", typeof(string), typeof(Project1UIToast)); | ||
/// <summary> | ||
/// 消息 | ||
/// </summary> | ||
public string Subtitle | ||
{ | ||
get { return (string)GetValue(SubtitleProperty); } | ||
set { SetValue(SubtitleProperty, value); } | ||
} | ||
#endregion | ||
#endregion | ||
|
||
private StackPanel buttonsPanel; | ||
|
||
public Project1UIToast() | ||
{ | ||
this.DefaultStyleKey = typeof(Project1UIToast); | ||
} | ||
public override void OnApplyTemplate() | ||
{ | ||
base.OnApplyTemplate(); | ||
buttonsPanel = GetTemplateChild("buttonsPanel") as StackPanel; | ||
} | ||
private void CreateButtons(string[] buttons) | ||
{ | ||
if (buttonsPanel != null) | ||
{ | ||
foreach (string name in buttons) | ||
{ | ||
var btn = new Project1UIButton(); | ||
btn.Content = name; | ||
buttonsPanel.Children.Add(btn); | ||
} | ||
} | ||
} | ||
public void Alert(string title, string message, | ||
string subtitle = "", | ||
int duration = 0, | ||
string[] buttons = null) | ||
{ | ||
|
||
this.Title = title; | ||
this.Message = message; | ||
this.Subtitle = subtitle; | ||
this.Loaded += (e, c) => | ||
{ | ||
this.Visibility = Visibility.Visible; | ||
CreateButtons(buttons); | ||
}; | ||
this.Show(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:controls="clr-namespace:Project1.UI.Controls" | ||
> | ||
|
||
|
||
|
||
|
||
<Style TargetType="{x:Type controls:Project1UIToast}"> | ||
<Setter Property="Background" Value="{DynamicResource WindowBackground}" /> | ||
<Setter Property="SnapsToDevicePixels" Value="False" /> | ||
<Setter Property="Width" Value="384" /> | ||
<Setter Property="Height" Value="160" /> | ||
<Setter Property="AllowsTransparency" Value="True" /> | ||
<Setter Property="ResizeMode" Value="NoResize" /> | ||
<Setter Property="WindowStyle" Value="None" /> | ||
<Setter Property="ShowInTaskbar" Value="False" /> | ||
<Setter Property="Topmost" Value="True" /> | ||
<Setter Property="Visibility" Value="Collapsed" /> | ||
|
||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type controls:Project1UIToast}"> | ||
<Border Background="{TemplateBinding Background}" Margin="10" BorderBrush="#ABADB3" BorderThickness="1"> | ||
<Border.Effect> | ||
<DropShadowEffect ShadowDepth="0" Opacity=".2" BlurRadius="16"/> | ||
</Border.Effect> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="40"/> | ||
<RowDefinition Height="*"/> | ||
<RowDefinition Height="40"/> | ||
</Grid.RowDefinitions> | ||
<!--header--> | ||
<Grid Grid.Row="0"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="48"/> | ||
<ColumnDefinition Width="*"/> | ||
</Grid.ColumnDefinitions> | ||
<!--icon--> | ||
<Image Grid.Column="0" Source="/Project1.UI;component/Assets/Images/sunglasses.png" Width="15" VerticalAlignment="Center" HorizontalAlignment="Center" /> | ||
|
||
|
||
<TextBlock Grid.Column="1" Text="{TemplateBinding Title}" VerticalAlignment="Center" FontSize="14" FontWeight="Bold"/> | ||
</Grid> | ||
<!--content--> | ||
<StackPanel Margin="48,0,0,0" Grid.Row="1"> | ||
<TextBlock Text="{TemplateBinding Subtitle}" FontSize="14" FontWeight="Bold"/> | ||
<TextBlock Margin="0,5,0,0" Text="{TemplateBinding Message}" FontSize="14"/> | ||
</StackPanel> | ||
<!--buttons--> | ||
<StackPanel x:Name="buttonsPanel" Grid.Row="2" Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="10"> | ||
|
||
</StackPanel> | ||
|
||
|
||
</Grid> | ||
</Border> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
|
||
</Style> | ||
|
||
|
||
</ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ProjectEye.Core.Service | ||
{ | ||
public class PreAlertService : IService | ||
{ | ||
public void Init() | ||
{ | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters