From ca2ad079d42a8020ed215090ca2c0c6efa6f3848 Mon Sep 17 00:00:00 2001 From: localhorst Date: Mon, 3 Jun 2019 22:24:18 +0200 Subject: [PATCH] added directory chooser for export --- .../controller/Controller.kt | 7 ++-- .../view/mainView/MainViewController.kt | 36 +++++++++++++++++++ 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/controller/Controller.kt b/client/src/main/kotlin/org/hso/texturesyncclient/controller/Controller.kt index 126da25..f03247b 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/controller/Controller.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/controller/Controller.kt @@ -2,18 +2,15 @@ package org.hso.texturesyncclient.controller import javafx.collections.ObservableList import org.hso.texturesyncclient.controller.net.Connection -import org.hso.texturesyncclient.model.GUIModel -import org.hso.texturesyncclient.model.Texture import org.hso.texturesyncclient.view.importView.ImportViewController import org.hso.texturesyncclient.view.mainView.MainViewController import org.hso.texturesyncclient.view.startupView.StartupViewController import tornadofx.Controller import java.net.InetAddress -import java.util.* import java.util.Calendar import java.io.File import javax.imageio.ImageIO -import java.awt.image.BufferedImage + @@ -61,4 +58,6 @@ class RootController : Controller() { println("Height: ${bimg.getHeight()} With: ${bimg.getWidth()}") } + + } \ No newline at end of file diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainViewController.kt b/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainViewController.kt index b762f49..7eb93c5 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainViewController.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainViewController.kt @@ -3,7 +3,15 @@ package org.hso.texturesyncclient.view.mainView import javafx.collections.ObservableList import javafx.scene.image.Image import org.hso.texturesyncclient.model.GUIModel +import org.hso.texturesyncclient.model.TextureFormat import tornadofx.Controller +import javafx.stage.DirectoryChooser +import javax.swing.JColorChooser.showDialog +import java.io.File + + + + class MainViewController : Controller() { @@ -47,4 +55,32 @@ class MainViewController : Controller() { println(cvTags.chips) } + + /** + * save the texture file to r + * @param data the file as a byte array + * @param name name for the file + * @param format specific file format. jpeg or png + */ + fun exportTexture(data: ByteArray, name: String, format : TextureFormat){ + + + val directoryChooser = DirectoryChooser() + + directoryChooser.title = "Export Verzeichnis wählen" + + // TODO directoryChooser.setInitialDirectory(new File(System.getProperty("user.home"))) + + val dir = directoryChooser.showDialog(primaryStage) + + if (dir != null) { + + //copy data (bytesarray) with name and extension to dir + + } + + + } + + } \ No newline at end of file