mirror of
https://github.com/colhountech/DarkUI.Net5.git
synced 2025-07-05 00:19:27 +03:00
Events for closing and changing text
This commit is contained in:
parent
d8308f6f03
commit
a464a213fa
@ -15,9 +15,45 @@ namespace DarkUI.Docking
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class DockContentClosingEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
public DarkDockContent Content { get; private set; }
|
||||||
|
|
||||||
|
public bool Cancel { get; set; }
|
||||||
|
|
||||||
|
public DockContentClosingEventArgs(DarkDockContent content)
|
||||||
|
{
|
||||||
|
Content = content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DockTextChangedEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
public DarkDockContent Content { get; private set; }
|
||||||
|
|
||||||
|
public string OldText { get; private set; }
|
||||||
|
|
||||||
|
public string NewText { get; private set; }
|
||||||
|
|
||||||
|
public DockTextChangedEventArgs(DarkDockContent content, string oldText, string newText)
|
||||||
|
{
|
||||||
|
Content = content;
|
||||||
|
OldText = oldText;
|
||||||
|
NewText = newText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ToolboxItem(false)]
|
[ToolboxItem(false)]
|
||||||
public class DarkDockContent : UserControl
|
public class DarkDockContent : UserControl
|
||||||
{
|
{
|
||||||
|
#region Event Region
|
||||||
|
|
||||||
|
public event EventHandler<DockContentClosingEventArgs> Closing;
|
||||||
|
public event EventHandler<DockContentEventArgs> Closed;
|
||||||
|
public event EventHandler<DockTextChangedEventArgs> DockHeaderChanged;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Field Region
|
#region Field Region
|
||||||
|
|
||||||
private string _dockText;
|
private string _dockText;
|
||||||
@ -34,9 +70,14 @@ namespace DarkUI.Docking
|
|||||||
get { return _dockText; }
|
get { return _dockText; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
var oldText = _dockText;
|
||||||
|
|
||||||
_dockText = value;
|
_dockText = value;
|
||||||
|
|
||||||
|
if (DockHeaderChanged != null)
|
||||||
|
DockHeaderChanged(this, new DockTextChangedEventArgs(this, oldText, _dockText));
|
||||||
|
|
||||||
Invalidate();
|
Invalidate();
|
||||||
// TODO: raise event for re-sizing parent tabs
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,8 +123,19 @@ namespace DarkUI.Docking
|
|||||||
|
|
||||||
public virtual void Close()
|
public virtual void Close()
|
||||||
{
|
{
|
||||||
|
var e = new DockContentClosingEventArgs(this);
|
||||||
|
|
||||||
|
if (Closing != null)
|
||||||
|
Closing(this, e);
|
||||||
|
|
||||||
|
if (e.Cancel)
|
||||||
|
return;
|
||||||
|
|
||||||
if (DockPanel != null)
|
if (DockPanel != null)
|
||||||
DockPanel.RemoveContent(this);
|
DockPanel.RemoveContent(this);
|
||||||
|
|
||||||
|
if (Closed != null)
|
||||||
|
Closed(this, new DockContentEventArgs(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
Loading…
x
Reference in New Issue
Block a user