/// ------------------------------------------------------------------------------------ private void InitializeGrid() { _grid = new TextAnnotationEditorGrid(_project.TranscriptionFont, _project.FreeTranslationFont); _grid.TranscriptionFontChanged += font => { _project.TranscriptionFont = font; _project.Save(); }; // SP-873: Translation font not saving _grid.TranslationFontChanged += font => { _project.FreeTranslationFont = font; _project.Save(); }; L10NSharpExtender gridLocExtender = new L10NSharpExtender(); gridLocExtender.LocalizationManagerId = "SayMore"; gridLocExtender.SetLocalizingId(_grid, "TextAnnotationEditorGrid"); gridLocExtender.EndInit(); _grid.Dock = DockStyle.Fill; _splitter.Panel2.Controls.Add(_grid); }
/// ------------------------------------------------------------------------------------ public ElementGrid() { CellBorderStyle = DataGridViewCellBorderStyle.None; VirtualMode = true; RowHeadersVisible = false; BorderStyle = BorderStyle.None; StandardTab = true; Font = Program.DialogFont; // Underlying code still allows for deleting multiple elements, but JohnH said not // to allow it. MultiSelect = false; PaintFullRowFocusRectangle = true; ExtendFullRowSelectRectangleToEdge = true; ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders; var clr = ColorHelper.CalculateColor(Color.White, DefaultCellStyle.SelectionBackColor, 140); FullRowFocusRectangleColor = DefaultCellStyle.SelectionBackColor; DefaultCellStyle.SelectionBackColor = clr; DefaultCellStyle.SelectionForeColor = DefaultCellStyle.ForeColor; _locExtender = new L10NSharpExtender(); _locExtender.LocalizationManagerId = "SayMore"; _locExtender.SetLocalizingId(this, "ElementGrid"); }
public void TestLocalizingALocalizableComponent() { // Setup test m_extender.BeginInit(); // Doesn't currently do anything, but for completeness... var locComponent = new MockLocalizableComponent(); m_extender.SetLocalizingId(locComponent, "TestLocalizableComponent"); // SUT m_extender.EndInit(); // Verify English Assert.AreEqual("It's a crow", locComponent.GetLocalizedStringFromMock(locComponent.BirdButton, "TestItem.Bird.Crow")); Assert.AreEqual("It's not a crow", locComponent.GetLocalizedStringFromMock(locComponent.BirdButton, "TestItem.Bird.Raven")); Assert.AreEqual("It's a chicken", locComponent.GetLocalizedStringFromMock(locComponent.ChickenButton, "TestItem.Chicken.Rooster")); Assert.AreEqual("Fish-eating bird", locComponent.GetLocalizedStringFromMock(locComponent.BirdButton, "TestItem.Bird.Eagle")); // SUT2 LocalizationManager.SetUILanguage("fr", true); // Verify French Assert.AreEqual("C'est un corbeau", locComponent.GetLocalizedStringFromMock(locComponent.BirdButton, "TestItem.Bird.Crow")); Assert.AreEqual("Ce n'est pas un corbeau", locComponent.GetLocalizedStringFromMock(locComponent.BirdButton, "TestItem.Bird.Raven")); Assert.AreEqual("C'est un poulet", locComponent.GetLocalizedStringFromMock(locComponent.ChickenButton, "TestItem.Chicken.Rooster")); Assert.AreEqual("Un oiseau qui mange des poissons", locComponent.GetLocalizedStringFromMock(locComponent.BirdButton, "TestItem.Bird.Eagle")); // SUT3 (I don't like doing multiple tests in one test method, but when I tried to make a different test // I got some test interaction because of setup/teardown. That's easily avoidable by putting the new test here.) var result = m_extender.CanExtend(locComponent); // Verify Assert.IsTrue(result, "an ILocalizableComponent ought to be extendable by the L10NSharpExtender"); }
private void InitializeControls() { _grid = new BetterGrid { Dock = DockStyle.Top, RowHeadersVisible = false, AllowUserToOrderColumns = false, AllowUserToResizeRows = true, AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None, Name = "PersonContributionGrid", BorderStyle = BorderStyle.None, ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.None, ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing }; // look for saved settings var widths = Array.ConvertAll(Settings.Default.PersonContributionColumns.Split(new[] { ',' }), int.Parse).ToList(); while (widths.Count < 4) { widths.Add(200); } // set the localizable column header text string[] headerText = { @"_L10N_:PeopleView.ContributionEditor.NameColumnTitle!Name", @"_L10N_:PeopleView.ContributionEditor.RoleColumnTitle!Role", @"_L10N_:PeopleView.ContributionEditor.DateColumnTitle!Date", @"_L10N_:PeopleView.ContributionEditor.CommentColumnTitle!Comments" }; for (var i = 0; i < headerText.Length; i++) { _grid.Columns.Add(new DataGridViewTextBoxColumn { Width = widths[i], SortMode = DataGridViewColumnSortMode.Automatic, ReadOnly = true, HeaderText = headerText[i] }); } // set column header height to match the other grids _grid.AutoResizeColumnHeadersHeight(); _grid.ColumnHeadersHeight += 8; // make it localizable L10NSharpExtender locExtender = new L10NSharpExtender(); locExtender.LocalizationManagerId = "SayMore"; locExtender.SetLocalizingId(_grid, "ContributionsEditorGrid"); locExtender.EndInit(); Controls.Add(_grid); _grid.ColumnWidthChanged += _grid_ColumnWidthChanged; Program.PersonDataChanged += Program_PersonDataChanged; Disposed += PersonContributionEditor_Disposed; }
public void GetSetTests() { Assert.AreEqual(0, m_extCtrls.Count); var lbl = new Label(); m_extender.SetLocalizableToolTip(lbl, "lions"); m_extender.SetLocalizationComment(lbl, "tigers"); m_extender.SetLocalizingId(lbl, "bears"); m_extender.SetLocalizationPriority(lbl, LocalizationPriority.MediumLow); Assert.AreEqual(1, m_extCtrls.Count); Assert.AreEqual("lions", m_extender.GetLocalizableToolTip(lbl)); Assert.AreEqual("tigers", m_extender.GetLocalizationComment(lbl)); Assert.AreEqual("bears", m_extender.GetLocalizingId(lbl)); Assert.AreEqual(LocalizationPriority.MediumLow, m_extender.GetLocalizationPriority(lbl)); }
/// ------------------------------------------------------------------------------------ public FieldsValuesGrid(FieldsValuesGridViewModel model, string name) { Name = name; // ReSharper disable once UseObjectOrCollectionInitializer _locExtender = new L10NSharpExtender(); _locExtender.LocalizationManagerId = "SayMore"; _locExtender.SetLocalizingId(this, "FieldsAndValuesGrid"); VirtualMode = true; Font = Program.DialogFont; _factoryFieldFont = new Font(Font, FontStyle.Bold); AllowUserToDeleteRows = true; MultiSelect = false; Margin = new Padding(0, Margin.Top, 0, Margin.Bottom); RowHeadersVisible = false; DefaultCellStyle.SelectionForeColor = DefaultCellStyle.ForeColor; _focusedSelectionBackColor = ColorHelper.CalculateColor(Color.White, DefaultCellStyle.SelectionBackColor, 140); SetSelectionColors(false); _model = model; AddColumns(); RowCount = _model.RowData.Count; // setting AllowUserToAddRows=True will add a blank line AllowUserToAddRows = _model.AllowUserToAddRows; AutoResizeRows(); _model.ComponentFileChanged = HandleComponentFileChanged; if (!string.IsNullOrEmpty(_model.GridSettingsName) && Settings.Default[_model.GridSettingsName] != null) { ((GridSettings)Settings.Default[_model.GridSettingsName]).InitializeGrid(this); } }
/// <remarks>SP-874: Localize column headers</remarks> public void SetLocalizationExtender(L10NSharpExtender extender) { extender.SetLocalizingId(_grid, "ContributorsEditorGrid"); }
/// <remarks>SP-874: Localize column headers</remarks> public void SetLocalizationExtender(L10NSharpExtender extender) { extender.SetLocalizingId(_grid, "ContributorsEditorGrid"); }