/// <summary> /// Adds Height/Width/Top/Left/Windows state to the list of properties to track. Uses /// the "ResizeEnd" to trigger persist. Handles validation for edge cases (2nd display /// disconnected, saving size info while minimized/maximized). /// </summary> /// <param name="configuration"></param> public override void InitializeConfiguration(TrackingConfiguration configuration) { var form = configuration.TargetReference.Target as Form; configuration .AddProperties<Form>(f => f.Height, f => f.Width, f => f.Top, f => f.Left, f => f.WindowState) .RegisterPersistTrigger(nameof(form.ResizeEnd)) .RegisterPersistTrigger(nameof(form.LocationChanged)) .IdentifyAs(form.Name); configuration.PersistingProperty += (sender, args) => { //do not save height/width/top/left when the form is maximized or minimized args.Cancel = form.WindowState != FormWindowState.Normal && args.Property != nameof(form.WindowState); }; configuration.ApplyingProperty += (sender, args) => { //We don't want to restore the form off screeen. //This can happen in case of a multi-display setup i.e. the form was closed on 2nd display, but restored after the 2nd display was disconnected if (args.Property == "Left") args.Value = (int)Math.Min(Math.Max(SystemParameters.VirtualScreenLeft, (int)args.Value), SystemParameters.VirtualScreenWidth - form.Width); }; base.InitializeConfiguration(configuration); }
public void ConfigureTracking(TrackingConfiguration <ColorPickerUC> configuration) { configuration .Id(_ => Name) .Properties(x => new { red = tbRed.Value, green = tbGreen.Value, blue = tbBlue.Value }) .PersistOn(nameof(Form.FormClosing), this.FindForm()); }
/// <summary> /// Initializes the tracking configuration for a target object /// </summary> /// <param name="configuration"></param> public virtual void InitializeConfiguration(TrackingConfiguration configuration) { object target = configuration.TargetReference.Target; //set key if [TrackingKey] detected Type targetType = target.GetType(); PropertyInfo keyProperty = targetType.GetProperties().SingleOrDefault(pi => pi.IsDefined(typeof(TrackingKeyAttribute), true)); if (keyProperty != null) configuration.Key = keyProperty.GetValue(target, null).ToString(); //add properties that have [Trackable] applied foreach (PropertyInfo pi in targetType.GetProperties()) { TrackableAttribute propTrackableAtt = pi.GetCustomAttributes(true).OfType<TrackableAttribute>().Where(ta => ta.TrackerName == configuration.StateTracker.Name).SingleOrDefault(); if (propTrackableAtt != null) { //use [DefaultValue] if present DefaultValueAttribute defaultAtt = pi.CustomAttributes.OfType<DefaultValueAttribute>().SingleOrDefault(); if (defaultAtt != null) configuration.AddProperty(pi.Name, defaultAtt.Value); else configuration.AddProperty(pi.Name); } } //allow the object to alter its configuration ITrackingAware trackingAwareTarget = target as ITrackingAware; if (trackingAwareTarget != null) trackingAwareTarget.InitConfiguration(configuration); }
/// <summary> /// Adds Height/Width/Top/Left/Windows state to the list of properties to track. Uses /// the "ResizeEnd" to trigger persist. Handles validation for edge cases (2nd display /// disconnected, saving size info while minimized/maximized). /// </summary> /// <param name="configuration"></param> public override void InitializeConfiguration(TrackingConfiguration configuration) { var form = configuration.TargetReference.Target as Form; configuration .AddProperties <Form>(f => f.Height, f => f.Width, f => f.Top, f => f.Left, f => f.WindowState) .RegisterPersistTrigger(nameof(form.ResizeEnd)) .RegisterPersistTrigger(nameof(form.LocationChanged)) .IdentifyAs(form.Name); configuration.PersistingProperty += (sender, args) => { //do not save height/width/top/left when the form is maximized or minimized args.Cancel = form.WindowState != FormWindowState.Normal && args.Property != nameof(form.WindowState); }; configuration.ApplyingProperty += (sender, args) => { //We don't want to restore the form off screeen. //This can happen in case of a multi-display setup i.e. the form was closed on 2nd display, but restored after the 2nd display was disconnected if (args.Property == "Left") { args.Value = (int)Math.Min(Math.Max(SystemParameters.VirtualScreenLeft, (int)args.Value), SystemParameters.VirtualScreenWidth - form.Width); } }; base.InitializeConfiguration(configuration); }
/// <summary> /// Creates or retrieves the tracking configuration for the speficied object. /// </summary> /// <param name="target"></param> /// <returns></returns> public TrackingConfiguration Configure(object target) { TrackingConfiguration config = FindExistingConfig(target); if (config == null) _configurations.Add(config = new TrackingConfiguration(target, this)); return config; }
public void SetUp() { tracker = new Mock <ITracker>(); scheduler = new TestScheduler(); logger = new NullLogger <ExpireTracking>(); trackingConfiguration = new TrackingConfiguration(TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1), "Data.csv"); instance = CreateInstance(); }
private void SetupTracking(IServiceCollection builder) { var config = new TrackingConfiguration(TimeSpan.FromHours(1), TimeSpan.FromDays(10), Path.Combine(GetPersistencyLocation(), "ratings.csv")); logger.LogInformation("Setup tracking: {0}", config.Persistency); config.Restore = true; builder.RegisterModule(new TrackingModule(config)); }
public void Config_TrackableAttributeHonoredOnClass() { TrackingConfiguration config = new TrackingConfiguration(new DummyClass1() { Key = 5 }, null); Assert.AreEqual(2, config.Properties.Count); Assert.AreEqual("Property1", config.Properties.ElementAt(0)); Assert.AreEqual("Property2", config.Properties.ElementAt(1)); Assert.AreEqual("5", config.Key); }
public void ConfigureTracking(TrackingConfiguration <AppSettings> configuration) { configuration.Properties(s => new { s.PersistedSettings, s.MarginToolSettings }); AppDomain.CurrentDomain.ProcessExit += (sender, args) => { configuration.Tracker.Persist(this); }; }
protected override void CustomizeConfiguration(TrackingConfiguration configuration) { Form window = configuration.TargetReference.Target as Form; if (window != null) { configuration .AddProperties<Form>(f => f.Left, f => f.Top, f => f.Height, f => f.Width, f => f.WindowState) .RegisterPersistTrigger("Closed"); } base.CustomizeConfiguration(configuration); }
protected override void CustomizeConfiguration(TrackingConfiguration configuration) { Window window = configuration.TargetReference.Target as Window; if (window != null) { configuration .AddProperties<Window>(w => w.Left, w => w.Top, w => w.Height, w => w.Width, w => w.WindowState) .RegisterPersistTrigger("Closed"); } base.CustomizeConfiguration(configuration); }
public void Config_TrackerNameHonred() { TrackingConfiguration config = new TrackingConfiguration(new DummyClass4(), new SettingsTracker() { Name = "1" }); Assert.AreEqual(2, config.Properties.Count); Assert.AreEqual("Property1", config.Properties.ElementAt(0)); Assert.AreEqual("Property2", config.Properties.ElementAt(1)); config = new TrackingConfiguration(new DummyClass4(), new SettingsTracker() { Name = "2" }); Assert.AreEqual(1, config.Properties.Count); Assert.AreEqual("Property2", config.Properties.ElementAt(0)); }
protected override void CustomizeConfiguration(TrackingConfiguration configuration) { Form window = configuration.TargetReference.Target as Form; if (window != null) { configuration .AddProperties <Form>(f => f.Left, f => f.Top, f => f.Height, f => f.Width, f => f.WindowState) .RegisterPersistTrigger("Closed"); } base.CustomizeConfiguration(configuration); }
protected override void CustomizeConfiguration(TrackingConfiguration configuration) { Window window = configuration.TargetReference.Target as Window; if (window != null) { configuration .AddProperties <Window>(w => w.Left, w => w.Top, w => w.Height, w => w.Width, w => w.WindowState) .RegisterPersistTrigger("Closed"); } base.CustomizeConfiguration(configuration); }
public void ConfigureTracking(TrackingConfiguration <Form1> configuration) { // include selected tab index when tracking this form configuration.Property(f => f.tabControl1.SelectedIndex); // include data grid column widths when tracking this form for (int i = 0; i < dataGridView1.Columns.Count; i++) { var idx = i; // capture i into a variable (cannot use i directly since it changes in each iteration) configuration.Property(f => f.dataGridView1.Columns[idx].Width, "grid_column_" + dataGridView1.Columns[idx].Name); } }
public void Setup() { var file = Path.Combine(TestContext.CurrentContext.TestDirectory, "Test", "result.csv"); if (File.Exists(file)) { File.Delete(file); } config = new TrackingConfiguration(TimeSpan.FromMinutes(1), TimeSpan.FromDays(2), file); config.Restore = true; }
public MainWindow() { InitializeComponent(); DataContext = this; this.genSettings = new GeneralSettings { CustomWindows = new StringCollection(), Username = string.Empty, FadeChat = false, FadeTime = "120", ShowBotActivity = false, ChatNotificationSound = "None", ThemeIndex = 1, ChatType = 0, CustomURL = string.Empty, ZoomLevel = 0, OpacityLevel = 0, AutoHideBorders = false, EnableTrayIcon = true, ConfirmClose = true, HideTaskbarIcon = false, AllowInteraction = true, VersionTracker = 0.7 }; Services.Tracker.Configure(this).IdentifyAs("State").Apply(); this.genSettingsTrackingConfig = Services.Tracker.Configure(this.genSettings); this.genSettingsTrackingConfig.IdentifyAs("MainWindow").Apply(); var browserSettings = new BrowserSettings { FileAccessFromFileUrls = CefState.Enabled, UniversalAccessFromFileUrls = CefState.Enabled }; Browser1.BrowserSettings = browserSettings; CefSharpSettings.LegacyJavascriptBindingEnabled = true; //this.Browser1.RegisterAsyncJsObject("jsCallback", new JsCallbackFunctions()); this.jsCallbackFunctions = new JsCallbackFunctions(); Browser1.JavascriptObjectRepository.Register("jsCallback", this.jsCallbackFunctions, isAsync: true, options: BindingOptions.DefaultBinder); }
/*public event PropertyChangedEventHandler PropertyChanged; * protected void OnPropertyChanged([CallerMemberName]string propertyName = null) * { * PropertyChangedEventHandler handler = this.PropertyChanged; * if (handler != null) * { * var e = new PropertyChangedEventArgs(propertyName); * handler(this, e); * } * }*/ public MainWindow() { CefSettings settings = new CefSettings() { PersistSessionCookies = true, PersistUserPreferences = true, RootCachePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "TransparentTwitchChatWPF", "cef"), CachePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "TransparentTwitchChatWPF", "cef", "cache") }; Cef.Initialize(settings); InitializeComponent(); DataContext = this; this.currentChat = new CustomURLChat(); // TODO: initializing here needed? Services.Tracker.Configure(this).IdentifyAs("State").Apply(); this.genSettingsTrackingConfig = Services.Tracker.Configure(SettingsSingleton.Instance.genSettings); this.genSettingsTrackingConfig.IdentifyAs("MainWindow").Apply(); var browserSettings = new BrowserSettings { //ApplicationCache = CefState.Enabled, LocalStorage = CefState.Enabled, //FileAccessFromFileUrls = CefState.Enabled, //UniversalAccessFromFileUrls = CefState.Enabled, }; Browser1.BrowserSettings = browserSettings; Browser1.RequestContext = new RequestContext(new RequestContextSettings() { CachePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "TransparentTwitchChatWPF", "cef", "cache"), PersistSessionCookies = true, PersistUserPreferences = true, }); //this.Browser1.JavascriptObjectRepository.Settings.LegacyBindingEnabled = true; //this.Browser1.RegisterAsyncJsObject("jsCallback", new JsCallbackFunctions()); this.jsCallbackFunctions = new JsCallbackFunctions(); Browser1.JavascriptObjectRepository.Register("jsCallback", this.jsCallbackFunctions, isAsync: true, options: BindingOptions.DefaultBinder); }
/// <summary> /// Adds Height/Width/Top/Left/WindowState to list of tracked properties. Uses /// the "Sizechanged" event to trigger persistence. Handles validation for edge /// cases (2nd display disconnected between application shutdown and restart). /// </summary> /// <param name="configuration"></param> public override void InitializeConfiguration(TrackingConfiguration configuration) { Window window = configuration.TargetReference.Target as Window; configuration .AddProperties<Window>(w => w.Height, w => w.Width, w => w.Top, w => w.Left, w => w.WindowState) .RegisterPersistTrigger(nameof(window.SizeChanged)) .RegisterPersistTrigger(nameof(window.LocationChanged)) .IdentifyAs(window.Name); configuration.ApplyingProperty += (sender, args) => { //We don't want to restore the form off screeen. //This can happen in case of a multi-display setup i.e. the form was closed on 2nd display, but restored after the 2nd display was disconnected if (args.Property == "Left") args.Value = Math.Min(Math.Max(SystemParameters.VirtualScreenLeft, (double)args.Value), SystemParameters.VirtualScreenWidth - window.Width); }; base.InitializeConfiguration(configuration); }
public void SetUp() { scheduler = new TestScheduler(); mockRestorer = new Mock <IRestorer>(); mockTrackingConfiguration = new TrackingConfiguration(TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1), Path.Combine(TestContext.CurrentContext.TestDirectory, "file.csv")); if (File.Exists(mockTrackingConfiguration.Persistency)) { File.Delete(mockTrackingConfiguration.Persistency); } mockRatingStream = new Mock <IRatingStream>(); var tracker = new Mock <ITracker>(); var stream = scheduler.CreateHotObservable( new Recorded <Notification <(ITracker Tracker, RatingRecord Rating)> >(100, Notification.CreateOnNext((tracker.Object, new RatingRecord { Id = "1", Date = DateTime.Now, Rating = 2 })))); mockRatingStream.Setup(item => item.Stream).Returns(stream); instance = CreateTrackingPersistency(); }
/// <summary> /// Initializes the tracking configuration for a target object /// </summary> /// <param name="configuration"></param> public virtual void InitializeConfiguration(TrackingConfiguration configuration) { object target = configuration.TargetReference.Target; //set key if [TrackingKey] detected Type targetType = target.GetType(); PropertyInfo keyProperty = targetType.GetProperties().SingleOrDefault(pi => pi.IsDefined(typeof(TrackingKeyAttribute), true)); if (keyProperty != null) { configuration.Key = keyProperty.GetValue(target, null).ToString(); } //add properties that have [Trackable] applied foreach (PropertyInfo pi in targetType.GetProperties()) { TrackableAttribute propTrackableAtt = pi.GetCustomAttributes(true).OfType <TrackableAttribute>().Where(ta => ta.TrackerName == configuration.StateTracker.Name).SingleOrDefault(); if (propTrackableAtt != null) { //use [DefaultValue] if present DefaultValueAttribute defaultAtt = pi.CustomAttributes.OfType <DefaultValueAttribute>().SingleOrDefault(); if (defaultAtt != null) { configuration.AddProperty(pi.Name, defaultAtt.Value); } else { configuration.AddProperty(pi.Name); } } } //allow the object to alter its configuration ITrackingAware trackingAwareTarget = target as ITrackingAware; if (trackingAwareTarget != null) { trackingAwareTarget.InitConfiguration(configuration); } }
/// <summary> /// Adds Height/Width/Top/Left/WindowState to list of tracked properties. Uses /// the "Sizechanged" event to trigger persistence. Handles validation for edge /// cases (2nd display disconnected between application shutdown and restart). /// </summary> /// <param name="configuration"></param> public override void InitializeConfiguration(TrackingConfiguration configuration) { Window window = configuration.TargetReference.Target as Window; configuration .AddProperties <Window>(w => w.Height, w => w.Width, w => w.Top, w => w.Left, w => w.WindowState) .RegisterPersistTrigger(nameof(window.SizeChanged)) .RegisterPersistTrigger(nameof(window.LocationChanged)) .IdentifyAs(window.Name); configuration.ApplyingProperty += (sender, args) => { //We don't want to restore the form off screeen. //This can happen in case of a multi-display setup i.e. the form was closed on 2nd display, but restored after the 2nd display was disconnected if (args.Property == "Left") { args.Value = Math.Min(Math.Max(SystemParameters.VirtualScreenLeft, (double)args.Value), SystemParameters.VirtualScreenWidth - window.Width); } }; base.InitializeConfiguration(configuration); }
/*public event PropertyChangedEventHandler PropertyChanged; * protected void OnPropertyChanged([CallerMemberName]string propertyName = null) * { * PropertyChangedEventHandler handler = this.PropertyChanged; * if (handler != null) * { * var e = new PropertyChangedEventArgs(propertyName); * handler(this, e); * } * }*/ public MainWindow() { InitializeComponent(); DataContext = this; Services.Tracker.Configure(this).IdentifyAs("State").Apply(); this.genSettingsTrackingConfig = Services.Tracker.Configure(SettingsSingleton.Instance.genSettings); this.genSettingsTrackingConfig.IdentifyAs("MainWindow").Apply(); var browserSettings = new BrowserSettings { FileAccessFromFileUrls = CefState.Enabled, UniversalAccessFromFileUrls = CefState.Enabled }; Browser1.BrowserSettings = browserSettings; CefSharpSettings.LegacyJavascriptBindingEnabled = true; //this.Browser1.RegisterAsyncJsObject("jsCallback", new JsCallbackFunctions()); this.jsCallbackFunctions = new JsCallbackFunctions(); Browser1.JavascriptObjectRepository.Register("jsCallback", this.jsCallbackFunctions, isAsync: true, options: BindingOptions.DefaultBinder); }
public void InitConfiguration(TrackingConfiguration configuration) { configuration.StateTracker.Configure(tabControl).AddProperties <TabControl>(tc => tc.SelectedIndex).Apply(); configuration.StateTracker.Configure(col).AddProperties <ColumnDefinition>(tc => tc.Width).Apply(); }
public TrackingOperationEventArgs(TrackingConfiguration configuration, string property) { Configuration = configuration; Property = property; }
public void InitConfiguration(TrackingConfiguration configuration) { configuration.AddProperties("Value1", "Value2"); }
public void SetTrackingConfig(TrackingConfiguration trackingConfig) { // TODO IRuleSetTrackingInterceptor.SetTrackingConfig }
public void ConfigureTracking(TrackingConfiguration <AppSettings> configuration) { configuration.Properties(s => new { s.DisplaySettings, s.RuntimeSettings }); System.Windows.Application.Current.Exit += (s, e) => { configuration.Tracker.Persist(this); }; }
public void ConfigureTracking(TrackingConfiguration configuration) { configuration.AsGeneric <TrackingAwareTestClass>() .Id(f => "x") .Properties(f => new { f.Double, f.Int, f.Timespan }); }
public void ConfigureTracking(TrackingConfiguration <TestTrackingAware> configuration) { configuration.Properties(x => new { Value1, Value2 }); }
public void Config_ReleaseReference() { TrackingConfiguration config = new TrackingConfiguration(new DummyClass1(), null); GC.Collect(2, GCCollectionMode.Forced); GC.WaitForFullGCComplete(); Assert.IsFalse(config.TargetReference.IsAlive); }
public void InitConfiguration(TrackingConfiguration configuration) { configuration.IdentifyAs(this.Name); }
public void Config_TrackableAttributeExcludeHonored() { TrackingConfiguration config = new TrackingConfiguration(new DummyClass3(), null); Assert.AreEqual(1, config.Properties.Count); Assert.AreEqual("Property1", config.Properties.ElementAt(0)); }
public void InitConfiguration(TrackingConfiguration configuration) { configuration.AddProperties("Value1", "Value2"); }
public void ConfigureTracking(TrackingConfiguration <AuthenticationSettings> configuration) { configuration.Properties(settings => new { settings.Token }); PropertyChanged += (sender, args) => { configuration.Tracker.Persist(this); }; }
public TrackingModule(TrackingConfiguration configuration) { this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); }
protected virtual void CustomizeConfiguration(TrackingConfiguration configuration) { }
/// <summary> /// Creates a new instance of TrackingOperationEventArgs. /// </summary> /// <param name="configuration">The TrackingConfiguration object that initiated the tracking operation.</param> /// <param name="property">The property that is being persisted or applied to.</param> /// <param name="value">The value that is being persited or applied.</param> public TrackingOperationEventArgs(TrackingConfiguration configuration, string property, object value) { Configuration = configuration; Property = property; Value = value; }
public void ConfigureTracking(TrackingConfiguration <GeneralSettings> configuration) { configuration.Properties(settings => new { settings.IsAlwaysOnTop }); PropertyChanged += (sender, args) => { configuration.Tracker.Persist(this); }; }
public void InitConfiguration(TrackingConfiguration configuration) { configuration.SettingsTracker.Configure(tabControl).AddProperties<TabControl>(tc=>tc.SelectedIndex).Apply(); configuration.SettingsTracker.Configure(col).AddProperties<ColumnDefinition>(tc => tc.Width).Apply(); }
/// <summary> /// Gets or creates a configuration object what will control how the target object is going to be tracked (which properties, when to persist, when to apply, validation). /// For a given target object, always returns the same configuration instance. /// </summary> /// <param name="target">The object whose properties your want to track.</param> /// <returns>The tracking configuration object.</returns> public TrackingConfiguration Configure(object target) { TrackingConfiguration config = FindExistingConfig(target); if (config == null) { config = new TrackingConfiguration(target, this); var initializer = FindInitializer(target.GetType()); initializer.InitializeConfiguration(config); _trackedObjects.Add(new WeakReference(target)); _configurationsDict.Add(target, config); } return config; }
public void InitializeConfiguration(TrackingConfiguration configuration) { configuration.AddProperties<Foo>(t => t.A, t => t.B, t => t.Double, t => t.Int, t => t.Timespan); }
protected virtual void CustomizeConfiguration(TrackingConfiguration configuration) { }
protected override void CustomizeConfiguration(TrackingConfiguration configuration) { if(configuration.TargetReference.Target is Form) FormsHelper.ConfigureFormTracking(configuration); base.CustomizeConfiguration(configuration); }
public void InitConfiguration(TrackingConfiguration configuration) { configuration.IdentifyAs(this.Name); }
public void InitializeConfiguration(TrackingConfiguration configuration) { configuration.AddProperties <Foo>(t => t.A, t => t.B, t => t.Double, t => t.Int, t => t.Timespan); }
public void SetTrackingConfig(TrackingConfiguration trackingConfig) { this.trackingConfig = trackingConfig; }
/// <summary> /// Sets the rule set tracking GUID and tracking configuration. /// </summary> /// <param name="trackingConfig">The tracking configuration.</param> public void SetTrackingConfig(TrackingConfiguration trackingConfig) { this.trackingConfig = trackingConfig; }