Check-in [05c2a5be28]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Show selected monitor border on main form, and draw each respective monitor's image. Click to (de)select a monitor. Read random file from local directory.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 05c2a5be289348c89f4a3d6008d9bb0e87fa5ba2
User & Date: tinus 2014-12-01 20:42:14
Context
2014-12-01
20:52
Added file for to-dos, ideas, etc. check-in: 703b671e0a user: tinus tags: trunk
20:42
Show selected monitor border on main form, and draw each respective monitor's image. Click to (de)select a monitor. Read random file from local directory. check-in: 05c2a5be28 user: tinus tags: trunk
2014-11-07
23:06
Start using FreeImage to load images. Added DataModule to host the tray icon and its menu. Main form can now show a scaled version of the desktop, and allows for selection of separate monitors. check-in: aeddb28d5f user: tinus tags: trunk
Changes

Changes to src/F_Main.dfm.

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
      Height = 210
      Align = alClient
      OnClick = pbxDesktopClick
      OnPaint = pbxDesktopPaint
      ExplicitLeft = 0
    end
    object shpMonitor: TShape
      Left = 176
      Top = 104
      Width = 65
      Height = 65
      Brush.Style = bsClear
      Pen.Mode = pmNot
      Pen.Style = psDot
      OnMouseDown = shpMonitorMouseDown
    end
  end
end







|
|
|
|







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
      Height = 210
      Align = alClient
      OnClick = pbxDesktopClick
      OnPaint = pbxDesktopPaint
      ExplicitLeft = 0
    end
    object shpMonitor: TShape
      Left = 1
      Top = 1
      Width = 280
      Height = 210
      Brush.Style = bsClear
      Pen.Mode = pmNot
      Pen.Style = psDot
      OnMouseDown = shpMonitorMouseDown
    end
  end
end

Changes to src/F_Main.pas.

26
27
28
29
30
31
32



33
34
35
36
37
38
39
..
41
42
43
44
45
46
47
48
49
50
51



52
53
54
55
56
57
58
..
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
  end;

var
  frmMain: TfrmMain;

implementation




{$R *.dfm}

procedure TfrmMain.FormCreate(Sender: TObject);
var
  i: integer;
begin
  SetLength(FMonitorShape, Screen.MonitorCount);
................................................................................
    if Screen.Monitors[i].Primary then begin
      FMonitorShape[i] := shpMonitor;
    end else begin
      FMonitorShape[i] := TShape.Create(Self);
      FMonitorShape[i].Parent := pnlDesktop;
      FMonitorShape[i].OnMouseDown := shpMonitorMouseDown;
      FMonitorShape[i].Brush.Style := bsClear;
      FMonitorShape[i].Pen.Style := psDot;
      FMonitorShape[i].Pen.Mode := pmNot;
      FMonitorShape[i].Visible := True;
    end;



  end;
end;

procedure TfrmMain.FormResize(Sender: TObject);
var
  ScaleFactor: Double;
  DR, MR: TRect;
................................................................................
  end;
end;

procedure TfrmMain.pbxDesktopClick(Sender: TObject);
var
  i: Integer;
begin

  for i := Low(FMonitorShape) to High(FMonitorShape) do begin
    FMonitorShape[i].Pen.Style := psDot;
  end;
end;

procedure TfrmMain.pbxDesktopPaint(Sender: TObject);



begin


  modMain.Desktop.Draw(pbxDesktop.Canvas, pbxDesktop.BoundsRect);






end;

procedure TfrmMain.shpMonitorMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  i: Integer;
begin

  for i := Low(FMonitorShape) to High(FMonitorShape) do begin
    if (Sender = FMonitorShape[i]) and (FMonitorShape[i].Pen.Style = psDot) then begin
      FMonitorShape[i].Pen.Style := psSolid;
    end else begin
      FMonitorShape[i].Pen.Style := psDot;
    end;
  end;
end;

end.







>
>
>







 







|



>
>
>







 







>

|




>
>
>

>
>
|
>
>
>
>
>
>







>

|
|

|





26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
..
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
..
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
  end;

var
  frmMain: TfrmMain;

implementation

uses
  U_WPImages;

{$R *.dfm}

procedure TfrmMain.FormCreate(Sender: TObject);
var
  i: integer;
begin
  SetLength(FMonitorShape, Screen.MonitorCount);
................................................................................
    if Screen.Monitors[i].Primary then begin
      FMonitorShape[i] := shpMonitor;
    end else begin
      FMonitorShape[i] := TShape.Create(Self);
      FMonitorShape[i].Parent := pnlDesktop;
      FMonitorShape[i].OnMouseDown := shpMonitorMouseDown;
      FMonitorShape[i].Brush.Style := bsClear;
      FMonitorShape[i].Pen.Style := psClear;
      FMonitorShape[i].Pen.Mode := pmNot;
      FMonitorShape[i].Visible := True;
    end;
  end;
  if Screen.MonitorCount = 1 then begin
    shpMonitor.Visible := False;
  end;
end;

procedure TfrmMain.FormResize(Sender: TObject);
var
  ScaleFactor: Double;
  DR, MR: TRect;
................................................................................
  end;
end;

procedure TfrmMain.pbxDesktopClick(Sender: TObject);
var
  i: Integer;
begin
  // TODO: select desktop in list
  for i := Low(FMonitorShape) to High(FMonitorShape) do begin
    FMonitorShape[i].Pen.Style := psClear;
  end;
end;

procedure TfrmMain.pbxDesktopPaint(Sender: TObject);
var
  i: integer;
  MonImg: TWPImage;
begin
  pbxDesktop.Canvas.FillRect(pbxDesktop.BoundsRect);
  if Assigned(modMain.Desktop) then
    modMain.Desktop.Draw(pbxDesktop.Canvas, pbxDesktop.BoundsRect);
  for i := 0 to modMain.Monitors.Count - 1 do begin
    MonImg := modMain.Monitors[i];
    if Assigned(MonImg) then begin
      MonImg.Draw(pbxDesktop.Canvas, FMonitorShape[i].BoundsRect);
    end;
  end;
end;

procedure TfrmMain.shpMonitorMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  i: Integer;
begin
  // TODO: select given monitor in list
  for i := Low(FMonitorShape) to High(FMonitorShape) do begin
    if (Sender = FMonitorShape[i]) and (FMonitorShape[i].Pen.Style = psClear) then begin
      FMonitorShape[i].Pen.Style := psDot;
    end else begin
      FMonitorShape[i].Pen.Style := psClear;
    end;
  end;
end;

end.

Changes to src/M_Main.pas.

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
  end;

var
  modMain: TmodMain;

implementation
uses

  Forms,
  F_Main;

{%CLASSGROUP 'Vcl.Controls.TControl'}

{$R *.dfm}

procedure TmodMain.DataModuleCreate(Sender: TObject);
var
  i: Integer;

begin
  FDesktop := TWPImage.Create('C:\MC\MM\Image\Work\Background\composite\Chateau_de_Lassay_2.bmp');

  FMonitors := TWPImages.Create;
  for i := 0 to Screen.MonitorCount - 1 do begin
    FMonitors.Add(nil);

  end;

  trayIcon.Icon.Assign(Application.Icon);
  trayIcon.Visible := True;
end;

procedure TmodMain.DataModuleDestroy(Sender: TObject);







>
|









>

|
>


<
>







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
  end;

var
  modMain: TmodMain;

implementation
uses
  System.IOUtils, System.Types,
  Vcl.Forms,
  F_Main;

{%CLASSGROUP 'Vcl.Controls.TControl'}

{$R *.dfm}

procedure TmodMain.DataModuleCreate(Sender: TObject);
var
  i: Integer;
  Files: TStringDynArray;
begin
  FDesktop := nil; // TWPImage.Create('C:\MC\MM\Image\Work\Background\composite\Chateau_de_Lassay_2.bmp');
  Files := TDirectory.GetFiles('C:\MC\MM\Image\Work\Background\single', '*.jpg', TSearchOption.soAllDirectories);
  FMonitors := TWPImages.Create;
  for i := 0 to Screen.MonitorCount - 1 do begin

    FMonitors.Add(TWPImage.Create(Files[Random(Length(Files))]));
  end;

  trayIcon.Icon.Assign(Application.Icon);
  trayIcon.Visible := True;
end;

procedure TmodMain.DataModuleDestroy(Sender: TObject);