Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving docking UX and other improvements #1723

Merged
merged 9 commits into from
May 12, 2023
74 changes: 53 additions & 21 deletions Analogy.CommonControls/UserControls/LogMessagesUC.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 27 additions & 4 deletions Analogy.CommonControls/UserControls/LogMessagesUC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
using DevExpress.XtraBars;
using DevExpress.XtraBars.Alerter;
using DevExpress.XtraBars.Docking;
using DevExpress.XtraCharts;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraEditors.Mask;
Expand Down Expand Up @@ -183,6 +184,8 @@ public bool RealTimeMode
}
}
private LogLevelSelectionType LogLevelSelectionType => Settings.LogLevelSelection;
public string? Title { get; set; }

#endregion

#region fields
Expand Down Expand Up @@ -399,7 +402,8 @@ private async void LogMessagesUC_Load(object sender, EventArgs e)
documentManager1.BeginUpdate();
documentManager1.View.ActivateDocument(dockPanelLogs);
documentManager1.EndUpdate();

LogGrid.ClearSorting();
LogGrid.Columns[DataGridDateColumnName].SortOrder = ColumnSortOrder.Ascending;
}

private void HideColumns()
Expand Down Expand Up @@ -1457,12 +1461,13 @@ public async Task LoadExtensions()
DockPanel? pnl = dockManager1.Panels.FirstOrDefault(i => i.ID == extension.Id);
if (pnl == null)
{
pnl = dockManager1.AddPanel(DockingStyle.Float);
pnl = dockPanelTree;
pnl.Text = extension.Title;
pnl.ID = extension.Id;
pnl.DockedAsTabbedDocument = true;
}
pnl.Controls.Add(extension.CreateUserControl(Id, Logger));
if (Title != null && pnl.ParentPanel != null)
pnl.ParentPanel.Text = Title;
pnl.ControlContainer.Controls.Add(extension.CreateUserControl(Id, Logger));
pnl.SizeChanged += ExtensionPanel_SizeChanged;
await extension.InitializeUserControl(this, Id, Logger);
}
Expand Down Expand Up @@ -3654,6 +3659,24 @@ public void ReportFileReadProgress(AnalogyFileReadProgress progress)
{
DataProviderProgressReporter.Report(progress);
}



public void ShowSecondaryWindow()
{
foreach (DockPanel dockPanel in dockManager1.Panels.Where(i => i.Dock == DockingStyle.Float).ToList())
{
dockPanel.Visibility = DockVisibility.Visible;
}
}

public void HideSecondaryWindow()
{
foreach (DockPanel dockPanel in dockManager1.Panels.Where(i => i.Dock == DockingStyle.Float).ToList())
{
dockPanel.Visibility = DockVisibility.Hidden;
}
}
}
}

Expand Down
15 changes: 9 additions & 6 deletions Analogy/Forms/FluentDesignMainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,13 @@ private async Task OpenOfflineLogs(string[] fileNames, IAnalogyOfflineDataProvid
{
openedWindows++;
await FactoriesManager.Instance.InitializeIfNeeded(dataProvider);
UserControl offlineUC = new LocalLogFilesUC(dataProvider, fileNames);
string fullTitle = $"{offlineTitle} #{openedWindows}{(title == null ? "" : $" ({title})")}";
UserControl offlineUC = new LocalLogFilesUC(dataProvider, fileNames, title: fullTitle);
var page = dockManager1.AddPanel(DockingStyle.Float);
page.DockedAsTabbedDocument = true;
page.Controls.Add(offlineUC);
offlineUC.Dock = DockStyle.Fill;
page.Text = $"{offlineTitle} #{openedWindows}{(title == null ? "" : $" ({title})")}";
page.Text = fullTitle;
dockManager1.ActivePanel = page;
}
private void SetupEventHandlers()
Expand Down Expand Up @@ -826,12 +827,13 @@ async Task OpenOffline(string titleOfDataSource, string initialFolder, string[]
{
openedWindows++;
await FactoriesManager.Instance.InitializeIfNeeded(offlineAnalogy);
UserControl offlineUC = new LocalLogFilesUC(offlineAnalogy, files, initialFolder);
string fullTitle = $"{offlineTitle} #{openedWindows} ({titleOfDataSource})";
UserControl offlineUC = new LocalLogFilesUC(offlineAnalogy, files, initialFolder, title: fullTitle);
var page = dockManager1.AddPanel(DockingStyle.Float);
page.DockedAsTabbedDocument = true;
page.Controls.Add(offlineUC);
offlineUC.Dock = DockStyle.Fill;
page.Text = $"{offlineTitle} #{openedWindows} ({titleOfDataSource})";
page.Text = fullTitle;
dockManager1.ActivePanel = page;
}

Expand Down Expand Up @@ -1105,12 +1107,13 @@ private void AddRecentFolder(AccordionControlElement recentElement, IAnalogyOffl
btn.Click += (s, be) =>
{
openedWindows++;
UserControl offlineUC = new LocalLogFilesUC(offlineAnalogy, null, recentPath);
string fullTitle = $"{offlineTitle} #{openedWindows} ({title})";
UserControl offlineUC = new LocalLogFilesUC(offlineAnalogy, null, recentPath, title: fullTitle);
var page = dockManager1.AddPanel(DockingStyle.Float);
page.DockedAsTabbedDocument = true;
page.Controls.Add(offlineUC);
offlineUC.Dock = DockStyle.Fill;
page.Text = $"{offlineTitle} #{openedWindows} ({title})";
page.Text = fullTitle;
dockManager1.ActivePanel = page;
};

Expand Down
5 changes: 5 additions & 0 deletions Analogy/Forms/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 28 additions & 8 deletions Analogy/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -575,13 +575,14 @@ private async Task OpenOfflineLogs(RibbonPage ribbonPage, string[] filenames,
{
OpenedWindows++;
await FactoriesManager.Instance.InitializeIfNeeded(dataProvider);
UserControl offlineUC = new LocalLogFilesUC(dataProvider, filenames);
string fullTitle = $"{offlineTitle} #{OpenedWindows}{(title == null ? "" : $" ({title})")}";
UserControl offlineUC = new LocalLogFilesUC(dataProvider, filenames, title: fullTitle);
var page = dockManager1.AddPanel(DockingStyle.Float);
page.DockedAsTabbedDocument = true;
page.Tag = ribbonPage;
page.Controls.Add(offlineUC);
offlineUC.Dock = DockStyle.Fill;
page.Text = $"{offlineTitle} #{OpenedWindows}{(title == null ? "" : $" ({title})")}";
page.Text = fullTitle;
dockManager1.ActivePanel = page;
}
private void LoadStartupExtensions()
Expand Down Expand Up @@ -1457,13 +1458,14 @@ async Task OpenOffline(string titleOfDataSource, IAnalogyOfflineDataProvider dat
{
OpenedWindows++;
await FactoriesManager.Instance.InitializeIfNeeded(dataProvider);
UserControl offlineUC = new LocalLogFilesUC(dataProvider, files, initialFolder);
string fullTitle = $"{offlineTitle} #{OpenedWindows} ({titleOfDataSource})";
UserControl offlineUC = new LocalLogFilesUC(dataProvider, files, initialFolder, title: fullTitle);
var page = dockManager1.AddPanel(DockingStyle.Float);
page.DockedAsTabbedDocument = true;
page.Tag = ribbonPage;
page.Controls.Add(offlineUC);
offlineUC.Dock = DockStyle.Fill;
page.Text = $"{offlineTitle} #{OpenedWindows} ({titleOfDataSource})";
page.Text = fullTitle;
dockManager1.ActivePanel = page;
}

Expand Down Expand Up @@ -1820,13 +1822,14 @@ async Task OpenOffline(string titleOfDataSource, string initialFolder, string[]
{
OpenedWindows++;
await FactoriesManager.Instance.InitializeIfNeeded(offlineAnalogy);
UserControl offlineUC = new LocalLogFilesUC(offlineAnalogy, files, initialFolder);
string fullTitle = $"{offlineTitle} #{OpenedWindows} ({titleOfDataSource})";
UserControl offlineUC = new LocalLogFilesUC(offlineAnalogy, files, initialFolder, title: fullTitle);
var page = dockManager1.AddPanel(DockingStyle.Float);
page.DockedAsTabbedDocument = true;
page.Tag = ribbonPage;
page.Controls.Add(offlineUC);
offlineUC.Dock = DockStyle.Fill;
page.Text = $"{offlineTitle} #{OpenedWindows} ({titleOfDataSource})";
page.Text = fullTitle;
dockManager1.ActivePanel = page;
}

Expand All @@ -1850,7 +1853,8 @@ void OpenFilePooling(string titleOfDataSource, string initialFolder, string file
{

OpenedWindows++;
UserControl filepoolingUC = new FilePoolingUCLogs(offlineAnalogy, file, initialFile, initialFolder);
string fullTitle = $"{filePoolingTitle} #{filePooling++} ({titleOfDataSource})";
UserControl filepoolingUC = new FilePoolingUCLogs(offlineAnalogy, file, initialFile, initialFolder, title: fullTitle);
var page = dockManager1.AddPanel(DockingStyle.Float);
page.DockedAsTabbedDocument = true;

Expand All @@ -1876,7 +1880,7 @@ void OnXtcLogsOnControlRemoved(object sender, DockPanelEventArgs arg)
page.Tag = ribbonPage;
page.Controls.Add(filepoolingUC);
filepoolingUC.Dock = DockStyle.Fill;
page.Text = $"{filePoolingTitle} #{filePooling++} ({titleOfDataSource})";
page.Text = fullTitle;
dockManager1.ActivePanel = page;
dockManager1.ClosedPanel += OnXtcLogsOnControlRemoved;
}
Expand Down Expand Up @@ -2341,6 +2345,22 @@ private void bbiDownloadStatistics_ItemClick(object sender, ItemClickEventArgs e
AnalogyAboutBox ab = new AnalogyAboutBox(2);
ab.ShowDialog(this);
}

private void TabbedView1_DocumentDeactivated(object sender, DevExpress.XtraBars.Docking2010.Views.DocumentEventArgs e)
{
if (e.Document is { Control: DockPanel { Controls.Count: > 0 } pnl })
if (pnl.Controls[0] is ControlContainer { Controls.Count: > 0 } cc)
if (cc.Controls[0] is IUserControlWithUCLogs logUc)
logUc.HideSecondaryWindow();
}

private void TabbedView1_DocumentActivated(object sender, DevExpress.XtraBars.Docking2010.Views.DocumentEventArgs e)
{
if (e.Document is { Control: DockPanel { Controls.Count: > 0 } pnl })
if (pnl.Controls[0] is ControlContainer { Controls.Count: > 0 } cc)
if (cc.Controls[0] is IUserControlWithUCLogs logUc)
logUc.ShowSecondaryWindow();
}
}
}

8 changes: 8 additions & 0 deletions Analogy/Interfaces/IUserControlWithUCLogs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Analogy.Interfaces
{
internal interface IUserControlWithUCLogs
{
void ShowSecondaryWindow();
void HideSecondaryWindow();
}
}
Loading