private void CreateLabel(Color backColour, bool border, bool outline) { NameLabel = null; for (int i = 0; i < LabelList.Count; i++) { if (LabelList[i].Text != Name || LabelList[i].Border != border || LabelList[i].BackColour != backColour || LabelList[i].ForeColour != NameColour || LabelList[i].OutLine != outline) { continue; } NameLabel = LabelList[i]; break; } if (NameLabel != null && !NameLabel.IsDisposed) { return; } NameLabel = new MirControls.MirLabel { AutoSize = true, BorderColour = Color.Black, BackColour = backColour, ForeColour = NameColour, OutLine = outline, Border = border, Text = Regex.Replace(Name, @"\d+$", string.Empty), }; LabelList.Add(NameLabel); }
public void CreateNPCLabel(string word, int wordOrder) { TempLabel = null; for (int i = 0; i < LabelList.Count; i++) { if (LabelList[i].Text != word || LabelList[i].ForeColour != (wordOrder == 0 ? NameColour : Color.White)) { continue; } TempLabel = LabelList[i]; break; } if (TempLabel != null && !TempLabel.IsDisposed) { return; } TempLabel = new MirLabel { AutoSize = true, BackColour = Color.Transparent, ForeColour = wordOrder == 0 ? NameColour : Color.White, OutLine = true, OutLineColour = Color.Black, Text = word, }; TempLabel.Disposing += (o, e) => LabelList.Remove(TempLabel); LabelList.Add(TempLabel); }
private void LoadTrainnedFace() { try { LabelList.Clear(); TrainingImages.Clear(); // Load haarcascades for face detection Face = new HaarCascade("haarcascade_frontalface_default.xml"); // Load the number of trained faces var files = GetAllFiles(Application.StartupPath + "/TrainedFaces"); TrainedFacesCounter = files.Count; foreach (var file in files) { TrainingImages.Add(new Image <Gray, byte>(file.FullName)); LabelList.Add(file.Name.Split('@')[0]); } } catch { // By pass } }
public void CreateGameField() { GameTiles = new List <List <Image> >(); for (int i = 0; i < 4; i++) { GameTiles.Add(new List <Image>()); } foreach (var LabelList in GameTiles) { for (int i = 0; i < 4; i++) { LabelList.Add(new Image() { BackgroundColor = Color.Gray, }); } } int c = 0; int b = 0; foreach (var LabelList in GameTiles) { foreach (var Label in LabelList) { GameGrid.Children.Add(Label, b, c); c++; } c = 0; b++; } }
public override void CreateLabel() { base.CreateLabel(); OwnerLabel = null; string ownerText = $"{OwnerName}'s Hero"; for (int i = 0; i < LabelList.Count; i++) { if (LabelList[i].Text != ownerText || LabelList[i].ForeColour != NameColour) { continue; } OwnerLabel = LabelList[i]; break; } if (OwnerLabel != null && !OwnerLabel.IsDisposed) { return; } OwnerLabel = new MirLabel { AutoSize = true, BackColour = Color.Transparent, ForeColour = NameColour, OutLine = true, OutLineColour = Color.Black, Text = ownerText, }; OwnerLabel.Disposing += (o, e) => LabelList.Remove(OwnerLabel); LabelList.Add(OwnerLabel); }
/**/ /// <summary> /// 是否动态改变颜色 /// </summary> public bool IsChangeColor = false; #endregion protected void Page_Load(object sender, EventArgs e) { zedGraphControl.Width = ZGWidth; zedGraphControl.Height = ZGHeight; zedGraphControl.RenderGraph += new ZedGraph.Web.ZedGraphWebControlEventHandler(zedGraphControl_RenderGraph); //保存位置(ZedGraph/Images目录可以自定义) FilePath = "~/Admin/Controls/ZedGraph/"; zedGraphControl.RenderedImagePath = FilePath; } private void InitDefaultColors() { //以下为颜色样例 //defaultColors.Add(Color.Red); //defaultColors.Add(Color.Green); //defaultColors.Add(Color.Blue); //defaultColors.Add(Color.Yellow); //defaultColors.Add(Color.YellowGreen); //defaultColors.Add(Color.Brown); //defaultColors.Add(Color.Aqua); //defaultColors.Add(Color.Cyan); //defaultColors.Add(Color.DarkSeaGreen); //defaultColors.Add(Color.Indigo); if (IsChangeColor) { defaultColors.Add(Color.FromArgb(255, 158, 158)); //红色 defaultColors.Add(Color.FromArgb(167, 233, 145)); //绿色 defaultColors.Add(Color.FromArgb(145, 233, 255)); //蓝色 defaultColors.Add(Color.FromArgb(255, 255, 145)); //黄色 defaultColors.Add(Color.FromArgb(211, 233, 145)); //黄绿 defaultColors.Add(Color.FromArgb(255, 145, 255)); //紫色 defaultColors.Add(Color.FromArgb(0, 153, 255)); defaultColors.Add(Color.FromArgb(255, 204, 0)); defaultColors.Add(Color.FromArgb(76, 183, 255)); // defaultColors.Add(Color.FromArgb(255, 214, 51)); defaultColors.Add(Color.FromArgb(127, 204, 255)); // defaultColors.Add(Color.FromArgb(255, 224, 102)); defaultColors.Add(Color.FromArgb(166, 219, 255)); // defaultColors.Add(Color.FromArgb(255, 235, 153)); defaultColors.Add(Color.FromArgb(204, 235, 255)); // defaultColors.Add(Color.FromArgb(255, 245, 204)); } else { defaultColors.Add(Color.FromArgb(0, 153, 255)); // defaultColors.Add(Color.FromArgb(255, 204, 0)); defaultColors.Add(Color.FromArgb(76, 183, 255)); // defaultColors.Add(Color.FromArgb(255, 214, 51)); defaultColors.Add(Color.FromArgb(127, 204, 255)); // defaultColors.Add(Color.FromArgb(255, 224, 102)); defaultColors.Add(Color.FromArgb(166, 219, 255)); // defaultColors.Add(Color.FromArgb(255, 235, 153)); defaultColors.Add(Color.FromArgb(204, 235, 255)); // defaultColors.Add(Color.FromArgb(255, 245, 204)); } } /**/ /// <summary> /// 如果属性为空则初始化属性数据 /// </summary> private void InitProperty() { InitDefaultColors(); if (string.IsNullOrEmpty(Title)) { Title = string.Empty; } if (string.IsNullOrEmpty(XAxisTitle)) { XAxisTitle = "横轴"; } if (string.IsNullOrEmpty(YAxisTitle)) { YAxisTitle = "纵轴"; } if (Type == AnalyticsType.Pie) { Count = ScaleData.Count; } else { Count = DataSource.Count; } if (Colors.Count == 0 || Colors.Count != Count) { if (IsChangeColor) { for (int i = 0; i < 16; i++) { Colors.Add(defaultColors[i]); } } else { for (int i = 0; i < 10; i++) { Colors.Add(defaultColors[i]); } } } if (NameList.Count == 0) { if (Type == AnalyticsType.Bar || Type == AnalyticsType.Line) { for (int i = 0; i < DataSource[0].Count; i++) { NameList.Add((i + 1).ToString()); } } else { for (int i = 0; i < Count; i++) { NameList.Add((i + 1).ToString()); } } } if (LabelList.Count == 0) { if (Count > 5) { int k = 1; for (int i = 0; i < Count; i++) { LabelList.Add("名称 " + k.ToString()); if (i % 2 != 0) { k++; } } } else { for (int i = 0; i < Count; i++) { LabelList.Add("名称 " + (i + 1).ToString()); } } } }