Beispiel #1
0
        partial void change8021XProfile(NSObject sender)
        {
            var index = joinUser8021XProfilePopupButton.IndexOfSelectedItem;

            if (index >= 0)
            {
                CW8021XProfile tmp = CW8021XProfile.AllUser8021XProfiles[index];
                if (tmp != null)
                {
                    if (String.Equals(joinUser8021XProfilePopupButton.SelectedItem.Title, "Default"))
                    {
                        joinUsernameField.StringValue   = String.Empty;
                        joinUsernameField.Enabled       = true;
                        joinPassphraseField.StringValue = String.Empty;
                        joinPassphraseField.Enabled     = true;
                    }
                    else
                    {
                        joinUsernameField.StringValue   = tmp.Username;
                        joinUsernameField.Enabled       = false;
                        joinPassphraseField.StringValue = tmp.Password;
                        joinPassphraseField.Enabled     = false;
                    }
                }
            }
        }
Beispiel #2
0
        partial void joinOKButtonPressed(NSObject sender)
        {
            CW8021XProfile profile = null;

            joinSpinner.Hidden = false;
            joinSpinner.StartAnimation(Window);

            if (joinUser8021XProfilePopupButton.Enabled)
            {
                if (String.Equals(joinUser8021XProfilePopupButton, "Default"))
                {
                    profile                 = CW8021XProfile.Profile;
                    profile.Ssid            = joinNetworkNameField.StringValue;
                    profile.UserDefinedName = joinNetworkNameField.StringValue;
                    profile.Username        = !String.IsNullOrEmpty(joinUsernameField.StringValue) ? joinUsernameField.StringValue : null;
                    profile.Password        = !String.IsNullOrEmpty(joinPassphraseField.StringValue) ? joinPassphraseField.StringValue : null;
                }
                else
                {
                    var index = joinUser8021XProfilePopupButton.IndexOfSelectedItem;
                    if (index >= 0)
                    {
                        profile = CW8021XProfile.AllUser8021XProfiles[index];
                    }
                }
            }

            if (JoinDialogContext)
            {
                NSMutableDictionary param = new NSMutableDictionary();
                if (profile != null)
                {
                    param.SetValueForKey(profile, CWConstants.CWAssocKey8021XProfile);
                }

                else
                {
                    param.SetValueForKey(!String.IsNullOrEmpty(joinPassphraseField.StringValue) ? joinPassphraseField.ObjectValue: null, CWConstants.CWAssocKeyPassPhrase);
                }

                NSError error  = null;
                bool    result = CurrentInterface.AssociateToNetwork(SelectedNetwork, NSDictionary.FromDictionary(param), out error);

                joinSpinner.StopAnimation(Window);
                joinSpinner.Hidden = true;

                if (!result)
                {
                    NSAlert.WithError(error).RunModal();
                }

                else
                {
                    joinCancelButtonPressed(this);
                }
            }
        }
        partial void joinButtonPressed(NSObject sender)
        {
            int index = scanResultsTable.SelectedRow;

            if (index >= 0)
            {
                ResetDialog();

                SelectedNetwork = ScanResults[index];
                joinNetworkNameField.StringValue = SelectedNetwork.Ssid;
                joinNetworkNameField.Enabled     = false;
                joinSecurityPopupButton.SelectItem(StringForSecurityMode(SelectedNetwork.SecurityMode));
                joinSecurityPopupButton.Enabled = false;

                changeSecurityMode(null);

                CWWirelessProfile wProfile = SelectedNetwork.WirelessProfile;
                CW8021XProfile    xProfile = wProfile.User8021XProfile;

                switch ((CWSecurityMode)SelectedNetwork.SecurityMode.IntValue)
                {
                case CWSecurityMode.CWSecurityModeWPA_PSK:
                case CWSecurityMode.CWSecurityModeWPA2_PSK:
                case CWSecurityMode.CWSecurityModeWEP:
                    if (!String.IsNullOrEmpty(wProfile.Passphrase))
                    {
                        joinPassphraseField.StringValue = wProfile.Passphrase;
                    }
                    break;

                case CWSecurityMode.CWSecurityModeOpen:
                    break;

                case CWSecurityMode.CWSecurityModeWPA_Enterprise:
                case CWSecurityMode.CWSecurityModeWPA2_Enterprise:
                    if (xProfile != null)
                    {
                        joinUser8021XProfilePopupButton.SelectItem(xProfile.UserDefinedName);
                        joinUsernameField.StringValue   = xProfile.Username;
                        joinUsernameField.Enabled       = false;
                        joinPassphraseField.StringValue = xProfile.Password;
                        joinPassphraseField.Enabled     = false;
                    }
                    break;
                }

                joinDialogWindow.MakeFirstResponder(joinNetworkNameField);

                JoinDialogContext = true;
                NSApplication.SharedApplication.BeginSheet(joinDialogWindow, Window, delegate
                {
                    JoinDialogContext = false;
                });
            }
        }