Here are the examples of the csharp api System.Windows.MessageBox.Show(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1091 Examples
19
Source : ServerMaster.cs
with Apache License 2.0
from AlexWan
with Apache License 2.0
from AlexWan
private static void SendNewLogMessage(string message, LogMessageType type)
{
if (LogMessageEvent != null)
{
LogMessageEvent(message, type);
}
else if (type == LogMessageType.Error)
{ // if nobody is subscribled to us and there is a log error / если на нас никто не подписан и в логе ошибка
MessageBox.Show(message);
}
}
19
Source : MainWindow.xaml.cs
with Apache License 2.0
from AlexWan
with Apache License 2.0
from AlexWan
private void AddClient()
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
fbd.SelectedPath = _lastPathToFolder;
if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
_lastPathToFolder = fbd.SelectedPath;
var info = Directory.GetFiles(_lastPathToFolder);
var needFile = info.FirstOrDefault(p => p.EndsWith("OsEngine.exe"));
if (needFile == null)
{
MessageBox.Show("В выбранном каталоге не обнаружен OsEngine.exe");
return;
}
if (Engines.FirstOrDefault(o=>o.Path == needFile) != null)
{
MessageBox.Show("OsEngine с таким путем уже добавлен");
return;
}
var os = new OsEngine(needFile);
os.State = State.Off;
os.ProcessId = _manager.GetProcessIdByPath(_lastPathToFolder);
Engines.Add(os);
}
Save();
}
19
Source : OptimizerReportUi.xaml.cs
with Apache License 2.0
from AlexWan
with Apache License 2.0
from AlexWan
private void ButtonSaveInFile_Click(object sender, RoutedEventArgs e)
{
try
{
SaveFileDialog myDialog = new SaveFileDialog();
string saveFileName = _master.StrategyName;
if(_master.TabsSimpleNamesAndTimeFrames != null && _master.TabsSimpleNamesAndTimeFrames.Count != 0)
{
saveFileName += "_" + _master.TabsSimpleNamesAndTimeFrames[0].NameSecurity;
saveFileName += "_" + _master.TabsSimpleNamesAndTimeFrames[0].TimeFrame;
}
IIStrategyParameter regime = _master._optimizerExecutor._parameters.Find(p => p.Name == "Regime");
if(regime != null)
{
saveFileName += "_" + ((StrategyParameterString)regime).ValueString;
}
saveFileName = saveFileName.Replace(".txt", "");
myDialog.FileName = saveFileName;
myDialog.Filter = "*.txt|";
myDialog.ShowDialog();
if (string.IsNullOrEmpty(myDialog.FileName))
{
System.Windows.Forms.MessageBox.Show(OsLocalization.Journal.Message1);
return;
}
string fileName = myDialog.FileName;
if (fileName.Split('.').Length == 1)
{
fileName = fileName + ".txt";
}
string saveStr = "";
for (int i = 0; i < _reports.Count; i++)
{
saveStr += _reports[i].GetSaveString() + "\r\n";
}
StreamWriter writer = new StreamWriter(fileName);
writer.Write(saveStr);
writer.Close();
}
catch (Exception error)
{
MessageBox.Show(error.ToString());
}
}
19
Source : OptimizerReportUi.xaml.cs
with Apache License 2.0
from AlexWan
with Apache License 2.0
from AlexWan
private void ButtonLoadFromFile_Click(object sender, RoutedEventArgs e)
{
try
{
OpenFileDialog myDialog = new OpenFileDialog();
myDialog.Filter = "*.txt|";
myDialog.ShowDialog();
if (string.IsNullOrEmpty(myDialog.FileName))
{
System.Windows.Forms.MessageBox.Show(OsLocalization.Journal.Message2);
return;
}
if (_reports == null)
{
_reports = new List<OptimazerFazeReport>();
}
else
{
_reports.Clear();
}
using (StreamReader reader = new StreamReader(myDialog.FileName))
{
while (reader.EndOfStream == false)
{
string str = reader.ReadLine();
if (string.IsNullOrEmpty(str))
{
continue;
}
OptimazerFazeReport newReport = new OptimazerFazeReport();
newReport.LoadFromString(str);
_reports.Add(newReport);
}
}
RepaintResults();
}
catch (Exception error)
{
MessageBox.Show(error.ToString());
}
}
19
Source : OsTraderMaster.cs
with Apache License 2.0
from AlexWan
with Apache License 2.0
from AlexWan
public void SendNewLogMessage(string message, LogMessageType type)
{
if (LogMessageEvent != null)
{
LogMessageEvent(message, type);
}
else if (type == LogMessageType.Error)
{
MessageBox.Show(message);
}
}
19
Source : Helpers.cs
with MIT License
from Alkl58
with MIT License
from Alkl58
public static void Check_Unicode(string file_name)
{
// This function checks if the provided video file has compatible unicode characters in the filename
// Reference: codesnippets.fesslersoft.de/how-to-check-if-a-string-is-unicode-in-c-and-vb-net/
int asciiBytesCount = Encoding.ASCII.GetByteCount(file_name);
int unicodBytesCount = Encoding.UTF8.GetByteCount(file_name);
if (asciiBytesCount != unicodBytesCount)
{
MessageBox.Show("The filename contains non unicode characters.\n\nPlease rename your file before proceeding to guarantee a successful encode!");
}
}
19
Source : AudioEncode.cs
with MIT License
from Alkl58
with MIT License
from Alkl58
public static void EncodeAudio(string videoInput, bool logging, string audioBitrate, string audioCodec, string currentPath, string ffmpegPath, bool trackone, bool tracktwo, bool trackthree, bool trackfour)
{
if (logging == true)
{
SmallScripts.WriteToFileThreadSafe(DateTime.Now.ToString("h:mm:ss tt") + " Audio Encoding started", "log.log");
}
string allAudioSettings = "";
//Sets Settings for Audio Encoding
if (audioCodec == "Copy Audio")
{
if (logging == true)
{
SmallScripts.WriteToFileThreadSafe(DateTime.Now.ToString("h:mm:ss tt") + " Audio Encoding Setting Encode Mode to Audio Copy", "log.log");
}
allAudioSettings = " -c:a copy";
}
else if (audioCodec == "Opus")
{
if (logging == true)
{
SmallScripts.WriteToFileThreadSafe(DateTime.Now.ToString("h:mm:ss tt") + " Audio Encoding Setting Encode Mode to libopus", "log.log");
}
allAudioSettings = " -c:a libopus -b:a " + audioBitrate + "k ";
}
else if (audioCodec == "Opus 5.1")
{
if (logging == true)
{
SmallScripts.WriteToFileThreadSafe(DateTime.Now.ToString("h:mm:ss tt") + " Audio Encoding Setting Encode Mode to libopus 5.1", "log.log");
}
allAudioSettings = " -c:a libopus -b:a " + audioBitrate + "k -af channelmap=channel_layout=5.1";
}
else if (audioCodec == "AAC CBR")
{
if (logging == true)
{
SmallScripts.WriteToFileThreadSafe(DateTime.Now.ToString("h:mm:ss tt") + " Audio Encoding Setting Encode Mode to AAC CBR", "log.log");
}
allAudioSettings = " -c:a aac -b:a " + audioBitrate + "k ";
}
else if (audioCodec == "AC3")
{
if (logging == true)
{
SmallScripts.WriteToFileThreadSafe(DateTime.Now.ToString("h:mm:ss tt") + " Audio Encoding Setting Encode Mode to AC3 CBR", "log.log");
}
allAudioSettings = " -c:a ac3 -b:a " + audioBitrate + "k ";
}
else if (audioCodec == "FLAC")
{
if (logging == true)
{
SmallScripts.WriteToFileThreadSafe(DateTime.Now.ToString("h:mm:ss tt") + " Audio Encoding Setting Encode Mode to FLAC", "log.log");
}
allAudioSettings = " -c:a flac ";
}
else if (audioCodec == "MP3 CBR")
{
if (logging == true)
{
SmallScripts.WriteToFileThreadSafe(DateTime.Now.ToString("h:mm:ss tt") + " Audio Encoding Setting Encode Mode to MP3 CBR", "log.log");
}
allAudioSettings = " -c:a libmp3lame -b:a " + audioBitrate + "k ";
}
else if (audioCodec == "MP3 VBR")
{
if (logging == true)
{
SmallScripts.WriteToFileThreadSafe(DateTime.Now.ToString("h:mm:ss tt") + " Audio Encoding Setting Encode Mode to MP3 CBR", "log.log");
}
if (Int16.Parse(audioBitrate) >= 10)
{
MessageBox.Show("Audio VBR Range is from 0-9");
}
else if (Int16.Parse(audioBitrate) <= 10)
{
allAudioSettings = " -c:a libmp3lame -q:a " + audioBitrate + " ";
}
}
else if (audioCodec == "Opus Downmix")
{
if (logging == true)
{
SmallScripts.WriteToFileThreadSafe(DateTime.Now.ToString("h:mm:ss tt") + " Audio Encoding Setting Encode Mode to Opus Downmix", "log.log");
}
allAudioSettings = " -c:a libopus -b:a " + audioBitrate + "k -ac 2";
}
//Creates Audio Folder
if (!Directory.Exists(Path.Combine(currentPath, "AudioExtracted")))
Directory.CreateDirectory(Path.Combine(currentPath, "AudioExtracted"));
if (!Directory.Exists(Path.Combine(currentPath, "AudioEncoded")))
Directory.CreateDirectory(Path.Combine(currentPath, "AudioEncoded"));
Process process = new Process();
//Starts extracting maximal 4 Audio Streams
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.WorkingDirectory = ffmpegPath;
startInfo.FileName = "cmd.exe";
if (trackone == true && tracktwo == true && trackthree == true && trackfour == true)
{
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:0 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:1 " + '\u0022' + currentPath + "\\AudioExtracted\\audio1.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:2 " + '\u0022' + currentPath + "\\AudioExtracted\\audio2.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:3 " + '\u0022' + currentPath + "\\AudioExtracted\\audio3.mkv" + '\u0022';
}
//Only One out of Four Tracks
//1st Track
if (trackone == true && tracktwo == false && trackthree == false && trackfour == false)
{
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:0 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022';
}
//2nd Track
if (trackone == false && tracktwo == true && trackthree == false && trackfour == false)
{
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:1 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022';
}
//3rd Track
if (trackone == false && tracktwo == false && trackthree == true && trackfour == false)
{
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:2 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022';
}
//4th Track
if (trackone == false && tracktwo == false && trackthree == false && trackfour == true)
{
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:3 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022';
}
//Two out of Four Tracks
//1st & 2nd // //
if (trackone == true && tracktwo == true && trackthree == false && trackfour == false)
{
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:0 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:1 " + '\u0022' + currentPath + "\\AudioExtracted\\audio1.mkv" + '\u0022';
}
//1st & 3rd // //
if (trackone == true && tracktwo == false && trackthree == true && trackfour == false)
{
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:0 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:2 " + '\u0022' + currentPath + "\\AudioExtracted\\audio1.mkv" + '\u0022';
}
//1st & 4th // //
if (trackone == true && tracktwo == false && trackthree == false && trackfour == true)
{
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:0 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:3 " + '\u0022' + currentPath + "\\AudioExtracted\\audio1.mkv" + '\u0022';
}
//2nd & 3rd // //
if (trackone == false && tracktwo == true && trackthree == true && trackfour == false)
{
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:1 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:2 " + '\u0022' + currentPath + "\\AudioExtracted\\audio1.mkv" + '\u0022';
}
//2nd & 4th // //
if (trackone == false && tracktwo == true && trackthree == false && trackfour == true)
{
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:1 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:3 " + '\u0022' + currentPath + "\\AudioExtracted\\audio1.mkv" + '\u0022';
}
//3rd & 4th // //
if (trackone == false && tracktwo == false && trackthree == true && trackfour == true)
{
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:2 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:3 " + '\u0022' + currentPath + "\\AudioExtracted\\audio1.mkv" + '\u0022';
}
//Three out of Four Tracks
//1st & 2nd & 3rd // // //
if (trackone == true && tracktwo == true && trackthree == true && trackfour == false)
{
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:0 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:1 " + '\u0022' + currentPath + "\\AudioExtracted\\audio1.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:2 " + '\u0022' + currentPath + "\\AudioExtracted\\audio2.mkv" + '\u0022';
}
//1st & 2nd & 4th // // //
if (trackone == true && tracktwo == true && trackthree == false && trackfour == true)
{
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:0 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:1 " + '\u0022' + currentPath + "\\AudioExtracted\\audio1.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:3 " + '\u0022' + currentPath + "\\AudioExtracted\\audio2.mkv" + '\u0022';
}
//1st & 3rd & 4th // // //
if (trackone == true && tracktwo == false && trackthree == true && trackfour == true)
{
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:0 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:2 " + '\u0022' + currentPath + "\\AudioExtracted\\audio1.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:3 " + '\u0022' + currentPath + "\\AudioExtracted\\audio2.mkv" + '\u0022';
}
//2nd & 3rd & 4th // // //
if (trackone == false && tracktwo == true && trackthree == true && trackfour == true)
{
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:1 " + '\u0022' + currentPath + "\\AudioExtracted\\audio0.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:2 " + '\u0022' + currentPath + "\\AudioExtracted\\audio1.mkv" + '\u0022' + " & ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vn -map_metadata -1 -c copy -map 0:a:3 " + '\u0022' + currentPath + "\\AudioExtracted\\audio2.mkv" + '\u0022';
}
Console.WriteLine(startInfo.Arguments);
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();
Console.WriteLine(currentPath + "\\AudioExtracted");
DirectoryInfo AudioExtracted = new DirectoryInfo(currentPath + "\\AudioExtracted");
//Loops through all mkv files in AudioExtracted
foreach (var file in AudioExtracted.GetFiles("*.mkv"))
{
//Directory.Move(file.FullName, filepath + "\\TextFiles\\" + file.Name);
//Get the Filesize, because the command above also creates mkv files even if there is not audiostream (filesize = 0)
long length = new FileInfo(currentPath +"\\AudioExtracted\\" + file).Length;
//Console.WriteLine(length);
//If Filesize = 0 -> delete file
if (length == 0)
{
File.Delete(currentPath + "\\AudioExtracted\\" + file);
}
else if (length > 1)
{
//Encodes the Audio to the given format
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.WorkingDirectory = ffmpegPath;
startInfo.Arguments = "/C ffmpeg.exe -i " + '\u0022' + currentPath + "\\AudioExtracted\\" + file + '\u0022' + " " + allAudioSettings + "-vn " + '\u0022' + currentPath + "\\AudioEncoded\\" + file + '\u0022';
Console.WriteLine(startInfo.Arguments);
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();
}
}
//Counts the number of AudioFiles
int audioCount = Directory.GetFiles(currentPath + "\\AudioEncoded", "*mkv", SearchOption.TopDirectoryOnly).Length;
//Sets the number of AudioTracks of the concat process
MainWindow.SetNumberOfAudioTracks(audioCount);
}
19
Source : Settings.xaml.cs
with MIT License
from Alkl58
with MIT License
from Alkl58
private void Button_aomenc_Click(object sender, RoutedEventArgs e)
{
if (CheckBoxAomencFolder.IsChecked == true)
{
System.Windows.Forms.FolderBrowserDialog browse = new System.Windows.Forms.FolderBrowserDialog();
if (browse.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
TextBoxAomenc.Text = browse.SelectedPath;
bool fileExist = File.Exists(TextBoxAomenc.Text + "\\aomenc.exe");
if (fileExist != true)
{
MessageBox.Show("Couldn't find aomenc in the directory!");
}
}
}
}
19
Source : Settings.xaml.cs
with MIT License
from Alkl58
with MIT License
from Alkl58
private void ButtonFfprobe_Click(object sender, RoutedEventArgs e)
{
if (CheckBoxFfprobeFolder.IsChecked == true)
{
System.Windows.Forms.FolderBrowserDialog browse = new System.Windows.Forms.FolderBrowserDialog();
if (browse.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
TextBoxFfprobe.Text = browse.SelectedPath;
bool fileExist = File.Exists(TextBoxFfprobe.Text + "\\ffprobe.exe");
if (fileExist != true)
{
MessageBox.Show("Couldn't find ffprobe in the directory!");
}
}
}
}
19
Source : Settings.xaml.cs
with MIT License
from Alkl58
with MIT License
from Alkl58
private void ButtonFfmpeg_Click(object sender, RoutedEventArgs e)
{
if (CheckBoxFfmpegFolder.IsChecked == true)
{
System.Windows.Forms.FolderBrowserDialog browse = new System.Windows.Forms.FolderBrowserDialog();
if (browse.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
TextBoxFfmpeg.Text = browse.SelectedPath;
bool fileExist = File.Exists(TextBoxFfmpeg.Text + "\\ffmpeg.exe");
if (fileExist != true)
{
MessageBox.Show("Couldn't find ffmpeg in the directory!");
}
}
}
}
19
Source : SmallScripts.cs
with MIT License
from Alkl58
with MIT License
from Alkl58
public static void CheckDependencies()
{
bool aomencExist = false;
bool ffmpegExist = false;
bool ffprobeExist = false;
if (MainWindow.customAomencPathActive == true)
{
aomencExist = File.Exists(MainWindow.customAomencPath+"\\aomenc.exe");
}else if (MainWindow.customAomencPathActive == false)
{
aomencExist = File.Exists("aomenc.exe");
}
if (MainWindow.customFfmpegPathActive == true)
{
ffmpegExist = File.Exists(MainWindow.customFfmpegPath+"\\ffmpeg.exe");
}else if (MainWindow.customFfmpegPathActive == false)
{
ffmpegExist = File.Exists("ffmpeg.exe");
}
if (MainWindow.customFfprobePathActive == true)
{
ffprobeExist = File.Exists(MainWindow.customFfprobePath + "\\ffprobe.exe");
}else if (MainWindow.customFfprobePathActive == false)
{
ffprobeExist = File.Exists("ffprobe.exe");
}
if (aomencExist == false || ffmpegExist == false || ffprobeExist == false)
{
MessageBox.Show("Couldn't find all depedencies: \n aomenc found: " + aomencExist + "\n ffmpeg found: " + ffmpegExist + " \n ffprobe found: " + ffprobeExist);
}
}
19
Source : HelloButton.xaml.cs
with MIT License
from alvpickmans
with MIT License
from alvpickmans
private void btnHello_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("Hello there!");
}
19
Source : HelloUINodeView.cs
with MIT License
from alvpickmans
with MIT License
from alvpickmans
private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
MessageBox.Show("Hello there!");
}
19
Source : OpenFileViewModel.cs
with GNU General Public License v3.0
from AndreiFedarets
with GNU General Public License v3.0
from AndreiFedarets
internal void OpenFileSystemInfo(string path)
{
if (string.IsNullOrWhiteSpace(path))
{
return;
}
object fileSystemInfo;
if (_accessor.DirectoryExists(path))
{
fileSystemInfo = _accessor.GetDirectory(path);
}
else if (_accessor.FileExists(path))
{
fileSystemInfo = _accessor.GetFile(path);
}
else
{
string errorMessage = string.Format("Path '{0}' does not exists", path);
MessageBox.Show(errorMessage);
return;
}
OpenFileSystemInfo(fileSystemInfo);
}
19
Source : ExceptionReporter.cs
with GNU General Public License v3.0
from AndreiFedarets
with GNU General Public License v3.0
from AndreiFedarets
public static void ShowError(Exception exception)
{
MessageBox.Show(exception.ToString());
}
19
Source : AboutViewModel.cs
with MIT License
from andydandy74
with MIT License
from andydandy74
private void ZoomToNode(string guid)
{
try
{
// Clear current selection and select our node
foreach (var item in readyParams.CurrentWorkspaceModel.CurrentSelection)
{
item.Deselect();
}
var node = readyParams.CurrentWorkspaceModel.Nodes.First(x => x.GUID.ToString() == guid);
node.Select();
// Get the node center
var nodeX = node.CenterX;
var nodeY = node.CenterY;
/*
// How do we set the workspace center?
viewModel.Model.CurrentWorkspace.X = nodeX;
viewModel.Model.CurrentWorkspace.Y = nodeY;
viewModel.Model.CurrentWorkspace.Zoom = 2;
// Zoom in
// How do we zoom in?
// var currentZoom = viewModel.Model.CurrentWorkspace.Zoom;
// viewModel.CurrentSpaceViewModel.SetZoomCommand.Execute(2);
// Just for testing*/
// viewModel.CurrentSpaceViewModel.ResetFitViewToggleCommand.Execute(null);*/
MessageBox.Show(nodeX.ToString() + " - " + nodeY.ToString() + " - ");
// Deselect node since somehow it can only be deselected programmatically
node.Deselect();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
19
Source : Monito.cs
with MIT License
from andydandy74
with MIT License
from andydandy74
public void Loaded(ViewLoadedParams p)
{
var monitoMenuItem = new MenuItem { Header = "DynaMonito" };
var VM = p.DynamoWindow.DataContext as DynamoViewModel;
MenuItem subMenuItem;
#region FIND_UNGROUPED
if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnableFindUngrouped"))
{
subMenuItem = new MenuItem { Header = "Find and Fix Ungrouped" };
subMenuItem.ToolTip = new ToolTip { Content = "Identify nodes and notes that don't belong to a group.." };
subMenuItem.Click += (sender, args) =>
{
var viewModel = new FindUngroupedViewModel(p, VM);
var window = new FindUngroupedWindow
{
findUngroupedPanel = { DataContext = viewModel },
Owner = p.DynamoWindow
};
window.Left = window.Owner.Left + 400;
window.Top = window.Owner.Top + 200;
window.Show();
};
monitoMenuItem.Items.Add(subMenuItem);
}
#endregion FIND_UNGROUPED
#region ISOLATE_IN_GEOMETRY_PREVIEW
if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnableIsolateInGeometryPreview"))
{
subMenuItem = new MenuItem { Header = "Isolate in Geometry Preview" };
subMenuItem.ToolTip = new ToolTip { Content = "Quickly isolate the current selection in geometry preview..." };
subMenuItem.Click += (sender, args) =>
{
var viewModel = new IsolateInPreviewViewModel(p, VM, p.DynamoWindow);
var window = new IsolateInPreviewWindow
{
isolatePreviewPanel = { DataContext = viewModel },
Owner = p.DynamoWindow
};
window.Left = window.Owner.Left + 400;
window.Top = window.Owner.Top + 200;
window.Show();
};
monitoMenuItem.Items.Add(subMenuItem);
}
#endregion ISOLATE_IN_GEOMETRY_PREVIEW
#region PLAYER_INPUTS
if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnablePlayerInputs"))
{
subMenuItem = new MenuItem { Header = "Manage Dynamo Player Inputs" };
subMenuItem.ToolTip = new ToolTip { Content = "Manage which input nodes should be displayed by Dynamo Player..." };
subMenuItem.Click += (sender, args) =>
{
var viewModel = new PlayerInputsViewModel(p, VM);
var window = new PlayerInputsWindow
{
playerInputsPanel = { DataContext = viewModel },
Owner = p.DynamoWindow
};
window.Left = window.Owner.Left + 400;
window.Top = window.Owner.Top + 200;
window.Show();
};
monitoMenuItem.Items.Add(subMenuItem);
}
#endregion PLAYER INPUTS
#region MY_GRAPHS
if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnableMyGraphs"))
{
// Read list of graph directories from config
var topDirs = monitoSettings["MyGraphsDirectoryPaths"].Value.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
if (topDirs.Length > 0)
{
subMenuItem = new MenuItem { Header = "My Graphs" };
subMenuItem.ToolTip = new ToolTip { Content = "Quick access to all your graphs..." };
if (topDirs.Length == 1)
{
subMenuItem = BuildMyGraphsMenu(topDirs[0], subMenuItem, VM);
}
else
{
foreach(string topDir in topDirs)
{
string topDirName = Path.GetFileName(topDir);
MenuItem topDirMenuItem = new MenuItem { Header = topDirName };
topDirMenuItem.ToolTip = new ToolTip { Content = topDir };
topDirMenuItem = BuildMyGraphsMenu(topDir, topDirMenuItem, VM);
subMenuItem.Items.Add(topDirMenuItem);
}
}
if (subMenuItem != null) { monitoMenuItem.Items.Add(subMenuItem); }
}
}
#endregion MY_GRAPHS
#region MY_TEMPLATES
if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnableMyTemplates"))
{
var tplDir = monitoSettings["MyTemplatesDirectoryPath"].Value;
if (Directory.Exists(tplDir))
{
// Create a menu item for each template
List<MenuItem> tempMenuItems = new List<MenuItem>();
var templates = Directory.GetFiles(tplDir, "*.dyn");
foreach (string t in templates)
{
string tplName = Path.GetFileNameWithoutExtension(t);
MenuItem tplMenu = new MenuItem { Header = tplName };
tplMenu.ToolTip = new ToolTip { Content = t };
tplMenu.Click += (sender, args) =>
{
if (File.Exists(t))
{
// Close current home workspace, open template and set to manual mode
VM.CloseHomeWorkspaceCommand.Execute(null);
VM.OpenCommand.Execute(t);
VM.CurrentSpaceViewModel.RunSettingsViewModel.Model.RunType = RunType.Manual;
// Select all nodes and notes as well as annotations and copy everything
VM.SelectAllCommand.Execute(null);
foreach (var anno in VM.HomeSpaceViewModel.Model.Annotations) { VM.AddToSelectionCommand.Execute(anno); }
VM.CopyCommand.Execute(null);
// Create new home workspace, set to manual mode and paste template content
VM.NewHomeWorkspaceCommand.Execute(null);
VM.CurrentSpaceViewModel.RunSettingsViewModel.Model.RunType = RunType.Manual;
VM.Model.Paste();
GeneralUtils.ClearSelection();
VM.CurrentSpaceViewModel.ResetFitViewToggleCommand.Execute(null);
VM.FitViewCommand.Execute(null);
}
else { MessageBox.Show("Template " + tplName + " has been moved, renamed or deleted..."); }
};
tempMenuItems.Add(tplMenu);
}
// Only show the templates menu item if templates exist
if (tempMenuItems.Count > 0)
{
subMenuItem = new MenuItem { Header = "New Workspace from Template" };
subMenuItem.ToolTip = new ToolTip { Content = "Quick access to all your templates..." };
foreach (MenuItem tempMenuItem in tempMenuItems) { subMenuItem.Items.Add(tempMenuItem); }
monitoMenuItem.Items.Add(subMenuItem);
}
}
}
#endregion MY_TEMPLATES
#region PACKAGE_DIRECTORIES
if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnablePackageDirectories"))
{
subMenuItem = new MenuItem { Header = "Package Directories" };
subMenuItem.ToolTip = new ToolTip { Content = "Quick access to all your package directories..." };
foreach (string packageDir in startupParams.Preferences.CustomPackageFolders)
{
if (Directory.Exists(packageDir))
{
MenuItem monitoPackageDirMenuItem = new MenuItem { Header = packageDir };
monitoPackageDirMenuItem.ToolTip = new ToolTip { Content = "Show contents of " + packageDir + " ..." };
monitoPackageDirMenuItem.Click += (sender, args) =>
{
if (Directory.Exists(packageDir)) { Process.Start(@"" + packageDir); }
else { MessageBox.Show("Directory " + packageDir + " has been moved, renamed or deleted..."); }
};
subMenuItem.Items.Add(monitoPackageDirMenuItem);
}
}
monitoMenuItem.Items.Add(subMenuItem);
}
#endregion PACKAGE_DIRECTORIES
#region SEARCH_IN_WORKSPACE
if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnableSearchInWorkspace"))
{
subMenuItem = new MenuItem { Header = "Search in Workspace" };
subMenuItem.ToolTip = new ToolTip { Content = "Search for nodes, notes and groups in the current workspace..." };
subMenuItem.Click += (sender, args) =>
{
var viewModel = new SearchInWorkspaceViewModel(p, VM, monitoSettings);
var window = new SearchInWorkspaceWindow
{
searchPanel = { DataContext = viewModel },
Owner = p.DynamoWindow
};
window.Left = window.Owner.Left + 400;
window.Top = window.Owner.Top + 200;
window.Show();
};
monitoMenuItem.Items.Add(subMenuItem);
}
#endregion SEARCH_IN_WORKSPACE
#region UNFANCIFY
if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnableUnfancify"))
{
subMenuItem = new MenuItem { Header = "Unfancify" };
subMenuItem.ToolTip = new ToolTip { Content = "Simplify your graph..." };
subMenuItem.Click += (sender, args) =>
{
var viewModel = new UnfancifyViewModel(p, VM, monitoSettings, p.DynamoWindow);
var window = new UnfancifyWindow
{
unfancifyPanel = { DataContext = viewModel },
Owner = p.DynamoWindow
};
window.Left = window.Owner.Left + 400;
window.Top = window.Owner.Top + 200;
window.Show();
};
monitoMenuItem.Items.Add(subMenuItem);
}
#endregion UNFANCIFY
#region ABOUT
subMenuItem = new MenuItem { Header = "About DynaMonito" };
subMenuItem.Click += (sender, args) =>
{
var window = new AboutWindow
{
aboutPanel = { DataContext = this },
Owner = p.DynamoWindow
};
window.Left = window.Owner.Left + 400;
window.Top = window.Owner.Top + 200;
window.Show();
};
if (monitoMenuItem.Items.Count > 0) { monitoMenuItem.Items.Add(new Separator()); }
monitoMenuItem.Items.Add(subMenuItem);
#endregion ABOUT
p.dynamoMenu.Items.Add(monitoMenuItem);
}
19
Source : Monito.cs
with MIT License
from andydandy74
with MIT License
from andydandy74
public void Startup(ViewStartupParams p)
{
startupParams = p;
// Try loading the package config file
// We need this to determine which tools to load (and also settings for some of the tools)
string configPath = this.GetType().replacedembly.Location;
try
{
Configuration myDllConfig = ConfigurationManager.OpenExeConfiguration(configPath);
AppSettingsSection myDllConfigAppSettings = (AppSettingsSection)myDllConfig.GetSection("appSettings");
monitoSettings = myDllConfigAppSettings.Settings;
monitoSettingsLoaded = true;
}
catch { MessageBox.Show("Couldn't find, load or read DynaMonito config file at " + configPath); }
}
19
Source : Monito.cs
with MIT License
from andydandy74
with MIT License
from andydandy74
public MenuItem BuildMyGraphsMenu(string dir, MenuItem menuItem, DynamoViewModel vm)
{
if (!Directory.Exists(dir)) { return null; }
List<MenuItem> tempMenuItems = new List<MenuItem>();
foreach (string d in Directory.GetDirectories(dir))
{
string dirName = Path.GetFileName(d);
if (dirName != "backup")
{
MenuItem dirMenu = new MenuItem { Header = dirName };
dirMenu.ToolTip = new ToolTip { Content = d };
dirMenu = BuildMyGraphsMenu(d, dirMenu, vm);
if (dirMenu != null) { tempMenuItems.Add(dirMenu); }
}
}
var files = Directory.GetFiles(dir, "*.dyn");
foreach (string f in files)
{
string graphName = Path.GetFileNameWithoutExtension(f);
MenuItem graphMenu = new MenuItem { Header = graphName };
graphMenu.ToolTip = new ToolTip { Content = f };
graphMenu.Click += (sender, args) =>
{
if (File.Exists(f))
{
vm.CloseHomeWorkspaceCommand.Execute(null);
vm.OpenCommand.Execute(f);
}
else { MessageBox.Show("Graph " + graphName + " has been moved, renamed or deleted..."); }
};
tempMenuItems.Add(graphMenu);
}
if (tempMenuItems.Count > 0)
{
foreach (MenuItem tempMenuItem in tempMenuItems) { menuItem.Items.Add(tempMenuItem); }
return menuItem;
}
else { return null; }
}
19
Source : NotepadWindow.xaml.cs
with MIT License
from AngryCarrot789
with MIT License
from AngryCarrot789
private void InitialiseTreeFileExplorer()
{
try
{
DriveInfo[] drives = DriveInfo.GetDrives();
DriveInfo.GetDrives().ToList().ForEach(drive =>
{
fileExplorerTree.Items.Add(new FileSystemObjectInfo(drive));
});
}
catch (Exception e)
{
MessageBox.Show($"Failed to initialise File Explorer. Error: {e.Message}");
}
}
19
Source : NotepadWindow.xaml.cs
with MIT License
from AngryCarrot789
with MIT License
from AngryCarrot789
public void HighlightFindResult(FindResult result, bool focusTextEditor = true)
{
try
{
MainTextBox.HighlightSearchResult(result, focusTextEditor);
}
catch (Exception e)
{
MessageBox.Show($"Failed to highlight text: {e.Message}");
}
}
19
Source : App.xaml.cs
with Apache License 2.0
from AnkiUniversal
with Apache License 2.0
from AnkiUniversal
private static void HandleArgs(StartupEventArgs e)
{
if (e.Args.Length == 0)
{
MessageBox.Show("The app is already running.");
return;
}
using (var client = new NlpJdictServiceProxy())
{
client.SearchText(e.Args[0]);
}
}
19
Source : MainWindowViewModel.cs
with MIT License
from Aptacode
with MIT License
from Aptacode
private void FormViewModelOnOnTriggered(object sender, (EventListener, FormElementEvent) e)
{
switch (e.Item1.Name)
{
case "submit":
Submit();
break;
case "tooLittleExperiance":
MessageBox.Show("Sorry you've too little exp!");
break;
}
}
19
Source : SpotifyRemoteSettingsControl.xaml.cs
with MIT License
from arjankuijpers
with MIT License
from arjankuijpers
private void UpdateUIColors()
{
var defaultBackground = VSColorTheme.GetThemedColor(EnvironmentColors.ToolWindowBackgroundColorKey);
var defaultForeground = VSColorTheme.GetThemedColor(EnvironmentColors.ToolWindowTextColorKey);
System.Drawing.Color c = VSColorTheme.GetThemedColor(EnvironmentColors.ToolWindowBackgroundColorKey);
SolidColorBrush backgroundCol = new SolidColorBrush(ThemeHelper.ToMediaColor(defaultBackground));
switch (ThemeHelper.GetTheme())
{
case ThemeHelper.eVSTheme.kDark:
foregroundColor = Color.FromRgb(255, 255, 255);
subOptionsColor = Color.FromRgb(130, 203, 247);
explainOptColor = Color.FromRgb(255, 255, 255);
Windowreplacedle.Foreground = new SolidColorBrush(Color.FromRgb(186, 255, 171));
Windowreplacedle.Background = new SolidColorBrush(ThemeHelper.ToMediaColor(defaultBackground));
Background = backgroundCol;
//listView.Background = backgroundCol;
break;
case ThemeHelper.eVSTheme.kBlue:
foregroundColor = Color.FromRgb(0, 0, 0);
subOptionsColor = Color.FromRgb(100, 106, 106);
explainOptColor = Color.FromRgb(0, 0, 0);
Windowreplacedle.Foreground = new SolidColorBrush(Color.FromRgb(83, 114, 76));
Windowreplacedle.Background = new SolidColorBrush(ThemeHelper.ToMediaColor(defaultBackground));
Background = backgroundCol;
//.Background = backgroundCol;
break;
case ThemeHelper.eVSTheme.kLight:
foregroundColor = Color.FromRgb(0, 0, 0);
subOptionsColor = Color.FromRgb(100, 106, 106);
explainOptColor = Color.FromRgb(0, 0, 0);
Windowreplacedle.Foreground = new SolidColorBrush(Color.FromRgb(83, 114, 76));
Windowreplacedle.Background = backgroundCol;
Background = backgroundCol;
//listView.Background = backgroundCol;
break;
case ThemeHelper.eVSTheme.kUnknown:
//break;
default:
byte a = defaultForeground.A;
byte r = defaultForeground.R;
byte g = defaultForeground.G;
byte b = defaultForeground.B;
foregroundColor = Color.FromArgb(a, r, g, b);
subOptionsColor = Color.FromArgb(a, r, g, b);
explainOptColor = Color.FromArgb(a, r, g, b);
Windowreplacedle.Foreground = new SolidColorBrush(foregroundColor);
Windowreplacedle.Background = new SolidColorBrush(ThemeHelper.ToMediaColor(defaultBackground));
Dispatcher.BeginInvoke(new System.Action(() => MessageBox.Show("Spotify extension couldn't detect color scheme. \nWould you be so kind to file a bug report?")));
break;
}
//SetListViewColors(foregroundColor);
UpdateSettingsreplacedles(foregroundColor);
UpdateSettingsSubOptions(subOptionsColor);
UpdateExplainationSettings(explainOptColor);
}
19
Source : App.xaml.cs
with GNU General Public License v3.0
from armandoalonso
with GNU General Public License v3.0
from armandoalonso
public void App_Startup(object sender, StartupEventArgs e)
{
try
{
//check for oneclick args
if (AppDomain.CurrentDomain?.SetupInformation?.ActivationArguments?.ActivationData != null)
{
var path = new Uri(AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0]).LocalPath;
if(string.IsNullOrWhiteSpace(path)) return;
var info = new FileInfo(path);
C3Addon c3addon;
//check if file is json or project
var addonInfo = File.ReadAllLines(info.FullName)[0];
if (addonInfo == "@@METADATA")
{
c3addon = ProjectManager.ReadProject(info.FullName);
}
else
{
var data = File.ReadAllText(info.FullName);
c3addon = JsonConvert.DeserializeObject<C3Addon>(data);
}
var currAddon = DataAccessFacade.Insatnce.AddonData.Get(x => x.Id.Equals(c3addon.Id));
if (currAddon != null)
{
var results = MessageBox.Show(
"Addon currently exists do you want to overwrite addon? \n(YES) will overwrite, \n(NO) will replacedign new addon id.",
"Overwrite?", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
if (results == MessageBoxResult.Yes)
{
c3addon.LastModified = DateTime.Now;
DataAccessFacade.Insatnce.AddonData.Upsert(c3addon);
}
else if (results == MessageBoxResult.No)
{
c3addon.Id = Guid.NewGuid();
c3addon.LastModified = DateTime.Now;
DataAccessFacade.Insatnce.AddonData.Upsert(c3addon);
}
else
{
//do not open new addon
return;
}
}
else
{
c3addon.LastModified = DateTime.Now;
DataAccessFacade.Insatnce.AddonData.Upsert(c3addon);
}
//get the plugin template
c3addon.Template = TemplateFactory.Insatnce.CreateTemplate(c3addon.Type);
AddonManager.CurrentAddon = c3addon;
}
//process command line args
var args = e.Args;
if (args.Any())
{
//checked if string is guid
if (Guid.TryParse(args[0], out var guid))
{
var addon = DataAccessFacade.Insatnce.AddonData.Get(x => x.Id == guid).FirstOrDefault();
if (addon != null)
{
AddonManager.CurrentAddon = addon;
}
}
else
{
MessageBox.Show($"invalid arg => {args[0]}");
}
}
}
catch (Exception ex)
{
LogManager.AddErrorLog(ex);
}
//always start main window
//MainWindow main = new MainWindow();
//main.Show();
}
19
Source : BeatSaver.cs
with MIT License
from Assistant
with MIT License
from Assistant
private static async Task<BeatSaverApiResponse> GetResponse(string url, bool showNotification = true, int retries = 3)
{
if (retries == 0)
{
Modreplacedistant.Utils.Log($"Max tries reached: Skipping {url}", "ERROR");
Utils.SetMessage($"{string.Format((string)Application.Current.FindResource("OneClick:RatelimitSkip"), url)}");
App.CloseWindowOnFinish = false;
throw new Exception("Max retries allowed");
}
BeatSaverApiResponse response = new BeatSaverApiResponse();
try
{
var resp = await HttpClient.GetAsync(url);
response.statusCode = resp.StatusCode;
response.ratelimit = GetRatelimit(resp.Headers);
string body = await resp.Content.ReadreplacedtringAsync();
if ((int)resp.StatusCode == 429)
{
Utils.SetMessage($"{string.Format((string)Application.Current.FindResource("OneClick:RatelimitHit"), response.ratelimit.ResetTime.ToLocalTime())}");
await response.ratelimit.Wait();
return await GetResponse(url, showNotification, retries - 1);
}
if (response.statusCode == HttpStatusCode.OK)
{
response.map = JsonSerializer.Deserialize<BeatSaverApiResponseMap>(body);
return response;
}
else
{
Utils.SetMessage($"{string.Format((string)Application.Current.FindResource("OneClick:Failed"), url)}");
App.CloseWindowOnFinish = false;
return response;
}
}
catch (Exception e)
{
if (showNotification)
{
MessageBox.Show($"{Application.Current.FindResource("OneClick:MapDownloadFailed")}\n\n" + e);
}
return null;
}
}
19
Source : Diagnostics.cs
with MIT License
from Assistant
with MIT License
from Assistant
public static string[] ReadFolder(string path, int level = 0)
{
List<string> entries = new List<string>();
foreach (string file in Directory.GetFileSystemEntries(path))
{
string line = string.Empty;
if (File.Exists(file))
{
line = Utils.CalculateMD5(file) + " " + LevelSeparator(level) + "├─ " + Path.GetFileName(file);
entries.Add(line);
}
else if (Directory.Exists(file))
{
line = Utils.Constants.MD5Spacer + LevelSeparator(level) + "├─ " + Path.GetFileName(file);
entries.Add(line);
foreach (string entry in ReadFolder(file.Replace(@"\", @"\\"), level + 1))
{
//MessageBox.Show(entry);
entries.Add(entry);
}
}
else
{
MessageBox.Show("! " + file);
}
}
if (entries.Count > 0)
{
entries[entries.Count - 1] = entries[entries.Count - 1].Replace("├", "└");
}
return entries.ToArray();
}
19
Source : OneClickInstaller.cs
with MIT License
from Assistant
with MIT License
from Assistant
public static void Register(string Protocol, bool Background = false, string Description = null)
{
if (IsRegistered(Protocol) == true)
return;
try
{
if (Utils.IsAdmin)
{
RegistryKey ProtocolKey = Registry.ClreplacedesRoot.OpenSubKey(Protocol, true);
if (ProtocolKey == null)
ProtocolKey = Registry.ClreplacedesRoot.CreateSubKey(Protocol, true);
RegistryKey CommandKey = ProtocolKey.CreateSubKey(@"shell\open\command", true);
if (CommandKey == null)
CommandKey = Registry.ClreplacedesRoot.CreateSubKey(@"shell\open\command", true);
if (ProtocolKey.GetValue("OneClick-Provider", "").ToString() != "Modreplacedistant")
{
if (Description != null)
{
ProtocolKey.SetValue("", Description, RegistryValueKind.String);
}
ProtocolKey.SetValue("URL Protocol", "", RegistryValueKind.String);
ProtocolKey.SetValue("OneClick-Provider", "Modreplacedistant", RegistryValueKind.String);
CommandKey.SetValue("", $"\"{Utils.ExePath}\" \"--install\" \"%1\"");
}
Utils.SendNotify(string.Format((string)Application.Current.FindResource("OneClick:ProtocolHandler:Registered"), Protocol));
}
else
{
Utils.StartAsAdmin($"\"--register\" \"{Protocol}\" \"{Description}\"");
}
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
if (Background)
Application.Current.Shutdown();
else
Pages.Options.Instance.UpdateHandlerStatus();
}
19
Source : OneClickInstaller.cs
with MIT License
from Assistant
with MIT License
from Assistant
public static void Unregister(string Protocol, bool Background = false)
{
if (IsRegistered(Protocol) == false)
return;
try
{
if (Utils.IsAdmin)
{
using (RegistryKey ProtocolKey = Registry.ClreplacedesRoot.OpenSubKey(Protocol, true))
{
if (ProtocolKey != null
&& ProtocolKey.GetValue("OneClick-Provider", "").ToString() == "Modreplacedistant")
{
Registry.ClreplacedesRoot.DeleteSubKeyTree(Protocol);
}
}
Utils.SendNotify(string.Format((string)Application.Current.FindResource("OneClick:ProtocolHandler:Unregistered"), Protocol));
}
else
{
Utils.StartAsAdmin($"\"--unregister\" \"{Protocol}\"");
}
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
if (Background)
Application.Current.Shutdown();
else
Pages.Options.Instance.UpdateHandlerStatus();
}
19
Source : Themes.cs
with MIT License
from Assistant
with MIT License
from Assistant
public static void WriteThemeToDisk(string themeName)
{
Directory.CreateDirectory(ThemeDirectory);
Directory.CreateDirectory($"{ThemeDirectory}\\{themeName}");
if (File.Exists($@"{ThemeDirectory}\\{themeName}.xaml") == false)
{
/*
* Any theme that you want to write must be set as an Embedded Resource instead of the default Page.
* This is so that we can grab its exact content from Manifest, shown below.
* Writing it as is instead of using XAMLWriter keeps the source as is with comments, spacing, and organization.
* Using XAMLWriter would compress it into an unorganized mess.
*/
using (Stream s = replacedembly.GetExecutingreplacedembly().GetManifestResourceStream($"Modreplacedistant.Themes.{themeName}.xaml"))
using (FileStream writer = new FileStream($@"{ThemeDirectory}\\{themeName}\\{themeName}.xaml", FileMode.Create))
{
byte[] buffer = new byte[s.Length];
int read = s.Read(buffer, 0, (int)s.Length);
writer.Write(buffer, 0, buffer.Length);
}
MainWindow.Instance.MainText = string.Format((string)Application.Current.FindResource("Themes:SavedTemplateTheme"), themeName);
}
else
{
MessageBox.Show((string)Application.Current.FindResource("Themes:TemplateThemeExists"));
}
}
19
Source : Utils.cs
with MIT License
from Assistant
with MIT License
from Assistant
public static string GetInstallDir()
{
string InstallDir = Properties.Settings.Default.InstallFolder;
if (!string.IsNullOrEmpty(InstallDir)
&& Directory.Exists(InstallDir)
&& Directory.Exists(Path.Combine(InstallDir, "Beat Saber_Data", "Plugins"))
&& File.Exists(Path.Combine(InstallDir, "Beat Saber.exe")))
{
return InstallDir;
}
try
{
InstallDir = GetSteamDir();
}
catch { }
if (!string.IsNullOrEmpty(InstallDir))
{
return InstallDir;
}
try
{
InstallDir = GetOculusDir();
}
catch { }
if (!string.IsNullOrEmpty(InstallDir))
{
return InstallDir;
}
MessageBox.Show((string)Application.Current.FindResource("Utils:NoInstallFolder"));
InstallDir = GetManualDir();
if (!string.IsNullOrEmpty(InstallDir))
{
return InstallDir;
}
return null;
}
19
Source : Utils.cs
with MIT License
from Assistant
with MIT License
from Assistant
public static void OpenFolder(string location)
{
if (!location.EndsWith(Path.DirectorySeparatorChar.ToString())) location += Path.DirectorySeparatorChar;
if (Directory.Exists(location))
{
try
{
Process.Start(new System.Diagnostics.ProcessStartInfo()
{
FileName = location,
UseShellExecute = true,
Verb = "open"
});
return;
}
catch { }
}
MessageBox.Show($"{string.Format((string)Application.Current.FindResource("Utils:CannotOpenFolder"), location)}.");
}
19
Source : Intro.xaml.cs
with MIT License
from Assistant
with MIT License
from Assistant
private void Disagree_Click(object sender, RoutedEventArgs e)
{
MainWindow.Instance.ModsButton.IsEnabled = false;
Properties.Settings.Default.Agreed = false;
Properties.Settings.Default.Save();
MessageBox.Show((string)FindResource("Intro:ClosingApp"));
Application.Current.Shutdown();
}
19
Source : Intro.xaml.cs
with MIT License
from Assistant
with MIT License
from Assistant
private void Agree_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(MainWindow.GameVersion))
{
string line1 = (string)FindResource("Intro:VersionDownloadFailed");
string line2 = (string)FindResource("Intro:ModsTabDisabled");
MessageBox.Show($"{line1}.\n{line2}");
}
else
{
MainWindow.Instance.ModsButton.IsEnabled = true;
string text = (string)FindResource("Intro:ModsTabEnabled");
Utils.SendNotify(text);
MainWindow.Instance.MainText = text;
}
Properties.Settings.Default.Agreed = true;
Properties.Settings.Default.Save();
}
19
Source : Mods.xaml.cs
with MIT License
from Assistant
with MIT License
from Assistant
public async Task PopulateModsList()
{
try
{
var resp = await HttpClient.GetAsync(Utils.Constants.BeatModsAPIUrl + Utils.Constants.BeatModsModsOptions + "&gameVersion=" + MainWindow.GameVersion);
var body = await resp.Content.ReadreplacedtringAsync();
ModsList = JsonSerializer.Deserialize<Mod[]>(body);
}
catch (Exception e)
{
System.Windows.MessageBox.Show($"{FindResource("Mods:LoadFailed")}.\n\n" + e);
return;
}
foreach (Mod mod in ModsList)
{
bool preSelected = mod.required;
if (DefaultMods.Contains(mod.name) || (App.SaveModSelection && App.SavedMods.Contains(mod.name)))
{
preSelected = true;
if (!App.SavedMods.Contains(mod.name))
{
App.SavedMods.Add(mod.name);
}
}
RegisterDependencies(mod);
ModLisreplacedem Lisreplacedem = new ModLisreplacedem()
{
IsSelected = preSelected,
IsEnabled = !mod.required,
ModName = mod.name,
ModVersion = mod.version,
ModDescription = mod.description.Replace("\r\n", " ").Replace("\n", " "),
ModInfo = mod,
Category = mod.category
};
foreach (Promotion promo in Promotions.List)
{
if (promo.Active && mod.name == promo.ModName)
{
Lisreplacedem.PromotionTexts = new string[promo.Links.Count];
Lisreplacedem.PromotionLinks = new string[promo.Links.Count];
Lisreplacedem.PromotionTextAfterLinks = new string[promo.Links.Count];
for (int i = 0; i < promo.Links.Count; ++i)
{
PromotionLink link = promo.Links[i];
Lisreplacedem.PromotionTexts[i] = link.Text;
Lisreplacedem.PromotionLinks[i] = link.Link;
Lisreplacedem.PromotionTextAfterLinks[i] = link.TextAfterLink;
}
}
}
foreach (Mod installedMod in InstalledMods)
{
if (mod.name == installedMod.name)
{
Lisreplacedem.InstalledModInfo = installedMod;
Lisreplacedem.IsInstalled = true;
Lisreplacedem.InstalledVersion = installedMod.version;
break;
}
}
mod.Lisreplacedem = Lisreplacedem;
ModList.Add(Lisreplacedem);
}
foreach (Mod mod in ModsList)
{
ResolveDependencies(mod);
}
}
19
Source : Mods.xaml.cs
with MIT License
from Assistant
with MIT License
from Assistant
private async Task InstallMod(Mod mod, string directory)
{
int filesCount = 0;
string downloadLink = null;
foreach (Mod.DownloadLink link in mod.downloads)
{
filesCount = link.hashMd5.Length;
if (link.type == "universal")
{
downloadLink = link.url;
break;
}
else if (link.type.ToLowerInvariant() == App.BeatSaberInstallType.ToLowerInvariant())
{
downloadLink = link.url;
break;
}
}
if (string.IsNullOrEmpty(downloadLink))
{
System.Windows.MessageBox.Show(string.Format((string)FindResource("Mods:ModDownloadLinkMissing"), mod.name));
return;
}
while (true)
{
List<ZipArchiveEntry> files = new List<ZipArchiveEntry>(filesCount);
using (Stream stream = await DownloadMod(Utils.Constants.BeatModsURL + downloadLink))
using (ZipArchive archive = new ZipArchive(stream))
{
foreach (ZipArchiveEntry file in archive.Entries)
{
string fileDirectory = Path.GetDirectoryName(Path.Combine(directory, file.FullName));
if (!Directory.Exists(fileDirectory))
{
Directory.CreateDirectory(fileDirectory);
}
if (!string.IsNullOrEmpty(file.Name))
{
foreach (Mod.DownloadLink download in mod.downloads)
{
foreach (Mod.FileHashes fileHash in download.hashMd5)
{
using (Stream fileStream = file.Open())
{
if (fileHash.hash == Utils.CalculateMD5FromStream(fileStream))
{
files.Add(file);
break;
}
}
}
}
}
}
if (files.Count == filesCount)
{
foreach (ZipArchiveEntry file in files)
{
await ExtractFile(file, Path.Combine(directory, file.FullName), 3.0, mod.name, 10);
}
break;
}
}
}
if (App.CheckInstalledMods)
{
mod.Lisreplacedem.IsInstalled = true;
mod.Lisreplacedem.InstalledVersion = mod.version;
mod.Lisreplacedem.InstalledModInfo = mod;
}
}
19
Source : Options.xaml.cs
with MIT License
from Assistant
with MIT License
from Assistant
private void OpenAppDataButton_Click(object sender, RoutedEventArgs e)
{
string location = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
"AppData", "LocalLow", "Hyperbolic Magnetism");
if (Directory.Exists(location))
{
Utils.OpenFolder(location);
}
else
{
MessageBox.Show((string)Application.Current.FindResource("Options:AppDataNotFound"));
}
}
19
Source : Options.xaml.cs
with MIT License
from Assistant
with MIT License
from Assistant
private void ApplicationThemeOpenThemesFolder_Click(object sender, RoutedEventArgs e)
{
if (Directory.Exists(Themes.ThemeDirectory))
{
Utils.OpenFolder(Themes.ThemeDirectory);
}
else
{
MessageBox.Show((string)Application.Current.FindResource("Options:ThemeFolderNotFound"));
}
}
19
Source : MainWindow.xaml.cs
with MIT License
from Assistant
with MIT License
from Assistant
private async void LoadVersionsAsync()
{
try
{
var resp = await HttpClient.GetAsync(Utils.Constants.BeatModsVersions);
var body = await resp.Content.ReadreplacedtringAsync();
List<string> versions = JsonSerializer.Deserialize<string[]>(body).ToList();
resp = await HttpClient.GetAsync(Utils.Constants.BeatModsAlias);
body = await resp.Content.ReadreplacedtringAsync();
Dictionary<string, string[]> aliases = JsonSerializer.Deserialize<Dictionary<string, string[]>>(body);
Dispatcher.Invoke(() =>
{
GameVersion = GetGameVersion(versions, aliases);
GameVersionsBox.ItemsSource = versions;
GameVersionsBox.SelectedValue = GameVersion;
if (!string.IsNullOrEmpty(GameVersionOverride))
{
GameVersionsBox.Visibility = Visibility.Collapsed;
GameVersionsBoxOverride.Visibility = Visibility.Visible;
GameVersionsBoxOverride.Text = GameVersionOverride;
GameVersionsBoxOverride.IsEnabled = false;
}
if (!string.IsNullOrEmpty(GameVersion) && Properties.Settings.Default.Agreed)
{
Instance.ModsButton.IsEnabled = true;
}
});
VersionLoadStatus.SetResult(true);
}
catch (Exception e)
{
Dispatcher.Invoke(() =>
{
GameVersionsBox.IsEnabled = false;
MessageBox.Show($"{Application.Current.FindResource("MainWindow:GameVersionLoadFailed")}\n{e}");
});
VersionLoadStatus.SetResult(false);
}
}
19
Source : MainWindow.xaml.cs
with MIT License
from Assistant
with MIT License
from Assistant
private void InfoButton_Click(object sender, RoutedEventArgs e)
{
if ((Mods.ModLisreplacedem)Mods.Instance.ModsListView.SelectedItem == null)
{
MessageBox.Show((string)Application.Current.FindResource("MainWindow:NoModSelected"));
return;
}
Mods.ModLisreplacedem mod = ((Mods.ModLisreplacedem)Mods.Instance.ModsListView.SelectedItem);
string infoUrl = mod.ModInfo.link;
if (string.IsNullOrEmpty(infoUrl))
{
MessageBox.Show(string.Format((string)Application.Current.FindResource("MainWindow:NoModInfoPage"), mod.ModName));
}
else
{
System.Diagnostics.Process.Start(infoUrl);
}
}
19
Source : Themes.cs
with MIT License
from Assistant
with MIT License
from Assistant
private static Theme LoadTheme(string directory, string name)
{
Theme theme = new Theme(name, null)
{
Waifus = new Waifus()
};
foreach (string file in Directory.EnumerateFiles(directory).OrderBy(x => x))
{
FileInfo info = new FileInfo(file);
bool isPng = info.Name.EndsWith(".png", StringComparison.OrdinalIgnoreCase);
bool isSidePng = info.Name.EndsWith(".side.png", StringComparison.OrdinalIgnoreCase);
bool isXaml = info.Name.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase);
if (isPng && !isSidePng)
{
theme.Waifus.Background = new BitmapImage(new Uri(info.FullName));
}
if (isSidePng)
{
theme.Waifus.Sidebar = new BitmapImage(new Uri(info.FullName));
}
if (isXaml)
{
try
{
Uri resourceSource = new Uri(info.FullName);
ResourceDictionary dictionary = new ResourceDictionary
{
Source = resourceSource
};
theme.ThemeDictionary = dictionary;
}
catch (Exception ex)
{
string message = string.Format((string)Application.Current.FindResource("Themes:FailedToLoadXaml"), name, ex.Message);
MessageBox.Show(message);
}
}
if (supportedVideoExtensions.Contains(info.Extension))
{
if (info.Name != $"_{name}{info.Extension}" || theme.VideoLocation is null)
{
theme.VideoLocation = info.FullName;
}
}
}
return theme;
}
19
Source : Themes.cs
with MIT License
from Assistant
with MIT License
from Assistant
private static Theme LoadZipTheme(string directory, string name, string extension)
{
Waifus waifus = new Waifus();
ResourceDictionary dictionary = null;
using (FileStream stream = new FileStream(Path.Combine(directory, name + extension), FileMode.Open, FileAccess.Read))
using (ZipArchive archive = new ZipArchive(stream))
{
foreach (ZipArchiveEntry file in archive.Entries)
{
bool isPng = file.Name.EndsWith(".png", StringComparison.OrdinalIgnoreCase);
bool isSidePng = file.Name.EndsWith(".side.png", StringComparison.OrdinalIgnoreCase);
bool isXaml = file.Name.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase);
if (isPng && !isSidePng)
{
waifus.Background = GetImageFromStream(Utils.StreamToArray(file.Open()));
}
if (isSidePng)
{
waifus.Sidebar = GetImageFromStream(Utils.StreamToArray(file.Open()));
}
string videoExtension = $".{file.Name.Split('.').Last()}";
if (supportedVideoExtensions.Contains(videoExtension))
{
string videoName = $"{ThemeDirectory}\\{name}\\_{name}{videoExtension}";
Directory.CreateDirectory($"{ThemeDirectory}\\{name}");
if (File.Exists(videoName) == false)
{
file.ExtractToFile(videoName, false);
}
else
{
/*
* Check to see if the lengths of each file are different. If they are, overwrite what currently exists.
* The reason we are also checking LoadedTheme against the name variable is to prevent overwriting a file that's
* already being used by Modreplacedistant and causing a System.IO.IOException.
*/
FileInfo existingInfo = new FileInfo(videoName);
if (existingInfo.Length != file.Length && LoadedTheme != name)
{
file.ExtractToFile(videoName, true);
}
}
}
if (isXaml && loadedThemes.ContainsKey(name) == false)
{
try
{
dictionary = (ResourceDictionary)XamlReader.Load(file.Open());
}
catch (Exception ex)
{
string message = string.Format((string)Application.Current.FindResource("Themes:FailedToLoadXaml"), name, ex.Message);
MessageBox.Show(message);
}
}
}
}
Theme theme = new Theme(name, dictionary)
{
Waifus = waifus
};
return theme;
}
19
Source : Utils.cs
with MIT License
from Assistant
with MIT License
from Assistant
public static void StartAsAdmin(string Arguments, bool Close = false)
{
using (Process process = new Process())
{
process.StartInfo.FileName = Process.GetCurrentProcess().MainModule.FileName;
process.StartInfo.Arguments = Arguments;
process.StartInfo.UseShellExecute = true;
process.StartInfo.Verb = "runas";
try
{
process.Start();
if (!Close)
{
process.WaitForExit();
}
}
catch
{
MessageBox.Show((string)Application.Current.FindResource("Utils:RunAsAdmin"));
}
if (Close) Application.Current.Shutdown();
}
}
19
Source : SelectAssemblyPage.xaml.cs
with MIT License
from avestura
with MIT License
from avestura
private void Button_Click(object sender, RoutedEventArgs e)
{
var dialog = new OpenFileDialog
{
Filter = "replacedembly (*.exe, *.dll)|*.dll;*.exe",
CheckFileExists = true,
CheckPathExists = true,
Multiselect = false,
replacedle = "Select replacedembly"
};
if(dialog.ShowDialog() == true)
{
try
{
var asm = replacedembly.LoadFrom(dialog.FileName);
ParentFrame.Navigate(new InspectorPage(asm, ParentFrame));
}
catch(Exception ex)
{
MessageBox.Show($"File not valid, Reason: {ex.Message}" + ((ex.InnerException != null) ? $"\nInner{ex.InnerException.Message}" : ""));
}
}
}
19
Source : AyGaosiBackgroundLayer.xaml.cs
with MIT License
from ay2015
with MIT License
from ay2015
public void ReLoadImageBmp(string path)
{
if (AyCommon.ISXP)
{
ImageBrush ib = new ImageBrush(new BitmapImage(new Uri(path, UriKind.RelativeOrAbsolute)));
if (this.BgData != null)
{
ib.Stretch = BackgroundStretch;
BgData.ImBrush = ib;
}
}
else
{
if (Bmp != null)
{
Bmp.Dispose();
Marshal.FreeHGlobal(ImageCopyPointer);
}
try
{
if (path.IndexOf("pack://") == 0)
{
BitmapSource bitp = new BitmapImage(new Uri(path, UriKind.RelativeOrAbsolute));
Bmp = AyFuncBitmapWithWpf.Instance.GetBitmap(bitp);
}
else
{
Bmp = (System.Drawing.Bitmap)System.Drawing.Bitmap.FromFile(path);
}
System.Drawing.Imaging.BitmapData BmpData = new System.Drawing.Imaging.BitmapData();
Bmp.LockBits(new System.Drawing.Rectangle(0, 0, Bmp.Width, Bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, Bmp.PixelFormat, BmpData); // 用原始格式LockBits,得到图像在内存中真正地址,这个地址在图像的大小,色深等未发生变化时,每次Lock返回的Scan0值都是相同的。
ImagePointer = BmpData.Scan0; // 记录图像在内存中的真正地址
DataLength = BmpData.Stride * BmpData.Height; // 记录整幅图像占用的内存大小
ImageCopyPointer = Marshal.AllocHGlobal(DataLength); // 直接用内存数据来做备份,AllocHGlobal在内部调用的是LocalAlloc函数
CopyMemory(ImageCopyPointer, ImagePointer, DataLength); // 这里当然也可以用Bitmap的Clone方式来处理,但是我总认为直接处理内存数据比用对象的方式速度快。
Bmp.UnlockBits(BmpData);
UpdateImage();
}
catch (Exception d)
{
MessageBox.Show(d.Message);
}
}
}
19
Source : AyFuncFtp.cs
with MIT License
from ay2015
with MIT License
from ay2015
public void ErrLog(string ed)
{
MessageBox.Show(ed);
}
19
Source : AyFuncSystem.cs
with MIT License
from ay2015
with MIT License
from ay2015
public static Process StartProcess(string filename, string[] args)
{
try
{
string s = "";
foreach (string arg in args)
{
s = s + arg + " ";
}
s = s.Trim();
Process myprocess = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo(filename, s);
startInfo.WindowStyle= ProcessWindowStyle.Maximized;
myprocess.StartInfo = startInfo;
myprocess.StartInfo.UseShellExecute = false;
myprocess.Start();
return myprocess;
}
catch (Exception ex)
{
MessageBox.Show("启动应用程序时出错!原因:" + ex.Message);
}
return null;
}
19
Source : AyWindowShell.cs
with MIT License
from ay2015
with MIT License
from ay2015
public void ReLoadImageBmp(string path)
{
if (AyCommon.ISXP)
{
ImageBrush ib = new ImageBrush(new BitmapImage(new Uri(path, UriKind.RelativeOrAbsolute)));
if (this.BgData != null)
{
ib.Stretch = BackgroundStretch;
ib.AlignmentX = AlignmentX.Left;
ib.AlignmentY = AlignmentY.Top;
BgData.ImBrush = ib;
}
}
else
{
if (Bmp != null)
{
Bmp.Dispose();
Marshal.FreeHGlobal(ImageCopyPointer);
}
try
{
if (path.IndexOf("pack://") == 0)
{
BitmapSource bitp = new BitmapImage(new Uri(path, UriKind.RelativeOrAbsolute));
Bmp = AyFuncBitmapWithWpf.Instance.GetBitmap(bitp);
}
else
{
Bmp = (System.Drawing.Bitmap)System.Drawing.Bitmap.FromFile(path);
}
Bmp = (System.Drawing.Bitmap)System.Drawing.Bitmap.FromFile(path);
System.Drawing.Imaging.BitmapData BmpData = new System.Drawing.Imaging.BitmapData();
Bmp.LockBits(new System.Drawing.Rectangle(0, 0, Bmp.Width, Bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, Bmp.PixelFormat, BmpData); // 用原始格式LockBits,得到图像在内存中真正地址,这个地址在图像的大小,色深等未发生变化时,每次Lock返回的Scan0值都是相同的。
ImagePointer = BmpData.Scan0; // 记录图像在内存中的真正地址
DataLength = BmpData.Stride * BmpData.Height; // 记录整幅图像占用的内存大小
ImageCopyPointer = Marshal.AllocHGlobal(DataLength); // 直接用内存数据来做备份,AllocHGlobal在内部调用的是LocalAlloc函数
CopyMemory(ImageCopyPointer, ImagePointer, DataLength); // 这里当然也可以用Bitmap的Clone方式来处理,但是我总认为直接处理内存数据比用对象的方式速度快。
Bmp.UnlockBits(BmpData);
UpdateImage();
}
catch (Exception d)
{
MessageBox.Show(d.Message);
}
}
}
19
Source : AyDateStrictExpression.cs
with MIT License
from ay2015
with MIT License
from ay2015
internal static DateTime Convert(string expression)
{
var _afterReplaceText = Regex.Replace(expression, @"{(?<c>.*?)}", teSepc);
MatchCollection matches = Regex.Matches(expression, @"{(?<c>.*?)}");
List<string> strs = new List<string>();
foreach (Match match in matches)
{
GroupCollection groups = match.Groups;
string _1 = groups["c"].Value;
if (_1 != null)
{
strs.Add(groups["c"].Value);
}
}
var dtnow = DateTime.Now;
int curSpecIndex = 0;
DateTime dtReturn = new DateTime();
var _p1 = _afterReplaceText.Split(' ');
if (_p1.Length == 1)
{
//判断是年月还是时间
var _text = _p1[0];
if (_text.IndexOf(":") > -1) //时间方式处理
{
ReturnTimeDateTime(teSepc, strs, dtnow, ref curSpecIndex, ref dtReturn, _text);
dtReturn = new DateTime(dtnow.Year, dtnow.Month, dtnow.Day, dtReturn.Hour, dtReturn.Minute, dtReturn.Second);
}
else//年月日方式处理
{
ReturnDateDateTime(teSepc, strs, dtnow, ref curSpecIndex, ref dtReturn, _text);
}
}
else if (_p1.Length == 2)
{
//判断是年月 时间处理
var _date = _p1[0];
var _time = _p1[1];
//必须按照年月日时分秒方式去处理
ReturnDateDateTime(teSepc, strs, dtnow, ref curSpecIndex, ref dtReturn, _date);
//处理时间 Time
ReturnTimeDateTime(teSepc, strs, dtnow, ref curSpecIndex, ref dtReturn, _time);
}
else
{
MessageBox.Show("[AY日期限制表达式]语法错误,语句为:" + expression);
}
return dtReturn;
}
19
Source : AyCommon.cs
with MIT License
from ay2015
with MIT License
from ay2015
public static Process StartProcess(string filename, string[] args)
{
try
{
string s = "";
if (args.IsNotNull())
{
foreach (string arg in args)
{
s = s + arg + " ";
}
}
s = s.Trim();
Process myprocess = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo(filename, s);
startInfo.WindowStyle = ProcessWindowStyle.Maximized;
myprocess.StartInfo = startInfo;
myprocess.StartInfo.UseShellExecute = false;
myprocess.Start();
return myprocess;
}
catch (Exception ex)
{
MessageBox.Show("启动应用程序时出错!原因:" + ex.Message);
}
return null;
}
See More Examples