Example #1
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            bool isrunning = (bool)value;

            if (targetType == typeof(TextDecorationCollection))
            {
                return(!isrunning ? null: TextDecorations.Underline);
            }
            else if (targetType == typeof(FontWeight))
            {
                return(isrunning ? _weightConverter.ConvertFrom("Bold") : _weightConverter.ConvertFrom("Normal"));
            }
            return(null);
        }
        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);
        }
Example #3
0
        private void SelectFont()
        {
            var fontDialog = new FontDialog();

            if (!string.IsNullOrEmpty(Options.FontFamily))
            {
                fontDialog.Chooser.SelectedFontFamily = new FontFamily(Options.FontFamily);
            }
            if (Options.FontSize > 0)
            {
                fontDialog.Chooser.SelectedFontSize = Options.FontSize;
            }

            // ReSharper disable PossibleNullReferenceException
            if (!string.IsNullOrEmpty(Options.FontStretch))
            {
                fontDialog.Chooser.SelectedFontStretch = (FontStretch)_fontStretchConverter.ConvertFrom(Options.FontStretch);
            }
            if (!string.IsNullOrEmpty(Options.FontStyle))
            {
                fontDialog.Chooser.SelectedFontStyle = (FontStyle)_fontStyleConverter.ConvertFrom(Options.FontStyle);
            }
            if (!string.IsNullOrEmpty(Options.FontWeight))
            {
                fontDialog.Chooser.SelectedFontWeight = (FontWeight)_fontWeightConverter.ConvertFrom(Options.FontWeight);
            }
            // ReSharper restore PossibleNullReferenceException

            var result = fontDialog.ShowDialog();

            if (result.GetValueOrDefault())
            {
                Options.FontFamily  = fontDialog.Chooser.SelectedFontFamily.ToString();
                Options.FontSize    = fontDialog.Chooser.SelectedFontSize;
                Options.FontStyle   = fontDialog.Chooser.SelectedFontStyle.ToString();
                Options.FontStretch = fontDialog.Chooser.SelectedFontStretch.ToString();
                Options.FontWeight  = fontDialog.Chooser.SelectedFontWeight.ToString();
                RaisePropertyChanged(() => Font);
            }
        }
Example #4
0
        private SSSymbolViewModel BuildSymbolViewModel(XRNANucleotide symbol)
        {
            SSSymbolViewModel retValue = new SSSymbolViewModel(symbol.Sequence.RawData[symbol.Index], symbol.Index + 1,
                                                               new FontFamily(symbol.FontFace), (FontStyle)_fscvtr.ConvertFrom(symbol.FontStyle), (FontWeight)_fwcvtr.ConvertFrom(symbol.FontWeight), (Brush)_colorCvtr.ConvertFrom(symbol.Color),
                                                               symbol.FontSize, symbol.Center.X, symbol.Center.Y);

            retValue.Visible = !symbol.Hidden;
            return(retValue);
        }