private static Panel CreateViewRules([NotNull] FormSparseWorkingCopyViewModel sparse, [NotNull] ToolTip tooltip, [NotNull] IGitUICommandsSource cmdsource) { // Label var label1 = new Label() { AutoSize = true, Text = Globalized.Strings.SpecifyTheRulesForIncludingOrExcludingFilesAndDirectories.Text, Dock = DockStyle.Top, Padding = new Padding(10, 5, 10, 0) }; var label2 = new Label() { AutoSize = true, Text = Globalized.Strings.SpecifyTheRulesForIncludingOrExcludingFilesAndDirectoriesLine2.Text, Dock = DockStyle.Top, Padding = new Padding(25, 3, 10, 3), ForeColor = SystemColors.GrayText }; sparse.PropertyChanged += delegate { label1.Visible = label2.Visible = sparse.IsSparseCheckoutEnabled; }; // Text editor var editor = new FileViewer() { Dock = DockStyle.Fill, UICommandsSource = cmdsource, IsReadOnly = false }; editor.TextLoaded += (sender, args) => sparse.SetRulesTextAsOnDisk(editor.GetText()); try { FileInfo sparsefile = sparse.GetPathToSparseCheckoutFile(); if (sparsefile.Exists) { editor.ViewFile(sparsefile.FullName); } } catch (Exception ex) { MessageBox.Show(ActiveForm, Globalized.Strings.CannotLoadTheTextOfTheSparseFile.Text + "\n\n" + ex.Message, Globalized.Strings.SparseWorkingCopy.Text + " – " + Globalized.Strings.LoadFile.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } editor.TextChanged += (sender, args) => sparse.RulesText = editor.GetText() ?? ""; tooltip.SetToolTip(editor, Globalized.Strings.EditsTheContentsOfTheGitInfoSparseCheckoutFile.Text); Control separator = CreateViewSeparator(DockStyle.Top); sparse.PropertyChanged += delegate { editor.Visible = separator.Visible = sparse.IsSparseCheckoutEnabled; }; var panel = new Panel() { Margin = Padding.Empty, Padding = Padding.Empty, Controls = { editor, separator, label2, label1 }, AutoSize = true, Dock = DockStyle.Fill }; return(panel); }