{------------------------------------------------------------------------------} { Unit Name: DemoWWWForm Purpose : Main form for User Interface for demo's Author : Vesa Lappalainen Date : 28.12.2000 shr Changed : 12.01.2001 + drop many files - reject files from wrong place Changed : 09.09.2001 + The type of the meeting can be changed + Delete line ToDo : When creating new file, the local dir is not changed? } {------------------------------------------------------------------------------} unit DemoWWWForm; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ActnList, Menus, ExtCtrls, ComCtrls, ToolWin, StdCtrls, savepos, EditDouble,Task, kDragTarget, ImgList, kinicomp, StdActns, OptionsForm,ViewFileForm, DragDrop, DropSource, DragDropFile; type TFormDemoWWW = class(TForm) PanelFilesTxt: TPanel; MainMenu1: TMainMenu; File1: TMenuItem; New1: TMenuItem; ActionList1: TActionList; ActionFileNew: TAction; ActionFileSave: TAction; ActionFileOpen: TAction; ActionFileExit: TAction; Save1: TMenuItem; Open1: TMenuItem; N1: TMenuItem; ActionFileExit1: TMenuItem; ToolBar: TToolBar; PanelInformation: TPanel; StatusBar: TStatusBar; MemoFilesTxt: TMemo; OpenDialog: TOpenDialog; ActionViewFile: TAction; Edit1: TMenuItem; View1: TMenuItem; Help1: TMenuItem; ActionViewFile1: TMenuItem; SavePos1: TSavePos; ActionEditOptions: TAction; Options1: TMenuItem; DragEditFileName: TkDragTarget; OpenFiles: TOpenDialog; SaveDialog: TSaveDialog; ToolButton1: TToolButton; ImageList1: TImageList; ToolButtonOpen: TToolButton; ToolButtonSave: TToolButton; ToolButtonNew: TToolButton; PanelFile: TPanel; PanelComment: TPanel; LabelComment: TLabel; PanelTaskAndNumber: TPanel; PanelPoints: TPanel; PanelTask: TPanel; LabelFile: TLabel; PanelFileNameAndButton: TPanel; EditFile: TEditIni; PanelFileButton: TPanel; ButtonFiles: TButton; LabelTaskNumber: TLabel; EditTaskNumber: TEditIni; LabelPoints: TLabel; EditPoints: TEditDouble; EditComment: TEditIni; ActionHelpAbout: TAction; About1: TMenuItem; N2: TMenuItem; EditCut1: TEditCut; EditCopy1: TEditCopy; EditPaste1: TEditPaste; EditUndo1: TEditUndo; Undo1: TMenuItem; N3: TMenuItem; N4: TMenuItem; Cut1: TMenuItem; Copy1: TMenuItem; Paste1: TMenuItem; ToolButtonUndo: TToolButton; ToolButtonCut: TToolButton; ToolButtonCopy: TToolButton; ToolButtonPaste: TToolButton; ToolButton2: TToolButton; ActionViewToolBar: TAction; Viewtoolbar1: TMenuItem; CBViewToolbar: TCheckBoxIni; CBViewFileWindow: TCheckBoxIni; ActionHelpContents: THelpContents; HelpTopicSearch1: THelpTopicSearch; Contents1: TMenuItem; ActionFilePreview: TAction; N5: TMenuItem; Preview1: TMenuItem; ToolButtonPreview: TToolButton; ActionFileCopyToWWW: TAction; CopytoWWW1: TMenuItem; ToolButtonCopyToWWW: TToolButton; ToolButton3: TToolButton; ActionEditAddLine: TAction; ToolButtonAddLine: TToolButton; ActionAddRow: TAction; N6: TMenuItem; Insertseparatorline1: TMenuItem; Addrow1: TMenuItem; ToolButtonAddTask: TToolButton; ToolButton6: TToolButton; ToolButtonMoveLast: TToolButton; ActionMoveLast: TAction; ActionMoveFirst: TAction; ActionMoveNext: TAction; ActionMovePrior: TAction; ToolButtonMoveFirst: TToolButton; ToolButtonMoveNext: TToolButton; ToolButtonMovePrior: TToolButton; DragTargetMemoFilesTxt: TkDragTarget; DropFileSource1: TDropFileSource; ToolButtonTest: TToolButton; ActionFileTest: TAction; FontDialog1: TFontDialog; ActionViewFileFont: TAction; N7: TMenuItem; ActionViewFileFont1: TMenuItem; ActionViewFileFontPlus: TAction; ActionViewFileFontMinus: TAction; ActionViewFlipFileCharSet: TAction; ActionViewUserList: TAction; Increasefontsize1: TMenuItem; Viewuserlist1: TMenuItem; EditFileFont: TEditIni; ActionViewNextUser: TAction; ActionViewPreviousUser: TAction; ActionViewRandomUser: TAction; ToolButtonDeleteLine: TToolButton; ActionEditDeleteLine: TAction; Deleteline1: TMenuItem; ToolButtonEditOptions: TToolButton; procedure ActionFileExitExecute(Sender: TObject); procedure ActionFileOpenExecute(Sender: TObject); procedure ActionViewFileExecute(Sender: TObject); procedure ActionEditOptionsExecute(Sender: TObject); procedure MemoFilesTxtClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure MemoFilesTxtKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure MemoFilesTxtChange(Sender: TObject); procedure DragEditFileNameDrop(Sender: TkDragTarget; pt: TPoint); procedure ButtonFilesClick(Sender: TObject); procedure MemoFilesTxtKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); procedure MemoFilesTxtDblClick(Sender: TObject); procedure MemoFilesTxtExit(Sender: TObject); procedure ActionFileSaveExecute(Sender: TObject); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure ActionFileNewExecute(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure ActionHelpAboutExecute(Sender: TObject); procedure ActionViewToolBarExecute(Sender: TObject); procedure ActionFilePreviewExecute(Sender: TObject); procedure ActionFileCopyToWWWExecute(Sender: TObject); procedure ActionEditAddLineExecute(Sender: TObject); procedure ActionAddRowExecute(Sender: TObject); procedure ActionMoveLastExecute(Sender: TObject); procedure ActionMoveFirstExecute(Sender: TObject); procedure ActionMoveNextExecute(Sender: TObject); procedure ActionMovePriorExecute(Sender: TObject); procedure FormDeactivate(Sender: TObject); procedure MemoFilesTxtMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure DragTargetMemoFilesTxtDrop(Sender: TkDragTarget; pt: TPoint); procedure ActionHelpContentsExecute(Sender: TObject); procedure ActionFileTestExecute(Sender: TObject); procedure ActionViewFileFontExecute(Sender: TObject); procedure ActionViewFileFontPlusExecute(Sender: TObject); procedure ActionViewFileFontMinusExecute(Sender: TObject); procedure ActionViewFlipFileCharSetExecute(Sender: TObject); procedure ActionViewUserListExecute(Sender: TObject); procedure EditFileFontChange(Sender: TObject); procedure FormShow(Sender: TObject); procedure ActionViewNextUserExecute(Sender: TObject); procedure ActionViewPreviousUserExecute(Sender: TObject); procedure ActionViewRandomUserExecute(Sender: TObject); procedure ActionEditDeleteLineExecute(Sender: TObject); private FTask : TTask; FTaskCounter : TTask; FLineNr : integer; AlreadyDragging : boolean; DragPoint: TPoint; FormOptions: TFormOptions; FormViewFile: TFormViewFile; procedure TaskChange(Sender: TObject); procedure CheckTaskOnCurrentLine; function CheckDemoFile(const s:string):boolean; procedure SetDemoFile(s: string); function GetFileName: string; procedure SetPath(const Value: string); function GetPath: string; function AskDemoFile : boolean; procedure CheckTaskWithLine; procedure SetLineNr(const Value: integer); procedure MarkLineVisible(n:integer=-1); procedure ShowFile; function CheckSaved: boolean; function Save: boolean; procedure CountPoints; procedure CheckFileSyntaxInMemoFiles; procedure AddDemoRow; procedure AddLineRow; procedure AddRow; procedure RunCommand(const s: string); procedure CheckTaskVisible; procedure PutCaption; procedure CheckIfDemoNrOkInMemoFiles; function AskAndCreateNewFile: boolean; function DoNewFile: boolean; procedure MemoChange(b: boolean); function CheckIfFileAllreadyIn(const s: string): boolean; function GetDemoNr: double; procedure SetDemoNr(const Value: double); procedure ChooseFont(ctrl: TControl); procedure DecreaseFont(ctrl: TControl); procedure IncreaseFont(ctrl: TControl); procedure FlipCharSet(ctrl: TControl); procedure SaveFont; function FindTask(const t: string):boolean; function GetDemoType: string; procedure SetDemoType(const Value: string); public constructor Create(AOwner:TComponent); override; function LoadFile: boolean; overload; function LoadFile(const name,task:string): boolean; overload; property FileName : string read GetFileName; property Path : string read GetPath write SetPath; property LineNr : integer read FLineNr write SetLineNr; property DemoNr : double read GetDemoNr write SetDemoNr; property DemoType : string read GetDemoType write SetDemoType; end; var FormDemoWWW: TFormDemoWWW; implementation uses kstring,about,FileCtrl, ShellApi, UserListForm, kini,Clipbrd; {$R *.DFM} procedure TFormDemoWWW.ActionFileExitExecute(Sender: TObject); begin Close(); end; procedure TFormDemoWWW.PutCaption; begin Caption := 'DemoWWW - ' + FileName; end; function TFormDemoWWW.LoadFile : boolean; begin PutCaption; try MemoFilesTxt.Lines.LoadFromFile(FileName); CheckFileSyntaxInMemoFiles; MarkLineVisible; except DoNewFile; end; Result := true; end; function TFormDemoWWW.LoadFile(const name,task:string) : boolean; begin Result := false; if ( not CheckSaved ) then exit; try FormOptions.CheckProject := false; Path := ExtractFilePath(name); Result := LoadFile; if ( Result ) then Result := FindTask(task); finally FormOptions.CheckProject := true; MemoFilesTxt.Modified := false; Path := ExtractFilePath(name); end; end; procedure TFormDemoWWW.ActionFileOpenExecute(Sender: TObject); begin if ( not CheckSaved ) then exit; OpenDialog.InitialDir := Path; OpenDialog.FileName := FormOptions.FileName; if ( not OpenDialog.Execute ) then exit; if ( LowerCase(FormOptions.FileName) <> LowerCase(ExtractFileName(OpenDialog.FileName)) ) then begin ShowMessage(Format('Only "%s" is allowed to open!',[FormOptions.FileName])); Exit; end; Path := ExtractFilePath(OpenDialog.FileName); LoadFile; end; procedure TFormDemoWWW.ActionViewFileExecute(Sender: TObject); begin ActionViewFile.Checked := not ActionViewFile.Checked; FormViewFile.Visible := ActionViewFile.Checked; end; procedure TFormDemoWWW.ActionViewToolBarExecute(Sender: TObject); begin ActionViewToolBar.Checked := not ActionViewToolBar.Checked; ToolBar.Visible := ActionViewToolBar.Checked; end; procedure TFormDemoWWW.ActionHelpAboutExecute(Sender: TObject); begin AboutBox.ShowModal; end; procedure TFormDemoWWW.ActionEditOptionsExecute(Sender: TObject); begin if FormOptions.ShowModal = mrOK then CheckIfDemoNrOkInMemoFiles; end; procedure TFormDemoWWW.CheckTaskOnCurrentLine; var y : integer; s: string; begin y := LineNr; if ( FTask = nil ) or ( y < 0 ) then exit; s := MemoFilesTxt.Lines[y]; FTask.AsString := s; ShowFile; end; procedure TFormDemoWWW.CheckTaskWithLine; var y : integer; begin y := MemoFilesTxt.CaretPos.y; if ( y = LineNr ) then exit; LineNr := y; CheckTaskOnCurrentLine; end; procedure TFormDemoWWW.ShowFile; begin FormViewFile.ShowFile(path+EditFile.Text); end; procedure TFormDemoWWW.MemoFilesTxtClick(Sender: TObject); begin CheckTaskWithLine; end; constructor TFormDemoWWW.Create(AOwner: TComponent); begin FormViewFile := TFormViewFile.Create(self); FormOptions := TFormOptions.Create(self); FormOptions.CheckCourse; FormViewFile.MemoFile.OnMouseMove := MemoFilesTxtMouseMove; inherited; // Application.CreateForm(TFormViewFile, FormViewFile); // Application.CreateForm(TFormOptions, FormOptions); end; procedure TFormDemoWWW.FormCreate(Sender: TObject); var n:integer; begin Application.OnDeactivate := FormDeactivate; Application.ShowHint := true; ForceCurrentDirectory := true; FTaskCounter := TTask.Create(); FtaskCounter.DemoTexts := FormOptions.EditTypeComboBox.Items; FTask := TTask.Create(EditFile,EditTaskNumber,EditPoints,EditComment); FTask.OnChange := TaskChange; n := ParamCount; if ( n > 0 ) then begin if ( ParamStr(1) = '/u' ) then exit; if ( ParamStr(1) <> '/p' ) then Path := ParamStr(1); end else Path := '.'; if ( Path = '.' ) or (Path='.\') or ( Trim(Path) = '' ) then Path := GetCurrentDir(); if ( FileExists(FormOptions.FileName) ) then Path := GetCurrentDir(); if ( not FileExists(FileName) ) then begin DoNewFile; exit; end; LoadFile; end; procedure TFormDemoWWW.FormDestroy(Sender: TObject); begin FTask.Free; FTaskCounter.Free; end; procedure TFormDemoWWW.MarkLineVisible(n:integer); var SelStart,LineLen:integer; begin SelStart := SendMessage(MemoFilesTxt.Handle, EM_LINEINDEX, n, 0); if SelStart < 0 then Exit; LineLen := SendMessage(MemoFilesTxt.Handle, EM_LINELENGTH, SelStart, 0); if LineLen < 0 then Exit; MemoFilesTxt.SelStart := SelStart; MemoFilesTxt.SelLength := LineLen; CheckTaskWithLine; end; procedure TFormDemoWWW.MemoChange(b:boolean); begin if ( b ) then MemoFilesTxt.OnChange := MemoFilesTxtChange else MemoFilesTxt.OnChange := nil; end; procedure TFormDemoWWW.TaskChange(Sender: TObject); var y : integer; s: string; begin // y := MemoFilesTxt.CaretPos.y; y := LineNr; if ( FTask = nil ) or ( y < 0 ) then exit; s := FTask.AsString; MemoChange(false); MemoFilesTxt.Lines[y] := s; CountPoints; MemoChange(true); MarkLineVisible; ShowFile; end; procedure TFormDemoWWW.MemoFilesTxtKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin CheckTaskOnCurrentLine; end; procedure TFormDemoWWW.MemoFilesTxtChange(Sender: TObject); begin CheckTaskOnCurrentLine; CountPoints; end; function TFormDemoWWW.CheckDemoFile(const s: string): boolean; procedure Error(const err:string); begin SetForegroundWindow(self.Handle); ShowMessage(s +#13#10+err); end; var rel : string; begin rel := ExtractRelativePath(Path,s); Result := False; if ( Pos(':',rel) > 0 ) then begin Error('File must be in same disk with ' + FileName); Exit; end; if ( Pos('..\..',rel) > 0 ) then begin Error('File must be in same tree with ' + FileName); Exit; end; if ( DirectoryExists(s) ) then begin Error('Directory names not allowed '); Exit; end; Result := true; end; procedure TFormDemoWWW.SetDemoFile(s:string); begin if not CheckDemoFile(s) then exit; s := ExtractRelativePath(Path,s); EditFile.Text := ChangeAll(s,'\','/'); end; procedure TFormDemoWWW.DragEditFileNameDrop(Sender: TkDragTarget; pt: TPoint); begin if ( sender.Count = 0 ) then exit; SetDemoFile(sender.DropName[0]); end; function TFormDemoWWW.CheckIfFileAllreadyIn(const s:string):boolean; var i: integer; rel : string; begin Result := true; rel := ChangeAll(LowerCase(ExtractRelativePath(Path,s)),'\','/'); for i:=0 to MemoFilesTxt.Lines.Count-1 do begin FTaskCounter.AsString := MemoFilesTxt.Lines[i]; if ( LowerCase(FTaskCounter.FileName) = rel ) then exit; end; Result := false; end; procedure TFormDemoWWW.DragTargetMemoFilesTxtDrop(Sender: TkDragTarget; pt: TPoint); var i:integer; begin if ( sender.Count = 0 ) then exit; for i := 0 to sender.Count-1 do begin if ( not CheckDemoFile(sender.DropName[i]) ) then exit; if ( CheckIfFileAllreadyIn(sender.DropName[i]) ) then continue; AddRow; SetDemoFile(sender.DropName[i]); end; end; function CheckDir(const PathName:string):boolean; var s,p:string; begin Result := true; s := PathName; if ( s <> '' ) and ( s[Length(s)] = '\' ) then Delete(s,Length(s),1); p := GetCurrentDir(); if ( LowerCase(s) = LowerCase(p) ) then exit; try ChDir(s); except // ShowMessage('Can not change directory!'); Result := false; end; end; function TFormDemoWWW.AskDemoFile:boolean; begin Result := false; CheckDir(FormOptions.Path); OpenFiles.FileName := FileName; OpenFiles.InitialDir := FormOptions.Path; OpenFiles.FileName := ChangeAll(EditFile.Text,'/','\'); // OpenFiles.FileName := ExtractFileName(OpenFiles.FileName); if ( not OpenFiles.Execute ) then exit; Result := true; SetDemoFile(OpenFiles.FileName); end; procedure TFormDemoWWW.ButtonFilesClick(Sender: TObject); begin AskDemoFile; end; function TFormDemoWWW.GetFileName: string; begin Result := ChangeAll(FormOptions.Path+'\'+ FormOptions.FileName,'\\','\'); end; procedure TFormDemoWWW.SetPath(const Value: string); begin FormOptions.EditPath.Text := Value; end; function TFormDemoWWW.GetPath: string; begin Result := ChangeAll(FormOptions.Path+'\','\\','\'); end; procedure TFormDemoWWW.MemoFilesTxtKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); begin CheckTaskWithLine; end; procedure TFormDemoWWW.MemoFilesTxtDblClick(Sender: TObject); var SelStart : integer; begin SelStart := SendMessage(MemoFilesTxt.Handle, EM_LINEINDEX, LineNr, 0); MemoFilesTxt.SelStart := SelStart; AskDemoFile; end; procedure TFormDemoWWW.SetLineNr(const Value: integer); begin FLineNr := Value; StatusBar.Panels[0].Text := Format('%2d',[LineNr+1]); end; procedure TFormDemoWWW.MemoFilesTxtExit(Sender: TObject); begin MarkLineVisible; end; function TFormDemoWWW.Save:boolean; begin Result := true; try MemoFilesTxt.Lines.SaveToFile(FileName); MemoFilesTxt.Modified := false; except Result := false; ShowMessage('Can not save the file: '+FileName); end; end; function TFormDemoWWW.CheckSaved : boolean; var key : integer; begin Result := FormViewFile.CheckSaved; if ( not Result ) then exit; if ( not MemoFilesTxt.Modified ) then exit; key := MessageDlg(Format('File "%s" modified!%s Save?',[Filename,#13#10]), mtConfirmation,mbYesNoCancel,0); if ( key = mrNo ) then exit; if ( key = mrYes ) then begin Result := Save; exit; end; Result := false; end; procedure TFormDemoWWW.ActionFileSaveExecute(Sender: TObject); begin Save; end; procedure TFormDemoWWW.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin CanClose := CheckSaved; end; function TFormDemoWWW.DoNewFile : boolean; begin if FormOptions.CBShowOptions.Checked and ( not FormUserListVisible ) then FormOptions.ShowModal; MemoChange(false); MemoFilesTxt.Lines.Clear; MarkLineVisible(0); AddLineRow; AddDemoRow; AddLineRow; AddRow; MemoFilesTxt.Modified := true; MemoChange(true); PutCaption; CheckTaskWithLine; CountPoints; Result := true; end; function TFormDemoWWW.AskAndCreateNewFile : boolean; begin Result := false; if ( not CheckSaved ) then exit; SaveDialog.InitialDir := FormOptions.Path; SaveDialog.FileName := FormOptions.FileName; if ( not SaveDialog.Execute ) then exit; Path := ExtractFilePath(SaveDialog.FileName); // FormOptions.EditFileName.AsString := ExtractFileName(SaveDialog.FileName); CheckDir(Path); Result := DoNewFile; end; procedure TFormDemoWWW.ActionFileNewExecute(Sender: TObject); begin AskAndCreateNewFile; end; procedure TFormDemoWWW.CountPoints; var sum : double; i: integer; dnr : double; begin sum := 0; dnr := 0; FTaskCounter.DemoType := DemoType; for i:=0 to MemoFilesTxt.Lines.Count-1 do begin FTaskCounter.AsString := MemoFilesTxt.Lines[i]; sum := sum + FTaskCounter.Points; if ( dnr = 0 ) then dnr := FTaskCounter.DemoNr; if ( dnr > 0 ) then begin DemoType := FTaskCounter.DemoType; DemoNr := dnr; dnr := -1; end; // set only first end; StatusBar.Panels[1].Text := Format('%.2f',[sum]); if ( MemoFilesTxt.Lines.Count > 2 ) and ( dnr = 0 ) then DemoNr := 0; end; function TFormDemoWWW.FindTask(const t:string) : boolean; var i: integer; begin Result := True; if ( t = '' ) then exit; for i:=0 to MemoFilesTxt.Lines.Count-1 do begin FTaskCounter.AsString := MemoFilesTxt.Lines[i]; if ( FTaskCounter.TaskDone(t) ) then begin MarkLineVisible(i); exit; end; end; MarkLineVisible(0); Result := false; end; procedure TFormDemoWWW.CheckTaskVisible; begin PanelTaskAndNumber.Visible := FormOptions.Demo; end; procedure TFormDemoWWW.CheckIfDemoNrOkInMemoFiles; var i: integer; dnr : double; begin FTaskCounter.DemoType := DemoType; for i:=0 to MemoFilesTxt.Lines.Count-1 do begin FTaskCounter.AsString := MemoFilesTxt.Lines[i]; dnr := FTaskCounter.DemoNr; if ( dnr > 0 ) then begin if ( DemoNr <> dnr ) or ( FTaskCounter.DemoType <> DemoType ) then begin MemoChange(false); MemoFilesTxt.Lines.Delete(i); MarkLineVisible(i); AddDemoRow; MarkLineVisible(i); MemoChange(true); LineNr :=i; CheckTaskOnCurrentLine; end; exit; end; end; if ( DemoNr > 0 ) then begin MemoChange(false); LineNr := 1; MemoFilesTxt.Lines.Delete(1); AddDemoRow; MemoChange(true); end; // if ( MemoFilesTxt.Lines.Count > 2 ) then FormOptions.EditDemoNrEditDouble.Value := 0; end; procedure TFormDemoWWW.CheckFileSyntaxInMemoFiles; var i: integer; begin for i:=0 to MemoFilesTxt.Lines.Count-1 do begin FTaskCounter.AsString := MemoFilesTxt.Lines[i]; if ( FTaskCounter.AsString <> MemoFilesTxt.Lines[i] ) then MemoFilesTxt.Lines[i] := FTaskCounter.AsString end; end; procedure TFormDemoWWW.RunCommand(const s:string); //var com,param:string; begin if ( not CheckSaved ) then exit; CheckDir(FormOptions.Path); // param := s; // com := Separate(param,' '); WinExec(PChar(s),SW_SHOW); // ShellExecute(Handle,'open',PChar(com),PChar(param),'',SW_SHOW); // ShellExecute(handle, nil, '.', nil, nil, SW_SHOWNORMAL); end; procedure TFormDemoWWW.ActionFilePreviewExecute(Sender: TObject); begin RunCommand(FormOptions.PreviewCommand); end; procedure TFormDemoWWW.ActionFileCopyToWWWExecute(Sender: TObject); begin RunCommand(FormOptions.Command); end; procedure TFormDemoWWW.ActionFileTestExecute(Sender: TObject); begin RunCommand(FormOptions.TestDemoCommand); end; procedure TFormDemoWWW.AddLineRow; begin MemoFilesTxt.Lines.Insert(LineNr,'=----------------------------------------'); end; procedure TFormDemoWWW.AddDemoRow; begin if ( FormOptions.Demo ) then MemoFilesTxt.Lines.Insert(LineNr,Format('= %s %g',[DemoType,DemoNr])) else MemoFilesTxt.Lines.Insert(LineNr,Format('= %s',[DemoType])); CheckTaskVisible; end; procedure TFormDemoWWW.ActionEditAddLineExecute(Sender: TObject); begin AddLineRow; end; procedure TFormDemoWWW.ActionEditDeleteLineExecute(Sender: TObject); begin if ( LineNr < 0 ) then exit; Clipboard.AsText := MemoFilesTxt.Lines[LineNr]+#13#10; MemoFilesTxt.Lines.Delete(LineNr); end; procedure TFormDemoWWW.AddRow; var n : integer; begin n := MemoFilesTxt.Lines.Add('='); MarkLineVisible(n); CheckTaskWithLine; end; procedure TFormDemoWWW.ActionAddRowExecute(Sender: TObject); begin AddRow; end; procedure TFormDemoWWW.ActionMoveLastExecute(Sender: TObject); begin MarkLineVisible(MemoFilesTxt.Lines.Count); end; procedure TFormDemoWWW.ActionMoveFirstExecute(Sender: TObject); begin MarkLineVisible(0); end; procedure TFormDemoWWW.ActionMoveNextExecute(Sender: TObject); begin MarkLineVisible(LineNr+1); end; procedure TFormDemoWWW.ActionMovePriorExecute(Sender: TObject); begin MarkLineVisible(LineNr-1); end; procedure TFormDemoWWW.FormDeactivate(Sender: TObject); begin MarkLineVisible; end; procedure TFormDemoWWW.MemoFilesTxtMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var MShift : TShiftState; begin if AlreadyDragging then exit; if ( EditFile.Text = '' ) then exit; MShift := Shift * [ssLeft,ssRight]; if (Shift = [ssLeft]) or ( MShift = [] ) or ((abs(DragPoint.X - X) <10) and (abs(DragPoint.Y - Y) <10)) then exit; DropFileSource1.Files.clear; DropFileSource1.Files.Add(Path+EditFile.Text); AlreadyDragging := true; DropFileSource1.execute; AlreadyDragging := false; end; procedure TFormDemoWWW.ActionHelpContentsExecute(Sender: TObject); var s:string; begin s := ChangeFileExt(Application.ExeName,'.html'); ShellExecute(Handle,'open',PChar(s),nil,'',SW_SHOW); end; function TFormDemoWWW.GetDemoNr: double; begin Result := FormOptions.DemoNr; end; procedure TFormDemoWWW.SetDemoNr(const Value: double); begin FormOptions.DemoNr := Value; if ( Value = 0 ) then FormOptions.Demo := false; CheckTaskVisible; end; function TFormDemoWWW.GetDemoType: string; begin Result := FormOptions.DemoType; end; procedure TFormDemoWWW.SetDemoType(const Value: string); begin FormOptions.DemoType := Value; CheckTaskVisible; end; type TFontControl = class(TControl) public property Font; end; procedure TFormDemoWWW.ChooseFont(ctrl:TControl); var memo : TFontControl; begin memo := TFontControl(ctrl); FontDialog1.Font := memo.Font; if ( not FontDialog1.Execute ) then exit; memo.Font := FontDialog1.Font; SaveFont; end; procedure TFormDemoWWW.IncreaseFont(ctrl:TControl); var memo : TFontControl; begin memo := TFontControl(ctrl); memo.Font.Size := memo.Font.Size + 1; SaveFont; end; procedure TFormDemoWWW.DecreaseFont(ctrl:TControl); var memo : TFontControl; begin memo := TFontControl(ctrl); memo.Font.Size := memo.Font.Size - 1; SaveFont; end; procedure TFormDemoWWW.FlipCharSet(ctrl:TControl); var memo : TFontControl; begin memo := TFontControl(ctrl); if ( memo.Font.Charset = OEM_CHARSET ) then memo.Font.Charset := ANSI_CHARSET else memo.Font.Charset := OEM_CHARSET end; procedure TFormDemoWWW.SaveFont; begin EditFileFont.Text := FontToStr(FormViewFile.MemoFile.Font); end; procedure TFormDemoWWW.EditFileFontChange(Sender: TObject); begin StrToFont(EditFileFont.Text,FormViewFile.MemoFile.Font); end; procedure TFormDemoWWW.ActionViewFileFontExecute(Sender: TObject); begin ChooseFont(FormViewFile.MemoFile); end; procedure TFormDemoWWW.ActionViewFileFontPlusExecute(Sender: TObject); begin IncreaseFont(FormViewFile.MemoFile); end; procedure TFormDemoWWW.ActionViewFileFontMinusExecute(Sender: TObject); begin DecreaseFont(FormViewFile.MemoFile); end; procedure TFormDemoWWW.ActionViewFlipFileCharSetExecute(Sender: TObject); begin FlipCharSet(FormViewFile.MemoFile); end; procedure TFormDemoWWW.ActionViewUserListExecute(Sender: TObject); begin FormUserListView(self); end; procedure TFormDemoWWW.FormShow(Sender: TObject); begin if ( ParamStr(1) = '/u' ) then begin Show; FormUserListView(self,ParamStr(2)); exit; end; end; procedure TFormDemoWWW.ActionViewNextUserExecute(Sender: TObject); begin FormUserListUser(1); end; procedure TFormDemoWWW.ActionViewPreviousUserExecute(Sender: TObject); begin FormUserListUser(-1); end; procedure TFormDemoWWW.ActionViewRandomUserExecute(Sender: TObject); begin FormUserListUser(0); end; end.