public ImageBrush blackPawn() { ImageBrush myBrush = new ImageBrush(); myBrush.ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "\\images\\czarPion.png")); return(myBrush); }
/// <inheritdoc/> public override string QualifiedUrl(string path) { var baseUri = BaseUriHelper.GetBaseUri(); var qualifiedUri = new Uri(baseUri, path); return(qualifiedUri.ToString()); }
public ImageBrush whiteQueen() { ImageBrush myBrush = new ImageBrush(); myBrush.ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "\\images\\bialqueen.png")); return(myBrush); }
private void changeScore() { isLose = false; answerTime = scoreTimeCounter; stopAnimation(); ImageBrush answerBrush = new ImageBrush(); answerBrush.ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "images/愛心.png")); correctAnswer.Background = answerBrush; if (answerTime >= 0 && answerTime <= 2 * level / 3) { score += 7; } else if (answerTime > 2 * level / 3 && answerTime <= 4 * level / 3) { score += 5; } else if (answerTime > 4 * level / 3 && answerTime <= 2 * level) { score += 2; } lblScore.Content = score.ToString(); //關卡設計 if (gameTimeCounter >= 10 && level > 1) { level--; gameTimeCounter = 0; } }
public void DrawColor() { ImageBrush imagebrush = new ImageBrush(); if (IsOranje && !IsSolid) { imagebrush.ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "../../../images/oranje-stippel.png")); recDag.Fill = imagebrush; btnCreateMandag.BorderBrush = new SolidColorBrush(Colors.LawnGreen); } else if (IsGroen && IsSolid) { recDag.Fill = new SolidColorBrush(Colors.LawnGreen); btnCreateMandag.BorderBrush = new SolidColorBrush(Colors.LawnGreen); } else if (IsGroen && !IsSolid) { imagebrush.ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "../../../images/groen-stippel.png")); recDag.Fill = imagebrush; btnCreateMandag.BorderBrush = new SolidColorBrush(Colors.LawnGreen); } else if (!IsGroen && IsSolid) { recDag.Fill = new SolidColorBrush(Colors.OrangeRed); btnCreateMandag.BorderBrush = new SolidColorBrush(Colors.OrangeRed); } else if (!IsGroen && !IsSolid) { imagebrush.ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "../../../images/rood-stippel.png")); recDag.Fill = imagebrush; btnCreateMandag.BorderBrush = new SolidColorBrush(Colors.OrangeRed); } }
public MainWindow() { InitializeComponent(); Uri iconUri = new Uri("pack://application:,,,/Resources/MWT.ico", UriKind.RelativeOrAbsolute); BaseUri = BaseUriHelper.GetBaseUri(this); this.Icon = BitmapFrame.Create(iconUri); MainTitle += $" v{version}"; this.Title = $"{MainTitle}"; ofd.Filter = Translate.Key(nameof(MifareWindowsTool.Properties.Resources.DumpFileFilter)); t = new Tools(this); ofd.InitialDirectory = Path.Combine(t.DefaultWorkingDir, "dumps"); if (!t.TestWritePermission(ofd.InitialDirectory)) { MessageBox.Show(Translate.Key(nameof(MifareWindowsTool.Properties.Resources.PleaseRestartAsAdmin))); Application.Current.Shutdown(); } if (CheckSetDriver()) { PeriodicScanTag(); } }
private void Lose() { ImageBrush answerBrush = new ImageBrush(); answerBrush.ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "images2/叉叉.png")); wrongAnswer.Background = answerBrush; stopAnimation(); gameover = true; if (score >= Name1.highScoreGame2) { Name1.highScoreGame2 = score; if (System.Windows.MessageBox.Show("Congratulations! You get the highest score : " + score.ToString(), "GameOver", MessageBoxButton.OK, MessageBoxImage.Question) == MessageBoxResult.OK) { Name1 child = new Name1(); child.Owner = this; child.Show(); highScoreLbl.Content = Name1.highScoreGame2; } } else if (System.Windows.MessageBox.Show("Your score is : " + score.ToString() + "\n The highest score is : " + Name1.highScoreNameGame2 + " , " + Name1.highScoreGame2, "GameOver", MessageBoxButton.OK, MessageBoxImage.Question) == MessageBoxResult.OK) { ; } }
private void changeScore() { if (person == 1) { person1.Background = null; person = 2; } else if (person == 2) { person2.Background = null; person = 3; } else { person3.Background = null; person = 1; } ImageBrush answerBrush = new ImageBrush(); answerBrush.ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "images/愛心.png")); correctAnswer.Background = answerBrush; score += (1); lblScore.Content = score.ToString(); isCorrect = true; }
public void creaQuadre(string rutaImatge, string nom, int fila, int columna, int midaLletra) { StackPanel persona = new StackPanel(); TextBlock nomPersona = new TextBlock(); nomPersona.FontSize = midaLletra; nomPersona.FontWeight = FontWeights.Bold; nomPersona.Foreground = new SolidColorBrush(Colors.Red); nomPersona.Text = nom; persona.Children.Add(nomPersona); ImageBrush fons = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), rutaImatge))); persona.Background = fons; if (nom != "*") { persona.AllowDrop = true; persona.MouseDown += persona_MouseDown; persona.DragEnter += persona_DragEnter; persona.Drop += persona_Drop; } Grid.SetColumn(persona, columna); Grid.SetRow(persona, fila); grdEscenari.Children.Add(persona); //FerAnimacio(); }
// Set snowman to buffed state public override void buff() { this.Snowman.Img = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(Application.Current.MainWindow), "../Images/snowman_buffed.png")); this.Snowman.Moveable = true; this.Snowman.Buffed = true; this.Snowman.TransitionTo(new BuffedState()); }
private void satinal_Click(object sender, RoutedEventArgs e) { if (suankikullanici == 0) { Kaydir("Girisac", Giris); Giris.Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "rsm/kırmızılı.jpg"))); } else { int z = 0; if (sepetlist.Count != 0) { for (int i = 0; i < sepetlist.Count; i++) { z += sepetlist.ElementAt(i).fiyat *sepetlist.ElementAt(i).adet; } sontutar.Content = "Toplam Tutar: " + z.ToString(); Kaydir("siparisitamamlaac", alisverisspnl); Kaydir("Giriskapa", Giris); } else { System.Windows.MessageBox.Show("Sepetiniz boş "); } } Kaydir("Sepetkapa", Sepet); }
public void PrepareWindow() { // select respective image string resource; switch (MessageType) { case MessageType.Blue: resource = "Resources/goodWindow.png"; break; case MessageType.Red: resource = "Resources/errorWindow.png"; break; case MessageType.White: resource = "Resources/someWindow.png"; break; default: resource = "Resources/aboutWindow.png"; break; } Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), resource))); TextBlockCaption.Text = Caption; TextBlockText.Text = _isSingle ? _text : _texts[0]; InitButtons(); }
private void render() { for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { IPiece piece = _gameState.At(x, y); Rectangle square = _imageSquares[x, y]; SquareState currentState = (SquareState)square.Tag; if (currentState.Piece != piece) { if (piece != null) { string path = "images/" + piece.ImageFile(); Uri imageUri = new Uri(BaseUriHelper.GetBaseUri(this), path); BitmapImage image = new BitmapImage(imageUri); currentState.Piece = piece; square.Tag = currentState; square.Fill = new ImageBrush(image); } else { currentState.Piece = null; square.Tag = currentState; square.Fill = new ImageBrush(); } } } } lblPlayerTurn.Content = _gameState.PlayerTurn.ToString(); //lblWhiteHeuristic.Content = Agent.Heuristic.GetHeuristic(_gameState, Team.White); lblWhiteHeuristic.Content = _totalEvals; }
public void SetImage() { ImageBrush myBrush = new ImageBrush(); myBrush.ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "background.jpg")); this.Background = myBrush; }
public MainWindow() { InitializeComponent(); this.DataContext = MainWindowVM.GetInstance; #region BackGround if (!Directory.Exists(Environment.CurrentDirectory + "/Images/")) { Directory.CreateDirectory(Environment.CurrentDirectory + "/Images/"); } string[] fileArray = Directory.GetFiles(Environment.CurrentDirectory + "/Images/"); Random rand = new Random(); if (fileArray.Length > 0) { try { Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), fileArray[rand.Next(0, fileArray.Length)]))); } catch (Exception ex) { ExceptionUtility.LogError(ex); } } #endregion }
private void RestartGame() { foreach (var x in MyCanvas.Children.OfType <Rectangle>()) { if (x.Tag.ToString() == "car") { itemRemover.Add(x); } if (x.Tag.ToString() == "bomb") { ImageBrush lostLife = new ImageBrush(); lostLife.ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "/Resources/Images/FuelFull.png")); Life1.Fill = lostLife; Life2.Fill = lostLife; Life3.Fill = lostLife; } } foreach (Rectangle y in itemRemover) { MyCanvas.Children.Remove(y); } itemRemover.Clear(); StartGame(); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var intValue = value as int?; if (intValue == null) { return(Binding.DoNothing); } if (intValue < 0 || intValue > 52) { return(Binding.DoNothing); } var control = parameter as Control; if (control == null) { return(Binding.DoNothing); } return(new ImageBrush( new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(control), string.Format("/DriveHUD.Common.Resources;component/images/cards/{0}.png", intValue))))); }
public void ClearDapAn() { txtAwsA.Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "Image/button3.png"))); txtAwsB.Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "Image/button3.png"))); txtAwsC.Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "Image/button3.png"))); txtAwsD.Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "Image/button3.png"))); }
public Sprite(string name, int spriteWidth, AnimationSpeed speed = AnimationSpeed.Normal, AnimationType type = AnimationType.AnimateOnce) { BitmapImage spriteSheet = new BitmapImage(UriFromImageName(name)) { BaseUri = BaseUriHelper.GetBaseUri(this) }; numSprites = (int)((spriteSheet.Width / spriteWidth) - 1); int spriteHeight = (int)spriteSheet.Height; croppedImages = new CroppedBitmap[numSprites]; for (int i = 0; i < numSprites; i++) { Int32Rect cropWindow = new Int32Rect(spriteWidth * i, 0, spriteWidth, spriteHeight); croppedImages[i] = new CroppedBitmap(spriteSheet, cropWindow); } animationType = type; this.Source = croppedImages[0]; animationTimer.Interval = (int)speed; animationTimer.Tick += animationTimer_Tick; animationTimer.Start(); }
private void HelpCommand_Executed(object sender, ExecutedRoutedEventArgs e) { var baseUri = BaseUriHelper.GetBaseUri(this); BitmapSource img = new BitmapImage(new Uri(baseUri, @"/img/colora.png")); manager.ShowAboutBox(img); }
private void Maingrid() { maingrid = (Grid)Content; maingrid.Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "pmr.jpg"))); maingrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); maingrid.RowDefinitions.Add(new RowDefinition()); maingrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); maingrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); maingrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); maingrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); maingrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); maingrid.ColumnDefinitions.Add(new ColumnDefinition()); maingrid.ColumnDefinitions.Add(new ColumnDefinition()); maingrid.ColumnDefinitions.Add(new ColumnDefinition()); }
private void Button_Click(object sender, RoutedEventArgs e) { // Ablak címének beállítása this.Title = "Hello Világ!"; // Szöveg mező beállítása Text1.Content = "Hello Világ!"; //Szövegmező betűtipusának beállítása Text1.FontFamily = new FontFamily("Arial"); // checkbox alapján történő szöveg beállítás if (check1.IsChecked.Value) { Text1.Content = "Hello Checkbox!"; } // Háttérkép beállítása az ablaknak az internetről //Háttér betöltése az ecsetbe ImageBrush myImageBrush = new ImageBrush(); myImageBrush.ImageSource = new BitmapImage( new Uri(BaseUriHelper.GetBaseUri(this), "http://www.gamechannel.hu/pictures/hirblock/tovabbra_is_a_windows_xp_a_masodik_legnepszerubb_windows_1.jpg" )); // Háttér beállítása this.Background = myImageBrush; }
private ImageSource TryConvertToImageSource(object value) { if (value is ImageSource) { var imageSource = (ImageSource)value; // Set BaseUri. var uriContext = imageSource as IUriContext; if (uriContext != null && !imageSource.IsFrozen && uriContext.BaseUri == null) { uriContext.BaseUri = BaseUriHelper.GetBaseUri(this); } return(imageSource); } if (value is string) { value = new Uri((string)value, UriKind.RelativeOrAbsolute); } if (value is Uri) { var bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.BaseUri = BaseUriHelper.GetBaseUri(this); bitmapImage.UriSource = (Uri)value; bitmapImage.EndInit(); return(bitmapImage); } return(null); }
public MainWindow() { InitializeComponent(); //初始化当前时间 label5.Content = DateTime.Now.ToLongTimeString().ToString(); label6.Content = DateTime.Now.ToString("yyyy-MM-dd"); //计时器 DispatcherTimer time = new DispatcherTimer(); time.Interval = new TimeSpan(0, 0, 1); time.Tick += new EventHandler(setTime); time.Start(); //计算今天是谁打扫 TimeSpan dayNow = new TimeSpan(DateTime.Now.Ticks); TimeSpan dayStart = new TimeSpan(timeStart.Ticks); int timeDiff = dayNow.Subtract(dayStart).Duration().Days; //遍历按钮插值 for (int i = 0; i < member.Length; i++) { string btnName = "button" + i, imgName = "image" + i, labelName = "label" + i, textBlockName = "textBlock" + i, titleName = "title" + i; var btn = GetControlObject <Button>(btnName); btn.Opacity = 0.5; if (member[i].num == timeDiff % pCount + 1) { btn.Opacity = 1; duty = btn; label7.Content = "今天是" + member[i].name + "值日"; btn.Opacity = 1; } if (member[i].picture != "") { try { var imgBrush = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), member[i].picture))); imgBrush.Stretch = Stretch.UniformToFill; btn.Background = imgBrush; GetControlObject <Image>(imgName).Source = new BitmapImage(new Uri(member[i].picture, UriKind.Absolute)); } catch (Exception e) { MessageBox.Show(e.Message); } } GetControlObject <Label>(labelName).Content = member[i].name; GetControlObject <TextBlock>(textBlockName).Text = member[i].intro; GetControlObject <Label>(titleName).Content = member[i].name; } }
private void Button_Click(object sender, RoutedEventArgs e) { try { if (string.IsNullOrWhiteSpace(txt1.Text) || string.IsNullOrWhiteSpace(psb1.Password)) { txt1.BorderBrush = Brushes.Red; txt1.BorderThickness = new Thickness(2); psb1.BorderBrush = Brushes.Red; psb1.BorderThickness = new Thickness(2); MessageBox.Show("You didn't fill login or password"); return; } User result = dBTravelAgency.SelectRole(txt1.Text, psb1.Password); if (result == null) { MessageBox.Show("Incorrect login or password was written"); return; } if (result.Role == "User") { this.Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "2.jpg"))); auth.Visibility = Visibility.Hidden; Userview.Visibility = Visibility.Visible; dBforUsers.SelectAll(); dtgtourist.ItemsSource = dBforUsers.tourists; dtgtour.ItemsSource = dBforUsers.tours; dtgdisc.ItemsSource = dBforUsers.discounts; List <int> TourIds = new List <int>(); List <int> DiscountsIds = new List <int>(); TourIds.AddRange(dBforUsers.tours.Select(r => r.Id)); DiscountsIds.AddRange(dBforUsers.discounts.Select(r => r.Id)); comboBoxColum.ItemsSource = TourIds; cmbdisc.ItemsSource = DiscountsIds; stuser.DataContext = result; } else if (result.Role == "Admin") { this.Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "london.jpg"))); auth.Visibility = Visibility.Hidden; Adminview.Visibility = Visibility.Visible; dBForAdmin.SelectAdminAll(); dtgadmtour.ItemsSource = dBForAdmin.tours; dtgusertour.ItemsSource = dBForAdmin.users; } else { MessageBox.Show("Incorrect login or password was written"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//su kien khi chon add new tu popup menu private void addNewTable_Click(object sender, RoutedEventArgs e) { maxTableCurrentNumber++; buttonTableCurrentNumber++; Rectangle rec = new Rectangle(); if (maxTableCurrentNumber < 10) { rec.Name = "table" + "0" + maxTableCurrentNumber.ToString(); } else { rec.Name = "table" + maxTableCurrentNumber.ToString(); } rec.HorizontalAlignment = HorizontalAlignment.Left; rec.VerticalAlignment = VerticalAlignment.Top; Thickness m = rec.Margin; m.Left = Convert.ToInt32(currentPosition.X); m.Top = Convert.ToInt32(currentPosition.Y); rec.Margin = m; rec.Width = int.Parse(ReadWriteData.readTableSize()[0]); rec.Height = int.Parse(ReadWriteData.readTableSize()[1]); //rec.Fill = Brushes.Red; rec.Opacity = 0.65; rec.Fill = new ImageBrush { ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "..\\Images\\Number\\icons8_" + int.Parse(rec.Name.Substring(5)).ToString() + "_50px.png")) }; rec.MouseLeftButtonDown += btnTableAdded_StartDrag; rec.MouseMove += btnTableAdded_MoveDrag; rec.MouseLeftButtonDown += btnTableAdded_Click; rec.MouseRightButtonDown += btnTableAdded_ContextMenu; rec.MouseMove += btnTableAdded_MouseMove; rec.MouseLeave += btnTableAdded_MouseLeave; rec.Cursor = Cursors.SizeAll; Panel.SetZIndex(rec, 30); grTable.Children.Add(rec); imgTable.MouseMove -= crossCursorToAdd; imgTable.MouseLeftButtonDown -= changeToNormalCursor; iii = 0; ckeckPosition(rec, m); ((MainWindow)Window.GetWindow(this)).proTable.Maximum += 1; currentTableList.Add(ReadWriteData.writeOnAddNew(_unitofwork, rec, App.Current.Properties["EmpLogin"] as Entities.Employee)); rec.ToolTip = SetTooltip(rec); }
public override RainDrop CreatePositiveRainDrop() { // star image BitmapImage img = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(Application.Current.MainWindow), "../Images/star.png")); Star star = new Star(img); return(star); }
private void grd_exit_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e) { img_exit.Source = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "img/cancel_hover2.png")); img_exit.Height = 32; img_exit.Width = 32; grd_exit.Height = 32; grd_exit.Width = 32; }
// Labor.Birja_TrudaDataSetTableAdapters.VacansiesTableAdapter birja_TrudaDataSetVacansiesTableAdapter = new Labor.Birja_TrudaDataSetTableAdapters.VacansiesTableAdapter(); public VacanciesBase() { InitializeComponent(); ImageBrush myBrush = new ImageBrush(); myBrush.ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "background.jpg")); this.Background = myBrush; }
private void MouseLeave_Label(object sender, MouseEventArgs e) { ((Label)sender).Foreground = Brushes.OrangeRed; ImageBrush i = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "icons/icon_" + ((Label)sender).Name + "_normal.png"))); ((Label)sender).Background = i; }