Monday, August 12, 2013

silverlight Storyboard begin from end of time with AutoReverse is true

Storyboard sbSongName = (Storyboard)this.FindResource("sbSongName");
sbSongName.Stop();
sbSongName.AutoReverse = true;
sbSongName.Begin();
sbSongName.SeekAlignedToLastTick(sbSongName.GetCurrentTime(), TimeSeekOrigin.Duration);

Saturday, August 10, 2013

CreateInstance from Assembly in AppDomain

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string pathToDll = AppDomain.CurrentDomain.BaseDirectory + @"App.Core.dll"; //Full path to dll you want to load
            string typeName = "App.Core.Sockets.ServerSocket";

            string subDir = AppDomain.CurrentDomain.BaseDirectory;
            AppDomainSetup setup = new AppDomainSetup();
            setup.PrivateBinPath = subDir;
            setup.ApplicationBase = subDir;
            AppDomain newDomain = AppDomain.CreateDomain(subDir, null, setup);
            byte[] file = File.ReadAllBytes(pathToDll);//dll path is a dll inside subDir
            Assembly assembly = newDomain.Load(file);

            var obj = assembly.CreateInstance(typeName);
            obj.ToString();
        }
    }

Friday, August 9, 2013

xaml chart index animation background by ellipse, path

<Ellipse x:Name="shpEllipse" HorizontalAlignment="Left" Width="70" StrokeThickness="2" Stroke="White" Margin="45,36,0,0" Height="70" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5">
                    <Ellipse.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform ScaleX="0.75" ScaleY="0.75"/>
                            <SkewTransform/>
                            <RotateTransform/>
                            <TranslateTransform/>
                        </TransformGroup>
                    </Ellipse.RenderTransform>
                    <Ellipse.Effect>
                        <DropShadowEffect BlurRadius="3" ShadowDepth="3"/>
                    </Ellipse.Effect>
                    <Ellipse.Fill>
                        <RadialGradientBrush>
                            <GradientStop Color="White" Offset="0"/>
                            <GradientStop Color="#FF600000" Offset="0.743"/>
                            <GradientStop Color="White"/>
                        </RadialGradientBrush>
                    </Ellipse.Fill>
                </Ellipse>
                <Path x:Name="pthHureeTom" Data="M84.64254,56.516499 L101.2,56.516499 101.16492,56.738163 C98.004402,75.448341 84.238998,90.554283 66.265854,95.658798 L65.851501,95.770927 65.851501,78.510521 66.591904,78.164825 C75.138695,74.046547 81.698822,66.458344 84.44471,57.227797 z M4.5037427,56.516499 L19.05945,56.516499 19.127028,56.775002 C22.094675,67.286343 29.990305,75.730423 40.16116,79.454487 L40.851501,79.697636 40.851501,96.035 40.605637,95.975002 C22.111521,91.21666 7.8422217,75.932732 4.5638685,56.88938 z M100.19556,35.849498 C100.19556,35.849498 100.19556,35.849498 100.19556,35.849498 z M65.851501,1.2640686 L66.265854,1.3761902 C82.634254,6.0249557 95.512749,18.968896 100.06928,35.37593 L100.19556,35.849498 83.79203,35.849498 83.679832,35.534825 C80.591675,27.33604 74.42646,20.645254 66.591904,16.870167 L65.851501,16.524466 z M40.851501,1 L40.851501,15.337355 40.16116,15.580505 C30.803974,19.00664 23.372538,26.427803 19.932524,35.778316 L19.907883,35.849498 5.5070066,35.849498 5.7000399,35.139443 C10.42399,18.456896 23.762781,5.3934841 40.605637,1.0599937 z" Fill="#FF400000" HorizontalAlignment="Left" Height="125" Margin="15.305,8,0,0" Stretch="Fill" Stroke="Snow" VerticalAlignment="Top" Width="129.695" RenderTransformOrigin="0.5,0.5">
                    <Path.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform ScaleX="0.6" ScaleY="0.6"/>
                            <SkewTransform/>
                            <RotateTransform Angle="45"/>
                            <TranslateTransform/>
                        </TransformGroup>
                    </Path.RenderTransform>
                </Path>
                <Path x:Name="pthHuree" Data="M36.616284,73.999999 L51.713873,73.999999 51.732786,74.042922 C58.943678,89.296806 75.824856,99.999999 95.5,99.999999 115.17515,99.999999 132.05632,89.296806 139.26721,74.042922 L139.28613,73.999999 156.38372,73.999999 156.19012,74.598739 C148.27691,98.00518 124.54572,115 96.5,115 68.454288,115 44.723093,98.00518 36.809878,74.598739 z M155.69389,38.999999 C155.69389,38.999999 155.69389,38.999999 155.69389,38.999999 z M37.30611,38.999999 C37.30611,38.999999 37.30611,38.999999 37.30611,38.999999 z M96.5,0 C123.46703,-7.4505806E-07 146.44505,15.712663 155.20752,37.729572 L155.69389,38.999999 138.27335,38.999999 137.26701,37.241977 C129.22339,23.993655 113.53555,15 95.5,14.999998 77.464451,15 61.776609,23.993655 53.732994,37.241977 L52.726658,38.999999 37.303493,38.997044 37.792484,37.729572 C46.554952,15.712663 69.53297,-7.4505806E-07 96.5,0 z" Fill="Maroon" HorizontalAlignment="Left" Height="105" Stretch="Fill" VerticalAlignment="Top" Width="100.333" Stroke="White" StrokeThickness="2" RenderTransformOrigin="0.5,0.5" Margin="29.662,17.997,0,0">
                    <Path.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform ScaleX="0.6" ScaleY="0.6"/>
                            <SkewTransform/>
                            <RotateTransform/>
                            <TranslateTransform/>
                        </TransformGroup>
                    </Path.RenderTransform>
                    <Path.Effect>
                        <DropShadowEffect BlurRadius="1" ShadowDepth="0"/>
                    </Path.Effect>
                </Path>