Skip to content
This repository has been archived by the owner on May 29, 2023. It is now read-only.

Commit

Permalink
日常功能完成
Browse files Browse the repository at this point in the history
1、系统托盘
2、新增标签
3、退出标签
4、窗体页面设计等
  • Loading branch information
li-zheng-hao committed Jan 26, 2019
1 parent 168c903 commit 2e4e2ac
Show file tree
Hide file tree
Showing 37 changed files with 1,740 additions and 32 deletions.
2 changes: 2 additions & 0 deletions StikyNotes.sln.DotSettings
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=StikyNotes_002EAnnotations/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
27 changes: 20 additions & 7 deletions StikyNotes/App.xaml
Expand Up @@ -6,18 +6,31 @@
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
<ResourceDictionary Source="Style/Color.xaml"/>
<ResourceDictionary Source="Style/Font.xaml"/>
<ResourceDictionary Source="Style/Control.xaml"/>



<!--<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />-->
<!--<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />-->
<!--<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />-->
<!--<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />-->
<!--<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />-->


<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Grey.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.LightBlue.xaml" />
<!--<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />-->
<!--<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />-->
<!--<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Grey.xaml" />-->
<!--<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.LightBlue.xaml" />-->
</ResourceDictionary.MergedDictionaries>

<ContextMenu x:Key="NotifyIconMenu" StaysOpen="False">
<MenuItem Header="新建"
Name="MenuOpen" Click="MenuOpen_Click"/>
<MenuItem Header="退出"
Name="MenuExit" Click="MenuExit_Click" />
</ContextMenu>
</ResourceDictionary>
</Application.Resources>
</Application>
56 changes: 56 additions & 0 deletions StikyNotes/App.xaml.cs
Expand Up @@ -5,6 +5,11 @@
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Forms;
using Application = System.Windows.Application;
using ContextMenu = System.Windows.Controls.ContextMenu;
using MessageBox = System.Windows.MessageBox;

namespace StikyNotes
{
Expand All @@ -13,5 +18,56 @@ namespace StikyNotes
/// </summary>
public partial class App : Application
{

protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var systemtray = SystemTray.Instance;
}

protected override void OnDeactivated(EventArgs e)
{
base.OnDeactivated(e);
System.Windows.Controls.ContextMenu menu = this.FindResource("NotifyIconMenu") as ContextMenu;
if (menu.IsOpen == true)
{
menu.IsOpen = false;
}

}



/// <summary>
/// 新建窗体
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MenuOpen_Click(object sender, RoutedEventArgs e)
{


}

/// <summary>
/// 窗体退出
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MenuExit_Click(object sender, RoutedEventArgs e)
{
SystemTray.Instance.DisposeNotifyIcon();
App.Current.Shutdown();
}
/// <summary>
/// 窗体退出事件
/// </summary>
/// <param name="e"></param>
protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
SystemTray.Instance.DisposeNotifyIcon();

}
}
}
65 changes: 65 additions & 0 deletions StikyNotes/Commands/RelayCommand.cs
@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace StikyNotes
{
class RelayCommand:ICommand
{
#region Private Members

/// <summary>
/// The action to run
/// </summary>
private Action mAction;

#endregion

#region Public Events

/// <summary>
/// The event thats fired when the <see cref="CanExecute(object)"/> value has changed
/// </summary>
public event EventHandler CanExecuteChanged = (sender, e) => { };

#endregion

#region Constructor

/// <summary>
/// Default constructor
/// </summary>
public RelayCommand(Action action)
{
mAction = action;
}

#endregion

#region Command Methods

/// <summary>
/// A relay command can always execute
/// </summary>
/// <param name="parameter"></param>
/// <returns></returns>
public bool CanExecute(object parameter)
{
return true;
}

/// <summary>
/// Executes the commands Action
/// </summary>
/// <param name="parameter"></param>
public void Execute(object parameter)
{
mAction();
}

#endregion
}
}
65 changes: 65 additions & 0 deletions StikyNotes/Commands/RelayParamCommand.cs
@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace StikyNotes
{
public class RelayParamCommand:ICommand
{
#region Private Members

/// <summary>
/// The action to run
/// </summary>
private Action<object> mAction;

#endregion

#region Public Events

/// <summary>
/// The event thats fired when the <see cref="CanExecute(object)"/> value has changed
/// </summary>
public event EventHandler CanExecuteChanged = (sender, e) => { };

#endregion

#region Constructor

/// <summary>
/// Default constructor
/// </summary>
public RelayParamCommand(Action<object> action)
{
mAction = action;
}

#endregion

#region Command Methods

/// <summary>
/// A relay command can always execute
/// </summary>
/// <param name="parameter"></param>
/// <returns></returns>
public bool CanExecute(object parameter)
{
return true;
}

/// <summary>
/// Executes the commands Action
/// </summary>
/// <param name="parameter"></param>
public void Execute(object parameter)
{
mAction(parameter);
}

#endregion
}
}
90 changes: 71 additions & 19 deletions StikyNotes/MainWindow.xaml
@@ -1,40 +1,92 @@
<Window x:Class="StikyNotes.MainWindow"
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:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:local="clr-namespace:StikyNotes"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
WindowStyle="None"
Height="450" Width="300" MinWidth="300" MinHeight="200">
AllowsTransparency="True"
Icon="MyLogo.ico"
Height="450" Width="300" MinWidth="300" MinHeight="300" MaxWidth="300"
BorderThickness="24"
WindowStartupLocation="CenterScreen"
>
<Window.Effect>
<DropShadowEffect BlurRadius="12" Color="DarkGray" Direction="90" ShadowDepth="1"/>
</Window.Effect>
<Window.Style>
<Style TargetType="Window">
<Setter Property="WindowChrome.WindowChrome">
<Setter.Value>
<WindowChrome CaptionHeight="30" ResizeBorderThickness="5" />
</Setter.Value>
<Setter.Value>
<WindowChrome ResizeBorderThickness="24" CaptionHeight="0" CornerRadius="24"/>
</Setter.Value>
</Setter>
</Style>
</Window.Style>
<Grid>
<!--菜单栏阴影效果-->
<Grid.Effect>
<DropShadowEffect ShadowDepth="-4" BlurRadius="10" Color="Gray"/>
</Grid.Effect>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<Button Margin="2"
Width="30"
Height="30"
Style="{DynamicResource MahApps.Metro.Styles.MetroCircleButtonStyle}"
ToolTip="MaterialDesignFloatingActionMiniLightButton">
<Grid Name="Menu" Grid.Row="0" Background="{DynamicResource ForgroundBrush}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!--增加按钮-->
<Button Name="AddButton" Grid.Column="0"
HorizontalAlignment="Left"
Style="{StaticResource Button_Menu}" ToolTip="New">
<materialDesign:PackIcon
Kind="Add"
Height="24"
Width="24" />
Kind="LibraryAdd"
Height="18"
Width="18"/>
</Button>
</StackPanel>
<StackPanel Grid.Row="1"></StackPanel>
<!--软件名称-->
<Label Grid.Column="1" Name="SoftWareName" FontFamily="{StaticResource LatoRegular}" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="18" Opacity="0.6" >Stiky Notes</Label>

<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
<!--更多设置按钮-->
<materialDesign:PopupBox Grid.Column="2" HorizontalAlignment="Right"
PlacementMode="BottomAndAlignCentres">
<ListView Margin="5" MinWidth="80" x:Name="Click">
<ListViewItem>
设置
</ListViewItem>
<ListViewItem >
关于
</ListViewItem>
</ListView>
</materialDesign:PopupBox>
<!--删除按钮 -->
<Button Name="DeleteButton" Grid.Column="3"
ToolTip="Exit" HorizontalAlignment="Right"
Style="{StaticResource Button_Menu}"
>
<iconPacks:Modern
Kind="Delete"
Height="18"
Width="18" />
</Button>
</StackPanel>
</Grid>


<!--文字显示区域-->
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Hidden">
<RichTextBox Name="rickTextBox"

Style="{DynamicResource RichText_Content}" >
<RichTextBox.Resources>
<Style TargetType="{x:Type Paragraph}">
<Setter Property="Margin" Value="0"/>
</Style>
</RichTextBox.Resources>
</RichTextBox>
</ScrollViewer>
</Grid>
</Window>
8 changes: 6 additions & 2 deletions StikyNotes/MainWindow.xaml.cs
@@ -1,18 +1,20 @@
using System;
using System.Collections.Generic;
using System.IO;
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.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MahApps.Metro.Controls;

namespace StikyNotes
{
Expand All @@ -24,7 +26,9 @@ public partial class MainWindow
public MainWindow()
{
InitializeComponent();
this.WindowStyle = WindowStyle.None;
this.Topmost = true;
this.DataContext=new MainViewModel(this);
this.ShowInTaskbar = false;
}


Expand Down
Binary file added StikyNotes/MyLogo.ico
Binary file not shown.

0 comments on commit 2e4e2ac

Please sign in to comment.