private void ShowErrorDialog(string Format, params object[] Args) { string Message = String.Format(Format, Args); Log.WriteLine(Message); MessageBox.Show(Message); }
bool SendTimingData(TelemetryTimingData Data, string Version, string IpAddress) { try { Stopwatch Timer = Stopwatch.StartNew(); LogWriter.WriteLine("Posting timing data... ({0}, {1}, {2}, {3}, {4}, {5})", Data.Action, Data.Result, Data.UserName, Data.Project, Data.Timestamp, Data.Duration); using (SqlConnection Connection = new SqlConnection(SqlConnectionString)) { Connection.Open(); using (SqlCommand Command = new SqlCommand("INSERT INTO dbo.[Telemetry.v2] (Action, Result, UserName, Project, Timestamp, Duration, Version, IpAddress) VALUES (@Action, @Result, @UserName, @Project, @Timestamp, @Duration, @Version, @IpAddress)", Connection)) { Command.Parameters.AddWithValue("@Action", Data.Action); Command.Parameters.AddWithValue("@Result", Data.Result); Command.Parameters.AddWithValue("@UserName", Data.UserName); Command.Parameters.AddWithValue("@Project", Data.Project); Command.Parameters.AddWithValue("@Timestamp", Data.Timestamp); Command.Parameters.AddWithValue("@Duration", Data.Duration); Command.Parameters.AddWithValue("@Version", Version); Command.Parameters.AddWithValue("@IPAddress", IpAddress); Command.ExecuteNonQuery(); } } LogWriter.WriteLine("Done in {0}ms.", Timer.ElapsedMilliseconds); return(true); } catch (Exception Ex) { LogWriter.WriteException(Ex, "Failed with exception."); return(false); } }
public EventMonitor(string InApiUrl, string InProject, string InCurrentUserName, string InLogFileName) { ApiUrl = InApiUrl; Project = InProject; CurrentUserName = InCurrentUserName; LatestIds = new LatestData { LastBuildId = 0, LastCommentId = 0, LastEventId = 0 }; MetadataStream = Project.ToLowerInvariant().TrimEnd('/'); if (MetadataStream.StartsWith("//", StringComparison.Ordinal)) { int NextIdx = MetadataStream.IndexOf('/', 2); if (NextIdx != -1) { NextIdx = MetadataStream.IndexOf('/', NextIdx + 1); if (NextIdx != -1) { MetadataProject = MetadataStream.Substring(NextIdx + 1); MetadataStream = MetadataStream.Substring(0, NextIdx); } } } LogWriter = new BoundedLogWriter(InLogFileName); if (ApiUrl == null) { LastStatusMessage = "Database functionality disabled due to empty ApiUrl."; } else { LogWriter.WriteLine("Using connection string: {0}", ApiUrl); } }
bool SendTimingData(TelemetryTimingData Data, string Version, string IpAddress) { try { Stopwatch Timer = Stopwatch.StartNew(); LogWriter.WriteLine("Posting timing data... ({0}, {1}, {2}, {3}, {4}, {5})", Data.Action, Data.Result, Data.UserName, Data.Project, Data.Timestamp, Data.Duration); RESTApi.POST(ApiUrl, "telemetry", new JavaScriptSerializer().Serialize(Data), string.Format("Version={0}", Version), string.Format("IpAddress={0}", IpAddress)); LogWriter.WriteLine("Done in {0}ms.", Timer.ElapsedMilliseconds); return(true); } catch (Exception Ex) { LogWriter.WriteException(Ex, "Failed with exception."); return(false); } }
bool SendEventToBackend(EventData Event) { try { Stopwatch Timer = Stopwatch.StartNew(); LogWriter.WriteLine("Posting event... ({0}, {1}, {2})", Event.Change, Event.UserName, Event.Type); using (SqlConnection Connection = new SqlConnection(SqlConnectionString)) { Connection.Open(); using (SqlCommand Command = new SqlCommand("INSERT INTO dbo.UserVotes (Changelist, UserName, Verdict, Project) VALUES (@Changelist, @UserName, @Verdict, @Project)", Connection)) { Command.Parameters.AddWithValue("@Changelist", Event.Change); Command.Parameters.AddWithValue("@UserName", Event.UserName.ToString()); Command.Parameters.AddWithValue("@Verdict", Event.Type.ToString()); Command.Parameters.AddWithValue("@Project", Event.Project); Command.ExecuteNonQuery(); } } LogWriter.WriteLine("Done in {0}ms.", Timer.ElapsedMilliseconds); return(true); } catch (Exception Ex) { LogWriter.WriteException(Ex, "Failed with exception."); return(false); } }
public TelemetryWriter(string InSqlConnectionString, string InLogFileName) { Instance = this; SqlConnectionString = InSqlConnectionString; LogWriter = new BoundedLogWriter(InLogFileName); LogWriter.WriteLine("Using connection string: {0}", SqlConnectionString); WorkerThread = new Thread(() => WorkerThreadCallback()); WorkerThread.Start(); }
public TelemetryWriter(string InApiUrl, string InLogFileName) { Instance = this; ApiUrl = InApiUrl; LogWriter = new BoundedLogWriter(InLogFileName); LogWriter.WriteLine("Using connection string: {0}", ApiUrl); WorkerThread = new Thread(() => WorkerThreadCallback()); WorkerThread.Start(); }
public EventMonitor(string InApiUrl, string InProject, string InCurrentUserName, string InLogFileName) { ApiUrl = InApiUrl; Project = InProject; CurrentUserName = InCurrentUserName; LogWriter = new BoundedLogWriter(InLogFileName); if (ApiUrl == null) { LastStatusMessage = "Database functionality disabled due to empty ApiUrl."; } else { LogWriter.WriteLine("Using connection string: {0}", ApiUrl); } }
public EventMonitor(string InSqlConnectionString, string InProject, string InCurrentUserName, string InLogFileName) { SqlConnectionString = InSqlConnectionString; Project = InProject; CurrentUserName = InCurrentUserName; LogWriter = new BoundedLogWriter(InLogFileName); if (SqlConnectionString == null) { LastStatusMessage = "Database functionality disabled due to empty SqlConnectionString."; } else { LogWriter.WriteLine("Using connection string: {0}", SqlConnectionString); } }
public IssueMonitor(string ApiUrl, string UserName, TimeSpan UpdateInterval, string LogFileName) { this.ApiUrl = ApiUrl; this.UserName = UserName; this.UpdateIntervalMs = (int)UpdateInterval.TotalMilliseconds; LogWriter = new BoundedLogWriter(LogFileName); if (ApiUrl == null) { LastStatusMessage = "Database functionality disabled due to empty ApiUrl."; } else { LogWriter.WriteLine("Using connection string: {0}", this.ApiUrl); } RefreshEvent = new AutoResetEvent(false); }
bool SendEventToBackend(EventData Event) { try { Stopwatch Timer = Stopwatch.StartNew(); LogWriter.WriteLine("Posting event... ({0}, {1}, {2})", Event.Change, Event.UserName, Event.Type); RESTApi.POST(ApiUrl, "event", new JavaScriptSerializer().Serialize(Event)); return(true); } catch (Exception Ex) { LogWriter.WriteException(Ex, "Failed with exception."); return(false); } }
private void CreateErrorPanel(int ReplaceTabIdx, UserSelectedProjectSettings Project, string Message) { Log.WriteLine(Message); ErrorPanel ErrorPanel = new ErrorPanel(Project); ErrorPanel.Parent = TabPanel; ErrorPanel.BorderStyle = BorderStyle.FixedSingle; ErrorPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(250)))), ((int)(((byte)(250)))), ((int)(((byte)(250))))); ErrorPanel.Location = new Point(0, 0); ErrorPanel.Size = new Size(TabPanel.Width, TabPanel.Height); ErrorPanel.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; ErrorPanel.Hide(); string SummaryText = String.Format("Unable to open '{0}'.", Project.ToString()); int NewContentWidth = Math.Max(Math.Max(TextRenderer.MeasureText(SummaryText, ErrorPanel.Font).Width, TextRenderer.MeasureText(Message, ErrorPanel.Font).Width), 400); ErrorPanel.SetContentWidth(NewContentWidth); List <StatusLine> Lines = new List <StatusLine>(); StatusLine SummaryLine = new StatusLine(); SummaryLine.AddText(SummaryText); Lines.Add(SummaryLine); Lines.Add(new StatusLine() { LineHeight = 0.5f }); StatusLine ErrorLine = new StatusLine(); ErrorLine.AddText(Message); Lines.Add(ErrorLine); Lines.Add(new StatusLine() { LineHeight = 0.5f }); StatusLine ActionLine = new StatusLine(); ActionLine.AddLink("Open...", FontStyle.Bold | FontStyle.Underline, () => { BeginInvoke(new MethodInvoker(() => { EditSelectedProject(ErrorPanel); })); }); ActionLine.AddText(" | "); ActionLine.AddLink("Retry", FontStyle.Bold | FontStyle.Underline, () => { BeginInvoke(new MethodInvoker(() => { TryOpenProject(Project, TabControl.FindTabIndex(ErrorPanel)); })); }); ActionLine.AddText(" | "); ActionLine.AddLink("Close", FontStyle.Bold | FontStyle.Underline, () => { BeginInvoke(new MethodInvoker(() => { TabControl.RemoveTab(TabControl.FindTabIndex(ErrorPanel)); })); }); Lines.Add(ActionLine); ErrorPanel.Set(Lines, null, null, null); string NewProjectName = "Unknown"; if (Project.Type == UserSelectedProjectType.Client && Project.ClientPath != null) { NewProjectName = Project.ClientPath.Substring(Project.ClientPath.LastIndexOf('/') + 1); } if (Project.Type == UserSelectedProjectType.Local && Project.LocalPath != null) { NewProjectName = Project.LocalPath.Substring(Project.LocalPath.LastIndexOfAny(new char[] { '/', '\\' }) + 1); } string NewTabName = String.Format("Error: {0}", NewProjectName); if (ReplaceTabIdx == -1) { int TabIdx = TabControl.InsertTab(-1, NewTabName, ErrorPanel); TabControl.SelectTab(TabIdx); } else { TabControl.InsertTab(ReplaceTabIdx + 1, NewTabName, ErrorPanel); TabControl.RemoveTab(ReplaceTabIdx); TabControl.SelectTab(ReplaceTabIdx); } UpdateProgress(); }
bool ReadCurrentIssues() { try { Stopwatch Timer = Stopwatch.StartNew(); LogWriter.WriteLine(); LogWriter.WriteLine("Polling for notifications at {0}...", DateTime.Now.ToString()); // Get the initial number of issues. We won't post updates if this stays at zero. int InitialNumIssues = Issues.Count; // Fetch the new issues List <IssueData> NewIssues = RESTApi.GET <List <IssueData> >(ApiUrl, String.Format("issues?user={0}", UserName)); // Check if we're tracking a particular issue. If so, we want updates even when it's resolved. long[] LocalTrackingIssueIds; lock (LockObject) { LocalTrackingIssueIds = TrackingIssueIds.Distinct().ToArray(); } foreach (long LocalTrackingIssueId in LocalTrackingIssueIds) { if (!NewIssues.Any(x => x.Id == LocalTrackingIssueId)) { try { IssueData Issue = RESTApi.GET <IssueData>(ApiUrl, String.Format("issues/{0}", LocalTrackingIssueId)); if (Issue != null) { NewIssues.Add(Issue); } } catch (Exception Ex) { LogWriter.WriteException(Ex, "Exception while fetching tracked issue"); } } } // Update all the builds for each issue foreach (IssueData NewIssue in NewIssues) { NewIssue.Builds = RESTApi.GET <List <IssueBuildData> >(ApiUrl, String.Format("issues/{0}/builds", NewIssue.Id)); } // Apply any pending updates to this issue list, and update it lock (LockObject) { foreach (IssueUpdateData PendingUpdate in PendingUpdates) { ApplyPendingUpdate(NewIssues, PendingUpdate); } Issues = NewIssues; } // Update the main thread if (InitialNumIssues > 0 || Issues.Count > 0) { if (OnIssuesChanged != null) { OnIssuesChanged(); } } // Update the stats LastStatusMessage = String.Format("Last update took {0}ms", Timer.ElapsedMilliseconds); LogWriter.WriteLine("Done in {0}ms.", Timer.ElapsedMilliseconds); return(true); } catch (Exception Ex) { LogWriter.WriteException(Ex, "Failed with exception."); LastStatusMessage = String.Format("Last update failed: ({0})", Ex.ToString()); return(false); } }
static void InnerMain(Mutex InstanceMutex, EventWaitHandle ActivateEvent, string[] Args) { List <string> RemainingArgs = new List <string>(Args); string UpdatePath; ParseArgument(RemainingArgs, "-updatepath=", out UpdatePath); string UpdateSpawn; ParseArgument(RemainingArgs, "-updatespawn=", out UpdateSpawn); bool bRestoreState; ParseOption(RemainingArgs, "-restorestate", out bRestoreState); bool bUnstable; ParseOption(RemainingArgs, "-unstable", out bUnstable); string ProjectFileName; ParseArgument(RemainingArgs, "-project=", out ProjectFileName); string UpdateConfigFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "AutoUpdate.ini"); MergeUpdateSettings(UpdateConfigFile, ref UpdatePath, ref UpdateSpawn); string SyncVersionFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "SyncVersion.txt"); if (File.Exists(SyncVersionFile)) { try { SyncVersion = File.ReadAllText(SyncVersionFile).Trim(); } catch (Exception) { SyncVersion = null; } } string DataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "UnrealGameSync"); Directory.CreateDirectory(DataFolder); using (TelemetryWriter Telemetry = new TelemetryWriter(SqlConnectionString, Path.Combine(DataFolder, "Telemetry.log"))) { try { using (UpdateMonitor UpdateMonitor = new UpdateMonitor(new PerforceConnection(null, null, null), UpdatePath)) { using (BoundedLogWriter Log = new BoundedLogWriter(Path.Combine(DataFolder, "UnrealGameSync.log"))) { Log.WriteLine("Application version: {0}", Assembly.GetExecutingAssembly().GetName().Version); Log.WriteLine("Started at {0}", DateTime.Now.ToString()); UserSettings Settings = new UserSettings(Path.Combine(DataFolder, "UnrealGameSync.ini")); if (!String.IsNullOrEmpty(ProjectFileName)) { string FullProjectFileName = Path.GetFullPath(ProjectFileName); if (!Settings.OpenProjectFileNames.Any(x => x.Equals(FullProjectFileName, StringComparison.InvariantCultureIgnoreCase))) { Settings.OpenProjectFileNames = Settings.OpenProjectFileNames.Concat(new string[] { FullProjectFileName }).ToArray(); } } MainWindow Window = new MainWindow(UpdateMonitor, SqlConnectionString, DataFolder, ActivateEvent, bRestoreState, UpdateSpawn ?? Assembly.GetExecutingAssembly().Location, ProjectFileName, bUnstable, Log, Settings); if (bUnstable) { Window.Text += String.Format(" (UNSTABLE BUILD {0})", Assembly.GetExecutingAssembly().GetName().Version); } Application.Run(Window); } if (UpdateMonitor.IsUpdateAvailable && UpdateSpawn != null) { InstanceMutex.Close(); Utility.SpawnProcess(UpdateSpawn, "-restorestate" + (bUnstable? " -unstable" : "")); } } } catch (Exception Ex) { TelemetryWriter.Enqueue(TelemetryErrorType.Crash, Ex.ToString(), null, DateTime.Now); MessageBox.Show(String.Format("UnrealGameSync has crashed.\n\n{0}", Ex.ToString())); } } }
private void CreateErrorPanel(int ReplaceTabIdx, string ProjectFileName, string Message) { Log.WriteLine(Message); ErrorPanel ErrorPanel = new ErrorPanel(ProjectFileName); ErrorPanel.Parent = TabPanel; ErrorPanel.BorderStyle = BorderStyle.FixedSingle; ErrorPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(250)))), ((int)(((byte)(250)))), ((int)(((byte)(250))))); ErrorPanel.Location = new Point(0, 0); ErrorPanel.Size = new Size(TabPanel.Width, TabPanel.Height); ErrorPanel.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; ErrorPanel.Hide(); string SummaryText = String.Format("Unable to open '{0}'.", ProjectFileName); int NewContentWidth = Math.Max(Math.Max(TextRenderer.MeasureText(SummaryText, ErrorPanel.Font).Width, TextRenderer.MeasureText(Message, ErrorPanel.Font).Width), 400); ErrorPanel.SetContentWidth(NewContentWidth); List <StatusLine> Lines = new List <StatusLine>(); StatusLine SummaryLine = new StatusLine(); SummaryLine.AddText(SummaryText); Lines.Add(SummaryLine); Lines.Add(new StatusLine() { LineHeight = 0.5f }); StatusLine ErrorLine = new StatusLine(); ErrorLine.AddText(Message); Lines.Add(ErrorLine); Lines.Add(new StatusLine() { LineHeight = 0.5f }); StatusLine ActionLine = new StatusLine(); ActionLine.AddLink("Close", FontStyle.Bold | FontStyle.Underline, () => { BeginInvoke(new MethodInvoker(() => { TabControl.RemoveTab(TabControl.FindTabIndex(ErrorPanel)); })); }); ActionLine.AddText(" | "); ActionLine.AddLink("Retry", FontStyle.Bold | FontStyle.Underline, () => { BeginInvoke(new MethodInvoker(() => { TryOpenProject(ProjectFileName, TabControl.FindTabIndex(ErrorPanel)); })); }); ActionLine.AddText(" | "); ActionLine.AddLink("Open another...", FontStyle.Bold | FontStyle.Underline, () => { BeginInvoke(new MethodInvoker(() => { BrowseForProject(TabControl.FindTabIndex(ErrorPanel)); })); }); Lines.Add(ActionLine); ErrorPanel.Set(Lines); string NewTabName = "Error: " + Path.GetFileName(ProjectFileName); if (ReplaceTabIdx == -1) { int TabIdx = TabControl.InsertTab(-1, NewTabName, ErrorPanel); TabControl.SelectTab(TabIdx); } else { TabControl.InsertTab(ReplaceTabIdx + 1, NewTabName, ErrorPanel); TabControl.RemoveTab(ReplaceTabIdx); TabControl.SelectTab(ReplaceTabIdx); } UpdateProgress(); }
static void InnerMain(Mutex InstanceMutex, EventWaitHandle ActivateEvent, string[] Args) { string ServerAndPort = null; string UserName = null; string BaseUpdatePath = null; Utility.ReadGlobalPerforceSettings(ref ServerAndPort, ref UserName, ref BaseUpdatePath); List <string> RemainingArgs = new List <string>(Args); string UpdateSpawn; ParseArgument(RemainingArgs, "-updatespawn=", out UpdateSpawn); string UpdatePath; ParseArgument(RemainingArgs, "-updatepath=", out UpdatePath); bool bRestoreState; ParseOption(RemainingArgs, "-restorestate", out bRestoreState); bool bUnstable; ParseOption(RemainingArgs, "-unstable", out bUnstable); string ProjectFileName; ParseArgument(RemainingArgs, "-project=", out ProjectFileName); string UpdateConfigFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "AutoUpdate.ini"); MergeUpdateSettings(UpdateConfigFile, ref UpdatePath, ref UpdateSpawn); string SyncVersionFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "SyncVersion.txt"); if (File.Exists(SyncVersionFile)) { try { SyncVersion = File.ReadAllText(SyncVersionFile).Trim(); } catch (Exception) { SyncVersion = null; } } string DataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "UnrealGameSync"); Directory.CreateDirectory(DataFolder); // Create the log file using (TimestampLogWriter Log = new TimestampLogWriter(new BoundedLogWriter(Path.Combine(DataFolder, "UnrealGameSync.log")))) { Log.WriteLine("Application version: {0}", Assembly.GetExecutingAssembly().GetName().Version); Log.WriteLine("Started at {0}", DateTime.Now.ToString()); string SessionId = Guid.NewGuid().ToString(); Log.WriteLine("SessionId: {0}", SessionId); if (ServerAndPort == null || UserName == null) { Log.WriteLine("Missing server settings; finding defaults."); GetDefaultServerSettings(ref ServerAndPort, ref UserName, Log); Utility.SaveGlobalPerforceSettings(ServerAndPort, UserName, BaseUpdatePath); } using (BoundedLogWriter TelemetryLog = new BoundedLogWriter(Path.Combine(DataFolder, "Telemetry.log"))) { TelemetryLog.WriteLine("Creating telemetry sink for session {0}", SessionId); ITelemetrySink PrevTelemetrySink = Telemetry.ActiveSink; using (ITelemetrySink TelemetrySink = DeploymentSettings.CreateTelemetrySink(UserName, SessionId, TelemetryLog)) { Telemetry.ActiveSink = TelemetrySink; Telemetry.SendEvent("Startup", new { User = Environment.UserName, Machine = Environment.MachineName }); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; PerforceConnection DefaultConnection = new PerforceConnection(UserName, null, ServerAndPort); using (UpdateMonitor UpdateMonitor = new UpdateMonitor(DefaultConnection, UpdatePath)) { ProgramApplicationContext Context = new ProgramApplicationContext(DefaultConnection, UpdateMonitor, DeploymentSettings.ApiUrl, DataFolder, ActivateEvent, bRestoreState, UpdateSpawn, ProjectFileName, bUnstable, Log); Application.Run(Context); if (UpdateMonitor.IsUpdateAvailable && UpdateSpawn != null) { InstanceMutex.Close(); bool bLaunchUnstable = UpdateMonitor.RelaunchUnstable ?? bUnstable; Utility.SpawnProcess(UpdateSpawn, "-restorestate" + (bLaunchUnstable ? " -unstable" : "")); } } } Telemetry.ActiveSink = PrevTelemetrySink; } } }
public TelemetryWriter(string InSqlConnectionString, string InLogFileName) { Instance = this; SqlConnectionString = InSqlConnectionString; LogWriter = new BoundedLogWriter(InLogFileName); LogWriter.WriteLine("Using connection string: {0}", SqlConnectionString); WorkerThread = new Thread(() => WorkerThreadCallback()); WorkerThread.Start(); }
public ProgramApplicationContext(UpdateMonitor UpdateMonitor, string ApiUrl, string DataFolder, EventWaitHandle ActivateEvent, bool bRestoreState, string UpdateSpawn, string ProjectFileName, bool bUnstable) { this.UpdateMonitor = UpdateMonitor; this.ApiUrl = ApiUrl; this.DataFolder = DataFolder; this.bRestoreState = bRestoreState; this.UpdateSpawn = UpdateSpawn; this.bUnstable = bUnstable; // Make sure a synchronization context is set. We spawn a bunch of threads (eg. UpdateMonitor) at startup, and need to make sure we can post messages // back to the main thread at any time. if (SynchronizationContext.Current == null) { SynchronizationContext.SetSynchronizationContext(new WindowsFormsSynchronizationContext()); } // Capture the main thread's synchronization context for callbacks MainThreadSynchronizationContext = WindowsFormsSynchronizationContext.Current; // Create the log file Log = new BoundedLogWriter(Path.Combine(DataFolder, "UnrealGameSync.log")); Log.WriteLine("Application version: {0}", Assembly.GetExecutingAssembly().GetName().Version); Log.WriteLine("Started at {0}", DateTime.Now.ToString()); // Read the user's settings Settings = new UserSettings(Path.Combine(DataFolder, "UnrealGameSync.ini")); if (!String.IsNullOrEmpty(ProjectFileName)) { string FullProjectFileName = Path.GetFullPath(ProjectFileName); if (!Settings.OpenProjects.Any(x => x.LocalPath != null && String.Compare(x.LocalPath, FullProjectFileName, StringComparison.InvariantCultureIgnoreCase) == 0)) { Settings.OpenProjects.Add(new UserSelectedProjectSettings(null, null, UserSelectedProjectType.Local, null, FullProjectFileName)); } } // Register the update listener UpdateMonitor.OnUpdateAvailable += OnUpdateAvailableCallback; // Create the activation listener ActivationListener = new ActivationListener(ActivateEvent); ActivationListener.Start(); ActivationListener.OnActivate += OnActivationListenerAsyncCallback; // Create the notification menu items NotifyMenu_OpenUnrealGameSync = new ToolStripMenuItem(); NotifyMenu_OpenUnrealGameSync.Name = nameof(NotifyMenu_OpenUnrealGameSync); NotifyMenu_OpenUnrealGameSync.Size = new Size(196, 22); NotifyMenu_OpenUnrealGameSync.Text = "Open UnrealGameSync"; NotifyMenu_OpenUnrealGameSync.Click += new EventHandler(NotifyMenu_OpenUnrealGameSync_Click); NotifyMenu_OpenUnrealGameSync.Font = new Font(NotifyMenu_OpenUnrealGameSync.Font, FontStyle.Bold); NotifyMenu_OpenUnrealGameSync_Separator = new ToolStripSeparator(); NotifyMenu_OpenUnrealGameSync_Separator.Name = nameof(NotifyMenu_OpenUnrealGameSync_Separator); NotifyMenu_OpenUnrealGameSync_Separator.Size = new Size(193, 6); NotifyMenu_SyncNow = new ToolStripMenuItem(); NotifyMenu_SyncNow.Name = nameof(NotifyMenu_SyncNow); NotifyMenu_SyncNow.Size = new Size(196, 22); NotifyMenu_SyncNow.Text = "Sync Now"; NotifyMenu_SyncNow.Click += new EventHandler(NotifyMenu_SyncNow_Click); NotifyMenu_LaunchEditor = new ToolStripMenuItem(); NotifyMenu_LaunchEditor.Name = nameof(NotifyMenu_LaunchEditor); NotifyMenu_LaunchEditor.Size = new Size(196, 22); NotifyMenu_LaunchEditor.Text = "Launch Editor"; NotifyMenu_LaunchEditor.Click += new EventHandler(NotifyMenu_LaunchEditor_Click); NotifyMenu_ExitSeparator = new ToolStripSeparator(); NotifyMenu_ExitSeparator.Name = nameof(NotifyMenu_ExitSeparator); NotifyMenu_ExitSeparator.Size = new Size(193, 6); NotifyMenu_Exit = new ToolStripMenuItem(); NotifyMenu_Exit.Name = nameof(NotifyMenu_Exit); NotifyMenu_Exit.Size = new Size(196, 22); NotifyMenu_Exit.Text = "Exit"; NotifyMenu_Exit.Click += new EventHandler(NotifyMenu_Exit_Click); // Create the notification menu NotifyMenu = new ContextMenuStrip(Components); NotifyMenu.Name = nameof(NotifyMenu); NotifyMenu.Size = new System.Drawing.Size(197, 104); NotifyMenu.SuspendLayout(); NotifyMenu.Items.Add(NotifyMenu_OpenUnrealGameSync); NotifyMenu.Items.Add(NotifyMenu_OpenUnrealGameSync_Separator); NotifyMenu.Items.Add(NotifyMenu_SyncNow); NotifyMenu.Items.Add(NotifyMenu_LaunchEditor); NotifyMenu.Items.Add(NotifyMenu_ExitSeparator); NotifyMenu.Items.Add(NotifyMenu_Exit); NotifyMenu.ResumeLayout(false); // Create the notification icon NotifyIcon = new NotifyIcon(Components); NotifyIcon.ContextMenuStrip = NotifyMenu; NotifyIcon.Icon = Properties.Resources.Icon; NotifyIcon.Text = "UnrealGameSync"; NotifyIcon.Visible = true; NotifyIcon.DoubleClick += new EventHandler(NotifyIcon_DoubleClick); NotifyIcon.MouseDown += new MouseEventHandler(NotifyIcon_MouseDown); // Find the initial list of projects to attempt to reopen List <DetectProjectSettingsTask> Tasks = new List <DetectProjectSettingsTask>(); foreach (UserSelectedProjectSettings OpenProject in Settings.OpenProjects) { Tasks.Add(new DetectProjectSettingsTask(OpenProject, DataFolder, Log)); } // Detect settings for the project we want to open DetectStartupProjectSettingsTask = new DetectMultipleProjectSettingsTask(Tasks); DetectStartupProjectSettingsWindow = new ModalTaskWindow(DetectStartupProjectSettingsTask, "Opening Projects", "Opening projects, please wait...", FormStartPosition.CenterScreen); if (Settings.bWindowVisible) { DetectStartupProjectSettingsWindow.Show(); if (!bRestoreState) { DetectStartupProjectSettingsWindow.Activate(); } } DetectStartupProjectSettingsWindow.Complete += OnDetectStartupProjectsComplete; }
public MainWindow(UpdateMonitor InUpdateMonitor, string InSqlConnectionString, string InDataFolder, EventWaitHandle ActivateEvent, bool bInRestoreStateOnLoad, string InOriginalExecutableFileName, string InProjectFileName) { InitializeComponent(); NotifyMenu_OpenUnrealGameSync.Font = new Font(NotifyMenu_OpenUnrealGameSync.Font, FontStyle.Bold); if (Application.RenderWithVisualStyles) { SelectedItemRenderer = new VisualStyleRenderer("Explorer::ListView", 1, 3); TrackedItemRenderer = new VisualStyleRenderer("Explorer::ListView", 1, 2); } UpdateMonitor = InUpdateMonitor; ActivationListener = new ActivationListener(ActivateEvent); SqlConnectionString = InSqlConnectionString; DataFolder = InDataFolder; bRestoreStateOnLoad = bInRestoreStateOnLoad; OriginalExecutableFileName = InOriginalExecutableFileName; Log = new BoundedLogWriter(Path.Combine(DataFolder, "UnrealGameSync.log")); Log.WriteLine("Application version: {0}", Assembly.GetExecutingAssembly().GetName().Version); Log.WriteLine("Started at {0}", DateTime.Now.ToString()); Settings = new UserSettings(Path.Combine(DataFolder, "UnrealGameSync.ini")); if(!String.IsNullOrEmpty(InProjectFileName)) { Settings.LastProjectFileName = InProjectFileName; } System.Reflection.PropertyInfo DoubleBufferedProperty = typeof(Control).GetProperty("DoubleBuffered", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); DoubleBufferedProperty.SetValue(BuildList, true, null); // force the height of the rows BuildList.SmallImageList = new ImageList(){ ImageSize = new Size(1, 20) }; BuildList_FontChanged(null, null); BuildList.OnScroll += BuildList_OnScroll; Splitter.OnVisibilityChanged += Splitter_OnVisibilityChanged; UpdateTimer = new Timer(); UpdateTimer.Interval = 30; UpdateTimer.Tick += TimerCallback; BuildAfterSyncCheckBox.Checked = Settings.bBuildAfterSync; RunAfterSyncCheckBox.Checked = Settings.bRunAfterSync; OpenSolutionAfterSyncCheckBox.Checked = Settings.bOpenSolutionAfterSync; Splitter.SetLogVisibility(Settings.bShowLogWindow); OptionsContextMenu_AutoResolveConflicts.Checked = Settings.bAutoResolveConflicts; OptionsContextMenu_UseIncrementalBuilds.Checked = Settings.bUseIncrementalBuilds; OptionsContextMenu_SyncPrecompiledEditor.Checked = Settings.bSyncPrecompiledEditor; UpdateCheckedBuildConfig(); UpdateProjectList(); UpdateSyncActionCheckboxes(); }