{"id":307475,"date":"2020-07-25T15:00:21","date_gmt":"2020-07-25T15:00:21","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=307475"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=307475","title":{"rendered":"Desktop pet \u043d\u0430 C# WPF"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/512448\/\">\n<p>Desktop pet \u2014 \u043f\u0443\u0441\u0442\u044c \u0438 \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435, \u043d\u043e \u0432\u0435\u0441\u044c\u043c\u0430 \u0437\u0430\u0431\u0430\u0432\u043d\u043e\u0435 \u0443\u043a\u0440\u0430\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u0441\u0442\u043e\u043b\u0430. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0441\u0430\u043c\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/fd\/eu\/9t\/fdeu9tbu2ee-ptnfirpm7-xwsqi.png\"><br \/>  <em>\u0413\u0438\u0444\u043a\u0430 \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c!<\/em><\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/xe\/5w\/o2\/xe5wo2mp2sefd3qntb4xahf5fqe.gif\"><\/p>\n<p>  <\/p>\n<h2>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u043d\u0430\u0447\u0430\u043b\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 WPF<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430\u0441\u044c Visual Studio 2017. \u0418\u0442\u0430\u043a, \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0440\u043e\u0435\u043a\u0442, <b>Visual C# -&gt; \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 WPF<\/b>.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/0p\/cs\/wo\/0pcswo6nswfxskz63x8fx8aqy0u.png\"><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0430\u043f\u043a\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u043f\u0440\u0430\u0439\u0442\u044b \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043e \u0434\u0435\u0441\u043a\u0442\u043e\u043f \u043f\u0435\u0442\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0439\u0442\u043a\u043b\u0438\u043a\u043d\u0443\u0442\u044c \u043f\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 \u043e\u0431\u043e\u0437\u0440\u0435\u0432\u0430\u0442\u0435\u043b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 <b>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c -&gt; \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0430\u043f\u043a\u0443<\/b>, \u043d\u0430\u0437\u043e\u0432\u0451\u043c <i>Images<\/i>. <\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ta\/ux\/qv\/tauxqv1gerdocfboa2dlf3iajak.png\"><\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043f\u0440\u0430\u0439\u0442\u044b \u0432 \u043f\u0430\u043f\u043a\u0443, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0438\u0445 \u0432 \u043d\u0435\u0451 \u0432 \u043e\u0431\u043e\u0437\u0440\u0435\u0432\u0430\u0442\u0435\u043b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/v3\/_6\/_w\/v3_6_wgeyahgacd0qybrr_9cfla.png\"><\/p>\n<p>  <\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u043a\u043d\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p>  <\/p>\n<p>\u041e\u043a\u043d\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0442\u0435\u043b\u043e \u0434\u0435\u0441\u043a\u0442\u043e\u043f \u043f\u0435\u0442\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0443\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0451 \u043b\u0438\u0448\u043d\u0435\u0435, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u0432\u0438\u0434\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u044b. \u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u0432 <i>MainWindow.xaml<\/i>. \u041f\u0440\u043e\u043f\u0438\u0448\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u0442\u0435\u0433\u0430 Window. \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043e\u043d\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"xml\">Title=&quot;MainWindow&quot; Height=&quot;450&quot; Width=&quot;800&quot;&gt;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0431\u0440\u0430\u0442\u044c \u0440\u0430\u043c\u043a\u0443 \u043e\u043a\u043d\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"xml\">WindowStyle=&quot;None&quot; ResizeMode=&quot;NoResize&quot;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u043c \u0444\u043e\u043d:<\/p>\n<p>  <\/p>\n<pre><code class=\"xml\">Background=&quot;Transparent&quot; AllowsTransparency=&quot;True&quot;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043c\u0435\u0441\u0442\u043e \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435, \u0433\u0434\u0435 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u043e\u043a\u043d\u043e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043f\u0440\u0430\u0432\u043e\u043c \u043d\u0438\u0436\u043d\u0435\u043c \u0443\u0433\u043b\u0443 \u043d\u0430\u0434 \u043f\u0430\u043d\u0435\u043b\u044c\u044e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u043a\u043d\u0430 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0433\u0434\u0435 <strong>Top<\/strong> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043e\u0442\u0441\u0442\u0443\u043f \u043e\u0442 \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u043a\u0440\u0430\u044f \u044d\u043a\u0440\u0430\u043d\u0430, \u0430 <strong>Left<\/strong> \u2013 \u043e\u0442 \u043b\u0435\u0432\u043e\u0433\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"xml\">WindowStartupLocation=&quot;Manual&quot; Top=&quot;485&quot; Left=&quot;1000&quot;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u0442\u0435\u0433 <strong>Window<\/strong> \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"xml\">&lt;Window x:Class=&quot;WpfApp1.MainWindow&quot;         xmlns=&quot;http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\/presentation&quot;         xmlns:x=&quot;http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml&quot;         xmlns:d=&quot;http:\/\/schemas.microsoft.com\/expression\/blend\/2008&quot;         xmlns:mc=&quot;http:\/\/schemas.openxmlformats.org\/markup-compatibility\/2006&quot;         xmlns:local=&quot;clr-namespace:WpfApp1&quot;         mc:Ignorable=&quot;d&quot;         Title=&quot;MainWindow&quot; Height=&quot;340&quot; Width=&quot;353.2&quot; WindowStyle=&quot;None&quot; Background=&quot;Transparent&quot; AllowsTransparency=&quot;True&quot; WindowStartupLocation=&quot;Manual&quot; Top=&quot;485&quot; Left=&quot;1000&quot;&gt;<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"wpfanimatedgif\">WpfAnimatedGif<\/h2>\n<p>  <\/p>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e WPF \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0433\u0438\u0444\u043a\u0430\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <strong>WpfAnimatedGif<\/strong>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0439\u0442\u043a\u043b\u0438\u043a\u043d\u0443\u0442\u044c \u043f\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 \u043e\u0431\u043e\u0437\u0440\u0435\u0432\u0430\u0442\u0435\u043b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438 \u0432\u044b\u0431\u0440\u0430\u0442\u044c <strong>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u0430\u043c\u0438 NuGet\u2026<\/strong><\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/tm\/8_\/a6\/tm8_a66jcwftfvpbnka9jnfhdnk.png\"><\/p>\n<p>  <\/p>\n<p>\u0412 \u043f\u043e\u044f\u0432\u0438\u0432\u0448\u0435\u043c\u0441\u044f \u043e\u043a\u043d\u0435 \u0432\u0432\u043e\u0434\u0438\u043c \u0432 \u043f\u043e\u0438\u0441\u043a \u201cWpfAnimatedGif\u201d, \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0435\u0440\u0432\u043e\u0435 \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/js\/2u\/zn\/js2uzndsrh6axxvtv_ba4tamjtw.png\"><\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432 \u0442\u0435\u0433 <strong>Window<\/strong> \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0451\u043d:<\/p>\n<p>  <\/p>\n<pre><code class=\"xml\">xmlns:gif=&quot;http:\/\/wpfanimatedgif.codeplex.com&quot; <\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u0430, \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u0430\u043c.<\/p>\n<p>  <\/p>\n<h2 id=\"osnovnaya-chast\">\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/h2>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u043c\u0443 \u043e\u043a\u043d\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 Grid. \u041f\u0435\u0440\u0435\u0434 \u043d\u0430\u0447\u0430\u043b\u043e\u043c \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u0435\u043c \u0443\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c Grid:<\/p>\n<p>  <\/p>\n<pre><code class=\"xml\">&lt;Grid  Opacity=&quot;1&quot;&gt;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0432 \u0442\u0435\u0433\u0435 Image, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c AnimatedSource \u0438\u0437 WpfAnimatedGif:<\/p>\n<p>  <\/p>\n<pre><code class=\"xml\">gif:ImageBehavior.AnimatedSource=&quot;Images\/a.gif&quot;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u0431\u044b\u043b\u0430 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439, \u043d\u0443\u0436\u043d\u043e \u0441\u0442\u0430\u0432\u0438\u0442\u044c <em>gif:ImageBehavior.RepeatBehavior=&quot;Forever&quot;<\/em>, \u043d\u043e \u0432 \u043c\u043e\u0451\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u043e\u0441\u043b\u0435 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0434\u0440\u0443\u0433\u0430\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 <em>gif:ImageBehavior.RepeatBehavior=&quot;1x\u201d<\/em>.<\/p>\n<p>  <\/p>\n<pre><code class=\"xml\">&lt;Image Name=&quot;img&quot; gif:ImageBehavior.AnimatedSource=&quot;Images\/a.gif&quot; gif:ImageBehavior.RepeatBehavior=&quot;1x&quot;  Margin=&quot;-68,-63,-68,-38&quot; RenderTransformOrigin=&quot;0.5,0.5&quot; gif:ImageBehavior.AutoStart=&quot;True&quot; gif:ImageBehavior.AnimationCompleted=&quot;Complete&quot;&gt;         &lt;\/Image&gt; <\/code><\/pre>\n<p>  <\/p>\n<p><em>gif:ImageBehavior.AnimationCompleted=&quot;Complete&quot;<\/em> \u2013 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u0430\u044f \u043f\u043e\u0441\u043b\u0435 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u0443\u044e \u043a\u043d\u043e\u043f\u043a\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"xml\">&lt;Button Name=&quot;btn1&quot; Content=&quot;Button&quot; HorizontalAlignment=&quot;Left&quot; Height=&quot;314&quot; Margin=&quot;93,26,0,0&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;163&quot; Opacity=&quot;0&quot; Click=&quot;Change&quot;\/&gt;<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <em>Click=\u201dChange\u201d<\/em>, \u0433\u0434\u0435 <em>Change<\/em> \u2013 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u0430\u044f \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 Grid \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"xml\">&lt;Grid  Opacity=&quot;1&quot;&gt;         &lt;Image Name=&quot;img&quot; gif:ImageBehavior.AnimatedSource=&quot;Images\/a.gif&quot; gif:ImageBehavior.RepeatBehavior=&quot;1x&quot;  Margin=&quot;-68,-63,-68,-38&quot; RenderTransformOrigin=&quot;0.5,0.5&quot; gif:ImageBehavior.AutoStart=&quot;True&quot; gif:ImageBehavior.AnimationCompleted=&quot;Complete&quot;&gt;         &lt;\/Image&gt;         &lt;Button Name=&quot;btn1&quot; Content=&quot;Button&quot; HorizontalAlignment=&quot;Left&quot; Height=&quot;314&quot; Margin=&quot;93,26,0,0&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;163&quot; Opacity=&quot;0&quot; Click=&quot;Change&quot;\/&gt;     &lt;\/Grid&gt;<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/lq\/kr\/wy\/lqkrwyagkxapspfnbuzevl3l6dw.png\"><\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u043a\u043e\u0434\u0443 \u0434\u043b\u044f \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0434\u0435\u0441\u043a\u0442\u043e\u043f \u043f\u0435\u0442\u0430 (<em>MainWindow.xaml.cs<\/em>). \u041f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u0436 \u0447\u0438\u0445\u0430\u0435\u0442 \u0438 \u043c\u0435\u043d\u044f\u0435\u0442 \u044d\u043c\u043e\u0446\u0438\u044e, \u043f\u0440\u0438\u0447\u0435\u043c \u0447\u0438\u0445\u0430\u0435\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0432 \u0434\u0440\u0443\u0433\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443.<br \/>  \u0412\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 <em>MainWindow:Window<\/em> \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">int k = 0;\/\/\u043d\u043e\u043c\u0435\u0440 \u044d\u043c\u043e\u0446\u0438\u0438 string num = &quot;&quot;;\/\/\u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430  int n=11;\/\/\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043c\u043e\u0446\u0438\u0439 +1(\u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0447\u0438\u0445\u0438)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0430\u043c \u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438: <em>Complete<\/em> \u0438 <em>Change<\/em>.<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">private void Complete(object sender, RoutedEventArgs e)         {             num = &quot;Images\/&quot; + k.ToString() + &quot;.gif&quot;;             BitmapImage image = new BitmapImage();             image.BeginInit();             image.UriSource = new Uri(num, UriKind.Relative);              image.EndInit();             ImageBehavior.SetAnimatedSource(img, image); \/\/\u0441\u043c\u0435\u043d\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438, img \u2013 name \u0432 Image, image \u2013 \u043d\u043e\u0432\u0430\u044f \u0433\u0438\u0444\u043a\u0430         }  private void Change(object sender, RoutedEventArgs e)         {             k = (k + 1) % n;             BitmapImage image = new BitmapImage();             image.BeginInit();             if (k%2==0) image.UriSource = new Uri(&quot;Images\/a.gif&quot;, UriKind.Relative);             else image.UriSource = new Uri(&quot;Images\/b.gif&quot;, UriKind.Relative);             image.EndInit();             ImageBehavior.SetAnimatedSource(img, image);         }<\/code><\/pre>\n<p>  <\/p>\n<p><em>object sender<\/em> \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043d\u043e\u043f\u043a\u0430. <em>a.gif<\/em> \u0438 <em>b.gif<\/em> \u2013 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0447\u0438\u0445\u0430\u043d\u0438\u044f(\u0432\u043f\u0440\u0430\u0432\u043e \u0438 \u0432\u043b\u0435\u0432\u043e), \u0430 <em>0.gif<\/em> \u2013 <em>10.gif<\/em> \u2013 \u044d\u043c\u043e\u0446\u0438\u0439. \u041f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043d\u0430\u0436\u0430\u0442\u0438\u0438 <em>k<\/em> \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 10. \u0415\u0441\u043b\u0438 <em>k<\/em> \u0447\u0451\u0442\u043d\u043e\u0435 \u2013 \u0447\u0438\u0445 \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u043e\u0440\u043e\u043d\u0443, \u0435\u0441\u043b\u0438 \u043d\u0435\u0447\u0451\u0442\u043d\u043e\u0435 \u2013 \u0432 \u0434\u0440\u0443\u0433\u0443\u044e. \u041f\u043e\u0441\u043b\u0435 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0447\u0438\u0445\u0430\u043d\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <em>Complete<\/em>, \u043c\u0435\u043d\u044f\u044e\u0449\u0430\u044f \u044d\u043c\u043e\u0446\u0438\u044e \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u0436\u0430.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/s7\/k-\/d9\/s7k-d9178fd_0ye05tpaxhlv3qg.png\"><\/p>\n<p>  <\/p>\n<h2 id=\"rezultat\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h2>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/e4\/pp\/aa\/e4ppaaoyyjzeegux8reftnc4rrs.gif\"><\/p>\n<p>  <\/p>\n<h2 id=\"istochniki\">\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438<\/h2>\n<p>  <\/p>\n<p><a href=\"http:\/\/docs.microsoft.com\/ru-ru\/dotnet\/framework\/wpf\/\" rel=\"nofollow\">WPF<\/a><br \/>  <a href=\"http:\/\/github.com\/XamlAnimatedGif\/WpfAnimatedGif\" rel=\"nofollow\">WpfAnimatedGif<\/a><br \/>  <a href=\"http:\/\/ace-attorney.fandom.com\/ru\/wiki\/%D0%A4%D0%B5%D0%BD%D0%B8%D0%BA%D1%81_%D0%A0%D0%B0%D0%B9%D1%82_-_%D0%93%D0%B0%D0%BB%D0%B5%D1%80%D0%B5%D1%8F_%D1%81%D0%BF%D1%80%D0%B0%D0%B9%D1%82%D0%BE%D0%B2#College%20student%20(T&amp;T)\" rel=\"nofollow\">\u0421\u043f\u0440\u0430\u0439\u0442\u044b<\/a><\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/512448\/\"> https:\/\/habr.com\/ru\/post\/512448\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/512448\/\">\n<p>Desktop pet \u2014 \u043f\u0443\u0441\u0442\u044c \u0438 \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435, \u043d\u043e \u0432\u0435\u0441\u044c\u043c\u0430 \u0437\u0430\u0431\u0430\u0432\u043d\u043e\u0435 \u0443\u043a\u0440\u0430\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u0441\u0442\u043e\u043b\u0430. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0441\u0430\u043c\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/fd\/eu\/9t\/fdeu9tbu2ee-ptnfirpm7-xwsqi.png\"><br \/>  <em>\u0413\u0438\u0444\u043a\u0430 \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c!<\/em><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-307475","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/307475","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=307475"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/307475\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=307475"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=307475"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=307475"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}