PieChart with Labels - wpf

I want to make LabeledPieCharts in WPF (Source: Bea's Blog )
I have downloaded the DemoProject and it runs. If I want to create a LabeledPieChart it fails with this Error:
The Tag "LabeledPieChart.Series" isn't in XML-Namespace "clr-namespace:Controls;assembly=Controls". Line 65 Position 14.
Here is my code:
<customControls:LabeledPieChart x:Name="labeledPieChart"
Title="Population of Puget Sound Cities"
Grid.Row="3"
Width="700"
Height="500"
BorderBrush="Gray">
<customControls:LabeledPieChart.Series>
<customControls:LabeledPieSeries x:Name="labeledPieSeries"
DependentValuePath="Population"
IndependentValuePath="Name"
IsSelectionEnabled="True"
ItemsSource="{Binding}"
LabelDisplayMode="Auto"
PieChartLabelItemTemplate="{StaticResource pieChartLabelDataTemplate}"
PieChartLabelStyle="{StaticResource pieChartLabelStyle}" />
</customControls:LabeledPieChart.Series>
</customControls:LabeledPieChart>

I've downloaded the project and your code seems to work OK. Maybe this question will help you a bit.

Related

h264_qsv leads to memory leak

I use h264_qsv encoder to export a video.
The mlt xml :
<consumer mlt_service="avformat" target="10.mp4" strict="experimental" vn="0" vcodec="h264_qsv" width="1920" height="800" frame_rate_num="50.000000" frame_rate_den="1" vb="8000k" cbr="1" vbufsize="12288000" minrate="8000k" maxrate="8000k" acodec="aac" channels="1" ar="44100" ab="192k" preset="fast" profile="main" level="3.0" bf="0" thread="0" real_time="-1" sc_threshold="0" g="125" f="mp4" preview_off="1"/>
Ive tried multiple variations of this, but none of them seem to work. Any ideas?
Thanks in advance.

Sometimes MediaFailed event fired for WPF MediaKit

MediaFailed event fired twice from time to time, my xaml is as below:
<controls:MediaUriElement Name="videoMedia" HorizontalAlignment="Center" Margin="20 20 20 5" VerticalAlignment="Center"
DeeperColor="False" VideoRenderer="EnhancedVideoRenderer" UnloadedBehavior="Stop"
MediaOpened="videoMedia_MediaOpened" MediaFailed="videoMedia_MediaFailed"
/>
the information for first MediaFailedEventArgs.Exception is as below:
Message "The download of the specified resource has failed"
Source "DirectShowLib-2005"
StackTrace:
" at DirectShowLib.DsError.ThrowExceptionForHR(Int32 hr)\r\n at WPFMediaKit.DirectShow.MediaPlayers.MediaUriPlayer.oldOpenSource()"
Second exception is as below:
Message "Unspecified error"
Source "DirectShowLib-2005"
StackTrace:
" at DirectShowLib.DsError.ThrowExceptionForHR(Int32 hr)\r\n at WPFMediaKit.DirectShow.MediaPlayers.MediaUriPlayer.OpenSource()"
Note: because my application is target for .NET 4.0, I change the source code and rebuild in my local machine, the source code change is:
change D3DRenderer.cs from
D3DImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, backBuffer, true);
to
D3DImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, backBuffer);

Preview actual image of PathGeometry in WPF MVVM

In my application there is a common Icon.xaml file which contains many PathGeometry Figures having unique key names like as shown below.
<PathGeometry x:Key="CloseGeometry" Figures="m 357.0883 499.0572 12.62375 12.6275 5.31375 -5.31625 -12.62625 -12.62625 12.62625 -12.61875 -5.31375 -5.3125 -12.62375 12.62 -12.6325 -12.62 -5.30375 5.3125 12.6175 12.61875 -12.6175 12.62625 5.30375 5.31625 12.6325 -12.6275 z"/>
<PathGeometry x:Key="NormalGeometry" Figures="M4.3685131,23.127279L4.3685131,47.283243 47.117023,47.283243 47.117023,23.127279z M25.087107,13.948568C23.539013,13.948568 22.286318,15.201555 22.286318,16.74834 22.286318,18.292325 23.539013,19.547214 25.087107,19.547214 26.6327,19.547214 27.886597,18.292325 27.886597,16.74834 27.886597,15.201555 26.6327,13.948568 25.087107,13.948568z M16.126242,13.948568C14.580646,13.948568 13.326751,15.201555 13.326751,16.74834 13.326751,18.292325 14.580646,19.547214 16.126242,19.547214 17.673136,19.547214 18.928329,18.292325 18.928329,16.74834 18.928329,15.201555 17.673136,13.948568 16.126242,13.948568z M7.1679735,13.948568C5.621069,13.948568 4.3685136,15.201555 4.3685131,16.74834 4.3685136,18.292325 5.621069,19.547214 7.1679735,19.547214 8.713438,19.547214 9.9674625,18.292325 9.9674625,16.74834 9.9674625,15.201555 8.713438,13.948568 7.1679735,13.948568z M0,10.684L53.755001,10.684 53.755001,51.668001 0,51.668001z M8.5679998,0L58.668022,0 64,0 64,5.6864691 64,45.317999 58.668022,45.317999 58.668022,5.6864691 8.5679998,5.6864691z"/>
<PathGeometry x:Key="MaximiseGeometry" Figures="M5.2010002,14.812L5.2010002,43.573997 56.098,43.573997 56.098,14.812z M29.868601,3.8869994C28.026201,3.8869996 26.534,5.3791947 26.534,7.2190399 26.534,9.0588851 28.026201,10.553 29.868601,10.553 31.7085,10.553 33.202,9.0588851 33.202,7.2190399 33.202,5.3791947 31.7085,3.8869996 29.868601,3.8869994z M19.200649,3.8869994C17.359457,3.8869996 15.867001,5.3791947 15.867001,7.2190399 15.867001,9.0588851 17.359457,10.553 19.200649,10.553 21.042044,10.553 22.536999,9.0588851 22.536999,7.2190399 22.536999,5.3791947 21.042044,3.8869996 19.200649,3.8869994z M8.5339746,3.8869994C6.6931,3.8869996 5.2010002,5.3791947 5.2010002,7.2190399 5.2010002,9.0588851 6.6931,10.553 8.5339746,10.553 10.37495,10.553 11.867,9.0588851 11.867,7.2190399 11.867,5.3791947 10.37495,3.8869996 8.5339746,3.8869994z M0,0L63.999001,0 63.999001,48.792999 0,48.792999z"/>
<PathGeometry x:Key="MinimiseGeometry" Figures="M 0 1, 1 1 "/>
.....
But my problem is that there are around 300 to 400 different PathGeometries and it becomes difficult to check whether particular type of Image exists or not.
Example:
If new WPF form is gettign developed by programmer in which s\he needs to use delete Icon then s\he will first check in Icon.xaml file whether it already exists or not, if not then it will be added.But this checking needs to be done manually which is a pain.
So is there any simplest way to preview or check whether particular iamge exists or not.
Currently, I konw two tools can help you preview PathGeometry data of xaml.
XamlPadX
Download: XamlPadX v4.0.
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<Grid>
<Path Stroke="Black" StrokeThickness="2" Data="M4.3685131,23.127279L4.3685131,47.283243 47.117023,47.283243 47.117023,23.127279z M25.087107,13.948568C23.539013,13.948568 22.286318,15.201555 22.286318,16.74834 22.286318,18.292325 23.539013,19.547214 25.087107,19.547214 26.6327,19.547214 27.886597,18.292325 27.886597,16.74834 27.886597,15.201555 26.6327,13.948568 25.087107,13.948568z M16.126242,13.948568C14.580646,13.948568 13.326751,15.201555 13.326751,16.74834 13.326751,18.292325 14.580646,19.547214 16.126242,19.547214 17.673136,19.547214 18.928329,18.292325 18.928329,16.74834 18.928329,15.201555 17.673136,13.948568 16.126242,13.948568z M7.1679735,13.948568C5.621069,13.948568 4.3685136,15.201555 4.3685131,16.74834 4.3685136,18.292325 5.621069,19.547214 7.1679735,19.547214 8.713438,19.547214 9.9674625,18.292325 9.9674625,16.74834 9.9674625,15.201555 8.713438,13.948568 7.1679735,13.948568z M0,10.684L53.755001,10.684 53.755001,51.668001 0,51.668001z M8.5679998,0L58.668022,0 64,0 64,5.6864691 64,45.317999 58.668022,45.317999 58.668022,5.6864691 8.5679998,5.6864691z" />
</Grid>
</Page>
Then put the PathGeometry data (string of the node "Figures") to the value of inside "Data":
Next, you need to click "Auto Parse" button in left top postion, you can view the rendering result (red border region in screenshot). See below, I just use the data second one from your data.
WPF Geometry Transformation Tool
Download: WPF Geometry Transformation Tool.
Put the string of the node "Figures" into the textarea of Input Geometry, then you can see the result (red border region in screenshot).

Storyboard issues when archiving ios 7 app with ios 6.1 sdk

I have re-created my app from scratch using xcode 5 and ios 7. I have set the deployment target to ios 5.0. I am able to run the app successfully on all the ios 5.0+ simulators using xcode 5. And I am able to archive the ios 7.0 version of my app to my iphone without issues.
The issue arises when I try to build by app with the ios 6.1 sdk using xcode 4.6.3. I get the following build error:
"The document Main.storyboard could not be opened. Could not read archive."
I open that file in source code view, and see this on the top:
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="4510" systemVersion="12E55" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="rS3-R9-Ivy">
I change the version to 2.0, which is the advice some people are giving. After doing this, I clean and rebuild and get the following error:
"The document Main.storyboard could not be opened. Failed to unarchive element named 'tableViewCellContentView'."
I am not sure what to do at this point. If it helps, tableViewCellContent shows up two times in the storyboard source:
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="jxu-2I-e7e" id="p3Z-Dy-Wwr">
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Share Location" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="QHi-wS-Lfa">
<rect key="frame" x="20" y="11" width="116" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" id="jfR-fE-3PU">
<rect key="frame" x="251" y="6" width="51" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<inset key="insetFor6xAndEarlier" minX="20" minY="-2" maxX="-20" maxY="2"/>
</switch>
</subviews>
</tableViewCellContentView>
and
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ase-uh-S8O" id="Qfa-Dd-22s">
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="m8y-pR-Z3V">
<rect key="frame" x="15" y="3" width="36" height="22"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Subtitle" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="4bW-Fg-tmx">
<rect key="frame" x="15" y="25" width="43" height="15"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
If I remove those two snippets above from the source, I can successfully open the storyboard in xcode 4.6.3 using the ios 6.1 sdk. However, the UI is not correct as a result.
Any ideas what part of this could not be backwards compatible with ios 6.1 sdk?
You can make a storyboard file created/updated using Xcode 5 compatible with Xcode 4.6 by setting the option as below.
However you will not be able to make iOS 7 related UI changes once you do that.

How do you clone a path resource in Silverlight?

I have a resource defined in my Xaml file as follows:
<Path x:Key="myPath"
Data="M14.773241,18.080208 C12.373256,18.080208 10.239936,19.30687 10.239936,27.573483
L10.239936,36.106766 C10.239936,45.440037 12.586588,46.506699 14.986573,46.506699
C18.613216,46.506699 19.359879,42.400059 19.359879,35.3601 L19.359879,27.733482
C19.359879,20.05353 17.386559,18.080208 14.773241,18.080208 z M14.879907,11.786915
C17.973221,11.786915 22.293194,13.013573 24.906511,17.920212 C26.773167,21.386856
27.519829,27.093487 27.519829,32.213455 C27.519829,34.506775 27.306496,41.706726
24.906511,46.453365 C23.626518,49.013351 20.906536,52.799992 15.199905,52.799992
C2.1333201,52.799992 2.1333201,37.600086 2.1333201,32.160122 C2.1333201,28.05348
2.1333201,22.666847 4.4266391,18.453541 C5.8666301,15.840225 8.639946,11.786915
14.879907,11.786915 z"
/>
I want to able to add multiple "instances" of this path (and several others) to a StackPanel. Of course, I can't simply add "myPath" to the panel since it's already a child of another container.
However, I can't seem to be able to clone the path either. I've tried:
Path clone = new Path()
{
Data = source.Data
};
But no luck...exception about value being out of expected range.
Finally, I tried digging into source.Data (a PathGeometry), but it contains no PathFigures...I have no idea why, since the Path does render if I copy it from the resource section to a panel directly.
What gives?
Thanks,
Sergio
Put the path data in a string resource:
<Page.Resources>
<system:String x:Key="PathData">
M14.773241,18.080208 C12.373256,18.080208 10.239936,19.30687 10.239936,27.573483
L10.239936,36.106766 C10.239936,45.440037 12.586588,46.506699 14.986573,46.506699
C18.613216,46.506699 19.359879,42.400059 19.359879,35.3601 L19.359879,27.733482
C19.359879,20.05353 17.386559,18.080208 14.773241,18.080208 z M14.879907,11.786915
C17.973221,11.786915 22.293194,13.013573 24.906511,17.920212 C26.773167,21.386856
27.519829,27.093487 27.519829,32.213455 C27.519829,34.506775 27.306496,41.706726
24.906511,46.453365 C23.626518,49.013351 20.906536,52.799992 15.199905,52.799992
C2.1333201,52.799992 2.1333201,37.600086 2.1333201,32.160122 C2.1333201,28.05348
2.1333201,22.666847 4.4266391,18.453541 C5.8666301,15.840225 8.639946,11.786915
14.879907,11.786915 z
</system:String>
</Page.Resources>
And to use it:
<Path x:Name="Path1" Data="{StaticResource PathData}" Fill="Blue" ... />
<Path x:Name="Path2" Data="{StaticResource PathData}" Fill="Red" ... />
You'll need this in your XAML declaration:
xmlns:system="clr-namespace:System;assembly=mscorlib"
If you want to create paths programmatically using a common path string, Silverlight is missing a bit of key functionality that WPF has -- so you have to kludge it:
string pathXaml =
#"<Path xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
Data=""path_data_goes_here"" />";
Path path = (Path)System.Windows.Markup.XamlReader.Load(pathXaml);

Resources