private void UpdateInformationPopover(bool isReopenIfShown = true)
        {
            if (!NSThread.IsMain)
            {
                InvokeOnMainThread(() => UpdateInformationPopover(isReopenIfShown));
                return;
            }

            if (__GuiPopoverConnectionInfo == null)
            {
                return;
            }

            GuiGeoLookupView.Hidden         = __ProofsViewModel.State != ProofsViewModel.StateEnum.Ok;
            GuiGeoLookupCityView.Hidden     = __ProofsViewModel.State != ProofsViewModel.StateEnum.Ok || __ProofsViewModel.GeoLookup == null || string.IsNullOrEmpty(__ProofsViewModel.GeoLookup.City);
            GuiGeoLookupPublicIpView.Hidden = __ProofsViewModel.State != ProofsViewModel.StateEnum.Ok;

            GuiGeoLookupUpdateView.Hidden   = __ProofsViewModel.State != ProofsViewModel.StateEnum.Updating;
            GuiGeoLookupErrorView.Hidden    = __ProofsViewModel.State != ProofsViewModel.StateEnum.Error;
            GuiGeoLookupDurationView.Hidden = __MainViewModel.ConnectionState != ServiceState.Connected || __MainViewModel.PauseStatus != MainViewModel.PauseStatusEnum.Resumed;

            NSViewController informationPopoverController = new NSViewController();

            informationPopoverController.View = __InformationPopoverStacker.CreateView();

            __GuiPopoverConnectionInfo.ContentViewController = informationPopoverController;

            if (isReopenIfShown && __GuiPopoverConnectionInfo.Shown)
            {
                __GuiPopoverConnectionInfo.Show(GuiInformationButton.Bounds, GuiInformationButton, NSRectEdge.MinYEdge);
            }
        }
Example #2
0
        private void UpdateNetworksButtons()
        {
            if (NetworksView == null)
            {
                return;
            }

            ViewStacker stacker = new ViewStacker();
            List <NetworkActionsConfig.NetworkAction> networks = new List <NetworkActionsConfig.NetworkAction>(__NetworksViewModel.AllNetworkActions);

            foreach (var network in networks)
            {
                NetworkActionButton btn = new NetworkActionButton(network, __NetworksViewModel, (float)NetworksView.EnclosingScrollView.ContentSize.Width);
                stacker.Add(btn);
            }

            var newView = stacker.CreateView();

            nfloat minViewHeight = NetworksView.EnclosingScrollView.ContentSize.Height;

            if (minViewHeight > newView.Frame.Height) // height can not be smaller than EnclosingScrollView height
            {
                newView.Frame = new CGRect(newView.Frame.X, newView.Frame.Y, newView.Frame.Width, minViewHeight);
            }

            NetworksView.Frame = newView.Frame;

            if (__NetworksListView == null)
            {
                NetworksView.AddSubview(newView);
            }
            else
            {
                NetworksView.ReplaceSubviewWith(__NetworksListView, newView);
            }

            NetworksView.ScrollPoint(new CGPoint(0, newView.Frame.Bottom));

            __NetworksListView = newView;
        }
Example #3
0
        private void UpdateServersButtons()
        {
            if (!NSThread.IsMain)
            {
                InvokeOnMainThread(UpdateServersButtons);
                return;
            }

            if (UiServersView == null)
            {
                return;
            }

            __ServerButtons.Clear();
            ViewStacker stacker = new ViewStacker();

            foreach (ViewModelFastestServerSettings.SelectionItem item in __ViewModel.Items)
            {
                AddNewLocation(stacker, item);
            }

            stacker.Add(new MarginControl(10));

            var newView = stacker.CreateView((float)UiScrollViewer.Frame.Height);

            UiServersView.Frame = newView.Frame;

            if (__ServersListView == null)
            {
                UiServersView.AddSubview(newView);
                UiServersView.ScrollPoint(new CGPoint(0, newView.Frame.Bottom));
            }
            else
            {
                UiServersView.ReplaceSubviewWith(__ServersListView, newView);
            }

            __ServersListView = newView;
        }
        private void UpdateServersButtons()
        {
            if (ServersView == null)
            {
                return;
            }

            // Implementation of 'Config' button (will be in use after implementation configuration for each server)
            //__IsServersUpdateRequired = false;

            if (__FastestServerButton != null)
            {
                __FastestServerButton.IsSelected = __ViewModel.IsAutomaticServerSelected;
            }

            __ServerButtons.Clear();
            ViewStacker stacker = new ViewStacker();

            // automatic setver selection button
            __FastestServerButton = null;
            if (__ViewModel.ServerSelectionType == ServerSelectionType.SingleServer)
            {
                // automatic server selection is allowed only for singlehop
                __FastestServerButton = new ServerFastestSelectionButton(__ViewModel.IsAutomaticServerSelected);

                //  Implementation of 'Config' button (will be in use after implementation configuration for each server)
                //__FastestServerButton.IsConfigMode = IsConfigMode;
                __FastestServerButton.IsConfigMode = true;

                __FastestServerButton.Activated += (object sender, EventArgs e) =>
                {
                    __ViewModel.SelectAutomaticServerSelectionCommand.Execute(null);
                };
                __FastestServerButton.OnConfigButtonPressed += (object sender, EventArgs e) =>
                {
                    __ViewModel.ConfigureAutomaticServerSelectionCommand.Execute(null);
                };
                stacker.Add(__FastestServerButton);
            }

            // servers buttons
            List <ServerLocation> servers = new List <ServerLocation>(__ViewModel.Service.Servers.ServersList);

            foreach (var location in servers)
            {
                AddNewLocation(stacker, location);
            }

            stacker.Add(new MarginControl(10));

            var newView = stacker.CreateView((float)ScrollViewer.Frame.Height);

            ServersView.Frame = newView.Frame;

            if (__ServersListView == null)
            {
                ServersView.AddSubview(newView);
                ServersView.ScrollPoint(new CGPoint(0, newView.Frame.Bottom));
            }
            else
            {
                ServersView.ReplaceSubviewWith(__ServersListView, newView);
            }

            __ServersListView = newView;

            UpdateDisallowedServers();
        }