unit WinForm;

interface

uses
  System.Drawing, System.Collections, System.ComponentModel,
  System.Windows.Forms, System.Data, System.Globalization, System.Resources;

type
  TWinForm = class(System.Windows.Forms.Form)
  {$REGION 'Designer Managed Code'}
  strict private
    /// <summary>
    /// Required designer variable.
    /// </summary>
    components: System.ComponentModel.IContainer;
    Timer1: System.Windows.Forms.Timer;
    NotifyIcon1: System.Windows.Forms.NotifyIcon;
    ContextMenu1: System.Windows.Forms.ContextMenu;
    MenuItem1: System.Windows.Forms.MenuItem;
    MenuItem2: System.Windows.Forms.MenuItem;
    Button1: System.Windows.Forms.Button;
    Button2: System.Windows.Forms.Button;
    DataSet1: System.Data.DataSet;
    DataTable1: System.Data.DataTable;
    DataColumn1: System.Data.DataColumn;
    DataColumn2: System.Data.DataColumn;
    ListBox1: System.Windows.Forms.ListBox;
    ListBox2: System.Windows.Forms.ListBox;
    TextBox1: System.Windows.Forms.TextBox;
    Panel1: System.Windows.Forms.Panel;
    RichTextBox1: System.Windows.Forms.RichTextBox;
    Label1: System.Windows.Forms.Label;
    Label2: System.Windows.Forms.Label;
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    procedure InitializeComponent;
    procedure Timer1_Tick(sender: System.Object; e: System.EventArgs);
    procedure Button1_Click(sender: System.Object; e: System.EventArgs);
    procedure MenuItem1_Click(sender: System.Object; e: System.EventArgs);
    procedure TWinForm_Closing(sender: System.Object; e: System.ComponentModel.CancelEventArgs);
    procedure NotifyIcon1_DoubleClick(sender: System.Object; e: System.EventArgs);
    procedure MenuItem2_Click(sender: System.Object; e: System.EventArgs);
    procedure Button2_Click(sender: System.Object; e: System.EventArgs);
  {$ENDREGION}
  strict protected
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    procedure Dispose(Disposing: Boolean); override;
    procedure Pokaz();
  private
    { Private Declarations }
  public
    constructor Create;
  end;



  [assembly: RuntimeRequiredAttribute(TypeOf(TWinForm))]

implementation

{$AUTOBOX ON}

{$REGION 'Windows Form Designer generated code'}
/// <summary>
/// Required method for Designer support -- do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure TWinForm.InitializeComponent;
type
  TArrayOfSystem_Windows_Forms_MenuItem = array of System.Windows.Forms.MenuItem;
  TArrayOfSystem_Data_DataTable = array of System.Data.DataTable;
  TArrayOfSystem_Data_DataColumn = array of System.Data.DataColumn;
var
  resources: System.Resources.ResourceManager;
begin
  Self.components := System.ComponentModel.Container.Create;
  resources := System.Resources.ResourceManager.Create(TypeOf(TWinForm));
  Self.Timer1 := System.Windows.Forms.Timer.Create(Self.components);
  Self.NotifyIcon1 := System.Windows.Forms.NotifyIcon.Create(Self.components);
  Self.ContextMenu1 := System.Windows.Forms.ContextMenu.Create;
  Self.MenuItem1 := System.Windows.Forms.MenuItem.Create;
  Self.MenuItem2 := System.Windows.Forms.MenuItem.Create;
  Self.Button1 := System.Windows.Forms.Button.Create;
  Self.Button2 := System.Windows.Forms.Button.Create;
  Self.DataSet1 := System.Data.DataSet.Create;
  Self.DataTable1 := System.Data.DataTable.Create;
  Self.DataColumn1 := System.Data.DataColumn.Create;
  Self.DataColumn2 := System.Data.DataColumn.Create;
  Self.ListBox1 := System.Windows.Forms.ListBox.Create;
  Self.ListBox2 := System.Windows.Forms.ListBox.Create;
  Self.Panel1 := System.Windows.Forms.Panel.Create;
  Self.Label2 := System.Windows.Forms.Label.Create;
  Self.Label1 := System.Windows.Forms.Label.Create;
  Self.RichTextBox1 := System.Windows.Forms.RichTextBox.Create;
  Self.TextBox1 := System.Windows.Forms.TextBox.Create;
  (System.ComponentModel.ISupportInitialize(Self.DataSet1)).BeginInit;
  (System.ComponentModel.ISupportInitialize(Self.DataTable1)).BeginInit;
  Self.Panel1.SuspendLayout;
  Self.SuspendLayout;
  // 
  // Timer1
  // 
  Self.Timer1.Enabled := True;
  Self.Timer1.Interval := 1000;
  Include(Self.Timer1.Tick, Self.Timer1_Tick);
  // 
  // NotifyIcon1
  // 
  Self.NotifyIcon1.ContextMenu := Self.ContextMenu1;
  Self.NotifyIcon1.Icon := (System.Drawing.Icon(resources.GetObject('NotifyI' +
    'con1.Icon')));
  Self.NotifyIcon1.Text := 'Przypominacz';
  Self.NotifyIcon1.Visible := True;
  Include(Self.NotifyIcon1.DoubleClick, Self.NotifyIcon1_DoubleClick);
  // 
  // ContextMenu1
  // 
  Self.ContextMenu1.MenuItems.AddRange(TArrayOfSystem_Windows_Forms_MenuItem.Create(Self.MenuItem1, 
          Self.MenuItem2));
  // 
  // MenuItem1
  // 
  Self.MenuItem1.Index := 0;
  Self.MenuItem1.Text := 'Nowy';
  Include(Self.MenuItem1.Click, Self.MenuItem1_Click);
  // 
  // MenuItem2
  // 
  Self.MenuItem2.Index := 1;
  Self.MenuItem2.Text := 'Wyjście';
  Include(Self.MenuItem2.Click, Self.MenuItem2_Click);
  // 
  // Button1
  // 
  Self.Button1.Location := System.Drawing.Point.Create(298, 351);
  Self.Button1.Name := 'Button1';
  Self.Button1.Size := System.Drawing.Size.Create(90, 26);
  Self.Button1.TabIndex := 2;
  Self.Button1.Text := 'Dodaj';
  Include(Self.Button1.Click, Self.Button1_Click);
  // 
  // Button2
  // 
  Self.Button2.Location := System.Drawing.Point.Create(19, 351);
  Self.Button2.Name := 'Button2';
  Self.Button2.Size := System.Drawing.Size.Create(90, 26);
  Self.Button2.TabIndex := 3;
  Self.Button2.Text := 'Usuń';
  Include(Self.Button2.Click, Self.Button2_Click);
  // 
  // DataSet1
  // 
  Self.DataSet1.DataSetName := 'NewDataSet';
  Self.DataSet1.Locale := System.Globalization.CultureInfo.Create('pl-PL');
  Self.DataSet1.Tables.AddRange(TArrayOfSystem_Data_DataTable.Create(Self.DataTable1));
  // 
  // DataTable1
  // 
  Self.DataTable1.Columns.AddRange(TArrayOfSystem_Data_DataColumn.Create(Self.DataColumn1, 
          Self.DataColumn2));
  Self.DataTable1.TableName := 'Table1';
  // 
  // DataColumn1
  // 
  Self.DataColumn1.ColumnName := 'Godzina';
  // 
  // DataColumn2
  // 
  Self.DataColumn2.ColumnName := 'Opis';
  // 
  // ListBox1
  // 
  Self.ListBox1.DataSource := Self.DataTable1;
  Self.ListBox1.DisplayMember := 'Godzina';
  Self.ListBox1.ItemHeight := 16;
  Self.ListBox1.Location := System.Drawing.Point.Create(10, 9);
  Self.ListBox1.Name := 'ListBox1';
  Self.ListBox1.Size := System.Drawing.Size.Create(105, 308);
  Self.ListBox1.TabIndex := 4;
  // 
  // ListBox2
  // 
  Self.ListBox2.DataSource := Self.DataTable1;
  Self.ListBox2.DisplayMember := 'Opis';
  Self.ListBox2.ItemHeight := 16;
  Self.ListBox2.Location := System.Drawing.Point.Create(125, 9);
  Self.ListBox2.Name := 'ListBox2';
  Self.ListBox2.Size := System.Drawing.Size.Create(278, 148);
  Self.ListBox2.TabIndex := 5;
  // 
  // Panel1
  // 
  Self.Panel1.BorderStyle := System.Windows.Forms.BorderStyle.FixedSingle;
  Self.Panel1.Controls.Add(Self.Label2);
  Self.Panel1.Controls.Add(Self.Label1);
  Self.Panel1.Controls.Add(Self.RichTextBox1);
  Self.Panel1.Controls.Add(Self.TextBox1);
  Self.Panel1.Location := System.Drawing.Point.Create(125, 175);
  Self.Panel1.Name := 'Panel1';
  Self.Panel1.Size := System.Drawing.Size.Create(278, 213);
  Self.Panel1.TabIndex := 8;
  // 
  // Label2
  // 
  Self.Label2.Location := System.Drawing.Point.Create(19, 83);
  Self.Label2.Name := 'Label2';
  Self.Label2.Size := System.Drawing.Size.Create(39, 27);
  Self.Label2.TabIndex := 4;
  Self.Label2.Text := 'Opis';
  // 
  // Label1
  // 
  Self.Label1.Location := System.Drawing.Point.Create(58, 9);
  Self.Label1.Name := 'Label1';
  Self.Label1.Size := System.Drawing.Size.Create(57, 27);
  Self.Label1.TabIndex := 3;
  Self.Label1.Text := 'Godzina';
  // 
  // RichTextBox1
  // 
  Self.RichTextBox1.Location := System.Drawing.Point.Create(67, 46);
  Self.RichTextBox1.Name := 'RichTextBox1';
  Self.RichTextBox1.Size := System.Drawing.Size.Create(192, 111);
  Self.RichTextBox1.TabIndex := 2;
  Self.RichTextBox1.Text := '';
  // 
  // TextBox1
  // 
  Self.TextBox1.Location := System.Drawing.Point.Create(125, 9);
  Self.TextBox1.Name := 'TextBox1';
  Self.TextBox1.Size := System.Drawing.Size.Create(134, 22);
  Self.TextBox1.TabIndex := 1;
  Self.TextBox1.Text := '';
  // 
  // TWinForm
  // 
  Self.AutoScale := False;
  Self.AutoScaleBaseSize := System.Drawing.Size.Create(6, 15);
  Self.ClientSize := System.Drawing.Size.Create(412, 394);
  Self.Controls.Add(Self.ListBox2);
  Self.Controls.Add(Self.ListBox1);
  Self.Controls.Add(Self.Button2);
  Self.Controls.Add(Self.Button1);
  Self.Controls.Add(Self.Panel1);
  Self.Name := 'TWinForm';
  Self.ShowInTaskbar := False;
  Self.Text := 'Przypominacz (Windows Forms)';
  Self.WindowState := System.Windows.Forms.FormWindowState.Minimized;
  Include(Self.Closing, Self.TWinForm_Closing);
  (System.ComponentModel.ISupportInitialize(Self.DataSet1)).EndInit;
  (System.ComponentModel.ISupportInitialize(Self.DataTable1)).EndInit;
  Self.Panel1.ResumeLayout(False);
  Self.ResumeLayout(False);
end;
{$ENDREGION}
procedure TWinForm.Pokaz;
begin
 Show;
 Self.WindowState:=FormWindowState.Normal;
end;

procedure TWinForm.Dispose(Disposing: Boolean);
begin
  if Disposing then
  begin
    if Components <> nil then
      Components.Dispose();
  end;
  inherited Dispose(Disposing);
end;

constructor TWinForm.Create;
begin
  inherited Create;
  //
  // Required for Windows Form Designer support
  //
  InitializeComponent;
  //
  // TODO: Add any constructor code after InitializeComponent call
  //
end;

procedure TWinForm.Button2_Click(sender: System.Object; e: System.EventArgs);
var    wiersz: DataRow;
begin
if ListBox1.SelectedIndex>=0 then
  begin
  wiersz:=dataset1.Tables.Item[0].Rows[ListBox1.SelectedIndex];
  dataset1.Tables.Item[0].Rows.Remove(wiersz);
  end;
end;

procedure TWinForm.MenuItem2_Click(sender: System.Object; e: System.EventArgs);
begin
 Self.Free;
end;

procedure TWinForm.NotifyIcon1_DoubleClick(sender: System.Object; e: System.EventArgs);
begin
  if FormWindowState.Minimized=WindowState then
  Pokaz;
end;

procedure TWinForm.TWinForm_Closing(sender: System.Object; e: System.ComponentModel.CancelEventArgs);
begin
  e.Cancel:=true;
  Self.WindowState:=FormWindowState.Minimized;
  Hide;
end;

procedure TWinForm.MenuItem1_Click(sender: System.Object; e: System.EventArgs);
begin
  Pokaz;
end;

procedure TWinForm.Button1_Click(sender: System.Object; e: System.EventArgs);
var    wiersz: DataRow;
begin
wiersz:=dataset1.Tables[0].NewRow;
wiersz[0]:=TextBox1.Text;
wiersz[1]:=RichTextBox1.Text;
DataSet1.Tables[0].Rows.Add(wiersz);
end;

procedure TWinForm.Timer1_Tick(sender: System.Object; e: System.EventArgs);
var dt: DateTime;
    wiersz: DataRow;
    format: System.Globalization.DateTimeFormatInfo;
    i: integer;
begin
format:=System.Globalization.DateTimeFormatInfo.Create;
dt:=DateTime.Now;
for i:=0 to ListBox1.Items.Count-1 do
  begin
  wiersz:=dataset1.Tables[0].Rows[i];

 if wiersz.Item[0].tostring=dt.tostring(format.LongTimePattern,format) then
  if FormWindowState.Minimized=WindowState then
  begin
  Pokaz;
  MessageBox.Show('Przypominacz :'+#13+wiersz.Item[1].tostring);
      end;
  end;

end;

end.
