Пример #1
0
		void ChangeState (DialogState newState)
		{
			bool hasConfig = comboModel.Active == 0;

			switch (newState) {
			case DialogState.Create:
				btnBack.Visible = false;
				btnConfig.Visible = true;
				btnConfig.Sensitive = isWebService && hasConfig;
				btnOK.Visible = true;
				btnOK.Sensitive = isWebService;
				tlbNavigate.Visible = WebBrowserService.CanGetWebBrowser;
				tbxReferenceName.Sensitive = isWebService;
				comboModel.Sensitive = true;
				break;

			case DialogState.CreateConfig:
				btnBack.Visible = true;
				btnBack.Sensitive = true;
				btnConfig.Visible = false;
				btnOK.Visible = true;
				btnOK.Sensitive = true;
				tlbNavigate.Visible = false;
				tbxReferenceName.Sensitive = false;
				comboModel.Sensitive = false;
				break;

			case DialogState.Modify:
				btnBack.Visible = false;
				btnConfig.Visible = true;
				btnConfig.Sensitive = isWebService && hasConfig;
				btnOK.Visible = true;
				btnOK.Sensitive = isWebService;
				tlbNavigate.Visible = WebBrowserService.CanGetWebBrowser;
				tbxReferenceName.Sensitive = false;
				comboModel.Sensitive = false;
				break;

			case DialogState.ModifyConfig:
				btnBack.Visible = false;
				btnConfig.Visible = false;
				btnOK.Visible = true;
				btnOK.Sensitive = true;
				tlbNavigate.Visible = false;
				tbxReferenceName.Sensitive = false;
				comboModel.Sensitive = false;
				break;
				
			default:
				throw new InvalidOperationException ();
			}

			if (wcfConfig != null)
				wcfConfig.Update ();

			if (state == newState)
				return;

			if (state != DialogState.Uninitialized)
				frmBrowser.Forall (c => frmBrowser.Remove (c));

			browser = null;
			browserWidget = null;
			docLabel = null;
			wcfConfig = null;

			state = newState;
			
			ScrolledWindow sw;

			switch (state) {
			case DialogState.Create:
			case DialogState.Modify:
				if (WebBrowserService.CanGetWebBrowser) {
					browser = WebBrowserService.GetWebBrowser ();
					browserWidget = (Widget) browser;
					browser.LocationChanged += Browser_LocationChanged;
					browser.NetStart += Browser_StartLoading;
					browser.NetStop += Browser_StopLoading;
					frmBrowser.Add (browserWidget);
					browser.LoadUrl (tbxReferenceURL.Text);
					browserWidget.Show ();
				} else {
					docLabel = new Label ();
					docLabel.Xpad = 6;
					docLabel.Ypad = 6;
					docLabel.Xalign = 0;
					docLabel.Yalign = 0;

					sw = new ScrolledWindow ();
					sw.ShadowType = ShadowType.In;
					sw.AddWithViewport (docLabel);
					sw.ShowAll ();
					frmBrowser.Add (sw);
					UpdateLocation ();
				}
				break;

			case DialogState.ModifyConfig:
			case DialogState.CreateConfig:
				if (!hasConfig)
					return;

				sw = new ScrolledWindow ();
				sw.ShadowType = ShadowType.In;

				wcfConfig = new WCFConfigWidget (wcfOptions);
				sw.AddWithViewport (wcfConfig);
				sw.ShowAll ();
				frmBrowser.Add (sw);
				break;

			default:
				throw new InvalidOperationException ();
			}
		}
Пример #2
0
        void ChangeState(DialogState newState)
        {
            bool hasConfig = comboModel.Active == 0;

            switch (newState)
            {
            case DialogState.Create:
                btnBack.Visible            = false;
                btnConfig.Visible          = true;
                btnConfig.Sensitive        = isWebService && hasConfig;
                btnOK.Visible              = true;
                btnOK.Sensitive            = isWebService;
                tlbNavigate.Visible        = WebBrowserService.CanGetWebBrowser;
                tbxReferenceName.Sensitive = isWebService;
                comboModel.Sensitive       = !project.IsPortableLibrary;
                break;

            case DialogState.CreateConfig:
                btnBack.Visible            = true;
                btnBack.Sensitive          = true;
                btnConfig.Visible          = false;
                btnOK.Visible              = true;
                btnOK.Sensitive            = true;
                tlbNavigate.Visible        = false;
                tbxReferenceName.Sensitive = false;
                comboModel.Sensitive       = false;
                break;

            case DialogState.Modify:
                btnBack.Visible            = false;
                btnConfig.Visible          = true;
                btnConfig.Sensitive        = isWebService && hasConfig;
                btnOK.Visible              = true;
                btnOK.Sensitive            = isWebService;
                tlbNavigate.Visible        = WebBrowserService.CanGetWebBrowser;
                tbxReferenceName.Sensitive = false;
                comboModel.Sensitive       = false;
                break;

            case DialogState.ModifyConfig:
                btnBack.Visible            = false;
                btnConfig.Visible          = false;
                btnOK.Visible              = true;
                btnOK.Sensitive            = true;
                tlbNavigate.Visible        = false;
                tbxReferenceName.Sensitive = false;
                comboModel.Sensitive       = false;
                break;

            default:
                throw new InvalidOperationException();
            }

            if (wcfConfig != null)
            {
                wcfConfig.Update();
            }

            if (state == newState)
            {
                return;
            }

            if (state != DialogState.Uninitialized)
            {
                frmBrowser.Forall(frmBrowser.Remove);
            }

            browser       = null;
            browserWidget = null;
            docLabel      = null;
            wcfConfig     = null;

            state = newState;

            ScrolledWindow sw;

            switch (state)
            {
            case DialogState.Create:
            case DialogState.Modify:
                if (WebBrowserService.CanGetWebBrowser)
                {
                    browser                  = WebBrowserService.GetWebBrowser();
                    browserWidget            = (Widget)browser;
                    browser.LocationChanged += Browser_LocationChanged;
                    browser.NetStart        += Browser_StartLoading;
                    browser.NetStop         += Browser_StopLoading;
                    frmBrowser.Add(browserWidget);
                    browser.LoadUrl(tbxReferenceURL.Text);
                    browserWidget.Show();
                }
                else
                {
                    docLabel        = new Label();
                    docLabel.Xpad   = 6;
                    docLabel.Ypad   = 6;
                    docLabel.Xalign = 0;
                    docLabel.Yalign = 0;

                    sw            = new ScrolledWindow();
                    sw.ShadowType = ShadowType.In;
                    sw.AddWithViewport(docLabel);
                    sw.ShowAll();
                    frmBrowser.Add(sw);
                    UpdateLocation();
                }
                break;

            case DialogState.ModifyConfig:
            case DialogState.CreateConfig:
                if (!hasConfig)
                {
                    return;
                }

                sw            = new ScrolledWindow();
                sw.ShadowType = ShadowType.In;

                wcfConfig = new WCFConfigWidget(wcfOptions, wcfProject);
                sw.AddWithViewport(wcfConfig);
                sw.ShowAll();
                frmBrowser.Add(sw);
                break;

            default:
                throw new InvalidOperationException();
            }
        }