Skip to content

Commit

Permalink
Improve view version
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Sep 5, 2022
1 parent 5fcc063 commit cc13728
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 deletions.
8 changes: 5 additions & 3 deletions AddInManager/App.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Autodesk.Revit.UI;
using System.IO;
using Autodesk.Revit.UI;
using RevitAddinManager.Command;
using RevitAddinManager.View;
using System.Reflection;
using System.Windows;
using RevitAddinManager.Model;
using RevitAddinManager.View.Control;
using RevitAddinManager.ViewModel;
Expand All @@ -17,12 +19,12 @@ public class App : IExternalApplication
public static int ThemId { get; set; } = -1;
public static DockablePaneId PaneId => new DockablePaneId(new Guid("942D8578-7F25-4DC3-8BD8-585C1DBD3614"));
public static string PaneName => "Debug/Trace Output";

public Result OnStartup(UIControlledApplication application)
{
CreateRibbonPanel(application);
application.ControlledApplication.DocumentClosed += DocumentClosed;
//EventWatcher eventWatcher = new EventWatcher(application);

DefaultSetting.Version += VersionChecker.CurrentVersion;
DockPanelProvider = new FrmDockablePanel() { DataContext = new DockableViewModel(application) };
if (!DockablePane.PaneIsRegistered(PaneId))
{
Expand Down
4 changes: 4 additions & 0 deletions AddInManager/Model/DefaultSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ namespace RevitAddinManager.Model;
/// </summary>
public static class DefaultSetting
{
public static string Application = "RevitAddinManager";
public static string Version = " ";
public static string NewVersion = "";
public static bool IsNewVersion = false;
public static string AppName = "Revit Add-in Manager";
public static string FileName = "ExternalTool";
public static string FormatExAddin = ".addin";
Expand Down
48 changes: 48 additions & 0 deletions AddInManager/Model/VersionChecker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Microsoft.Win32;

namespace RevitAddinManager.Model;

public static class VersionChecker
{
/// <summary>
/// Return Current Version Installed In Computer
/// </summary>
public static string CurrentVersion
{
get
{
string displayName;
string registryKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(registryKey);
if (key != null)
{
foreach (RegistryKey subkey in key.GetSubKeyNames().Select(keyName => key.OpenSubKey(keyName)))
{
displayName = subkey.GetValue("DisplayName") as string;
if (displayName != null && displayName.Contains(DefaultSetting.Application))
{
return subkey.GetValue("DisplayVersion") as string;
}
}
key.Close();
}

registryKey = @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall";
key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(registryKey);
if (key != null)
{
foreach (RegistryKey subkey in key.GetSubKeyNames().Select(keyName => key.OpenSubKey(keyName)))
{
displayName = subkey.GetValue("DisplayName") as string;
if (displayName != null && displayName.Contains(DefaultSetting.Application))
{
return subkey.GetValue("DisplayVersion") as string;
}
}
key.Close();
}
return string.Empty;
}

}
}
1 change: 1 addition & 0 deletions AddInManager/View/FrmAddInManager.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public FrmAddInManager(AddInManagerViewModel vm)
viewModel = vm;
App.FrmAddInManager = this;
ThemManager.ChangeThem(true);
Title += DefaultSetting.Version;
}

private void TbxDescription_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
Expand Down

0 comments on commit cc13728

Please sign in to comment.