예제 #1
0
        public void Set(IEnumerable <StatusLine> NewLines, StatusLine NewCaption, StatusLine NewAlert, Color?NewTintColor)
        {
            if (Resources == null)
            {
                Resources = new StatusElementResources(Font);
            }

            if (TintColor != NewTintColor)
            {
                Invalidate();
            }

            InvalidateElements();
            Lines.Clear();
            Lines.AddRange(NewLines);
            Caption   = NewCaption;
            Alert     = NewAlert;
            TintColor = NewTintColor;
            LayoutElements();
            InvalidateElements();

            MouseOverElement = null;
            MouseDownElement = null;
            SetMouseOverLocation(MouseOverLocation);
            SetMouseDownLocation(MouseDownLocation);
        }
예제 #2
0
        private void SetupDefaultControl()
        {
            List <StatusLine> Lines = new List <StatusLine>();

            StatusLine SummaryLine = new StatusLine();

            SummaryLine.AddText("To get started, open an existing Unreal project file on your hard drive.");
            Lines.Add(SummaryLine);

            StatusLine OpenLine = new StatusLine();

            OpenLine.AddLink("Open project...", FontStyle.Bold | FontStyle.Underline, () => { BrowseForProject(); });
            Lines.Add(OpenLine);

            DefaultControl.Set(Lines);
        }
예제 #3
0
 public void Clear()
 {
     InvalidateElements();
     Lines.Clear();
     Caption = null;
 }
예제 #4
0
        private void CreateErrorPanel(int ReplaceTabIdx, UserSelectedProjectSettings Project, string Message)
        {
            Log.WriteLine(Message ?? "Unknown error");

            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.Dock        = DockStyle.Fill;
            ErrorPanel.Hide();

            string SummaryText = String.Format("Unable to open '{0}'.", Project.ToString());

            int NewContentWidth = Math.Max(TextRenderer.MeasureText(SummaryText, ErrorPanel.Font).Width, 400);

            if (!String.IsNullOrEmpty(Message))
            {
                NewContentWidth = Math.Max(NewContentWidth, TextRenderer.MeasureText(Message, ErrorPanel.Font).Width);
            }

            ErrorPanel.SetContentWidth(NewContentWidth);

            List <StatusLine> Lines = new List <StatusLine>();

            StatusLine SummaryLine = new StatusLine();

            SummaryLine.AddText(SummaryText);
            Lines.Add(SummaryLine);

            if (!String.IsNullOrEmpty(Message))
            {
                Lines.Add(new StatusLine()
                {
                    LineHeight = 0.5f
                });

                foreach (string MessageLine in Message.Split('\n'))
                {
                    StatusLine ErrorLine = new StatusLine();
                    ErrorLine.AddText(MessageLine);
                    ErrorLine.LineHeight = 0.8f;
                    Lines.Add(ErrorLine);
                }
            }

            Lines.Add(new StatusLine()
            {
                LineHeight = 0.5f
            });

            StatusLine ActionLine = new StatusLine();

            ActionLine.AddLink("Retry", FontStyle.Bold | FontStyle.Underline, () => { BeginInvoke(new MethodInvoker(() => { TryOpenProject(Project, TabControl.FindTabIndex(ErrorPanel)); })); });
            ActionLine.AddText(" | ");
            ActionLine.AddLink("Settings", FontStyle.Bold | FontStyle.Underline, () => { BeginInvoke(new MethodInvoker(() => { EditSelectedProject(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();
        }
예제 #5
0
        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();
        }
예제 #6
0
		private void UpdateStatusPanel()
		{
			int NewContentWidth = Math.Max(TextRenderer.MeasureText(String.Format("Last synced to {0} at changelist 123456789. 12 users are on a newer build.        | Sync Now | Sync To...", StreamName ?? ""), StatusPanel.Font).Width, 400);
			StatusPanel.SetContentWidth(NewContentWidth);

			List<StatusLine> Lines = new List<StatusLine>();
			if(Workspace == null)
			{
				StatusLine SummaryLine = new StatusLine();
				SummaryLine.AddText("To get started, open an existing Unreal project file on your hard drive.");
				Lines.Add(SummaryLine);

				StatusLine OpenLine = new StatusLine();
				OpenLine.AddLink("Open project...", FontStyle.Bold | FontStyle.Underline, () => { BrowseForProject(); });
				Lines.Add(OpenLine);
			}
			else if(Workspace.IsBusy())
			{
				// Sync in progress
				Tuple<string, float> Progress = Workspace.CurrentProgress;

				StatusLine SummaryLine = new StatusLine();
				SummaryLine.AddText("Updating to changelist ");
				SummaryLine.AddLink(Workspace.PendingChangeNumber.ToString(), FontStyle.Regular, () => { SelectChange(Workspace.PendingChangeNumber); });
				SummaryLine.AddText("... | ");
				SummaryLine.AddLink(Splitter.IsLogVisible()? "Hide Log" : "Show Log", FontStyle.Bold | FontStyle.Underline, () => { ToggleLogVisibility(); });
				SummaryLine.AddText(" | ");
				SummaryLine.AddLink("Cancel", FontStyle.Bold | FontStyle.Underline, () => { CancelWorkspaceUpdate(); });
				Lines.Add(SummaryLine);

				StatusLine ProgressLine = new StatusLine();
				ProgressLine.AddText(String.Format("{0}  ", Progress.Item1));
				if(Progress.Item2 > 0.0f) ProgressLine.AddProgressBar(Progress.Item2);
				Lines.Add(ProgressLine);
			}
			else
			{
				// Sync status
				StatusLine SummaryLine = new StatusLine();
				if(Workspace.CurrentChangeNumber != -1)
				{
					if(StreamName == null)
					{
						SummaryLine.AddText("Last synced to changelist ");
					}
					else
					{
						SummaryLine.AddText("Last synced to ");
						SummaryLine.AddLink(StreamName + "\u25BE", FontStyle.Regular, (P, R) => { SelectOtherStream(R); });
						SummaryLine.AddText(" at changelist ");
					}
					SummaryLine.AddLink(String.Format("{0}.", Workspace.CurrentChangeNumber), FontStyle.Regular, () => { SelectChange(Workspace.CurrentChangeNumber); });
					int NumUsersOnNewerChange = SortedChangeNumbers.Where(x => (x > Workspace.CurrentChangeNumber)).OrderByDescending(x => x).Select(x => EventMonitor.GetSummaryForChange(x)).Where(x => x != null && (!ShouldSyncPrecompiledEditor || GetArchivePathForChangeNumber(x.ChangeNumber) != null)).Sum(x => x.CurrentUsers.Count);
					if(NumUsersOnNewerChange > 0)
					{
						SummaryLine.AddText((NumUsersOnNewerChange == 1)? " 1 user is on a newer build." : String.Format(" {0} users are on a newer build.", NumUsersOnNewerChange));
					}
				}
				else
				{
					SummaryLine.AddText("You are not currently synced to ");
					if(StreamName == null)
					{
						SummaryLine.AddText("this branch.");
					}
					else
					{
						SummaryLine.AddLink(StreamName + " \u25BE", FontStyle.Regular, (P, R) => { SelectOtherStream(R); });
					}
				}
				SummaryLine.AddText("  |  ");
				SummaryLine.AddLink("Sync Now", FontStyle.Bold | FontStyle.Underline, () => { SyncLatestChange(); });
				SummaryLine.AddText(" - ");
				SummaryLine.AddLink(" To... \u25BE", 0, (P, R) => { ShowSyncMenu(R); });
				Lines.Add(SummaryLine);

				// Programs
				StatusLine ProgramsLine = new StatusLine();
				if(Workspace.CurrentChangeNumber != -1)
				{
					ProgramsLine.AddLink("Unreal Editor", FontStyle.Regular, () => { LaunchEditor(); });
					ProgramsLine.AddText("  |  ");
				}
				ProgramsLine.AddLink("Perforce", FontStyle.Regular, () => { OpenPerforce(); });
				ProgramsLine.AddText("  |  ");
				ProgramsLine.AddLink("Visual Studio", FontStyle.Regular, () => { OpenSolution(); });
				ProgramsLine.AddText("  |  ");
				ProgramsLine.AddLink("Windows Explorer", FontStyle.Regular, () => { Process.Start("explorer.exe", String.Format("\"{0}\"", Path.GetDirectoryName(SelectedFileName))); });
				ProgramsLine.AddText("  |  ");
				ProgramsLine.AddLink("More... \u25BE", FontStyle.Regular, (P, R) => { ShowActionsMenu(R); });
				Lines.Add(ProgramsLine);

				// Get the summary of the last sync
				if(Settings.CurrentWorkspace.LastSyncChangeNumber > 0)
				{
					string SummaryText;
					if(Settings.CurrentWorkspace.LastSyncChangeNumber == Workspace.CurrentChangeNumber && Settings.CurrentWorkspace.LastSyncResult == WorkspaceUpdateResult.Success && Settings.CurrentWorkspace.LastSyncTime.HasValue)
					{
						Lines.Add(new StatusLine());

						StatusLine SuccessLine = new StatusLine();
						SuccessLine.AddIcon(Properties.Resources.StatusIcons, new Size(16, 16), 0);
						SuccessLine.AddText(String.Format("  Sync took {0}{1}s, completed at {2}.", (Settings.CurrentWorkspace.LastSyncDurationSeconds >= 60)? String.Format("{0}m ", Settings.CurrentWorkspace.LastSyncDurationSeconds / 60) : "", Settings.CurrentWorkspace.LastSyncDurationSeconds % 60, Settings.CurrentWorkspace.LastSyncTime.Value.ToLocalTime().ToString("h\\:mmtt").ToLowerInvariant()));
						Lines.Add(SuccessLine);
					}
					else if(GetLastUpdateMessage(Settings.CurrentWorkspace.LastSyncResult, Settings.CurrentWorkspace.LastSyncResultMessage, out SummaryText))
					{
						Lines.Add(new StatusLine());

						int SummaryTextLength = SummaryText.IndexOf('\n');
						if(SummaryTextLength == -1)
						{
							SummaryTextLength = SummaryText.Length;
						}
						SummaryTextLength = Math.Min(SummaryTextLength, 80);

						StatusLine FailLine = new StatusLine();
						FailLine.AddIcon(Properties.Resources.StatusIcons, new Size(16, 16), 1);

						if(SummaryTextLength == SummaryText.Length)
						{
							FailLine.AddText(String.Format("  {0}  ", SummaryText));
						}
						else 
						{
							FailLine.AddText(String.Format("  {0}...  ", SummaryText.Substring(0, SummaryTextLength).TrimEnd()));
							FailLine.AddLink("More...", FontStyle.Bold | FontStyle.Underline, () => { ViewLastSyncStatus(); });
							FailLine.AddText("  |  ");
						}
						FailLine.AddLink("Show Log", FontStyle.Bold | FontStyle.Underline, () => { ShowErrorInLog(); });
						Lines.Add(FailLine);
					}
				}
			}
			StatusPanel.Set(Lines);
		}