public UserNetworkService(V1Service service, bool isEnabled)
        {
            if (service == null)
            {
                throw new ArgumentNullException("service");
            }

            m_service = service;
            m_isEnabled = isEnabled;
        }
        private void OnAddUserServiceCommand(UIElement element)
        {
            var addUserServiceControl = new AddUserServiceControl();
            var flyout = new Flyout();
            flyout.Content = addUserServiceControl;
            flyout.Placement = PlacementMode.Top;
            flyout.PlacementTarget = element;
            flyout.IsOpen = true;
            flyout.Background = addUserServiceControl.Background;

            addUserServiceControl.AddClicked += async (sender, e) =>
            {
                flyout.IsOpen = false;

                var service = new V1Service(
                    addUserServiceControl.SelectedName,
                    addUserServiceControl.SelectedProtocol.Convert(),
                    UInt16.Parse(addUserServiceControl.SelectedPort),
                    true);
                AddUserServiceSelection(service);

                var userServices = new V1UserServices();
                userServices.Services.AddRange(m_userNetworkServices.Select(x => x.Service));
                await NetworkServiceConfigurator.WriteUserServicesAsync(userServices);
            };
        }
 private void AddUserServiceSelection(V1Service service)
 {
     var serviceSelection = new NetworkServicePresenter<V1Service>(service.Name, service.Protocol.Convert(), service.Port, service.IsEnabled, service);
     serviceSelection.IsEnabledChanged += OnUserServiceSelectionIsEnabledChanged;
     try
     {
         // TODO: Need to use CollectionView instead of relying on ordered insert.
         m_userNetworkServices.Add(serviceSelection);
     }
     catch (ArgumentException)
     {
         // TODO: Duplicate item. CollectionView will eliminate requirement for this.
     }
 }