unit main;

interface

uses
//  FastMM4,
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, ComCtrls, ExtDlgs, Buttons, jpeg, Menus,
  AdvPanel, GradientLabel, AdvSmoothLedLabel, AdvGlowButton, AdvGlassButton,
  AdvToolBar, AdvToolBtn, AdvPageControl, IniFiles, Math;  

Const
  WM_FUCK_ALERT = WM_USER + 6;

type                             
  TForm1 = class(TForm)           
    ScreenTimer: TTimer;                    
    PanelControl: TPanel;
    PanelActiveMes: TPanel;
    PanelMesDT: TPanel;
    PanelMesText: TPanel;
    CurTimeTimer: TTimer;
    PopupMenu1: TPopupMenu;
    mnFindScadaObject: TMenuItem;
    AdvPanelStyler1: TAdvPanelStyler;
    lbLogo: TGradientLabel;
    pnlTime: TAdvPanel;
    bvl2: TBevel;
    lbTime: TGradientLabel;
    pnlMain: TAdvPanel;
    bvl3: TBevel;
    ExitButton: TAdvGlowButton;
    ConnectButton: TAdvGlowButton;
    DisconnectButton: TAdvGlowButton;
    LockButton: TAdvGlowButton;
    SetupButton: TAdvGlowButton;
    MesViewButton: TAdvGlowButton;
    MesMonButton: TAdvGlowButton;
    btTrendViewer: TAdvGlowButton;
    btArcViewer: TAdvGlowButton;
    bvl1: TBevel;
    PageControl: TAdvPageControl;
    ScrollBarVert: TScrollBar;
    ScrollBarHoriz: TScrollBar;
    pnlUser: TAdvPanel;
    lbUser: TGradientLabel;
    bvExtra: TBevel;
    btMotohr: TAdvGlowButton;
    bvTail: TBevel;
    Bevel1: TBevel;
    btParams: TAdvGlowButton;
    Bevel3: TBevel;
    Bevel4: TBevel;
    Bevel6: TBevel;
    Bevel7: TBevel;
    Bevel2: TBevel;
    btWesClient: TAdvGlowButton;
    procedure ConnectButton1Click(Sender: TObject);
    procedure DisconnectButton1Click(Sender: TObject);
    procedure ScreenTimerTimer(Sender: TObject);
    procedure PageControl1Change(Sender: TObject);
    procedure TabSheetMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormDestroy(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure PanelMesTextClick(Sender: TObject);
    procedure MesMonitorButtonClick(Sender: TObject);
    procedure MesViewButton1Click(Sender: TObject);
    procedure ExitButton1Click(Sender: TObject);
    procedure CurTimeTimerTimer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SetupButton1Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure GotoMenuItemClick(Sender: TObject);
    procedure mnFindScadaObjectClick(Sender: TObject);
    procedure LockButtonClick(Sender: TObject);
    procedure FormMouseWheel(Sender: TObject; Shift: TShiftState;
      WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
    procedure btTrendViewer1Click(Sender: TObject);
    procedure btArcViewer1Click(Sender: TObject);
    procedure ScrollBarChange(Sender: TObject);
    procedure btParamsClick(Sender: TObject);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormResize(Sender: TObject);

    procedure ShowFuckAlert(var Message: TWMChar); message WM_FUCK_ALERT;
    procedure btWesClientClick(Sender: TObject);
    procedure btMotohrClick(Sender: TObject);

  end;

var
  Form1: TForm1;

implementation
{$R *.DFM}

uses
  infodlg,
  DataClientConnectBad,
  UserControlEx,
  RpVisualGlobal,
  RpVisualMain,
  AdminMain,
  users,
  _PrjProcs;


procedure TForm1.ExitButton1Click(Sender: TObject);
begin
  Close;
end;

procedure TForm1.CurTimeTimerTimer(Sender: TObject);
begin
  lbTime.Caption := TimeToStr(now);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  _FormCreate(Sender);
end;

procedure TForm1.FormActivate(Sender: TObject);
begin
  _FormActivate(Sender);
end;

procedure TForm1.ConnectButton1Click(Sender: TObject);
begin
  _ConnectButtonClick(Sender);
end;

procedure TForm1.DisconnectButton1Click(Sender: TObject);
begin
  if not rvgLogIn then Exit;
  if (Sender=nil) or (showInfoDlg('Выйти из системы?', mtConfirmation, [mbYes, mbNo], 0) = mrYes) then begin
    if DataClientConnectBadForm <> nil then begin
      DataClientConnectBadForm.free;
      DataClientConnectBadForm := nil;
    end;
    _DisconnectButtonClick(sender);
  end;
end;

procedure TForm1.LockButtonClick(Sender: TObject);
begin
  _LockButtonClick(sender);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  _FormDestroy(sender)
end;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  _FormCloseQuery(Sender, CanClose);
end;

procedure TForm1.ScreenTimerTimer(Sender: TObject);
begin
  _ScreenTimerTimer(sender);
  if rvgPrjOnTimerEnabled then
    _PrjOnTimer;
end;

procedure TForm1.PanelMesTextClick(Sender: TObject);
begin
  _PanelMesTextClick(sender);
end;

procedure TForm1.MesMonitorButtonClick(Sender: TObject);
begin
  _MesMonitorButtonClick(sender);
end;

procedure TForm1.MesViewButton1Click(Sender: TObject);
begin
  _MesViewButtonClick(sender);
end;

procedure TForm1.PageControl1Change(Sender: TObject);
begin
  _PageControlChange(sender);
end;

procedure TForm1.TabSheetMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  _TabSheetMouseDown(Sender, Button, Shift, X, Y);
end;

procedure TForm1.SetupButton1Click(Sender: TObject);
begin
  _SetupButtonClick(sender);
end;

procedure TForm1.GotoMenuItemClick(Sender: TObject);
begin
  _GotoMenuItemClick(sender);
end;

procedure TForm1.mnFindScadaObjectClick(Sender: TObject);
begin
  _mnFindScadaObjectClick(Sender);
end;

procedure TForm1.FormMouseWheel(Sender: TObject; Shift: TShiftState;
  WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin
  _FormMouseWheel(Sender, Shift, WheelDelta, MousePos, Handled );
  PageControl1Change(Sender);
end;

procedure TForm1.btTrendViewer1Click(Sender: TObject);
begin
  _btTrendViewerClick(Sender);
end;

procedure TForm1.btArcViewer1Click(Sender: TObject);
begin
  _btArcViewerClick(Sender);
end;


procedure TForm1.ScrollBarChange(Sender: TObject);
begin
  _ScrollBarChange(Sender);
end;


procedure TForm1.btParamsClick(Sender: TObject);
begin
// Do not remove! See CommonDataboard.CommonDataboard_Init
end;

procedure TForm1.btWesClientClick(Sender: TObject);
begin
  _btWesClientClick(Sender);
end;

procedure TForm1.btMotohrClick(Sender: TObject);
begin
  _btMotohrClick(sender);
end;

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
  _FormMouseMove(Sender, Shift, X, Y);
end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  _TabSheetMouseDown(Sender, Button, Shift, X, Y);
end;

procedure TForm1.FormResize(Sender: TObject);
begin
  _TabSheetMouseDown(nil, mbLeft, [], 0, 0);
end;

procedure TForm1.ShowFuckAlert(var Message: TWMChar);
begin
  if message.CharCode = 0 then                    
    ShowMessage('Лицензия на использования данного программного обеспечения закончена!')
  else
    ShowMessage('Внимание! Лицензия на использования данного программного обеспечения заканчивается через '+
          inttostr(Message.KeyData) + ' дней.');
end;



end.
