public void RefreshImage() { DecalImageModel decal = this.DataContext as DecalImageModel; decal.RefreshPreview(); imgPreview.Source = decal.ImageSource; }
private void Button_Click_2(object sender, RoutedEventArgs e) { ColorPickerControls.Dialogs.ColorPickerFullDialog dlg = new ColorPickerControls.Dialogs.ColorPickerFullDialog(); DecalImageModel decal = this.DataContext as DecalImageModel; dlg.InitialColor = decal.Color3; if (dlg.ShowDialog().GetValueOrDefault(false)) { decal.Color3 = dlg.SelectedColor; } var expression = rectangle3.GetBindingExpression(Border.BackgroundProperty); if (expression != null) { expression.UpdateTarget(); } RefreshImage(); }
private void btnSave_Click(object sender, RoutedEventArgs e) { try { RasterResult = RasterImage.CreateFromBitmap(quantizedBitmap); InstanceId = TGIRandomGenerator.GetNext(); DatabaseIndex newIndex = new DatabaseIndex(_index.Owner); newIndex.TypeId = (uint)TypeIds.RasterFile; newIndex.InstanceId = InstanceId; newIndex.Flags = 1; newIndex.IsModified = true; newIndex.Compressed = false; newIndex.ModifiedData = new ModifiedRasterFile() { ImageFileData = RasterResult.ToIndexData() }; _index.Owner.Indices.Add(newIndex); SimCityPak.PackageReader.DatabaseManager.Instance.Indices.Add(newIndex); Decal = new DecalImageModel(); Decal.IdProperty = TGIRandomGenerator.GetNext().ToHex(); Decal.DecalIdProperty = InstanceId.ToHex(); Decal.Color4 = ((SolidColorBrush)rectangle1.Background).Color; Decal.Color1 = ((SolidColorBrush)rectangle2.Background).Color; Decal.Color2 = ((SolidColorBrush)rectangle3.Background).Color; Decal.Color3 = ((SolidColorBrush)rectangle4.Background).Color; Decal.AspectRatioProperty = 1; this.DialogResult = true; this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error during generation", MessageBoxButton.OK, MessageBoxImage.Error); } }
public ViewEditDecalDictionaryEntry(DecalImageModel decal) { this.DataContext = decal; InitializeComponent(); RefreshImage(); }