2026-01-24 15:44:20 +08:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using WordAddIn.Properties;
|
|
|
|
|
|
|
|
|
|
namespace WordAddIn
|
|
|
|
|
{
|
|
|
|
|
public class ImageOptionsForm : Form
|
|
|
|
|
{
|
|
|
|
|
public string SelectedStyle { get; private set; }
|
|
|
|
|
public string AdditionalPrompt { get; private set; }
|
|
|
|
|
|
|
|
|
|
private ComboBox cmbStyles;
|
|
|
|
|
private TextBox txtAdditionalPrompt;
|
|
|
|
|
private Button btnOk;
|
|
|
|
|
private Button btnCancel;
|
2026-01-24 18:05:24 +08:00
|
|
|
private Label lblStyle;
|
|
|
|
|
private Label lblPrompt;
|
2026-01-24 15:44:20 +08:00
|
|
|
|
|
|
|
|
private readonly string[] _styles = new string[]
|
|
|
|
|
{
|
|
|
|
|
"写实摄影 (Photorealistic)",
|
|
|
|
|
"软件架构图 (Architecture Diagram)",
|
|
|
|
|
"技术原理图 (Technical Schematic)",
|
|
|
|
|
"手绘草图 (Sketch)",
|
|
|
|
|
"卡通插画 (Cartoon)",
|
|
|
|
|
"3D 渲染 (3D Render)",
|
|
|
|
|
"水彩画 (Watercolor)",
|
|
|
|
|
"赛博朋克 (Cyberpunk)"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public ImageOptionsForm()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
InitializeStyles();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitializeComponent()
|
|
|
|
|
{
|
2026-01-24 18:05:24 +08:00
|
|
|
this.lblStyle = new System.Windows.Forms.Label();
|
|
|
|
|
this.cmbStyles = new System.Windows.Forms.ComboBox();
|
|
|
|
|
this.lblPrompt = new System.Windows.Forms.Label();
|
|
|
|
|
this.txtAdditionalPrompt = new System.Windows.Forms.TextBox();
|
|
|
|
|
this.btnOk = new System.Windows.Forms.Button();
|
|
|
|
|
this.btnCancel = new System.Windows.Forms.Button();
|
|
|
|
|
this.SuspendLayout();
|
|
|
|
|
//
|
|
|
|
|
// lblStyle
|
|
|
|
|
//
|
|
|
|
|
this.lblStyle.AutoSize = true;
|
|
|
|
|
this.lblStyle.Location = new System.Drawing.Point(30, 30);
|
|
|
|
|
this.lblStyle.Name = "lblStyle";
|
|
|
|
|
this.lblStyle.Size = new System.Drawing.Size(59, 12);
|
|
|
|
|
this.lblStyle.TabIndex = 0;
|
|
|
|
|
this.lblStyle.Text = "图片风格:";
|
|
|
|
|
//
|
|
|
|
|
// cmbStyles
|
|
|
|
|
//
|
|
|
|
|
this.cmbStyles.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
|
|
|
|
this.cmbStyles.FormattingEnabled = true;
|
|
|
|
|
this.cmbStyles.Location = new System.Drawing.Point(30, 55);
|
|
|
|
|
this.cmbStyles.Name = "cmbStyles";
|
|
|
|
|
this.cmbStyles.Size = new System.Drawing.Size(370, 20);
|
|
|
|
|
this.cmbStyles.TabIndex = 1;
|
|
|
|
|
//
|
|
|
|
|
// lblPrompt
|
|
|
|
|
//
|
|
|
|
|
this.lblPrompt.AutoSize = true;
|
|
|
|
|
this.lblPrompt.Location = new System.Drawing.Point(30, 100);
|
|
|
|
|
this.lblPrompt.Name = "lblPrompt";
|
|
|
|
|
this.lblPrompt.Size = new System.Drawing.Size(191, 12);
|
|
|
|
|
this.lblPrompt.TabIndex = 2;
|
|
|
|
|
this.lblPrompt.Text = "补充描述 (可选,例如:背景要白色):";
|
|
|
|
|
//
|
|
|
|
|
// txtAdditionalPrompt
|
|
|
|
|
//
|
|
|
|
|
this.txtAdditionalPrompt.Location = new System.Drawing.Point(30, 125);
|
|
|
|
|
this.txtAdditionalPrompt.Multiline = true;
|
|
|
|
|
this.txtAdditionalPrompt.Name = "txtAdditionalPrompt";
|
|
|
|
|
this.txtAdditionalPrompt.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
|
|
|
|
this.txtAdditionalPrompt.Size = new System.Drawing.Size(370, 60);
|
|
|
|
|
this.txtAdditionalPrompt.TabIndex = 3;
|
|
|
|
|
//
|
|
|
|
|
// btnOk
|
|
|
|
|
//
|
|
|
|
|
this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK;
|
|
|
|
|
this.btnOk.Location = new System.Drawing.Point(210, 210);
|
|
|
|
|
this.btnOk.Name = "btnOk";
|
|
|
|
|
this.btnOk.Size = new System.Drawing.Size(90, 35);
|
|
|
|
|
this.btnOk.TabIndex = 4;
|
|
|
|
|
this.btnOk.Text = "生成图片";
|
|
|
|
|
this.btnOk.UseVisualStyleBackColor = true;
|
|
|
|
|
this.btnOk.Click += new System.EventHandler(this.BtnOk_Click);
|
|
|
|
|
//
|
|
|
|
|
// btnCancel
|
|
|
|
|
//
|
|
|
|
|
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
|
|
|
|
this.btnCancel.Location = new System.Drawing.Point(310, 210);
|
|
|
|
|
this.btnCancel.Name = "btnCancel";
|
|
|
|
|
this.btnCancel.Size = new System.Drawing.Size(90, 35);
|
|
|
|
|
this.btnCancel.TabIndex = 5;
|
|
|
|
|
this.btnCancel.Text = "取消";
|
|
|
|
|
this.btnCancel.UseVisualStyleBackColor = true;
|
|
|
|
|
//
|
|
|
|
|
// ImageOptionsForm
|
|
|
|
|
//
|
|
|
|
|
this.AcceptButton = this.btnOk;
|
|
|
|
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
|
|
|
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
|
|
|
this.CancelButton = this.btnCancel;
|
|
|
|
|
this.ClientSize = new System.Drawing.Size(450, 261);
|
|
|
|
|
this.Controls.Add(this.btnCancel);
|
|
|
|
|
this.Controls.Add(this.btnOk);
|
|
|
|
|
this.Controls.Add(this.txtAdditionalPrompt);
|
|
|
|
|
this.Controls.Add(this.lblPrompt);
|
|
|
|
|
this.Controls.Add(this.cmbStyles);
|
|
|
|
|
this.Controls.Add(this.lblStyle);
|
|
|
|
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
2026-01-24 15:44:20 +08:00
|
|
|
this.MaximizeBox = false;
|
|
|
|
|
this.MinimizeBox = false;
|
2026-01-24 18:05:24 +08:00
|
|
|
this.Name = "ImageOptionsForm";
|
|
|
|
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
|
|
|
|
this.Text = "生成配图设置";
|
|
|
|
|
this.ResumeLayout(false);
|
|
|
|
|
this.PerformLayout();
|
2026-01-24 15:44:20 +08:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitializeStyles()
|
|
|
|
|
{
|
|
|
|
|
cmbStyles.Items.AddRange(_styles);
|
|
|
|
|
|
|
|
|
|
// 尝试恢复上次的选择
|
|
|
|
|
string lastStyle = Settings.Default.LastImageStyle;
|
|
|
|
|
if (!string.IsNullOrEmpty(lastStyle) && cmbStyles.Items.Contains(lastStyle))
|
|
|
|
|
{
|
|
|
|
|
cmbStyles.SelectedItem = lastStyle;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cmbStyles.SelectedIndex = 0; // 默认选中第一个
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnOk_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SelectedStyle = cmbStyles.SelectedItem.ToString();
|
|
|
|
|
AdditionalPrompt = txtAdditionalPrompt.Text.Trim();
|
|
|
|
|
|
|
|
|
|
// 保存选择
|
|
|
|
|
Settings.Default.LastImageStyle = SelectedStyle;
|
|
|
|
|
Settings.Default.Save();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|