diff --git a/App.config b/App.config
index 99b3cf6..0f07c61 100644
--- a/App.config
+++ b/App.config
@@ -1,12 +1,12 @@
-
+
-
-
+
+
-
+
@@ -45,4 +45,4 @@
-
\ No newline at end of file
+
diff --git a/App.xaml b/App.xaml
index 91a7b7d..99aaa7f 100644
--- a/App.xaml
+++ b/App.xaml
@@ -4,6 +4,11 @@
Startup="RunCheck"
ShutdownMode="OnExplicitShutdown">
-
+
+
+
+
+
+
diff --git a/App.xaml.cs b/App.xaml.cs
index 6c4e7ac..0763e5e 100644
--- a/App.xaml.cs
+++ b/App.xaml.cs
@@ -11,7 +11,7 @@ namespace DesktopNote
public partial class App : Application
{
public static MainWindow mainwin;
- public static FormatBox fb;
+ public static Win_Format fb;
internal const int MaxWindowCount = 2;//need to set this to 4 while debugging if you use live debug toolbar in vs2015.
[System.Runtime.InteropServices.DllImport("shlwapi.dll")]
@@ -85,5 +85,7 @@ private void RunCheck(object sender1, StartupEventArgs e1)
Current.MainWindow = mainwin;
mainwin.Show();
}
+
+
}
}
diff --git a/DesktopNote.csproj b/DesktopNote.csproj
index 132114b..339e67f 100644
--- a/DesktopNote.csproj
+++ b/DesktopNote.csproj
@@ -9,11 +9,12 @@
Properties
DesktopNote
DesktopNote
- v4.5.1
+ v4.5.2
512
{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
4
true
+
AnyCPU
@@ -37,6 +38,10 @@
Resources\stickynote.ico
+
+
+
+
@@ -60,14 +65,18 @@
MSBuild:Compile
Designer
-
- FormatBox.xaml
+
+ Win_Format.xaml
+
+
+ Win_Options.xaml
+
Win_Search.xaml
-
+
Designer
MSBuild:Compile
@@ -91,6 +100,14 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/FormatBox.xaml b/FormatBox.xaml
deleted file mode 100644
index d0dab48..0000000
--- a/FormatBox.xaml
+++ /dev/null
@@ -1,210 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 32a7f6f..aa2fd19 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -18,7 +18,6 @@ public partial class MainWindow : Window
private object Lock_Save = new object();
private static int CountDown = 0;
string doc_loc = AppDomain.CurrentDomain.BaseDirectory + Properties.Settings.Default.Doc_Location;
- public string assname = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
Point mousepos;
private bool fbopen = false;
@@ -266,15 +265,15 @@ private void RTB_Main_ContextMenuOpening(object sender, ContextMenuEventArgs e)
((Xceed.Wpf.Toolkit.ColorPicker)App.fb.CP_Font.Content).SelectedColor = Properties.Settings.Default.FontColor;
((Xceed.Wpf.Toolkit.ColorPicker)App.fb.CP_Back.Content).SelectedColor = Properties.Settings.Default.BackColor;
}
- App.fb.Popup();
+ App.fb.FadeIn();
}
private void RTB_Main_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
- if (e.ChangedButton == MouseButton.Left && App.fb?.Grid_Main?.Opacity == 1)
+ if (e.ChangedButton == MouseButton.Left && App.fb?.Opacity == 1)
{
fbopen = false;
- App.fb.Unpop();
+ App.fb.FadeOut();
}
}
@@ -419,7 +418,7 @@ private void Win_Main_Loaded(object sender, RoutedEventArgs e)
Top = set.Win_Pos.Y;
}
- App.fb = new FormatBox();
+ App.fb = new Win_Format();
App.fb.Tag = RTB_Main;
App.fb.Owner = this; //causing fb to close when mainwin closes.
lastdockstatus = (DockStatus)set.DockedTo;
@@ -429,7 +428,6 @@ private void Win_Main_Loaded(object sender, RoutedEventArgs e)
RTB_Main.Background = new SolidColorBrush(set.BackColor);
((Xceed.Wpf.Toolkit.ColorPicker)App.fb.CP_Back.Content).SelectedColor = set.BackColor;
Rec_BG.Fill = new SolidColorBrush(set.PaperColor);
- ((Xceed.Wpf.Toolkit.ColorPicker)App.fb.CP_Paper.Content).SelectedColor = set.PaperColor;
//add fonts to menu
foreach (var f in Fonts.SystemFontFamilies)
@@ -447,7 +445,7 @@ private void Win_Main_Loaded(object sender, RoutedEventArgs e)
App.fb.CB_Font.Items.SortDescriptions.Add(new System.ComponentModel.SortDescription("Content", System.ComponentModel.ListSortDirection.Ascending));
App.fb.CB_Font.SelectionChanged += (object s1, SelectionChangedEventArgs e1) =>
{
- if (App.fb.Grid_Main.Opacity == 1 && e1.AddedItems.Count == 1)
+ if (App.fb.Opacity == 1 && e1.AddedItems.Count == 1)
{
var mi = (ComboBoxItem)e1.AddedItems[0];
@@ -494,19 +492,6 @@ private void Win_Main_Loaded(object sender, RoutedEventArgs e)
RTB_Main.IsUndoEnabled = true;
//without the above two lines, Load actions can be undone.
- //check auto dock
- if (set.AutoDock == true) App.fb.CB_AutoDock.IsChecked = true;
-
- //check auto start
- var run = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
- string run_value = (string)run.GetValue(assname);
-
- if (!string.IsNullOrEmpty(run_value))
- {//update the exe location if Run contains assname.
- App.fb.CB_AutoStart.IsChecked = true;
- if (run_value != System.Reflection.Assembly.GetExecutingAssembly().Location)
- run.SetValue(assname, System.Reflection.Assembly.GetExecutingAssembly().Location, Microsoft.Win32.RegistryValueKind.String);
- }
currScrnRect = new GetCurrentMonitor().GetInfo();
diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs
index ac6f895..2440bd0 100644
--- a/Properties/Resources.Designer.cs
+++ b/Properties/Resources.Designer.cs
@@ -1,69 +1,61 @@
//------------------------------------------------------------------------------
//
-// 此代码由工具生成。
-// 运行时版本: 4.0.30319.18408
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
//
-// 对此文件的更改可能会导致不正确的行为,并且如果
-// 重新生成代码,这些更改将丢失。
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
//
//------------------------------------------------------------------------------
-namespace DesktopNote.Properties
-{
-
-
+namespace DesktopNote.Properties {
+ using System;
+
+
///
- /// 一个强类型的资源类,用于查找本地化的字符串等。
+ /// A strongly-typed resource class, for looking up localized strings, etc.
///
- // 此类是由 StronglyTypedResourceBuilder
- // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
- // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
- // (以 /str 作为命令选项),或重新生成 VS 项目。
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources
- {
-
+ internal class Resources {
+
private static global::System.Resources.ResourceManager resourceMan;
-
+
private static global::System.Globalization.CultureInfo resourceCulture;
-
+
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources()
- {
+ internal Resources() {
}
-
+
///
- /// 返回此类使用的、缓存的 ResourceManager 实例。
+ /// Returns the cached ResourceManager instance used by this class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager
- {
- get
- {
- if ((resourceMan == null))
- {
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DesktopNote.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
-
+
///
- /// 为所有资源查找重写当前线程的 CurrentUICulture 属性,
- /// 方法是使用此强类型资源类。
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture
- {
- get
- {
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
return resourceCulture;
}
- set
- {
+ set {
resourceCulture = value;
}
}
diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs
index 7983661..1f892db 100644
--- a/Properties/Settings.Designer.cs
+++ b/Properties/Settings.Designer.cs
@@ -1,10 +1,10 @@
//------------------------------------------------------------------------------
//
-// 此代码由工具生成。
-// 运行时版本:4.0.30319.18408
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
//
-// 对此文件的更改可能会导致不正确的行为,并且如果
-// 重新生成代码,这些更改将会丢失。
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
//
//------------------------------------------------------------------------------
@@ -12,7 +12,7 @@ namespace DesktopNote.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
diff --git a/Resources/StringResources.en.xaml b/Resources/StringResources.en.xaml
index 92c4922..6e99285 100644
--- a/Resources/StringResources.en.xaml
+++ b/Resources/StringResources.en.xaml
@@ -53,4 +53,7 @@ Program will exit now.
Underline (Ctrl + U)
Undo (Ctrl + Z)
DesktopNote is already running.
+ Options
+ Content path
+ Text content path
\ No newline at end of file
diff --git a/Resources/StringResources.zh.xaml b/Resources/StringResources.zh.xaml
index 69f77fd..69dba4f 100644
--- a/Resources/StringResources.zh.xaml
+++ b/Resources/StringResources.zh.xaml
@@ -53,4 +53,7 @@
下划线 (Ctrl + U)
撤销 (Ctrl + Z)
DesktopNote已经在运行。
+ 选项
+ 笔记保存路径
+ 文本保存路径
\ No newline at end of file
diff --git a/RoundedWindow.cs b/RoundedWindow.cs
new file mode 100644
index 0000000..7e3d6c4
--- /dev/null
+++ b/RoundedWindow.cs
@@ -0,0 +1,284 @@
+//using System;
+//using System.Collections.Generic;
+//using System.Linq;
+//using System.Text;
+using System.Threading.Tasks;
+using System;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.ComponentModel;
+
+namespace DesktopNote
+{
+ public class RectConverter : IMultiValueConverter
+ {
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ //parameter is the clipped width to preserve
+ var offset = parameter != null ? double.Parse((string)parameter) : 0d;
+ var width = (double)values[0];
+ var height = (double)values[1];
+ return new Rect(new Point(-offset, -offset), new Point(width + offset - 20, height + offset - 20));//20是两边空隙总和
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ public class RoundedWindow : Window
+ {
+ public enum CloseBehaviors { Close, Hide, FadeOutAndHide, FadeOutAndClose }
+
+ #region Properties
+ ///
+ /// Get or set the background of the rounded rectangle.
+ ///
+ public new Brush Background
+ {
+ get { return (Brush)GetValue(BackgroundProperty); }
+ set { SetValue(BackgroundProperty, value); }
+ }
+ public static readonly new DependencyProperty BackgroundProperty =
+ DependencyProperty.Register("Background", typeof(Brush), typeof(RoundedWindow), new PropertyMetadata(new SolidColorBrush(Color.FromRgb(255, 247, 197))));
+
+
+ public bool ButtonCloseVisible
+ {
+ get { return (bool)GetValue(ButtonCloseVisibleProperty); }
+ set { SetValue(ButtonCloseVisibleProperty, value); }
+ }
+ public static readonly DependencyProperty ButtonCloseVisibleProperty =
+ DependencyProperty.Register("ButtonCloseVisible", typeof(bool), typeof(RoundedWindow), new PropertyMetadata(true));
+
+
+ public bool ButtonMaxVisible
+ {
+ get { return (bool)GetValue(ButtonMaxVisibleProperty); }
+ set { SetValue(ButtonMaxVisibleProperty, value); }
+ }
+ public static readonly DependencyProperty ButtonMaxVisibleProperty =
+ DependencyProperty.Register("ButtonMaxVisible", typeof(bool), typeof(RoundedWindow), new PropertyMetadata(false));
+
+
+ public bool ButtonMinVisible
+ {
+ get { return (bool)GetValue(ButtonMinVisibleProperty); }
+ set { SetValue(ButtonMinVisibleProperty, value); }
+ }
+ public static readonly DependencyProperty ButtonMinVisibleProperty =
+ DependencyProperty.Register("ButtonMinVisible", typeof(bool), typeof(RoundedWindow), new PropertyMetadata(false));
+
+
+ public CloseBehaviors CloseBehavior
+ {
+ get { return (CloseBehaviors)GetValue(CloseBehaviorProperty); }
+ set { SetValue(CloseBehaviorProperty, value); }
+ }
+ public static readonly DependencyProperty CloseBehaviorProperty =
+ DependencyProperty.Register("CloseBehavior", typeof(CloseBehaviors), typeof(RoundedWindow), new PropertyMetadata(CloseBehaviors.FadeOutAndClose));
+
+ ///
+ /// If set to false, keyboard focus will be set to the owner when the window gets focus.
+ ///
+ public new bool Focusable
+ {
+ get { return (bool)GetValue(FocusableProperty); }
+ set { SetValue(FocusableProperty, value); }
+ }
+ public static readonly new DependencyProperty FocusableProperty =
+ DependencyProperty.Register("Focusable", typeof(bool), typeof(RoundedWindow), new PropertyMetadata(true));
+
+ #endregion
+
+
+ static RoundedWindow()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(RoundedWindow), new FrameworkPropertyMetadata(typeof(RoundedWindow)));
+ }
+
+ public static readonly RoutedEvent FadingInEvent = EventManager.RegisterRoutedEvent("FadingIn", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(RoundedWindow));
+ public event RoutedEventHandler FadingIn
+ {
+ add
+ {
+ AddHandler(FadingInEvent, value);
+ }
+ remove
+ {
+ RemoveHandler(FadingInEvent, value);
+ }
+ }
+
+ public static readonly RoutedEvent FadingOutEvent = EventManager.RegisterRoutedEvent("FadingOut", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(RoundedWindow));
+ public event RoutedEventHandler FadingOut
+ {
+ add
+ {
+ AddHandler(FadingOutEvent, value);
+ }
+ remove
+ {
+ RemoveHandler(FadingOutEvent, value);
+ }
+ }
+
+
+
+ public RoundedWindow()
+ {
+ AllowsTransparency = true;
+ WindowStyle = WindowStyle.None;
+ base.Background = null;
+ }
+
+ private Grid Grid_Main;
+
+ public override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+
+ Grid_Main = (Grid)GetTemplateChild("Grid_Main");
+
+ Button minimizeButton = GetTemplateChild("minimizeButton") as Button;
+ if (minimizeButton != null) minimizeButton.Click += MinimizeClick;
+
+ Button restoreButton = GetTemplateChild("restoreButton") as Button;
+ if (restoreButton != null) restoreButton.Click += RestoreClick;
+
+ Button closeButton = GetTemplateChild("closeButton") as Button;
+ if (closeButton != null) closeButton.Click += CloseClick;
+
+ if (!Focusable && Owner != null)
+ {
+ PreviewGotKeyboardFocus += (object sender, KeyboardFocusChangedEventArgs e) =>
+ {
+ e.Handled = true;
+ Owner.Focus();
+ };
+ }
+ }
+
+ #region Click Events
+ protected void MinimizeClick(object sender, RoutedEventArgs e)
+ {
+ WindowState = WindowState.Minimized;
+ }
+
+ protected void RestoreClick(object sender, RoutedEventArgs e)
+ {
+ WindowState = (WindowState == WindowState.Normal) ? WindowState.Maximized : WindowState.Normal;
+ }
+
+ protected void CloseClick(object sender, RoutedEventArgs e)
+ {
+ //make sure the scale animation ends at the top right corner when close is clicked.
+ Grid_Main.RenderTransformOrigin = new Point(1, 0);
+ Close();
+ }
+ #endregion
+
+ protected override void OnClosing(CancelEventArgs e)
+ {
+ base.OnClosing(e);
+ switch (CloseBehavior)
+ {
+ case CloseBehaviors.Close:
+ break;
+ case CloseBehaviors.FadeOutAndClose:
+ e.Cancel = true;
+ FadeOut(true);
+ break;
+ case CloseBehaviors.FadeOutAndHide:
+ e.Cancel = true;
+ FadeOut();
+ break;
+ case CloseBehaviors.Hide:
+ e.Cancel = true;
+ Hide();
+ break;
+ }
+ }
+
+ ///
+ /// Show the window without fading animation.
+ ///
+ public new void Show()
+ {
+ base.Show();
+ //ensure the contents are visible when not using fading animation.
+ Grid_Main.RenderTransform = new ScaleTransform(1, 1);
+ Opacity = 1;
+ }
+
+ ///
+ /// Fade in the window at mouse position. Or the specified Left and Top position.
+ ///
+ public void FadeIn(double left = double.NaN, double top = double.NaN)
+ {
+ if (!IsLoaded) base.Show();//how to call something similar to initializecomponent?
+
+ //make sure the scale animation starts from left top corner.
+ Grid_Main.RenderTransformOrigin = new Point(0, 0);
+
+ //compute mouse position or set to existing values
+ Point newpos;
+ Point realpos;
+ if (left.Equals(double.NaN) || top.Equals(double.NaN))//nan==nan returns false.
+ {
+ newpos = PointToScreen(Mouse.GetPosition(this));
+ realpos = PresentationSource.FromVisual(Application.Current.MainWindow).CompositionTarget.TransformFromDevice.Transform(newpos);
+ }
+ else
+ realpos = new Point(left, top);
+
+ if (Opacity == 0)
+ {
+ Left = realpos.X;
+ Top = realpos.Y;
+ base.Show();
+ RaiseEvent(new RoutedEventArgs(FadingInEvent));
+ }
+ else
+ {
+ //move window to the new cursor location
+ var easefunc = new CubicEase() { EasingMode = EasingMode.EaseInOut };
+ var anim_move_x = new DoubleAnimation(realpos.X, new Duration(new TimeSpan(0, 0, 0, 0, 300)), FillBehavior.Stop) { EasingFunction = easefunc };
+ var anim_move_y = new DoubleAnimation(realpos.Y, new Duration(new TimeSpan(0, 0, 0, 0, 300)), FillBehavior.Stop) { EasingFunction = easefunc };
+ BeginAnimation(LeftProperty, anim_move_x);
+ BeginAnimation(TopProperty, anim_move_y);
+ }
+ }
+ ///
+ /// Fade out the window. This ignores the CloseBehavior setting.
+ ///
+ /// Set to true to close the window after. Otherwise it is only hidden.
+ public async void FadeOut(bool closeafterfade = false)
+ {
+ if (IsLoaded)//without this it will crash at the below line.
+ {
+ RaiseEvent(new RoutedEventArgs(FadingOutEvent));
+ //need to be longer than the fading animation otherwise the window will flash when Show() is called.
+ await Task.Run(() => System.Threading.Thread.Sleep(250));
+ if (closeafterfade)
+ {
+ CloseBehavior = CloseBehaviors.Close;
+ Close();
+ }
+ else Hide();
+ }
+ }
+
+ protected override void OnMouseDown(MouseButtonEventArgs e)
+ {
+ base.OnMouseDown(e);
+ if (e.ChangedButton == MouseButton.Left && e.ButtonState == MouseButtonState.Pressed) DragMove();
+ }
+ }
+}
diff --git a/Themes/Generic.xaml b/Themes/Generic.xaml
new file mode 100644
index 0000000..ee312c6
--- /dev/null
+++ b/Themes/Generic.xaml
@@ -0,0 +1,202 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Win_Format.xaml b/Win_Format.xaml
new file mode 100644
index 0000000..a82ff49
--- /dev/null
+++ b/Win_Format.xaml
@@ -0,0 +1,126 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FormatBox.xaml.cs b/Win_Format.xaml.cs
similarity index 51%
rename from FormatBox.xaml.cs
rename to Win_Format.xaml.cs
index 4429d8c..2918609 100644
--- a/FormatBox.xaml.cs
+++ b/Win_Format.xaml.cs
@@ -18,120 +18,58 @@
namespace DesktopNote
{
- public partial class FormatBox : Window
+ public partial class Win_Format : RoundedWindow
{
- RichTextBox RTB_Main;
+ RichTextBox RTB_Main = App.mainwin.RTB_Main;
- //private const int GWL_EXSTYLE = -20;
- //private const int WS_EX_NOACTIVATE = 0x08000000;
- //private const int WS_EX_TOOLWINDOW = 0x00000080;
- //[System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
- //public static extern IntPtr SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
- //[System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
- //public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
-
- //private void FB1_SourceInitialized(object sender, EventArgs e)
- //{
- // //not working
- // var interopHelper = new System.Windows.Interop.WindowInteropHelper(this);
- // int exStyle = GetWindowLong(interopHelper.Handle, GWL_EXSTYLE);
- // SetWindowLong(interopHelper.Handle, GWL_EXSTYLE, exStyle | WS_EX_NOACTIVATE);
- //}
-
- public FormatBox()
+ public Win_Format()
{
InitializeComponent();
}
- private void FB1_PreviewGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
- {
- System.Diagnostics.Debug.Print("focused" + " @ " + DateTime.Now.ToString());
- e.Handled = true;
- Owner.Focus();
- }
-
- public void Popup()
+ #region Menu Events
+ private void ColorChange(object sender, RoutedPropertyChangedEventArgs e)
{
- //refresh reference for when reset setting is executed
- RTB_Main = App.mainwin.RTB_Main;
- //compute mouse position
- var newpos = RTB_Main.PointToScreen(Mouse.GetPosition(RTB_Main));
- var realpos = PresentationSource.FromVisual(Application.Current.MainWindow).CompositionTarget.TransformFromDevice.Transform(newpos);
-
- if (Grid_Main.Opacity == 0)
- {
- Left = realpos.X;
- Top = realpos.Y;
- //Rec_BG.Fill = new SolidColorBrush(Colors.WhiteSmoke); //new SolidColorBrush(Properties.Settings.Default.PaperColor);
- //Topmost = false;
- //Topmost = true;
- Show();
- //why show() would make the window flash once???
- //to avoid that, SB_Out sets scale transform to 0 at the end.
- //turns out the above method is not working well.
- ((Storyboard)FindResource("SB_In")).Begin(App.fb.Grid_Main);
- }
- else
+ if (e.NewValue.HasValue && ((Xceed.Wpf.Toolkit.ColorPicker)sender).IsOpen)
{
- //move window to the new cursor location
- var easefunc = new CubicEase() { EasingMode = EasingMode.EaseInOut };
- var anim_move_x = new DoubleAnimation(realpos.X, new Duration(new TimeSpan(0, 0, 0, 0, 300)), FillBehavior.Stop) { EasingFunction = easefunc };
- var anim_move_y = new DoubleAnimation(realpos.Y, new Duration(new TimeSpan(0, 0, 0, 0, 300)), FillBehavior.Stop) { EasingFunction = easefunc };
- //Topmost = false;
- //Topmost = true;
- BeginAnimation(LeftProperty, anim_move_x);
- BeginAnimation(TopProperty, anim_move_y);
+ var cp = (ContentPresenter)VisualTreeHelper.GetParent((DependencyObject)sender);
+ if (cp != null)
+ {
+ switch (cp.Name)
+ {
+ case "CP_Font":
+ if (!RTB_Main.Selection.IsEmpty) //only change selected
+ RTB_Main.Selection.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(e.NewValue.Value));
+ else //change default
+ {
+ RTB_Main.Foreground = new SolidColorBrush(e.NewValue.Value);
+ Properties.Settings.Default.FontColor = e.NewValue.Value;
+ }
+ break;
+ case "CP_Back":
+ if (!RTB_Main.Selection.IsEmpty) //only change selected
+ RTB_Main.Selection.ApplyPropertyValue(TextElement.BackgroundProperty, new SolidColorBrush(e.NewValue.Value)); //the caret color will be changed as well
+ else //change default
+ {
+ RTB_Main.Background = new SolidColorBrush(e.NewValue.Value);
+ Properties.Settings.Default.BackColor = e.NewValue.Value;
+ }
+ break;
+ //moved to Win_Options.
+ //case "CP_Paper":
+ // App.mainwin.Rec_BG.Fill = new SolidColorBrush(e.NewValue.Value);
+ // Properties.Settings.Default.PaperColor = e.NewValue.Value;
+ // break;
+ }
+ }
}
}
-
- public async void Unpop()
- {
- var sb = ((Storyboard)FindResource("SB_Out"));
- //Topmost = false;
- //Topmost = true;
- sb.Begin();
- await Task.Run(() => System.Threading.Thread.Sleep(200));
- Hide();
- }
-
- #region Menu Events
- private void Button_Help_Click(object sender, RoutedEventArgs e)
- {
- if (MessageBox.Show((string)Application.Current.Resources["msgbox_help"], "", MessageBoxButton.OKCancel, MessageBoxImage.Information) == MessageBoxResult.OK)
- System.Diagnostics.Process.Start("iexplore.exe", "https://github.com/changbowen/DesktopNote");
- }
private void Button_Exit_Click(object sender, RoutedEventArgs e)
{
App.mainwin.Quit(true);
}
- internal void Button_ResetFormats_Click(object sender, RoutedEventArgs e)
- {
- //clear custom formats
- var tr = new TextRange(RTB_Main.Document.ContentStart, RTB_Main.Document.ContentEnd);
- tr.ClearAllProperties();
-
- //reset global font size
- RTB_Main.FontSize = App.mainwin.FontSize;
-
- //resetting paper color should be processed with Reset Settings
- //var cp = (Color)ColorConverter.ConvertFromString((string)Properties.Settings.Default.Properties["PaperColor"].DefaultValue);
- //Properties.Settings.Default.PaperColor = cp;
- //Rec_BG.Fill = new SolidColorBrush(cp);
- }
-
- private void Button_ResetSet_Click(object sender, RoutedEventArgs e)
- {
- Properties.Settings.Default.Reset();
- Properties.Settings.Default.Save();
-
- App.mainwin.Close();
- App.mainwin = new MainWindow();
- Application.Current.MainWindow = App.mainwin;
- App.mainwin.Show();
- }
-
internal void ToggleStrike(object sender, RoutedEventArgs e)
{
//strike-through
@@ -219,67 +157,7 @@ internal void DecreaseSize(object sender, RoutedEventArgs e)
EditingCommands.DecreaseFontSize.Execute(null, RTB_Main);
}
}
-
- private void ColorChange(object sender, RoutedPropertyChangedEventArgs e)
- {
- if (e.NewValue.HasValue && ((Xceed.Wpf.Toolkit.ColorPicker)sender).IsOpen)
- {
- var cp = (ContentPresenter)VisualTreeHelper.GetParent((DependencyObject)sender);
- if (cp != null)
- {
- switch (cp.Name)
- {
- case "CP_Font":
- if (!RTB_Main.Selection.IsEmpty) //only change selected
- RTB_Main.Selection.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(e.NewValue.Value));
- else //change default
- {
- RTB_Main.Foreground = new SolidColorBrush(e.NewValue.Value);
- Properties.Settings.Default.FontColor = e.NewValue.Value;
- }
- break;
- case "CP_Back":
- if (!RTB_Main.Selection.IsEmpty) //only change selected
- RTB_Main.Selection.ApplyPropertyValue(TextElement.BackgroundProperty, new SolidColorBrush(e.NewValue.Value)); //the caret color will be changed as well
- else //change default
- {
- RTB_Main.Background = new SolidColorBrush(e.NewValue.Value);
- Properties.Settings.Default.BackColor = e.NewValue.Value;
- }
- break;
- case "CP_Paper":
- App.mainwin.Rec_BG.Fill = new SolidColorBrush(e.NewValue.Value);
- Properties.Settings.Default.PaperColor = e.NewValue.Value;
- break;
- }
- }
- }
- }
-
- private void CB_AutoStart_Click(object sender, RoutedEventArgs e)
- {
- var run = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
- if (CB_AutoStart.IsChecked == true)
- run.SetValue(App.mainwin.assname, System.Reflection.Assembly.GetExecutingAssembly().Location, Microsoft.Win32.RegistryValueKind.String);
- else
- run.DeleteValue(App.mainwin.assname, false);
- }
-
- private void CB_AutoDock_Click(object sender, RoutedEventArgs e)
- {
- if (CB_AutoDock.IsChecked == true)
- {
- Properties.Settings.Default.AutoDock = true;
- App.mainwin.DockToSide(true);
- }
- else
- {
- Properties.Settings.Default.AutoDock = false;
- App.mainwin.Topmost = false;
- }
- Properties.Settings.Default.Save();
- }
-
+
internal void PasteAsText(object sender, RoutedEventArgs e)
{
var txt = Clipboard.GetText();
@@ -290,9 +168,21 @@ internal void PasteAsText(object sender, RoutedEventArgs e)
internal void Find(object sender, RoutedEventArgs e)
{
- new Win_Search().Show();
+ App.fb.FadeOut();
+ var win = new Win_Search();
+ win.Owner = App.mainwin;
+ win.FadeIn(
+ App.mainwin.Left + (App.mainwin.Width - win.Width) / 2,
+ App.mainwin.Top + (App.mainwin.Height - win.Height) / 2
+ );
}
#endregion
+
+ private void Button_Options_Click(object sender, RoutedEventArgs e)
+ {
+ App.fb.FadeOut();
+ new Win_Options().FadeIn();
+ }
}
}
diff --git a/Win_Options.xaml b/Win_Options.xaml
new file mode 100644
index 0000000..f21c75f
--- /dev/null
+++ b/Win_Options.xaml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Win_Options.xaml.cs b/Win_Options.xaml.cs
new file mode 100644
index 0000000..60ce9ee
--- /dev/null
+++ b/Win_Options.xaml.cs
@@ -0,0 +1,115 @@
+//using System;
+//using System.Collections.Generic;
+//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.Media;
+//using System.Windows.Media.Imaging;
+//using System.Windows.Shapes;
+
+namespace DesktopNote
+{
+ public partial class Win_Options : RoundedWindow
+ {
+ RichTextBox RTB_Main = App.mainwin.RTB_Main;
+ private string assname = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
+
+ public Win_Options()
+ {
+ InitializeComponent();
+ }
+
+ private void CB_AutoStart_Click(object sender, RoutedEventArgs e)
+ {
+ var run = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
+ if (CB_AutoStart.IsChecked == true)
+ run.SetValue(assname, System.Reflection.Assembly.GetExecutingAssembly().Location, Microsoft.Win32.RegistryValueKind.String);
+ else
+ run.DeleteValue(assname, false);
+ }
+
+ private void CB_AutoDock_Click(object sender, RoutedEventArgs e)
+ {
+ if (CB_AutoDock.IsChecked == true)
+ {
+ Properties.Settings.Default.AutoDock = true;
+ App.mainwin.DockToSide(true);
+ }
+ else
+ {
+ Properties.Settings.Default.AutoDock = false;
+ App.mainwin.Topmost = false;
+ }
+ Properties.Settings.Default.Save();
+ }
+
+ internal void Button_ResetFormats_Click(object sender, RoutedEventArgs e)
+ {
+ //clear custom formats
+ var tr = new TextRange(RTB_Main.Document.ContentStart, RTB_Main.Document.ContentEnd);
+ tr.ClearAllProperties();
+
+ //reset global font size
+ RTB_Main.FontSize = App.mainwin.FontSize;
+
+ //resetting paper color should be processed with Reset Settings
+ //var cp = (Color)ColorConverter.ConvertFromString((string)Properties.Settings.Default.Properties["PaperColor"].DefaultValue);
+ //Properties.Settings.Default.PaperColor = cp;
+ //Rec_BG.Fill = new SolidColorBrush(cp);
+ }
+
+ private void Button_ResetSet_Click(object sender, RoutedEventArgs e)
+ {
+ Properties.Settings.Default.Reset();
+ Properties.Settings.Default.Save();
+
+ App.mainwin.Close();
+ App.mainwin = new MainWindow();
+ Application.Current.MainWindow = App.mainwin;
+ App.mainwin.Show();
+ }
+
+ private void Button_Help_Click(object sender, RoutedEventArgs e)
+ {
+ if (MessageBox.Show((string)Application.Current.Resources["msgbox_help"], "", MessageBoxButton.OKCancel, MessageBoxImage.Information) == MessageBoxResult.OK)
+ System.Diagnostics.Process.Start("iexplore.exe", "https://github.com/changbowen/DesktopNote");
+ }
+
+ private void ColorChange(object sender, RoutedPropertyChangedEventArgs e)
+ {
+ if (e.NewValue.HasValue && ((Xceed.Wpf.Toolkit.ColorPicker)sender).IsOpen)
+ {
+ App.mainwin.Rec_BG.Fill = new SolidColorBrush(e.NewValue.Value);
+ Properties.Settings.Default.PaperColor = e.NewValue.Value;
+ }
+ }
+
+ private void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+ var set = Properties.Settings.Default;
+
+ //check auto dock
+ if (set.AutoDock == true) CB_AutoDock.IsChecked = true;
+
+ //check auto start
+ var run = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
+ string run_value = (string)run.GetValue(assname);
+
+ if (!string.IsNullOrEmpty(run_value))
+ {//update the exe location if Run contains assname.
+ CB_AutoStart.IsChecked = true;
+ if (run_value != System.Reflection.Assembly.GetExecutingAssembly().Location)
+ run.SetValue(assname, System.Reflection.Assembly.GetExecutingAssembly().Location, Microsoft.Win32.RegistryValueKind.String);
+ }
+
+ //set paper color
+ CP_Paper.SelectedColor = set.PaperColor;
+
+ }
+ }
+}
diff --git a/Win_Search.xaml b/Win_Search.xaml
index 694f4bb..e131a8a 100644
--- a/Win_Search.xaml
+++ b/Win_Search.xaml
@@ -1,13 +1,21 @@
-
-
-
-
-
-
-
+ xmlns:l="clr-namespace:DesktopNote"
+ Height="110" Width="250" FontSize="10" ResizeMode="NoResize" SizeToContent="Height"
+ Loaded="Window_Loaded" ShowInTaskbar="False" Topmost="True" Background="#CCF0FFFF" ButtonCloseVisible="False">
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/Win_Search.xaml.cs b/Win_Search.xaml.cs
index 9762f71..f092d52 100644
--- a/Win_Search.xaml.cs
+++ b/Win_Search.xaml.cs
@@ -9,7 +9,7 @@ namespace DesktopNote
///
/// Interaction logic for Win_Search.xaml
///
- public partial class Win_Search : Window
+ public partial class Win_Search : RoundedWindow
{
private bool textchanged = true;
@@ -27,7 +27,8 @@ private void MarkTextInRange(RichTextBox richTextBox, string searchText, bool se
else
searchRange = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);
- TextPointer start = searchRange.Start.GetNextContextPosition(LogicalDirection.Forward);
+ TextPointer start = searchRange.Start;
+ //TextPointer start = searchRange.Start.GetNextContextPosition(LogicalDirection.Forward); why?
while (start != null)
{
var txt = start.GetTextInRun(LogicalDirection.Forward);
@@ -57,17 +58,9 @@ private void MarkTextInRange(RichTextBox richTextBox, string searchText, bool se
private void Window_Loaded(object sender, RoutedEventArgs e)
{
- var mainwin = (MainWindow)Application.Current.MainWindow;
- Left = mainwin.Left + (mainwin.Width - Width) / 2;
- Top = mainwin.Top + (mainwin.Height - Height) / 2;
TB_Search.Focus();
}
- private void Window_MouseDown(object sender, MouseButtonEventArgs e)
- {
- if (e.ChangedButton == MouseButton.Left) DragMove();
- }
-
private void TB_Search_TextChanged(object sender, TextChangedEventArgs e)
{
textchanged = true;
@@ -79,15 +72,14 @@ private void Btn_Search_Click(object sender, RoutedEventArgs e)
Close();
else
{
- var mainwin = (MainWindow)Application.Current.MainWindow;
if (textchanged)
{
textchanged = false;
- MarkTextInRange(mainwin.RTB_Main, TB_Search.Text, false);
+ MarkTextInRange(App.mainwin.RTB_Main, TB_Search.Text, false);
}
else
{
- MarkTextInRange(mainwin.RTB_Main, TB_Search.Text, true);
+ MarkTextInRange(App.mainwin.RTB_Main, TB_Search.Text, true);
}
Activate();
}