Ejemplo n.º 1
0
 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 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 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 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);
        }
Ejemplo n.º 5
0
        public void onStoringSettings(Base.ISettings settings)
        {
            if (settings == null)
            {
                return;
            }
            var boxSettings    = Dispatcher.Invoke(() => PopupHelper.getUpdatedLocation(mybox));
            var popMsgSettings = Dispatcher.Invoke(() => getNewerSettings(popMsg));

            boxSettings.relativeTo(SystemParameters.WorkArea);
            popMsgSettings.relativeTo(SystemParameters.WorkArea);
            settings.put(Constant.FloatingboxKey, boxSettings);
            settings.put(Constant.FloatingPopMsgKey, popMsgSettings);
        }
Ejemplo n.º 6
0
        public FloatingBox(Base.ISettings settings)
        {
            InitializeComponent();
            timer = TimerWrapper.wrap(() => {
                Dispatcher.Invoke(() => viewMsgBoxState(false));
            }, 5000);
            RoutedEventHandler onLoaded = null;

            onLoaded = (sender, e) => {
                this.Loaded -= onLoaded;
                onLoadedInternal(settings);
            };
            this.Loaded += onLoaded;
        }
        public void onStoringSettings(Base.ISettings settings)
        {
            if (settings == null)
            {
                return;
            }
            var location = Dispatcher.Invoke(() => {
                return(PopupHelper.getUpdatedLocation(popbox));
            });
            var flowChecked = Dispatcher.Invoke(() => flowToggle.IsChecked == true);

            location.relativeTo(SystemParameters.WorkArea);
            settings.put(Constant.FlowBoxKey, location);
            settings.put(Constant.FlowBoxOpenKey, flowChecked);
            settings.put(Constant.FlowBoxMaxRecentKey, msgHost.MaxRecentSize);
        }
        //private List<ToggleButton> mutexToggle;

        public MessageFlowBox(Base.ISettings settings)
        {
            InitializeComponent();
            subscribeEvent(settings);
        }