/// <summary> /// Creates a new file mover. /// </summary> /// <param name="buildPath">The path of the local build.</param> /// <param name="checkMode">Specifies whether the file mover uses a mutex GUID /// or checks for the existence of a process when waiting for the main /// application to exit before moving files.</param> /// <param name="appGuid">The GUID of the main application. The file mover /// can use it to wait for the application to exit before moving files.</param> /// <param name="processName">The name of the main application's process. /// The file mover can use it to wait for the application to exit before moving files.</param> public FileMover(string buildPath, ProcessCheckMode checkMode, string appGuid, string processName) { this.buildPath = buildPath; this.processCheckMode = checkMode; this.appGuid = appGuid; this.processNameToCheck = processName; }
private void Form1_Load(object sender, EventArgs e) { IniFile configIni = new IniFile(Application.StartupPath + Path.DirectorySeparatorChar + CONFIGURATION_FILE); string basePath = Application.StartupPath + Path.DirectorySeparatorChar; productName = configIni.GetStringValue(USER_INTERACE, "ProductName", string.Empty); buildPath = basePath + configIni.GetStringValue(INI_SECTION, "BuildPath", string.Empty); targetExecutable = configIni.GetStringValue(INI_SECTION, "ProductExecutable", string.Empty); ProcessCheckMode checkMode = (ProcessCheckMode)Enum.Parse(typeof(ProcessCheckMode), configIni.GetStringValue(INI_SECTION, "WaitMode", "Mutex"), true); string appGuid = configIni.GetStringValue(INI_SECTION, "TargetAppGuid", string.Empty); string processName = configIni.GetStringValue(INI_SECTION, "TargetProcessName", string.Empty); try { Text = configIni.GetStringValue(USER_INTERACE, "WindowTitle", string.Empty); string foreColorString = configIni.GetStringValue(USER_INTERACE, "ForeColor", string.Empty); if (!string.IsNullOrEmpty(foreColorString)) { int[] parts = Array.ConvertAll(foreColorString.Split(','), int.Parse); ForeColor = Color.FromArgb(parts[0], parts[1], parts[2]); listBox1.ForeColor = ForeColor; } string windowSizeString = configIni.GetStringValue(USER_INTERACE, "WindowSize", string.Empty); if (!string.IsNullOrEmpty(windowSizeString)) { int[] parts = Array.ConvertAll(windowSizeString.Split(','), int.Parse); Size = new Size(parts[0], parts[1]); } ParseControlAttributes(configIni, "Label", lblDescription); string labelLocationString = configIni.GetStringValue(USER_INTERACE, "LabelLocation", string.Empty); if (!string.IsNullOrEmpty(labelLocationString)) { int[] parts = Array.ConvertAll(labelLocationString.Split(','), int.Parse); lblDescription.Location = new Point(parts[0], parts[1]); } ParseControlAttributes(configIni, "ListBox", listBox1); string backgroundImage = configIni.GetStringValue(USER_INTERACE, "BackgroundImage", string.Empty); if (File.Exists(basePath + backgroundImage)) { byte[] buffer = File.ReadAllBytes(basePath + backgroundImage); var memoryStream = new MemoryStream(buffer); // Image.FromStream needs the memory stream to be open // when the image is actually drawn, so we don't // dispose the stream BackgroundImage = Image.FromStream(memoryStream); } string icon = configIni.GetStringValue(USER_INTERACE, "Icon", string.Empty); if (File.Exists(basePath + icon)) { Icon = Icon.ExtractAssociatedIcon(basePath + icon); } } catch (Exception ex) { listBox1.Items.Add("Parsing user interface information failed: " + ex.Message); } fileMover = new FileMover(buildPath, checkMode, appGuid, processName); fileMover.LogEntry += FileMover_LogEntry; fileMover.FilesMoved += FileMover_FilesMoved; }