我继承了这个项目,有人在一段时间后就开始了。它是用DevExpress for Winforms制作的。他已准备好“欢迎”页面,带有“welkom”标签和“ik heb een afspraak”标签(3个底部标签的顶部)。我刚刚开始研究它,似乎无法找出为什么我启动程序/ winforms时我新添加的Labelcontrols(2个底部的)没有出现。
以下是设计师的外观图像:
这是Designer代码页(Designer.cs文件):
partial class Welcome
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.layoutCtrlMain = new DevExpress.XtraLayout.LayoutControl();
this.lblPickupRepair = new DevExpress.XtraEditors.LabelControl();
this.lblNoAppointment = new DevExpress.XtraEditors.LabelControl();
this.lblAppointment = new DevExpress.XtraEditors.LabelControl();
this.lblWelcome = new DevExpress.XtraEditors.LabelControl();
this.layoutMain = new DevExpress.XtraLayout.LayoutControlGroup();
this.emptySpaceItem1 = new DevExpress.XtraLayout.EmptySpaceItem();
this.emptySpaceItem2 = new DevExpress.XtraLayout.EmptySpaceItem();
this.layoutControlItem1 = new DevExpress.XtraLayout.LayoutControlItem();
this.emptySpaceItem3 = new DevExpress.XtraLayout.EmptySpaceItem();
this.emptySpaceItem4 = new DevExpress.XtraLayout.EmptySpaceItem();
this.emptySpaceItem5 = new DevExpress.XtraLayout.EmptySpaceItem();
this.layoutControlItem2 = new DevExpress.XtraLayout.LayoutControlItem();
this.emptySpaceItem6 = new DevExpress.XtraLayout.EmptySpaceItem();
this.layoutControlItem4 = new DevExpress.XtraLayout.LayoutControlItem();
this.layoutControlItem3 = new DevExpress.XtraLayout.LayoutControlItem();
((System.ComponentModel.ISupportInitialize)(this.layoutCtrlMain)).BeginInit();
this.layoutCtrlMain.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.layoutMain)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem4)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem5)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem6)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem4)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).BeginInit();
this.SuspendLayout();
//
// layoutCtrlMain
//
this.layoutCtrlMain.Controls.Add(this.lblPickupRepair);
this.layoutCtrlMain.Controls.Add(this.lblNoAppointment);
this.layoutCtrlMain.Controls.Add(this.lblAppointment);
this.layoutCtrlMain.Controls.Add(this.lblWelcome);
this.layoutCtrlMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.layoutCtrlMain.Location = new System.Drawing.Point(0, 0);
this.layoutCtrlMain.Name = "layoutCtrlMain";
this.layoutCtrlMain.OptionsCustomizationForm.DesignTimeCustomizationFormPositionAndSize = new System.Drawing.Rectangle(2218, 466, 859, 400);
this.layoutCtrlMain.Root = this.layoutMain;
this.layoutCtrlMain.Size = new System.Drawing.Size(1131, 427);
this.layoutCtrlMain.TabIndex = 0;
//
// lblPickupRepair
//
this.lblPickupRepair.Appearance.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblPickupRepair.Appearance.ForeColor = System.Drawing.Color.White;
this.lblPickupRepair.Appearance.Image = global::ESC.Intern.Custom.DigRecWF.Reception.Properties.Resources.Webp_net_resizeimage;
this.lblPickupRepair.Appearance.Options.UseFont = true;
this.lblPickupRepair.Appearance.Options.UseForeColor = true;
this.lblPickupRepair.Appearance.Options.UseImage = true;
this.lblPickupRepair.ImageAlignToText = DevExpress.XtraEditors.ImageAlignToText.LeftCenter;
this.lblPickupRepair.IndentBetweenImageAndText = 15;
this.lblPickupRepair.Location = new System.Drawing.Point(355, 309);
this.lblPickupRepair.Name = "lblPickupRepair";
this.lblPickupRepair.Size = new System.Drawing.Size(326, 49);
this.lblPickupRepair.StyleController = this.layoutCtrlMain;
this.lblPickupRepair.TabIndex = 8;
this.lblPickupRepair.Text = "Afhaling / herstelling";
//
// lblNoAppointment
//
this.lblNoAppointment.Appearance.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblNoAppointment.Appearance.ForeColor = System.Drawing.Color.White;
this.lblNoAppointment.Appearance.Image = global::ESC.Intern.Custom.DigRecWF.Reception.Properties.Resources.Webp_net_resizeimage;
this.lblNoAppointment.Appearance.Options.UseFont = true;
this.lblNoAppointment.Appearance.Options.UseForeColor = true;
this.lblNoAppointment.Appearance.Options.UseImage = true;
this.lblNoAppointment.ImageAlignToText = DevExpress.XtraEditors.ImageAlignToText.LeftCenter;
this.lblNoAppointment.IndentBetweenImageAndText = 15;
this.lblNoAppointment.Location = new System.Drawing.Point(355, 256);
this.lblNoAppointment.Name = "lblNoAppointment";
this.lblNoAppointment.Size = new System.Drawing.Size(331, 49);
this.lblNoAppointment.StyleController = this.layoutCtrlMain;
this.lblNoAppointment.TabIndex = 7;
this.lblNoAppointment.Text = "Ik heb geen afspraak";
this.lblNoAppointment.Click += new System.EventHandler(this.lblNoAppointment_Click);
//
// lblAppointment
//
this.lblAppointment.Appearance.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblAppointment.Appearance.ForeColor = System.Drawing.Color.White;
this.lblAppointment.Appearance.Image = global::ESC.Intern.Custom.DigRecWF.Reception.Properties.Resources.Webp_net_resizeimage;
this.lblAppointment.Appearance.Options.UseFont = true;
this.lblAppointment.Appearance.Options.UseForeColor = true;
this.lblAppointment.Appearance.Options.UseImage = true;
this.lblAppointment.ImageAlignToText = DevExpress.XtraEditors.ImageAlignToText.LeftCenter;
this.lblAppointment.IndentBetweenImageAndText = 15;
this.lblAppointment.Location = new System.Drawing.Point(355, 203);
this.lblAppointment.Name = "lblAppointment";
this.lblAppointment.Size = new System.Drawing.Size(315, 49);
this.lblAppointment.StyleController = this.layoutCtrlMain;
this.lblAppointment.TabIndex = 5;
this.lblAppointment.Text = "Ik heb een afspraak";
this.lblAppointment.Click += new System.EventHandler(this.lblAppointment_Click);
//
// lblWelcome
//
this.lblWelcome.Appearance.Font = new System.Drawing.Font("Arial Narrow", 48F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblWelcome.Appearance.ForeColor = System.Drawing.SystemColors.ControlLightLight;
this.lblWelcome.Appearance.Options.UseFont = true;
this.lblWelcome.Appearance.Options.UseForeColor = true;
this.lblWelcome.Location = new System.Drawing.Point(290, 70);
this.lblWelcome.Name = "lblWelcome";
this.lblWelcome.Size = new System.Drawing.Size(396, 75);
this.lblWelcome.StyleController = this.layoutCtrlMain;
this.lblWelcome.TabIndex = 4;
this.lblWelcome.Text = "Welkom bij ESC!";
//
// layoutMain
//
this.layoutMain.EnableIndentsWithoutBorders = DevExpress.Utils.DefaultBoolean.True;
this.layoutMain.GroupBordersVisible = false;
this.layoutMain.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] {
this.emptySpaceItem1,
this.emptySpaceItem2,
this.layoutControlItem1,
this.emptySpaceItem3,
this.emptySpaceItem4,
this.emptySpaceItem5,
this.layoutControlItem2,
this.emptySpaceItem6,
this.layoutControlItem4,
this.layoutControlItem3});
this.layoutMain.Name = "Root";
this.layoutMain.Size = new System.Drawing.Size(1131, 427);
this.layoutMain.TextVisible = false;
//
// emptySpaceItem1
//
this.emptySpaceItem1.AllowHotTrack = false;
this.emptySpaceItem1.Location = new System.Drawing.Point(678, 0);
this.emptySpaceItem1.MinSize = new System.Drawing.Size(104, 24);
this.emptySpaceItem1.Name = "emptySpaceItem1";
this.emptySpaceItem1.Size = new System.Drawing.Size(433, 407);
this.emptySpaceItem1.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
this.emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0);
//
// emptySpaceItem2
//
this.emptySpaceItem2.AllowHotTrack = false;
this.emptySpaceItem2.Location = new System.Drawing.Point(0, 0);
this.emptySpaceItem2.Name = "emptySpaceItem2";
this.emptySpaceItem2.Size = new System.Drawing.Size(278, 407);
this.emptySpaceItem2.TextSize = new System.Drawing.Size(0, 0);
//
// layoutControlItem1
//
this.layoutControlItem1.Control = this.lblWelcome;
this.layoutControlItem1.Location = new System.Drawing.Point(278, 58);
this.layoutControlItem1.Name = "layoutControlItem1";
this.layoutControlItem1.Size = new System.Drawing.Size(400, 79);
this.layoutControlItem1.TextSize = new System.Drawing.Size(0, 0);
this.layoutControlItem1.TextVisible = false;
//
// emptySpaceItem3
//
this.emptySpaceItem3.AllowHotTrack = false;
this.emptySpaceItem3.Location = new System.Drawing.Point(278, 350);
this.emptySpaceItem3.MinSize = new System.Drawing.Size(104, 24);
this.emptySpaceItem3.Name = "emptySpaceItem3";
this.emptySpaceItem3.Size = new System.Drawing.Size(400, 57);
this.emptySpaceItem3.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
this.emptySpaceItem3.TextSize = new System.Drawing.Size(0, 0);
//
// emptySpaceItem4
//
this.emptySpaceItem4.AllowHotTrack = false;
this.emptySpaceItem4.Location = new System.Drawing.Point(278, 0);
this.emptySpaceItem4.Name = "emptySpaceItem4";
this.emptySpaceItem4.Size = new System.Drawing.Size(400, 58);
this.emptySpaceItem4.TextSize = new System.Drawing.Size(0, 0);
//
// emptySpaceItem5
//
this.emptySpaceItem5.AllowHotTrack = false;
this.emptySpaceItem5.Location = new System.Drawing.Point(278, 137);
this.emptySpaceItem5.Name = "emptySpaceItem5";
this.emptySpaceItem5.Size = new System.Drawing.Size(400, 54);
this.emptySpaceItem5.TextSize = new System.Drawing.Size(0, 0);
//
// layoutControlItem2
//
this.layoutControlItem2.Control = this.lblAppointment;
this.layoutControlItem2.Location = new System.Drawing.Point(343, 191);
this.layoutControlItem2.Name = "layoutControlItem2";
this.layoutControlItem2.Size = new System.Drawing.Size(335, 53);
this.layoutControlItem2.TextSize = new System.Drawing.Size(0, 0);
this.layoutControlItem2.TextVisible = false;
//
// emptySpaceItem6
//
this.emptySpaceItem6.AllowHotTrack = false;
this.emptySpaceItem6.Location = new System.Drawing.Point(278, 191);
this.emptySpaceItem6.Name = "emptySpaceItem6";
this.emptySpaceItem6.Size = new System.Drawing.Size(65, 159);
this.emptySpaceItem6.TextSize = new System.Drawing.Size(0, 0);
//
// layoutControlItem4
//
this.layoutControlItem4.Control = this.lblNoAppointment;
this.layoutControlItem4.Location = new System.Drawing.Point(343, 244);
this.layoutControlItem4.Name = "layoutControlItem4";
this.layoutControlItem4.Size = new System.Drawing.Size(335, 53);
this.layoutControlItem4.TextSize = new System.Drawing.Size(0, 0);
this.layoutControlItem4.TextVisible = false;
//
// layoutControlItem3
//
this.layoutControlItem3.Control = this.lblPickupRepair;
this.layoutControlItem3.Location = new System.Drawing.Point(343, 297);
this.layoutControlItem3.Name = "layoutControlItem3";
this.layoutControlItem3.Size = new System.Drawing.Size(335, 53);
this.layoutControlItem3.TextSize = new System.Drawing.Size(0, 0);
this.layoutControlItem3.TextVisible = false;
//
// Welcome
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(1131, 427);
this.Controls.Add(this.layoutCtrlMain);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Welcome";
this.Text = "Form1";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.Welcome_Load);
this.Shown += new System.EventHandler(this.Welcome_Shown);
((System.ComponentModel.ISupportInitialize)(this.layoutCtrlMain)).EndInit();
this.layoutCtrlMain.ResumeLayout(false);
this.layoutCtrlMain.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.layoutMain)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem4)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem5)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem6)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem4)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DevExpress.XtraLayout.LayoutControl layoutCtrlMain;
private DevExpress.XtraLayout.LayoutControlGroup layoutMain;
private DevExpress.XtraEditors.LabelControl lblWelcome;
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem1;
private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem4;
private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem5;
private DevExpress.XtraEditors.LabelControl lblAppointment;
private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem6;
private DevExpress.XtraEditors.LabelControl lblPickupRepair;
private DevExpress.XtraEditors.LabelControl lblNoAppointment;
private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem3;
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem2;
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem4;
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem3;
private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem1;
private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem2;
}
}
这是代码页(.cs文件):
public partial class Welcome : BaseForm
{
public Welcome(int timeoutIntervalInSeconds, Controller controller) : base(timeoutIntervalInSeconds, controller)
{
InitializeComponent();
if (!_controller.IsDesignMode)
{
}
_controller.SetDesignMode(layoutCtrlMain);
}
private void Welcome_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e)
{
if (!_controller.IsDesignMode) return;
_controller.SaveLayout(layoutCtrlMain, Enums.LayoutType.Welcome);
}
private void lblAppointment_Click(object sender, EventArgs e)
{
_controller.OpenAppointments();
Close();
}
private void lblNoAppointment_Click(object sender, EventArgs e)
{
_controller.OpenAppointments();
Close();
}
private void Welcome_Load(object sender, EventArgs e)
{
_controller.LoadLayout(layoutCtrlMain, Enums.LayoutType.Welcome);
layoutCtrlMain.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Flat;
layoutCtrlMain.LookAndFeel.UseDefaultLookAndFeel = false;
layoutCtrlMain.OptionsView.ShareLookAndFeelWithChildren = false;
layoutCtrlMain.OptionsView.EnableTransparentBackColor = true;
layoutCtrlMain.Root.AppearanceGroup.BackColor = System.Drawing.Color.Transparent;
layoutCtrlMain.Root.AppearanceGroup.Options.UseBackColor = true;
var sharepath = _controller.GetSharePath(Enums.LayoutType.Welcome);
var backFile = Path.Combine(_controller.GetSharePath(LayoutType.Welcome), "background.png");
if (File.Exists(backFile)) layoutCtrlMain.BackgroundImage = Image.FromFile(backFile);
//throws them out of the main layoutgroup...
/*layoutControlItem4.RestoreFromCustomization();
layoutControlItem3.RestoreFromCustomization();*/
}
private void Welcome_Shown(object sender, EventArgs e)
{
LoadMenuDisplayed();
}
private void LoadMenuDisplayed()
{
//var sharepath = _controller.GetSharePath(LayoutType.Appointment);
//((System.ComponentModel.ISupportInitialize)(this.layoutCtrlMain)).BeginInit();
//flpMain.SuspendLayout();
//flpMain.Controls.Clear();
//layoutCtrlMain.SuspendLayout();
//var itemFont = new Font("Arial", 18F, FontStyle.Bold);
//var fontService = _controller.GetContainer().Resolve(typeof(ILayoutService), "") as ILayoutService;
//if (fontService != null)
//{
// var fontResponse = fontService.GetFontLayout(LayoutType.Appointment_Font_EmployeeNameButton);
// if (fontResponse.IsSuccess) itemFont = fontResponse.GetValue().Font;
//}
//var firstBtn = new MyHoverButton();
//int counter = 0;
//foreach (var item in response.Values)
//{
// if (counter >= 20) break; //we only show 20 employees max
// var btn = new MyHoverButton();
// btn.TextLocation = TextLocation.Bottom;
// btn.ItemText = item.FullName;
// btn.ItemValue = item.ID;
// btn.ItemFont = itemFont;
// if (item.ID > 0)
// {
// var medwImg = Path.Combine(_controller.GetSharePath(LayoutType.Appointment), "Medewerkers", "contact_" + item.ID + ".jpg");
// if (File.Exists(medwImg))
// {
// btn.NormalImage = Image.FromFile(medwImg);
// //btn.HoverImage = Image.FromFile(medwImg);
// }
// else
// {
// }
// }
// btn.BorderStyle = BorderStyle.None;
// //btn.Width = flpMain.Size.Width / 5;
// //btn.Height = flpMain.Size.Height / 4;
// btn.ItemClicked += Btn_Click;
// flpMain.Controls.Add(btn);
// counter++;
//}
//layoutCtrlMain.ResumeLayout();
//flpMain.ResumeLayout();
//((System.ComponentModel.ISupportInitialize)(this.layoutCtrlMain)).EndInit();
}
}
}
我不熟悉DevExpress,所以也许我忘记了某个地方?
答案 0 :(得分:1)
我不熟悉DevExpress所以也许我忘记了什么 某处?
我相信你没有忘记任何事情,因为设计师已经看到了新的标签。这个谜语必须有一个非常简单的钥匙。
在Welcome_Load方法中注释掉这一行:
_controller.LoadLayout(layoutCtrlMain, Enums.LayoutType.Welcome);
如果这有帮助,则不会显示新添加的标签,因为先前保存的布局不包含它们。
要解决此问题并保持_controller.LoadLayout代码行取消注释,请找到_controller保存布局的文件并将其删除。