⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tsimagelisteditor.pas

📁 企业进销存管理系统
💻 PAS
📖 第 1 页 / 共 4 页
字号:
                        Dlg.optFixedColor.Checked := (Dlg.ImageCollection[I - 1].TransparentMode = tmFixed);
                        First := False;
                    end;
                end;
            end;

            if Dlg.optFixedColor.Checked then
            begin
                Dlg.butSelectColor.Enabled := True;
                Dlg.shpFixedColor.Brush.Style := bsSolid;
                Dlg.shpFixedColor.Brush.Color := Dlg.ImageCollection[Dlg.grdImages.SelectedCols.Next(0) - 1].TransparentColor;
                Dlg.shpFixedColor.Pen.Color := clBlack;
            end
            else
            begin
                Dlg.butSelectColor.Enabled := False;
                Dlg.shpFixedColor.Brush.Style := bsClear;
                Dlg.shpFixedColor.Pen.Color := clGrayText;
            end;

            Dlg.lblPictureSize.Caption := '';
        end
        else
        begin
            DisableControls := True;
            for I := 1 to Dlg.grdImages.Cols do
            begin
                if Dlg.grdImages.Col[I].Visible then
                begin
                    DisableControls := False;
                    Break;
                end;
            end;

            if DisableControls then
            begin
                ClearControls;
                Dlg.txtName.Enabled := False;
                Dlg.chkTransparent.Enabled := False;
                Dlg.optLowerLeftPixel.Enabled := False;
                Dlg.optFixedColor.Enabled := False;
                Dlg.butSelectColor.Enabled := False;
                Dlg.shpFixedColor.Brush.Style := bsClear;
                Dlg.shpFixedColor.Pen.Color := clGrayText;

                Dlg.chkTransparent.Checked := False;
                Dlg.optLowerLeftPixel.Checked := False;
                Dlg.optFixedColor.Checked := False;
                Dlg.lblPictureSize.Caption := '';
            end
            else
            begin
                Dlg.txtName.Enabled := True;
                Dlg.chkTransparent.Enabled := True;

                Dlg.txtName.Text := Dlg.ImageCollection[Dlg.grdImages.CurrentDataCol - 1].Name;

                Dlg.chkTransparent.Checked := Dlg.ImageCollection[Dlg.grdImages.CurrentDataCol - 1].Transparent;
                Dlg.optLowerLeftPixel.Enabled := Dlg.chkTransparent.Checked;
                Dlg.optFixedColor.Enabled := Dlg.chkTransparent.Checked;

                if (Dlg.ImageCollection[Dlg.grdImages.CurrentDataCol - 1].TransparentMode = tmAuto) and Dlg.optLowerLeftPixel.Enabled then
                   Dlg.optLowerLeftPixel.Checked := True
                else if (Dlg.ImageCollection[Dlg.grdImages.CurrentDataCol - 1].TransparentMode = tmFixed) and Dlg.optFixedColor.Enabled then
                     Dlg.optFixedColor.Checked := True
                else begin
                        Dlg.optLowerLeftPixel.Checked := False;
                        Dlg.optFixedColor.Checked := False;
                     end;

                if Dlg.optFixedColor.Checked and Dlg.optFixedColor.Enabled then
                begin
                    Dlg.butSelectColor.Enabled := True;
                    Dlg.shpFixedColor.Brush.Style := bsSolid;
                    Dlg.shpFixedColor.Brush.Color := Dlg.ImageCollection[Dlg.grdImages.CurrentDataCol - 1].TransparentColor;
                    Dlg.shpFixedColor.Pen.Color := clBlack;
                end
                else
                begin
                    Dlg.butSelectColor.Enabled := False;
                    Dlg.shpFixedColor.Brush.Style := bsClear;
                    Dlg.shpFixedColor.Pen.Color := clGrayText;
                end;

                Dlg.lblPictureSize.Caption := IntToStr(Dlg.ImageCollection[Dlg.grdImages.CurrentDataCol - 1].Bitmap.Width);
                Dlg.lblPictureSize.Caption := Dlg.lblPictureSize.Caption + ' x ' + IntToStr(Dlg.ImageCollection[Dlg.grdImages.CurrentDataCol - 1].Bitmap.Height);
            end;
        end;
    finally
        IgnoreChange := False;
        if Dlg.txtName.Enabled then
            Dlg.txtName.Color := clWindow
        else
            Dlg.txtName.Color := Dlg.Color;
    end;
end;

procedure ShowSetInGrid;
var
    I: integer;
    Temp: string;
    OldEnablePaint: Boolean;
begin
    Temp := Trim(LowerCase(Dlg.cmbGlobalSetName.Text));
    OldEnablePaint := Dlg.grdImages.EnablePaint;
    Dlg.grdImages.EnableRedraw := False;
    Dlg.grdImages.ResetColProperties([prSelected]);
    try
        if Temp = MainSetName then Temp := '';
        for I := Dlg.grdImages.Cols downto 1 do
        begin
            if Trim(LowerCase(Dlg.ImageCollection[I - 1].SetName)) = Temp then
                Dlg.grdImages.Col[I].Visible := True
            else
                Dlg.grdImages.Col[I].Visible := False;
        end;
    finally
        Dlg.grdImages.EnableRedraw := OldEnablePaint;
    end;
end;

procedure EnableButtons;
begin
    if VisibleCols(Dlg.grdImages) = 0 then
    begin
        Dlg.butDelete.Enabled := False;
        Dlg.butLeft.Enabled := False;
        Dlg.butRight.Enabled := False;
        Dlg.butLoad.Enabled := False;
        Dlg.butMoveToSet.Enabled := False;
    end
    else
    begin
        Dlg.butDelete.Enabled := True;

        if Dlg.cmbGlobalSetName.Items.Count > 1 then
            Dlg.butMoveToSet.Enabled := True
        else
            Dlg.butMoveToSet.Enabled := False;

        if Dlg.grdImages.SelectedCols.Count > 1 then
        begin
            Dlg.butLoad.Enabled := False;
            Dlg.butLeft.Enabled := False;
            Dlg.butRight.Enabled := False;
        end
        else
        begin
            Dlg.butLoad.Enabled := True;
            Dlg.butLeft.Enabled := (LeftVisibleCol(Dlg.grdImages.CurrentDataCol) <>  - 1);
            Dlg.butRight.Enabled := (RightVisibleCol(Dlg.grdImages.CurrentDataCol) <> -1);
        end;
    end;

    if Dlg.cmbGlobalSetName.Text = MainSetName then
    begin
        Dlg.butDeleteSet.Enabled := False;
        Dlg.butEditSet.Enabled := False;
    end
    else
    begin
        Dlg.butDeleteSet.Enabled := True;
        Dlg.butEditSet.Enabled := True;
    end;
end;

procedure ShowImageEditor(forComponent : TComponent);
begin
    Screen.Cursor := crHourglass;
    Dlg := TtsImageListDlg.Create(Application);
    try
        Dlg.InDesignMode := True;
        Dlg.Caption := forComponent.Owner.Name + '.' +
                       forComponent.Name;

        //make local copy of imagecollection of component
        if Assigned(TtsImageList(forComponent).Images) then
            Dlg.ImageCollection.Assign(TtsImageList(forComponent).Images);

        if Dlg.ShowModal = mrOK then
        begin
            Screen.Cursor := crHourglass;
            //copy changed imagecollection back to component
            TtsImageList(forComponent).Images.Assign(Dlg.ImageCollection);
            //Modified;
        end;
    finally
        Dlg.Free;
        Screen.Cursor := crDefault;
    end;
end;

{TtsImageCollectionEditor}

function TtsImageCollectionEditor.GetAttributes: TPropertyAttributes;
begin
    Result := [paDialog];  //This is a dialog based property editor
end;

function TtsImageCollectionEditor.GetValue:string;
begin
    //Display the name of the object in the object inspector
    Result := Format('(%s)', [GetPropType^.Name]);
end;

procedure TtsImageCollectionEditor.Edit;
begin
  ShowImageEditor(TComponent(GetComponent(0)));
end;

{TtsImageListEditor}

procedure TtsImageListEditor.ExecuteVerb(Index: Integer);
begin
    Edit;
end;

function TtsImageListEditor.GetVerb(Index: Integer): string;
begin
    Result := '&Imagelist Editor';
end;

function TtsImageListEditor.GetVerbCount: Integer;
begin
    Result := 1;
end;


{$IFDEF TSVER_V6}
procedure TtsImageListEditor.GetImageListEditor(const Prop: IProperty);
begin
  //ShowMessage('Get Property Name ' + Prop.GetName);
  //if Prop.GetName = 'Images' then
  //   Prop.Edit;
  if Prop.GetName = 'Images' then
     FEditor := TPropertyEditor(Prop);
  //TPropertyEditor(Prop).Free;
  //ShowMessage('Get Property Name Complete ' + Prop.GetName);
end;
{$ELSE}
procedure TtsImageListEditor.GetImageListEditor(PropertyEditor: TPropertyEditor);
begin
    if PropertyEditor is TtsImageCollectionEditor
        then FEditor := PropertyEditor
        else PropertyEditor.Free;
end;
{$ENDIF}

procedure TtsImageListEditor.Edit;
begin
  ShowImageEditor(Component);
end;

{TtsImageListDlg}

procedure TtsImageListDlg.FormCreate(Sender: TObject);
begin
    grdImages.RowHeight[1] := 94;

    dlgLoadPicture.Filter := 'All files (*.*)|*.*|Bitmap files (*.bmp)|*.BMP|Icons (*.ico)|*.ICO|JPEG files (*.jpg, *.jpeg)|*.JPG;*.JPEG|Metafiles (*.wmf, *.emf)|*.WMF;*.EMF';
    dlgLoadPicture.FilterIndex := 2;
    dlgLoadPicture.Options := [{$IFDEF TSVER_D4} ofEnableSizing, {$ENDIF} ofHideReadOnly, ofFileMustExist, ofPathMustExist];

    dlgColor.Options := [cdAnyColor, cdFullOpen];

    IgnoreChange := False;
    InDesignMode := False;

    ImageCollection := TtsImageCollection.Create(nil, TtsImage);

    Dlg := Self;

    //resize all controls if large fonts are being used
    if butDelete.Width < Dlg.Canvas.TextWidth(butDelete.Caption) then
    begin
        butAddSet.Width := Dlg.Canvas.TextWidth(butAddSet.Caption) + 1;
        butDeleteSet.Width := Dlg.Canvas.TextWidth(butDeleteSet.Caption) + 1;
        butEditSet.Width := Dlg.Canvas.TextWidth(butEditSet.Caption) + 1;
        butAdd.Width := Dlg.Canvas.TextWidth(butAdd.Caption) + 1;
        butDelete.Width := Dlg.Canvas.TextWidth(butDelete.Caption) + 1;
        butLoad.Width := Dlg.Canvas.TextWidth(butLoad.Caption) + 1;
        butLeft.Width := Dlg.Canvas.TextWidth(butLeft.Caption) + 1;
        butRight.Width := Dlg.Canvas.TextWidth(butRight.Caption) + 1;
        butMoveToSet.Width := Dlg.Canvas.TextWidth(butMoveToSet.Caption) + 1;

        cmbGlobalSetName.Left := lblSetName.Left + lblSetName.Width + 5;
        butAddSet.Left := cmbGlobalSetName.Left + cmbGlobalSetName.Width + 16;
        butDeleteSet.Left := butAddSet.Left + butAddSet.Width + 7;
        butEditSet.Left := butDeleteSet.Left + butDeleteSet.Width + 7;

        butDelete.Left := butAdd.Left + butAdd.Width + 7;
        bvlSeperator1.Left := butDelete.Left + butDelete.Width + 6;
        butLoad.Left := butDelete.Left + butDelete.Width + 14;
        bvlSeperator2.Left := butLoad.Left + butLoad.Width + 6;
        butLeft.Left := butLoad.Left + butLoad.Width + 14;
        butRight.Left := butLeft.Left + butLeft.Width + 7;
        bvlSeperator3.Left := butRight.Left + butRight.Width + 6;
        butMoveToSet.Left := butRight.Left + butRight.Width + 14;

        grdImages.HeadingHeight := Dlg.Canvas.TextHeight('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') + 2;
        grdImages.Height := grdImages.HeadingHeight + grdImages.RowHeight[1] + 20;
        bvlProperties.Top := grdImages.Top + grdImages.Height + 10;
        lblProperties.Top := bvlProperties.Top - lblProperties.Height div 2;
        butOK.Top := bvlProperties.Top + bvlProperties.Height + 11;
        butCancel.Top := butOK.Top;
        Dlg.ClientHeight := butOK.Top + butOK.Height + 11;

        optLowerLeftPixel.Width := Dlg.Canvas.TextWidth(optLowerLeftPixel.Caption) + 15;
        optFixedColor.Width := Dlg.Canvas.TextWidth(optFixedColor.Caption) + 15;
        shpFixedColor.Left := optFixedColor.Left + optFixedColor.Width + 1;
        butSelectColor.Left := shpFixedColor.Left + shpFixedColor.Width + 13;
        butSelectColor.Width := Dlg.Canvas.TextWidth(butSelectColor.Caption) + 1;

        bvlProperties.Width := optLowerLeftPixel.Left + optLowerLeftPixel.Width - bvlProperties.Left + 8;

        Dlg.ClientWidth := Max(bvlProperties.Width + bvlProperties.Left * 2, butMoveToSet.Left + butMoveToSet.Width + butAdd.Left);

        bvlProperties.Width := Dlg.ClientWidth - bvlProperties.Left * 2;
        grdImages.Width := bvlProperties.Width;

        butCancel.Left := bvlProperties.Left + bvlProperties.Width - butCancel.Width;
        butOK.Left := butCancel.Left - butOK.Width - 25;
    end;
end;

procedure TtsImageListDlg.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
    if Dlg.ActiveControl = txtName then
    begin
        if HandleNameChange() = False then
        begin
            CanClose := False;
            Exit;
        end;
    end;

    if not CloseButtonPressed and Dlg.Modified then
    begin
       if mrYes = MessageDlg('The imagecollection has changed. Do you wish to save the changes?', mtConfirmation, [mbYes, mbNo], 0) then
           ModalResult := mrOk
       else
           ModalResult := mrCancel
    end;
end;

procedure TtsImageListDlg.FormDestroy(Sender: TObject);
begin
    ImageCollection.Free;
end;

procedure TtsImageListDlg.FormShow(Sender: TObject);
var
    I: integer;
begin
    CloseButtonPressed := False;

    Dlg.cmbGlobalSetName.Items.Assign(TtsImageCollection_(ImageCollection).SetNames);
    Dlg.cmbGlobalSetName.Items.Insert(0, MainSetName);

    grdImages.Cols := ImageCollection.Count;
    for I := 1 to grdImages.Cols do
    begin
        grdImages.Col[I].ControlType := ctPicture;
        grdImages.Col[I].Width := 100;
        grdImages.Col[I].Heading :=ImageCollection[I - 1].Name;
    end;

    if ImageCollection.Count = 0 then ItemIndex := Unassigned;

    //ShowMessage('Step Start');
    cmbGlobalSetName.ItemIndex := 0;
    if ImageCollection.IndexExists(ItemIndex) then
    begin
        if Assigned(ImageCollection.Items[ItemIndex]) then
        begin

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -