fix issue with clipboard url detection

This commit is contained in:
Frank Skare
2019-09-28 04:01:10 +02:00
parent 6947c925b9
commit 8935101058
7 changed files with 20 additions and 21 deletions

View File

@@ -176,7 +176,7 @@ namespace mpvnet
$"{width} x {height}\n";
if (fileSize > 0)
text += Convert.ToInt32(fileSize / 1024.0 / 1024.0).ToString() + " MB\n";
text += Convert.ToInt32(fileSize / 1024.0 / 1024.0) + " MB\n";
text += $"{videoFormat}\n{audioCodec}";

View File

@@ -50,23 +50,23 @@ public class Msg
td.Show();
}
}
catch (Exception ex)
catch (Exception e)
{
MessageBox.Show(ex.GetType().Name + "\n\n" + ex.Message + "\n\n" + ex.ToString(),
MessageBox.Show(e.GetType().Name + "\n\n" + e.Message + "\n\n" + e,
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
public static void ShowException(Exception e)
public static void ShowException(Exception exception)
{
try
{
using (TaskDialog<string> td = new TaskDialog<string>())
{
td.MainInstruction = e.GetType().Name;
td.Content = e.Message;
td.MainInstruction = exception.GetType().Name;
td.Content = exception.Message;
td.MainIcon = MsgIcon.Error;
td.ExpandedInformation = e.ToString();
td.ExpandedInformation = exception.ToString();
td.Footer = "[Copy Message](copymsg)";
if (!string.IsNullOrEmpty(Msg.SupportURL))
@@ -75,9 +75,9 @@ public class Msg
td.Show();
}
}
catch (Exception ex)
catch (Exception e)
{
MessageBox.Show(ex.GetType().Name + "\n\n" + ex.Message + "\n\n" + ex.ToString(),
MessageBox.Show(e.GetType().Name + "\n\n" + e.Message + "\n\n" + e,
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
@@ -144,9 +144,9 @@ public class Msg
return td.Show();
}
}
catch (Exception ex)
catch (Exception e)
{
return (MsgResult)MessageBox.Show(ex.GetType().Name + "\n\n" + ex.Message + "\n\n" + ex.ToString(),
return (MsgResult)MessageBox.Show(e.GetType().Name + "\n\n" + e.Message + "\n\n" + e,
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
@@ -235,6 +235,7 @@ public class TaskDialog<T> : TaskDialogNative, IDisposable
if (Path.GetFileName(lpszFileName.ToString().Replace(".vshost", "")) ==
Path.GetFileName(Assembly.GetEntryAssembly().Location))
return foregroundWindow;
return IntPtr.Zero;

View File

@@ -200,8 +200,7 @@ namespace mpvnet
private void FilterListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count > 0)
SearchControl.Text = e.AddedItems[0].ToString() + ":"; // TODO: remove ToString()
if (e.AddedItems.Count > 0) SearchControl.Text = e.AddedItems[0] + ":";
}
private void OpenSettingsTextBlock_MouseUp(object sender, MouseButtonEventArgs e)

View File

@@ -44,7 +44,7 @@ namespace mpvnet
} catch {}
for (int i = 0; i < 13; i++)
if ("D" + i.ToString() == text)
if ("D" + i == text)
text = text.Substring(1);
switch (e.KeyCode)
@@ -59,7 +59,7 @@ namespace mpvnet
case WF.Keys.NumPad7:
case WF.Keys.NumPad8:
case WF.Keys.NumPad9:
text = "KP" + e.KeyCode.ToString()[6].ToString(); break;
text = "KP" + e.KeyCode.ToString()[6]; break;
case WF.Keys.Space:
text = "Space"; break;
case WF.Keys.Enter:

View File

@@ -571,7 +571,6 @@ namespace mpvnet
ContextMenuStrip = ContextMenu;
WPF.WPF.Init();
System.Windows.Application.Current.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;
CheckClipboardForURL();
Cursor.Position = new Point(Cursor.Position.X + 1, Cursor.Position.Y);
WasShown = true;
mp.LoadScripts();
@@ -660,10 +659,11 @@ namespace mpvnet
!clipboard.Contains(" ") && clipboard.Contains(url.ToLower().Trim()) &&
RegHelp.GetString(App.RegPath, "LastURL") != clipboard && Visible)
{
RegHelp.SetObject(App.RegPath, "LastURL", clipboard);
if (Msg.ShowQuestion("Play URL?", clipboard) == MsgResult.OK)
mp.Load(new[] { clipboard }, true, Control.ModifierKeys.HasFlag(Keys.Control));
RegHelp.SetObject(App.RegPath, "LastURL", clipboard);
break;
}
}
}

View File

@@ -631,7 +631,6 @@ namespace mpvnet
i.Contains(":\\") || i.StartsWith("\\\\") || File.Exists(i)))
{
files.Add(i);
if (i.Contains("://")) RegHelp.SetObject(App.RegPath, "LastURL", i);
}
}