AssembledStyles (roughly equivalent to the old VwPropertyStore) represents the results of applying various styles (and explicit formatting). It is designed to be especially efficient when the same properties are independently derived for different parts of the display; for example, if parts of several lexical entries are independently marked bold, only a single AssembledStyles object is created to represent the effect of adding 'Bold' to whatever the context AssembledStyles was. Enhance JohnT: this is only a skeleton at present, it eventually needs most if not all the properties in VwPropertyStore.
コード例 #1
0
		/// <summary>
		/// Intended for use only by AssembledStylesCache to make derived styles.
		/// </summary>
		internal AssembledStyles(AssembledStyles basedOn) : this(basedOn, false)
		{}
コード例 #2
0
ファイル: BlockBox.cs プロジェクト: sillsdev/FieldWorks
		/// <summary>
		/// A box that has a specified color and size in millipoints and simply draws a rectangle that size and color.
		/// </summary>
		/// <param name="styles"></param>
		public BlockBox(AssembledStyles styles, Color color, int mpWidth, int mpHeight) : base(styles)
		{
			MpHeight = mpHeight;
			MpWidth = mpWidth;
			BlockColor = color;
		}
コード例 #3
0
ファイル: RootBox.cs プロジェクト: bbriggs/FieldWorks
		public RootBox(AssembledStyles styles)
			: base(styles)
		{
		}
コード例 #4
0
ファイル: Form1.cs プロジェクト: bbriggs/FieldWorks
		private void InitSeveralBoxes()
		{
			var styles = new AssembledStyles();
			RootBox root = new RootBoxFdo(styles);
			var items = new List<IClientRun>();
			items.Add(new BlockBox(styles, Color.Red, 72000, 36000));
			items.Add(new BlockBox(styles, Color.Blue, 36000, 18000));
			items.Add(new BlockBox(styles, Color.Orange, 18000, 36000));
			items.Add(new BlockBox(styles, Color.Green, 72000, 18000));
			items.Add(new ImageBox(styles.WithBackColor(Color.Pink).WithBorderColor(Color.Blue)
				.WithBorders(new Thickness(2.0)).WithPads(new Thickness(4.0)), new Icon(SystemIcons.Shield, 40, 40).ToBitmap()));
			items.Add(new BlockBox(styles, Color.Yellow, 72000, 36000));
			var source = new TextSource(items);
			var para = new ParaBox(styles, source);
			root.AddBox(para);
			theSharpView.Root = root;
		}
コード例 #5
0
ファイル: ImageBox.cs プロジェクト: sillsdev/FieldWorks
		public ImageBox(AssembledStyles styles, Image image) : base(styles)
		{
			BaseImage = image; // keep a reference to it so it doesn't become garbage
			Picture = (IPicture)OLECvt.ToOLE_IPictureDisp(image);
		}
コード例 #6
0
ファイル: Form1.cs プロジェクト: bbriggs/FieldWorks
		private void InitStyleSheetChooser()
		{
			var stylesheet = SetupStyles();

			int ws = 1; // arbitrary with default renderer factory.
			var styles = new AssembledStyles(stylesheet);
			RootBox root = new RootBoxFdo(styles);
			root.RendererFactory = theSharpView.RendererFactory;

			var obj0 = ApplyTsStringStyle("plain, ", "Normal", ws);
			var obj1 = ApplyTsStringStyle("bold, ", "Bold", ws);
			var obj2 = ApplyTsStringStyle("italic, ", "Italic", ws);
			var obj3 = ApplyTsStringStyle("bold italic, ", "Bold Italic", ws);
			var obj4 = ApplyTsStringStyle("red on yellow", "Red on Yellow", ws);

			root.Builder.Show(Paragraph.Containing(Display.Of(() => obj0.TsContents),
												   Display.Of(() => obj1.TsContents),
												   Display.Of(() => obj2.TsContents),
												   Display.Of(() => obj3.TsContents),
												   Display.Of(() => obj4.TsContents)));
			styleChooser.Visible = true;

			theSharpView.Root = root;
			root.SelectAtStart().Install();
			theSharpView.Focus();
		}
コード例 #7
0
ファイル: Form1.cs プロジェクト: bbriggs/FieldWorks
		// Add to the root a text paragraph which reflects the SimpleText property.
		private void AddSimpleTextPara(AssembledStyles styles, int ws, RootBox root)
		{
			var items = new List<IClientRun>();
			var run = new StringClientRun("This is the day that the Lord has made. We will rejoice and be glad in it",
										  styles.WithWs(ws));
			items.Add(run);
			var source = new TextSource(items);
			var para = new ParaBox(styles, source);
			var hookup = new StringHookup(this, () => this.SimpleText,
										  hook => SimpleTextChanged += hook.StringPropChanged,
										  hook => SimpleTextChanged -= hook.StringPropChanged, para);
			hookup.Writer = newVal => SimpleText = newVal;
			run.Hookup = hookup;
			root.AddBox(para);
		}
コード例 #8
0
			internal override void SetOwnProperty(AssembledStyles styles)
			{
				styles.SetFaceName(SetToValue);
			}
コード例 #9
0
			internal override void SetOwnProperty(AssembledStyles styles)
			{
				styles.StyleName = SetToValue;
			}
コード例 #10
0
			internal abstract void SetOwnProperty(AssembledStyles styles);
コード例 #11
0
			internal void SetProperty(AssembledStyles styles)
			{
				m_fHasBeenUsed = true;
				SetOwnProperty(styles);
				if (m_next != null)
					m_next.SetProperty(styles);
			}
コード例 #12
0
		public bool Equals(AssembledStyles other)
		{
			if (other == null)
				return false;
			LgCharRenderProps chrp = other.m_chrp;
			return other.FontWeight == FontWeight
					&& m_chrp.ttvItalic == chrp.ttvItalic
					&& m_chrp.clrFore == chrp.clrFore
					&& m_chrp.clrBack == chrp.clrBack
					&& m_chrp.clrUnder == chrp.clrUnder
				   && m_chrp.ws == chrp.ws
				   && m_chrp.dympHeight == chrp.dympHeight
				   && m_chrp.dympOffset == chrp.dympOffset
				   && m_chrp.unt == chrp.unt
				   && other.m_borderColor == m_borderColor
				   && other.m_margins == m_margins
				   && other.m_pads == m_pads
				   && other.m_borders == m_borders
				   && other.FaceName == FaceName
				   && other.m_lineHeight == m_lineHeight
				   && other.m_firstLineIndent == FirstLineIndent
				   && other.m_paraAlignment == m_paraAlignment
				   && other.m_styleName == m_styleName
				   && other.RightToLeft == RightToLeft;
	   }
コード例 #13
0
		internal AssembledStyles(AssembledStyles basedOn, PropSetter setter) : this(basedOn)
		{
			var impl = (PropSetterImpl) setter;
			impl.SetProperty(this);
		}
コード例 #14
0
		/// <summary>
		/// Intended for use only by AssembledStylesCache to make derived styles.
		/// If inheritedOnly is true, only those properties are copied which should be inherited by
		/// nested boxes.
		/// </summary>
		internal AssembledStyles(AssembledStyles basedOn, bool inheritedOnly)
		{
			m_styleCache = basedOn.m_styleCache; // all derived styles share it
			m_chrp = basedOn.m_chrp;
			m_lineHeight = basedOn.m_lineHeight;
			m_firstLineIndent = basedOn.m_firstLineIndent;
			m_styleName = basedOn.m_styleName;
			RightToLeft = basedOn.RightToLeft;
			if (inheritedOnly)
			{
				SetNonInheritedDefaults();
			}
			else
			{
				// copy everything else, too.
				m_paraAlignment = basedOn.m_paraAlignment;
				m_borderColor = basedOn.m_borderColor;
				m_borders = basedOn.m_borders;
				m_margins = basedOn.m_margins;
				m_pads = basedOn.m_pads;
				m_weight = basedOn.m_weight;
			}
		}
コード例 #15
0
ファイル: Form1.cs プロジェクト: bbriggs/FieldWorks
		private void InitMultiPara()
		{
			var styles = new AssembledStyles();
			RootBox root = new RootBoxFdo(styles);
			var owner = new ParagraphOwnerDemo();
			owner.InsertParagraph(0, new ParagraphDemo());
			int ws = 1; // arbitrary with default renderer factory.
			root.Builder.Show(Display.Of(() => owner.Paragraphs).Using(
				(builder, para) => builder.AddString(() => para.Contents, ws))
				.EditParagraphsUsing(new ParagraphOpsDemo(owner)));
			theSharpView.Root = root;
			root.SelectAtStart().Install();
			theSharpView.Focus();
		}
コード例 #16
0
			internal override void SetOwnProperty(AssembledStyles styles)
			{
				styles.m_chrp.dympOffset = SetToValue;
			}
コード例 #17
0
ファイル: Form1.cs プロジェクト: bbriggs/FieldWorks
		private void InitLongText()
		{
			var stylesheet = SetupStyles();
			var styles = new AssembledStyles(stylesheet);
			RootBox root = new RootBoxFdo(styles.WithLineHeight(12500));
			var owner = new ParagraphOwnerDemo();
			var words =
				"This is a bit of text from which we can extract substrings of increasing length to populate various paragraphs in different ways"
					.Split(' ');
			string sb = "";
			int ws = 1; // arbitrary with default renderer factory.
			for (int i = 0; i < 20; i++)
			{
				if (i < words.Length)
					sb += (words[i]);
				if (i < words.Length)
					sb += (" ");
				var para = ApplyTsStringStyle(sb, "Normal", ws);
				owner.InsertParagraph(0, para);
			}

			root.Builder.Show(Div.Containing(Div.Containing(Display.Of(() => owner.Paragraphs).Using(
				(builder, para) => builder.Show(Paragraph.Containing(Display.Of(() => para.TsContents)).Style(para.ParaStyle)))
								.EditParagraphsUsing(new ParagraphOpsDemo(owner))).Border(1500).Pads(3000, 3000, 3000, 3000)).Border(2500).Pads(1000, 1000, 1000, 1000));

			styleChooser.Visible = true;
			theSharpView.Root = root;
			root.SelectAtStart().Install();
			theSharpView.Focus();
		}
コード例 #18
0
			internal override void SetOwnProperty(AssembledStyles styles)
			{
				styles.m_lineHeight = SetToValue;
			}
コード例 #19
0
ファイル: Form1.cs プロジェクト: bbriggs/FieldWorks
		private void InitStyledText()
		{
			var styles = new AssembledStyles();
			RootBox root = new RootBoxFdo(styles);
			root.RendererFactory = theSharpView.RendererFactory;
			var obj0 = new ParagraphDemo { Contents = "plain " };
			var obj1 = new ParagraphDemo { Contents = "bold " };
			var obj2 = new ParagraphDemo { Contents = "italic " };
			var obj3 = new ParagraphDemo { Contents = "bold italic " };
			var obj4 = new ParagraphDemo { Contents = "red on yellow" };
			int ws = 1; // arbitrary with default renderer factory.
			root.Builder.Show(
				Paragraph.Containing(
					Display.Of(() => obj0.Contents, ws).FaceName("Times New Roman"),
					Display.Of(() => obj1.Contents, ws).FaceName("Times New Roman").Bold,
					Display.Of(() => obj2.Contents, ws).FaceName("Times New Roman").Italic,
					Display.Of(() => obj3.Contents, ws).FaceName("Times New Roman").Bold.Italic,
					Display.Of(() => obj4.Contents, ws).ForeColor(Color.Red).BackColor(Color.Yellow)
					).Border(1.Points(), Color.Red).Pads(2.Points(), 3.Points(), 2.Points(), 3.Points())
				);
			root.Builder.Show(
				Paragraph.Containing(
					Display.Of("plain"),
					Display.Of("underOnYellow").Underline(FwUnderlineType.kuntSingle).BackColor(Color.Yellow).FaceName("Times New Roman")
					).Margins(3.Points(), 2.Points(), 5.Points(), 2.Points())
					.Borders(1.Points(), 2.Points(), 3.Points(), 4.Points(), Color.Green)
					.BackColor(Color.Pink).Pads(2.Points(), 2.Points(), 2.Points(), 2.Points()),
				Paragraph.Containing(
					Display.Of("doubleRedOnPink").Underline(FwUnderlineType.kuntDouble, Color.Red).BackColor(Color.Pink),
					Display.Of("dotted").Underline(FwUnderlineType.kuntDotted),
					Display.Of("dottedOnYellow").Underline(FwUnderlineType.kuntDotted).BackColor(Color.Yellow)
					),
				Paragraph.Containing(
					Display.Of("dashed").Underline(FwUnderlineType.kuntDashed),
					Display.Of("dashedRed").Underline(FwUnderlineType.kuntDashed).ForeColor(Color.Red),
					Display.Of("squiggle").Underline(FwUnderlineType.kuntSquiggle, Color.Red)
					)
				);
			theSharpView.Root = root;
			root.SelectAtStart().Install();
			theSharpView.Focus();
		}
コード例 #20
0
			internal override void SetOwnProperty(AssembledStyles styles)
			{
				styles.m_firstLineIndent = SetToValue;
			}
コード例 #21
0
ファイル: Form1.cs プロジェクト: bbriggs/FieldWorks
		private void InitFixedRowBoxes()
		{
			var stylesheet = SetupStyles();
			var styles = new AssembledStyles(stylesheet);
			RootBox root = new RootBoxFdo(styles.WithFirstLineIndent(10000));

			var item1 = ApplyTsStringStyle("This begins row one", "Normal", 1);
			var item2 = ApplyTsStringStyle("This is Box 2", "Normal", 1);
			var item3 = ApplyTsStringStyle("This is Box 3", "Normal", 1);
			var item4 = ApplyTsStringStyle("This ends row one", "Normal", 1);

			root.Builder.Show(
				Row.WithWidths(new FixedColumnWidths(300, 60, 60, 100)).Containing(
					Cell.Containing(Paragraph.Containing(Display.Of(() => item1.TsContents)).Style(item1.ParaStyle)).Pads(2000, 2000, 2000, 2000).Margins(2000, 2000, 2000, 2000)
						.BackColor(Color.Pink).Border(1000),
					Cell.Containing(Paragraph.Containing(Display.Of(() => item2.TsContents)).Style(item2.ParaStyle)).Pads(2000, 2000, 2000, 2000).Margins(2000, 2000, 2000, 2000)
						.BackColor(Color.Orange).Border(1000),
					Cell.Containing(Paragraph.Containing(Display.Of(() => item3.TsContents)).Style(item3.ParaStyle)).Pads(2000, 2000, 2000, 2000).Margins(2000, 2000, 2000, 2000)
						.BackColor(Color.LightGray).Border(1000),
					Cell.Containing(Paragraph.Containing(Display.Of(() => item4.TsContents)).Style(item4.ParaStyle)).Pads(2000, 2000, 2000, 2000).Margins(2000, 2000, 2000, 2000)
						.BackColor(Color.FloralWhite).Border(1000)).Margins(5000, 5000, 5000, 5000).Borders(1000, 1000, 1000, 1000, Color.Black));
			root.Builder.Show(
				Row.WithWidths(new FixedColumnWidths(300, 60, 60, 100)).WithWrap.Containing(
					Cell.Containing(Paragraph.Containing(Display.Of(() => item1.TsContents)).Style(item1.ParaStyle)).Pads(2000, 2000, 2000, 2000).Margins(2000, 2000, 2000, 2000)
						.BackColor(Color.Pink).Border(1000),
					Cell.Containing(Paragraph.Containing(Display.Of(() => item2.TsContents)).Style(item2.ParaStyle)).Pads(2000, 2000, 2000, 2000).Margins(2000, 2000, 2000, 2000)
						.BackColor(Color.Orange).Border(1000),
					Cell.Containing(Paragraph.Containing(Display.Of(() => item3.TsContents)).Style(item3.ParaStyle)).Pads(2000, 2000, 2000, 2000).Margins(2000, 2000, 2000, 2000)
						.BackColor(Color.LightGray).Border(1000),
					Cell.Containing(Paragraph.Containing(Display.Of(() => item4.TsContents)).Style(item4.ParaStyle)).Pads(2000, 2000, 2000, 2000).Margins(2000, 2000, 2000, 2000)
						.BackColor(Color.FloralWhite).Border(1000)).Margins(5000, 5000, 5000, 5000).Borders(1000, 1000, 1000, 1000, Color.Black));

			styleChooser.Visible = true;
			theSharpView.Root = root;
			theSharpView.Focus();
		}
コード例 #22
0
			internal override void SetOwnProperty(AssembledStyles styles)
			{
				if (SetToValue == (int) FwTextToggleVal.kttvInvert)
					styles.m_chrp.ttvItalic = styles.FontItalic ? (int) FwTextToggleVal.kttvOff : (int) FwTextToggleVal.kttvForceOn;
				else
					styles.m_chrp.ttvItalic = SetToValue;
			}
コード例 #23
0
ファイル: Form1.cs プロジェクト: bbriggs/FieldWorks
		private void InitRedBox()
		{
			var styles = new AssembledStyles();
			RootBox root = new RootBoxFdo(styles);
			var block = new BlockBox(styles, Color.Red, 72000, 36000);
			root.AddBox(block);
			theSharpView.Root = root;
		}
コード例 #24
0
ファイル: Form1.cs プロジェクト: bbriggs/FieldWorks
		void StartupMultiLingualStrings()
		{
			var stylesheet = SetupStyles();
			var styles = new AssembledStyles(stylesheet);
			RootBox root = new RootBoxFdo(styles);
			var owner = new ParagraphOwnerDemo();
			var paraDemo = new ParagraphDemo {ParaStyle = "Left"};
			paraDemo.MlsContents = m_mlsOwner.MyMultiString;
			owner.InsertParagraph(0, paraDemo);
			root.Builder.Show(Display.Of(() => owner.Paragraphs).Using(
				(builder, para) =>
				builder.Show(Paragraph.Containing(Display.Of(() => para.MlsContents, Ws2)).Style(para.ParaStyle))),
							  Display.Of(() => owner.Paragraphs).Using(
								(builder, para) =>
								builder.Show(Paragraph.Containing(Display.Of(() => para.MlsContents, Ws1)).Style(para.ParaStyle))))
				.EditParagraphsUsing(new ParagraphOpsDemo(owner));
			wsSelector1.SelectedItem = wsSelector1.Items[Ws1 - 1];
			wsSelector2.SelectedItem = wsSelector2.Items[Ws2 - 1];
			theSharpView.Root = root;
			root.SelectAtStart().Install();
			theSharpView.Focus();
		}
コード例 #25
0
ファイル: DivBox.cs プロジェクト: sillsdev/FieldWorks
		public DivBox(AssembledStyles styles) : base(styles)
		{
		}
コード例 #26
0
ファイル: Form1.cs プロジェクト: bbriggs/FieldWorks
		private void InitTextWithPrompts()
		{
			var styles = new AssembledStyles();
			RootBox root = new RootBoxFdo(styles);
			root.RendererFactory = theSharpView.RendererFactory;
			var obj0 = new ParagraphDemo { Contents = "one" };
			var obj1 = new ParagraphDemo { Contents = "" };
			var obj2 = new ParagraphDemo { Contents = "three" };
			int ws = 1; // arbitrary with default renderer factory.
			root.Builder.Show(
				Paragraph.Containing(
					Display.Of(() => obj0.Contents, ws).WhenEmpty("prompt", ws),
					Display.Of(" "),
					Display.Of(() => obj1.Contents, ws).WhenEmpty("prompt", ws),
					Display.Of(" "),
					Display.Of(() => obj2.Contents, ws).WhenEmpty("prompt", ws)
					)
				);
			theSharpView.Root = root;
			root.SelectAtStart().Install();
			theSharpView.Focus();
		}
コード例 #27
0
ファイル: Box.cs プロジェクト: sillsdev/FieldWorks
		public Box(AssembledStyles style)
		{
			Style = style;
		}
コード例 #28
0
ファイル: Form1.cs プロジェクト: bbriggs/FieldWorks
		private void InitDoubleString()
		{
			var styles = new AssembledStyles();
			RootBox root = new RootBoxFdo(styles);
			int ws = 1; // arbitrary with default renderer factory.
			AddSimpleTextPara(styles, ws, root);
			AddSimpleTextPara(styles, ws, root);
			theSharpView.Root = root;
			root.SelectAtStart().Install();
			theSharpView.Focus();
		}
コード例 #29
0
ファイル: LeafBox.cs プロジェクト: sillsdev/FieldWorks
		/// <summary>
		/// A root class for all varieties of Box that do not contain other boxes.
		/// </summary>
		/// <param name="styles"></param>
		public LeafBox(AssembledStyles styles) : base(styles)
		{

		}
コード例 #30
0
		internal AssembledStyles CanonicalInstance(AssembledStyles astyles)
		{
			return m_styleCache.CanonicalInstance(astyles);
		}