Skip to content
This repository has been archived by the owner on Jul 21, 2020. It is now read-only.

Commit

Permalink
Added Save Setting to File - UI Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkl58 committed Feb 29, 2020
1 parent 794f8d0 commit 880fff6
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 13 deletions.
1 change: 1 addition & 0 deletions NotEnoughEncodes/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@
<Label Content="2. Output" HorizontalAlignment="Left" Margin="9,42,0,0" VerticalAlignment="Top" Foreground="White" Background="#99232323" Width="92"/>
<TextBlock x:Name="textBlockOutput" HorizontalAlignment="Left" Margin="109,45,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="20" Width="402" Background="#99232323" Foreground="White" Grid.ColumnSpan="4" Text=" Output"/>
<Button x:Name="ButtonOutput" Content="Save to..." Grid.Column="3" HorizontalAlignment="Left" Margin="24,45,0,0" VerticalAlignment="Top" Width="96" Background="#99232323" Foreground="White" BorderBrush="#FFC3C3C3" Click="ButtonOutput_Click"/>
<Button Content="Save Settings" HorizontalAlignment="Left" Margin="14,152,0,0" VerticalAlignment="Top" Width="106" Background="#99232323" Foreground="#FF74FF00" BorderBrush="#FFC3C3C3" Height="22" Click="Button_Click_4"/>


</Grid>
Expand Down
76 changes: 63 additions & 13 deletions NotEnoughEncodes/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,60 @@ public MainWindow()
//Sets the Number of Workers = Phsyical Core Count
int tempCorecount = coreCount * 1 / 2;
TextBoxNumberWorkers.Text = tempCorecount.ToString();


//Load Settings
readSettings();
}

public void readSettings()
{
try
{
//If settings.ini exist -> Set all Values
bool fileExist = File.Exists("settings.ini");

if (fileExist)
{
string[] lines = System.IO.File.ReadAllLines("settings.ini");

TextBoxNumberWorkers.Text = lines[0];
ComboBoxCpuUsed.Text = lines[1];
ComboBoxBitdepth.Text = lines[2];
TextBoxEncThreads.Text = lines[3];
TextBoxcqLevel.Text = lines[4];
TextBoxKeyframeInterval.Text = lines[5];
TextBoxTileCols.Text = lines[6];
TextBoxTileRows.Text = lines[7];
ComboBoxPasses.Text = lines[8];
TextBoxFramerate.Text = lines[9];
ComboBoxEncMode.Text = lines[10];
TextBoxChunkLength.Text = lines[11];
}

}
catch { }

}

private void Button_Click_4(object sender, RoutedEventArgs e)
{
//Saves all Current Settings to a file
string maxConcurrency = TextBoxNumberWorkers.Text;
string cpuUsed = ComboBoxCpuUsed.Text;
string bitDepth = ComboBoxBitdepth.Text;
string encThreads = TextBoxEncThreads.Text;
string cqLevel = TextBoxcqLevel.Text;
string kfmaxdist = TextBoxKeyframeInterval.Text;
string tilecols = TextBoxTileCols.Text;
string tilerows = TextBoxTileRows.Text;
string nrPasses = ComboBoxPasses.Text;
string fps = TextBoxFramerate.Text;
string encMode = this.ComboBoxEncMode.Text;
string chunkLength = TextBoxChunkLength.Text;

string[] lines = { maxConcurrency, cpuUsed, bitDepth, encThreads, cqLevel, kfmaxdist, tilecols, tilerows, nrPasses, fps, encMode, chunkLength };
System.IO.File.WriteAllLines("settings.ini", lines);

}

private void Button_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -164,10 +217,13 @@ public void MainClass()
//Set the Maximum Value of Progressbar
prgbar.Maximum = chunks.Count();
}

//Starts the async task
StartTask(maxConcurrency, cpuUsed, bitDepth, encThreads, cqLevel, kfmaxdist, tilerows, tilecols, nrPasses, fps, encMode, resume, videoOutput);
//Set Maximum of Progressbar
prgbar.Maximum = chunks.Count();
//Set the Progresslabel to 0 out of Number of chunks, because people would think that it doesnt to anything
pLabel.Dispatcher.Invoke(() => pLabel.Content = "0 / " + prgbar.Maximum, DispatcherPriority.Background);

}

Expand Down Expand Up @@ -395,20 +451,15 @@ private void Button_Click_3(object sender, RoutedEventArgs e)
{
try
{
//Delete all files in Chunks folder
System.IO.DirectoryInfo dichunk = new DirectoryInfo("Chunks");
foreach (FileInfo file in dichunk.GetFiles())
{
file.Delete();
}
foreach (DirectoryInfo dir in dichunk.GetDirectories())
{
dir.Delete(true);
}
//Delete Files, because of lazy dump****
File.Delete("encoded.txt");
Directory.Delete("Chunks", true);

}
catch { }
}

//Some smaller Blackmagic, so parallel Workers won't lockdown the encoded.txt file
private static ReaderWriterLockSlim _readWriteLock = new ReaderWriterLockSlim();
public void WriteToFileThreadSafe(string text, string path)
{
Expand All @@ -430,6 +481,5 @@ public void WriteToFileThreadSafe(string text, string path)
}
}


}
}

0 comments on commit 880fff6

Please sign in to comment.