private void addPaletteToolStripMenuItem_Click(object sender, EventArgs e) { if (_textST.StyleSegment.Palettes.Count < 254) { int id = 1; while (_textST.StyleSegment.Palettes.Any(p => p.PaletteEntryId == id)) { id++; } var palette = new TextST.Palette { PaletteEntryId = id, Y = 235, Cr = 128, Cb = 128, T = 255 }; _textST.StyleSegment.Palettes.Add(palette); var paletteNode = new TreeNode("Palette " + id) { Tag = palette }; _palettesNode.Nodes.Add(paletteNode); treeView1.SelectedNode = paletteNode; } }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { groupBoxPropertiesRoot.Visible = false; groupBoxPropertiesPalette.Visible = false; groupBoxPropertiesRegionStyle.Visible = false; groupBoxPropertiesUserStyle.Visible = false; groupBoxPresentationSegmentRegion.Visible = false; groupBoxFontStyle.Visible = false; groupBoxChangeFontSize.Visible = false; groupBoxSubtitleText.Visible = false; groupBoxChangeFontColor.Visible = false; groupBoxFontSet.Visible = false; if (e.Node != null && _textST != null) { _currentNode = e.Node; if (e.Node == _rootNode) { groupBoxPropertiesRoot.Visible = true; textBoxRoot.Text = "Number of region styles: " + _textST.StyleSegment.RegionStyles.Count + Environment.NewLine + "Number of user styles: " + _textST.StyleSegment.UserStyles.Count + Environment.NewLine + "Number of palettes: " + _textST.StyleSegment.Palettes.Count + Environment.NewLine + "Number of subtitles: " + _textST.StyleSegment.NumberOfDialogPresentationSegments + Environment.NewLine; } else if (e.Node.Tag is TextST.Palette) { groupBoxPropertiesPalette.Visible = true; _currentPalette = e.Node.Tag as TextST.Palette; numericUpDownPaletteEntry.Value = _currentPalette.PaletteEntryId; numericUpDownPaletteY.Value = _currentPalette.Y; numericUpDownPaletteCr.Value = _currentPalette.Cr; numericUpDownPaletteCb.Value = _currentPalette.Cb; numericUpDownPaletteOpacity.Value = _currentPalette.T; panelPaletteColor.BackColor = Color.FromArgb(255, _currentPalette.Color); } else if (e.Node.Tag is TextST.RegionStyle) { groupBoxPropertiesRegionStyle.Visible = true; _currentRegionStyle = e.Node.Tag as TextST.RegionStyle; numericUpDownRegionStyleId.Value = _currentRegionStyle.RegionStyleId; numericUpDownRegionStyleHPos.Value = _currentRegionStyle.RegionHorizontalPosition; numericUpDownRegionStyleVPos.Value = _currentRegionStyle.RegionVerticalPosition; numericUpDownRegionStyleWidth.Value = _currentRegionStyle.RegionWidth; numericUpDownRegionStyleHeight.Value = _currentRegionStyle.RegionHeight; numericUpDownRegionStylePaletteEntryId.Value = _currentRegionStyle.RegionBgPaletteEntryIdRef; numericUpDownRegionStyleTBHorPos.Value = _currentRegionStyle.TextBoxHorizontalPosition; numericUpDownRegionStyleTBVerPos.Value = _currentRegionStyle.RegionVerticalPosition; numericUpDownRegionStyleTBWidth.Value = _currentRegionStyle.TextBoxWidth; numericUpDownRegionStyleTBHeight.Value = _currentRegionStyle.TextBoxHeight; numericUpDownRegionStyleTextFlow.Value = _currentRegionStyle.TextFlow; numericUpDownRegionStyleTextHorAlign.Value = _currentRegionStyle.TextHorizontalAlignment; numericUpDownRegionStyleTextVerAlign.Value = _currentRegionStyle.TextVerticalAlignment; numericUpDownRegionStyleLineSpace.Value = _currentRegionStyle.LineSpace; numericUpDownRegionStyleFontIdRef.Value = _currentRegionStyle.FontIdRef; numericUpDownRegionStyleFontStyle.Value = _currentRegionStyle.FontStyle; numericUpDownRegionStyleFontSize.Value = _currentRegionStyle.FontSize; numericUpDownRegionStyleFontPaletteId.Value = _currentRegionStyle.FontPaletteEntryIdRef; numericUpDownRegionStyleFontOutlinePaletteId.Value = _currentRegionStyle.FontOutlinePaletteEntryIdRef; numericUpDownRegionStyleFontOutlineThickness.Value = _currentRegionStyle.FontOutlineThickness; } else if (e.Node.Tag is TextST.UserStyle) { groupBoxPropertiesUserStyle.Visible = true; _currentUserStyle = e.Node.Tag as TextST.UserStyle; numericUpDownUserStyleId.Value = _currentUserStyle.UserStyleId; numericUpDownUserStyleHorPosDir.Value = _currentUserStyle.RegionHorizontalPositionDirection; numericUpDownUserStyleHorPosDelta.Value = _currentUserStyle.RegionHorizontalPositionDelta; numericUpDownUserStyleVerPosDir.Value = _currentUserStyle.RegionVerticalPositionDirection; numericUpDownUserStyleVerPosDelta.Value = _currentUserStyle.RegionVerticalPositionDelta; numericUpDownUserStyleFontSizeIncDec.Value = _currentUserStyle.FontSizeIncDec; numericUpDownUserStyleFontSizeDelta.Value = _currentUserStyle.FontSizeDelta; numericUpDownUserStyleTBHorPosDir.Value = _currentUserStyle.TextBoxHorizontalPositionDirection; numericUpDownUserStyleTBHorPosDelta.Value = _currentUserStyle.TextBoxHorizontalPositionDelta; numericUpDownUserStyleTBVerPosDir.Value = _currentUserStyle.TextBoxVerticalPositionDirection; numericUpDownUserStyleTBVerPosDelta.Value = _currentUserStyle.TextBoxVerticalPositionDelta; numericUpDownUserStyleTBWidthIncDec.Value = _currentUserStyle.TextBoxWidthIncDec; numericUpDownUserStyleTBWidthDelta.Value = _currentUserStyle.TextBoxWidthDelta; numericUpDownUserStyleTBHeightIncDec.Value = _currentUserStyle.TextBoxHeightIncDec; numericUpDownUserStyleTBHeightDelta.Value = _currentUserStyle.TextBoxHeightDelta; numericUpDownUserStyleLineSpaceIncDec.Value = _currentUserStyle.LineSpaceIncDec; numericUpDownUserStyleLineSpaceDelta.Value = _currentUserStyle.LineSpaceDelta; } else if (e.Node.Tag is TextST.SubtitleRegion) { groupBoxPresentationSegmentRegion.Visible = true; _currentSubtitleRegion = e.Node.Tag as TextST.SubtitleRegion; checkBoxSubRegionContinuous.Checked = _currentSubtitleRegion.ContinuousPresentation; checkBoxSubRegionForced.Checked = _currentSubtitleRegion.Forced; numericUpDownSubRegionStyleIdRef.Value = _currentSubtitleRegion.RegionStyleId; } else if (e.Node.Tag is TextST.SubtitleRegionContentChangeFontStyle) { groupBoxFontStyle.Visible = true; _currentSubtitleFontStyle = e.Node.Tag as TextST.SubtitleRegionContentChangeFontStyle; comboBoxChangeFontStyleFontStyle.SelectedIndex = _currentSubtitleFontStyle.FontStyle; numericUpDownChangeFontStyleOutlinePaletteId.Value = _currentSubtitleFontStyle.FontOutlinePaletteId; comboBoxChangeFontStyleOutlineThickness.SelectedIndex = _currentSubtitleFontStyle.FontOutlineThickness - 1; } else if (e.Node.Tag is TextST.SubtitleRegionContentChangeFontSize) { groupBoxChangeFontSize.Visible = true; _currentSubtitleFontSize = e.Node.Tag as TextST.SubtitleRegionContentChangeFontSize; numericUpDownChangeFontSize.Value = _currentSubtitleFontSize.FontSize; } else if (e.Node.Tag is TextST.SubtitleRegionContentText) { groupBoxSubtitleText.Visible = true; _currentSubtitleText = e.Node.Tag as TextST.SubtitleRegionContentText; textBoxSubtitleText.Text = _currentSubtitleText.Text; } else if (e.Node.Tag is TextST.SubtitleRegionContentChangeFontColor) { groupBoxChangeFontColor.Visible = true; _currentSubtitleFontColor = e.Node.Tag as TextST.SubtitleRegionContentChangeFontColor; numericUpDownChangeFontColor.Value = _currentSubtitleFontColor.FontPaletteId; } else if (e.Node.Tag is TextST.SubtitleRegionContentChangeFontSet) { groupBoxFontSet.Visible = true; _currentSubtitleFontSet = e.Node.Tag as TextST.SubtitleRegionContentChangeFontSet; numericUpDownFontSetFontId.Value = _currentSubtitleFontSet.FontId; } } }