private void onLoadedInternal(Base.ISettings settings) { this.fadeMsg = FindResource("fadeMsg") as Storyboard; this.fadeMsg.Completed += showNextMessage; this.WindowStartupLocation = WindowStartupLocation.Manual; this.Dispatcher.ShutdownStarted += saveConfig; if (Owner != null) { Owner.Closing += onOwnerClosing; } this.mybox.Closed += onUnexpectedlyClosed; this.Left = SystemParameters.WorkArea.Width; this.Top = 0; this.Hide(); if (settings != null) { var boxSettings = settings.get(Constant.FloatingboxKey, new WidgetSettings()); var popMsgSettings = settings.get(Constant.FloatingPopMsgKey, new WidgetSettings()); boxSettings = WidgetSettings.match(boxSettings, SystemParameters.WorkArea); popMsgSettings = WidgetSettings.match(popMsgSettings, SystemParameters.WorkArea); System.Diagnostics.Debug.WriteLine($"Loading location {boxSettings.XOffset},{boxSettings.YOffset}"); System.Diagnostics.Debug.WriteLine($"Loading location {popMsgSettings.XOffset},{popMsgSettings.YOffset}"); PopupHelper.SetSettings(mybox, boxSettings); PopupHelper.SetSettings(popMsg, popMsgSettings); } PopupHelper.SetVisible(mybox, true); }
private void setFlow(Base.ISettings settings) { //set flow message source & recent message source var msgFlowList = new BindingList <MessageBean> (); var recentMsgList = new BindingList <MessageBean> (); flowItems.ItemsSource = msgFlowList; recentItems.ItemsSource = recentMsgList; animator = new FlowAnimationWrapper(flowItems.GetVisualChild <ScrollViewer> (), msgFlowList); //set message host var maxRecent = settings.get(Constant.FlowBoxMaxRecentKey, 60); msgHost = new MessageWrapper <MessageBean> (msgFlowList, recentMsgList, msg => { return(new MessageBean(msg.Tag, msg.Content) { Extra = $"[{DateTime.Now.ToString("HH:mm:ss fff")}]" }); }, Math.Max(maxRecent, 60)); msgHost.onMessageAddedDo(() => animator.raiseAnimated()); //must set it after because of flowToggle control flowItems's visibility //which may case flowItems.GetVisualChild<T> return null var enabled = settings.get(Constant.FlowBoxOpenKey, true); flowToggle.IsChecked = (bool)enabled; onFlowEnableChanged((bool)enabled); }
private void subscribeEvent(Base.ISettings settings) { RoutedEventHandler onLoaded = null; onLoaded = (sender, e) => { this.Loaded -= onLoaded; if (Owner != null) { Owner.Closing += onOwnerClosing; } this.Top = 0; this.Hide(); tvNormal = TryFindResource("tv-normal") as PathGeometry; tvDisable = TryFindResource("tv-disable") as PathGeometry; var mode = settings.get(Constant.FlowBoxModeKey, false); toDisplayMode(mode); settings.put(Constant.FlowBoxModeKey, mode); setPopup(settings); setFlow(settings); /*mutexToggle = new List<ToggleButton>(new ToggleButton[] { * dloadDetailToggle, * recentToggle, * prefToggle * }); * foreach(var toggle in mutexToggle) { * toggle.Checked += onWhoChecked; * }*/ }; this.Loaded += onLoaded; }
/*private void onWhoChecked(object sender, RoutedEventArgs e) { * foreach(var toggle in mutexToggle) { * if (toggle == sender) * continue; * toggle.IsChecked = false; * } * }*/ private void setPopup(Base.ISettings settings) { popbox.Closed += reopenOnUnexpectedlyClosed; //get settings from storage //get extra from storage var location = settings.get(Constant.FlowBoxKey, new WidgetSettings()); location = WidgetSettings.match(location, SystemParameters.WorkArea); System.Diagnostics.Debug.WriteLine($"Loading location {location.XOffset},{location.YOffset}"); //set popup PopupHelper.SetSettings(popbox, location); PopupHelper.SetVisible(popbox, true); }