diff --git a/CHANGELOG.md b/CHANGELOG.md index aeece42..9ebf99d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [0.75] - 2020-02-18 + +### Added +- when a firewall rule gets changed a new notification pupup gets displayed +- notification window has now tabs +-- added tab with rule changed notifications +- notification window can now be opened/closed by single clicking on the tray icon, without discarding contents + +### Fixed +- settings backups names dont longer contian ':' ## [0.74] - 2019-12-21 diff --git a/PrivateSetup/PrivateSetup.csproj b/PrivateSetup/PrivateSetup.csproj index e3f1f8f..cdab7f6 100644 --- a/PrivateSetup/PrivateSetup.csproj +++ b/PrivateSetup/PrivateSetup.csproj @@ -33,6 +33,7 @@ TRACE prompt 4 + false icon.ico diff --git a/PrivateSetup/Resources/icon.ico b/PrivateSetup/Resources/icon.ico new file mode 100644 index 0000000..9ffbc2a Binary files /dev/null and b/PrivateSetup/Resources/icon.ico differ diff --git a/PrivateSetup/SetupWorker.cs b/PrivateSetup/SetupWorker.cs index 7b673fd..4444978 100644 --- a/PrivateSetup/SetupWorker.cs +++ b/PrivateSetup/SetupWorker.cs @@ -147,12 +147,14 @@ private List Extract(bool Install = false) progData = @"C:\ProgramData"; IniPath = progData + "\\" + SetupData.AppKey; - if (!Directory.Exists(IniPath)) - Directory.CreateDirectory(IniPath); - MiscFunc.SetAnyDirSec(IniPath); // ensure access for non admins } else // Note: when the ini file ins inside the application directory the app starts in portable mode - IniPath = Data.InstallationPath; + IniPath = Data.InstallationPath + @"\Data"; + + if (!Directory.Exists(IniPath)) + Directory.CreateDirectory(IniPath); + MiscFunc.SetAnyDirSec(IniPath); // ensure access for non admins + IniPath += @"\" + SetupData.AppKey + ".ini"; App.IniWriteValue(IniPath, "Startup", "Usage", Data.Use.ToString()); diff --git a/PrivateWin10/App.xaml.cs b/PrivateWin10/App.xaml.cs index f071e62..f4a5c54 100644 --- a/PrivateWin10/App.xaml.cs +++ b/PrivateWin10/App.xaml.cs @@ -262,11 +262,12 @@ public static void Main(string[] args) InitLicense(); + MainWnd = new MainWindow(); + TrayIcon = new TrayIcon(); TrayIcon.Action += TrayAction; TrayIcon.Visible = (GetConfigInt("Startup", "Tray", 0) != 0) || App.TestArg("-autorun"); - MainWnd = new MainWindow(); if (!App.TestArg("-autorun") || !TrayIcon.Visible) MainWnd.Show(); @@ -607,6 +608,14 @@ static void TrayAction(object sender, TrayIcon.TrayEventArgs args) MainWnd.Show(); break; } + case TrayIcon.Actions.ToggleNotify: + { + if (MainWnd.notificationWnd.IsVisible) + MainWnd.notificationWnd.HideWnd(); + else if (!MainWnd.notificationWnd.IsEmpty()) + MainWnd.notificationWnd.ShowWnd(); + break; + } case TrayIcon.Actions.CloseApplication: { if (Priv10Service.IsInstalled() && AdminFunc.IsAdministrator()) diff --git a/PrivateWin10/Controls/ConnectionNotify.xaml b/PrivateWin10/Controls/ConnectionNotify.xaml new file mode 100644 index 0000000..de6cd0c --- /dev/null +++ b/PrivateWin10/Controls/ConnectionNotify.xaml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PrivateWin10/Controls/SplitButton.xaml.cs b/PrivateWin10/Controls/SplitButton.xaml.cs new file mode 100644 index 0000000..d8f0bf1 --- /dev/null +++ b/PrivateWin10/Controls/SplitButton.xaml.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace PrivateWin10.Controls +{ + public partial class SplitButton : UserControl + { + private Button button; + + private ObservableCollection menuItemsSource = new ObservableCollection(); + + public Collection MenuItemsSource { get { return this.menuItemsSource; } } + + public SplitButton() + { + InitializeComponent(); + } + + public static readonly DependencyProperty CommandProperty = DependencyProperty.Register( + "Command", + typeof(ICommand), + typeof(SplitButton), + new UIPropertyMetadata(null, OnCommandChanged)); + + public ICommand Command + { + get + { + return (ICommand)GetValue(CommandProperty); + } + + set + { + SetValue(CommandProperty, value); + } + } + + private static void OnCommandChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs eventArgs) + { + if (eventArgs.NewValue != eventArgs.OldValue) + { + var splitButton = dependencyObject as SplitButton; + + if (splitButton.button != null) + { + splitButton.button.Command = eventArgs.NewValue as ICommand; + } + } + } + + private void OnArrowClick(object sender, RoutedEventArgs e) + { + var buttonMenu = ContextMenuService.GetContextMenu(this.button); + + if (this.menuItemsSource.Count > 0 && buttonMenu != null) + { + buttonMenu.IsOpen = !buttonMenu.IsOpen; + buttonMenu.PlacementTarget = this.button; + buttonMenu.Placement = PlacementMode.Bottom; + } + } + + private void SplitButton_OnLoaded(object sender, RoutedEventArgs e) + { + this.button = this.Template.FindName("mainButton", this) as Button; + if (this.Command != null) + { + this.button.Command = this.Command; + } + } + } +} diff --git a/PrivateWin10/Controls/TweakNotify.xaml b/PrivateWin10/Controls/TweakNotify.xaml new file mode 100644 index 0000000..61b82bd --- /dev/null +++ b/PrivateWin10/Controls/TweakNotify.xaml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PrivateWin10/Controls/TweakNotify.xaml.cs b/PrivateWin10/Controls/TweakNotify.xaml.cs new file mode 100644 index 0000000..b7c98da --- /dev/null +++ b/PrivateWin10/Controls/TweakNotify.xaml.cs @@ -0,0 +1,46 @@ +using PrivateWin10.Windows; +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.Navigation; +using System.Windows.Shapes; + +namespace PrivateWin10.Controls +{ + /// + /// Interaction logic for TweakNotify.xaml + /// + public partial class TweakNotify : UserControl, INotificationTab + { + public event EventHandler Emptied; + + public TweakNotify() + { + InitializeComponent(); + } + + public bool IsEmpty() + { + return true; + } + + public bool Add(TweakManager.TweakEventArgs args) + { + return true; + } + + public void Closing() + { + + } + } +} diff --git a/PrivateWin10/Core/NetworkMonitor.cs b/PrivateWin10/Core/NetworkMonitor.cs index c278b4d..94d7753 100644 --- a/PrivateWin10/Core/NetworkMonitor.cs +++ b/PrivateWin10/Core/NetworkMonitor.cs @@ -298,6 +298,10 @@ public void UpdateSockets() App.engine.DnsInspector.GetHostName(Socket.ProcessId, Socket.RemoteAddress, Socket, NetworkSocket.HostSetter); var moduleInfo = SocketRow.Module; + + /*if (moduleInfo != null) + Console.WriteLine("Module {0} ({1})", moduleInfo.ModuleName, moduleInfo.ModulePath);*/ + if (moduleInfo == null || moduleInfo.ModulePath.Equals("System", StringComparison.OrdinalIgnoreCase)) Socket.ProgID = ProgramID.NewID(ProgramID.Types.System); else diff --git a/PrivateWin10/Core/Priv10Engine.cs b/PrivateWin10/Core/Priv10Engine.cs index 46e5c20..04a738b 100644 --- a/PrivateWin10/Core/Priv10Engine.cs +++ b/PrivateWin10/Core/Priv10Engine.cs @@ -49,7 +49,7 @@ public class FwEventArgs : EventArgs } [Serializable()] - public class ChangeArgs : EventArgs + public class UpdateArgs : EventArgs { public Guid guid; public enum Types @@ -60,6 +60,15 @@ public enum Types public Types type; } + [Serializable()] + public class ChangeArgs : EventArgs + { + public Program prog; + public FirewallRuleEx rule; + public Priv10Engine.RuleEventType type; + public Priv10Engine.RuleFixAction action; + } + public void RunInEngineThread(FX fx) { if (mDispatcher == null) @@ -195,7 +204,7 @@ public void Run() ProgramList.Changed += (object sender, ProgramList.ListEvent e) => { - NotifyProgramChange(e.guid); + NotifyProgramUpdate(e.guid); }; AppLog.Debug("Starting engine timer..."); @@ -216,7 +225,7 @@ public void Run() // queue a refresh push RunInEngineThread(() => { - NotifyProgramChange(Guid.Empty); + NotifyProgramUpdate(Guid.Empty); }); Dispatcher.Run(); // run @@ -546,19 +555,19 @@ public void LoadLogAsync() }).Start(); } - public void NotifyProgramChange(Guid guid) + public void NotifyProgramUpdate(Guid guid) { if (App.host != null) - App.host.NotifyChange(guid, ChangeArgs.Types.ProgSet); + App.host.NotifyUpdate(guid, UpdateArgs.Types.ProgSet); } - public void NotifyRulesChange(Guid guid) + public void NotifyRulesUpdte(Guid guid) { if (App.host != null) - App.host.NotifyChange(guid, ChangeArgs.Types.Rules); + App.host.NotifyUpdate(guid, UpdateArgs.Types.Rules); } - public void OnRulesChanged(ProgramSet progSet) + public void OnRulesUpdated(ProgramSet progSet) { foreach (Program prog in progSet.Programs.Values) { @@ -566,15 +575,15 @@ public void OnRulesChanged(ProgramSet progSet) Socket.Access = prog.LookupRuleAccess(Socket); } - NotifyRulesChange(progSet.guid); + NotifyRulesUpdte(progSet.guid); } - public void OnRulesChanged(Program prog) + public void OnRulesUpdated(Program prog) { foreach (NetworkSocket Socket in prog.Sockets.Values) Socket.Access = prog.LookupRuleAccess(Socket); - NotifyRulesChange(prog.ProgSet.guid); + NotifyRulesUpdte(prog.ProgSet.guid); } #if FW_COM_ITF @@ -925,7 +934,7 @@ protected void OnRuleRemoved(FirewallRuleEx knownRule, Program prog) LogRuleEvent(prog, knownRule, RuleEventType.Removed, actionTaken); } - enum RuleEventType + public enum RuleEventType { Changed = 0, Added, @@ -933,7 +942,7 @@ enum RuleEventType UnChanged, // role was changed to again match the aproved configuration } - enum RuleFixAction + public enum RuleFixAction { None = 0, Restored, @@ -944,7 +953,10 @@ enum RuleFixAction private void LogRuleEvent(Program prog, FirewallRuleEx rule, RuleEventType type, RuleFixAction action) { - OnRulesChanged(prog); + OnRulesUpdated(prog); + + if (App.host != null) + App.host.NotifyChange(prog, rule, type, action); // Logg the event Dictionary Params = new Dictionary(); @@ -981,9 +993,11 @@ private void LogRuleEvent(Program prog, FirewallRuleEx rule, RuleEventType type, } if (type == RuleEventType.UnChanged || action == RuleFixAction.Restored) - App.LogInfo(EventID, Params, App.EventFlags.Notifications, Message); + App.LogInfo(EventID, Params, App.EventFlags.AppLogEntries, Message); else - App.LogWarning(EventID, Params, App.EventFlags.Notifications, Message); + App.LogWarning(EventID, Params, App.EventFlags.AppLogEntries, Message); + + } public void ApproveRules() @@ -1022,7 +1036,7 @@ public int CleanupFwRules(bool bAll = false) } if(bRemoved) - OnRulesChanged(prog); + OnRulesUpdated(prog); } return Count; } @@ -1192,7 +1206,7 @@ public bool UpdateRule(FirewallRule rule, UInt64 expiration = 0) { old_prog?.Rules.Remove(old_rule.guid); - OnRulesChanged(prog); + OnRulesUpdated(prog); } } @@ -1200,18 +1214,18 @@ public bool UpdateRule(FirewallRule rule, UInt64 expiration = 0) if (!FirewallManager.ApplyRule(prog, rule, expiration)) // if the rule is new this will set the guid return false; - OnRulesChangedEx(prog); + OnRulesUpdatedEx(prog); return true; })); } - private void OnRulesChangedEx(Program prog) + private void OnRulesUpdatedEx(Program prog) { - OnRulesChanged(prog); + OnRulesUpdated(prog); App.engine.FirewallManager.EvaluateRules(prog.ProgSet); - NotifyProgramChange(prog.ProgSet.guid); + NotifyProgramUpdate(prog.ProgSet.guid); } public bool RemoveRule(FirewallRule rule) @@ -1225,7 +1239,7 @@ public bool RemoveRule(FirewallRule rule) { prog.Rules.Remove(rule.guid); - OnRulesChanged(prog); + OnRulesUpdated(prog); } return true; })); @@ -1257,7 +1271,7 @@ private bool ApproveRule(bool bApply, Program prog, FirewallRuleEx ruleEx) } } - OnRulesChangedEx(prog); + OnRulesUpdatedEx(prog); return true; } @@ -1275,7 +1289,7 @@ private bool RestoreRule(Program prog, FirewallRuleEx ruleEx) } ruleEx.Backup = null; - OnRulesChangedEx(prog); + OnRulesUpdatedEx(prog); return true; } diff --git a/PrivateWin10/Core/Tweaks/TweakManager.cs b/PrivateWin10/Core/Tweaks/TweakManager.cs index 965433e..5c2070e 100644 --- a/PrivateWin10/Core/Tweaks/TweakManager.cs +++ b/PrivateWin10/Core/Tweaks/TweakManager.cs @@ -39,6 +39,22 @@ public IEnumerable GetAllTweaks() UInt64 NextTweakCheck = 0; UInt64 LastSaveTime = MiscFunc.GetTickCount64(); + [Serializable()] + public class TweakEventArgs : EventArgs + { + public enum State + { + eNone, + eChanged, + eRestored + }; + + public State state; + public Tweak tweak; + } + + public event EventHandler TweakChanged; + public TweakManager() { TweakStore.InitTweaks(Categorys); @@ -174,6 +190,8 @@ public bool TestTweak(Tweak tweak, bool fixChanged = false) if (tweak.Status == false && tweak.State != Tweak.States.Unsellected) { + TweakEventArgs.State state = TweakEventArgs.State.eChanged; + if (fixChanged == true && tweak.FixFailed == false) { ApplyTweak(tweak); @@ -185,6 +203,7 @@ public bool TestTweak(Tweak tweak, bool fixChanged = false) } else { + state = TweakEventArgs.State.eRestored; tweak.FixedCount++; App.LogInfo(App.EventIDs.TweakFixed, Params, App.EventFlags.Notifications, Translate.fmt("msg_tweak_fixed", tweak.Name, tweak.Group)); } @@ -193,6 +212,8 @@ public bool TestTweak(Tweak tweak, bool fixChanged = false) { App.LogWarning(App.EventIDs.TweakChanged, Params, App.EventFlags.Notifications, Translate.fmt("msg_tweak_un_done", tweak.Name, tweak.Group)); } + + TweakChanged?.Invoke(this, new TweakEventArgs() { tweak = tweak, state = state }); } } return status; diff --git a/PrivateWin10/Core/WindowsFirewall/FirewallManager.cs b/PrivateWin10/Core/WindowsFirewall/FirewallManager.cs index 86efcd6..2664f6d 100644 --- a/PrivateWin10/Core/WindowsFirewall/FirewallManager.cs +++ b/PrivateWin10/Core/WindowsFirewall/FirewallManager.cs @@ -217,7 +217,7 @@ public void ApplyRules(ProgramSet progSet, UInt64 expiration = 0) progSet.config.CurAccess = progSet.config.NetAccess; - App.engine.OnRulesChanged(progSet); + App.engine.OnRulesUpdated(progSet); } public bool ApplyRule(Program prog, FirewallRule rule, UInt64 expiration = 0) diff --git a/PrivateWin10/Core/WindowsFirewall/FirewallRule.cs b/PrivateWin10/Core/WindowsFirewall/FirewallRule.cs index 3979bce..01363cf 100644 --- a/PrivateWin10/Core/WindowsFirewall/FirewallRule.cs +++ b/PrivateWin10/Core/WindowsFirewall/FirewallRule.cs @@ -597,7 +597,9 @@ public static string GetSpecialNet(string SubNet, NetworkMonitor.AdapterInfo Nic else if (SubNet.Equals(FirewallRule.AddrKeywordRmtIntrAnet, StringComparison.OrdinalIgnoreCase) || SubNet.Equals(FirewallRule.AddrKeywordPly2Renders, StringComparison.OrdinalIgnoreCase) || SubNet.Equals(FirewallRule.AddrKeywordCaptivePortal, StringComparison.OrdinalIgnoreCase)) + { ; // todo: + } else return null; return string.Join(",", IpRanges.ToArray()); diff --git a/PrivateWin10/IPC/Priv10Client.cs b/PrivateWin10/IPC/Priv10Client.cs index 22dad1b..c0d2ee1 100644 --- a/PrivateWin10/IPC/Priv10Client.cs +++ b/PrivateWin10/IPC/Priv10Client.cs @@ -248,6 +248,7 @@ public bool UndoTweak(TweakManager.Tweak tweak) public event EventHandler ActivityNotification; public event EventHandler ChangeNotification; + public event EventHandler UpdateNotification; public override void HandlePushNotification(string func, object args) @@ -267,6 +268,12 @@ public override void HandlePushNotification(string func, object args) { Application.Current.Dispatcher.BeginInvoke(new Action(() => { ChangeNotification?.Invoke(this, (Priv10Engine.ChangeArgs)args); + })); + } + else if (func == "UpdateNotification") + { + Application.Current.Dispatcher.BeginInvoke(new Action(() => { + UpdateNotification?.Invoke(this, (Priv10Engine.UpdateArgs)args); })); } else diff --git a/PrivateWin10/IPC/Priv10Host.cs b/PrivateWin10/IPC/Priv10Host.cs index 2e51e75..b382542 100644 --- a/PrivateWin10/IPC/Priv10Host.cs +++ b/PrivateWin10/IPC/Priv10Host.cs @@ -238,14 +238,26 @@ public void NotifyActivity(Guid guid, Program.LogEntry entry, ProgramID progID, SendPushNotification("ActivityNotification", args); } - public void NotifyChange(Guid guid, Priv10Engine.ChangeArgs.Types type) + public void NotifyChange(Program prog, FirewallRuleEx rule, Priv10Engine.RuleEventType type, Priv10Engine.RuleFixAction action) { Priv10Engine.ChangeArgs args = new Priv10Engine.ChangeArgs() + { + prog = prog, + rule = rule, + type = type, + action = action + }; + SendPushNotification("ChangeNotification", args); + } + + public void NotifyUpdate(Guid guid, Priv10Engine.UpdateArgs.Types type) + { + Priv10Engine.UpdateArgs args = new Priv10Engine.UpdateArgs() { guid = guid, type = type }; - SendPushNotification("ChangeNotification", args); + SendPushNotification("UpdateNotification", args); } } } diff --git a/PrivateWin10/MainWindow.xaml.cs b/PrivateWin10/MainWindow.xaml.cs index fba735f..959adf1 100644 --- a/PrivateWin10/MainWindow.xaml.cs +++ b/PrivateWin10/MainWindow.xaml.cs @@ -107,6 +107,8 @@ public class PageItem public bool FullyLoaded = false; + public NotificationWnd notificationWnd = null; + public MainWindow() { InitializeComponent(); @@ -130,6 +132,10 @@ public MainWindow() WpfFunc.LoadWnd(this, "Main"); bool HasEngine = App.client.IsConnected(); + + notificationWnd = new NotificationWnd(HasEngine); + //notificationWnd.Closed += NotificationClosed; + mPages.Add("Overview", new PageItem(new OverviewPage())); mPages.Add("Privacy", new PageItem(new PrivacyPage())); mPages.Add("Firewall", new PageItem(HasEngine ? new FirewallPage() : null)); @@ -207,6 +213,9 @@ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs (page.ctrl as IUserPage).OnClose(); } + if (notificationWnd != null) + notificationWnd.CloseWnd(); + if (App.TrayIcon.Visible) { e.Cancel = true; @@ -219,6 +228,11 @@ private void Window_Closed(object sender, EventArgs e) } + /*void NotificationClosed(object sender, EventArgs e) + { + notificationWnd = null; + }*/ + public void UpdateEnabled() { bool HasEngine = App.client.IsConnected(); diff --git a/PrivateWin10/Pages/FirewallPage.xaml.cs b/PrivateWin10/Pages/FirewallPage.xaml.cs index b3e025e..47e5295 100644 --- a/PrivateWin10/Pages/FirewallPage.xaml.cs +++ b/PrivateWin10/Pages/FirewallPage.xaml.cs @@ -270,7 +270,6 @@ public FirewallPage() progTree.SetPage(this); - mTimer.Tick += new EventHandler(OnTimerTick); mTimer.Interval = new TimeSpan(0, 0, 0, 0, 250); // 4 times a second mTimer.Start(); @@ -278,6 +277,7 @@ public FirewallPage() App.client.ActivityNotification += OnActivity; App.client.ChangeNotification += OnChange; + App.client.UpdateNotification += OnUpdate; //ProgramSets = new ObservableCollection(); @@ -326,9 +326,6 @@ public void OnClose() consList.OnClose(); sockList.OnClose(); dnsList.OnClose(); - - if (notificationWnd != null) - notificationWnd.Close(); } private void ProgList_SelectionChanged(object sender, EventArgs e) @@ -429,37 +426,28 @@ void OnActivity(object sender, Priv10Engine.FwEventArgs args) consList.AddEntry(prog, program, args); } - - private NotificationWnd notificationWnd = null; - - private void ShowNotification(ProgramSet prog, Priv10Engine.FwEventArgs args) + void OnChange(object sender, Priv10Engine.ChangeArgs args) { - if (notificationWnd == null) - { - if (args.update) // dont show on update events - return; - - notificationWnd = new NotificationWnd(); - notificationWnd.Closing += NotificationClosing; - } - if(notificationWnd.Add(prog, args)) - notificationWnd.Show(); + App.MainWnd.notificationWnd.NotifyRule(args); } - void NotificationClosing(object sender, CancelEventArgs e) + private void ShowNotification(ProgramSet prog, Priv10Engine.FwEventArgs args) { - notificationWnd = null; + if (args.update && !App.MainWnd.notificationWnd.IsVisible) // dont show on update events + return; + + App.MainWnd.notificationWnd.AddCon(prog, args); } HashSet UpdatesProgs = new HashSet(); bool FullUpdate = false; bool RuleUpdate = false; - void OnChange(object sender, Priv10Engine.ChangeArgs args) + void OnUpdate(object sender, Priv10Engine.UpdateArgs args) { if (args.guid == Guid.Empty) FullUpdate = true; - else if (args.type == Priv10Engine.ChangeArgs.Types.ProgSet) + else if (args.type == Priv10Engine.UpdateArgs.Types.ProgSet) UpdatesProgs.Add(args.guid); else RuleUpdate = true; diff --git a/PrivateWin10/Pages/PrivacyPage.xaml.cs b/PrivateWin10/Pages/PrivacyPage.xaml.cs index 053a432..e8fe498 100644 --- a/PrivateWin10/Pages/PrivacyPage.xaml.cs +++ b/PrivateWin10/Pages/PrivacyPage.xaml.cs @@ -32,6 +32,13 @@ public partial class PrivacyPage : UserControl, IUserPage public PrivacyPage() { InitializeComponent(); + + App.tweaks.TweakChanged += OnChange; + } + + public void OnChange(object sender, TweakManager.TweakEventArgs args) + { + App.MainWnd.notificationWnd.NotifyTweak(args); } public void OnShow() diff --git a/PrivateWin10/Pages/SettingsPage.xaml.cs b/PrivateWin10/Pages/SettingsPage.xaml.cs index 0082775..b43fbf4 100644 --- a/PrivateWin10/Pages/SettingsPage.xaml.cs +++ b/PrivateWin10/Pages/SettingsPage.xaml.cs @@ -417,7 +417,7 @@ private void BtnBackup_Click(object sender, RoutedEventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Zip Archives|*.zip"; - saveFileDialog.FileName = "PrivateWin10-Data_" + DateTime.Now.ToString("HH:mm:ss_dd.MM.yyyy") + ".zip"; + saveFileDialog.FileName = "PrivateWin10-Data_" + DateTime.Now.ToString("HH-mm-ss--dd-MM-yyyy") + ".zip"; if (saveFileDialog.ShowDialog() != true) return; diff --git a/PrivateWin10/PrivateWin10.csproj b/PrivateWin10/PrivateWin10.csproj index 9adeddf..338c296 100644 --- a/PrivateWin10/PrivateWin10.csproj +++ b/PrivateWin10/PrivateWin10.csproj @@ -108,6 +108,9 @@ AddressControl.xaml + + ConnectionNotify.xaml + DnsBlockListsControl.xaml @@ -145,13 +148,22 @@ + + RuleNotify.xaml + + + SplitButton.xaml + TweakControl.xaml TweakGroup.xaml + + TweakNotify.xaml + @@ -240,6 +252,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -280,6 +296,14 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -288,6 +312,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + MSBuild:Compile Designer diff --git a/PrivateWin10/Properties/AssemblyInfo.cs b/PrivateWin10/Properties/AssemblyInfo.cs index d342685..3aa0d7d 100644 --- a/PrivateWin10/Properties/AssemblyInfo.cs +++ b/PrivateWin10/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.74.0.0")] -[assembly: AssemblyFileVersion("0.74.0.0")] +[assembly: AssemblyVersion("0.75.0.0")] +[assembly: AssemblyFileVersion("0.75.0.0")] diff --git a/PrivateWin10/Translate.cs b/PrivateWin10/Translate.cs index a37c23e..41584a4 100644 --- a/PrivateWin10/Translate.cs +++ b/PrivateWin10/Translate.cs @@ -34,8 +34,6 @@ static public void Load(string lang = "") mStrings.Add("name_service", "{0} (service: {1})"); mStrings.Add("name_app", "{0} (app: {1})"); mStrings.Add("name_global", "All Processes"); - mStrings.Add("prefix_service", "Service: "); - mStrings.Add("prefix_programm", "Program: "); mStrings.Add("prefix_app", "App: "); mStrings.Add("sort_no", "Unsorted"); mStrings.Add("sort_name", "Name"); @@ -138,14 +136,21 @@ static public void Load(string lang = "") mStrings.Add("lbl_name", "Name"); mStrings.Add("lbl_group", "Group"); mStrings.Add("lbl_index", "Index"); - mStrings.Add("wnd_notify", "Connection Notification Window"); + mStrings.Add("wnd_notify", "PrivateWin10 Notifications"); mStrings.Add("lbl_prev", "Previous"); mStrings.Add("lbl_next", "Next"); mStrings.Add("lbl_remember", "Remember:"); mStrings.Add("lbl_ignore", "Ignore"); + mStrings.Add("lbl_ignore_all", "Ignore All"); + mStrings.Add("lbl_approve", "Approve"); + mStrings.Add("lbl_approve_all", "Approve All"); + mStrings.Add("lbl_reject", "Reject"); + mStrings.Add("lbl_reject_all", "Reject All"); mStrings.Add("lbl_apply", "Apply"); mStrings.Add("lbl_direction", "Direction"); mStrings.Add("lbl_protocol", "Protocol"); + mStrings.Add("lbl_protocol_", "Protocol:"); + mStrings.Add("lbl_program_", "Program:"); mStrings.Add("lbl_ip_port", "Address:Port"); mStrings.Add("lbl_remote_host", "Remote Host"); mStrings.Add("lbl_time_stamp", "Timestamp"); @@ -177,6 +182,8 @@ static public void Load(string lang = "") mStrings.Add("grp_network", "Network Properties"); mStrings.Add("lbl_local_ip", "Local Address"); mStrings.Add("lbl_remote_ip", "Remote Address"); + mStrings.Add("lbl_local", "Local:"); + mStrings.Add("lbl_remote", "Remote:"); mStrings.Add("btn_add_prog", "Add Program"); mStrings.Add("btn_add_to_set", "Add Program to set"); mStrings.Add("btn_merge_progs", "Merge Programs"); @@ -428,6 +435,12 @@ static public void Load(string lang = "") mStrings.Add("msg_backup_ok", "Data directory saved successfully to: {0}"); mStrings.Add("msg_restore_info", "PrivateWin10 will now restart to apply the backup"); mStrings.Add("msg_restore_no_ini", "The sellected archive does not look like a PrivateWin10 configuration backup!"); + mStrings.Add("lbl_rule_guide", "Some Firewall rules have been changed by a 3rd party application, please review the changed rules and approve or reject the changes."); + mStrings.Add("lbl_rule_details", "Rule details"); + mStrings.Add("lbl_con_notify", "New Connections"); + mStrings.Add("lbl_rule_notify", "Changed Rules"); + mStrings.Add("lbl_tweak_notify", "Changed Tweaks"); + //mStrings.Add("", ""); diff --git a/PrivateWin10/TrayIcon.cs b/PrivateWin10/TrayIcon.cs index 3f68138..f5a385c 100644 --- a/PrivateWin10/TrayIcon.cs +++ b/PrivateWin10/TrayIcon.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using System.Windows.Forms; using System.ComponentModel; +using System.Windows.Threading; namespace PrivateWin10 { @@ -17,9 +18,12 @@ public class TrayIcon private MenuItem menuExit; private IContainer components; + DispatcherTimer mTimer = new DispatcherTimer(); + public enum Actions { ToggleWindow, + ToggleNotify, CloseApplication, } @@ -80,6 +84,22 @@ public TrayIcon() // Handle the DoubleClick event to activate the form. notifyIcon.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick); notifyIcon.Click += new System.EventHandler(this.notifyIcon1_Click); + + mTimer.Tick += new EventHandler(OnTimerTick); + mTimer.Interval = new TimeSpan(0, 0, 0, 0, 500); + mTimer.Start(); + } + + private void OnTimerTick(object sender, EventArgs e) + { + if (clicked) + { + clicked = false; + + TrayEventArgs args = new TrayEventArgs(); + args.Action = Actions.ToggleNotify; + Action(this, args); + } } public bool Visible { get { return notifyIcon.Visible; } set { notifyIcon.Visible = value; } } @@ -95,9 +115,14 @@ public void Notify(string Message, ToolTipIcon Icon = ToolTipIcon.Info) notifyIcon.ShowBalloonTip(5000, App.Title, Message, Icon); } + bool clicked = false; + private void notifyIcon1_Click(object Sender, EventArgs e) { - //MessageBox.Show("clicked"); + if ((e as MouseEventArgs).Button != MouseButtons.Left) + return; + + clicked = true; } private void notifyIcon1_DoubleClick(object Sender, EventArgs e) @@ -105,6 +130,7 @@ private void notifyIcon1_DoubleClick(object Sender, EventArgs e) if ((e as MouseEventArgs).Button != MouseButtons.Left) return; + clicked = false; TrayEventArgs args = new TrayEventArgs(); args.Action = Actions.ToggleWindow; Action(this, args); diff --git a/PrivateWin10/Windows/NotificationWnd.xaml b/PrivateWin10/Windows/NotificationWnd.xaml index 69b71f7..037e5b5 100644 --- a/PrivateWin10/Windows/NotificationWnd.xaml +++ b/PrivateWin10/Windows/NotificationWnd.xaml @@ -3,83 +3,46 @@ 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:draw="clr-namespace:System.Drawing;assembly=System.Drawing" xmlns:local="clr-namespace:PrivateWin10.Windows" xmlns:controls="clr-namespace:PrivateWin10.Controls" mc:Ignorable="d" - Title="Connection Notification Window" + Title="Notification Window" ShowActivated="false" WindowStyle="ToolWindow" Height="400" Width="300" MinHeight="300" MinWidth="300" ShowInTaskbar="false" Closing="Window_Closing"> - + + - - - - - - - - - - - - - -