Esempio n. 1
0
        private void AddNewLocation(ViewStacker stacker, ViewModelFastestServerSettings.SelectionItem item)
        {
            var btn = new ServerCheckButton(item.ServerInfo, item.IsSelected);

            btn.OnChecked += () =>
            {
                item.IsSelected = btn.IsChecked;
                // confirm that value was changed
                btn.IsChecked = item.IsSelected;
            };

            __ServerButtons.Add(btn);
            stacker.Add(btn);
        }
Esempio n. 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;
        }
Esempio n. 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 AddNewLocation(ViewStacker stacker, ServerLocation location)
        {
            var btn = new ServerSelectionButton(location);

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

            if (location.CountryCode == __ViewModel.DisallowedCountryCode)
            {
                btn.DisabledForSelection = true;
            }

            btn.Activated += (object sender, EventArgs e) =>
            {
                __ViewModel.SelectServerCommand.Execute(((ServerSelectionButton)sender).ServerLocation);
            };
            btn.OnConfigButtonPressed += (object sender, EventArgs e) =>
            {
            };

            __ServerButtons.Add(btn);
            stacker.Add(btn);
        }
        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();
        }