the Save SVG button now prompts a form to select the folder

This commit is contained in:
2022-06-20 14:23:06 +02:00
parent 9b4cfb33bd
commit 95217bb3c5
2 changed files with 31 additions and 2 deletions

View File

@@ -471,7 +471,22 @@ namespace Paint_2
private void btnSvgExport_Click(object sender, EventArgs e)
{
Project.ConvertToSVG();
FolderBrowserDialog fbd = new FolderBrowserDialog();
fbd.Description = "Custom Description";
if (fbd.ShowDialog() == DialogResult.OK)
{
string SelectedPath = fbd.SelectedPath;
if (Project.SaveSvg(SelectedPath,tbxProjectName.Text))
{
MessageBox.Show("Svg saved at "+ SelectedPath);
}
else
{
MessageBox.Show("Ooops, could not save the SVG in " + SelectedPath);
}
}
}
}
}

View File

@@ -417,7 +417,7 @@ namespace Paint_2
return result;
}
public void ConvertToSVG()
public string ConvertToSVG()
{
string fileContent = "";
string newLine = Environment.NewLine;
@@ -434,6 +434,20 @@ namespace Paint_2
fileContent += newLine;
fileContent += "</svg>";
return fileContent;
}
public bool SaveSvg(string path,string fileName)
{
bool result = false;
if (Directory.Exists(path))
{
using (StreamWriter sw = File.CreateText(path + "\\" + fileName + ".svg"))
{
sw.WriteLine(ConvertToSVG());
result = true;
}
}
return result;
}
}
}