Skip to content

Commit

Permalink
add undock delay option;
Browse files Browse the repository at this point in the history
change dock and undock mechanism;
defaults to 64bit build;
refactor code;
some changes made by vs;
bump version;
  • Loading branch information
changbowen committed Jan 31, 2023
1 parent 0c13e9f commit 543702e
Show file tree
Hide file tree
Showing 16 changed files with 251 additions and 218 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ bld/
[Bb]in/*
[Bb]in/[Rr]elease/*
[Oo]bj/
!bin/Release/DesktopNote.exe

# Visual Studio 2015 cache/options directory
.vs/
Expand Down
9 changes: 4 additions & 5 deletions App.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
</startup>
<userSettings>
<DesktopNote.Properties.Settings>
<setting name="UpgradeFlag" serializeAs="String">
<value>True</value>
</setting>
<setting name="NoteList" serializeAs="Xml">
<value>
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
</value>
</setting>
<setting name="UpgradeFlag" serializeAs="String">
<value>True</value>
</setting>
</DesktopNote.Properties.Settings>
</userSettings>
</configuration>
19 changes: 10 additions & 9 deletions App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
using System.Web.Script.Serialization;
using System.Net;
using System.Diagnostics;
using System.Reflection;

namespace DesktopNote
{
public partial class App : Application
{
public static readonly string AppRootDir = AppDomain.CurrentDomain.BaseDirectory;
public static Assembly Assembly => Assembly.GetExecutingAssembly();
public static List<MainWindow> MainWindows = new List<MainWindow>();
public static ResourceDictionary Res;
public static Win_Format FormatWindow;
Expand All @@ -38,15 +40,15 @@ private void RunCheck(object sender1, StartupEventArgs e1)
}

AppDomain.CurrentDomain.AssemblyResolve += (object sender, ResolveEventArgs e) => {
var desiredAssembly = new System.Reflection.AssemblyName(e.Name).Name;
var desiredAssembly = new AssemblyName(e.Name).Name;
switch (desiredAssembly) {
case "Xceed.Wpf.Toolkit":
case "Hardcodet.Wpf.TaskbarNotification":
var ressourceName = "DesktopNote.Resources." + desiredAssembly + ".dll";
using (var stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(ressourceName)) {
using (var stream = Assembly.GetManifestResourceStream(ressourceName)) {
byte[] assemblyData = new byte[stream.Length];
stream.Read(assemblyData, 0, assemblyData.Length);
return System.Reflection.Assembly.Load(assemblyData);
return Assembly.Load(assemblyData);
}
default:
return null;
Expand All @@ -57,9 +59,8 @@ private void RunCheck(object sender1, StartupEventArgs e1)
var lang = System.Threading.Thread.CurrentThread.CurrentCulture.Name.Substring(0, 2);
//check if stringresources.lang exist
bool langadded = false;
var assembly = System.Reflection.Assembly.GetExecutingAssembly();
var resourceName = assembly.GetName().Name + ".g";
var resourceManager = new System.Resources.ResourceManager(resourceName, assembly);
var resourceName = Assembly.GetName().Name + ".g";
var resourceManager = new System.Resources.ResourceManager(resourceName, Assembly);
try {
var resourceSet = resourceManager.GetResourceSet(System.Threading.Thread.CurrentThread.CurrentCulture, true, true);
foreach (System.Collections.DictionaryEntry resource in resourceSet) {
Expand All @@ -82,7 +83,7 @@ private void RunCheck(object sender1, StartupEventArgs e1)

// check for updates
Task.Run(() => {
var localVer = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
var localVer = Assembly.GetName().Version;
var req = WebRequest.CreateHttp($@"https://api.github.com/repos/changbowen/{nameof(DesktopNote)}/releases/latest");
req.ContentType = @"application/json; charset=utf-8";
req.UserAgent = nameof(DesktopNote); // needed otherwise 403
Expand All @@ -93,7 +94,7 @@ private void RunCheck(object sender1, StartupEventArgs e1)
var dict = new JavaScriptSerializer().Deserialize<Dictionary<string, object>>(reader.ReadToEnd());
if (!dict.TryGetValue("tag_name", out var tagName)) return;
var remoteVer = Version.Parse(((string)tagName).TrimStart('v'));
if (localVer < remoteVer && MessageBox.Show(string.Format((string)App.Res["msgbox_new_version_avail"],
if (localVer < remoteVer && MessageBox.Show(string.Format((string)Res["msgbox_new_version_avail"],
localVer, remoteVer), string.Empty, MessageBoxButton.OKCancel, MessageBoxImage.Information) == MessageBoxResult.OK) {
Process.Start(@"explorer", $@"https://github.com/changbowen/{nameof(DesktopNote)}/releases");
}
Expand All @@ -120,7 +121,7 @@ public async static void Quit()
{
//update notelist
Setting.NoteList.Clear();
Setting.NoteList.AddRange(App.MainWindows.Select(w => w.CurrentSetting.Doc_Location).ToArray());
Setting.NoteList.AddRange(MainWindows.Select(w => w.CurrentSetting.Doc_Location).ToArray());
Setting.Save();

foreach (var win in MainWindows.ToArray()) {
Expand Down
1 change: 1 addition & 0 deletions DesktopNote.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down
5 changes: 4 additions & 1 deletion Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@

namespace DesktopNote
{
internal static class Helpers
public static class Helpers
{
public enum DockStatus { None, Docking, Left, Right, Top, Bottom }
public static bool Docked(this DockStatus status) => (int)status > 1;

internal static string OpenFileDialog(Window owner, bool save, string path = null, string filter = null)
{
if (owner == null || PresentationSource.FromVisual(owner) == null)
Expand Down
Loading

0 comments on commit 543702e

Please sign in to comment.