Example #1
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            Window.Title = Constants.Name + " - " + LanguageManager.GetText("WindowsProviderEditOpenVPNTitle");

            GuiUtils.SetButtonCancel(Window, CmdCancel);
            GuiUtils.SetButtonDefault(Window, CmdOk);

            LblTitle.Title          = Provider.DefinitionTitle;
            LblSubtitle.StringValue = Provider.DefinitionSubTitle;

            GuiUtils.SetCheck(ChkEnabled, Provider.Enabled);
            TxtTitle.StringValue = Provider.Title;
            TxtPath.StringValue  = Provider.Path;

            ChkSupportIPv6.Title = LanguageManager.GetText("WindowsProviderEditOpenVPNSupportIPv6");
            GuiUtils.SetCheck(ChkSupportIPv6, Provider.SupportIPv6);

            TxtAuthPassUsername.StringValue = Provider.AuthPassUsername;
            TxtAuthPassPassword.StringValue = Provider.AuthPassPassword;

            LblTitle.Activated += (object sender, EventArgs e) =>
            {
                Core.Platform.Instance.OpenUrl(Provider.DefinitionHref);
            };

            CmdPathBrowse.Activated += (object sender, EventArgs e) =>
            {
                GuiUtils.SelectPath(this.Window, TxtPath);
            };

            CmdOk.Activated += (object sender, EventArgs e) =>
            {
                Provider.Enabled     = GuiUtils.GetCheck(ChkEnabled);
                Provider.Title       = TxtTitle.StringValue;
                Provider.Path        = TxtPath.StringValue;
                Provider.SupportIPv6 = GuiUtils.GetCheck(ChkSupportIPv6);

                Provider.AuthPassUsername = TxtAuthPassUsername.StringValue;
                Provider.AuthPassPassword = TxtAuthPassPassword.StringValue;

                Window.Close();
                NSApplication.SharedApplication.StopModal();
            };

            CmdCancel.Activated += (object sender, EventArgs e) =>
            {
                Provider = null;

                Window.Close();
                NSApplication.SharedApplication.StopModal();
            };
        }