diff options
author | sr55 <[email protected]> | 2009-01-29 21:49:05 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2009-01-29 21:49:05 +0000 |
commit | 0333e36d98952fc75b07a35bb2dd5affe526b25a (patch) | |
tree | 98bfbe7260eae1cffba33107bd19379cadad2b11 /win | |
parent | 9cfe126a970a4a7c544b8142224675a93637d31e (diff) |
WinGui:
- Code cleanup
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2106 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
-rw-r--r-- | win/C#/Functions/Encode.cs | 11 | ||||
-rw-r--r-- | win/C#/Functions/QueryParser.cs | 13 | ||||
-rw-r--r-- | win/C#/frmActivityWindow.cs | 37 | ||||
-rw-r--r-- | win/C#/frmAddPreset.cs | 2 | ||||
-rw-r--r-- | win/C#/frmDownload.cs | 15 | ||||
-rw-r--r-- | win/C#/frmGenPreview.cs | 12 | ||||
-rw-r--r-- | win/C#/frmMain.cs | 149 | ||||
-rw-r--r-- | win/C#/frmOptions.cs | 2 | ||||
-rw-r--r-- | win/C#/frmPreview.cs | 17 | ||||
-rw-r--r-- | win/C#/frmQueue.cs | 49 |
10 files changed, 110 insertions, 197 deletions
diff --git a/win/C#/Functions/Encode.cs b/win/C#/Functions/Encode.cs index 3f126d7e5..ed8920c91 100644 --- a/win/C#/Functions/Encode.cs +++ b/win/C#/Functions/Encode.cs @@ -7,7 +7,6 @@ using System;
using System.Diagnostics;
using System.Windows.Forms;
-using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
@@ -23,10 +22,7 @@ namespace Handbrake.Functions // Declarations
Process hbProc = new Process();
- Boolean encoding = false;
-
- // CLI output is based on en-US locale,
- static readonly private CultureInfo Culture = new CultureInfo("en-US", false);
+ Boolean encoding;
/// <summary>
/// Execute a HandBrakeCLI process.
@@ -88,7 +84,7 @@ namespace Handbrake.Functions switch (Properties.Settings.Default.CompletionOption)
{
case "Shutdown":
- System.Diagnostics.Process.Start("Shutdown", "-s -t 60");
+ Process.Start("Shutdown", "-s -t 60");
break;
case "Log Off":
ExitWindowsEx(0, 0);
@@ -143,7 +139,6 @@ namespace Handbrake.Functions if (Properties.Settings.Default.saveLog == "Checked")
{
string logPath = Path.Combine(Path.GetTempPath(), "hb_encode_log.dat");
- Functions.QueryParser parsed = Functions.QueryParser.Parse(query);
if (Properties.Settings.Default.saveLogWithVideo == "Checked")
{
@@ -175,7 +170,7 @@ namespace Handbrake.Functions /// </summary>
public Boolean isEncoding
{
- get { if (encoding == false) return false; else return true; }
+ get { return encoding; }
}
}
diff --git a/win/C#/Functions/QueryParser.cs b/win/C#/Functions/QueryParser.cs index df048c5d1..f189e1bbc 100644 --- a/win/C#/Functions/QueryParser.cs +++ b/win/C#/Functions/QueryParser.cs @@ -718,8 +718,7 @@ namespace Handbrake.Functions if (chapters.Success)
{
- var actTitles = new string[2];
- actTitles = chapters.ToString().Replace("-c ", "").Split('-');
+ string[] actTitles = chapters.ToString().Replace("-c ", "").Split('-');
thisQuery.q_chaptersStart = int.Parse(actTitles[0]);
if (actTitles.Length > 1)
{
@@ -777,8 +776,7 @@ namespace Handbrake.Functions if (crop.Success)
{
thisQuery.q_cropValues = crop.ToString().Replace("--crop ", "");
- var actCropValues = new string[3];
- actCropValues = thisQuery.q_cropValues.Split(':');
+ string[] actCropValues = thisQuery.q_cropValues.Split(':');
thisQuery.q_croptop = actCropValues[0];
thisQuery.q_cropbottom = actCropValues[1];
thisQuery.q_cropLeft = actCropValues[2];
@@ -853,17 +851,14 @@ namespace Handbrake.Functions thisQuery.q_twoPass = twoPass.Success;
thisQuery.q_turboFirst = turboFirstPass.Success;
thisQuery.q_largeMp4 = largerMp4.Success;
- if (videoFramerate.Success)
- thisQuery.q_videoFramerate = videoFramerate.ToString().Replace("-r ", "");
- else
- thisQuery.q_videoFramerate = "Same as source";
+ thisQuery.q_videoFramerate = videoFramerate.Success ? videoFramerate.ToString().Replace("-r ", "") : "Same as source";
if (videoBitrate.Success)
thisQuery.q_avgBitrate = videoBitrate.ToString().Replace("-b ", "");
if (videoFilesize.Success)
thisQuery.q_videoTargetSize = videoFilesize.ToString().Replace("-S ", "");
- double qConvert = 0;
+ double qConvert;
if (videoQuality.Success)
{
qConvert = double.Parse(videoQuality.ToString().Replace("-q ", ""), Culture)*100;
diff --git a/win/C#/frmActivityWindow.cs b/win/C#/frmActivityWindow.cs index 1ad4e094e..94597f775 100644 --- a/win/C#/frmActivityWindow.cs +++ b/win/C#/frmActivityWindow.cs @@ -21,7 +21,7 @@ namespace Handbrake String read_file;
Thread monitor;
Functions.Encode encodeHandler;
- int position = 0; // Position in the arraylist reached by the current log output in the rtf box.
+ int position; // Position in the arraylist reached by the current log output in the rtf box.
/// <summary>
/// This window should be used to display the RAW output of the handbrake CLI which is produced during an encode.
@@ -29,7 +29,7 @@ namespace Handbrake public frmActivityWindow(string file, Functions.Encode eh)
{
InitializeComponent();
- this.rtf_actLog.Text = string.Empty;
+ rtf_actLog.Text = string.Empty;
// When the window closes, we want to abort the monitor thread.
this.Disposed += new EventHandler(forceQuit);
@@ -57,7 +57,7 @@ namespace Handbrake {
// Add a header to the log file indicating that it's from the Windows GUI and display the windows version
rtf_actLog.AppendText(String.Format("### Windows GUI {1} {0} \n", Properties.Settings.Default.hb_build, Properties.Settings.Default.hb_version));
- rtf_actLog.AppendText(String.Format("### Running: {0} \n###\n", Environment.OSVersion.ToString()));
+ rtf_actLog.AppendText(String.Format("### Running: {0} \n###\n", Environment.OSVersion));
rtf_actLog.AppendText(String.Format("### CPU: {0} \n", getCpuCount()));
rtf_actLog.AppendText(String.Format("### Ram: {0} MB \n", TotalPhysicalMemory()));
rtf_actLog.AppendText(String.Format("### Screen: {0}x{1} \n", screenBounds().Bounds.Width, screenBounds().Bounds.Height));
@@ -154,7 +154,7 @@ namespace Handbrake updateTextFromThread();
while (true)
{
- if (encodeHandler.isEncoding == true)
+ if (encodeHandler.isEncoding)
updateTextFromThread();
else
{
@@ -186,14 +186,14 @@ namespace Handbrake {
try
{
- string text = "";
+ string text;
List<string> data = readFile();
int count = data.Count;
while (position < count)
{
- text = data[position].ToString();
- if (data[position].ToString().Contains("has exited"))
+ text = data[position];
+ if (data[position].Contains("has exited"))
text = "\n ############ End of Log ############## \n";
position++;
@@ -217,15 +217,15 @@ namespace Handbrake // InvokeRequired required compares the thread ID of the
// calling thread to the thread ID of the creating thread.
// If these threads are different, it returns true.
- if (this.IsHandleCreated) // Make sure the windows has a handle before doing anything
+ if (IsHandleCreated) // Make sure the windows has a handle before doing anything
{
- if (this.rtf_actLog.InvokeRequired)
+ if (rtf_actLog.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
- this.Invoke(d, new object[] { text });
+ Invoke(d, new object[] { text });
}
else
- this.rtf_actLog.AppendText(text);
+ rtf_actLog.AppendText(text);
}
}
catch (Exception exc)
@@ -264,7 +264,7 @@ namespace Handbrake while (line != null)
{
if (line.Trim() != "")
- logData.Add(line + System.Environment.NewLine);
+ logData.Add(line + Environment.NewLine);
line = sr.ReadLine();
}
@@ -275,7 +275,7 @@ namespace Handbrake }
catch (Exception exc)
{
- MessageBox.Show("Error in readFile() \n Unable to read the log file.\n You may have to restart HandBrake.\n Error Information: \n\n" + exc.ToString(), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ MessageBox.Show("Error in readFile() \n Unable to read the log file.\n You may have to restart HandBrake.\n Error Information: \n\n" + exc, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
return null;
}
@@ -312,14 +312,7 @@ namespace Handbrake #region System Information
private struct MEMORYSTATUS
{
- public UInt32 dwLength;
- public UInt32 dwMemoryLoad;
public UInt32 dwTotalPhys; // Used
- public UInt32 dwAvailPhys;
- public UInt32 dwTotalPageFile;
- public UInt32 dwAvailPageFile;
- public UInt32 dwTotalVirtual;
- public UInt32 dwAvailVirtual;
}
[DllImport("kernel32.dll")]
@@ -358,9 +351,9 @@ namespace Handbrake /// Get the System screen size information.
/// </summary>
/// <returns>System.Windows.Forms.Scree</returns>
- public System.Windows.Forms.Screen screenBounds()
+ public Screen screenBounds()
{
- return System.Windows.Forms.Screen.PrimaryScreen;
+ return Screen.PrimaryScreen;
}
#endregion
diff --git a/win/C#/frmAddPreset.cs b/win/C#/frmAddPreset.cs index a4def1920..00b288cb9 100644 --- a/win/C#/frmAddPreset.cs +++ b/win/C#/frmAddPreset.cs @@ -29,7 +29,7 @@ namespace Handbrake if (check_pictureSettings.Checked)
pictureSettings = true;
- if (presetCode.addPreset(txt_preset_name.Text.Trim(), query, pictureSettings) == true)
+ if (presetCode.addPreset(txt_preset_name.Text.Trim(), query, pictureSettings))
{
frmMainWindow.loadPresetPanel();
this.Close();
diff --git a/win/C#/frmDownload.cs b/win/C#/frmDownload.cs index e055140fe..8b23df92b 100644 --- a/win/C#/frmDownload.cs +++ b/win/C#/frmDownload.cs @@ -15,7 +15,7 @@ namespace Handbrake {
public partial class frmDownload : Form
{
- private Thread downloadThread;
+ private readonly Thread downloadThread;
private Stream responceStream;
private Stream loacalStream;
private HttpWebRequest webRequest;
@@ -55,7 +55,7 @@ namespace Handbrake responceStream = wcDownload.OpenRead(hbUpdate);
loacalStream = new FileStream(tempPath, FileMode.Create, FileAccess.Write, FileShare.None);
- int bytesSize = 0;
+ int bytesSize;
byte[] downBuffer = new byte[2048];
long flength = 0;
@@ -63,16 +63,16 @@ namespace Handbrake {
loacalStream.Write(downBuffer, 0, bytesSize);
flength = loacalStream.Length;
- this.Invoke(new UpdateProgessCallback(this.UpdateProgress), new object[] { loacalStream.Length, fileSize });
+ Invoke(new UpdateProgessCallback(this.UpdateProgress), new object[] { loacalStream.Length, fileSize });
}
responceStream.Close();
loacalStream.Close();
if (flength != fileSize)
- this.Invoke(new DownloadFailedCallback(this.downloadFailed));
+ Invoke(new DownloadFailedCallback(this.downloadFailed));
else
- this.Invoke(new DownloadCompleteCallback(this.downloadComplete));
+ Invoke(new DownloadCompleteCallback(this.downloadComplete));
}
catch (Exception)
{
@@ -91,7 +91,7 @@ namespace Handbrake }
catch (Exception exc)
{
- MessageBox.Show("Integer Conversion Error On Download \n" + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ MessageBox.Show("Integer Conversion Error On Download \n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
@@ -101,8 +101,7 @@ namespace Handbrake btn_cancel.Text = "Close";
string tempPath = Path.Combine(Path.GetTempPath(), "handbrake-setup.exe");
-
- Process startInstall = Process.Start(tempPath);
+ Process.Start(tempPath);
this.Close();
Application.Exit();
}
diff --git a/win/C#/frmGenPreview.cs b/win/C#/frmGenPreview.cs index a7768a104..29a6213ad 100644 --- a/win/C#/frmGenPreview.cs +++ b/win/C#/frmGenPreview.cs @@ -24,10 +24,8 @@ namespace Handbrake private void btn_play_Click(object sender, EventArgs e)
{
- String currently_playing;
-
// Get the Destination of the sample video.
- currently_playing = "";
+ String currently_playing = "";
if (mainWindow.text_destination.Text != "")
currently_playing = mainWindow.text_destination.Text.Replace(".m", "_sample.m").Replace(".avi", "_sample.avi").Replace(".ogm", "_sample.ogm");
@@ -74,9 +72,9 @@ namespace Handbrake {
try
{
- if (this.InvokeRequired)
+ if (InvokeRequired)
{
- this.BeginInvoke(new UpdateHandler(encodingMessage));
+ BeginInvoke(new UpdateHandler(encodingMessage));
return;
}
lbl_status.Text = "Encoding, Please wait ...";
@@ -92,9 +90,9 @@ namespace Handbrake {
try
{
- if (this.InvokeRequired)
+ if (InvokeRequired)
{
- this.BeginInvoke(new UpdateHandler(updateUIElements));
+ BeginInvoke(new UpdateHandler(updateUIElements));
return;
}
diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index 3c9754ce3..44c7ac291 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -36,8 +36,8 @@ namespace Handbrake private frmGenPreview vlcpreview;
private frmPreview qtpreview;
private string lastAction;
- public int maxWidth = 0;
- public int maxHeight = 0;
+ public int maxWidth;
+ public int maxHeight;
Process hbproc;
@@ -144,14 +144,14 @@ namespace Handbrake {
try
{
- if (this.InvokeRequired)
+ if (InvokeRequired)
{
- this.BeginInvoke(new updateStatusChanger(startupUpdateCheck));
+ BeginInvoke(new updateStatusChanger(startupUpdateCheck));
return;
}
Boolean update = hb_common_func.updateCheck(false);
- if (update == true)
+ if (update)
{
frmUpdater updateWindow = new frmUpdater();
updateWindow.Show();
@@ -161,7 +161,7 @@ namespace Handbrake }
private void queueRecovery()
{
- if (hb_common_func.check_queue_recovery() == true)
+ if (hb_common_func.check_queue_recovery())
{
DialogResult result = MessageBox.Show("HandBrake has detected unfinished items on the queue from the last time the application was launched. Would you like to recover these?", "Queue Recovery Possible", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
@@ -227,7 +227,7 @@ namespace Handbrake }
private void mnu_encodeLog_Click(object sender, EventArgs e)
{
- String file = String.Empty;
+ String file;
if (lastAction == "scan")
file = "dvdinfo.dat";
else
@@ -258,7 +258,7 @@ namespace Handbrake private void mnu_delete_preset_Click(object sender, EventArgs e)
{
// Empty the preset file
- string presetsFile = Application.StartupPath.ToString() + "\\presets.xml";
+ string presetsFile = Application.StartupPath + "\\presets.xml";
if (File.Exists(presetsFile))
File.Delete(presetsFile);
@@ -270,7 +270,7 @@ namespace Handbrake }
catch (Exception exc)
{
- MessageBox.Show("An error has occured during the preset removal process.\n If you are using Windows Vista, you may need to run under Administrator Mode to complete this task. \n" + exc.ToString());
+ MessageBox.Show("An error has occured during the preset removal process.\n If you are using Windows Vista, you may need to run under Administrator Mode to complete this task. \n" + exc);
}
// Reload the preset panel
@@ -487,7 +487,7 @@ namespace Handbrake int i = 0;
foreach (TreeNode node in treeView_presets.Nodes)
{
- if (nodeStatus[i] == true)
+ if (nodeStatus[i])
node.Expand();
i++;
@@ -513,12 +513,12 @@ namespace Handbrake int i = 0;
foreach (TreeNode node in treeView_presets.Nodes)
{
- if (nodeStatus[i] == true)
+ if (nodeStatus[i])
node.Expand();
foreach (TreeNode subNode in node.Nodes)
{
- if (nodeStatus[i] == true)
+ if (nodeStatus[i])
subNode.Expand();
}
@@ -533,7 +533,7 @@ namespace Handbrake {
foreach (TreeNode node in treenode.Nodes)
{
- if (node.Text.ToString().Equals("Normal"))
+ if (node.Text.Equals("Normal"))
treeView_presets.SelectedNode = treeView_presets.Nodes[treenode.Index].Nodes[0];
}
}
@@ -584,11 +584,7 @@ namespace Handbrake // This is used for tracking which file to load in the activity window
lastAction = "encode";
- String query;
- if (rtf_query.Text != "")
- query = rtf_query.Text;
- else
- query = queryGen.GenerateTheQuery(this);
+ String query = rtf_query.Text != "" ? rtf_query.Text : queryGen.GenerateTheQuery(this);
if (encodeQueue.count() == 0)
{
@@ -672,13 +668,7 @@ namespace Handbrake }
private void btn_ActivityWindow_Click(object sender, EventArgs e)
{
-
-
- String file = String.Empty;
- if (lastAction == "scan")
- file = "dvdinfo.dat";
- else
- file = "hb_encode_log.dat";
+ String file = lastAction == "scan" ? "dvdinfo.dat" : "hb_encode_log.dat";
frmActivityWindow ActivityWindow = new frmActivityWindow(file, encodeHandler);
ActivityWindow.Show();
@@ -691,10 +681,7 @@ namespace Handbrake if (FormWindowState.Minimized == this.WindowState)
{
notifyIcon.Visible = true;
- if (lbl_encode.Text != "")
- notifyIcon.BalloonTipText = lbl_encode.Text;
- else
- notifyIcon.BalloonTipText = "Not Encoding";
+ notifyIcon.BalloonTipText = lbl_encode.Text != "" ? lbl_encode.Text : "Not Encoding";
notifyIcon.ShowBalloonTip(500);
this.Hide();
}
@@ -729,7 +716,7 @@ namespace Handbrake // This is used for tracking which file to load in the activity window
lastAction = "scan";
- String filename = "";
+ String filename;
text_source.Text = "";
DVD_Open.ShowDialog();
@@ -754,7 +741,7 @@ namespace Handbrake // This is used for tracking which file to load in the activity window
lastAction = "scan";
- String filename = "";
+ String filename;
text_source.Text = "";
ISO_Open.ShowDialog();
@@ -782,11 +769,10 @@ namespace Handbrake // This is used for tracking which file to load in the activity window
lastAction = "scan";
- String filename = "";
if (mnu_dvd_drive.Text.Contains("VIDEO_TS"))
{
string[] path = mnu_dvd_drive.Text.Split(' ');
- filename = path[0];
+ String filename = path[0];
setupGUIforScan(filename);
startScan(filename);
}
@@ -872,7 +858,7 @@ namespace Handbrake }
private void drop_chapterStart_SelectedIndexChanged(object sender, EventArgs e)
{
- int c_start, c_end = 1;
+ int c_start, c_end;
if (drop_chapterFinish.Text == "Auto" && drop_chapterFinish.Items.Count != 0)
drop_chapterFinish.SelectedIndex = drop_chapterFinish.Items.Count - 1;
@@ -895,7 +881,7 @@ namespace Handbrake }
private void drop_chapterFinish_SelectedIndexChanged(object sender, EventArgs e)
{
- int c_start, c_end = 1;
+ int c_start, c_end;
if (drop_chapterStart.Text == "Auto" && drop_chapterStart.Items.Count >= 1)
drop_chapterStart.SelectedIndex = 1;
@@ -914,7 +900,7 @@ namespace Handbrake // Run the Autonaming function
if (Properties.Settings.Default.autoNaming == "Checked")
text_destination.Text = hb_common_func.autoName(drp_dvdtitle, drop_chapterStart.Text, drop_chapterFinish.Text, text_source.Text, text_destination.Text, drop_format.SelectedIndex);
-
+
// Add more rows to the Chapter menu if needed.
if (Check_ChapterMarkers.Checked)
{
@@ -928,8 +914,8 @@ namespace Handbrake int n = data_chpt.Rows.Add();
data_chpt.Rows[n].Cells[0].Value = (i + 1);
data_chpt.Rows[n].Cells[1].Value = "Chapter " + (i + 1);
- data_chpt.Rows[n].Cells[0].ValueType = typeof (int);
- data_chpt.Rows[n].Cells[1].ValueType = typeof (string);
+ data_chpt.Rows[n].Cells[0].ValueType = typeof(int);
+ data_chpt.Rows[n].Cells[1].ValueType = typeof(string);
i++;
}
}
@@ -1072,7 +1058,7 @@ namespace Handbrake }
private void slider_videoQuality_Scroll(object sender, EventArgs e)
{
- SliderValue.Text = slider_videoQuality.Value.ToString() + "%";
+ SliderValue.Text = slider_videoQuality.Value + "%";
text_bitrate.Text = "";
text_filesize.Text = "";
check_2PassEncode.Enabled = false;
@@ -1102,13 +1088,9 @@ namespace Handbrake int width;
Boolean parsed = int.TryParse(text_width.Text, out width);
- if (parsed != false)
+ if (parsed)
{
- if ((width % 16) != 0)
- text_width.BackColor = Color.LightCoral;
- else
- text_width.BackColor = Color.LightGreen;
-
+ text_width.BackColor = (width % 16) != 0 ? Color.LightCoral : Color.LightGreen;
if (lbl_Aspect.Text != "Select a Title" && maxWidth == 0 && maxHeight == 0)
{
@@ -1130,13 +1112,8 @@ namespace Handbrake int height;
Boolean parsed = int.TryParse(text_height.Text, out height);
- if (parsed != false)
- {
- if ((height % 16) != 0)
- text_height.BackColor = Color.LightCoral;
- else
- text_height.BackColor = Color.LightGreen;
- }
+ if (parsed)
+ text_height.BackColor = (height % 16) != 0 ? Color.LightCoral : Color.LightGreen;
}
private void check_customCrop_CheckedChanged(object sender, EventArgs e)
{
@@ -1198,10 +1175,7 @@ namespace Handbrake }
private void slider_deblock_Scroll(object sender, EventArgs e)
{
- if (slider_deblock.Value == 4)
- lbl_deblockVal.Text = "Off";
- else
- lbl_deblockVal.Text = slider_deblock.Value.ToString();
+ lbl_deblockVal.Text = slider_deblock.Value == 4 ? "Off" : slider_deblock.Value.ToString();
}
//Audio Tab
@@ -1393,7 +1367,7 @@ namespace Handbrake drp_audmix_1.Text = lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[2].Text;
drp_audsr_1.Text = lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[3].Text;
drp_audbit_1.Text = lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[4].Text;
- double drcValue = 0; int drcCalculated = 0;
+ double drcValue; int drcCalculated;
double.TryParse(lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[5].Text, out drcValue);
drcValue = (drcValue * 10) - 10;
int.TryParse(drcValue.ToString(), out drcCalculated);
@@ -1567,7 +1541,7 @@ namespace Handbrake }
catch (Exception exc)
{
- MessageBox.Show("frmMain.cs - startScan " + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ MessageBox.Show("frmMain.cs - startScan " + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void scanProcess(object state)
@@ -1608,7 +1582,7 @@ namespace Handbrake }
catch (Exception exc)
{
- MessageBox.Show("frmMain.cs - scanProcess() " + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ MessageBox.Show("frmMain.cs - scanProcess() " + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
enableGUI();
}
}
@@ -1718,9 +1692,9 @@ namespace Handbrake {
try
{
- if (this.InvokeRequired)
+ if (InvokeRequired)
{
- this.BeginInvoke(new ProgressUpdateHandler(getDriveInfoThread));
+ BeginInvoke(new ProgressUpdateHandler(getDriveInfoThread));
return;
}
@@ -1732,8 +1706,8 @@ namespace Handbrake {
if (curDrive.IsReady)
{
- if (File.Exists(curDrive.RootDirectory.ToString() + "VIDEO_TS\\VIDEO_TS.IFO"))
- mnu_dvd_drive.Text = curDrive.RootDirectory.ToString() + "VIDEO_TS (" + curDrive.VolumeLabel + ")";
+ if (File.Exists(curDrive.RootDirectory + "VIDEO_TS\\VIDEO_TS.IFO"))
+ mnu_dvd_drive.Text = curDrive.RootDirectory + "VIDEO_TS (" + curDrive.VolumeLabel + ")";
else
mnu_dvd_drive.Text = "[No DVD Drive Ready]";
@@ -1756,7 +1730,7 @@ namespace Handbrake #region Audio Panel Code Helpers
private void setAudioByContainer(String path)
{
- string oldval = "";
+ string oldval;
if ((path.EndsWith(".mp4")) || (path.EndsWith(".m4v")))
{
@@ -1798,7 +1772,7 @@ namespace Handbrake }
private void setVideoByContainer(String path)
{
- string oldval = "";
+ string oldval;
if ((path.EndsWith(".mp4")) || (path.EndsWith(".m4v")))
{
@@ -1917,33 +1891,6 @@ namespace Handbrake dropdown.Items.Add("Dolby Surround");
dropdown.Items.Add("Dolby Pro Logic II");
}
- private void audioEncoderChange(ComboBox audenc, ComboBox audMix, ComboBox audbit, ComboBox audsr)
- {
- if (audenc.Text == "AC3")
- {
- audMix.Enabled = false;
- audbit.Enabled = false;
- audsr.Enabled = false;
-
- audMix.Text = "Automatic";
- audbit.Text = "160";
- audsr.Text = "Auto";
- }
- else
- {
- // Just make sure not to re-enable the following boxes if the track above is none
- /* if (drp_track2Audio.Text != "None")
- {
- audMix.Enabled = true;
- audbit.Enabled = true;
- audsr.Enabled = true;
-
- audMix.Text = "Automatic";
- audbit.Text = "160";
- audsr.Text = "Auto";
- }*/
- }
- }
#endregion
#region Public Methods
@@ -1953,14 +1900,13 @@ namespace Handbrake /// 1 = Encode Running
/// 0 = Encode Finished.
/// </summary>
- /// <param name="i">Int</param>
public void setEncodeFinished()
{
try
{
- if (this.InvokeRequired)
+ if (InvokeRequired)
{
- this.BeginInvoke(new UpdateWindowHandler(setEncodeFinished));
+ BeginInvoke(new UpdateWindowHandler(setEncodeFinished));
return;
}
@@ -1975,7 +1921,6 @@ namespace Handbrake notifyIcon.BalloonTipText = lbl_encode.Text;
notifyIcon.ShowBalloonTip(500);
}
-
}
catch (Exception exc)
{
@@ -1986,9 +1931,9 @@ namespace Handbrake {
try
{
- if (this.InvokeRequired)
+ if (InvokeRequired)
{
- this.BeginInvoke(new UpdateWindowHandler(setEncodeStarted));
+ BeginInvoke(new UpdateWindowHandler(setEncodeStarted));
return;
}
@@ -2033,13 +1978,13 @@ namespace Handbrake treeView_presets.Nodes.Clear();
- List<Presets.Preset> presetNameList = new List<Presets.Preset>();
- List<string> presetNames = new List<string>();
- TreeNode preset_treeview = new TreeNode();
+ List<Presets.Preset> presetNameList;
+ List<string> presetNames;
+ TreeNode preset_treeview;
TreeNode rootNode = new TreeNode();
TreeNode rootNodeTwo = new TreeNode();
- TreeNode childNode = new TreeNode();
+ TreeNode childNode;
int workingLevel = 0;
string previousCategory = String.Empty;
string currentCategory = String.Empty;
diff --git a/win/C#/frmOptions.cs b/win/C#/frmOptions.cs index dae22fe18..e56dbe79e 100644 --- a/win/C#/frmOptions.cs +++ b/win/C#/frmOptions.cs @@ -205,7 +205,7 @@ namespace Handbrake private void check_saveLogWithVideo_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.saveLogWithVideo = check_saveLogWithVideo.CheckState.ToString();
- if (check_saveLogWithVideo.Checked == true)
+ if (check_saveLogWithVideo.Checked)
text_logPath.Text = "";
}
diff --git a/win/C#/frmPreview.cs b/win/C#/frmPreview.cs index e00bcd976..029ac85d2 100644 --- a/win/C#/frmPreview.cs +++ b/win/C#/frmPreview.cs @@ -28,8 +28,7 @@ namespace Handbrake private void play()
{
- player = new Thread(OpenMovie);
- player.IsBackground = true;
+ player = new Thread(OpenMovie) {IsBackground = true};
player.Start();
}
@@ -38,9 +37,9 @@ namespace Handbrake {
try
{
- if (this.InvokeRequired)
+ if (InvokeRequired)
{
- this.BeginInvoke(new UpdateUIHandler(OpenMovie));
+ BeginInvoke(new UpdateUIHandler(OpenMovie));
return;
}
QTControl.URL = currently_playing;
@@ -59,11 +58,11 @@ namespace Handbrake catch (COMException ex)
{
QTUtils qtu = new QTUtils();
- MessageBox.Show("Unable to open movie:\n\nError Code: " + ex.ErrorCode.ToString("X") + "\nQT Error code : " + qtu.QTErrorFromErrorCode(ex.ErrorCode).ToString());
+ MessageBox.Show("Unable to open movie:\n\nError Code: " + ex.ErrorCode.ToString("X") + "\nQT Error code : " + qtu.QTErrorFromErrorCode(ex.ErrorCode));
}
catch (Exception ex)
{
- MessageBox.Show("Unable to open movie:\n\n" + ex.ToString());
+ MessageBox.Show("Unable to open movie:\n\n" + ex);
}
}
@@ -92,9 +91,9 @@ namespace Handbrake {
try
{
- if (this.InvokeRequired)
+ if (InvokeRequired)
{
- this.BeginInvoke(new UpdateUIHandler(encodeCompleted));
+ BeginInvoke(new UpdateUIHandler(encodeCompleted));
return;
}
btn_encode.Enabled = true;
@@ -108,7 +107,7 @@ namespace Handbrake }
catch (Exception exc)
{
- MessageBox.Show("frmPreview.cs encodeCompleted " + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ MessageBox.Show("frmPreview.cs encodeCompleted " + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
#endregion
diff --git a/win/C#/frmQueue.cs b/win/C#/frmQueue.cs index 1a9f30c7b..36e8b067e 100644 --- a/win/C#/frmQueue.cs +++ b/win/C#/frmQueue.cs @@ -45,7 +45,6 @@ namespace Handbrake /// <summary>
/// Initializes the Queue list with the Arraylist from the Queue class
/// </summary>
- /// <param name="qw"></param>
public void setQueue()
{
updateUIElements();
@@ -54,7 +53,7 @@ namespace Handbrake // Start and Stop Controls
private void btn_encode_Click(object sender, EventArgs e)
{
- if (queue.isPaused == true)
+ if (queue.isPaused)
{
setUIEncodeStarted();
MessageBox.Show("Encoding restarted", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
@@ -75,9 +74,9 @@ namespace Handbrake // Window Display Management
private void setUIEncodeStarted()
{
- if (this.InvokeRequired)
+ if (InvokeRequired)
{
- this.BeginInvoke(new UpdateHandler(setUIEncodeStarted));
+ BeginInvoke(new UpdateHandler(setUIEncodeStarted));
return;
}
btn_encode.Enabled = false;
@@ -85,9 +84,9 @@ namespace Handbrake }
private void setUIEncodeFinished()
{
- if (this.InvokeRequired)
+ if (InvokeRequired)
{
- this.BeginInvoke(new UpdateHandler(setUIEncodeFinished));
+ BeginInvoke(new UpdateHandler(setUIEncodeFinished));
return;
}
btn_pause.Visible = false;
@@ -95,9 +94,9 @@ namespace Handbrake }
private void resetQueue()
{
- if (this.InvokeRequired)
+ if (InvokeRequired)
{
- this.BeginInvoke(new UpdateHandler(resetQueue));
+ BeginInvoke(new UpdateHandler(resetQueue));
return;
}
btn_pause.Visible = false;
@@ -114,9 +113,9 @@ namespace Handbrake }
private void redrawQueue()
{
- if (this.InvokeRequired)
+ if (InvokeRequired)
{
- this.BeginInvoke(new UpdateHandler(redrawQueue));
+ BeginInvoke(new UpdateHandler(redrawQueue));
return;
}
@@ -128,14 +127,10 @@ namespace Handbrake Functions.QueryParser parsed = Functions.QueryParser.Parse(q_item);
// Get the DVD Title
- string title = "";
- if (parsed.DVDTitle == 0)
- title = "Auto";
- else
- title = parsed.DVDTitle.ToString();
+ string title = parsed.DVDTitle == 0 ? "Auto" : parsed.DVDTitle.ToString();
// Get the DVD Chapters
- string chapters = "";
+ string chapters;
if (parsed.DVDChapterStart == 0)
chapters = "Auto";
else
@@ -158,9 +153,9 @@ namespace Handbrake }
private void updateUIElements()
{
- if (this.InvokeRequired)
+ if (InvokeRequired)
{
- this.BeginInvoke(new UpdateHandler(updateUIElements));
+ BeginInvoke(new UpdateHandler(updateUIElements));
return;
}
@@ -171,9 +166,9 @@ namespace Handbrake {
try
{
- if (this.InvokeRequired)
+ if (InvokeRequired)
{
- this.BeginInvoke(new UpdateHandler(setCurrentEncodeInformation));
+ BeginInvoke(new UpdateHandler(setCurrentEncodeInformation));
}
// found query is a global varible
@@ -181,19 +176,13 @@ namespace Handbrake lbl_source.Text = queue.getLastQueryItem().Source;
lbl_dest.Text = queue.getLastQueryItem().Destination;
- if (parsed.DVDTitle == 0)
- lbl_title.Text = "Auto";
- else
- lbl_title.Text = parsed.DVDTitle.ToString();
+ lbl_title.Text = parsed.DVDTitle == 0 ? "Auto" : parsed.DVDTitle.ToString();
- string chapters = "";
- if (parsed.DVDChapterStart == 0)
- {
- lbl_chapt.Text = "Auto";
- }
+ if (Equals(parsed.DVDChapterStart, 0))
+ lbl_chapt.Text = "Auto";
else
{
- chapters = parsed.DVDChapterStart.ToString();
+ string chapters = parsed.DVDChapterStart.ToString();
if (parsed.DVDChapterFinish != 0)
chapters = chapters + " - " + parsed.DVDChapterFinish;
lbl_chapt.Text = chapters;
|