コード例 #1
0
        private void LoadState()
        {
            Log.Information("Loading State");
            var regAccessor             = new RegistryAccessor();
            var fontFamConverter        = new Media.FontFamilyConverter();
            var fontFamily              = regAccessor.Read("FONTFAMILY");
            var fontWeightToBeConverted = regAccessor.Read("FONTWEIGHT");
            var fontSize  = regAccessor.Read("FONTSIZE");
            var fontStyle = regAccessor.Read("FONTSYLE");

            if (fontFamily != null)
            {
                _formatModel.Family = fontFamConverter.ConvertFromString(fontFamily) as Media.FontFamily;
            }

            if (fontWeightToBeConverted != null)
            {
                _formatModel.Weight = FontWeight.FromOpenTypeWeight(Convert.ToInt32(regAccessor.Read("FONTWEIGHT")));
            }

            if (fontSize != null && fontSize != "0")
            {
                _formatModel.Size = Convert.ToDouble(fontSize);
            }

            if (fontStyle != null)
            {
                _formatModel.Style = ConvertFontSytleFromString(fontStyle);
            }
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: keyanmca/_Signage
 private void UpdateSampleTicker(DAL.Content sticker)
 {
     try
     {
         tbTickerSample.Text = sticker.Metadata8;
         FontFamilyConverter ffc = new FontFamilyConverter();
         FontFamily ff = new FontFamily();
         ff = (FontFamily)ffc.ConvertFromString(sticker.Metadata2);
         tbTickerSample.FontFamily = ff;
         tbTickerSample.FontSize = Convert.ToDouble(sticker.Metadata3);
         //Brush b = new
         //Color c = new Color();
         BrushConverter bc = new BrushConverter();
         tbTickerSample.Foreground = (Brush)bc.ConvertFromString(sticker.Metadata4);
         gridTickerBackground.Background = (Brush)bc.ConvertFromString(sticker.Metadata6);
         gridTickerBackground.Opacity = Convert.ToDouble(sticker.Metadata7);
     }
     catch (Exception ex)
     {
     }
 }
コード例 #3
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 ();
			}
コード例 #4
0
        private void MenuItemFontChange_Clicked(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.FontDialog fontDialog = new System.Windows.Forms.FontDialog();
            fontDialog.Font = new System.Drawing.Font(EditText1.FontFamily.ToString(), (float)EditText1.FontSize);

            if (fontDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                FontFamilyConverter ffc = new FontFamilyConverter();

                EditText1.FontSize = (double)fontDialog.Font.Size;
                EditText1.FontFamily = (FontFamily)ffc.ConvertFromString(fontDialog.Font.Name);

                /*
                if (fontDialog.Font.Bold)
                    textAnnotation.FontWeight = FontWeights.Bold;
                else
                    textAnnotation.FontWeight = FontWeights.Normal;

                if (fontDialog.Font.Italic)
                    textAnnotation.FontStyle = FontStyles.Italic;
                else
                    textAnnotation.FontStyle = FontStyles.Normal;
                */
            }
        }
コード例 #5
0
ファイル: Window1.xaml.cs プロジェクト: Ossir/WPF
 private void button8_Click(object sender, RoutedEventArgs e)
 {
     if (selTB != null)
     {
         selTB.Foreground = ChooseColor();
         using (System.Windows.Forms.FontDialog fd = new System.Windows.Forms.FontDialog())
         {
             try
             {
                 fd.AllowScriptChange = false;
                 fd.AllowSimulations = false;
                 if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                 {
                     FontFamilyConverter ffc = new FontFamilyConverter();
                     selTB.FontSize = fd.Font.Size;
                     selTB.FontFamily = (FontFamily)ffc.ConvertFromString(fd.Font.Name);
                 }
             }
             catch
             {
                 //Not a truetype font
                 MessageBox.Show("Шрифт не изменен");
             }
         }
     }
 }
コード例 #6
0
 private void btnReset_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         FontFamilyConverter converter = new FontFamilyConverter();
         FontFamily consolas = (FontFamily)converter.ConvertFromString("Consolas");
         Properties.Settings.Default.EditorFontFace = consolas;
         this.fontSizeSlider.Value = 13d;
         Properties.Settings.Default.EditorForeground = Colors.Black;
         Properties.Settings.Default.EditorBackground = Colors.White;
         Properties.Settings.Default.Save();
     }
     catch
     {
         //Can't reset settings
     }
     //Show settings
     this.ShowSettings();
 }
コード例 #7
0
 public void addPhoto(string path)
 {
     StackPanel sp = new StackPanel();
     Label label = new Label();
     label.HorizontalContentAlignment = HorizontalAlignment.Center;
     label.FontStyle = FontStyles.Italic;
     FontFamilyConverter ffc = new FontFamilyConverter();
     FontFamily f = ffc.ConvertFromString("Calibri") as FontFamily;
     label.FontFamily = f;
     Image img = new Image();
     sp.Children.Add(img);
     sp.Children.Add(label);
     BitmapImage bitmap = new BitmapImage();
     bitmap.BeginInit();
     bitmap.UriSource = new Uri(path);
     bitmap.EndInit();
     img.ToolTip = "Press space to preview photo";
     img.Source = bitmap;
     label.Content = System.IO.Path.GetFileName(img.Source.ToString());
     img.Height = 128;
     img.Width = 135;
     selectListBox.Items.Add(sp);
 }
コード例 #8
0
 private void fontComboBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     ComboBoxItem fontItem = (ComboBoxItem)fontComboBox.SelectedItem;
     string font = fontItem.Content.ToString();
     var fontFamilyConvertor = new FontFamilyConverter();
     send.FontFamily = fontFamilyConvertor.ConvertFromString(font) as FontFamily;
     myFont = font;
 }
コード例 #9
0
        private Paragraph CreateParagraph(string message)
        {
            Paragraph para = new Paragraph();
            para.BorderBrush = Brushes.Red;
            var emoticons = emoticonMap.Keys.Cast<string>();
            var color = Brushes.Red;
            para.Padding = new Thickness(0);
            var fontFamilyConvertor = new FontFamilyConverter();
            var font = fontFamilyConvertor.ConvertFromString("Segoe UI") as FontFamily;

            if (message.Contains("[col]")) {
                var colorCode = message.Substring(message.IndexOf("[col]") + 5, message.IndexOf("[/col]") - (message.IndexOf("[col]") + 5));
                message = message.Replace("[col]" + colorCode + "[/col]", "");
                color = GetColor(colorCode);

                var fontCode = message.Substring(message.IndexOf("[fon]") + 5, message.IndexOf("[/fon]") - (message.IndexOf("[fon]") + 5));
                message = message.Replace("[fon]" + fontCode + "[/fon]", "");
                font = fontFamilyConvertor.ConvertFromString(fontCode) as FontFamily;

                para.BorderBrush = color;
                para.FontFamily = font;

                var name = message.TakeWhile(elem => !(elem.Equals(':')));
                var parsedStringName = new string(name.ToArray());
                var regex = new Regex(parsedStringName);
                message = regex.Replace(message, "", 1);
                parsedStringName += message[0];
                message = message.Substring(1);
                para.AddText(parsedStringName, Brushes.Black);
            }
            var emoteExists = emoticons.Any(emote => message.Contains(emote));
            while (emoteExists || message.ToLower().Contains("https") || message.ToLower().Contains("http") || message.ToLower().Contains("www")) {
                message = message.Trim();
                if ("".Equals(message)) break;
                if (message.ToLower().StartsWith("https") || message.ToLower().StartsWith("http") || message.ToLower().StartsWith("www")) {
                    Hyperlink link = new Hyperlink();
                    link.IsEnabled = true;
                    link.Inlines.Add(" (Click) ");
                    var startIndex = message.IndexOf("https:");
                    if (startIndex == -1) startIndex = message.IndexOf("http:");
                    if (startIndex == -1) startIndex = message.IndexOf("www.");
                    if (startIndex != -1) {
                        var endIndex = message.IndexOf(" ", startIndex);
                        if (endIndex == -1) endIndex = message.Count();
                        var prefix = message.Substring(startIndex, endIndex - startIndex).StartsWith("www.") ? "http://" : "";
                        link.NavigateUri = new Uri(prefix + message.Substring(startIndex, endIndex - startIndex));
                        para.Inlines.Add(link);
                        link.RequestNavigate += new RequestNavigateEventHandler(link_RequestNavigate);
                        message = message.Replace(message.Substring(startIndex, endIndex - startIndex), "");
                    }
                } else if (emoticons.Any(emote => message.Substring(0, message.IndexOf(" ") == -1 ? message.Count() : message.IndexOf(" ")).Contains(emote))) {
                    var parsedMessage = message.TakeWhile(elem => !emoteStart.Contains(elem));
                    var parsedStringMessage = new string(parsedMessage.ToArray());
                    if (!parsedStringMessage.Equals("")) {
                        var regex = new Regex(parsedStringMessage);
                        message = regex.Replace(message, "", 1);
                        para.AddText(parsedStringMessage, color);
                    }
                    if (message.Count() == 0) break;
                    var emotes = emoticons.Where(emote => message.Substring(0, message.Count() < MAX_EMOTE_LENGTH ? message.Count() : MAX_EMOTE_LENGTH).Contains(emote));
                    if (emotes.Count() > 0) {
                        para.Inlines.Add(GetImageBySymbol(emotes.Last()));
                        message = message.Substring(emotes.Last().Count());
                    } else {
                        para.AddText("" + message[0], color);
                        message = message.Substring(1);
                    }
                } else {
                    para.AddText(message.Substring(0, message.IndexOf(" ") == -1 ? message.Count() : message.IndexOf(" ")) + " ", color);
                    var regex = new Regex(message.Substring(0, message.IndexOf(" ") == -1 ? message.Count() : message.IndexOf(" ")));
                    message = regex.Replace(message, "", 1);
                }
            }
            if (!"".Equals(message)) {
                para.AddText(message, color);
            }
            return para;
        }