static Program() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs args) { Exception e = (Exception)args.ExceptionObject; Log.Error(e); Message.Error(e); Environment.Exit(0); }; //SetProcessDpiAwareness((int)DpiAwareness.PerMonitorAware); AssemblyRoutines.AssemblyInfo ai = new AssemblyRoutines.AssemblyInfo(); Version = ai.Version; Name = ai.Product; FullName = Name + " " + Version.ToString(3); //Log.Initialize(Log.Mode.ONLY_LOG, Log.CompanyCommonDataDir, true);//must be called from the entry projects //Log.ShowDeleteOldLogsDialog = false;//must be called from the entry projects //Message.TopMost = true;//must be called from the entry projects //Config.Reload();//must be called from the entry projects }
static Program() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); AppDomain.CurrentDomain.UnhandledException += delegate (object sender, UnhandledExceptionEventArgs args) { Exception e = (Exception)args.ExceptionObject; Win.LogMessage.Error(e); Environment.Exit(0); }; //SetProcessDpiAwareness((int)DpiAwareness.PerMonitorAware); AssemblyRoutines.AssemblyInfo ai = new AssemblyRoutines.AssemblyInfo(); Version = ai.Version; Name = ai.Product; Message.TopMost = true; Config.Reload(); Win.LogMessage.DisableStumblingDialogs = false; Log.DeleteOldLogsDialog = null; Log.Initialize(Log.Mode.ONE_FOLDER, new System.Collections.Generic.List<string> { Log.CompanyUserDataDir }); }
void set(AssemblyRoutines.AssemblyInfo ai) { try { TextRange tr = new TextRange(text.Document.ContentEnd, text.Document.ContentEnd); tr.Text = ai.AssemblyProduct; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Maroon); tr.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold); tr.ApplyPropertyValue(TextElement.FontStyleProperty, FontStyles.Normal); tr = new TextRange(text.Document.ContentEnd, text.Document.ContentEnd); tr.Text = "\r\n" + "Version: " + ai.AssemblyCompilationVersion; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Black); tr.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Regular); //if (!string.IsNullOrWhiteSpace(AssemblyDescription)) //{ // tr = new TextRange(text.Document.ContentEnd, text.Document.ContentEnd); // tr.Text = "\r\n" + AssemblyDescription; // tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Gray); // tr.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Light); //} tr = new TextRange(text.Document.ContentEnd, text.Document.ContentEnd); tr.Text = "\r\nDevelopment: Sergey Stoyan, CliverSoft.com"; //tr.Text = "\r\[email protected]"; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Black); //tr.ApplyPropertyValue(TextElement.FontStyleProperty, FontStyles.Italic); tr.ApplyPropertyValue(TextElement.FontStyleProperty, FontStyles.Normal); tr.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Regular); tr = new TextRange(text.Document.ContentEnd, text.Document.ContentEnd); tr.Text = "\r\n" + ai.AssemblyCopyright; //tr.ApplyPropertyValue(TextElement.FontSizeProperty, FontSize); tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Black); tr.ApplyPropertyValue(TextElement.FontStyleProperty, FontStyles.Normal); tr.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Regular); //Product.Text = AssemblyProduct; //Version.Text = "Version: " + AssemblyRoutines.GetAppVersion(); //String.Format("Version {0}", AssemblyVersion); //Copyright.Text = AssemblyCopyright; //Developed.Text = AssemblyDescription;// AssemblyCompany; ////this.textBoxDescription.Text = AssemblyDescription;// + "\r\n\r\nThis app is not intended and must not be used for any malicious activity!"; } catch (Exception e) { Message.Error(e); } }
public ProjectInstaller() { InitializeComponent(); this.Committed += delegate { //try //{ ServiceController sc = new ServiceController(Program.SERVICE_NAME); sc.Start(); //} //catch (Exception e) //{ // //Message.Error(ex);//brings to an error: object is null // System.Windows.Forms.MessageBox.Show(e.Message); //} }; this.BeforeUninstall += delegate { //try //{ ServiceController sc = new ServiceController(Program.SERVICE_NAME); if (sc.Status != ServiceControllerStatus.Stopped) { sc.Stop(); double timeoutSecs = 20; sc.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(timeoutSecs)); if (sc.Status != ServiceControllerStatus.Stopped) { throw new Exception("Could not stop service '" + Cliver.CisteraScreenCaptureService.Program.SERVICE_NAME + "'. To unistall it, stop it manually."); } } //} //catch (Exception e) //{ // //Message.Error(ex);//brings to an error: object is null // MessageBox.Show(); // throw e;//to stop uninstalling(?) //} try { string servicePath = this.Context.Parameters["assemblypath"]; AssemblyRoutines.AssemblyInfo ai = new AssemblyRoutines.AssemblyInfo(servicePath); WindowsFirewall.DeleteRule(ai.AssemblyProduct, servicePath); WindowsFirewall.DeleteRule(ffmpegFirewallRuleName, PathRoutines.GetDirFromPath(servicePath) + "\\ffmpeg.exe"); } catch (Exception e) { //MessageBox.Show("You'll may need to set firewall manually because of the following error that happened while setting firewall:\r\n" + e.Message, "Cistera Screen Capture", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // throw e; } }; this.AfterInstall += delegate { try { string servicePath = this.Context.Parameters["assemblypath"]; AssemblyRoutines.AssemblyInfo ai = new AssemblyRoutines.AssemblyInfo(servicePath); WindowsFirewall.DeleteRule(ai.AssemblyProduct); WindowsFirewall.AllowProgram(ai.AssemblyProduct, servicePath, WindowsFirewall.Direction.IN); WindowsFirewall.AllowProgram(ai.AssemblyProduct, servicePath, WindowsFirewall.Direction.OUT); WindowsFirewall.DeleteRule(ffmpegFirewallRuleName); WindowsFirewall.AllowProgram(ffmpegFirewallRuleName, PathRoutines.GetDirFromPath(servicePath) + "\\ffmpeg.exe", WindowsFirewall.Direction.OUT); } catch (Exception e) { MessageBox.Show("You'll may need to set firewall manually because of the following error that happened while setting firewall:\r\n" + e.Message, "Cistera Screen Capture", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // throw e; } }; }