private TreeLabel creatLineHorizotal(string strTimeLable, string strTextLable, int index, int heightContext) //Tạo ra các Label như yêu cầu mà rỗng dữ liệu với kích thước location { Label lblTime; lblTime = new Label(); lblTime.Text = strTimeLable; lblTime.Location = new System.Drawing.Point(0, (int)(0.18 * this.Height) + index * heightContext); lblTime.Size = new System.Drawing.Size((int)(0.22 * this.Width), heightContext); lblTime.Font = new System.Drawing.Font("Microsoft Sans Serif", (float)((lblTime.Width / 8.0)), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); lblTime.AutoSize = false; Label lblContext; lblContext = new Label(); lblContext.AutoSize = false; lblContext.Text = strTextLable; lblContext.TextAlign = ContentAlignment.MiddleCenter; lblContext.Location = new System.Drawing.Point((int)(0.22 * this.Width), (int)(0.18 * this.Height) + index * heightContext); lblContext.Size = new System.Drawing.Size(this.Width - lblTime.Width, heightContext); lblContext.Font = new Font("Microsoft Sans Serif", (float)(0.01 * heightContext) * ((float)lblContext.Width / lblContext.Text.Length), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); lblTime.MouseHover += new EventHandler(lblLabel_MouseHover); lblContext.MouseHover += new EventHandler(lblLabel_MouseHover); lblTime.MouseLeave += new EventHandler(lblLabel_MouseLeave); lblContext.MouseLeave += new EventHandler(lblLabel_MouseLeave); TreeLabel TLable = new TreeLabel(lblTime, lblContext); return(TLable); }
private void lblLabel_MouseHover(object sender, EventArgs e) { int index = -1; Label lbl = sender as Label; try { TreeLabel lbl_ = listsTupLable.Where(i => i.LblTime == lbl).Single(); index = listsTupLable.IndexOf(lbl_); lbl_.LblContext.BackColor = this.lists[index].ColorSuKien; } catch (Exception) { try { TreeLabel lbl_ = listsTupLable.Where(i => i.LblContext == lbl).Single(); index = listsTupLable.IndexOf(lbl_); lbl_.LblTime.BackColor = this.lists[index].ColorSuKien; } catch (Exception) { ///Todo Cath empty /// return; } } if (index < 0) { return; } lbl.BackColor = this.lists[index].ColorSuKien; }
public void Dispose() { _defaultFont?.Dispose(); _boldFont?.Dispose(); List?.Dispose(); ListLabel?.Dispose(); Tree?.Dispose(); TreeLabel?.Dispose(); Form?.Dispose(); }
public SiebelTreeNode(EventData evtData, TreeLabel treeLabel) { EventData = evtData; TreeLabel = treeLabel; base.Text = TreeLabel != null ? FormatText() : EventData.Name; base.ImageKey = EventData.ImageKey == string.Empty ? "default.png" : EventData.ImageKey; }
/// <summary> /// 绑定标签至节点 /// </summary> /// <param name="labelId"></param> /// <param name="nodeIds"></param> /// <returns></returns> public virtual async Task BindToNode(int labelId, IEnumerable <int> nodeIds) { var repository = Resolve <IRepository <TreeLabel, int> >(); await repository.DeleteAsync(o => o.LabelId == labelId); foreach (var nodeId in nodeIds) { var treelabel = new TreeLabel() { BaseTreeId = nodeId, LabelId = labelId }; await repository.InsertAsync(treelabel); } }
private void loadDuLieu() //đỏ dữ liệu tu list lên lable, cần chay trước intialComponemt { int index = 0; if (this.lists == null) { this.lists = new List <SuKien>(); this.lists.Add(new SuKien(Color.AliceBlue, DateTime.Parse("00:00"), DateTime.Parse("23:59"), "Không có học gì khỏe re đọc blog")); } listsTupLable = new List <TreeLabel>(); int heightContext = (int)((0.82 * this.Height) / this.lists.Count); foreach (SuKien sk in this.lists) { string strTimeLable = sk.DtmBegin.ToShortTimeString() + "\n" + sk.DtmEnd.ToShortTimeString(); TreeLabel tLab = creatLineHorizotal(strTimeLable, sk.StrNoiDung, index, heightContext); listsTupLable.Add(tLab); index++; } }
/// <summary> /// Returns events so taht in can be load in to tree view, with ignore list /// </summary> public Event GetTreeEvents(List<IgnoreEvent> listIgnoreEventMsgs, TreeLabel treeLabel) { _curEvt = _evt; _curEvt.EventsToIgnore = listIgnoreEventMsgs; _curEvt.TreeLabel = treeLabel; return _curEvt; }