Ejemplo n.º 1
0
    private void onExportedObjectSelected(ExportedObjectSelectedMessage message) {
      string extension = Path.GetExtension(message.Filename)?.ToLowerInvariant();

      switch(extension) {
        case ".ogg": {
          Task.Run(() => playSound(new FileStream(message.Filename, FileMode.Open), resetToken())).FireAndForget();

          break;
        }
        case ".dds": {
          DdsFile image = new DdsFile(message.Filename);

          viewModel.MipMaps = null;

          viewModel.Texture = image.BitmapSource;

          break;
        }
        default: {
          break;
        }
      }
    }
Ejemplo n.º 2
0
    private void onMipMapViewEntityChanged(object sender, PropertyChangedEventArgs args) {
      if (isSelf) return;

      MipMapViewEntity entity = sender as MipMapViewEntity;

      if (entity == null) return;

      switch(args.PropertyName) {
        case "IsChecked": {
          if (entity.IsChecked) {
            isSelf = true;

            viewModel.MipMaps.Where(mip => mip != entity).ToList().ForEach(mip => mip.IsChecked = false);

            isSelf = false;

            Stream stream = texture.GetObjectStream(entity.Level - 1);

            if (stream != null) {
              DdsFile ddsFile = new DdsFile();

              ddsFile.Load(stream);

              viewModel.Texture = ddsFile.BitmapSource;

              stream.Close();
            }
          }
          else {
            isSelf = true;

            entity.IsChecked = true;

            isSelf = false;
          }

          break;
        }
        default: {
          break;
        }
      }
    }
Ejemplo n.º 3
0
    public override async Task SaveObject(string filename, object configuration) {
      if (MipMaps == null || !MipMaps.Any()) return;

      DdsSaveConfig config = configuration as DdsSaveConfig ?? new DdsSaveConfig(FileFormat.Unknown, 0, 0, false, false);

      FileFormat format;

      DomainMipMap mipMap = MipMaps.Where(mm => mm.ImageData != null && mm.ImageData.Length > 0).OrderByDescending(mm => mm.Width > mm.Height ? mm.Width : mm.Height).FirstOrDefault();

      if (mipMap == null) return;

      Stream memory = buildDdsImage(MipMaps.IndexOf(mipMap), out format);

      if (memory == null) return;

      DdsFile ddsImage = new DdsFile(memory);

      FileStream ddsStream = new FileStream(filename, FileMode.Create);

      config.FileFormat = format;

      await Task.Run(() => ddsImage.Save(ddsStream, config));

      ddsStream.Close();

      memory.Close();
    }