Skip to content

Commit

Permalink
MyraPad Refactoring: Move most of the logic to StudioWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
rds1983 committed Sep 18, 2024
1 parent c7626d4 commit e306fe9
Show file tree
Hide file tree
Showing 7 changed files with 1,625 additions and 1,587 deletions.
2 changes: 1 addition & 1 deletion src/Myra/Graphics2D/UI/Simple/TextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ private bool ShouldEnableHintText()
private void UpdateScrolling()
{
var p = GetRenderPositionByIndex(CursorPosition);
if (p == _lastCursorPosition)
if (p == _lastCursorPosition || Desktop == null)
{
return;
}
Expand Down
18 changes: 9 additions & 9 deletions src/MyraPad/AsyncTasksQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,31 @@ private void RefreshProc(object state)
{
try
{
Studio.Instance.QueueSetStatusText("Reloading Project...");
Studio.Instance.NewProject = Project.LoadFromXml(_projectXml, Studio.Instance.AssetManager);
Studio.Instance.QueueSetStatusText(string.Empty);
Studio.MainForm.QueueSetStatusText("Reloading Project...");
Studio.MainForm.NewProject = Project.LoadFromXml(_projectXml, Studio.MainForm.AssetManager);
Studio.MainForm.QueueSetStatusText(string.Empty);
}
catch (Exception ex)
{
Studio.Instance.QueueSetStatusText(ex.Message);
Studio.MainForm.QueueSetStatusText(ex.Message);
}

_projectXml = null;
}

if (!string.IsNullOrEmpty(_objectXml))
{
if (Studio.Instance.Project != null)
if (Studio.MainForm.Project != null)
{
try
{
Studio.Instance.QueueSetStatusText("Reloading Object...");
Studio.Instance.NewObject = Studio.Instance.Project.LoadObjectFromXml(_objectXml, Studio.Instance.AssetManager);
Studio.Instance.QueueSetStatusText(string.Empty);
Studio.MainForm.QueueSetStatusText("Reloading Object...");
Studio.MainForm.NewObject = Studio.MainForm.Project.LoadObjectFromXml(_objectXml, Studio.MainForm.AssetManager);
Studio.MainForm.QueueSetStatusText(string.Empty);
}
catch (Exception ex)
{
Studio.Instance.QueueSetStatusText(ex.Message);
Studio.MainForm.QueueSetStatusText(ex.Message);
}
}

Expand Down
15 changes: 9 additions & 6 deletions src/MyraPad/State.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ public static string StateFilePath
}

public Point Size { get; set; }
public float TopSplitterPosition { get; set; }
public float LeftSplitterPosition { get; set; }
public float TopSplitterPosition1 { get; set; } = 0.25f;
public float TopSplitterPosition2 { get; set; } = 0.75f;
public float CenterSplitterPosition { get; set; } = 0.5f;
public string EditedFile { get; set; }
public string LastFolder { get; set; }
public Color[] UserColors { get; set; }
Expand Down Expand Up @@ -74,14 +75,16 @@ public override string ToString()
colors = string.Join(", ", from c in UserColors select c.ToHexString());
}
return string.Format("Size = {0}\n" +
"TopSplitter = {1:0.##}\n" +
"LeftSplitter= {2:0.##}\n" +
"TopSplitter1 = {1:0.##}\n" +
"TopSplitter2 = {2:0.##}\n" +
"CenterSplitter = {2:0.##}\n" +
"EditedFile = {3}\n" +
"LastFolder = {4}\n" +
"UserColors = {5}",
Size,
TopSplitterPosition,
LeftSplitterPosition,
TopSplitterPosition1,
TopSplitterPosition2,
CenterSplitterPosition,
EditedFile,
LastFolder,
colors);
Expand Down
Loading

0 comments on commit e306fe9

Please sign in to comment.