using System.Windows.Forms; using System.Drawing; using com.andoutomo.kybernetes.data.DAO; using System; namespace com.andoutomo.kybernetes.view { internal class PanelController { private BaseForm baseForm; internal PanelController(BaseForm form) { this.baseForm = form; } internal Panel createRow(int point,TaskData data) { Panel rowPanel=new Panel(); Color frColor = Color.FromArgb(data.FrColor); Color bgColor = Color.FromArgb(data.BgColor); FontStyle style; FontStyle timeStyle; float fontsize; int rowsize; if (data.ForecastMin >= 90|| data.RealMin >=90) { fontsize = 10F; rowsize = 24; if (data.isComplete) { style = FontStyle.Strikeout; timeStyle = FontStyle.Strikeout; frColor = Color.Gray; } else if (data.ForecastMin >= 120 || data.RealMin >=120) { style = FontStyle.Regular; timeStyle = FontStyle.Bold; } else { timeStyle = FontStyle.Regular; style = FontStyle.Regular; } } else if (data.ForecastMin >= 60 || data.RealMin >= 60) { fontsize = 9F; rowsize = 20; if (data.isComplete) { timeStyle = FontStyle.Strikeout; style = FontStyle.Strikeout; frColor = Color.Gray; } else { timeStyle = FontStyle.Regular; style = FontStyle.Regular; } } else { fontsize = 9F; rowsize = 16; if (data.isComplete) { timeStyle = FontStyle.Strikeout; style = FontStyle.Strikeout; frColor = Color.Gray; } else { timeStyle = FontStyle.Regular; style = FontStyle.Regular; } } //全体サイズからContentの長さを決める。 int wkPanelSize = baseForm.getPanelSize(); int wkContentSize = wkPanelSize - 569; int wkDelaySize = wkContentSize - 211; sortID = data.SortID; rowPanel.Controls.Add(new CustomLabel(data.Indicator, frColor, bgColor, FontStyle.Regular, 9F, 0, 21, rowsize,ContentAlignment.MiddleCenter)); rowPanel.Controls.Add(new CustomLabel(data.DoDate.getDateString(), frColor, bgColor, style, 9F, 20, 56, rowsize,ContentAlignment.MiddleCenter)); rowPanel.Controls.Add(new CustomLabel(data.DoDate.getDowStr(), frColor, bgColor, style, 9F, 75, 26, rowsize,ContentAlignment.MiddleCenter)); rowPanel.Controls.Add(new CustomLabel(data.TimeArea, frColor, bgColor, style, 9F, 100, 21, rowsize,ContentAlignment.MiddleCenter)); rowPanel.Controls.Add(new CustomLabel(data.SortID.ToString(), frColor, bgColor, style, 9F, 120, 41, rowsize,ContentAlignment.MiddleRight)); rowPanel.Controls.Add(new CustomLabel(data.Category, frColor, bgColor, style, 9F, 160, 81, rowsize)); rowPanel.Controls.Add(new CustomLabel(data.Contents, frColor, bgColor, style, 9F, 240, wkContentSize, rowsize)); rowPanel.Controls.Add(new CustomLabel(data.getForcastHourStr, frColor, bgColor, timeStyle, fontsize, wkDelaySize + 450, 51, rowsize,ContentAlignment.MiddleRight)); rowPanel.Controls.Add(new CustomLabel(data.ForecastMin.ToString(), frColor, bgColor, timeStyle, fontsize, wkDelaySize + 500, 51, rowsize, ContentAlignment.MiddleRight)); rowPanel.Controls.Add(new CustomLabel(data.RealMin.ToString(), frColor, bgColor, timeStyle, fontsize, wkDelaySize + 550, 51, rowsize, ContentAlignment.MiddleRight)); rowPanel.Controls.Add(new CustomLabel(data.StartTime.ToString(), frColor, bgColor, style, 9F, wkDelaySize + 600, 61, rowsize, ContentAlignment.MiddleCenter)); rowPanel.Controls.Add(new CustomLabel(data.EndTime.ToString(), frColor, bgColor, style, 9F, wkDelaySize + 660, 61, rowsize, ContentAlignment.MiddleCenter)); rowPanel.Controls.Add(new CustomLabel((data.IsRepeat == 1 ? "R" : ""), frColor, bgColor, style, 9F, wkDelaySize + 720, 21, rowsize, ContentAlignment.MiddleCenter)); rowPanel.Controls.Add(new CustomLabel((data.HasComment == 1 ? "*" : ""), frColor, bgColor, style, 9F, wkDelaySize + 740, 21, rowsize, ContentAlignment.MiddleCenter)); rowPanel.Location = new Point(0, point); rowPanel.Size = new Size(wkPanelSize - 19, rowsize); rowPanel.TabStop = false; foreach (Control eachControls in rowPanel.Controls) { eachControls.DoubleClick += new System.EventHandler(rowPanelDblClickAction); } return rowPanel; } private int sortID; private void rowPanelDblClickAction(object sender, EventArgs args) { baseForm.AddIDToText(sortID.ToString()); } } internal class CustomLabel:Label { internal CustomLabel(string text,Color FRColor,Color BGColor,FontStyle style,float size,int location,int colsize,int rowSize) { //innerLabel = new Label(); //可変要素 this.Text = text; this.BackColor = BGColor; this.ForeColor = FRColor; this.Font = new Font("MS UI Gothic", size, style, GraphicsUnit.Point, 128); this.Location = new Point(location, 0); this.Size = new Size(colsize, rowSize); //固定要素 this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.TabIndex = 0; this.TextAlign = ContentAlignment.MiddleLeft; this.Anchor = (AnchorStyles.Left | AnchorStyles.Top); } internal CustomLabel(string text, Color FRColor, Color BGColor, FontStyle style, float size, int location, int colsize, int rowSize, ContentAlignment align) :this(text,FRColor,BGColor,style,size,location,colsize,rowSize) { this.TextAlign = align; } } }