예제 #1
0
        // -----------------------------------------------------------------------------------------
        public FrameworkElement GetPropertyValueExpositor(object Value, TextFormat Format = null,
                                                          double MaxValueWidth            = double.PositiveInfinity,
                                                          double MaxValueHeight           = double.PositiveInfinity)
        {
            FrameworkElement Result = null;

            if (Value is MAssignment)
            {
                Value = ((MAssignment)Value).AssignedValue;
            }

            if (Value is ImageSource)
            {
                var PictureLabel = new Border();
                // PictureLabel.BorderThickness = new Thickness(LINES_PROP_THICKNESS);
                // PictureLabel.BorderBrush = this.Configuration.FmtCardLinesForeground;
                var Picture = new Image();
                Picture.Source     = this.CurrentWorker.AtOriginalThreadGetFrozen((ImageSource)Value);
                PictureLabel.Child = Picture;

                Result = PictureLabel;
            }
            else
            {
                var TxbValue = new TextBlock();
                TxbValue.Text = (Value is IIdentifiableElement
                                 ? ((IIdentifiableElement)Value).Name
                                 : Value.ToStringAlways());

                if (Format == null)
                {
                    Format = this.Configuration.FmtListFieldValue;
                }

                TxbValue.FontFamily      = Format.CurrentTypeface.FontFamily;
                TxbValue.FontSize        = Format.FontSize;
                TxbValue.TextAlignment   = Format.Alignment;
                TxbValue.FontWeight      = Format.CurrentTypeface.Weight;
                TxbValue.FontStyle       = Format.CurrentTypeface.Style;
                TxbValue.TextDecorations = Format.GetCurrentDecorations();
                TxbValue.TextWrapping    = TextWrapping.Wrap;

                Result = TxbValue;
            }

            Result.MaxWidth  = MaxValueWidth;
            Result.MaxHeight = MaxValueHeight;

            return(Result);
        }
        // -----------------------------------------------------------------------------------------
        public FrameworkElement CreateText(string Text, TextFormat Format,
                                           HorizontalAlignment HorizontalAlign = HorizontalAlignment.Stretch,
                                           VerticalAlignment VerticalAlign     = VerticalAlignment.Center,
                                           Brush Background             = null, TextWrapping Wrapping = TextWrapping.Wrap,
                                           bool InterpretTextAsVariable = false)
        {
            var Result = new Border();

            Result.VerticalAlignment   = VerticalAlign;
            Result.HorizontalAlignment = HorizontalAlign;

            /* Result.HorizontalAlignment = (HorizontalAlign == null || !HorizontalAlign.HasValue
             *                            ? Format.Alignment.ToHorizontalAlignment() : HorizontalAlign.Value); */
            Result.Padding    = new Thickness(CARD_TEXT_PADDING);
            Result.Background = Background;

            var Content = new TextBlock();

            if (InterpretTextAsVariable &&
                Text.StartsWith(ReportingManager.VARIABLE_REF_INI) &&
                Text.EndsWith(ReportingManager.VARIABLE_REF_END))
            {
                Text = GetVariableValue(Text);
            }

            Content.Text = Text;

            Content.Foreground      = Format.ForegroundBrush;
            Content.FontFamily      = Format.CurrentTypeface.FontFamily;
            Content.FontSize        = Format.FontSize;
            Content.TextAlignment   = Format.Alignment;
            Content.FontWeight      = Format.CurrentTypeface.Weight;
            Content.FontStyle       = Format.CurrentTypeface.Style;
            Content.TextDecorations = Format.GetCurrentDecorations();
            Content.TextWrapping    = TextWrapping.Wrap;

            Result.Child = Content;

            return(Result);
        }
예제 #3
0
        CreateListHeader(ReportStandardPagesMaker PagesMaker,
                         Dictionary <string, Capsule <string, double, Func <IMModelClass, object> > > ColumnDefs,                // TechName + (Name + ColStarWidth)
                         TextFormat ColTitleFormat, Brush TitleBackground,
                         Brush BorderForeground              = null,
                         VerticalAlignment VerticalAlign     = VerticalAlignment.Stretch,
                         HorizontalAlignment HorizontalAlign = HorizontalAlignment.Stretch)
        {
            var Frame = new Grid();

            Frame.Width = this.WorkingPageContentWidth - PagesMaker.NestingMargin;

            var ColSpecs = new Dictionary <string, Capsule <double, Func <IMModelClass, object> > >();

            if (BorderForeground == null)
            {
                BorderForeground = ColTitleFormat.ForegroundBrush;
            }

            foreach (var ColDef in ColumnDefs)
            {
                Frame.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(ColDef.Value.Value1, GridUnitType.Star)
                });
            }

            var ColIndex = 0;

            foreach (var ColDef in ColumnDefs)
            {
                ColSpecs.Add(ColDef.Key, Capsule.Create(0.0, ColDef.Value.Value2));

                var BrdCell = new Border();
                BrdCell.Tag                 = ColDef.Key;
                BrdCell.Background          = TitleBackground;
                BrdCell.BorderBrush         = BorderForeground;
                BrdCell.BorderThickness     = new Thickness(LINES_LIST_THICKNESS);
                BrdCell.VerticalAlignment   = VerticalAlign;
                BrdCell.HorizontalAlignment = HorizontalAlign;
                BrdCell.Padding             = new Thickness(CARD_TEXT_PADDING);

                var TxbTitle = new TextBlock();
                TxbTitle.Text            = ColDef.Value.Value0;
                TxbTitle.FontFamily      = ColTitleFormat.CurrentTypeface.FontFamily;
                TxbTitle.FontSize        = ColTitleFormat.FontSize;
                TxbTitle.TextAlignment   = ColTitleFormat.Alignment;
                TxbTitle.FontWeight      = ColTitleFormat.CurrentTypeface.Weight;
                TxbTitle.FontStyle       = ColTitleFormat.CurrentTypeface.Style;
                TxbTitle.TextDecorations = ColTitleFormat.GetCurrentDecorations();
                TxbTitle.TextWrapping    = TextWrapping.Wrap;

                BrdCell.Child = TxbTitle;

                Frame.Children.Add(BrdCell);
                Grid.SetColumn(BrdCell, ColIndex);

                ColIndex++;
            }

            Frame.UpdateVisualization(this.WorkingPageContentWidth - PagesMaker.NestingMargin,
                                      PagesMaker.PageRemainingHeight /*? this.WorkingPageContentHeight*/);

            foreach (var Label in Frame.Children.OfType <FrameworkElement>())
            {
                ColSpecs[Label.Tag.ToStringAlways()].Value0 = Label.ActualWidth;
            }

            Frame.Tag = ReportStandardPagesMaker.PAGE_TOP_CONTENT_TAG;  // Declare the result as page-top content.
            var Result = Tuple.Create((FrameworkElement)Frame, ColSpecs);

            return(Result);
        }