コード例 #1
0
ファイル: Converters.cs プロジェクト: VacuityBox/ShowPlay
        public override FontWeight Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            var fontWeightString = reader.GetString() ?? "Normal";
            var converter        = new System.Windows.FontWeightConverter();

            return((FontWeight)converter.ConvertFromString(fontWeightString));
        }
コード例 #2
0
        public FontDefinition ToFontDefinition()
        {
            var styleConverter = new FontStyleConverter();
            var weightConverter = new FontWeightConverter();
            var stretchConverter = new FontStretchConverter();

            var style = (FontStyle?)styleConverter.ConvertFromString(FontStyle) ?? FontStyles.Normal;
            var weight = (FontWeight?)weightConverter.ConvertFromString(FontWeight) ?? FontWeights.Normal;
            var stretch = (FontStretch?)stretchConverter.ConvertFromString(FontStretch) ?? FontStretches.Normal;

            return new FontDefinition
            {
                FontFamily = new FontFamily(FontFamily),
                FontStyle = style,
                FontWeight = weight,
                FontStretch = stretch,
                FontSize = FontSize
            };
        }
コード例 #3
0
ファイル: FontUtilities.cs プロジェクト: kingpin2k/MCS
        public static FontFace GetFontFaceInfo(string font, MediaCenterTheme theme)
        {
            FontFace fontFace = new FontFace();
            List<FontFamily> list = new List<FontFamily>();

            if (theme != null)
                list.AddRange(theme.Fonts);

            InstallMediaCenterFonts();

            list.AddRange(Fonts.SystemFontFamilies);

            foreach (FontFamily fontFamily in list)
            {
                string name = FontUtil.GetName(fontFamily);
                if (font.StartsWith(name))
                {
                    fontFace.FontFamily = name;
                    FontWeightConverter fontWeightConverter = new FontWeightConverter();
                    string str = font.Substring(name.Length).Trim();
                    char[] chArray = new char[1] { ' ' };
                    foreach (string text in str.Split(chArray))
                    {
                        if (!string.IsNullOrEmpty(text))
                        {
                            try
                            {
                                fontFace.FontWeight = (FontWeight)fontWeightConverter.ConvertFromString(text);
                            }
                            catch (FormatException)
                            {
                            }
                        }
                    }
                    break;
                }
            }
            if (fontFace.FontFamily == null)
                return (FontFace)null;
            else
                return fontFace;
        }
コード例 #4
0
ファイル: FontConversions.cs プロジェクト: growse/Feedling
        /// <summary>
        /// Convert string to FontWeight for serialization
        /// </summary>
        public static FontWeight FontWeightFromString(string value)
        {
            var result = FontWeights.Normal;

            try
            {
                var convertFromString = new FontWeightConverter().ConvertFromString((value));
                if (convertFromString != null)
                {
                    result = (FontWeight)convertFromString;
                }
            }
            catch (NotSupportedException)
            {
            }
            catch (FormatException)
            {
            }

            return result;
        }
コード例 #5
0
		TextBlock InsertLineCenteredText (Canvas FramingCanvas, String Text,
							double FontSizePercentage, double TopPercentage,
							String Weight, String Color)
			{
			FontWeightConverter FWConverter = new FontWeightConverter ();
			BrushConverter BRConverter = new BrushConverter ();
			TextBlock BlockName = new TextBlock ();
			BlockName.Visibility = Visibility.Visible;
			FramingCanvas.Children.Add (BlockName);
			FramingCanvas.UpdateLayout ();
			double ActCanvasHeight = FramingCanvas.ActualHeight;
			double ActCanvasWidth = FramingCanvas.ActualWidth;
			BlockName.FontSize = FontSizePercentage * ActCanvasHeight / 100;
			BlockName.FontWeight = (FontWeight)FWConverter.ConvertFromString (Weight);
			BlockName.Foreground = (Brush)BRConverter.ConvertFromString (Color);
			BlockName.Text = Text;
			BlockName.TextAlignment = TextAlignment.Center;
			BlockName.UpdateLayout ();
			double ActHeadHeight = BlockName.ActualHeight;
			double ActHeadWidth = BlockName.ActualWidth;
			Canvas.SetTop (BlockName, (ActCanvasHeight * TopPercentage) / 100);
			Canvas.SetLeft (BlockName, ((ActCanvasWidth - ActHeadWidth) / 2));
			return BlockName;
			}
コード例 #6
0
		TextBlock InsertCanvasPositionedText (Canvas FramingCanvas, String Text,
							double WidthPercentage, double HeightPercentage,
							double FontSizePercentage, String Weight, String Color)
			{
			FontWeightConverter FWConverter = new FontWeightConverter ();
			BrushConverter BRConverter = new BrushConverter ();
			TextBlock BlockName = new TextBlock ();
			BlockName.Visibility = Visibility.Visible;
			FramingCanvas.Children.Add (BlockName);
			double ActCanvasHeight = FramingCanvas.ActualHeight;
			double ActCanvasWidth = FramingCanvas.ActualWidth;
			BlockName.FontSize = ActCanvasHeight * FontSizePercentage / 100.0;
			BlockName.FontWeight = (FontWeight)FWConverter.ConvertFromString (Weight);
			BlockName.Foreground = (Brush)BRConverter.ConvertFromString (Color);
			BlockName.Text = Text;
			BlockName.TextAlignment = TextAlignment.Center;
			BlockName.UpdateLayout ();
			double ActTextHeight = BlockName.ActualHeight;
			double ActTextWidth = BlockName.ActualWidth;
			Canvas.SetTop (BlockName, (((ActCanvasHeight * HeightPercentage) / 100) - (ActTextHeight / 2)));
			Canvas.SetLeft (BlockName, (((ActCanvasWidth * WidthPercentage) / 100) - (ActTextWidth / 2)));
			return BlockName;
			}
コード例 #7
0
ファイル: XAMLHandling.cs プロジェクト: heinzsack/DEV
		public TextBlock InsertCanvasPositionedTextBlock (Canvas FramingCanvas, String Text,
						double WidthPercentage, double HeightPercentage,
						double FontSizePercentage, double LeftPercentage,
						double TopPercentage, String Weight, String Color)
			{
			FontWeightConverter FWConverter = new FontWeightConverter ();
			BrushConverter BRConverter = new BrushConverter ();
			TextBlock BlockName = new TextBlock ();
			BlockName.Visibility = Visibility.Visible;
			FramingCanvas.Children.Add (BlockName);
			FramingCanvas.UpdateLayout ();
			double ActCanvasHeight = FramingCanvas.ActualHeight;
			if (ActCanvasHeight == 0)
				ActCanvasHeight = FramingCanvas.Height;
			double ActCanvasWidth = FramingCanvas.ActualWidth;
			if (ActCanvasWidth == 0)
				ActCanvasWidth = FramingCanvas.Width;
			Canvas.SetTop (BlockName, ((ActCanvasHeight * TopPercentage) / 100));
			Canvas.SetLeft (BlockName, ((ActCanvasWidth * LeftPercentage) / 100));
			double BlockNameWidth = (ActCanvasWidth * WidthPercentage) / 100;
			double BlockNameHeight = (ActCanvasHeight * HeightPercentage) / 100;
			Text = Text.Replace ("\r\n", " ");
			Text = Text.Replace ("\n", " ");
			Text = Text.Replace ("\r", " ");
			bool TextFit = false;
			double FontReduction = 1;
			while (!TextFit)
				{
				BlockName.FontSize = (ActCanvasHeight * FontSizePercentage / 100.0) * FontReduction;
				BlockName.FontWeight = (FontWeight)FWConverter.ConvertFromString (Weight);
				if (Color.IndexOf ('$') == -1)
					BlockName.Foreground = (Brush)BRConverter.ConvertFromString (Color);
				else
					BlockName.Foreground = (Brush)BRConverter.ConvertFromString (Color);
				BlockName.TextAlignment = TextAlignment.Left;
				BlockName.TextWrapping = TextWrapping.Wrap;
				BlockName.Text = Text;
				BlockName.UpdateLayout ();
				double ActTextHeight = BlockName.ActualHeight;
				double ActTextWidth = BlockName.ActualWidth;
				double NumberOfPossibleLines = (double)((int)(BlockNameHeight / ActTextHeight));
				double RequiredNumberOfLines = (ActTextWidth * 1.10) / BlockNameWidth;
				if (RequiredNumberOfLines < NumberOfPossibleLines)
					{
					TextFit = true;
					}
				FontReduction -= 0.05;
				if (FontReduction < 0.30)
					TextFit = true;
				}

			BlockName.Width = BlockNameWidth;
			BlockName.Height = BlockNameHeight;
			return BlockName;
			}
コード例 #8
0
        /// <summary>
        /// Helper function that converts the values stored in the settings into the font values
        /// and then sets the tasklist font values.
        /// </summary>
		public void SetFont()
        {
            var family = new FontFamily(User.Default.TaskListFontFamily);

            double size = User.Default.TaskListFontSize;

            var styleConverter = new FontStyleConverter();

            FontStyle style = (FontStyle)styleConverter.ConvertFromString(User.Default.TaskListFontStyle);

            var stretchConverter = new FontStretchConverter();
            FontStretch stretch = (FontStretch)stretchConverter.ConvertFromString(User.Default.TaskListFontStretch);

            var weightConverter = new FontWeightConverter();
            FontWeight weight = (FontWeight)weightConverter.ConvertFromString(User.Default.TaskListFontWeight);

            Color color = (Color)ColorConverter.ConvertFromString(User.Default.TaskListFontBrushColor);

			lbTasks.FontFamily = family;
			lbTasks.FontSize = size;
			lbTasks.FontStyle = style;
			lbTasks.FontStretch = stretch;
			lbTasks.FontWeight = weight;
			lbTasks.Foreground = new SolidColorBrush(color);
        }
コード例 #9
0
 public static bool CanParseFontWeight(string fontWeightName)
 {
     try
     {
         var converter = new FontWeightConverter();
         converter.ConvertFromString(fontWeightName);
         return true;
     }
     catch
     {
         return false;
     }
 }
コード例 #10
0
ファイル: Read.cs プロジェクト: joazlazer/ModdingStudio
        /// <summary>
        /// Read the WordsStyle XML tag with its attributes (if any) and return
        /// a resulting <seealso cref="WordsStyle"/> object.
        /// </summary>
        internal static WordsStyle ReadNode(XmlReader reader)
        {
            WordsStyle ret = null;
              FontWeightConverter FontWeightConverter = new FontWeightConverter();
              FontStyleConverter FontStyleConverter = new FontStyleConverter();

              string name = string.Empty;
              string fgColor = string.Empty;
              string bgColor = string.Empty;
              string fontWeight = string.Empty;
              string FontStyle = string.Empty;

              reader.ReadToNextSibling(ReadWordsStyle.XMLName);
              while (reader.MoveToNextAttribute())
              {
            switch (reader.Name)
            {
              case ReadWordsStyle.attr_name:
            name = reader.Value;
            break;

              case ReadWordsStyle.attr_fgColor:
            fgColor = (reader.Value == null ? string.Empty : reader.Value);
            break;

              case ReadWordsStyle.attr_bgColor:
            bgColor = (reader.Value == null ? string.Empty : reader.Value);
            break;

              case ReadWordsStyle.attr_fontWeight:
            fontWeight = (reader.Value == null ? string.Empty : reader.Value);
            break;

              case ReadWordsStyle.attr_FontStyle:
            FontStyle = (reader.Value == null ? string.Empty : reader.Value);
            break;

              case XMLNameSpace:
            break;

              default:
            if (reader.Name.Trim().Length > 0 && reader.Name != XMLComment)
              logger.Warn("Parsing the XML child:'" + reader.Name + "' of '" + ReadLexerType.XMLName + "' is not implemented.");
              break;
            }
              }

              ret = new WordsStyle(name);

              if (fgColor != string.Empty)
            ret.fgColor = ReadWordsStyle.SetColorFromString(ReadWordsStyle.attr_fgColor, fgColor);

              if (bgColor != string.Empty)
            ret.bgColor = ReadWordsStyle.SetColorFromString(ReadWordsStyle.attr_bgColor, bgColor);

              if (fontWeight != string.Empty)
            ret.fontWeight = ParseFontWeight(ReadWordsStyle.attr_fontWeight, fontWeight, FontWeightConverter);

              if (FontStyle != string.Empty)
            ret.fontStyle = ParseFontStyle(ReadWordsStyle.attr_FontStyle, FontStyle, FontStyleConverter);

              return ret;
        }
コード例 #11
0
ファイル: Read.cs プロジェクト: joazlazer/ModdingStudio
        /// <summary>
        /// Convert a string representation into a null-able <seealso cref="FontWeight"/> object and return it.
        /// </summary>
        /// <param name="stringAttribName"></param>
        /// <param name="fontWeight"></param>
        /// <param name="converter"></param>
        /// <returns></returns>
        protected static FontWeight? ParseFontWeight(string stringAttribName, string fontWeight, FontWeightConverter converter)
        {
            if (string.IsNullOrEmpty(fontWeight))
            return null;

              try
              {
            return (FontWeight?)converter.ConvertFromInvariantString(fontWeight);
              }
              catch (Exception exp)
              {
            throw new Exception(string.Format(CultureInfo.InvariantCulture, "Invalid FontWeight attribute value '{0}'=\"{1}\"", stringAttribName, fontWeight), exp);
              }
        }
コード例 #12
0
ファイル: PrintOut.cs プロジェクト: heinzsack/DEV
        private void CreateProjektForFaerbigeProjektKartenPage(FlowDocument ActuallDocument, DataRow ProjektRow,
            DataTable ConnectedActivities, DataTable Plakate, String PrintThisSecurityGroup,
            bool FullDataPresentationIsTrue, bool ShowDiskussionselemente, bool ShowPlakate = false)
            {
            BrushConverter BRConverter = new BrushConverter();
            ThicknessConverter ThickConverter = new ThicknessConverter();
            FontWeightConverter FWConverter = new FontWeightConverter();

            String ArbeitsGruppenNameID = ProjektRow["ArbeitsGruppenNameID"].ToString();
            String ArbeitsGruppenBeschreibung = String.Empty;
            foreach (DataRow AGRow in Basics.Instance.ArbeitsGruppen.Values)
                {
                if (AGRow["NameID"].ToString() == ArbeitsGruppenNameID)
                    {
                    ArbeitsGruppenBeschreibung = AGRow["LangName"].ToString();
                    break;
                    }
                }
            String Ortsteil = ProjektRow["Ortsteil"].ToString();
            String OrtsName = DataWrapper.Instance.GetOrteBezeichnung(ProjektRow);
            String NameID = ProjektRow["NameID"].ToString();
            String Wertigkeit = "Der Vorschlag hat keine Wertigkeitspunkte erhalten";
            if ((System.Guid) ProjektRow["ZustaendigID"] != System.Guid.Parse("EF0EFA6B-6884-4B54-9FDE-BCC575AE0D2A"))
                {
                Wertigkeit = "Für diesen Vorschlag ist nicht der "
                             +
                             Basics.Instance.Zustaendig["EF0EFA6B-6884-4B54-9FDE-BCC575AE0D2A".ToLower()]["NameID"]
                                 .ToString() +
                             " zuständig, sondern die Zuständigkeit ist \"" + ProjektRow["Zustaendig"].ToString() + "\"";
                }
            if ((ProjektRow["Wertigkeit"] != Convert.DBNull)
                && (Convert.ToInt32(ProjektRow["Wertigkeit"]) > 0))
                {
                Wertigkeit = "Das Projekt hat " + ProjektRow["Wertigkeit"].ToString() + " Wertigkeitspunkte erhalten";
                }
            String ProjektLangBeschreibung = ProjektRow["ProjektLangBeschreibung"].ToString();
            String NumericProjektID = ProjektRow["NumericProjektID"].ToString().Substring(3);
            String SymbolFarbe = GetSymbolColor(ConnectedActivities);

            //String Type = ProjektRow ["ProjektTyp"].ToString ();
            //String Wer = ProjektRow ["Wer"].ToString ();
            String OeffentlicheAktivitaetsInfo = GetOeffentlicheAktivitaetsInfo(ConnectedActivities);
//			ProjektRow ["TypenBeschreibung"].ToString ();


            Section ProjektSection = new Section();
            Paragraph NewPage = new Paragraph();
            NewPage.BreakPageBefore = true;
            ProjektSection.Blocks.Add(NewPage);
            ProjektSection.BreakPageBefore = true;
            ProjektSection.BorderThickness = (Thickness) ThickConverter.ConvertFromString("2");
            ProjektSection.BorderBrush = (Brush) BRConverter.ConvertFromString("Blue");
            ProjektSection.Tag = ProjektRow;

            TextPointer Start = ActuallDocument.ContentStart;
            Paragraph PArbeitsGruppenNameID = null;
            if (FullDataPresentationIsTrue)
                PArbeitsGruppenNameID = new Paragraph(new Run(ArbeitsGruppenNameID + " - " + ArbeitsGruppenBeschreibung
                                                              + "    (" + GetSortierFolge(ProjektRow) + ")"));
            else
                PArbeitsGruppenNameID = new Paragraph(new Run(ArbeitsGruppenNameID + " - " + ArbeitsGruppenBeschreibung
                                                              + "    (" + SymbolFarbe + " - " +
                                                              GetSortierFolge(ProjektRow) + ")"));
            PArbeitsGruppenNameID.FontSize = 14;
            PArbeitsGruppenNameID.BreakPageBefore = true;
            ProjektSection.Blocks.Add(PArbeitsGruppenNameID);

            List<String> BetreuerListe = WordUp23.DataWrapper.Instance.GetArbeitsGruppenMitarbeiter
                (ProjektRow, "8C2645EF-EED3-4169-8E63-DAE1F5CB55C6", (FullDataPresentationIsTrue == false)); // Betreuer
            Paragraph PArbeitsGruppenBetreuerHeadLine = new Paragraph(new Run("Verantwortliche Betreuer"));
            PArbeitsGruppenBetreuerHeadLine.FontSize = 8;
            PArbeitsGruppenBetreuerHeadLine.TextAlignment = TextAlignment.Right;
            ProjektSection.Blocks.Add(PArbeitsGruppenBetreuerHeadLine);
            foreach (String BetreuerDaten in BetreuerListe)
                {
                Paragraph PArbeitsGruppenBetreuer = new Paragraph(new Run(BetreuerDaten));
                PArbeitsGruppenBetreuer.FontSize = 10;
                PArbeitsGruppenBetreuer.TextAlignment = TextAlignment.Right;
                ProjektSection.Blocks.Add(PArbeitsGruppenBetreuer);
                }

            Paragraph PIntermediate1 = new Paragraph(new Run(""));
            PIntermediate1.FontSize = 10;
            PIntermediate1.Inlines.Add(new LineBreak());
            ProjektSection.Blocks.Add(PIntermediate1);

            Paragraph PProjektName = new Paragraph(new Run(Ortsteil + " - " + OrtsName + " - " + NameID));
            PProjektName.Inlines.Add(new LineBreak());
            PProjektName.FontSize = 18;
            PProjektName.FontWeight = (FontWeight) FWConverter.ConvertFromString("Bold");
            ProjektSection.Blocks.Add(PProjektName);

            Paragraph PProjektLangBeschreibung = new Paragraph(new Run(ProjektLangBeschreibung));
            //PProjektLangBeschreibung.Inlines.Add (new LineBreak ());
            PProjektLangBeschreibung.FontSize = 28;
            PProjektLangBeschreibung.TextAlignment = TextAlignment.Center;
            PProjektLangBeschreibung.FontWeight = (FontWeight) FWConverter.ConvertFromString("Bold");
            ProjektSection.Blocks.Add(PProjektLangBeschreibung);

            Paragraph PlakatHeadLineParagraph = new Paragraph();
            PlakatHeadLineParagraph.Inlines.Add(new LineBreak());
            PlakatHeadLineParagraph.Inlines.Add(new Run(Wertigkeit));
            PlakatHeadLineParagraph.Inlines.Add(new LineBreak());
            ActuallDocument.Blocks.Add(ProjektSection);

            if (ShowPlakate)
                {
                PlakatHeadLineParagraph.Inlines.Add(
                    new Run("Dieses/r Projekt/Vorschlag entstand aus folgenden Plakateinträgen:"));
                PlakatHeadLineParagraph.Inlines.Add(new LineBreak());
                PlakatHeadLineParagraph.FontSize = 12;
                ProjektSection.Blocks.Add(PlakatHeadLineParagraph);
                FlowDocumentBasis PlakatDoc = new FlowDocumentBasis();
                ActuallDocument.Blocks.Add(PlakatDoc.FillPlakateTable(String.Empty, String.Empty, Plakate));
                ActuallDocument.Blocks.LastBlock.Margin = new Thickness(30, 0, 0, 0);
                }
            Paragraph NewLineParagraph = new Paragraph(new Run(""));
            NewLineParagraph.FontSize = 10;
            NewLineParagraph.Inlines.Add(new LineBreak());
            ActuallDocument.Blocks.Add(NewLineParagraph);

            Paragraph OeffAktivitaet = new Paragraph(new Run(OeffentlicheAktivitaetsInfo));
            OeffAktivitaet.Inlines.Add(new LineBreak());
            ActuallDocument.Blocks.Add(OeffAktivitaet);

            FlowDocumentBasis AktivitaetDoc = new FlowDocumentBasis();
            ActuallDocument.Blocks.Add(AktivitaetDoc.FillActivitiesTable(PrintThisSecurityGroup, ConnectedActivities,
                new List<String>() {"FF793540-F928-4D38-BC42-0C61E9CCD649"}));
            ActuallDocument.Blocks.LastBlock.Margin = new Thickness(30, 0, 0, 10);


            Section FinalProjektSection = new Section();
            if (ShowDiskussionselemente)
                {
                String Line1 = "Soll weiter verfolgt werden ja / nein _________________________________________________";
                String Line2 =
                    "Wenn Begehung erforderlich - Treffpunkt / wann (Datum&Uhrzeit): ________________________";
                String Line3 = "Kontaktperson(en) bitte mit Name & HandyNummer: ___________________________________";
                //String MoeglicheBegehungsTermine = String.Join ("\r\n", GetMoeglicheBegehungen ().ToArray ());

                Paragraph PFormularTeil1 = new Paragraph(new LineBreak());
                PFormularTeil1.FontSize = 14;
                PFormularTeil1.Inlines.Add(new Run(Line1));
                PFormularTeil1.Inlines.Add(new LineBreak());
                PFormularTeil1.Inlines.Add(new LineBreak());
                FinalProjektSection.Blocks.Add(PFormularTeil1);
                Paragraph PFormularTeil2 = new Paragraph(new Run(Line2));
                PFormularTeil2.FontSize = 14;
                FinalProjektSection.Blocks.Add(PFormularTeil2);

                PFormularTeil2.Inlines.Add(new LineBreak());
                PFormularTeil2.Inlines.Add(new LineBreak());
                Paragraph PFormularTeil3 = new Paragraph(new Run(Line3));
                PFormularTeil3.FontSize = 14;
                PFormularTeil3.Inlines.Add(new LineBreak());
                PFormularTeil3.Inlines.Add(new LineBreak());
                FinalProjektSection.Blocks.Add(PFormularTeil3);

                Paragraph PVorschlagHeadLine = new Paragraph(new Run("Termin Möglichkeiten"));
                PVorschlagHeadLine.FontSize = 8;
                PVorschlagHeadLine.TextAlignment = TextAlignment.Right;
                PVorschlagHeadLine.Inlines.Add(new LineBreak());
                FinalProjektSection.Blocks.Add(PVorschlagHeadLine);

                foreach (String MoeglicherBegehungsTermin in GetMoeglicheBegehungen())
                    {
                    Paragraph PMoeglicherBegehungsTermin = new Paragraph(new Run(MoeglicherBegehungsTermin));
                    PMoeglicherBegehungsTermin.TextAlignment = TextAlignment.Right;
                    PMoeglicherBegehungsTermin.FontSize = 10;
                    FinalProjektSection.Blocks.Add(PMoeglicherBegehungsTermin);
                    }

                int PageLengthUpToNow = 0;
                TextPointer Stop = ActuallDocument.ContentEnd;
                PageLengthUpToNow = Start.GetOffsetToPosition(Stop);
                int LoopCounter = (1350 - PageLengthUpToNow)/90;
                while (LoopCounter-- > 0)
                    {
                    Paragraph PIntermediate3 = new Paragraph(new Run(""));
                    PIntermediate3.Inlines.Add(new LineBreak());
                    FinalProjektSection.Blocks.Add(PIntermediate3);
                    }
                }
            Paragraph PPageFooter = new Paragraph(new Run("Karte Nr.: " + GetSortierFolge(ProjektRow)
                                                          + ", Erzeugt am " +
                                                          DateTime.Now.ToString(WMB.Basics.ISO_DATE_TIME_FORMAT)));
            PPageFooter.FontSize = 10;
            PPageFooter.Inlines.Add(new LineBreak());
            PPageFooter.Inlines.Add(new LineBreak());
            PPageFooter.Inlines.Add(new LineBreak());
            PPageFooter.Inlines.Add(new LineBreak());
            PPageFooter.Inlines.Add(new Run("InsertPageBreakHere"));
            FinalProjektSection.Blocks.Add(PPageFooter);

            ActuallDocument.Blocks.Add(FinalProjektSection);

            //if (FullDataPresentationIsTrue)
            //    ProjektBlock.Blocks.Add (new PageBreak ())
            }
コード例 #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextEditorOptionsPageViewModel"/> class.
        /// </summary>
        /// <param name="textExtension">The <see cref="TextExtension"/>.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="textExtension"/> is <see langword="null"/>.
        /// </exception>
        public TextEditorOptionsPageViewModel(TextExtension textExtension)
            : base("Text Editor")
        {
            if (textExtension == null)
                throw new ArgumentNullException(nameof(textExtension));

            _textExtension = textExtension;
            Options = new TextEditorOptions();
            SetDefaultsCommand = new DelegateCommand(SetDefaults);
            SelectFontCommand = new DelegateCommand(SelectFont);

            _fontStretchConverter = new FontStretchConverter();
            _fontStyleConverter = new FontStyleConverter();
            _fontWeightConverter = new FontWeightConverter();
        }
コード例 #14
0
        //--------------------------------------------------------------
        #region Creation & Cleanup
        //--------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the <see cref="TextEditorOptionsPageViewModel"/> class. 
        /// (Do not use this constructor it is only for design-time support!)
        /// </summary>
        public TextEditorOptionsPageViewModel()
            : base("Text Editor")
        {
            Trace.Assert(WindowsHelper.IsInDesignMode, "This TextEditorOptionsPageViewModel constructor must not be used at runtime.");
            Options = new TextEditorOptions();
            _fontStyleConverter = new FontStyleConverter();
            _fontWeightConverter = new FontWeightConverter();
        }
コード例 #15
0
ファイル: FontConverter.cs プロジェクト: borkaborka/gmit
      /// <summary/>
      public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
         if (value == null) {
            throw new ArgumentNullException("value");
         }
         var fontString = value as string;
         if (fontString.IsEmpty()) {
            return base.ConvertFrom(context, culture, value);
         }

         if (fontString.StartsWith("@") && fontString.IndexOf(",") < 0 && ResourceProvider != null) {
            return ResourceProvider.GetResource<Font>(fontString);
         }

         var fontFamily = Font.DefaultFamily;
         var fontSize = Font.DefaultSize;
         var fontWeight = Font.DefaultWeight;
         var fontStyle = Font.DefaultStyle;
         var fontStretch = Font.DefaultStretch;

         var parts = fontString.Trim().Split(_reComma);
         var nparts = parts.Length;
         if (nparts == 0) return null;
         if (nparts > 5) {
            throw new InvalidCastException();
         }
         for (var i = 0; i < nparts; i++) {
            parts[i] = parts[i].RemoveAll(new Regex(@"\,"));
         }

         if (nparts >= 1 && parts[0].NotEmpty()) {
            fontFamily = _parseFontFamily(context, culture, parts[0]);
         }
         if (nparts >= 2 && parts[1].NotEmpty()) {
            fontSize = Double.Parse(parts[1]);
         }
         if (nparts >= 3 && parts[2].NotEmpty()) {
            var converter = new FontWeightConverter();
            fontWeight = _parseFontWeight(context, culture, parts[2]);
         }
         if (nparts >= 4 && parts[3].NotEmpty()) {
            var converter = new FontStyleConverter();
            fontStyle = _parseFontStyle(context, culture, parts[3]);
         }
         if (nparts >= 5 && parts[4].NotEmpty()) {
            fontStretch = _parseFontStretch(context, culture, parts[4]);
         }

         var face = new Typeface(fontFamily, fontStyle, fontWeight, fontStretch);
         var font = new Font(face, fontSize);
         font.Freeze();
         return font;
      }
コード例 #16
0
        private void ResetFlowDocumentText()
        {
            Paragraph para = new Paragraph();

            if (MatchedTextLength == 0)
            {
                // If the length is zero, there's nothing selected. Just dump ALL
                // the text into the document and bail.
                Run run = new Run(LastExecutedInputText);
                para.Inlines.Add(run);
            }
            else
            {
                // Cut the last exec'd input text into three pieces - before the matched text (begin),
                // the matched text itself (middle), and after the matched text (end). The "middle" part is
                // the one that we'll apply style stuff to so that it stands out from the rest of the text.
                Run begin = new Run(LastExecutedInputText.Substring(0, MatchedTextIndex));
                Run middle = new Run(LastExecutedInputText.Substring(MatchedTextIndex, MatchedTextLength));

                _fontWeightConverter = new FontWeightConverter();
                _brushConverter = new BrushConverter();

                middle.FontWeight = (FontWeight)_fontWeightConverter.ConvertFrom("Bold");
                middle.Foreground = new SolidColorBrush(_applicationOptions.MatchedTextForegroundColor);
                middle.Background = new SolidColorBrush(_applicationOptions.MatchedTextBackgroundColor);
                Run end = new Run(LastExecutedInputText.Substring(MatchedTextIndex + MatchedTextLength));

                para.Inlines.AddRange(new Run[] { begin, middle, end });
            }

            _inputTextResultsFlowDocument.Blocks.Clear();
            _inputTextResultsFlowDocument.Blocks.Add(para);
        }
コード例 #17
0
ファイル: RootWindow.xaml.cs プロジェクト: heinzsack/DEV
		private void CreateTimeWindow ()
			{
			if (WMB.Basics.GetUserConfigurationSettingsValue ("WPMediaShowTimeBackground") != "On")
				return;
			BrushConverter BRConverter = new BrushConverter ();
			System.Windows.FontWeightConverter FWConverter = new FontWeightConverter ();
			System.Windows.Media.FontFamilyConverter FFConverter = new FontFamilyConverter ();

			m_TimeWindow = new System.Windows.Window ();
			m_TimeWindow.Width = ((double) m_CVM.VideoWidth) * 0.8;
			m_TimeWindow.Height = ((double) m_CVM.VideoHeight) * 0.2;
			m_TimeWindow.MaxWidth = ((double) m_CVM.VideoWidth) * 0.8;
			m_TimeWindow.MaxHeight = ((double) m_CVM.VideoHeight) * 0.2;
			m_TimeWindow.MinWidth = ((double) m_CVM.VideoWidth) * 0.8;
			m_TimeWindow.MinHeight = ((double) m_CVM.VideoHeight) * 0.2;
			m_TimeWindow.Top = ((double) m_CVM.VideoRectangle.Top) + ((double) m_CVM.VideoHeight) * 0.75; ;
			m_TimeWindow.Left = ((double) m_CVM.VideoRectangle.Left) + ((double) m_CVM.VideoWidth) * 0.1;
			m_TimeWindow.AllowsTransparency = true;
			m_TimeWindow.Topmost = false;
			Brush TransparentBrush = (Brush) BRConverter.ConvertFromString ("Transparent");
			m_TimeWindow.Background = TransparentBrush;
			m_TimeWindow.BorderBrush = TransparentBrush;
			m_TimeWindow.WindowStyle = System.Windows.WindowStyle.None;

			Grid RootGrid = m_XAMLHandling.CreateGrid (new int [] {1}, new int [] {1});
			RootGrid.Background = TransparentBrush;
			m_TimeWindow.Content = RootGrid;
			Viewbox ViewBoxControl = new Viewbox ();
			RootGrid.Children.Add (ViewBoxControl);
			m_BackGroundTimeTextBlock = new TextBlock();
			ViewBoxControl.Child = m_BackGroundTimeTextBlock;
			m_BackGroundTimeTextBlock.Text = "WPMedia";
			m_BackGroundTimeTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
			m_BackGroundTimeTextBlock.VerticalAlignment = VerticalAlignment.Center;
			m_BackGroundTimeTextBlock.Foreground = (Brush) BRConverter.ConvertFromString("AntiqueWhite");
			m_BackGroundTimeTextBlock.Background = TransparentBrush;
			m_BackGroundTimeTextBlock.FontFamily = (FontFamily) FFConverter.ConvertFromString ("Verdana");
			m_BackGroundTimeTextBlock.FontWeight = (FontWeight) FWConverter.ConvertFromString ("Bold");
			m_TimeWindow.Cursor = Cursors.None;
			m_TimeWindow.Show ();
			}
コード例 #18
0
ファイル: FontConversions.cs プロジェクト: growse/Feedling
        /// <summary>
        /// Convert FontWeight to string for serialization
        /// </summary>
        public static string FontWeightToString(FontWeight value)
        {
            string result;

            try
            {
                result = new FontWeightConverter().ConvertToString(value);
            }
            catch (NotSupportedException)
            {
                result = "";
            }

            return result;
        }
コード例 #19
0
 public static FontWeight ParseFontWeight(string fontWeightName)
 {
     var converter = new FontWeightConverter();
     return (FontWeight) converter.ConvertFromString(fontWeightName);
 }
コード例 #20
0
ファイル: XAMLHandling.cs プロジェクト: heinzsack/DEV
		public void InsertTextBlockIntoFlowDocument (FlowDocument Document, String Text,
						double WidthPercentage, double HeightPercentage,
						String FontStyle, double FontSizePercentage, double LeftPercentage,
						double TopPercentage, String Alignment, String Weight, String Color,
						double OriginalWidth, double OriginalHeight, double FontSizingBase)
			{
			FontWeightConverter FWConverter = new FontWeightConverter ();
			BrushConverter BRConverter = new BrushConverter ();
			Text = Text.Replace ("\r\n", "\n");
			Text = Text.Replace ("\r", "\n");
			//Text = Text.Replace ("\r", " ");
			if (Document.Blocks.Count == 0)
				{
				Paragraph Para = new Paragraph (new Run (""));
				Document.Blocks.Add (Para);
				if (Alignment == "Right")
					Para.TextAlignment = TextAlignment.Right;

				}
			Run ActuallRun = new Run(Text);
			ActuallRun.FontFamily = new FontFamily (FontStyle);
			ActuallRun.Foreground = (Brush)BRConverter.ConvertFromString (Color);
			ActuallRun.FontWeight = (FontWeight)FWConverter.ConvertFromString (Weight);
			TextPointer FirstPosition = Document.ContentEnd;
			(Document.Blocks.FirstBlock as Paragraph).Inlines.Add (ActuallRun);
			bool TextFit = false;
			double FontReduction = 1;
			while (!TextFit)
				{
				ActuallRun.FontSize = (FontSizingBase * FontSizePercentage / 100.0) * FontReduction;
				TextPointer LastPosition = Document.ContentEnd;
				TextFit = true;
				}
			}
コード例 #21
0
 // Initialize known object types
 internal static TypeConverter CreateKnownTypeConverter(Int16 converterId)
 { 
     TypeConverter o = null;
     switch (converterId) 
     { 
         case -42: o = new System.Windows.Media.Converters.BoolIListConverter(); break;
         case -46: o = new System.ComponentModel.BooleanConverter(); break; 
         case -53: o = new System.Windows.Media.BrushConverter(); break;
         case -61: o = new System.ComponentModel.ByteConverter(); break;
         case -70: o = new System.ComponentModel.CharConverter(); break;
         case -71: o = new System.Windows.Media.Converters.CharIListConverter(); break; 
         case -87: o = new System.Windows.Media.ColorConverter(); break;
         case -94: o = new System.Windows.Input.CommandConverter(); break; 
         case -96: o = new System.Windows.Markup.ComponentResourceKeyConverter(); break; 
         case -111: o = new System.Windows.CornerRadiusConverter(); break;
         case -114: o = new System.ComponentModel.CultureInfoConverter(); break; 
         case -115: o = new System.Windows.CultureInfoIetfLanguageTagConverter(); break;
         case -117: o = new System.Windows.Input.CursorConverter(); break;
         case -124: o = new System.ComponentModel.DateTimeConverter(); break;
         case -125: o = new System.Windows.Markup.DateTimeConverter2(); break; 
         case -130: o = new System.ComponentModel.DecimalConverter(); break;
         case -137: o = new System.Windows.Markup.DependencyPropertyConverter(); break; 
         case -138: o = new System.Windows.DialogResultConverter(); break; 
         case -174: o = new System.Windows.Media.DoubleCollectionConverter(); break;
         case -175: o = new System.ComponentModel.DoubleConverter(); break; 
         case -176: o = new System.Windows.Media.Converters.DoubleIListConverter(); break;
         case -188: o = new System.Windows.DurationConverter(); break;
         case -190: o = new System.Windows.DynamicResourceExtensionConverter(); break;
         case -201: o = new System.Windows.ExpressionConverter(); break; 
         case -204: o = new System.Windows.FigureLengthConverter(); break;
         case -215: o = new System.Windows.Media.FontFamilyConverter(); break; 
         case -216: o = new System.Windows.FontSizeConverter(); break; 
         case -218: o = new System.Windows.FontStretchConverter(); break;
         case -220: o = new System.Windows.FontStyleConverter(); break; 
         case -222: o = new System.Windows.FontWeightConverter(); break;
         case -240: o = new System.Windows.Media.GeometryConverter(); break;
         case -256: o = new System.Windows.GridLengthConverter(); break;
         case -267: o = new System.ComponentModel.GuidConverter(); break; 
         case -286: o = new System.Windows.Media.ImageSourceConverter(); break;
         case -299: o = new System.Windows.Input.InputScopeConverter(); break; 
         case -301: o = new System.Windows.Input.InputScopeNameConverter(); break; 
         case -306: o = new System.ComponentModel.Int16Converter(); break;
         case -314: o = new System.Windows.Media.Int32CollectionConverter(); break; 
         case -315: o = new System.ComponentModel.Int32Converter(); break;
         case -319: o = new System.Windows.Int32RectConverter(); break;
         case -324: o = new System.ComponentModel.Int64Converter(); break;
         case -338: o = new System.Windows.Input.KeyConverter(); break; 
         case -340: o = new System.Windows.Input.KeyGestureConverter(); break;
         case -342: o = new System.Windows.KeySplineConverter(); break; 
         case -344: o = new System.Windows.KeyTimeConverter(); break; 
         case -348: o = new System.Windows.LengthConverter(); break;
         case -387: o = new System.Windows.Media.Media3D.Matrix3DConverter(); break; 
         case -392: o = new System.Windows.Media.MatrixConverter(); break;
         case -410: o = new System.Windows.Input.ModifierKeysConverter(); break;
         case -411: o = new System.Windows.Input.MouseActionConverter(); break;
         case -415: o = new System.Windows.Input.MouseGestureConverter(); break; 
         case -423: o = new System.Windows.NullableBoolConverter(); break;
         case -445: o = new System.Windows.Media.PathFigureCollectionConverter(); break; 
         case -453: o = new System.Windows.Media.PixelFormatConverter(); break; 
         case -462: o = new System.Windows.Media.Media3D.Point3DCollectionConverter(); break;
         case -463: o = new System.Windows.Media.Media3D.Point3DConverter(); break; 
         case -467: o = new System.Windows.Media.Media3D.Point4DConverter(); break;
         case -473: o = new System.Windows.Media.PointCollectionConverter(); break;
         case -474: o = new System.Windows.PointConverter(); break;
         case -475: o = new System.Windows.Media.Converters.PointIListConverter(); break; 
         case -492: o = new System.Windows.PropertyPathConverter(); break;
         case -498: o = new System.Windows.Media.Media3D.QuaternionConverter(); break; 
         case -507: o = new System.Windows.Media.Media3D.Rect3DConverter(); break; 
         case -511: o = new System.Windows.RectConverter(); break;
         case -521: o = new System.Windows.Media.Animation.RepeatBehaviorConverter(); break; 
         case -538: o = new System.Windows.Markup.RoutedEventConverter(); break;
         case -545: o = new System.ComponentModel.SByteConverter(); break;
         case -563: o = new System.ComponentModel.SingleConverter(); break;
         case -568: o = new System.Windows.Media.Media3D.Size3DConverter(); break; 
         case -572: o = new System.Windows.SizeConverter(); break;
         case -615: o = new System.ComponentModel.StringConverter(); break; 
         case -619: o = new System.Windows.StrokeCollectionConverter(); break; 
         case -633: o = new System.Windows.TemplateBindingExpressionConverter(); break;
         case -635: o = new System.Windows.TemplateBindingExtensionConverter(); break; 
         case -637: o = new System.Windows.Markup.TemplateKeyConverter(); break;
         case -645: o = new System.Windows.TextDecorationCollectionConverter(); break;
         case -655: o = new System.Windows.ThicknessConverter(); break;
         case -664: o = new System.ComponentModel.TimeSpanConverter(); break; 
         case -681: o = new System.Windows.Media.TransformConverter(); break;
         case -692: o = new System.Windows.Markup.TypeTypeConverter(); break; 
         case -696: o = new System.ComponentModel.UInt16Converter(); break; 
         case -698: o = new System.ComponentModel.UInt32Converter(); break;
         case -700: o = new System.ComponentModel.UInt64Converter(); break; 
         case -701: o = new System.Windows.Media.Converters.UShortIListConverter(); break;
         case -705: o = new System.UriTypeConverter(); break;
         case -714: o = new System.Windows.Media.Media3D.Vector3DCollectionConverter(); break;
         case -715: o = new System.Windows.Media.Media3D.Vector3DConverter(); break; 
         case -722: o = new System.Windows.Media.VectorCollectionConverter(); break;
         case -723: o = new System.Windows.VectorConverter(); break; 
         case -757: o = new System.Windows.Markup.XmlLanguageConverter(); break; 
     }
     return o; 
 }
コード例 #22
0
ファイル: Highlight.cs プロジェクト: faboo/Agent
        public static FontWeight ParseWeight(string weightString)
        {
            FontWeight weight = FontWeights.Normal;
            FontWeightConverter converter = new FontWeightConverter();

            try {
                weight = (FontWeight)converter.ConvertFromString(weightString);
            }
            catch {
            }

            return weight;
        }