private void HandleVersionIdChanged (InfoBox box, uint version_id)
		{
			Photo p = item.Current as Photo;
			PhotoQuery q = item.Collection as PhotoQuery;

			if (p !=  null && q != null) {
				p.DefaultVersionId  = version_id;
				q.Commit (item.Index);
			}
		}
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            GMarker marker = new GMarker(new GLatLng(35.68, 139.69));

            InfoBoxOptions options = new InfoBoxOptions();

            options.PixelOffset = new GSize(-140, 0);
            options.BoxStyle = "{ opacity: 0.75, width: '280px' }";

            InfoBox infoBox = new InfoBox(marker, "<div class=\"box\">I'm an info box!</div>", true, options);

            GMap1.Add(new GControl(GControl.preBuilt.ScaleControl));

            GMap1.setCenter(new GLatLng(35.68, 139.69));

            GMap1.Add(infoBox);
        }
        private void UploadButton_Click(object sender, EventArgs e)
        {
            if (!ValidateConnectionStatus())
            {
                return;
            }

            m_worker.RunWorkerAsync(new AsyncProcessWrapper(worker =>
            {
                try
                {
                    UpdateUI(SaveWorkspace);
                    WriteConfiguration();
                }
                catch (Exception ex)
                {
                    Trace.Warn(ex);
                    InfoBox.Show(GetErrorMessage("uploading settings"));
                }
            }));
        }
Example #4
0
        protected static bool NonQueryData(string querySql)
        {
            var cmd = new MySqlCommand(querySql, _conn);

            try
            {
                _conn.Open();
                cmd.ExecuteNonQuery();
                return(true);
            }
            catch (Exception ex)
            {
                InfoBox.ErrorMsg("数据库操作错误,请检查数据库连接或联系管理员");
                LogControl.LogError("db operation error", ex);
                return(false);
            }
            finally
            {
                _conn.Close();
            }
        }
Example #5
0
 private void SaveMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         m_backupManager.CreateBackup(m_firmwareFile, m_configuration.BackupCreationMode);
         if (m_firmware.IsEncrypted)
         {
             m_loader.SaveEncrypted(m_firmwareFile, m_firmware);
         }
         else if (m_firmware.IsEncrypted == false)
         {
             m_loader.SaveDecrypted(m_firmwareFile, m_firmware);
         }
         m_tabPages.ForEach(x => x.IsDirty = false);
         StatusLabel.Text = @"Firmware file saved.";
     }
     catch (Exception ex)
     {
         InfoBox.Show("Unable to save firmware.\n{0}", ex.Message);
     }
 }
        private async void OpenJob(object sender, RoutedEventArgs e)
        {
            var dlg = new OpenFileDialog
            {
                Filter      = "JoinerSplitter job file (*.jsj)|*.jsj",
                DefaultExt  = ".jsj",
                Multiselect = false
            };

            var result = dlg.ShowDialog();

            if (result == false)
            {
                return;
            }

            var infobox = InfoBox.Show(this, "Retrieving video files details...");

            await OpenJob(dlg.FileName);

            infobox.Close();
        }
Example #7
0
        protected static bool NonQueryData(string querySql, DataTable dt)
        {
            var dataAdapter = new MySqlDataAdapter();

            try
            {
                _conn.Open();
                dataAdapter.SelectCommand = new MySqlCommand(querySql, _conn);
                var mySqlCommandBuilder = new MySqlCommandBuilder(dataAdapter);
                dataAdapter.Update(dt);
                return(true);
            }
            catch (Exception ex)
            {
                InfoBox.ErrorMsg("数据库操作错误,请检查数据库连接或联系管理员");
                LogControl.LogError("db operation error", ex);
                return(false);
            }
            finally
            {
                _conn.Close();
            }
        }
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            this.txtApplicationName = new ValidatingTextBox
            {
                Required = true,
                Width = 300,
                ValidationExpression = "[0-9a-zA-Z]+"
            };
            try
            {
                txtApplicationName.Text = (Environment.UserDomainName ?? "").ToLowerInvariant() + "Extension";
                if (!string.IsNullOrEmpty(txtApplicationName.Text))
                    txtApplicationName.Text = txtApplicationName.Text[0].ToString().ToUpperInvariant() + txtApplicationName.Text.Substring(1);
            }
            catch {}

            this.txtApplicationName.ServerValidate +=
                (s, e) =>
                {
                    var applications = StoredProcs.Applications_GetApplications(null).Execute();
                    if (applications.Any(app => app.Application_Name.Equals(this.txtApplicationName.Text, StringComparison.OrdinalIgnoreCase)))
                        e.IsValid = false;
                };

            bool hasProviders = StoredProcs.Providers_GetProviders(Domains.ProviderTypes.SourceControl).Execute().Any();
            var ddlProvider = new ActionProviderPicker
            {
                AllowNameEntry = false,
                ProviderTypeCode = Domains.ProviderTypes.SourceControl,
                Visible = hasProviders
            };

            var ctlNoProviders = new InfoBox
            {
                BoxType = InfoBox.InfoBoxTypes.Error,
                Controls = { new LiteralControl("There are no source control providers set up in BuildMaster. Visit the <a href=\"/Administration/Providers/Overview.aspx?providerTypeCode=S\">Source Control Providers page</a> to add one.") },
                Visible = !hasProviders
            };

            var ctlMoreThanOneProject = new InfoBox
            {
                BoxType = InfoBox.InfoBoxTypes.Error,
                Controls = { new LiteralControl("There was more than one project in this solution. This application recipe only supports single-project solutions. Please go back to the previous step and select an extension solution with only one project.") },
                Visible = false
            };

            var ctlOneProject = new InfoBox
            {
                BoxType = InfoBox.InfoBoxTypes.Success,
                Controls = { new LiteralControl("There solution contains a single project. You may advance to the summary step.") }
            };

            var ctlSolutionPath = new SourceControlFileFolderPicker
            {
                DisplayMode = SourceControlBrowser.DisplayModes.FoldersAndFiles,
                BindToActionSourceControlProvider = true,
                Width = 300
            };

            var ffSolutionPath = new StandardFormField("Path of solution file (.sln):", ctlSolutionPath);

            this.wizardSteps.SelectOrganizationName.Controls.Add(
                new FormFieldGroup(
                    "Application Name",
                    "For custom extensions, the name should be <em>InitechExtension</em>, where \"Initech\" is your company's name. There's no need to have more than one custom extension per organization<br /><br />" 
                    + "For cloning BuildMaster extensions, use the exact name of the extension, for example <em>WindowsSdk</em><br /><br />.",
                    false,
                    new StandardFormField(
                        "Application Name (alpha-numeric only):",
                        txtApplicationName
                    )
                )
            );

            txtApplicationName.Load += (s, e) => this.wizardSteps.DownloadInstructions.ApplicationName = txtApplicationName.Text;

            this.wizardSteps.SelectProviderAndSolution.Controls.Add(
                new FormFieldGroup(
                    "Source Control",
                    "Select the Source Control Provider and the path to the extension's solution file.",
                    true,
                    new StandardFormField(
                        "Source Control Provider:",
                        ddlProvider,
                        ctlNoProviders,
                        new Div(
                            new ActionServerPicker { ID = "bm-action-server-id" }
                        ) { Style = "display: none;" }
                    ),
                    ffSolutionPath
                )
            );
            this.WizardStepChange +=
                (s, e) =>
                {
                    if (e.CurrentStep != this.wizardSteps.SelectProviderAndSolution)
                        return;

                    this.ProviderId = (int)ddlProvider.ProviderId;

                    using (var proxy = Util.Proxy.CreateProviderProxy(this.ProviderId))
                    {
                        var scm = proxy.TryGetService<SourceControlProviderBase>();
                        byte[] fileBytes = scm.GetFileContents(ctlSolutionPath.Text);

                        if (ctlSolutionPath.Text.EndsWith(".sln", StringComparison.OrdinalIgnoreCase))
                        {
                            var solution = Solution.Load(new MemoryStream(fileBytes));

                            if (solution.Projects.Count > 1)
                            {
                                ctlMoreThanOneProject.Visible = true;
                                ctlOneProject.Visible = false;
                            }

                            this.SolutionPath = new ProjectInfo(scm.DirectorySeparator, ctlSolutionPath.Text).ScmDirectoryName;
                            this.Project = new ProjectInfo(scm.DirectorySeparator, new ProjectInfo(scm.DirectorySeparator, ctlSolutionPath.Text).ProjectFileName);
                        }
                    }
                };

            this.wizardSteps.OneProjectVerification.Controls.Add(
                new FormFieldGroup(
                    "One Project Verification",
                    "This step ensures that there is only one project in the selected solution.",
                    true,
                    new StandardFormField(
                        "",
                        ctlMoreThanOneProject,
                        ctlOneProject
                    )
                )
            );

            this.wizardSteps.Confirmation.Controls.Add(
                new FormFieldGroup(
                    "Summary",
                    "This is a summary of the details of the application that will be created. The application's deployment plan may be modified after creation if necessary.",
                    true,
                    new StandardFormField(
                        "",
                        new Summary(this)
                    )
                )
            );
        }
	//
	// Constructor
	//
	public MainWindow (Db db)
	{
		this.db = db;

		if (Toplevel == null)
			Toplevel = this;

		Glade.XML gui = new Glade.XML (null, "f-spot.glade", "main_window", "f-spot");
		gui.Autoconnect (this);

		LoadPreference (Preferences.MAIN_WINDOW_WIDTH);
		LoadPreference (Preferences.MAIN_WINDOW_X);
		LoadPreference (Preferences.MAIN_WINDOW_MAXIMIZED);
		main_window.ShowAll ();

		LoadPreference (Preferences.SIDEBAR_POSITION);
		LoadPreference (Preferences.METADATA_EMBED_IN_IMAGE);

		LoadPreference (Preferences.COLOR_MANAGEMENT_ENABLED);
 		LoadPreference (Preferences.COLOR_MANAGEMENT_USE_X_PROFILE);
 		FSpot.ColorManagement.LoadSettings();
	
#if GTK_2_10
		pagesetup_menu_item.Activated += HandlePageSetupActivated;
#else
		pagesetup_menu_item.Visible = false;
#endif
		toolbar = new Gtk.Toolbar ();
		toolbar_vbox.PackStart (toolbar);

		ToolButton import_button = GtkUtil.ToolButtonFromTheme ("gtk-add", Catalog.GetString ("Import"), false);
		import_button.Clicked += HandleImportCommand;
		import_button.SetTooltip (ToolTips, Catalog.GetString ("Import new images"), null);
		toolbar.Insert (import_button, -1);
	
		toolbar.Insert (new SeparatorToolItem (), -1);

		ToolButton rl_button = GtkUtil.ToolButtonFromTheme ("object-rotate-left", Catalog.GetString ("Rotate Left"), true);
		rl_button.Clicked += HandleRotate270Command;
		toolbar.Insert (rl_button, -1);

		ToolButton rr_button = GtkUtil.ToolButtonFromTheme ("object-rotate-right", Catalog.GetString ("Rotate Right"), true);
		rr_button.Clicked += HandleRotate90Command;
		toolbar.Insert (rr_button, -1);

		toolbar.Insert (new SeparatorToolItem (), -1);

		browse_button = new ToggleToolButton ();
		browse_button.Label = Catalog.GetString ("Browse");
		browse_button.IconName = "mode-browse";
		browse_button.IsImportant = true;
		browse_button.Toggled += HandleToggleViewBrowse;
		browse_button.SetTooltip (ToolTips, Catalog.GetString ("Browse many photos simultaneously"), null);
		toolbar.Insert (browse_button, -1);

		edit_button = new ToggleToolButton ();
		edit_button.Label = Catalog.GetString ("Edit Image");
		edit_button.IconName = "mode-image-edit";
		edit_button.IsImportant = true;
		edit_button.Toggled += HandleToggleViewPhoto;
		edit_button.SetTooltip (ToolTips, Catalog.GetString ("View and edit a photo"), null);
		toolbar.Insert (edit_button, -1);

		toolbar.Insert (new SeparatorToolItem (), -1);

		ToolButton fs_button = GtkUtil.ToolButtonFromTheme ("view-fullscreen", Catalog.GetString ("Fullscreen"), true);
		fs_button.Clicked += HandleViewFullscreen;
		fs_button.SetTooltip (ToolTips, Catalog.GetString ("View photos fullscreen"), null);
		toolbar.Insert (fs_button, -1);

		ToolButton ss_button = GtkUtil.ToolButtonFromTheme ("media-playback-start", Catalog.GetString ("Slideshow"), true);
		ss_button.Clicked += HandleViewSlideShow;
		ss_button.SetTooltip (ToolTips, Catalog.GetString ("View photos in a slideshow"), null);
		toolbar.Insert (ss_button, -1);

		SeparatorToolItem white_space = new SeparatorToolItem ();
		white_space.Draw = false;
		white_space.Expand = true;
		toolbar.Insert (white_space, -1);

		ToolItem label_item = new ToolItem ();
		count_label = new Label (String.Empty);
		label_item.Child = count_label;
		toolbar.Insert (label_item, -1);

		display_previous_button = new ToolButton (Stock.GoBack);
		toolbar.Insert (display_previous_button, -1);
		display_previous_button.SetTooltip (ToolTips, Catalog.GetString ("Previous photo"), String.Empty);
		display_previous_button.Clicked += new EventHandler (HandleDisplayPreviousButtonClicked);

		display_next_button = new ToolButton (Stock.GoForward);
		toolbar.Insert (display_next_button, -1);
		display_next_button.SetTooltip (ToolTips, Catalog.GetString ("Next photo"), String.Empty);
		display_next_button.Clicked += new EventHandler (HandleDisplayNextButtonClicked);

		sidebar = new Sidebar ();
		ViewModeChanged += sidebar.HandleMainWindowViewModeChanged;
		sidebar_vbox.Add (sidebar);

		tag_selection_scrolled = new ScrolledWindow ();
		tag_selection_scrolled.ShadowType = ShadowType.In;
		
		tag_selection_widget = new TagSelectionWidget (db.Tags);
		tag_selection_scrolled.Add (tag_selection_widget);

		sidebar.AppendPage (tag_selection_scrolled, Catalog.GetString ("Tags"), "tag");

		AddinManager.AddExtensionNodeHandler ("/FSpot/Sidebar", OnSidebarExtensionChanged);

		sidebar.Context = ViewContext.Library;
 		
		sidebar.CloseRequested += HideSidebar;
		sidebar.Show ();

		info_box = new InfoBox ();
		ViewModeChanged += info_box.HandleMainWindowViewModeChanged;
		info_box.VersionIdChanged += delegate (InfoBox box, uint version_id) { UpdateForVersionIdChange (version_id);};
		sidebar_vbox.PackEnd (info_box, false, false, 0);

		info_box.Context = ViewContext.Library;
		
		tag_selection_widget.Selection.Changed += HandleTagSelectionChanged;
		tag_selection_widget.DragDataGet += HandleTagSelectionDragDataGet;
		tag_selection_widget.DragDrop += HandleTagSelectionDragDrop;
		tag_selection_widget.DragBegin += HandleTagSelectionDragBegin;
		tag_selection_widget.KeyPressEvent += HandleTagSelectionKeyPress;
		Gtk.Drag.SourceSet (tag_selection_widget, Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask,
				    tag_target_table, DragAction.Copy | DragAction.Move);

		tag_selection_widget.DragDataReceived += HandleTagSelectionDragDataReceived;
		tag_selection_widget.DragMotion += HandleTagSelectionDragMotion;
		Gtk.Drag.DestSet (tag_selection_widget, DestDefaults.All, tag_dest_target_table, 
				  DragAction.Copy | DragAction.Move ); 

		tag_selection_widget.ButtonPressEvent += HandleTagSelectionButtonPressEvent;
		tag_selection_widget.PopupMenu += HandleTagSelectionPopupMenu;
		tag_selection_widget.RowActivated += HandleTagSelectionRowActivated;
		
		LoadPreference (Preferences.TAG_ICON_SIZE);
		
		try {
			query = new FSpot.PhotoQuery (db.Photos);
		} catch (System.Exception e) {
			//FIXME assume any exception here is due to a corrupt db and handle that.
			new RepairDbDialog (e, db.Repair (), main_window);
			query = new FSpot.PhotoQuery (db.Photos);
		}

		UpdateStatusLabel ();
		query.Changed += HandleQueryChanged;

		db.Photos.ItemsChanged += HandleDbItemsChanged;
		db.Tags.ItemsChanged += HandleTagsChanged;
		db.Tags.ItemsAdded += HandleTagsChanged;
		db.Tags.ItemsRemoved += HandleTagsChanged;
#if SHOW_CALENDAR
		FSpot.SimpleCalendar cal = new FSpot.SimpleCalendar (query);
		cal.DaySelected += HandleCalendarDaySelected;
		left_vbox.PackStart (cal, false, true, 0);
#endif

		group_selector = new FSpot.GroupSelector ();
		group_selector.Adaptor = new FSpot.TimeAdaptor (query, Preferences.Get<bool> (Preferences.GROUP_ADAPTOR_ORDER_ASC));

		group_selector.ShowAll ();
		
		if (zoom_scale != null) {
			zoom_scale.ValueChanged += HandleZoomScaleValueChanged;
		}

		view_vbox.PackStart (group_selector, false, false, 0);
		view_vbox.ReorderChild (group_selector, 0);

		find_bar = new FindBar (query, tag_selection_widget.Model);
		view_vbox.PackStart (find_bar, false, false, 0);
		view_vbox.ReorderChild (find_bar, 1);
		main_window.KeyPressEvent += HandleKeyPressEvent;
		
		query_widget = new FSpot.QueryWidget (query, db, tag_selection_widget);
		query_widget.Logic.Changed += HandleQueryLogicChanged;
		view_vbox.PackStart (query_widget, false, false, 0);
		view_vbox.ReorderChild (query_widget, 2);

		icon_view = new QueryView (query);
		icon_view.ZoomChanged += HandleZoomChanged;
		LoadPreference (Preferences.ZOOM);
		LoadPreference (Preferences.SHOW_TAGS);
		LoadPreference (Preferences.SHOW_DATES);
		LoadPreference (Preferences.SHOW_RATINGS);
		icon_view_scrolled.Add (icon_view);
		icon_view.DoubleClicked += HandleDoubleClicked;
		icon_view.Vadjustment.ValueChanged += HandleIconViewScroll;
		icon_view.GrabFocus ();

		new FSpot.PreviewPopup (icon_view);

		Gtk.Drag.SourceSet (icon_view, Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask,
				    icon_source_target_table, DragAction.Copy | DragAction.Move);
		
		icon_view.DragBegin += HandleIconViewDragBegin;
		icon_view.DragDataGet += HandleIconViewDragDataGet;

		TagMenu tag_menu = new TagMenu (null, Database.Tags);
		tag_menu.NewTagHandler += delegate { HandleCreateTagAndAttach (this, null); };
		tag_menu.TagSelected += HandleAttachTagMenuSelected;
		tag_menu.Populate();
		attach_tag.Submenu = tag_menu;
		
		PhotoTagMenu pmenu = new PhotoTagMenu ();
		pmenu.TagSelected += HandleRemoveTagMenuSelected;
		remove_tag.Submenu = pmenu;
		
		Gtk.Drag.DestSet (icon_view, DestDefaults.All, icon_dest_target_table, 
				  DragAction.Copy | DragAction.Move); 

		//		icon_view.DragLeave += new DragLeaveHandler (HandleIconViewDragLeave);
		icon_view.DragMotion += HandleIconViewDragMotion;
		icon_view.DragDrop += HandleIconViewDragDrop;
		icon_view.DragDataReceived += HandleIconViewDragDataReceived;
		icon_view.KeyPressEvent += HandleIconViewKeyPressEvent;

		photo_view = new PhotoView (query);
		photo_box.Add (photo_view);

		photo_view.DoubleClicked += HandleDoubleClicked;
		photo_view.KeyPressEvent += HandlePhotoViewKeyPressEvent;
		photo_view.UpdateStarted += HandlePhotoViewUpdateStarted;
		photo_view.UpdateFinished += HandlePhotoViewUpdateFinished;

		photo_view.View.ZoomChanged += HandleZoomChanged;

		// Tag typing: focus the tag entry if the user starts typing a tag
		icon_view.KeyPressEvent += HandlePossibleTagTyping;
		photo_view.KeyPressEvent += HandlePossibleTagTyping;
		tag_entry = new TagEntry (db.Tags);
		tag_entry.KeyPressEvent += HandleTagEntryKeyPressEvent;
		tag_entry.TagsAttached += HandleTagEntryTagsAttached;
		tag_entry.TagsRemoved += HandleTagEntryRemoveTags;
		tag_entry.Activated += HandleTagEntryActivate;
		tag_entry_container.Add (tag_entry);

		Gtk.Drag.DestSet (photo_view, DestDefaults.All, tag_target_table, 
				  DragAction.Copy | DragAction.Move); 

		photo_view.DragMotion += HandlePhotoViewDragMotion;
		photo_view.DragDrop += HandlePhotoViewDragDrop;
		photo_view.DragDataReceived += HandlePhotoViewDragDataReceived;

		view_notebook.SwitchPage += HandleViewNotebookSwitchPage;
		group_selector.Adaptor.GlassSet += HandleAdaptorGlassSet;
		group_selector.Adaptor.Changed += HandleAdaptorChanged;
		LoadPreference (Preferences.GROUP_ADAPTOR);
		LoadPreference (Preferences.GROUP_ADAPTOR_ORDER_ASC);

		this.selection = new MainSelection (this);
		this.selection.Changed += HandleSelectionChanged;
		this.selection.ItemsChanged += HandleSelectionItemsChanged;
		this.selection.Changed += sidebar.HandleSelectionChanged;
		this.selection.ItemsChanged += sidebar.HandleSelectionItemsChanged;

		Mono.Addins.AddinManager.ExtensionChanged += PopulateExtendableMenus;
		PopulateExtendableMenus (null, null);

		UpdateMenus ();

		main_window.ShowAll ();

		tagbar.Hide ();
		find_bar.Hide ();

		UpdateFindByTagMenu ();

		LoadPreference (Preferences.SHOW_TOOLBAR);
		LoadPreference (Preferences.SHOW_SIDEBAR);
		LoadPreference (Preferences.SHOW_TIMELINE);
		LoadPreference (Preferences.SHOW_FILMSTRIP);

		LoadPreference (Preferences.GNOME_MAILTO_ENABLED);
		
		Preferences.SettingChanged += OnPreferencesChanged;

		main_window.DeleteEvent += HandleDeleteEvent;
		
		query_widget.HandleChanged (query);
		query_widget.Hide ();

		// When the icon_view is loaded, set it's initial scroll position
		icon_view.SizeAllocated += HandleIconViewReady;

		export.Activated += HandleExportActivated;
		UpdateToolbar ();

		Banshee.Kernel.Scheduler.Resume ();
	}
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            this.txtOrganizationName = new ValidatingTextBox()
            {
                Required = true,
                Width = 300
            };
            this.txtOrganizationName.ServerValidate += (s, e) =>
            {
                var applications = StoredProcs.Applications_GetApplications(null).Execute();
                if (applications.Any(app => app.Application_Name.Equals(this.txtOrganizationName.Text.Replace(" ", "") + "Extension", StringComparison.OrdinalIgnoreCase)))
                    e.IsValid = false;
            };

            var ddlProvider = new DropDownList { AutoPostBack = true };
            ddlProvider.Items.Add(new ListItem("", "0"));
            var providerItems = StoredProcs.Providers_GetProviders(
                    Domains.ProviderTypes.SourceControl,
                    null,
                    null
                ).Execute()
                .Select(p => new ListItem(p.Provider_Name, p.Provider_Id.ToString()))
                .ToArray();
            ddlProvider.Items.AddRange(providerItems);
            ddlProvider.Visible = providerItems.Any();

            var ctlNoProviders = new InfoBox()
            {
                BoxType = InfoBox.InfoBoxTypes.Error,
                Controls = { new LiteralControl("There are no source control providers set up in BuildMaster. Visit the <a href=\"/Administration/Providers/Overview.aspx?providerTypeCode=S\">Source Control Providers page</a> to add one.") },
                Visible = !providerItems.Any()
            };

            var ctlMoreThanOneProject = new InfoBox()
            {
                BoxType = InfoBox.InfoBoxTypes.Error,
                Controls = { new LiteralControl("There was more than one project in this solution. This application recipe only supports single-project solutions. Please go back to the previous step and select an extension solution with only one project.") },
                Visible = false
            };
            var ctlOneProject = new InfoBox()
            {
                BoxType = InfoBox.InfoBoxTypes.Success,
                Controls = { new LiteralControl("There solution contains a single project. You may advance to the summary step.") }
            };

            var ctlSolutionPath = new SourceControlFileFolderPicker() { DisplayMode = SourceControlBrowser.DisplayModes.FoldersAndFiles };

            var ffSolutionPath = new StandardFormField("Path of solution:", ctlSolutionPath) { Visible = false };

            ddlProvider.SelectedIndexChanged += (s, e) =>
            {
                ctlSolutionPath.SourceControlProviderId = int.Parse(ddlProvider.SelectedValue);
                this.ProviderId = ctlSolutionPath.SourceControlProviderId;
                ffSolutionPath.Visible = ctlSolutionPath.SourceControlProviderId > 0;
            };

            this.wizardSteps.SelectOrganizationName.Controls.Add(
                new FormFieldGroup(
                    "Organization Name",
                    "This should be your company or division name, e.g. \"Initech\". <br /><br />This is used to generate the sample code and also create the application name.",
                    true,
                    new StandardFormField(
                        "Organization Name:",
                        txtOrganizationName
                    )
                )
            );

            txtOrganizationName.Load += (S,E) => this.wizardSteps.DownloadInstructions.OrganizationName = txtOrganizationName.Text;

            this.wizardSteps.SelectProviderAndSolution.Controls.Add(
                new FormFieldGroup(
                    "Source Control",
                    "Select the Source Control Provider and the path to the extension's solution file.",
                    true,
                    new StandardFormField(
                        "Source Control Provider:",
                        ddlProvider,
                        ctlNoProviders
                    ),
                    ffSolutionPath
                )
            );
            this.WizardStepChange += (s, e) =>
            {
                if (e.CurrentStep != this.wizardSteps.SelectProviderAndSolution)
                    return;
                using (var scm = Util.Providers.CreateProviderFromId<SourceControlProviderBase>(ctlSolutionPath.SourceControlProviderId))
                {
                    var fileBytes = scm.GetFileContents(ctlSolutionPath.Text);
                    if (ctlSolutionPath.Text.EndsWith(".sln", StringComparison.OrdinalIgnoreCase))
                    {
                        var solution = Solution.Load(new MemoryStream(fileBytes));

                        if (solution.Projects.Count > 1)
                        {
                            ctlMoreThanOneProject.Visible = true;
                            ctlOneProject.Visible = false;
                        }

                        this.SolutionPath = new ProjectInfo(scm.DirectorySeparator, ctlSolutionPath.Text).ScmDirectoryName;
                        this.Project = new ProjectInfo(scm.DirectorySeparator, new ProjectInfo(scm.DirectorySeparator, ctlSolutionPath.Text).ProjectFileName);
                    }
                }
            };

            this.wizardSteps.OneProjectVerification.Controls.Add(
                new FormFieldGroup(
                    "One Project Verification",
                    "This step ensures that there is only one project in the selected solution.",
                    true,
                    new StandardFormField(
                        "",
                        ctlMoreThanOneProject,
                        ctlOneProject
                    )
                )
            );

            this.wizardSteps.Confirmation.Controls.Add(
                new FormFieldGroup(
                    "Summary",
                    "This is a summary of the details of the application that will be created. The application's deployment plan may be modified after creation if necessary.",
                    true,
                    new StandardFormField(
                        "",
                        new Summary(this)
                    )
                )
            );
        }
Example #11
0
        private void ShowStatistics()
        {
            LetsChangeDefinitions(1, 2);
            ColumnDefinition column = ColumnDefinitions.First();
            column.Width = new GridLength(180);

            InfoBox infoBox = new InfoBox();
            Grid.SetColumn(infoBox, 1);
            Children.Add(infoBox);

            StatisticsView statisticsView = new StatisticsView(context, infoBox);
            Children.Add(statisticsView);
        }
        private void CreateTfsConnectionControls()
        {
            var defaultCfg = (TfsConfigurer)this.GetExtensionConfigurer();
            var ctlError = new InfoBox { BoxType = InfoBox.InfoBoxTypes.Error, Visible = false };

            var txtBaseUrl = new ValidatingTextBox
            {
                Required = true,
                Text = defaultCfg.BaseUrl,
                DefaultText = "ex. http://tfsserver:8080/tfs"
            };

            var txtUserName = new ValidatingTextBox
            {
                DefaultText = "use system credentials",
                Text = defaultCfg.UserName
            };
            var txtPassword = new PasswordTextBox
            {
                Text = defaultCfg.Password
            };
            var txtDomain = new ValidatingTextBox
            {
                Text = defaultCfg.Domain
            };

            txtBaseUrl.ServerValidate +=
                (s, e) =>
                {
                    var configurer = new TfsConfigurer
                    {
                        BaseUrl = txtBaseUrl.Text,
                        UserName = txtUserName.Text,
                        Password = txtPassword.Text,
                        UseSystemCredentials = string.IsNullOrWhiteSpace(txtUserName.Text)
                    };

                    var errorMessage = configurer.TestConnection();
                    if (!string.IsNullOrEmpty(errorMessage))
                    {
                        e.IsValid = false;
                        ctlError.Visible = true;
                        ctlError.Controls.Add(new P("An error occurred while attempting to connect: " + errorMessage));
                    }
                };

            this.wizardSteps.TfsConnection.Controls.Add(
                ctlError,
                new SlimFormField("TFS collection URL:", txtBaseUrl
                )
                {
                    HelpText = "To use a specific collection, use http://tfsserver:8080/tfs/CollectionName as an example URL. The collection name may be omitted if the TFS server is configured to use the DefaultCollection at /tfs."
                },
                new SlimFormField("Username:"******"Password:"******"Domain:", txtDomain)
            );

            this.WizardStepChange += (s, e) =>
            {
                if (e.CurrentStep != this.wizardSteps.TfsConnection)
                    return;

                defaultCfg.BaseUrl = txtBaseUrl.Text;
                defaultCfg.UserName = txtUserName.Text;
                defaultCfg.Password = txtPassword.Text;
                var defaultProfile = StoredProcs
                        .ExtensionConfiguration_GetConfigurations(TfsConfigurer.TypeQualifiedName)
                        .Execute()
                        .Where(p => p.Default_Indicator == Domains.YN.Yes)
                        .FirstOrDefault() ?? new Tables.ExtensionConfigurations();

                StoredProcs
                    .ExtensionConfiguration_SaveConfiguration(
                        Util.NullIf(defaultProfile.ExtensionConfiguration_Id, 0),
                        TfsConfigurer.TypeQualifiedName,
                        defaultProfile.Profile_Name ?? "Default",
                        Util.Persistence.SerializeToPersistedObjectXml(defaultCfg),
                        Domains.YN.Yes)
                    .Execute();
            };
        }
        private void CreateTfsConnectionControls()
        {
            var defaultCfg = (TfsConfigurer)this.GetExtensionConfigurer();
            var ctlError = new InfoBox { BoxType = InfoBox.InfoBoxTypes.Error, Visible = false };

            var txtBaseUrl = new ValidatingTextBox
            {
                Required = true,
                Text = defaultCfg.BaseUrl,
                Width = 350
            };

            var txtUserName = new ValidatingTextBox
            {
                DefaultText = "System credentials",
                Text = defaultCfg.UserName,
                Width = 350
            };
            var txtPassword = new PasswordTextBox
            {
                Text = defaultCfg.Password,
                Width = 350
            };
            var txtDomain = new ValidatingTextBox
            {
                Text = defaultCfg.Domain,
                Width = 350
            };

            txtBaseUrl.ServerValidate +=
                (s, e) =>
                {
                    var configurer = new TfsConfigurer
                    {
                        BaseUrl = txtBaseUrl.Text,
                        UserName = txtUserName.Text,
                        Password = txtPassword.Text,
                        UseSystemCredentials = string.IsNullOrWhiteSpace(txtUserName.Text)
                    };

                    var errorMessage = configurer.TestConnection();
                    if (!string.IsNullOrEmpty(errorMessage))
                    {
                        e.IsValid = false;
                        ctlError.Visible = true;
                        ctlError.Controls.Add(new P("An error occurred while attempting to connect: " + errorMessage));
                    }
                };

            this.wizardSteps.TfsConnection.Controls.Add(
                ctlError,
                new FormFieldGroup("TFS Server Name",
                    "The name of the Team Foundation Server to connect to, e.g. http://tfsserver:8080/tfs",
                    false,
                    new StandardFormField("Server Name:", txtBaseUrl)
                ),
                new FormFieldGroup("Credentials",
                    "Specify the credentials of the account you would like to use to connect to Team Foundation Server",
                    false,
                    new StandardFormField("Username:"******"Password:"******"Domain:", txtDomain)
                )
            );

            this.WizardStepChange += (s, e) =>
            {
                if (e.CurrentStep != this.wizardSteps.TfsConnection)
                    return;

                defaultCfg.BaseUrl = txtBaseUrl.Text;
                defaultCfg.UserName = txtUserName.Text;
                defaultCfg.Password = txtPassword.Text;
                var defaultProfile = StoredProcs
                        .ExtensionConfiguration_GetConfigurations(TfsConfigurer.TypeQualifiedName)
                        .Execute()
                        .Where(p => p.Default_Indicator == Domains.YN.Yes)
                        .FirstOrDefault() ?? new Tables.ExtensionConfigurations();

                StoredProcs
                    .ExtensionConfiguration_SaveConfiguration(
                        Util.NullIf(defaultProfile.ExtensionConfiguration_Id, 0),
                        TfsConfigurer.TypeQualifiedName,
                        defaultProfile.Profile_Name ?? "Default",
                        Util.Persistence.SerializeToPersistedObjectXml(defaultCfg),
                        Domains.YN.Yes)
                    .Execute();
            };
        }
        private void CreateTeamCityConnectionControls()
        {
            var defaultCfg = TeamCityConfigurer.GetConfigurer(null) ?? new TeamCityConfigurer();
            var ctlError = new InfoBox { BoxType = InfoBox.InfoBoxTypes.Error, Visible = false };

            var txtServerUrl = new ValidatingTextBox
            {
                Required = true,
                Text = defaultCfg.ServerUrl,
                Width = 350
            };

            var txtUsername = new ValidatingTextBox
            {
                Text = defaultCfg.Username,
                Width = 350
            };
            var txtPassword = new PasswordTextBox
            {
                Text = defaultCfg.Password,
                Width = 350
            };

            txtServerUrl.ServerValidate += (s, e) =>
                {
                    var configurer = new TeamCityConfigurer
                    {
                        ServerUrl = txtServerUrl.Text,
                        Username = txtUsername.Text,
                        Password = txtPassword.Text
                    };
                    try
                    {
                        using (var client = new WebClient())
                        {
                            client.BaseAddress = configurer.BaseUrl;
                            if (!string.IsNullOrEmpty(configurer.Username))
                                client.Credentials = new NetworkCredential(configurer.Username, configurer.Password);

                            client.DownloadString("app/rest/buildTypes");
                        }
                    }
                    catch (Exception _e)
                    {
                        e.IsValid = false;
                        ctlError.Visible = true;
                        ctlError.Controls.Add(new P("An error occurred while attempting to connect: " + _e.Message));
                    }
                };

            this.wizardSteps.TeamCityConnection.Controls.Add(
                ctlError,
                new FormFieldGroup(
                    "TeamCity Server URL",
                    "Enter the URL of the TeamCity server, typically: http://teamcityserver",
                    false,
                    new StandardFormField("Server URL:", txtServerUrl)
                ),
                new FormFieldGroup(
                    "Authentication",
                    "If you wish to connect to the TeamCity server with HTTP Authentication, please enter the credentials. Leaving the username field blank will connect using guest authentication.",
                    true,
                    new StandardFormField("Username:"******"Password:"******"Default",
                        Util.Persistence.SerializeToPersistedObjectXml(defaultCfg),
                        Domains.YN.Yes)
                    .Execute();
            };
        }
	//
	// Constructor
	//
	public MainWindow (Db db)
	{
		this.db = db;

		if (Toplevel == null)
			Toplevel = this;

		Glade.XML gui = new Glade.XML (null, "f-spot.glade", "main_window", null);
		gui.Autoconnect (this);

		LoadPreference (Preferences.MAIN_WINDOW_WIDTH);
		LoadPreference (Preferences.MAIN_WINDOW_X);
		LoadPreference (Preferences.MAIN_WINDOW_MAXIMIZED);
		main_window.ShowAll ();

		LoadPreference (Preferences.SIDEBAR_POSITION);
		LoadPreference (Preferences.METADATA_EMBED_IN_IMAGE);
		
		slide_delay = new FSpot.Delay (new GLib.IdleHandler (SlideShow));
		
		toolbar = new Gtk.Toolbar ();
		toolbar_vbox.PackStart (toolbar);
	
		Widget import_button = GtkUtil.MakeToolbarButton (toolbar, "gtk-add", Catalog.GetString ("Import"), new System.EventHandler (HandleImportCommand));
		SetTip (import_button, Catalog.GetString ("Import photos"));
		toolbar.AppendSpace ();

		rl_button = GtkUtil.MakeToolbarButton (toolbar, "f-spot-rotate-270", new System.EventHandler (HandleRotate270Command));
		rr_button = GtkUtil.MakeToolbarButton (toolbar, "f-spot-rotate-90", new System.EventHandler (HandleRotate90Command));
		toolbar.AppendSpace ();
		
		// FIXME putting these two toggle buttons in a radio group would prevent
		// the two toggle sounds from being emitted every time you switch modes
		browse_button = GtkUtil.MakeToolbarToggleButton (toolbar, "f-spot-browse", 
								 new System.EventHandler (HandleToggleViewBrowse)) as ToggleButton;
		SetTip (browse_button, Catalog.GetString ("Browse many photos simultaneously"));
		edit_button = GtkUtil.MakeToolbarToggleButton (toolbar, "f-spot-edit-image", 
							       new System.EventHandler (HandleToggleViewPhoto)) as ToggleButton;
		SetTip (edit_button, Catalog.GetString ("View and edit a photo"));

		toolbar.AppendSpace ();

		Widget fs_button = GtkUtil.MakeToolbarButton (toolbar, "f-spot-fullscreen", new System.EventHandler (HandleViewFullscreen));
		SetTip (fs_button, Catalog.GetString ("View photos fullscreen"));
		
		Widget ss_button = GtkUtil.MakeToolbarButton (toolbar, "f-spot-slideshow", new System.EventHandler (HandleViewSlideShow));
		SetTip (ss_button, Catalog.GetString ("View photos in a slideshow"));

		tag_selection_widget = new TagSelectionWidget (db.Tags);
		tag_selection_scrolled.Add (tag_selection_widget);
		
		tag_selection_widget.Selection.Changed += HandleTagSelectionChanged;
		tag_selection_widget.DragDataGet += HandleTagSelectionDragDataGet;
		tag_selection_widget.DragDrop += HandleTagSelectionDragDrop;
		tag_selection_widget.DragBegin += HandleTagSelectionDragBegin;
		tag_selection_widget.KeyPressEvent += HandleTagSelectionKeyPress;
		Gtk.Drag.SourceSet (tag_selection_widget, Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask,
				    tag_target_table, DragAction.Copy | DragAction.Move);

		tag_selection_widget.DragDataReceived += HandleTagSelectionDragDataReceived;
		tag_selection_widget.DragMotion += HandleTagSelectionDragMotion;
		Gtk.Drag.DestSet (tag_selection_widget, DestDefaults.All, tag_dest_target_table, 
				  DragAction.Copy | DragAction.Move ); 

		tag_selection_widget.ButtonPressEvent += HandleTagSelectionButtonPressEvent;
		tag_selection_widget.PopupMenu += HandleTagSelectionPopupMenu;
		tag_selection_widget.RowActivated += HandleTagSelectionRowActivated;
		
		LoadPreference (Preferences.TAG_ICON_SIZE);

		info_box = new InfoBox ();
		info_box.VersionIdChanged += HandleInfoBoxVersionIdChange;
		left_vbox.PackStart (info_box, false, true, 0);
		
		try {
			query = new FSpot.PhotoQuery (db.Photos);
		} catch (System.Exception e) {
			//FIXME assume any exception here is due to a corrupt db and handle that.
			RestoreDb (e);
			query = new FSpot.PhotoQuery (db.Photos);
		}

		UpdateStatusLabel ();
		query.Changed += HandleQueryChanged;

		db.Photos.ItemsChanged += HandleDbItemsChanged;
		db.Tags.ItemsChanged += HandleTagsChanged;
		db.Tags.ItemsAdded += HandleTagsChanged;
		db.Tags.ItemsRemoved += HandleTagsChanged;
#if SHOW_CALENDAR
		FSpot.SimpleCalendar cal = new FSpot.SimpleCalendar (query);
		cal.DaySelected += HandleCalendarDaySelected;
		left_vbox.PackStart (cal, false, true, 0);
#endif

		group_selector = new FSpot.GroupSelector ();
		group_selector.Adaptor = new FSpot.TimeAdaptor (query);

		group_selector.ShowAll ();
		
		if (zoom_scale != null) {
			zoom_scale.ValueChanged += HandleZoomScaleValueChanged;
		}

		view_vbox.PackStart (group_selector, false, false, 0);
		view_vbox.ReorderChild (group_selector, 0);

		find_bar = new FindBar (query, tag_selection_widget.Model);
		//find_bar = new FindBar (query, db.Tags);
		view_vbox.PackStart (find_bar, false, false, 0);
		main_window.KeyPressEvent += HandleKeyPressEvent;
		
		query_widget = new FSpot.QueryWidget (query, db, tag_selection_widget);
		query_widget.Logic.Changed += HandleQueryLogicChanged;
		view_vbox.PackStart (query_widget, false, false, 0);
		view_vbox.ReorderChild (query_widget, 1);

		icon_view = new QueryView (query);
		icon_view.ZoomChanged += HandleZoomChanged;
		LoadPreference (Preferences.ZOOM);
		LoadPreference (Preferences.SHOW_TAGS);
		LoadPreference (Preferences.SHOW_DATES);
		icon_view_scrolled.Add (icon_view);
		icon_view.DoubleClicked += HandleDoubleClicked;
		icon_view.Vadjustment.ValueChanged += HandleIconViewScroll;
		icon_view.GrabFocus ();

		new FSpot.PreviewPopup (icon_view);

		Gtk.Drag.SourceSet (icon_view, Gdk.ModifierType.Button1Mask | Gdk.ModifierType.Button3Mask,
				    icon_source_target_table, DragAction.Copy | DragAction.Move);
		
		icon_view.DragBegin += HandleIconViewDragBegin;
		icon_view.DragDataGet += HandleIconViewDragDataGet;

		near_image.SetFromStock ("f-spot-stock_near", IconSize.SmallToolbar);
		far_image.SetFromStock ("f-spot-stock_far", IconSize.SmallToolbar);

		PhotoTagMenu pmenu = new PhotoTagMenu ();
		pmenu.TagSelected += HandleRemoveTagMenuSelected;
		remove_tag.Submenu = pmenu;
		
		Gtk.Drag.DestSet (icon_view, DestDefaults.All, icon_dest_target_table, 
				  DragAction.Copy | DragAction.Move); 

		//		icon_view.DragLeave += new DragLeaveHandler (HandleIconViewDragLeave);
		icon_view.DragMotion += HandleIconViewDragMotion;
		icon_view.DragDrop += HandleIconViewDragDrop;
		icon_view.DragDataReceived += HandleIconViewDragDataReceived;
		icon_view.KeyPressEvent += HandleIconViewKeyPressEvent;

		photo_view = new PhotoView (query);
		photo_box.Add (photo_view);

		photo_view.ButtonPressEvent += HandlePhotoViewButtonPressEvent;
		photo_view.KeyPressEvent += HandlePhotoViewKeyPressEvent;
		photo_view.UpdateStarted += HandlePhotoViewUpdateStarted;
		photo_view.UpdateFinished += HandlePhotoViewUpdateFinished;

		photo_view.View.ZoomChanged += HandleZoomChanged;

		// Tag typing: focus the tag entry if the user starts typing a tag
		icon_view.KeyPressEvent += HandlePossibleTagTyping;
		photo_view.KeyPressEvent += HandlePossibleTagTyping;
		tag_entry = new TagEntry (db.Tags);
		tag_entry.KeyPressEvent += HandleTagEntryKeyPressEvent;
		tag_entry.TagsAttached += HandleTagEntryTagsAttached;
		tag_entry.TagsRemoved += HandleTagEntryRemoveTags;
		tag_entry.Activated += HandleTagEntryActivate;
		tag_entry_container.Add (tag_entry);

		Gtk.Drag.DestSet (photo_view, DestDefaults.All, tag_target_table, 
				  DragAction.Copy | DragAction.Move); 

		photo_view.DragMotion += HandlePhotoViewDragMotion;
		photo_view.DragDrop += HandlePhotoViewDragDrop;
		photo_view.DragDataReceived += HandlePhotoViewDragDataReceived;

		view_notebook.SwitchPage += HandleViewNotebookSwitchPage;
		group_selector.Adaptor.GlassSet += HandleAdaptorGlassSet;
		group_selector.Adaptor.Changed += HandleAdaptorChanged;
		LoadPreference (Preferences.GROUP_ADAPTOR);
		LoadPreference (Preferences.GROUP_ADAPTOR_ORDER_ASC);

		this.selection = new MainSelection (this);
		this.selection.Changed += HandleSelectionChanged;
		this.selection.ItemsChanged += HandleSelectionItemsChanged;

		UpdateMenus ();

		main_window.ShowAll ();

		tagbar.Hide ();
		find_bar.Hide ();

		UpdateFindByTagMenu ();

		LoadPreference (Preferences.SHOW_TOOLBAR);
		LoadPreference (Preferences.SHOW_SIDEBAR);
		LoadPreference (Preferences.SHOW_TIMELINE);
		
		Preferences.SettingChanged += OnPreferencesChanged;

		main_window.DeleteEvent += HandleDeleteEvent;
		
		query_widget.HandleChanged (query);
		query_widget.Hide ();

		// When the icon_view is loaded, set it's initial scroll position
		icon_view.SizeAllocated += HandleIconViewReady;

		export.Activated += HandleExportActivated;
		UpdateToolbar ();

		Banshee.Kernel.Scheduler.Resume ();
	}
        private void ParseProjects(CheckBoxList ctlConfigFiles, InfoBox ctlNoConfigFiles, dynamic provider)
        {
            var parsedProjects = this.Projects
                .Select(p => (MSBuildProject)ReadProject(provider, this.SolutionPath + provider.DirectorySeparator + p.ScmPath))
                .ToArray();

            if (parsedProjects.SelectMany(GetConfigFiles).Any())
            {
                for (int i = 0; i < this.Projects.Length; i++)
                {
                    foreach (var configFile in GetConfigFiles(parsedProjects[i]))
                        ctlConfigFiles.Items.Add(new ListItem(configFile + " in " + this.Projects[i].Name, this.Projects[i].ScmPath + '|' + configFile));
                }
            }
            else
            {
                ctlNoConfigFiles.Visible = true;
            }
        }
        protected override void CreateChildControls()
        {
            var hasProviders = StoredProcs.Providers_GetProviders(Domains.ProviderTypes.SourceControl).Execute().Any();

            var ddlProvider = new ActionProviderPicker
            {
                AllowNameEntry = false,
                Visible = hasProviders,
                ProviderTypeCode = Domains.ProviderTypes.SourceControl
            };

            var ctlNoProviders = new InfoBox
            {
                BoxType = InfoBox.InfoBoxTypes.Error,
                Controls = { new LiteralControl("There are no source control providers set up in BuildMaster. Visit the <a href=\"/Administration/Providers/Overview.aspx?providerTypeCode=S\">Source Control Providers page</a> to add one.") },
                Visible = !hasProviders
            };

            var ctlProjectPath = new SourceControlFileFolderPicker
            {
                DisplayMode = SourceControlBrowser.DisplayModes.FoldersAndFiles,
                BindToActionSourceControlProvider = true,
                Width = 300
            };

            var ffProjectPath = new StandardFormField("Path of solution or project (.sln, .csproj, etc):", ctlProjectPath);

            var ctlProjectsInSolution = new CheckBoxList();

            var ctlOneProject = new InfoBox
            {
                BoxType = InfoBox.InfoBoxTypes.Success,
                Controls = { new LiteralControl("You have selected a project file, you may click Next to select a configuration file.") },
                Visible = false
            };

            var ctlConfigFiles = new CheckBoxList();

            var ctlNoConfigFiles = new InfoBox
            {
                BoxType = InfoBox.InfoBoxTypes.Warning,
                Controls = { new LiteralControl("There are no files with .config extension in any of the selected projects, therefore configuration files for this project/solution will have to be created manually.") },
                Visible = false
            };

            var ffgTargets = new FormFieldGroup(
                "Deployment Targets",
                "Select the location to deploy project outputs.",
                true
            );

            this.Load +=
                (s, e) =>
                {
                    for (int i = 0; i < this.Projects.Length; i++)
                    {
                        ffgTargets.FormFields.Add(
                            new StandardFormField(
                                this.Projects[i].Name + ":",
                                new SourceControlFileFolderPicker
                                {
                                    ID = "ctlDeployTarget" + i,
                                    DisplayMode = SourceControlBrowser.DisplayModes.Folders
                                }
                            )
                        );
                    }
                };

            this.wizardSteps.SelectProviderAndFile.Controls.Add(
                new FormFieldGroup(
                    "Source Control",
                    "Select the Source Control Provider and the path of a project or solution.",
                    true,
                    new StandardFormField(
                        "Source Control Provider:",
                        ddlProvider,
                        ctlNoProviders,
                        new Div(
                            new ActionServerPicker { ID = "bm-action-server-id" }
                        ) { ClientIDMode = ClientIDMode.Static, Style = "display: none;" }
                    ),
                    ffProjectPath
                )
            );
            this.WizardStepChange += (s, e) =>
            {
                if (e.CurrentStep != this.wizardSteps.SelectProviderAndFile)
                    return;

                this.ProviderId = (int)ddlProvider.ProviderId;

                using (var proxy = Util.Proxy.CreateProviderProxy((int)ddlProvider.ProviderId))
                {
                    var scm = proxy.TryGetService<SourceControlProviderBase>();
                    var fileBytes = (byte[])scm.GetFileContents(ctlProjectPath.Text);

                    if (ctlProjectPath.Text.EndsWith(".sln", StringComparison.OrdinalIgnoreCase))
                    {
                        var solution = Solution.Load(new MemoryStream(fileBytes, false));
                        ctlProjectsInSolution.Items.AddRange(
                            solution.Projects
                                .OrderBy(p => p.Name)
                                .Select(p => new ListItem(p.Name, p.ProjectPath))
                        );

                        this.SolutionPath = new ProjectInfo(scm.DirectorySeparator, ctlProjectPath.Text).ScmDirectoryName;
                    }
                    else
                    {
                        this.SolutionPath = new ProjectInfo(scm.DirectorySeparator, ctlProjectPath.Text).ScmDirectoryName;
                        this.Projects = new[] { new ProjectInfo(scm.DirectorySeparator, new ProjectInfo(scm.DirectorySeparator, ctlProjectPath.Text).ProjectFileName) };
                        ctlOneProject.Visible = true;
                    }
                }
            };

            this.wizardSteps.SelectProjectsInSolution.Controls.Add(
                new FormFieldGroup(
                    "Projects",
                    "Select the projects in the solution that you would like to create deployables for.",
                    true,
                    new StandardFormField(
                        "",
                        ctlProjectsInSolution,
                        ctlOneProject
                    )
                )
            );
            this.WizardStepChange += (s, e) =>
            {
                if (e.CurrentStep != this.wizardSteps.SelectProjectsInSolution)
                    return;

                using (var proxy = Util.Proxy.CreateProviderProxy((int)ddlProvider.ProviderId))
                {
                    var scm = proxy.TryGetService<SourceControlProviderBase>();
                    char dirSeparator = scm.DirectorySeparator;

                    if (ctlProjectPath.Text.EndsWith(".sln", StringComparison.OrdinalIgnoreCase))
                    {
                        this.Projects = ctlProjectsInSolution.Items
                            .Cast<ListItem>()
                            .Where(i => i.Selected)
                            .Select(i => new ProjectInfo(dirSeparator, i.Value.Replace('\\', dirSeparator)))
                            .ToArray();
                    }

                    ParseProjects(ctlConfigFiles, ctlNoConfigFiles, scm);
                }
            };

            this.wizardSteps.SelectConfigFiles.Controls.Add(
                new FormFieldGroup(
                    "Configuration Files",
                    "Select any configuration files that you would like BuildMaster to manage.",
                    true,
                    new StandardFormField(
                        "",
                        ctlConfigFiles,
                        ctlNoConfigFiles
                    )
                )
            );
            this.WizardStepChange += (s, e) =>
            {
                if (e.CurrentStep != this.wizardSteps.SelectConfigFiles)
                    return;
                var dict = this.Projects.ToDictionary(p => p.ScmPath);
                var configFiles = ctlConfigFiles.Items
                    .Cast<ListItem>()
                    .Where(i => i.Selected)
                    .Select(i => new { Path = i.Value.Split('|')[0], Name = i.Value.Split('|')[1] })
                    .GroupBy(c => c.Path);

                foreach (var cfg in configFiles)
                    dict[cfg.Key].ConfigFiles.AddRange(cfg.Select(c => c.Name));
            };

            this.wizardSteps.SelectDeploymentPaths.Controls.Add(ffgTargets);
            this.WizardStepChange += (s, e) =>
            {
                if (e.CurrentStep != this.wizardSteps.SelectDeploymentPaths)
                    return;
                var controls = this.wizardSteps.SelectDeploymentPaths.Controls
                            .Find<SourceControlFileFolderPicker>()
                            .Where(c => c.ID.StartsWith("ctlDeployTarget"));

                foreach (var control in controls)
                    this.Projects[int.Parse(control.ID.Substring("ctlDeployTarget".Length))].DeploymentTarget = control.Text;
            };

            this.wizardSteps.Confirmation.Controls.Add(
                new FormFieldGroup(
                    "Overview",
                    "Confirm that the actions listed here are correct, then click the Execute Recipe button.",
                    true,
                    new StandardFormField(
                        "",
                        new RecipeOverview(this)
                    )
                )
            );

            base.CreateChildControls();
        }
	void HandleInfoBoxVersionIdChange (InfoBox box, uint version_id)
	{
		UpdateForVersionIdChange (version_id);
	}
 internal void Delete(ListBox lstBoxSendTo, Message message)
 {
     if (lstBoxSendTo.SelectedItems.Count == 0) {
         message.Error(_window.FindResource("SelectedOnItem") as string);
         return;
     }
     FileItem[] sendToListItems = new FileItem[lstBoxSendTo.SelectedItems.Count];
     lstBoxSendTo.SelectedItems.CopyTo(sendToListItems, 0);
     string msg = sendToListItems.Length == 1
         ? _window.FindResource("SureToDelete") + " \"" + sendToListItems[0].Name + "\" " + _window.FindResource("FromSendToMenu")
         : _window.FindResource("SureToDeleteMultiple") + " " + sendToListItems.Length + " " + _window.FindResource("FromSendToMenuMultiple");
     InfoBox infoBox = new InfoBox(msg, _window.FindResource("Delete").ToString(),
         _window.FindResource("WarningMsgTitle").ToString(), InfoBox.DialogType.Question);
     if (infoBox.ShowDialog() != true) return;
     List<string> failedFiles = new List<string>();
     foreach (FileItem sendToFileItem in sendToListItems) {
         string filePath = sendToFileItem.FullName;
         try {
             if (Path.GetExtension(filePath).Equals(".lnk", StringComparison.InvariantCultureIgnoreCase) ||
                 Path.GetExtension(filePath).Equals(".pif", StringComparison.InvariantCultureIgnoreCase)) {
                 if (!System.IO.File.Exists(filePath)) {
                     failedFiles.Add(sendToFileItem.Name);
                     continue;
                 }
             }
             else {
                 failedFiles.Add(sendToFileItem.Name);
                 continue;
             }
             System.IO.File.Delete(filePath);
         }
         catch (IOException) {
             failedFiles.Add(sendToFileItem.Name);
         }
         catch (NullReferenceException) {
             failedFiles.Add(sendToFileItem.Name);
         }
     }
     if (!failedFiles.Any()) return;
     string failedMsg = failedFiles.Count > 1
         ? _window.FindResource("FailedToDelete") + " " + failedFiles.SentenceJoin() +
           " " + _window.FindResource("AreNotShortcutsMultiple")
         : _window.FindResource("FailedToDelete") + " " + failedFiles.SentenceJoin() +
           " " + _window.FindResource("AreNotShortcuts");
     message.Error(failedMsg);
 }
Example #20
0
 public PlacesView(Context context, InfoBox infoBox)
 {
     this.context = context;
     this.infoBox = infoBox;
     Init();
 }
Example #21
0
 public StatisticsView(Context context, InfoBox infoBox)
 {
     this.context = context;
     this.infoBox = infoBox;
     Init();
 }
Example #22
0
        private void ShowPeople() {
            LetsChangeDefinitions(1, 2);
            ColumnDefinition column = ColumnDefinitions.First();
            column.Width = new GridLength(180);

            InfoBox infoBox = new InfoBox();
            Grid.SetColumn(infoBox, 1);
            Children.Add(infoBox);

            PeopleView peopleView = new PeopleView(context, infoBox);
            Children.Add(peopleView);
        }