1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, IniFiles, StdCtrls, ComCtrls, jpeg, ExtCtrls, DateUtils;
type TForm1 = class(TForm) Panel1: TPanel; Panel2: TPanel; Image1: TImage; Button1: TButton; Button2: TButton; Label1: TLabel; procedure FormCreate(Sender: TObject); private procedure editEvent(sender : TObject); procedure Label_erstellen(aname, text: String; tmpleft, tmptop, LabelIndex: Integer; Komponent : TComponent; WinKontrol: TWinControl); public end;
var Form1: TForm1; LabelArray: array of TLabel;
implementation
{$R *.dfm}
function Teilstring_Ersetzen(Text, Suchen, Ersetzen:String):String; var Flags: TReplaceFlags; begin Flags:=[]; Flags:=[rfIgnoreCase]; result:=StringReplace(Text, Suchen, Ersetzen, Flags); end;
function Zeichen_Ersetzen(Text: String; altZeichen: char; neuZeichen: char):String; begin while Pos(altZeichen, Text) > 0 do Text[Pos(altZeichen, Text)] := neuZeichen; result:= Text; end;
procedure LinkFarbe(Index: Integer); var i: Integer; begin for i:=0 to 29 do begin if LabelArray[i] <> nil then begin LabelArray[i].Font.Color := clBlue; end; end; LabelArray[Index].Font.Color := clGray; end;
procedure Bild_Laden(Pfad: String); var tmpFloat: Extended; begin Pfad := Teilstring_Ersetzen(Pfad, 'Jahr', IntToSTr(YearOf(now))); Pfad := Teilstring_Ersetzen(Pfad, 'Monat', FormatDateTime('mmmmm', now)); Form1.Image1.Picture.LoadFromFile(Pfad);
tmpFloat := Form1.Image1.Picture.Width / 100; tmpFloat := Form1.Image1.Width / tmpFloat; tmpFloat := (Form1.Image1.Picture.Height / 100) * tmpFloat; Form1.Image1.Height := Trunc(tmpFloat); end;
procedure MenueAktualisieren(Komponent : TComponent; WinKontrol: TWinControl; aktLink: String); var LinkAnzahl1, LinkAnzahl2, LinkAnzahl3, LinkAnzahl4, LinkAnzahl5, LinkAnzahl6, LinkAnzahl7: Integer; a, b, c, d, e, f: Integer; tmpLink1, tmpLink2, tmpLink3, tmpLink4, tmpLink5, tmpLink6, tmpLink7: String; LabelIndex, top: Integer;
ini: TiniFile; Dauer, tmp: Integer; sl: TStringList; i, oben: Integer; tmpStr, tmpPfad, pfad: String; begin LabelIndex := 0; top := 60; pfad := ExtractFilePath(ParamStr(0)); pfad := pfad + 'CockpitChart.ini'; ini:=TIniFile.Create(pfad); LinkAnzahl1 := ini.ReadInteger('RootItems','RootItemsCount', LinkAnzahl1); for a:=1 to LinkAnzahl1 do begin tmpStr := ini.ReadString('RootItems', 'Item' + IntToStr(a), tmpStr); tmpLink1 := 'Link' + IntToStr(a); Form1.Label_erstellen(tmpLink1, tmpStr, 5, top, LabelIndex, Komponent, WinKontrol); inc(LabelIndex); top := top + 20; LinkAnzahl2 := ini.ReadInteger(tmpLink1,'ItemsCount', LinkAnzahl2);
if copy(aktLink, 1, 5) = tmpLink1 then begin tmpPfad := ini.ReadString('RootItems', 'Image' + IntToStr(a), tmpPfad); Bild_Laden(tmpPfad); LinkFarbe(LabelIndex-1); for b:=1 to LinkAnzahl2 do begin tmpStr := ini.ReadString(tmpLink1, 'Item' + IntToStr(b), tmpStr); tmpLink2 := 'Link' + IntToStr(a) + '.' + IntToStr(b); Form1.Label_erstellen(tmpLink2, tmpStr, 15, top, LabelIndex, Komponent, WinKontrol); inc(LabelIndex); top := top + 20; LinkAnzahl3 := ini.ReadInteger(tmpLink2,'ItemsCount', LinkAnzahl2);
if copy(aktLink, 1, 7) = tmpLink2 then begin tmpPfad := ini.ReadString(tmpLink1, 'Image' + IntToStr(b), tmpPfad); Bild_Laden(tmpPfad); LinkFarbe(LabelIndex-1); for c:=1 to LinkAnzahl3 do begin tmpStr := ini.ReadString(tmpLink2, 'Item' + IntToStr(c), tmpStr); tmpLink3 := 'Link' + IntToStr(a) + '.' + IntToStr(b) + '.' + IntToStr(c); Form1.Label_erstellen(tmpLink3, tmpStr, 25, top, LabelIndex, Komponent, WinKontrol); inc(LabelIndex); top := top + 20; LinkAnzahl4 := ini.ReadInteger(tmpLink3,'ItemsCount', LinkAnzahl4);
if copy(aktLink, 1, 9) = tmpLink3 then begin tmpPfad := ini.ReadString(tmpLink2, 'Image' + IntToStr(c), tmpPfad); Bild_Laden(tmpPfad); LinkFarbe(LabelIndex-1); for d:=1 to LinkAnzahl4 do begin tmpStr := ini.ReadString(tmpLink3, 'Item' + IntToStr(d), tmpStr); tmpLink4 := 'Link' + IntToStr(a) + '.' + IntToStr(b) + '.' + IntToStr(c) + '.' + IntToStr(d); Form1.Label_erstellen(tmpLink4, tmpStr, 35, top, LabelIndex, Komponent, WinKontrol); inc(LabelIndex); top := top + 20; LinkAnzahl5 := ini.ReadInteger(tmpLink4,'ItemsCount', LinkAnzahl5);
if copy(aktLink, 1, 11) = tmpLink4 then begin tmpPfad := ini.ReadString(tmpLink3, 'Image' + IntToStr(d), tmpPfad); Bild_Laden(tmpPfad); LinkFarbe(LabelIndex-1); for e:=1 to LinkAnzahl5 do begin tmpStr := ini.ReadString(tmpLink4, 'Item' + IntToStr(e), tmpStr); tmpLink5 := 'Link' + IntToStr(a) + '.' + IntToStr(b) + '.' + IntToStr(c) + '.' + IntToStr(d) + '.' + IntToStr(e); Form1.Label_erstellen(tmpLink5, tmpStr, 45, top, LabelIndex, Komponent, WinKontrol); inc(LabelIndex); top := top + 20; LinkAnzahl6 := ini.ReadInteger(tmpLink5,'ItemsCount', LinkAnzahl6);
if copy(aktLink, 1, 13) = tmpLink5 then begin tmpPfad := ini.ReadString(tmpLink4, 'Image' + IntToStr(d), tmpPfad); Bild_Laden(tmpPfad); LinkFarbe(LabelIndex-1); for f:=1 to LinkAnzahl6 do begin tmpStr := ini.ReadString(tmpLink5, 'Item' + IntToStr(f), tmpStr); tmpLink6 := 'Link' + IntToStr(a) + '.' + IntToStr(b) + '.' + IntToStr(c) + '.' + IntToStr(d) + '.' + IntToStr(e) + '.' + IntToStr(f); Form1.Label_erstellen(tmpLink6, tmpStr, 55, top, LabelIndex, Komponent, WinKontrol); inc(LabelIndex); top := top + 20; LinkAnzahl7 := ini.ReadInteger(tmpLink6,'ItemsCount', LinkAnzahl7);
if copy(aktLink, 1, 15) = tmpLink6 then begin tmpPfad := ini.ReadString(tmpLink5, 'Image' + IntToStr(f), tmpPfad); Bild_Laden(tmpPfad); LinkFarbe(LabelIndex-1); end; end; end; end; end; end; end; end; end; end; end; end; end;
procedure TForm1.Label_erstellen(aname, text: String; tmpleft, tmptop, LabelIndex: Integer; Komponent : TComponent; WinKontrol: TWinControl); var Test: TLabel; begin aname := Zeichen_Ersetzen(aname, '.', '_'); LabelArray[LabelIndex] := TLabel.Create(Komponent);
with LabelArray[LabelIndex] do begin parent := WinKontrol; left := tmpleft; top := tmptop; name := aname; Caption := text; onClick := editEvent; if Screen.Width <= 1360 then font.size := 8 else font.size := 12; font.color := clBlue; end; end;
procedure TForm1.editEvent(sender : TObject); var name: String; i: Integer; begin name := TLabel(sender).Name; name := Zeichen_Ersetzen(name, '_', '.');
for i:=0 to 29 do begin if LabelArray[i] <> nil then begin LabelArray[i].Free; LabelArray[i] := nil; end; end;
MenueAktualisieren(self, self, name); end;
procedure TForm1.FormCreate(Sender: TObject); var Fensterbreite, tmp: Integer; begin SetLength(LabelArray, 30); MenueAktualisieren(self, self, 'Link2.2');
if Screen.Width <= 1360 then begin
Image1.Left := 150; end else Image1.Left := 240;
Fensterbreite := Screen.Width; Label1.Left := (Fensterbreite div 2) - (Label1.Width div 2);
Form1.Panel1.Left := 0; Form1.Panel1.Width := Fensterbreite;
Image1.Width := (Fensterbreite - Image1.Left) - 10;
tmp := Fensterbreite - Image1.left; tmp := tmp div 2; tmp := tmp + Image1.Left - (Button1.Width div 2); Button1.Left := tmp ;
tmp := Fensterbreite - Image1.left; tmp := tmp div 2; tmp := tmp + Image1.Left - (Button2.Width div 2); Button2.Left := tmp ; Form1.Color := RGB(15, 185, 185); Form1.Panel1.Color := RGB(15, 185, 185);
Button1.Top := Image1.Top + Image1.Height + 50; Button2.Top := Image1.Top + Image1.Height + 80; Form1.WindowState := wsMaximized; end;
end. |