CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

IWCGJQNotificationHelperUnit

Share your useful code here.

by JohnFSklavounos » 16 Oct 2013 15:22

Update: Added an override to the ShowNotification procedure for position. I realized that if you set it in the component, why resend it every time?

Hi Everyone,

Here's a helper unit for the IWCGJQNotification component. With it you should be able to compress your code down a bit if you use the same IWCGJQNotification component to display multiple messages and also switch easily between the notification personalities.

Please remember to submit code back to the board if you make it better. :D

Enjoy!
John

Code: Select all
unit IWCGJQNotificationHelperUnit;

/// =================================================================================================
///
///  Author:    John F. Sklavounos
///  Date:      2013-10-16
///
///  Ownership:
///   You are free to use and distribute this code as you see fit. I only ask that improvements be
///   returned to the community at http://www.cgdevtools.com/cgforum/viewforum.php?f=109
///
///  Abstract:
///   I find myself using primarily only a few properties and the ShowNotification procedure with this
///   component, so I thought it would be great to combine the functionality and make my code more
///   compact.  Additionally, it makes it easy to switch between the NOTY and FreeOW personalities
///   because you only have to change the component's JQNotificationType property but not your calls! =)
///
///  Notes:
///
/// =================================================================================================

interface

uses
  IWCGJQNotification;

type TIWCGJQNotificationHelper = class
  class procedure ShowNotification(pOwner: TIWCGJQNotification; pType: TIWCGJQNotificationNotyType; pPosition: TIWCGJQNotificationNotyLayout; pTitle, pMessage: string); overload;
  class procedure ShowNotification(pOwner: TIWCGJQNotification; pType: TIWCGJQNotificationNotyType; pTitle, pMessage: string); overload;
end;

implementation

class procedure TIWCGJQNotificationHelper.ShowNotification(pOwner: TIWCGJQNotification; pType: TIWCGJQNotificationNotyType; pTitle, pMessage: string);
begin
  if pOwner.jqNotificationType = jqntFreeow then begin
    with pOwner.JQNotificationFreeOWOptions do begin
      IsError := (pType = jqnntError);
      Title := pTitle;
      Message := pMessage;
      ShowNotification;
    end;
  end else begin
    with pOwner.JQNotificationNotyOptions do begin
      Type_ := pType;
      Text := '<strong>' + pTitle + '</strong><br>' + pMessage +'';
      ShowNotification;
    end;
  end;
end;

class procedure TIWCGJQNotificationHelper.ShowNotification(pOwner: TIWCGJQNotification; pType: TIWCGJQNotificationNotyType; pPosition: TIWCGJQNotificationNotyLayout; pTitle, pMessage: string);
begin
  if pOwner.jqNotificationType = jqntFreeow then begin
    with pOwner.JQNotificationFreeOWOptions do begin
      case pPosition of
        jqnnlBottom, jqnnlBottomCenter, jqnnlBottomLeft, jqnnlBottomRight:
          Position := jqnpBottomRight;
        jqnnlCenter, jqnnlCenterLeft, jqnnlCenterRight, jqnnlInline, jqnnlTop, jqnnlTopCenter, jqnnlTopLeft, jqnnlTopRight:
          Position := jqnpTopRight;
      end;
    end;
  end else begin
    pOwner.JQNotificationNotyOptions.Layout := pPosition;
  end;
  ShowNotification(pOwner, pType, pTitle, pMessage);
end;

end.
Last edited by JohnFSklavounos on 16 Oct 2013 16:14, edited 1 time in total.
John F. Sklavounos
Software Developer
Always learning

XE7: Update 1
FireDAC: 20.0.16277 (Build 1276)
IW: 14.0.41
CG : 2.6.0.100
JohnFSklavounos
 
Posts: 109
Joined: 14 Aug 2013 00:35
Location: Miami, FL

by Jorge Sousa » 16 Oct 2013 16:08

Hi John

Thank you very much!!!!

Regards
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58


Return to Community Code

cron

Who is online

Users browsing this forum: No registered users and 2 guests

Contact Us.