Inheritance: System.Windows.Media.Imaging.BitmapSource, ISupportInitialize
Example #1
1
        public Model3DGroup Create(Color modelColor,string pictureName, Point3D startPos, double maxHigh)
        {
            try
            {
                Uri inpuri = new Uri(@pictureName, UriKind.Relative);
                BitmapImage bi = new BitmapImage();
                bi.BeginInit();
                bi.UriSource = inpuri;
                bi.EndInit();
                ImageBrush imagebrush = new ImageBrush(bi);
                imagebrush.Opacity = 100;
                imagebrush.Freeze();

                Point[] ptexture0 = { new Point(0, 0), new Point(0, 1), new Point(1, 0) };
                Point[] ptexture1 = { new Point(1, 0), new Point(0, 1), new Point(1, 1) };

                SolidColorBrush modelbrush = new SolidColorBrush(modelColor);
                Model3DGroup cube = new Model3DGroup();
                Point3D uppercircle = startPos;
                modelbrush.Freeze();
                uppercircle.Y = startPos.Y + maxHigh;
                cube.Children.Add(CreateEllipse2D(modelbrush, uppercircle, _EllipseHigh, new Vector3D(0, 1, 0)));
                cube.Children.Add(CreateEllipse2D(modelbrush, startPos, _EllipseHigh, new Vector3D(0, -1, 0)));
                cube.Children.Add(CreateEllipse3D(imagebrush, startPos, _EllipseHigh, maxHigh, ptexture0));
                return cube;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        private void Init(String n, bool s)
        {
            Name = n;
            Male = s;
            JobRole = "Boss";

            pictureFile = ".../.../Pictures/Enemies/Ravenscroft.png";
            characterPicture = new BitmapImage(new Uri(pictureFile, UriKind.Relative));

            /******************************************************************
             * stat progression unique to this job role.
             * ****************************************************************
             */
            HealthMulti = 3.00;
            EnergyMulti = 3.00;
            AttackMulti = 2.00;
            DefenseMulti = 3.00;
            SpeedMulti = 2;
            AgilityMulti = 2;
            AttackRangeMulti = 1.00;
            SpecialAttackMulti = 3.00;
            SpecialDefenseMulti = 3.00;

            ExperienceAmountMulti = 100.00;

            /******************************************************************
             * stats initialized after multipliers applied.
             * ****************************************************************
             */
            InstantiateLevel(1);
        }
Example #3
0
 void IThumbnailManager.SetThumbnail(string name, BitmapImage thumbnail)
 {
     using (var zipArchive = new ZipArchive("AssetThumbnails.zip"))
     {
         zipArchive.Save(name, thumbnail.StreamSource);
     }
 }
Example #4
0
        /// <summary>
        /// Gets a bitmap inside the given assembly at the given path therein.
        /// </summary>
        /// <param name="uri">
        /// The relative URI.
        /// </param>
        /// <param name="assemblyName">
        /// Name of the assembly.
        /// </param>
        /// <returns>
        /// </returns>
        public static BitmapImage GetBitmap(Uri uri, string assemblyName)
        {
            if (uri == null)
            {
                return null;
            }

            var stream = GetStream(uri, assemblyName);

            if (stream == null)
            {
                return null;
            }

            using (stream)
            {
                var bmp = new BitmapImage();

                bmp.BeginInit();
                bmp.StreamSource = stream;
                bmp.EndInit();

                return bmp;
            }
        }
      public async Task<ImageSource> DownloadPicture(string imageUri)
      {
         var request = (HttpWebRequest)WebRequest.Create(imageUri);
         if (string.IsNullOrEmpty(Configuration.SessionCookies) == false)
         {
            request.CookieContainer = new CookieContainer();
            request.CookieContainer.SetCookies(request.RequestUri, Configuration.SessionCookies);
         }

         var response = (HttpWebResponse)(await request.GetResponseAsync());

         using (Stream inputStream = response.GetResponseStream())
         using (Stream outputStream = new MemoryStream())
         {
            var buffer = new byte[4096];
            int bytesRead;
            do
            {
               bytesRead = await inputStream.ReadAsync(buffer, 0, buffer.Length);
               outputStream.Write(buffer, 0, bytesRead);
            } while (bytesRead != 0);

            var bitmapImage = new BitmapImage();
            bitmapImage.BeginInit();
            bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
            bitmapImage.StreamSource = outputStream;
            bitmapImage.EndInit();
            bitmapImage.Freeze();

            return bitmapImage;
         }
      }
		private void ImportImageButtonClick(object sender, RoutedEventArgs e)
		{
			OpenFileDialog openFileDialog = new OpenFileDialog();
#if WPF
			openFileDialog.Filter = "Image Files (*.png, *.jpg, *.bmp)|*.png;*.jpg;*.bmp";
#else
			openFileDialog.Filter = "Image Files (*.png, *.jpg)|*.png;*.jpg";
#endif
			bool? dialogResult = openFileDialog.ShowDialog();
			if (dialogResult.HasValue && dialogResult.Value == true)
			{
				Image image = new Image();
#if WPF
				image.Source = new BitmapImage(new Uri(openFileDialog.FileName, UriKind.Absolute));
#else
					using (var fileOpenRead = openFileDialog.File.OpenRead())
					{
						BitmapImage bitmap = new BitmapImage();
						bitmap.SetSource(fileOpenRead);
						image.Source = bitmap;
					}
#endif
				Viewbox viewBox = new Viewbox() { Stretch = Stretch.Fill, Margin = new Thickness(-4) };
				viewBox.Child = image;
				RadDiagramShape imageShape = new RadDiagramShape()
				{
					Content = viewBox
				};
				this.diagram.Items.Add(imageShape);
			}
		}
        //TODO filter by mimetype
        public void ShowImage(MemoryStream stream)
        {
            try
            {
                stream.Position = 0;
                var bitmapImage = new BitmapImage();
                bitmapImage.BeginInit();
                bitmapImage.StreamSource = stream;
                bitmapImage.EndInit();

                image1.Width = bitmapImage.Width;
                image1.Height = bitmapImage.Height;

                var screenInfo = GetScreenInfo();

                image1.Height = screenInfo.Height - 150;
                image1.Width = (image1.Height * bitmapImage.Width) / bitmapImage.Height;

                Height = image1.Height + 3;
                Width = image1.Width + 3;

                image1.Source = bitmapImage;
            }
            catch (NotSupportedException)
            { }
        }
        private void client_getApplicationByIdCompleted(object sender, MyService.getApplicationByIdCompletedEventArgs e)
        {
            string jsonString = e.Result.ToString();
            JObject jobj = JObject.Parse(jsonString);
            jobj = jobj["Application"] as JObject;

            string Id = jobj["Id"].ToString();
            string Name = jobj["Name"].ToString();
            float Price = float.Parse(jobj["Price"].ToString());
            float Rating = float.Parse(jobj["Rating"].ToString());
            int Reviews = Int32.Parse(jobj["Reviews"].ToString());
            DateTime DatePublished = DateTime.Parse(jobj["DatePublished"].ToString());
            string PublisherName = jobj["PublisherName"].ToString();
            string ImageUrl = jobj["ImageUrl"].ToString();

            pivFirstItem.Text = Name;

            BitmapImage myBitmapImage = new BitmapImage();

            myBitmapImage.UriSource = new Uri(ImageUrl);
            myBitmapImage.DecodePixelWidth = 300;
            myBitmapImage.DecodePixelWidth = 300;
            myBitmapImage.DecodePixelType = DecodePixelType.Logical;
            img.Source = myBitmapImage;
            txtDatePublished.Text = "Date published: "+DatePublished.ToShortDateString();
            txtPublisher.Text = "Publisher: "+PublisherName;
            txtRating.Text = "Rating: "+Rating.ToString();
            txtReviews.Text = "Number of reviews: "+Reviews.ToString();
            if (Price > 0)
                txtPrice.Text = "Price: $ " + Price.ToString();
            else
                txtPrice.Text = "This application is free";
        }
        public MainWindow()
        {
            InitializeComponent();

                // initialize tabItem array
                _tabItems = new List<TabItem>();

                // add a tabItem with + in header
                _tabAdd = new TabItem();
                //get image for header and setup add button
                _tabAdd.Style = new Style();
                _tabAdd.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0x30, 0x30, 0x30));
                _tabAdd.BorderBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x30, 0x30, 0x30));
                BitmapImage bitmap = new BitmapImage();
                bitmap.BeginInit();
                bitmap.UriSource = new Uri(@"pack://application:,,,/Explore10;component/Images/appbar.add.png");
                bitmap.EndInit();
                Image plus = new Image();
                plus.Source = bitmap;
                plus.Width = 25;
                plus.Height = 25;
                _tabAdd.Width = 35;
                _tabAdd.Header = plus;
                _tabAdd.MouseLeftButtonUp += new MouseButtonEventHandler(tabAdd_MouseLeftButtonUp);
                _tabItems.Add(_tabAdd);

                // add first tab
                //this.AddTabItem();

                // bind tab control
                tabDynamic.DataContext = _tabItems;

                tabDynamic.SelectedIndex = 0;
        }
        private void initImageCache()
        {
            // load all images in the "iamges" folder
            
            _imageSources = new Dictionary<string, ImageSource>();

            if (!string.IsNullOrEmpty(_imageFolder ) && Directory.Exists(_imageFolder))
            {

                foreach (var f in Directory.GetFiles(_imageFolder, "*.png", SearchOption.TopDirectoryOnly))
                {
                    if (f != null)
                    {
                        var filePath = Path.Combine(_imageFolder, f);

                        var bmp = new BitmapImage(new Uri(filePath));


                        var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(f);
                        _imageSources.Add(fileNameWithoutExtension, bmp);
                    }
                }
            }
            _imageSources.Add(".UIController", new BitmapImage(new Uri(@"/Resources/UIController.png", UriKind.Relative)));
            _imageSources.Add(".FlowUIController",
                new BitmapImage(new Uri(@"/Resources/UIController.png", UriKind.Relative)));
            _imageSources.Add(".AbstractUIController",
                new BitmapImage(new Uri(@"/Resources/UIController.png", UriKind.Relative)));
        }
Example #11
0
        /// <summary>
        /// 初始化
        /// </summary>
        public void init(string[] func_list)
        {
            for (int i = 0; i < func_list.Length; i++)
            {
                // 分割线
                Image img = new Image();
                BitmapImage bi = new BitmapImage();
                bi.BeginInit();
                bi.UriSource = new Uri(AppConfig.IconPath, UriKind.Relative);
                bi.EndInit();
                img.Margin = new Thickness(5, (i + 1) * 72 - 20, 0, 0);
                img.Width = 150;
                img.Height = 10;
                img.HorizontalAlignment = HorizontalAlignment.Left;
                img.VerticalAlignment = VerticalAlignment.Top;
                img.Source = bi;

                // 按钮
                MainNavButton mnb = new MainNavButton();
                mnb.Tag = func_list[i];
                mnb.id = i;
                mnb.init();
                mnb.HorizontalAlignment = HorizontalAlignment.Left;
                mnb.VerticalAlignment = VerticalAlignment.Top;
                mnb.Margin = new Thickness(0, (i + 1) * 72 - 20 + 3, 0, 0);
                if (i == 0)
                {
                    mnb.change_state();
                }
                mnbs.Add(mnb);
                this.main.Children.Add(img);
                this.main.Children.Add(mnb);
            }

        }
Example #12
0
        public static BitmapImage GetCharacterPortrait(Player player)
        {
            if (player == null || player.CharacterID == 0)
                return null;

            int Size = 64;
            string filePath = string.Format("{0}\\{1}.jpg", Utils.PortraitDir, player.CharacterID);

            BitmapImage image = null;
            try
            {
                if (!File.Exists(filePath))
                {

                    WebClient wc = new WebClient();
                    wc.DownloadFile(
                        string.Format("http://img.eve.is/serv.asp?s={0}&c={1}", Size, player.CharacterID),
                        filePath);
                }

                image = new BitmapImage();
                image.BeginInit();
                image.UriSource = new Uri(filePath,
                                          UriKind.Absolute);
                image.EndInit();

            }
            catch (Exception)
            {
            }

            return image;
        }
 public static BitmapImage ByteArraytoBitmap(Byte[] byteArray)
 {
     MemoryStream stream = new MemoryStream(byteArray);
     BitmapImage bitmapImage = new BitmapImage();
     bitmapImage.SetSource(stream);
     return bitmapImage;
 }
        static TopWallpaperRenderer()
        {
            ScreenArea = new Rect(0, 0, 412, 240);

            var defTopAlt = new BitmapImage();
            defTopAlt.BeginInit();
            //defTopAlt.StreamSource = (Stream) Extensions.GetResources(@"TopAlt_DefMask\.png").First().Value;
            defTopAlt.UriSource = new Uri(@"pack://application:,,,/ThemeEditor.WPF;component/Resources/TopAlt_DefMask.png");
            defTopAlt.CacheOption = BitmapCacheOption.OnLoad;
            defTopAlt.EndInit();

            var bgrData = defTopAlt.GetBgr24Data();
            RawTexture rTex = new RawTexture(defTopAlt.PixelWidth, defTopAlt.PixelHeight, RawTexture.DataFormat.A8);
            rTex.Encode(bgrData);
            DefaultTopSquares = new TextureViewModel(rTex, null);

            RenderToolFactory.RegisterTool<PenTool, Pen>
                (key => new Pen(new SolidColorBrush(key.Color)
                {
                    Opacity = key.Opacity
                },
                            key.Width));

            RenderToolFactory.RegisterTool<SolidColorBrushTool, Brush>
                (key => new SolidColorBrush(key.Color)
                {
                    Opacity = key.Opacity
                });

            RenderToolFactory.RegisterTool<LinearGradientBrushTool, Brush>
                (key => new LinearGradientBrush(key.ColorA, key.ColorB, key.Angle)
                {
                    Opacity = key.Opacity
                });

            RenderToolFactory.RegisterTool<ImageBrushTool, Brush>
                (key => new ImageBrush(key.Image)
                {
                    TileMode = key.Mode,
                    ViewportUnits = key.ViewportUnits,
                    Viewport = key.Viewport,
                    Opacity = key.Opacity
                });

            Type ownerType = typeof(TopWallpaperRenderer);
            IsEnabledProperty
                .OverrideMetadata(ownerType, new FrameworkPropertyMetadata(false, OnIsEnabledChanged));

            ClipToBoundsProperty.OverrideMetadata(ownerType,
                new FrameworkPropertyMetadata(true, null, (o, value) => true));
            WidthProperty.OverrideMetadata(ownerType,
                new FrameworkPropertyMetadata(412.0, null, (o, value) => 412.0));
            HeightProperty.OverrideMetadata(ownerType,
                new FrameworkPropertyMetadata(240.0, null, (o, value) => 240.0));

            EffectProperty.OverrideMetadata(ownerType,
                new FrameworkPropertyMetadata(default(WarpEffect),
                    null,
                    (o, value) => ((TopWallpaperRenderer) o).GetWarpEffectInstance()));
        }
Example #15
0
        private void busquedaBtn_Click(object sender, RoutedEventArgs e)
        {
            Client cliente = ControllerCliente.Instance.buscarCliente(busquedaBox.Text);
            if (cliente == null)
            {
                MessageBox.Show("No existe con ese carnet");
            }
            else
            {
                ciBox.Text = cliente.ci.ToString();
                nombreBox.Text = cliente.nombre;
                PaternoBox.Text = cliente.apellidoPaterno;
                MaternoBox.Text = cliente.apellidoMaterno;
                DomicilioBox.Text = cliente.domicilio;
                ZonaBox.Text = cliente.zona;
                emailBox.Text = cliente.email;
                telefonoCasaBox.Text = cliente.telefonoCasa;
                telefonoOficinaBox.Text = cliente.telefonoOficina;
                feCNacimientoBox.Text = cliente.fechaNacimiento.ToString();
                sexoBox.Text = cliente.sexo;
                BiometricoBox.Text = cliente.codBiometrico;

                System.IO.MemoryStream stream = new System.IO.MemoryStream(cliente.foto);
                BitmapImage foto = new BitmapImage();
                foto.BeginInit();
                foto.StreamSource = stream;
                foto.CacheOption = BitmapCacheOption.OnLoad;
                foto.EndInit();
                image.Source = foto;
            }
        }
Example #16
0
        public ExtTreeNode(Image icon, string title)
            : this()
        {
            if (icon != null)
            {
                this.icon = icon;
            }
            else//test inti icon
            {
                this.icon = new Image();
                BitmapImage bitmapImage = new BitmapImage();
                bitmapImage.BeginInit();
                bitmapImage.UriSource = new Uri(@"pack://application:,,,/ATNET;component/icons/add.png", UriKind.RelativeOrAbsolute);
                //bitmapImage.UriSource = new Uri(@"../../icons/add.png", UriKind.RelativeOrAbsolute);
                bitmapImage.EndInit();
                this.icon.Source = bitmapImage;
            }

            this.icon.Width = 16;
            this.icon.Height = 16;

            this.title = title;

            TextBlock tb = new TextBlock();
            tb.Text = title;
            Grid grid = new Grid();
            grid.ColumnDefinitions.Add(new ColumnDefinition());
            grid.ColumnDefinitions.Add(new ColumnDefinition());
            grid.Children.Add(this.icon);
            grid.Children.Add(tb);
            Grid.SetColumn(this.icon, 0);
            Grid.SetColumn(tb, 1);
            this.Header = grid;
        }
Example #17
0
        private void apartment_Click(object sender, RoutedEventArgs e)
        {
            index.DataContext = "1";
            indexStack.Background = new SolidColorBrush(Color.FromRgb(53, 60, 70));
            BitmapImage image1 = new BitmapImage(new Uri("\\icon\\index.png", UriKind.Relative));
            indexImg.Source = image1;

            undergraduate.DataContext = "1";
            undergraduateStack.Background = new SolidColorBrush(Color.FromRgb(53, 60, 70));
            BitmapImage image2 = new BitmapImage(new Uri("\\icon\\undergraduate.png", UriKind.Relative));
            undergraduateImg.Source = image2;

            graduate.DataContext = "1";
            graduateStack.Background = new SolidColorBrush(Color.FromRgb(53, 60, 70));
            BitmapImage image3 = new BitmapImage(new Uri("\\icon\\graduate.png", UriKind.Relative));
            graduateImg.Source = image3;

            document.DataContext = "1";
            documentStack.Background = new SolidColorBrush(Color.FromRgb(53, 60, 70));
            BitmapImage image4 = new BitmapImage(new Uri("\\icon\\document.png", UriKind.Relative));
            documentImg.Source = image4;

            apartment.DataContext = "2";
            currTab.Content = new currTab.apartment();
        }
Example #18
0
        public SplashScreen()
        {
            LoadConfigPrefs();

            Image SplashScreen = new Image()
            {
                Height = Application.Current.Host.Content.ActualHeight,
                Width = Application.Current.Host.Content.ActualWidth,
                Stretch = Stretch.Fill
            };

            var imageResource = GetSplashScreenImageResource();
            if (imageResource != null)
            {
                BitmapImage splash_image = new BitmapImage();
                splash_image.SetSource(imageResource.Stream);
                SplashScreen.Source = splash_image;
            }

            // Instansiate the popup and set the Child property of Popup to SplashScreen
            popup = new Popup() { IsOpen = false,
                                  Child = SplashScreen,
                                  HorizontalAlignment = HorizontalAlignment.Stretch,
                                  VerticalAlignment = VerticalAlignment.Center

            };
        }
        public SignatureWindow(string signature)
        {
            var digitalSignatureCollection = new List<object>();
            digitalSignatureCollection.Add(new ComboBoxItem() { Content = "" });
            digitalSignatureCollection.AddRange(Settings.Instance.Global_DigitalSignatureCollection.Select(n => new DigitalSignatureComboBoxItem(n)).ToArray());

            InitializeComponent();

            {
                var icon = new BitmapImage();

                icon.BeginInit();
                icon.StreamSource = new FileStream(Path.Combine(App.DirectoryPaths["Icons"], "Amoeba.ico"), FileMode.Open, FileAccess.Read, FileShare.Read);
                icon.EndInit();
                if (icon.CanFreeze) icon.Freeze();

                this.Icon = icon;
            }

            _signatureComboBox.ItemsSource = digitalSignatureCollection;

            for (int index = 0; index < Settings.Instance.Global_DigitalSignatureCollection.Count; index++)
            {
                if (Settings.Instance.Global_DigitalSignatureCollection[index].ToString() == signature)
                {
                    _signatureComboBox.SelectedIndex = index + 1;

                    break;
                }
            }
        }
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            var result = WeatherService.GetWeatherFor(SearchBox.Text);

            string fileUrl = $"{Environment.CurrentDirectory}/{result.icon}.gif";

            if (!File.Exists(fileUrl))
            {
                using (var webClient = new WebClient())
                {
                    byte[] bytes = webClient.DownloadData(result.icon_url);
                    File.WriteAllBytes(fileUrl, bytes);
                }
            }

            BitmapImage image = new BitmapImage(new Uri(fileUrl));

            WeatherImage.Source = image;

            // CityBlock.Text = result.full.ToString();
            LatiLongBlock.Text = result.latitude.ToString() + "/" + result.longitude.ToString();
            WeatherBlock.Text = result.weather.ToString();
            TempFBlock.Text = result.temp_f.ToString();
            TempCBlock.Text = result.temp_c.ToString();
            HumidityBlock.Text = result.relative_humidity.ToString();
            WindmphBlock.Text = result.wind_mph.ToString();
            WindDirectionBlock.Text = result.wind_dir.ToString();
            UVIndexBox.Text = result.UV.ToString();

        }
        /// <summary>
        /// Gets the bitmap image.
        /// </summary>
        /// <param name="uri">The URI.</param>
        /// <returns>BitmapImage.</returns>
        /// <exception cref="System.ArgumentNullException">uri</exception>
        public BitmapImage GetBitmapImage(Uri uri)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }

            var bitmap = new BitmapImage
            {
                CreateOptions = BitmapCreateOptions.DelayCreation,
                CacheOption = BitmapCacheOption.OnDemand,
                UriCachePolicy = new RequestCachePolicy(RequestCacheLevel.CacheIfAvailable)
            };

            var scalingMode = _config.Configuration.EnableHighQualityImageScaling
                                  ? BitmapScalingMode.Fant
                                  : BitmapScalingMode.LowQuality;

            RenderOptions.SetBitmapScalingMode(bitmap, scalingMode);

            bitmap.BeginInit();
            bitmap.UriSource = uri;
            bitmap.EndInit();

            return bitmap;
        }
Example #22
0
        private void updateImage()
        {
            try
            {
                SnapshotImg.Source = null;
                ImageExportOptions options = new ImageExportOptions();
                options.FilePath = snapshot;
                //   options.
                options.HLRandWFViewsFileType = ImageFileType.PNG;
                options.ShadowViewsFileType = ImageFileType.PNG;
                options.ExportRange = ExportRange.VisibleRegionOfCurrentView;
                options.ZoomType = ZoomFitType.FitToPage;
                options.ImageResolution = ImageResolution.DPI_72;
                options.PixelSize = 1000;
                doc.ExportImage(options);
                BitmapImage source = new BitmapImage();
                source.BeginInit();
                source.UriSource = new Uri(snapshot);
                source.CacheOption = BitmapCacheOption.OnLoad;
                source.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
                source.EndInit();
                SnapshotImg.Source = source;

                PathLabel.Content = "none";
            }
            catch (System.Exception ex1)
            {
                TaskDialog.Show("Error!", "exception: " + ex1);
            }

        }
Example #23
0
 public override Brush getViewTile(ICase tile)
 {
     ImageBrush brush = new ImageBrush();
     if (tile is CaseDesert)
     {
         if (tileDesert == null)
             tileDesert = new BitmapImage(new Uri("../../Resources/" + styleName + "/caseDesert.png", UriKind.Relative));
         brush.ImageSource = tileDesert;
     }
     else if (tile is CaseEau)
     {
         if (tileEau == null)
             tileEau = new BitmapImage(new Uri("../../Resources/" + styleName + "/caseEau.png", UriKind.Relative));
         brush.ImageSource = tileEau;
     }
     else if (tile is CaseForet)
     {
         if (tileForet == null)
             tileForet = new BitmapImage(new Uri("../../Resources/" + styleName + "/caseForet.png", UriKind.Relative));
         brush.ImageSource = tileForet;
     }
     else if (tile is CaseMontagne)
     {
         if (tileMontagne == null)
             tileMontagne = new BitmapImage(new Uri("../../Resources/" + styleName + "/caseMontagne.png", UriKind.Relative));
         brush.ImageSource = tileMontagne;
     }
     else if (tile is CasePlaine)
     {
         if (tilePlaine == null)
             tilePlaine = new BitmapImage(new Uri("../../Resources/" + styleName + "/casePlaine.png", UriKind.Relative));
         brush.ImageSource = tilePlaine;
     }
     return brush;
 }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (e.NavigationMode == NavigationMode.New)
            {
                XElement article = XElement.Load("Resources/about_program.xml");

                XElement Credits = article.Element("Credits");
                CreditsAbout.Text = Credits.Element("text").Value;

                CreditsCopyright.Text = "\u00A9" + CreditsCopyright.Text;
                CreditsText.Content = "\"" + CreditsText.Content + "\"";

                Version.Text = AppResources.Version + ": " + article.Element("version").Value;

                XElement developer = article.Element("developer");
                Stream stream = Application.GetResourceStream(new Uri(developer.Element("logo").Attribute("src").Value, UriKind.Relative)).Stream;

                BitmapImage bmp = new BitmapImage();
                bmp.SetSource(stream);
                stream.Close();

                DeveloperLogo.Source = bmp;
                DeveloperLogo.Stretch = Stretch.Uniform;
            }
        }
        /*
         * This returns the status of the system i.e. running or not... 
         */
        bool SetRunningStatus(bool running)
        {        
            if (running)
            {
                if(mIsRunning == false)
                {
                    var uri = new Uri("pack://application:,,,/Images/Generic/RunningOn.png");
                    var bitmap = new BitmapImage(uri);
                    StatusIndicator.Source = bitmap;
                    statusLabel.Content = "Started!";

                    mIsRunning = true;
                    return true;
                }
                else
                {
                    MessageBox.Show("The task is already running, try stopping it first!");
                    return false;
                }   
            }
            else
            {
                var uri = new Uri("pack://application:,,,/Images/Generic/RunningOff.png");
                var bitmap = new BitmapImage(uri);
                StatusIndicator.Source = bitmap;
                statusLabel.Content = "Stopped!";

                mIsRunning = false;
                return true;

            }
        }
 public StatisticsWindow()
 {
     InitializeComponent();
     Uri uri = new Uri("pack://siteoforigin:,,,/Resources/Без имени-2.png");
     BitmapImage bitmap = new BitmapImage(uri);
     img.Source = bitmap;
 }
		public override bool View(DecompilerTextView textView)
		{
			try {
				AvalonEditTextOutput output = new AvalonEditTextOutput();
				Data.Position = 0;
				BitmapImage image = new BitmapImage();

				//HACK: windows imaging does not understand that .cur files have the same layout as .ico
				// so load to data, and modify the ResourceType in the header to make look like an icon...
				byte[] curData = ((MemoryStream)Data).ToArray();
				curData[2] = 1;
				using (Stream stream = new MemoryStream(curData)) {
					image.BeginInit();
					image.StreamSource = stream;
					image.EndInit();
				}

				output.AddUIElement(() => new Image { Source = image });
				output.WriteLine();
				output.AddButton(Images.Save, "Save", delegate {
					Save(null);
				});
				textView.ShowNode(output, this, null);
				return true;
			}
			catch (Exception) {
				return false;
			}
		}
        private void LoadStorage()
        {
            if (!File.Exists(JsonFileName))
            {
                throw new FileNotFoundException("cannot find file " + JsonFileName);
            }

            using (FileStream fs = new FileStream(JsonFileName, FileMode.Open, FileAccess.Read))
            {
                var reader  = new StreamReader(fs);
                var data    = reader.ReadToEnd();
                Storage.ReadStorageJosn(data);
            }

            foreach (var obj in Storage.GetWallpapers())
            {
                var abspath = Path.GetFullPath(ImagePath + obj.FileName + obj.Extension);
                var img     = new BitmapImage(new Uri(abspath));
                lock (objLocker)
                {
                    ImageDictionary[obj.Url]    = img;
                    UrlSet[obj.Url]             = obj.Titile;
                }
                WallpaperList.Add(new WallpaperInfo() { Url = obj.Url, Title = obj.Titile });
            }
        }
        public AnimatedGifWindow()
        {
            var img = new Image();
            var src = default(BitmapImage);

            var source = Path.Combine(
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                "background.gif");

            if (File.Exists(source)) {
                src = new BitmapImage();
                src.BeginInit();
                src.StreamSource = File.OpenRead(source);
                src.EndInit();
            
                ImageBehavior.SetAnimatedSource(img, src);
                this.Content = img;
                this.Width = src.Width;
                this.Height = src.Height;
            }
                        
            this.AllowsTransparency = true;
            this.WindowStyle = WindowStyle.None;
            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            this.ShowInTaskbar = true;
            this.Topmost = true;
            this.TaskbarItemInfo = new TaskbarItemInfo {
                ProgressState = TaskbarItemProgressState.Normal
            };
            this.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
        }
        /// <summary>
        /// Called when IsEnabled property is changed for all GreyscalOnDisabledImage instances.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="args"></param>
        private static void OnGreyscaleOnDisabledImageIsEnabledPropertyChanged(DependencyObject source,
            DependencyPropertyChangedEventArgs args)
        {
            // Get the image object.
            var img = source as GreyscaleOnDisabledImage;

            // Ensure we have an instance of GreyscaleOnDisabledImage.
            if (img == null) return;

            // Check the new value of the IsEnabled property
            if (Convert.ToBoolean(args.NewValue)) // It is enabled (true)?
            {
                // Set the Source property to the original value.
                img.Source = ((FormatConvertedBitmap)img.Source).Source;
                // Reset the Opcity Mask
                img.OpacityMask = null;
            }
            else // It isn't enabled (false), use greyscale!
            {
                // Get the image as a bitmap
                var bitmapImage = new BitmapImage(new Uri(img.Source.ToString()));
                // Convert the image to greyscale using the bitmap
                img.Source = new FormatConvertedBitmap(bitmapImage, PixelFormats.Gray32Float, null, 0);
                // Create an Opacity Mask to use for the greyscale image
                img.OpacityMask = new ImageBrush(bitmapImage);
            }
        }