Telerik Forums
UI for WPF Forum
1 answer
239 views

I have the following extension method in my application. It captures previews of my usercontrols and allows the user to navigate them via a menu.

 

/// <summary>
/// Renders a framework element as a bitmap image.
/// </summary>
/// <param name="frameworkElement">The framework element to be rendered.</param>
/// <param name="background">The background to be applied to the element, in case the element has trasnparent background.</param>
/// <param name="scale">The scaling of the image, default should be 1.</param>
/// <returns>The image as a scaled bitmap.</returns>
public static BitmapImage RenderToBitmap(this FrameworkElement frameworkElement, Brush background, double scale = 1)
{
    Check.NotNull(frameworkElement, "frameworkElement");
 
 
    var renderWidth = (int)(frameworkElement.RenderSize.Width * scale);
    var renderHeight = (int)(frameworkElement.RenderSize.Height * scale);
 
    if (renderWidth > 0 && renderHeight > 0)
    {
        var renderTarget = new RenderTargetBitmap(renderWidth, renderHeight, 96, 96, PixelFormats.Default);
 
        var sourceBrush = new VisualBrush(frameworkElement);
 
        var drawingVisual = new DrawingVisual();
 
        var rect = new Rect(new Point(0, 0), new Point(frameworkElement.RenderSize.Width, frameworkElement.RenderSize.Height));
 
        using (var drawingContext = drawingVisual.RenderOpen())
        {
            drawingContext.PushTransform(new ScaleTransform(scale, scale));
            drawingContext.DrawRectangle(background, null, rect);
            drawingContext.DrawRectangle(sourceBrush, null, rect);
        }
 
        renderTarget.Render(drawingVisual);
 
        var image = new BitmapImage();
 
        using (MemoryStream memoryStream = new MemoryStream())
        {
            JpegBitmapEncoder encoder = new JpegBitmapEncoder();
 
            encoder.Frames.Add(BitmapFrame.Create(renderTarget));
 
            encoder.Save(memoryStream);
 
            image.BeginInit();
            image.StreamSource = new MemoryStream(memoryStream.ToArray());
            image.EndInit();
        }
 
        return image;
    }
 
    return null;
}

 

Lately we've started a new development with the radmap control and we started to have some issues. The app hanged whenever we entered the view containing the map. I profiled the app and the results tell me that there's an issue with the radmap control.

 

I've started trying stuff and I realized that the problem starts when I try to generate the visual before the image creation. If I instead do renderTarget.Render(frameworkElement) it seems to work, but then I can't apply the background transformation to the visual. The problem starts when I use the map to create a VisualBrush. Could this be a bug? 

 

Thanks for your time.

 

 

Petar Mladenov
Telerik team
 answered on 15 Jan 2016
3 answers
165 views

Hello

 The following HTML code looks very different when loaded in the RichTextBox compared to the Broswer version.

Check the attached images.

 

<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Listagem Módulos Montados</title>
  </head>
  <body>
    <table align="center" border="0">
      <thead id="HEADER">
        <tr>
          <td align="middle">
            <table width="630" border="0">
              <tbody>
                <tr>
                  <td style="FONT-WEIGHT: bold; FONT-SIZE: 12px; COLOR: #808080; PADDING-TOP: 20px; FONT-FAMILY: Arial" width="400">Data: 
12/01/2016<span style="MARGIN: 0px; WIDTH: 10px"></span> Hora: 
11:29:02</td>
                  <td style="FONT-WEIGHT: bold; FONT-SIZE: 12px; COLOR: #808080; PADDING-TOP: 20px; FONT-FAMILY: Arial" align="right">Listagem 
</td>
                </tr>
              </tbody>
            </table>
          </td>
        </tr>
      </thead>
      <tbody>
        <tr id="CUSTOMERDATA">
          <td valign="top">
            <table style="BORDER-RIGHT: #818181 1px solid; BORDER-TOP: #818181 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #818181 1px solid; BORDER-BOTTOM: #818181 1px solid; FONT-FAMILY: Tahoma; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
              <tbody>
                <tr>
                  <td style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; FONT-SIZE: 16px; PADDING-BOTTOM: 5px; COLOR: #808080; PADDING-TOP: 5px; BORDER-BOTTOM: #818181 1px solid" bgcolor="#eeeeee"><b>Dados do cliente:
</b></td>
                </tr>
                <tr>
                  <td style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; LINE-HEIGHT: 20px; PADDING-TOP: 5px" width="592" height="22">
                    <table cellspacing="5" cellpadding="2" width="100%" border="0">
                      <tbody>
                        <tr>
                          <td style="FONT-SIZE: 10px"><b><span style="COLOR: #535353">Nome:
</span></b></td>
                          <td style="FONT-SIZE: 10px"><b><span style="COLOR: #535353">CPF:
</span></b></td>
                        </tr>
                        <tr>
                          <td style="FONT-SIZE: 10px"><b><span style="COLOR: #535353">Endereço:
</span></b></td>
                          <td style="FONT-SIZE: 10px"><b><span style="COLOR: #535353">CEP:
</span></b></td>
                        </tr>
                        <tr>
                          <td style="FONT-SIZE: 10px"><b><span style="COLOR: #535353">Bairro:
</span></b></td>
                          <td style="FONT-SIZE: 10px"><b><span style="COLOR: #535353">UF:
</span></b></td>
                        </tr>
                        <tr>
                          <td style="FONT-SIZE: 10px"><b><span style="COLOR: #535353">End. Entrega:
</span></b></td>
                          <td style="FONT-SIZE: 10px"><b><span style="COLOR: #535353">Cidade:
</span></b></td>
                        </tr>
                        <tr>
                          <td style="FONT-SIZE: 10px"><b><span style="COLOR: #535353">Telefone:
</span></b></td>
                          <td style="FONT-SIZE: 10px"><b><span style="COLOR: #535353">Celular:
</span></b></td>
                        </tr>
                        <tr>
                          <td style="FONT-SIZE: 10px" colspan="2"><b><span style="COLOR: #535353">E-mail:
</span></b></td>
                        </tr>
                      </tbody>
                    </table>
                  </td>
                </tr>
              </tbody>
            </table>
          </td>
        </tr>
        <tr id="BODY" templatetext="Módulos montados por categoria">
          <td valign="top"></td>
        </tr>
        <tr id="OBSERVATIONS">
          <td valign="center">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td style="color:#818181;line-height:20px;padding:5px;font-size:10px;font-family:Arial;" valign="top" class="textoorc"><b><span style="color:#808080">Observações:</span></b><br></td>
              </tr>
            </table>
          </td>
        </tr>
      </tbody>
      <tfoot id="FOOTER">
        <tr>
          <td align="middle"><br><br><b><span style="COLOR: #535353">Razão social:
</span></b><span style="MARGIN: 0px; WIDTH: 5px"></span><span style="MARGIN: 0px; WIDTH: 10px"></span>| 
<span style="MARGIN: 0px; WIDTH: 10px"></span><b><span style="COLOR: #535353">Endereço:
</span></b><span style="MARGIN: 0px; WIDTH: 5px"></span><span style="MARGIN: 0px; WIDTH: 10px"></span> | 
<span style="MARGIN: 0px; WIDTH: 10px"></span><b><span style="COLOR: #535353">Telefone:
</span></b><span style="MARGIN: 0px; WIDTH: 5px"></span></td>
        </tr>
        <tr>
          <td align="middle"> Todos os direitos reservados
</td>
        </tr>
      </tfoot>
    </table>
  </body>
</html>

Maurício
Top achievements
Rank 1
 answered on 15 Jan 2016
6 answers
223 views
Hi,

I try to export my diagram to a list of images without success.

I use the following method : (the class inherit from RadDiagram)

public List<System.Drawing.Image> GetImages()
        {
            List<System.Drawing.Image> list = new List<System.Drawing.Image>();
            RadDiagramPagesInfo pagesInfo = this.CalculatePages(BackgroundPageGrid.GetPageSize(this), new Thickness());
            pagesInfo.Background = this.Background;
            pagesInfo.Dpi = 96d;
            foreach (WriteableBitmap writeableBitmap in pagesInfo.Pages)
            {
                using (MemoryStream stream = new MemoryStream())
                {
                    PngBitmapEncoder encoder = new PngBitmapEncoder();
                    encoder.Frames.Add(BitmapFrame.Create(writeableBitmap));
                    encoder.Save(stream);
                    list.Add(System.Drawing.Image.FromStream(stream));
                }
            }
            return (list);
        }

The problem is that pagesInfo.Pages is empty !

 Here is the call !

DiagramGraphSource graphSource = new DiagramGraphSource();
            graphSource.LoadProcedureSteps(steps.Cast<IStep>().ToList());
            diagram.GraphSource = graphSource;
            diagram.Measure(new System.Windows.Size(1000, 1000));
            diagram.Arrange(new Rect(new System.Windows.Size(1000, 1000)));
 
             
 
            return (diagram.GetImages().Select(x => new ImageObject { Image = x}).ToList());

Thanks a lot

 
 
 
Geoffrey
Top achievements
Rank 1
 answered on 14 Jan 2016
1 answer
115 views

Is it possible to disable the "Search as You Type" feature (Ctrl+F) shortcut?

 

Best regards

Michael

Maya
Telerik team
 answered on 14 Jan 2016
1 answer
201 views

I would like the user to be able to edit the text in the TimeSpanPicker or pick the values from the drop down. Is this supported?

 

Polya
Telerik team
 answered on 14 Jan 2016
6 answers
160 views

Hi,

 I have some question about GridView edit mode.

Question 1:

In the GridView's PerpareCellForEdit event, I have some business code for verifying whether the current cell can be edited. If business cannot let the cell be edited, I used CancelEdit() function to exit edit mode, but the CancelEdit() function will fire CellEditEnded event. I have some code for DB communication in that event. Do you have some way the can leave edit mode but don't fire CellEditEnded event?

Question 2:

When we double clicked a cell, it will change to edit mode. If we click the other cells or other places, it will leaves edit mode, but if we click the next cell in the same row, the next cell will still in the edit mode and fired CellEditEnded event and PrepareCellForEdit event. I don't  want to click the next cell in the same row stay with in edit mode, I want to leave edit mode when click the next cell. Is there a way to achieve it?

 

Than you

Stefan
Telerik team
 answered on 13 Jan 2016
9 answers
321 views
Hi,

I use a RadOutlookBar and I display an image (png) in the header section. The problem is that the image doesn't look the same when I look at it using the shell explorer vs in my RadOutlookBar. In my RadOutlookBar, the image is a little bit blurred... (the component seem's to magnify the image, the original size is 24x24 and in the componentm the isze is 30x30)

Here is my XAML code:

<

 

telerik:RadOutlookBarItem Header="{StaticResource Files}" FontWeight="Bold" Icon="Resources/Files_24x24.png" SmallIcon="Resources/Files_16x16.png" Tag="Files">

 


Thank's
Palani
Top achievements
Rank 1
Iron
 answered on 13 Jan 2016
1 answer
198 views
Hi! I'm very beginner in using of Telerik controls and interesting in the following subject: What is the difference between Chart control and ChartView control? Which of them has more capabilities and so that is more powerful for development of charts that are displaying information in real-time?
 
 
Dinko | Tech Support Engineer
Telerik team
 answered on 13 Jan 2016
1 answer
58 views
Hi, I need to get a hold of VisualStudio2013 theme files from release 2015 Q1. I downloaded Telerik_UI_for_WPF_2015_1_0401_Themes.zip but that theme is not part of that download - many others are but not this one. Where can I get it? Thanks.
Eric
Top achievements
Rank 1
 answered on 12 Jan 2016
4 answers
203 views
Hi, i need show the print preview of one Grid Hierarchy, i find some examples but only show the first level. When HierarchyChildTemplate is open in the grid not show the others levels...

How can show the print preview with HierarchyChildTemplate expanded?...

thanks..

Add picture...
Stefan Nenchev
Telerik team
 answered on 12 Jan 2016
Narrow your results
Selected tags
Tags
GridView
General Discussions
Chart
RichTextBox
Docking
ScheduleView
ChartView
TreeView
Diagram
Map
ComboBox
TreeListView
Window
RibbonView and RibbonWindow
PropertyGrid
DragAndDrop
TabControl
TileView
Carousel
DataForm
PDFViewer
MaskedInput (Numeric, DateTime, Text, Currency)
AutoCompleteBox
DatePicker
Buttons
ListBox
GanttView
PivotGrid
Spreadsheet
Gauges
NumericUpDown
PanelBar
DateTimePicker
DataFilter
Menu
ContextMenu
TimeLine
Calendar
Installer and Visual Studio Extensions
ImageEditor
BusyIndicator
Expander
Slider
TileList
PersistenceFramework
DataPager
Styling
TimeBar
OutlookBar
TransitionControl
Book
FileDialogs
ToolBar
ColorPicker
TimePicker
SyntaxEditor
MultiColumnComboBox
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
DesktopAlert
WatermarkTextBox
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
ProgressBar
Sparkline
LayoutControl
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
Licensing
WebCam
CardView
DataBar
FilePathPicker
PasswordBox
Rating
SplashScreen
Accessibility
Callout
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?