📄 qilineargaugecomponenteditor.pas
字号:
ShowTicksMinorCheckBox.AsBoolean := iLinearGauge.ShowTicksMinor;
TickMinorCountEdit.AsInteger := iLinearGauge.TickMinorCount;
TickMinorLengthEdit.AsInteger := iLinearGauge.TickMinorLength;
TickMinorColorPicker.Color := iLinearGauge.TickMinorColor;
TickMinorAlignmentRadioGroup.AsInteger := ord(iLinearGauge.TickMinorAlignment);
TickMinorStyleRadioGroup.AsInteger := ord(iLinearGauge.TickMinorStyle);
//-------------- Sections --------------------------------------------------------------------------------------------------------------------------
SectionCountEdit.AsInteger := iLinearGauge.SectionCount;
SectionColor1Picker.Color := iLinearGauge.SectionColor1;
SectionColor2Picker.Color := iLinearGauge.SectionColor2;
SectionColor3Picker.Color := iLinearGauge.SectionColor3;
SectionColor4Picker.Color := iLinearGauge.SectionColor4;
SectionColor5Picker.Color := iLinearGauge.SectionColor5;
SectionEnd1Edit.AsFloat := iLinearGauge.SectionEnd1;
SectionEnd2Edit.AsFloat := iLinearGauge.SectionEnd2;
SectionEnd3Edit.AsFloat := iLinearGauge.SectionEnd3;
SectionEnd4Edit.AsFloat := iLinearGauge.SectionEnd4;
//-------------- AutoScale --------------------------------------------------------------------------------------------------------------------------
AutoScaleDesiredTicksEdit.AsInteger := iLinearGauge.AutoScaleDesiredTicks;
AutoScaleMaxTicksEdit.AsInteger := iLinearGauge.AutoScaleMaxTicks;
AutoScaleEnabledCheckBox.AsBoolean := iLinearGauge.AutoScaleEnabled;
AutoScaleStyleRadioGroup.AsInteger := ord(iLinearGauge.AutoScaleStyle);
UpLoadOPCProperties(iLinearGauge, iOPCBrowserPanel);
FPointerManager.Clear;
for x := 0 to iLinearGauge.PointerCount-1 do
begin
FPointerManager.Add;
FPointerManager.Items[x].Visible := iLinearGauge.Pointers[x].Visible;
FPointerManager.Items[x].Position := iLinearGauge.Pointers[x].Position;
FPointerManager.Items[x].Size := iLinearGauge.Pointers[x].Size;
FPointerManager.Items[x].Margin := iLinearGauge.Pointers[x].Margin;
FPointerManager.Items[x].Color := iLinearGauge.Pointers[x].Color;
FPointerManager.Items[x].Style := iLinearGauge.Pointers[x].Style;
end;
TickLabelFontPicker.Font.Assign(iLinearGauge.TickLabelFont);
if iPointerListBox.Items.Count > FLastPointerIndex then iPointerListBox.ItemIndex := FLastPointerIndex;
UpdatePointers;
end;
//****************************************************************************************************************************************************
procedure TiLinearGaugeComponentEditorForm.CopyPropertiesToComponent(Component: TWinControl);
var
iLinearGauge : TiLinearGauge;
x : Integer;
begin
iLinearGauge := Component as TiLinearGauge;
//-------------- General ---------------------------------------------------------------------------------------------------------------------------
iLinearGauge.AutoScaleEnabled := False; //Required to set Min & Max before AutoScale Activates
iLinearGauge.PositionMax := PositionMaxEdit.AsFloat;
iLinearGauge.PositionMin := PositionMinEdit.AsFloat;
iLinearGauge.CurrentMax := CurrentMaxEdit.AsFloat;
iLinearGauge.CurrentMin := CurrentMinEdit.AsFloat;
iLinearGauge.EndsMargin := EndsMarginEdit.AsInteger;
iLinearGauge.BackGroundColor := BackGroundColorPicker.Color;
iLinearGauge.BorderStyle := TiBevelStyle(BorderStyleRadioGroup.AsInteger);
iLinearGauge.Orientation := TiOrientation(OrientationRadioGroup.AsInteger);
iLinearGauge.OrientationTickMarks := TiOrientationSide(OrientationTickMarksRadioGroup.AsInteger);
iLinearGauge.PrecisionStyle := TiPrecisionStyle(PrecisionStyleRadioGroup.AsInteger);
iLinearGauge.ReverseScale := ReverseScaleCheckBox.AsBoolean;
iLinearGauge.CachedDrawing := CachedDrawingCheckBox.AsBoolean;
iLinearGauge.Transparent := TransparentCheckBox.AsBoolean;
iLinearGauge.AutoFrameRate := AutoFrameRateCheckBox.AsBoolean;
iLinearGauge.AutoCenter := AutoCenterCheckBox.AsBoolean;
iLinearGauge.UpdateFrameRate := UpdateFrameRateEdit.AsInteger;
iLinearGauge.OffsetX := OffsetXEdit.AsInteger;
iLinearGauge.OffsetY := OffsetYEdit.AsInteger;
//-------------- Pointers --------------------------------------------------------------------------------------------------------------------------
iLinearGauge.MinMaxPointerSize := MinMaxPointerSizeEdit.AsInteger;
iLinearGauge.MinMaxPointerMargin := MinMaxPointerMarginEdit.AsInteger;
iLinearGauge.MinMaxFixed := MinMaxFixedCheckBox.AsBoolean;
iLinearGauge.MinMaxUserCanMove := MinMaxUserCanMoveCheckBox.AsBoolean;
iLinearGauge.ShowMaxPointer := ShowMaxPointerCheckBox.AsBoolean;
iLinearGauge.MaxPointerColor := MaxPointerColorPicker.Color;
iLinearGauge.ShowMinPointer := ShowMinPointerCheckBox.AsBoolean;
iLinearGauge.MinPointerColor := MinPointerColorPicker.Color;
//-------------- Ticks -----------------------------------------------------------------------------------------------------------------------------
iLinearGauge.ShowTicksAxis := ShowTicksAxisCheckBox.AsBoolean;
iLinearGauge.TickMargin := TickMarginEdit.AsInteger;
iLinearGauge.ShowTickLabels := ShowTickLabelsCheckBox.AsBoolean;
iLinearGauge.TickLabelPrecision := TickLabelPrecisionEdit.AsInteger;
iLinearGauge.TickLabelMargin := TickLabelMarginEdit.AsInteger;
iLinearGauge.ShowTicksMajor := ShowTicksMajorCheckBox.AsBoolean;
iLinearGauge.TickMajorCount := TickMajorCountEdit.AsInteger;
iLinearGauge.TickMajorLength := TickMajorLengthEdit.AsInteger;
iLinearGauge.TickMajorColor := TickMajorColorPicker.Color;
iLinearGauge.TickMajorStyle := TiBevelStyle(TickMajorStyleRadioGroup.AsInteger);
iLinearGauge.ShowTicksMinor := ShowTicksMinorCheckBox.AsBoolean;
iLinearGauge.TickMinorCount := TickMinorCountEdit.AsInteger;
iLinearGauge.TickMinorLength := TickMinorLengthEdit.AsInteger;
iLinearGauge.TickMinorColor := TickMinorColorPicker.Color;
iLinearGauge.TickMinorAlignment := TiTickMinorAlignment(TickMinorAlignmentRadioGroup.AsInteger);
iLinearGauge.TickMinorStyle := TiBevelStyle(TickMinorStyleRadioGroup.AsInteger);
//-------------- Sections --------------------------------------------------------------------------------------------------------------------------
iLinearGauge.SectionCount := SectionCountEdit.AsInteger;
iLinearGauge.SectionColor1 := SectionColor1Picker.Color;
iLinearGauge.SectionColor2 := SectionColor2Picker.Color;
iLinearGauge.SectionColor3 := SectionColor3Picker.Color;
iLinearGauge.SectionColor4 := SectionColor4Picker.Color;
iLinearGauge.SectionColor5 := SectionColor5Picker.Color;
iLinearGauge.SectionEnd1 := SectionEnd1Edit.AsFloat;
iLinearGauge.SectionEnd2 := SectionEnd2Edit.AsFloat;
iLinearGauge.SectionEnd3 := SectionEnd3Edit.AsFloat;
iLinearGauge.SectionEnd4 := SectionEnd4Edit.AsFloat;
//-------------- AutoScale --------------------------------------------------------------------------------------------------------------------------
iLinearGauge.AutoScaleDesiredTicks := AutoScaleDesiredTicksEdit.AsInteger;
iLinearGauge.AutoScaleMaxTicks := AutoScaleMaxTicksEdit.AsInteger;
iLinearGauge.AutoScaleStyle := TiAutoScaleStyle(AutoScaleStyleRadioGroup.AsInteger);
iLinearGauge.AutoScaleEnabled := AutoScaleEnabledCheckBox.AsBoolean;
DownLoadOPCProperties(iLinearGauge, iOPCBrowserPanel);
iLinearGauge.RemoveAllPointers;
for x := 0 to FPointerManager.Count-1 do
begin
if x <> 0 then iLinearGauge.AddPointer;
iLinearGauge.Pointers[x].Visible := FPointerManager.Items[x].Visible;
iLinearGauge.Pointers[x].Position := FPointerManager.Items[x].Position;
iLinearGauge.Pointers[x].Size := FPointerManager.Items[x].Size;
iLinearGauge.Pointers[x].Margin := FPointerManager.Items[x].Margin;
iLinearGauge.Pointers[x].Color := FPointerManager.Items[x].Color;
iLinearGauge.Pointers[x].Style := FPointerManager.Items[x].Style;
end;
iLinearGauge.TickLabelFont.Assign(TickLabelFontPicker.Font);
FLastPointerIndex := iPointerListBox.ItemIndex;
end;
//****************************************************************************************************************************************************
procedure TiLinearGaugeComponentEditorForm.iComponentEditorFormCreate(Sender: TObject);
begin
FPointerManager := TiGaugePointerManager.Create(ChangeEvent, InsertEvent, RemoveEvent);
UpdatePointers;
end;
//****************************************************************************************************************************************************
procedure TiLinearGaugeComponentEditorForm.iComponentEditorFormDestroy(Sender: TObject);
begin
FPointerManager.Free;
end;
//****************************************************************************************************************************************************
procedure TiLinearGaugeComponentEditorForm.iPointerListBoxClick(Sender: TObject);
begin
UpdatePointers;
end;
//****************************************************************************************************************************************************
procedure TiLinearGaugeComponentEditorForm.iPointerListBoxGetData(const Index: Integer; var DrawColorBox: Boolean; var AColor: TColor; var AText: String);
begin
AColor := (iPointerListBox.Items.Objects[Index] as TiGaugePointer).Color;
AText := 'Pointer(' + IntToStr(Index) + ')';
end;
//****************************************************************************************************************************************************
procedure TiLinearGaugeComponentEditorForm.ChangeEvent(Sender: TObject);
begin
end;
//****************************************************************************************************************************************************
procedure TiLinearGaugeComponentEditorForm.InsertEvent(Sender: TObject);
begin
if Sender is TiGaugePointer then
begin
iPointerListBox.Items.AddObject('',Sender);
with Sender as TiGaugePointer do
begin
Size := 10;
Color := clBlue;
Style := ord(ilgpsPointer);
end;
iPointerListBox.SelectLast;
end;
end;
//****************************************************************************************************************************************************
procedure TiLinearGaugeComponentEditorForm.RemoveEvent(Sender: TObject);
begin
iPointerListBox.Items.Delete(iPointerListBox.Items.IndexOfObject(Sender));
end;
//****************************************************************************************************************************************************
procedure TiLinearGaugeComponentEditorForm.iPointerAddButtonClick(Sender: TObject);
begin
FPointerManager.Add;
UpdatePointers;
Modified := True;
end;
//****************************************************************************************************************************************************
procedure TiLinearGaugeComponentEditorForm.PointerRemoveButtonClick(Sender: TObject);
begin
iPointerListBox.DeleteSelectedObject;
UpdatePointers;
Modified := True;
end;
//****************************************************************************************************************************************************
procedure TiLinearGaugeComponentEditorForm.PositionEditChange(Sender: TObject);
begin
FPointerManager.Items[0].Position := PositionEdit.AsFloat;
UpdatePointers;
end;
//****************************************************************************************************************************************************
procedure TiLinearGaugeComponentEditorForm.UpdatePointers;
var
iPointer : TiGaugePointer;
begin
if iPointerListBox.ItemIndex = - 1 then DisableAllEditControlsStartingWith('Pointer')
else
begin
EnableAllEditControlsStartingWith('Pointer');
iPointer := iPointerListBox.Items.Objects[iPointerListBox.ItemIndex] as TiGaugePointer;
PointerVisibleCheckBox.AsBoolean := iPointer.Visible;
PointerPositionEdit.AsFloat := iPointer.Position;
PointerSizeEdit.AsInteger := iPointer.Size;
PointerOffSetEdit.AsInteger := iPointer.Margin;
PointerColorPicker.Color := iPointer.Color;
PointerStyleRadioGroup.AsInteger := iPointer.Style;
iPointerListBox.Invalidate;
if iPointerListBox.ItemIndex = 0 then PointerRemoveButton.Enabled := False;
end;
end;
//****************************************************************************************************************************************************
procedure TiLinearGaugeComponentEditorForm.PointerChange(Sender: TObject);
var
iPointer : TiGaugePointer;
begin
if iPointerListBox.ItemIndex = -1 then exit;
iPointer := iPointerListBox.Items.Objects[iPointerListBox.ItemIndex] as TiGaugePointer;
iPointer.Visible := PointerVisibleCheckBox.AsBoolean;
iPointer.Position := PointerPositionEdit.AsFloat;
iPointer.Size := PointerSizeEdit.AsInteger;
iPointer.Margin := PointerOffSetEdit.AsInteger;
iPointer.Color := PointerColorPicker.Color;
iPointer.Style := PointerStyleRadioGroup.AsInteger;
if iPointerListBox.ItemIndex = 0 then
begin
PositionEdit.AsFloat := PointerPositionEdit.AsFloat;
end;
UpdatePointers;
end;
//****************************************************************************************************************************************************
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -