Esempio n. 1
0
 private object ReceiveSetZoomMessage(SendSetZoomMessage msg)
 {
     zoomLevel = msg.Zoom;
     if (msg.SetImmediately)
     {
         setBrowserZoom(zoomLevel);
     }
     return(null);
 }
 private object ReceiveSetZoomMessage(SendSetZoomMessage msg)
 {
     zoomLevel = msg.Zoom;
     if (msg.SetImmediately)
     {
         setBrowserZoom(zoomLevel);
     }
     return null;
 }
Esempio n. 3
0
        private async void EditFeed(RoutedEventArgs e)
        {
            if (_selectedNode == null)
                return;
            SimpleTreeNodeViewModel tvm = (SimpleTreeNodeViewModel)_selectedNode;
            Model.Feed selectedFeed = null;
            if (tvm.Node is Model.Feed)
            {
                selectedFeed = (Model.Feed)tvm.Node;
            }
            else
            {
                if (tvm.Node is Model.Host)
                {
                    try
                    {
                        Model.Host selectedHost = (Model.Host)tvm.Node;
                        IsBrowserVisible = false;
                        RaisePropertyChanged("IsBrowserVisible");
                        MetroDialogSettings diagSettings = new MetroDialogSettings();
                        diagSettings.DefaultText = selectedHost.Zoom.ToString();
                        var ZoomLevel = await _dialogCoordinator.ShowInputAsync(this, "Set Zoom Level", "Enter the desired zoom level for this host: ", diagSettings);
                        int prevZoom = selectedHost.Zoom;
                        selectedHost.Zoom = Int32.Parse(ZoomLevel.ToString());
                        Data.Host dh = new Data.Host(selectedHost);
                        dh.Save();

                        if (prevZoom != selectedHost.Zoom)
                        {
                            var msg = new SendSetZoomMessage(selectedHost.Zoom);
                            msg.SetImmediately = true;
                            Messenger.Default.Send<SendSetZoomMessage>(msg);
                        }
                    }
                    catch (Exception ex)
                    {
                        await _dialogCoordinator.ShowMessageAsync(this, "Set Zoom Level", "Unable to set zoom: " + ex.Message);
                    }
                    finally
                    {
                        IsBrowserVisible = true;
                        RaisePropertyChanged("IsBrowserVisible");
                    }
                }
                return;
            }


            // Hides browser otherwise dialog gets behind it
            IsBrowserVisible = false;
            RaisePropertyChanged("IsBrowserVisible");
            MetroDialogSettings dialogSettings = new MetroDialogSettings();
            dialogSettings.DefaultText = selectedFeed.Location.ToString();
            var FeedText = await _dialogCoordinator.ShowInputAsync(this, "Edit feed", "Enter the URL of the feed:", dialogSettings);
            if (FeedText != null)
            {
                string errMsg = null;
                try
                {
                    Uri feedUri = new Uri(FeedText);
                    Data.Feed f = new Data.Feed(selectedFeed);
                    f.Location = feedUri;
                    f.UpdateFromUri(true, RetentionDays);
                    f.Save(true);
                    InitializeData(true);
                }
                catch (Exception ex)
                {
                    errMsg = ex.Message;
                }
                if (errMsg != null)
                {
                    await _dialogCoordinator.ShowMessageAsync(this, "Edit Feed", "Unable to edit feed with the supplied URL: " + errMsg);
                }
            }
            IsBrowserVisible = true;
            RaisePropertyChanged("IsBrowserVisible");
        }