Can be any form element...
I call it on the server side..
So...I'd like to use the InfoPanel, and have it slide under the element passed in..
Messenger.WarningContext(....)
I got around it by using the CallOut, but would really rather use the InfoPanel..
Here is my static class...
public static class Messenger
{
#region Warnings
public static void Warning(string message, string title = "Warning")
{
Notify(title, message, UI.Warning, Icon.Error);
}
public static void WarningContext(string message, AbstractComponent element, int width = 200, int height = 100)
{
Callout(message, element, UI.Warning, Icon.Error, "Warning", width, height);
}
public static void WarningTop(string message, string title = "Warning", string queue = "")
{
Notify(title, message, UI.Warning, Icon.Error, "", queue);
}
public static void WarningModal(string message, string title = "Warning", string queue = "", int width = 200, int height = 100)
{
NotifyModal(title, message, UI.Warning, Icon.Error, "", queue, width, height);
}
#endregion
#region Error
public static void Error(string message, string title = "Error")
{
Notify(title, message, UI.Danger, Icon.Exclamation);
}
public static void ErrorContext(string message, AbstractComponent element, int width = 200, int height = 100)
{
Callout(message, element, UI.Danger, Icon.Exclamation, "Error", width, height);
}
public static void ErrorTop(string message, string title = "Error", string queue = "")
{
Notify(title, message, UI.Danger, Icon.Exclamation, "", queue);
}
public static void ErrorModal(string message, string title = "Error", string queue = "", int width = 200, int height = 100)
{
NotifyModal(title, message, UI.Danger, Icon.Exclamation, "", queue, width, height);
}
#endregion
#region Information
public static void Info(string message, string title = "Information")
{
Notify(title, message, UI.Primary, Icon.Information);
}
public static void InfoContext(string message, AbstractComponent element, int width = 200, int height = 100)
{
Callout(message, element, UI.Primary, Icon.Information, "Information", width, height);
}
public static void InfoTop(string message, string title = "Information", string queue = "")
{
Notify(title, message, UI.Primary, Icon.Information, "", queue);
}
public static void InfoModal(string message, string title = "Information", string queue = "", int width = 200, int height = 100)
{
NotifyModal(title, message, UI.Primary, Icon.Information, "", queue, width, height);
}
#endregion
#region Success
public static void Success(string message, string title = "Success")
{
Notify(title, message, UI.Success, Icon.Tick);
}
public static void SuccessContext(string message, AbstractComponent element, int width = 200, int height = 100)
{
Callout(message, element, UI.Success, Icon.Tick, "Success", width, height);
}
public static void SuccessTop(string message, string title = "Success", string queue = "")
{
Notify(title, message, UI.Success, Icon.Tick, "", queue);
}
public static void SuccessModal(string message, string title = "Success", string queue = "", int width = 200, int height = 100)
{
NotifyModal(title, message, UI.Success, Icon.Tick, "", queue, width, height);
}
#endregion
public static void NotifyModal(string title, string message, UI ui = UI.Warning, Icon icon = Icon.Exclamation, string element = "", string queue = "", int width = 200, int height = 100)
{
Notification.Show(new NotificationConfig
{
Title = title,
Shadow = true,
AutoHide = false,
Icon = icon,
Modal = true,
BringToFront = true,
Width = width,
Height = height,
AlignCfg = new NotificationAlignConfig
{
ElementAnchor = AnchorPoint.Center,
TargetAnchor = AnchorPoint.Center,
OffsetY = 0,
El = element
},
ShowFx = new SlideIn { Anchor = AnchorPoint.Top },
HideFx = new Ghost { Anchor = AnchorPoint.Top },
Html = message
});
//X.Msg.Info(new InfoPanel
//{
// AutoHide = false,
// Closable = true,
// Width=width,
// Height=height,
// Title = title,
// UI = ui,
// Icon = Icon.Error,
// Anchor="b",
// AlignmentEl = element +".el",
// AlignmentSpec = "b",
// Html = message
//}).Show();
}
/// <summary>
/// Pops up notification window.
/// </summary>
/// <param name="title"></param>
/// <param name="content"></param>
/// <param name="element"></param>
public static void Notify(string title, string message, UI ui = UI.Warning, Icon icon = Icon.Exclamation, string element = "", string queue = "")
{
Notification.Show(new NotificationConfig
{
Title = title,
Shadow = true,
HideDelay = 3000,
Icon = icon,
BringToFront = true,
PinEvent = "mouseover",
AlignCfg = new NotificationAlignConfig
{
ElementAnchor = AnchorPoint.Center,
TargetAnchor = AnchorPoint.Center,
OffsetY = 10,
El = element
},
ShowFx = new SlideIn { Anchor = AnchorPoint.Top },
HideFx = new Ghost { Anchor = AnchorPoint.Top },
Html = message
});
//X.Msg.Info(new InfoPanel
//{
// Title = title,
// UI = ui,
// Icon = icon,
// Alignment=AnchorPoint.Bottom,
// AlignmentEl = element+".el",
// Html = message
//}).Show();
}
public static void Callout(string message, AbstractComponent element, UI ui = UI.Warning, Icon icon = Icon.Exclamation, string title = "Attention", int width = 200, int height = 100)
{
X.Msg.Callout(element, new Callout
{
Title = title,
UI = ui,
Icon = icon,
Html = message,
Alignment = AnchorPoint.RightTop,
DismissDelay = 5000,
CloseAction = CloseAction.Destroy,
Height = height,
Width = width
}).Show(true);
}
}
}