Browse Source

解决冲突 更新

样式分支
fyf 2 years ago
parent
commit
1defd58564
9 changed files with 852 additions and 2 deletions
  1. +5
    -0
      BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
  2. BIN
     
  3. BIN
     
  4. +255
    -0
      BPASmartClient.CustomResource/UserControls/MessageShow/ControlEnum.cs
  5. +88
    -0
      BPASmartClient.CustomResource/UserControls/MessageShow/NoticeDemoViewModel.cs
  6. +144
    -0
      BPASmartClient.CustomResource/UserControls/MessageShow/Notifiaction.xaml
  7. +353
    -0
      BPASmartClient.CustomResource/UserControls/MessageShow/Notifiaction.xaml.cs
  8. +1
    -1
      BPASmartClient/MainWindow.xaml
  9. +6
    -1
      BPASmartClient/MainWindow.xaml.cs

+ 5
- 0
BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj View File

@@ -4,11 +4,13 @@
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>

<ItemGroup>
<None Remove="Fonts\iconfont.ttf" />
<None Remove="Image\bg.png" />
<None Remove="Image\btn_close.png" />
<None Remove="Image\btn_normal.png" />
<None Remove="Image\buttonOff.png" />
<None Remove="Image\buttonOn.png" />
@@ -117,6 +119,7 @@
<None Remove="Image\竖线.png" />
<None Remove="Image\维护.png" />
<None Remove="Image\背景.png" />
<None Remove="Image\背景2.png" />
<None Remove="Image\背景图片.png" />
<None Remove="Image\背景矢量\内部.png" />
<None Remove="Image\背景矢量\右上.png" />
@@ -158,12 +161,14 @@
</ItemGroup>

<ItemGroup>
<Resource Include="Image\btn_close.png" />
<Resource Include="Image\告警\Wifi_NO.png" />
<Resource Include="Image\告警\Wifi_OK.png" />
<Resource Include="Image\告警\严重告警.png" />
<Resource Include="Image\告警\无告警.png" />
<Resource Include="Image\告警\无告警1.png" />
<Resource Include="Image\告警\轻微告警.png" />
<Resource Include="Image\背景2.png" />
<Resource Include="Image\边角.png" />
</ItemGroup>



BIN
View File


BIN
View File


+ 255
- 0
BPASmartClient.CustomResource/UserControls/MessageShow/ControlEnum.cs View File

@@ -0,0 +1,255 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.CustomResource.UserControls
{
#region EnumDatePickerType
public enum EnumDatePickerType
{
/// <summary>
/// 单个日期
/// </summary>
SingleDate,
/// <summary>
/// 连续的多个日期
/// </summary>
SingleDateRange,
/// <summary>
/// 只显示年份
/// </summary>
Year,
/// <summary>
/// 只显示月份
/// </summary>
Month,
/// <summary>
/// 显示一个日期和时间
/// </summary>
DateTime,
/// <summary>
/// 显示连续的日期和时间
/// </summary>
DateTimeRange,
}
#endregion

#region FlatButtonSkinEnum
/// <summary>
/// Button类型
/// </summary>
public enum FlatButtonSkinEnum
{
Yes,
No,
Default,
primary,
ghost,
dashed,
text,
info,
success,
error,
warning,
}
#endregion

#region EnumPromptType
/// <summary>
/// 提示类型
/// </summary>
public enum EnumPromptType
{
/// <summary>
/// 消息
/// </summary>
Info,
/// <summary>
/// 警告
/// </summary>
Warn,
/// <summary>
/// 失败
/// </summary>
Error,
/// <summary>
/// 成功
/// </summary>
Success,
}
#endregion

/// <summary>
/// 加载类型
/// </summary>
#region EnumLoadingType
public enum EnumLoadingType
{
/// <summary>
/// 两个圆
/// </summary>
DoubleRound,
/// <summary>
/// 一个圆
/// </summary>
SingleRound,
/// <summary>
/// 仿Win10加载条
/// </summary>
Win10,
/// <summary>
/// 仿Android加载条
/// </summary>
Android,
/// <summary>
/// 仿苹果加载条
/// </summary>
Apple,
Cogs,
Normal,
/// <summary>
/// 线条动画
/// </summary>
Lines,
/// <summary>
/// 方格动画
/// </summary>
Grids,
/// <summary>
/// 中心旋转动画
/// </summary>
Rotate,
/// <summary>
/// 版块加载
/// </summary>
Block,
/// <summary>
/// 自定义图标动画
/// </summary>
PathAnimation
}
#endregion

/// <summary>
/// 方向
/// </summary>
#region EnumPlacement
public enum EnumPlacement
{
/// <summary>
/// 左上
/// </summary>
LeftTop,
/// <summary>
/// 左中
/// </summary>
LeftCenter,
/// <summary>
/// 左下
/// </summary>
LeftBottom,
/// <summary>
/// 右上
/// </summary>
RightTop,
/// <summary>
/// 右中
/// </summary>
RightCenter,
/// <summary>
/// 右下
/// </summary>
RightBottom,
/// <summary>
/// 上左
/// </summary>
TopLeft,
/// <summary>
/// 上中
/// </summary>
TopCenter,
/// <summary>
/// 上右
/// </summary>
TopRight,
/// <summary>
/// 下左
/// </summary>
BottomLeft,
/// <summary>
/// 下中
/// </summary>
BottomCenter,
/// <summary>
/// 下右
/// </summary>
BottomRight,
}
#endregion

/// <summary>
/// 动画容器类型
/// </summary>
public enum TransitionMode
{
Right2Left,
Left2Right,
Bottom2Top,
Top2Bottom,
Right2LeftWithFade,
Left2RightWithFade,
Bottom2TopWithFade,
Top2BottomWithFade,
Fade,
Custom
}
/// <summary>
/// 联系人类型
/// </summary>
public enum ContactType
{
SerialNumber,
Single,
Group,
AddUser,
CutUser
}
/// <summary>
/// 进度条类型
/// </summary>
public enum ProgressBarType
{
Line,
Round
}
/// <summary>
/// XAML显示类型
/// </summary>
public enum Scope
{
None,
This,
ThisAndChildren
}
/// <summary>
/// 加减数字控件
/// </summary>
public enum EnumCompare
{
/// <summary>
/// 小于
/// </summary>
Less,
/// <summary>
/// 等于
/// </summary>
Equal,
/// <summary>
/// 大于
/// </summary>
Large,
None,
}
}

+ 88
- 0
BPASmartClient.CustomResource/UserControls/MessageShow/NoticeDemoViewModel.cs View File

@@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;

namespace BPASmartClient.CustomResource.UserControls.MessageShow
{
public class NoticeDemoViewModel
{
public static Notifiaction NotifiactionShow { get; set; }

#region 右侧弹框
/// <summary>
/// 初始化
/// </summary>
public static void OnStartup()
{
//初始化通知弹框
if (NotifiactionShow == null)
{
NotifiactionShow = new Notifiaction();
}
}
/// <summary>
/// 手动关闭
/// </summary>
public static void OnExit(string e)
{
switch (e)
{
case "Error":
NotifiactionShow.Clear(EnumPromptType.Error);
return;
case "Success":
NotifiactionShow.Clear(EnumPromptType.Success);
return;
case "Warm":
NotifiactionShow.Clear(EnumPromptType.Warn);
return;
case "Info":
NotifiactionShow.Clear(EnumPromptType.Info);
return;
default:
break;
}
//NoticeManager.ExitNotifiaction();

}

/// <summary>
/// 屏幕右下角信息提示弹窗
/// </summary>
/// <param name="e">弹窗类型:Error、Success、Warm、Info,分别对应不同颜色</param>
/// <param name="title">弹窗消息类型:属性判证、XX告警...</param>
/// <param name="content">弹窗消息内容</param>
/// <param name="kcmbbh">一般为对应目标的目标编号</param>
/// <param name="id">该条消息的ID</param>
public static void OpenMsg(EnumPromptType type,System.Windows.Window window,string title,string content)
{
string text = string.Empty;
if (content != null)
{
if (content.Length < 40)
{
int count = 40 - content.Length;
for (int i = 0; i < count * 2; i++)
{
content += " ";
}

}
text = content;
}
if (NotifiactionShow == null) NotifiactionShow = new Notifiaction();
NotifiactionShow.AddNotifiaction(new NotifiactionModel()
{
Title = title,//"这是Error通知标题",
Content = text,//"这条通知不会自动关闭,需要点击关闭按钮",
ContentToolTip = content,
NotifiactionType = type,
window= window
});
}
#endregion
}
}

+ 144
- 0
BPASmartClient.CustomResource/UserControls/MessageShow/Notifiaction.xaml View File

@@ -0,0 +1,144 @@
<Window x:Class="BPASmartClient.CustomResource.UserControls.Notifiaction"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:local="clr-namespace:BPASmartClient.CustomResource.UserControls"
Title="Notifiaction" Width="300" MinHeight="700"
AllowsTransparency="True"
Background="Transparent" ShowActivated="False"
ShowInTaskbar="False"
UseLayoutRounding="True" WindowStyle="None" mc:Ignorable="d">

<Window.Resources>
<PathGeometry x:Key="Icon_Close" Figures="M754.782 212.596 512 455.368 269.218 212.596c-13.081-13.081-34.29-13.081-47.369 0-13.081 13.081-13.081 34.288 0 47.367l242.782 242.771L221.849 745.507c-13.081 13.081-13.081 34.288 0 47.367 13.081 13.081 34.29 13.081 47.369 0L512 550.103l242.782 242.771c13.081 13.081 34.289 13.081 47.37 0 13.081-13.081 13.081-34.288 0-47.367L559.37 502.735l242.782-242.771c13.081-13.081 13.081-34.288 0-47.367C789.07 199.517 767.862 199.517 754.782 212.596z" />
<PathGeometry x:Key="InfoIcon" Figures="M512 0C229.206 0 0 229.289 0 512s229.206 512 512 512 512-229.378 512-512C1024 229.289 794.794 0 512 0z m80.3 700.333c-38.656 58.028-77.911 102.656-144.128 102.656-45.139-7.339-63.66-39.678-53.844-72.617l85.078-281.683c2.05-6.911-1.367-14.25-7.678-16.467-6.228-2.216-18.6 5.972-29.267 17.578l-51.372 61.867c-1.367-10.328-0.083-27.561-0.083-34.473 38.572-58.027 102.06-103.766 145.15-103.766 40.872 4.183 60.16 36.95 53.077 72.872l-85.677 283.044c-1.112 6.484 2.216 12.8 8.105 15.017 6.228 2.133 19.539-5.972 30.206-17.667l51.455-61.866c1.284 10.333-1.022 28.505-1.022 35.505z m-11.433-367.96c-32.6 0-58.878-23.64-58.878-58.623s26.367-58.622 58.878-58.622c32.427 0 58.966 23.639 58.966 58.622s-26.455 58.622-58.966 58.622z" />
<!--<PathGeometry x:Key="WarnIcon" Figures="M514.63547095 64.50557607c-245.79772937 0-445.80505747 199.97978336-445.80505745 445.7795534 0 245.85077718 200.0073271 445.85810529 445.80505745 445.85810529 245.79875019 0 445.80505747-200.0073271 445.80505749-445.85810529C960.44052743 264.48535941 760.43422017 64.50557607 514.63547095 64.50557607zM572.44016637 798.25683382c-13.74446534 14.26678179-31.36753754 21.5057584-52.45401459 21.50575839-22.03113538 0-40.59886489-7.55216231-55.33899569-22.3453409-14.635056-14.79113893-22.03113538-32.5213256-22.03113537-52.66416523 0-19.46035985 6.87172326-35.87659514 20.50907311-48.78045812 17.93931743-17.04770793 36.61314256-25.70265117 55.39102367-25.70265118 20.40399732 0 38.08011732 7.3960794 52.55909039 21.92605961 14.58200819 14.47693239 21.92503973 32.31117502 21.92503974 53.08242667C593.00126648 766.25884451 586.0785361 784.14613494 572.44016637 798.25683382zM592.89721153 384.50077378l-26.12091168 136.06541617c-6.82071513 41.07119406-14.47693239 74.6932599-22.7656421 99.76545928l-0.94363748 3.04208384c0 0-8.28768988 0.42030118-11.59195128 0.42030118l-41.91077658-0.21015058-35.51138249-160.14195009c-12.43153382-62.47187666-20.40501816-106.16587322-24.39175932-133.59971641-2.09844638-17.73018767-3.09411183-30.84216056-3.09411182-39.34000105 0-2.51772771 0.7865347-7.92043552 2.5697547-16.10407044 1.5730694-17.57104421 8.39276469-31.21043477 20.24689454-40.23263136 11.43484853-8.60291527 27.48587116-13.74242565 47.89088833-15.21144013 10.85846444-1.67916503 18.25454379-2.57077553 21.55880619-2.57077552 23.28897839 0 43.22064757 6.03214073 59.16761426 17.99236524 16.4713238 12.27341122 24.75799285 29.68837249 24.75799287 51.87661064C602.75797079 305.71467607 599.50675619 337.81672134 592.89721153 384.50077378z" />-->
<PathGeometry x:Key="ErrorIcon" Figures="M881.510752 573.386092c-15.745612-6.138814-21.400403-6.851035-48.313356-8.439206-26.912953-1.588171-31.004131 0.221034-59.474556 2.077312-128.870066 0.884137-257.154801 16.884552-382.724705 47.590901-80.273255 19.629059-159.52218 45.809325-235.43001 78.411861-48.994877 21.038152-57.654095 69.491701-15.294334 103.485933 50.149167 40.246633 118.762871-8.394181 164.725692-31.022551 78.463026-38.626739 315.544653-119.546723 404.01766-135.841851 99.574856-18.339694 186.075953-8.589632 187.662077-32.692586C894.074905 591.861886 897.256364 579.524906 881.510752 573.386092z M912.098397 578.64077c-23.939225 14.811334 6.349615 37.685297 27.733645 32.69975 25.548886-5.955642 18.216897-25.934672-0.203638-34.332946C929.971463 572.610426 919.367965 574.147432 912.098397 578.64077 M271.709285 387.416564c19.113313-8.293897 38.860053-15.419178 57.628512-24.099884 26.979468-12.481266 54.486962-30.454616 58.508555-62.534242 4.055362-32.310893-16.281825-58.32743-43.281759-73.349565-64.283072-35.768645-136.454812-2.146896-194.184631 30.063713-30.356378 16.941857-53.135174 43.911092-66.342987 75.990718-34.590819 83.989903-7.642051 197.990307 18.917862 254.121721 18.296715 38.675858 60.662615 56.901964 101.754498 55.561433 22.150486-0.723477 45.067428-6.814196 65.925479-13.956873 13.036921-4.461615 25.762757-9.830903 38.068014-16.030092 6.14393-3.099594 12.186554-6.405897 18.096147-9.934257 4.305049-2.569522 10.900258-9.100262 15.659655-10.091846 1.880837-0.38988 3.752464-1.033539 5.611811-1.943258 18.915815-9.314133 29.03836-26.543539 27.069519-46.076408-1.451048-14.461363-13.455453-29.566386-42.797735-28.596292-7.640004 0.252757-15.519462 1.623987-22.781866 3.963265-15.020088 4.845355-100.891851 58.340733-110.154819 37.502126-5.955642-13.403265 32.605605-27.402093 41.409109-31.347962 21.132296-9.466606 44.182268-13.373589 65.581648-22.104437 26.91193-10.980076 71.130014-32.04074 75.275427-65.014736 5.104251-40.612976-44.633546-45.369304-72.502267-40.136116-27.031657 5.078669-52.896744 12.673647-77.589123 25.018813-1.862417 0.933255-3.859911 1.889023-5.930059 1.648546-13.731746-1.593288 2.78237-15.542998 6.14086-17.753339C244.361427 400.046209 257.868045 393.427464 271.709285 387.416564 M566.432727 365.658004c-12.226462-11.811-32.686447-10.939143-48.75747-11.757788-20.536732-1.043772-41.192168 0.070608-61.497633 3.350304-75.191516 12.137435-54.967916 133.555785-40.393989 185.121208 6.725168 23.793916 40.133046 46.989197 57.488319 19.673062 9.198499-14.473643 1.916653-33.547047 1.585101-49.431829-0.313132-15.392572-0.656963-30.79026-0.86981-46.182832-0.319272-23.76424 8.90788-46.573735 31.006178-57.501622 22.234397-10.998495 53.559846-0.539282 64.325028-29.865191 0.887206-2.419096 1.520633-5.052063 0.957815-7.571443C569.845453 369.570103 568.390311 367.549074 566.432727 365.658004 M582.388117 392.262942c-11.023054 13.939477-10.873652 47.750537-11.437493 64.707744-0.586354 17.634636 1.388627 35.198663 4.034896 52.608172 0.832971 5.485945 2.725064 43.529399 16.673751 33.727149 3.596921-2.52859 8.435113-0.706081 12.378935-5.194302 12.890588-14.678304 17.025769-34.983769 18.679431-53.875025 0.952698-10.960633-2.405793-22.618137 0.553609-33.388435 4.76042-17.334807 17.551748-12.81998 31.66314-17.21508 25.586748-7.980765 41.24231-30.269397 12.945847-45.13906C649.435139 378.801349 597.08791 373.672538 582.388117 392.262942z M736.139873 496.272807c-3.832282 2.353604-8.368598 3.053546-13.228279 1.078565-24.283056-9.867742-4.149507-47.554062 21.378913-36.992519-0.147356 0.293689-0.25992 0.595564-0.38681 0.896416 0.309038 0.308015 0.688685 0.539282 0.949628 0.917906C751.596913 472.068546 746.357586 490.011196 736.139873 496.272807zM752.159732 413.68688c-15.767102-6.786567-31.175023-7.724938-45.830815 2.731204-10.084683 7.192819-17.23657 17.887392-22.060435 29.274744-10.021238 23.608697-19.142989 51.077306 2.40477 70.483284 13.657045 12.298094 37.884842 25.13547 56.625672 18.027585 13.382798-5.070482 22.468734-17.929348 28.14399-30.451546 11.054777-24.421202 15.767102-65.370847-8.566096-83.972507C759.845785 417.461857 756.147556 415.401941 752.159732 413.68688z M831.934636 482.111273c0.164752-0.167822 0.306992-0.357134 0.477884-0.522909 17.013489-16.610306 39.110763-10.090822 60.309574-12.124132 3.007497-0.289596 5.5279-3.162016 3.490497-6.037507-9.083889-12.839423-22.604834-18.491143-37.19104-23.449062-8.798387-2.995217-16.394389 3.368724-21.968337 10.380418-1.974981-12.604062-8.864902-22.789029-24.152073-16.647145-22.857591 9.17701-22.583344 48.02069-21.716604 67.3929 0.652869 14.504342 5.808286 45.686529 25.759687 29.064966 10.776438-8.977465 11.877515-33.568537 14.491039-45.938262C831.585689 483.510132 831.766814 482.812237 831.934636 482.111273" />
<PathGeometry x:Key="SelectedIcon" Figures="M512 0C229.231 0 0 229.231 0 512 0 794.771 229.231 1024 512 1024 794.771 1024 1024 794.771 1024 512 1024 229.231 794.769 0 512 0ZM805.671 379.193 474.533 710.332C474.533 710.332 474.529 710.336 474.524 710.342 459.258 725.612 435.98 727.996 418.209 717.5 414.918 715.555 411.815 713.166 408.989 710.342 408.987 710.338 408.983 710.336 408.983 710.336L218.331 519.684C200.235 501.587 200.235 472.244 218.331 454.144 236.427 436.048 265.771 436.048 283.867 454.144L441.759 612.036 740.136 313.659C758.235 295.563 787.578 295.563 805.675 313.659 823.766 331.755 823.766 361.097 805.671 379.193Z" />

<Storyboard x:Key="CollapseStoryboard">
<DoubleAnimation Duration="0:0:0.3" From="70" Storyboard.TargetProperty="Height" To="0" />
</Storyboard>

<DataTemplate x:Key="NotifiactionTemplate">
<Grid x:Name="NoticeGrid" Margin="5" Tag="{Binding Path=Id}"
RenderTransformOrigin="1,0.5" SizeChanged="NoticeGrid_SizeChanged">
<Grid.RenderTransform>
<TransformGroup>
<ScaleTransform />
<RotateTransform />
<SkewTransform />
<TranslateTransform />
</TransformGroup>
</Grid.RenderTransform>

<Border x:Name="border" Margin="5,0,0,0" BorderBrush="#419aff" CornerRadius="2" Padding="5" BorderThickness="1" VerticalAlignment="Center" HorizontalAlignment="Center">
<Border.Background>
<ImageBrush Stretch="Fill" ImageSource="/BPASmartClient.CustomResource;component/Image/背景2.png" />
</Border.Background>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image x:Name="Icon" Grid.RowSpan="2" MaxWidth="26" Margin="10,0,10,0" VerticalAlignment="Center" Stretch="Uniform" ></Image>
<Grid Grid.Row="0" Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock x:Name="title" Grid.Column="0" VerticalAlignment="Center" FontSize="14"
Text="{Binding Title}" FontWeight="Bold">
<TextBlock.Foreground>
<SolidColorBrush Color="{Binding Path=color}" Opacity="1"/>
</TextBlock.Foreground>
</TextBlock>
<TextBlock x:Name="count" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14"
Text="{Binding count, StringFormat='1/{0}'}" FontWeight="Bold">
<TextBlock.Foreground>
<SolidColorBrush Color="{Binding Path=color}" Opacity="1"/>
</TextBlock.Foreground>
</TextBlock>
</Grid>
<TextBlock x:Name="text" Grid.Row="1" Grid.Column="1" Margin="0,8,30,0"
Text="{Binding Content}"
TextWrapping="Wrap" Background="Transparent">
<TextBlock.Foreground>
<SolidColorBrush Color="#f4f4f5" Opacity="1"/>
</TextBlock.Foreground>
</TextBlock>
<Image x:Name="PART_CloseButton" Grid.ColumnSpan="2" ToolTip="关闭窗口" Margin="0,0,5,0" Source="/BPASmartClient.CustomResource;component/Image/btn_close.png" HorizontalAlignment="Right" Width="12" Height="12" VerticalAlignment="Center" MouseLeftButtonDown="PART_CloseButton_MouseLeftButtonDown" Cursor="Hand"></Image>
</Grid>
</Border>
</Grid>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding NotifiactionType}" Value="Info">
<Setter TargetName="Icon" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/告警/消息.png"/>
</DataTrigger>
<DataTrigger Binding="{Binding NotifiactionType}" Value="Warn">
<Setter TargetName="Icon" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/告警/告警.png"/>
</DataTrigger>
<DataTrigger Binding="{Binding NotifiactionType}" Value="Error">
<Setter TargetName="Icon" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/告警/报错.png"/>
</DataTrigger>
<DataTrigger Binding="{Binding NotifiactionType}" Value="Success">
<Setter TargetName="Icon" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/告警/正常.png"/>
</DataTrigger>
<EventTrigger RoutedEvent="Grid.Loaded" SourceName="NoticeGrid">
<BeginStoryboard x:Name="FadeInStoryBoard">
<Storyboard>

<DoubleAnimation Duration="0:0:0.2" From="0.01" Storyboard.TargetName="NoticeGrid"
Storyboard.TargetProperty="Opacity"
To="1" />
<DoubleAnimation From="50" To="0" Duration="0:0:0.4" Storyboard.TargetName="NoticeGrid" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
<DoubleAnimation.EasingFunction>
<CubicEase EasingMode="EaseOut"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>


<DoubleAnimation BeginTime="0:0:10" Duration="0:0:0.2" From="1"
Storyboard.TargetName="NoticeGrid"
Storyboard.TargetProperty="Opacity" To="0" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<Trigger Property="IsMouseOver" Value="True">
<Trigger.EnterActions>
<SeekStoryboard BeginStoryboardName="FadeInStoryBoard" Offset="0:0:3" />
<PauseStoryboard BeginStoryboardName="FadeInStoryBoard" />
</Trigger.EnterActions>
<Trigger.ExitActions>
<SeekStoryboard BeginStoryboardName="FadeInStoryBoard" Offset="0:0:3" />
<ResumeStoryboard BeginStoryboardName="FadeInStoryBoard" />
</Trigger.ExitActions>
</Trigger>
<EventTrigger RoutedEvent="Button.Click" SourceName="PART_CloseButton">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Duration="0:0:0" From="1" Storyboard.TargetName="NoticeGrid"
Storyboard.TargetProperty="(Grid.Opacity)"
To="0" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<Trigger SourceName="NoticeGrid" Property="Opacity" Value="0">
<Setter TargetName="NoticeGrid" Property="Visibility" Value="Hidden" />
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource CollapseStoryboard}" />
</Trigger.EnterActions>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</Window.Resources>
<ItemsControl x:Name="NotificationsControl"
FocusVisualStyle="{x:Null}"
ItemTemplate="{StaticResource NotifiactionTemplate}"
ItemsSource="{Binding .}" />
</Window>

+ 353
- 0
BPASmartClient.CustomResource/UserControls/MessageShow/Notifiaction.xaml.cs View File

@@ -0,0 +1,353 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace BPASmartClient.CustomResource.UserControls
{
/// <summary>
/// Notifiaction.xaml 的交互逻辑
/// </summary>
public partial class Notifiaction :Window
{
private const byte MAX_NOTIFICATIONS = 3;
private readonly ObservableCollection<NotifiactionModel> buffer = new ObservableCollection<NotifiactionModel>();
private ObservableCollection<NotifiactionModel> NotifiactionList = new ObservableCollection<NotifiactionModel>();
private const double topOffset = 40;
private const double leftOffset = 350;
public DispatcherTimer uptimer = null;
public Notifiaction()
{
InitializeComponent();
this.NotificationsControl.DataContext = this.NotifiactionList;
this.Top = 130;
this.Left = SystemParameters.WorkArea.Left + SystemParameters.WorkArea.Width - this.Width;
this.Height = SystemParameters.WorkArea.Height - 460;
this.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual;
if (uptimer == null)
uptimer = new DispatcherTimer();
uptimer.Tick += new EventHandler(_timer_Tick);
uptimer.Interval = TimeSpan.FromSeconds(1);
uptimer.Start();
}

#region 显示控制
/// <summary>
/// 线程消失函数
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void _timer_Tick(object sender,EventArgs e)
{
NotifiactionList.ToList().ForEach(par =>
{
if (par.time > 0)
par.time = par.time - 1;
});
List<NotifiactionModel> Notifia = NotifiactionList.ToList().FindAll(x => x.time <= 0);
foreach (var item in Notifia)
{
RemoveNotification(item);
}
}
/// <summary>
/// 清除窗体显示函数
/// </summary>
/// <param name="type"></param>
public void Clear(EnumPromptType type)
{
List<NotifiactionModel> buff = buffer.ToList().FindAll(x => x.NotifiactionType == type);
foreach (var item in buff)
{
buffer.Remove(item);
}
List<NotifiactionModel> Notifia = NotifiactionList.ToList().FindAll(x => x.NotifiactionType == type);
foreach (var item in Notifia)
{
NotifiactionList.Remove(item);
}
}
/// <summary>
/// 增加一个消息弹框
/// </summary>
/// <param name="notification"></param>
public void AddNotifiaction(NotifiactionModel notification)
{
try
{
var window = Window.GetWindow(notification.window);
var intPtr = new WindowInteropHelper(window).Handle;
var screen = System.Windows.Forms.Screen.FromHandle(intPtr);
this.Left = screen.WorkingArea.Left + screen.WorkingArea.Width / 2 - this.Width / 2;// screen.WorkingArea.Left + screen.WorkingArea.Width - this.Width;

WindowInteropHelper helper = new WindowInteropHelper(this);
helper.Owner = new WindowInteropHelper(notification.window).Handle;
this.Topmost = false;
if (notification.window != null)
{
if (notification.window.WindowState == WindowState.Minimized)
{
this.WindowState = WindowState.Minimized;
}
else
{
this.WindowState = WindowState.Normal;
}
}

if (NotifiactionList.Count + 1 > MAX_NOTIFICATIONS)//且数量超过了限制
{
buffer.Add(notification);
}
else//已经显示的没找到,数量没有超过限制
{
NotifiactionList.Add(notification);
}

if (NotifiactionList.Count > 0 && !IsActive)
this.Show();
}
catch (Exception ex)
{

}
}
/// <summary>
/// 将显示窗体移除
/// </summary>
/// <param name="notification"></param>
public void RemoveNotification(NotifiactionModel notification)
{
if (notification == null)
return;

if (NotifiactionList.Contains(notification))
NotifiactionList.Remove(notification);

if (buffer.Count > 0)
{
if (notification.NotifiactionType == EnumPromptType.Warn)
{
NotifiactionModel mode = buffer.ToList().Find(par => par.NotifiactionType == EnumPromptType.Info);
if (mode == null)
{
NotifiactionModel mode1 = buffer.ToList().Find(par => par.NotifiactionType == EnumPromptType.Success);
if (mode1 == null)
{
NotifiactionList.Add(buffer[0]);
buffer.RemoveAt(0);
}
else
{
NotifiactionList.Add(mode1);
buffer.Remove(mode);
}
}
else
{
NotifiactionList.Add(mode);
buffer.Remove(mode);
}
}
else if (notification.NotifiactionType == EnumPromptType.Info)
{
NotifiactionModel mode = buffer.ToList().Find(par => par.NotifiactionType == EnumPromptType.Success);
if (mode == null)
{
NotifiactionModel mode1 = buffer.ToList().Find(par => par.NotifiactionType == EnumPromptType.Warn);
if (mode1 == null)
{
NotifiactionList.Add(buffer[0]);
buffer.RemoveAt(0);
}
else
{
NotifiactionList.Add(mode1);
buffer.Remove(mode);
}
}
else
{
NotifiactionList.Add(mode);
buffer.Remove(mode);
}
}
else if (notification.NotifiactionType == EnumPromptType.Success)
{
NotifiactionModel mode = buffer.ToList().Find(par => par.NotifiactionType == EnumPromptType.Warn);
if (mode == null)
{
NotifiactionModel mode1 = buffer.ToList().Find(par => par.NotifiactionType == EnumPromptType.Info);
if (mode1 == null)
{
NotifiactionList.Add(buffer[0]);
buffer.RemoveAt(0);
}
else
{
NotifiactionList.Add(mode1);
buffer.Remove(mode);
}
}
else
{
NotifiactionList.Add(mode);
buffer.Remove(mode);
}
}
else
{
NotifiactionList.Add(buffer[0]);
buffer.RemoveAt(0);
}
}

//Close window if there's nothing to show
if (NotifiactionList.Count < 1)
Hide();
}

private void NoticeGrid_SizeChanged(object sender,SizeChangedEventArgs e)
{
}
#endregion

#region 窗体事件

/// <summary>
/// 关闭窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PART_CloseButton_MouseLeftButtonDown(object sender,MouseButtonEventArgs e)
{
Image border = (Image)sender;
NotifiactionModel mode = border.DataContext as NotifiactionModel;
RemoveNotification(mode);
}
#endregion
}

public class NotifiactionModel :INotifyPropertyChanged
{
private int _count;
private string _content;
private int _time;
/// <summary>
/// Id不需要赋值
/// </summary>
public string Id { get; set; }
/// <summary>
/// 通知标题
/// </summary>
public string Title { get; set; }
/// <summary>
/// 通知内容
/// </summary>
public string Content
{
get { return _content; }
set
{
_content = value;
if (this.PropertyChanged != null)
{
this.PropertyChanged(this,new PropertyChangedEventArgs("Content"));
}
}
}
/// <summary>
/// 通知内容-显示全体
/// </summary>
public string ContentToolTip { get; set; }
/// <summary>
/// 通知类型
/// </summary>
private EnumPromptType enumPromptType;
public EnumPromptType NotifiactionType
{
get { return enumPromptType; }
set
{
enumPromptType = value;
switch (enumPromptType)
{
case EnumPromptType.Info:
color = Color.FromRgb(35,132,190);
break;
case EnumPromptType.Warn:
color = Color.FromRgb(255,170,22);
break;
case EnumPromptType.Error:
color = Color.FromRgb(245,49,49);
break;
case EnumPromptType.Success:
color = Color.FromRgb(28,194,59);
break;
}
if (this.PropertyChanged != null)
this.PropertyChanged(this,new PropertyChangedEventArgs("enumPromptType"));
}
}
/// <summary>
/// 背景颜色主题
/// </summary>
public Color color { get; set; }
/// <summary>
/// 文本颜色
/// </summary>
public Color textColor { get; set; }
/// <summary>
/// 外部windows
/// </summary>
public System.Windows.Window window { get; set; }
/// <summary>
/// 弹窗显示时长
/// </summary>
public int time
{
get { return _time; }
set
{
_time = value;
if (this.PropertyChanged != null)
this.PropertyChanged(this,new PropertyChangedEventArgs("time"));
}
}
public int count
{
get { return _count; }
set
{
_count = value;
if (this.PropertyChanged != null)
this.PropertyChanged(this,new PropertyChangedEventArgs("count"));
}
}//超过1显示数量
/// <summary>
/// 设置默认之
/// </summary>
public NotifiactionModel()
{
Id=Guid.NewGuid().ToString();
time = 5;
count = 1;
}

public event PropertyChangedEventHandler PropertyChanged;
}
}

+ 1
- 1
BPASmartClient/MainWindow.xaml View File

@@ -113,7 +113,7 @@
<Grid Margin="10">
<Border Style="{DynamicResource borderFromTitle}" Width="600"></Border>
<Button Grid.Row="0" Content="返回" Style="{DynamicResource CommonBtn_返回}" HorizontalAlignment="Left" VerticalAlignment="Top" Click="Button_Click" Cursor="Hand"/>
<Button Grid.Row="0" Content="弹窗" Style="{DynamicResource CommonBtn_返回}" Margin="100,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Click="Button_Click_1" Cursor="Hand"/>
<Button Grid.Row="0" Content="测试消息弹窗" Width="100" Style="{DynamicResource CommonBtn_返回}" Margin="100,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Click="Button_Click_1" Cursor="Hand"/>

<TextBlock x:Name="Title" HorizontalAlignment="Center" FontSize="18" Foreground="#feffff">日志监控界面</TextBlock>
</Grid>


+ 6
- 1
BPASmartClient/MainWindow.xaml.cs View File

@@ -1,5 +1,7 @@
using BPA.Message;
using BPASmartClient.Business;
using BPASmartClient.CustomResource.UserControls;
using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.EventBus;
using BPASmartClient.Helper;
using BPASmartClient.Message;
@@ -94,7 +96,10 @@ namespace BPASmartClient

private void Button_Click_1(object sender,RoutedEventArgs e)
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Info,this,"我是标题","我是消息内容!我是消息内容!我是消息内容!我是消息内容!");
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error,this,"我是标题","我是消息内容!我是消息内容!我是消息内容!我是消息内容!");
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn,this,"我是标题","我是消息内容!我是消息内容!我是消息内容!我是消息内容!");
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success,this,"我是标题","我是消息内容!我是消息内容!我是消息内容!我是消息内容!");
}
}
}

Loading…
Cancel
Save