public Snake(LabelContainer head, LabelContainer tail, List <LabelContainer> body, Dictionary <string, Label> fillDict) { this.Head = head; this.Tail = tail; this.Body = body; this.fillDict = fillDict; }
private static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); OptionsManager opm = new OptionsManager(); opm.LoadOptions(); BinFile bFile = new BinFile(); LabelContainer lContainer = new LabelContainer(); Disassembler dsembler = new Disassembler(bFile, lContainer); Assembler asmbler = new Assembler(lContainer); MainForm mainForm = new MainForm(bFile, dsembler, asmbler, lContainer); mainForm.GetOptions(opm.options); dsembler.GetOptions(opm.options); asmbler.GetOptions(opm.options); Application.Run(mainForm); mainForm.SetOptions(opm.options); dsembler.SetOptions(opm.options); asmbler.SetOptions(opm.options); opm.SaveOptions(); }
/// <summary> /// compGraphNodesCZero is used to build up of the edges of the compatibility graph /// </summary> /// <exception cref="System.IO.IOException"></exception> internal int CompatibilityGraphNodesIfCEdgeIsZero() { int countNodes = 1; var map = new List <string>(); compGraphNodesCZero = new List <int>(); //Initialize the compGraphNodesCZero List LabelContainer labelContainer = LabelContainer.Instance; compGraphNodes.Clear(); for (int i = 0; i < source.Atoms.Count; i++) { for (int j = 0; j < target.Atoms.Count; j++) { IAtom atom1 = source.Atoms[i]; IAtom atom2 = target.Atoms[j]; //You can also check object equal or charge, hydrogen count etc if (string.Equals(atom1.Symbol, atom2.Symbol, StringComparison.OrdinalIgnoreCase) && (!map.Contains(i + "_" + j))) { compGraphNodesCZero.Add(i); compGraphNodesCZero.Add(j); compGraphNodesCZero.Add(labelContainer.GetLabelID(atom1.Symbol)); //i.e C is label 1 compGraphNodesCZero.Add(countNodes); compGraphNodes.Add(i); compGraphNodes.Add(j); compGraphNodes.Add(countNodes++); map.Add(i + "_" + j); } } } map.Clear(); return(countNodes); }
private static List <List <int> > LabelAtoms(IAtomContainer atomCont) { List <List <int> > labelList = new List <List <int> >(); for (int i = 0; i < atomCont.Atoms.Count; i++) { LabelContainer labelContainer = LabelContainer.Instance; List <int> label = new List <int>(7); // label.SetSize(7); for (int a = 0; a < 7; a++) { label.Insert(a, 0); } IAtom refAtom = atomCont.Atoms[i]; string atom1Type = refAtom.Symbol; label[0] = labelContainer.GetLabelID(atom1Type); int countNeighbors = 1; var connAtoms = atomCont.GetConnectedAtoms(refAtom); foreach (var negAtom in connAtoms) { string atom2Type = negAtom.Symbol; label[countNeighbors++] = labelContainer.GetLabelID(atom2Type); } BubbleSort(label); labelList.Add(label); } return(labelList); }
/// <summary> /// 在尾巴到苹果的路径找到后,寻找头到苹果 /// </summary> public void FromAppleToHead(ContainerDictionary dict, LabelContainer apple, List <Coordinate> road) { var newSnake = new List <Coordinate>(); newSnake.Add(new Coordinate { X_ = Tail.X, Y_ = Tail.Y }); foreach (var body in Body) { newSnake.Add(new Coordinate { X_ = body.X, Y_ = body.Y }); } foreach (var r in road) { newSnake.Add(new Coordinate { X_ = r.X_, Y_ = r.Y_ }); } dict.SetContainerType(ContainerType.Start, Head.X, Head.Y); dict.SetContainerType(ContainerType.End, apple.X, apple.Y); foreach (var r in newSnake) { dict.SetContainerType(ContainerType.Wall, r.X_, r.Y_); } }
private bool draw = false;//标记是否绘图 void lab_MouseMove(object sender, MouseEventArgs e) { if (draw) { var lab = sender as LabelContainer; dict.SetContainerType((ContainerType)type, lab.X, lab.Y); if (type == 0) { if (Start != null) { Start.BackColor = dict.LastStartContainer.ContainerColor; } Start = lab; } if (type == 1) { if (End != null) { End.BackColor = dict.LastEndContainer.ContainerColor; } End = lab; } lab.BackColor = lab.ContainerColor; textBox1.Text = dict.CanPassCount().ToString(); } }
/// <summary> /// 寻找当前尾到当前苹果的路径 /// </summary> public void FromTailToApple(ContainerDictionary dict, LabelContainer apple) { dict.SetContainerType(ContainerType.Start, Tail.X, Tail.Y); dict.SetContainerType(ContainerType.End, apple.X, apple.Y); dict.SetContainerType(ContainerType.Wall, Head.X, Head.Y); foreach (var d in Body) { dict.SetContainerType(ContainerType.Wall, d.X, d.Y); } }
public MainForm(BinFile cs, Disassembler ds, Assembler ac, LabelContainer lcnew) { InitializeComponent(); mainTextBox = ((TextBoxHost)elementHost2.Child).mainTextBox; disassembler = ds; assembler = ac; labelContainer = lcnew; romFile = cs; funcLabelBox.DataSource = labelContainer.FuncList; dataLabelBox.DataSource = labelContainer.DataList; varLabelBox.DataSource = labelContainer.VarList; }
public AddCommentForm(LabelContainer lblContainer, LabelEditMode editMode, int offset = -1) { InitializeComponent(); labelContainer = lblContainer; if (editMode == LabelEditMode.Edit) { if (labelContainer.Comments.ContainsKey(offset)) { commentBox.Text = labelContainer.Comments[offset]; } Text = "Edit Comment"; } }
public NavigationViewHorizontalTabItem(T value) : base(value) { AutoSizeAxes = Axes.X; RelativeSizeAxes = Axes.Y; LabelContainer.Add(Highlight.With(d => { d.Anchor = Anchor.BottomCentre; d.Origin = Anchor.BottomCentre; d.RelativeSizeAxes = Axes.X; })); }
private void Reset_Click(object sender, EventArgs e) { source.Cancel(); dict.Reset(); this.End = null; this.Start = null; foreach (var d in dict) { var view = d as LabelContainer; view.BackColor = d.ContainerColor; } source = new CancellationTokenSource(); }
/// <summary> /// 寻找走到下一的时候,头到尾的路径 /// </summary> public void FromNextHeadToTail(ContainerDictionary dict, LabelContainer next) { dict.SetContainerType(ContainerType.Start, next.X, next.Y); dict.SetContainerType(ContainerType.Wall, Head.X, Head.Y); foreach (var i in this.Body) { dict.SetContainerType(ContainerType.Wall, i.X, i.Y); } if (next.SnakeType != SnakeTypeEnum.Apple) { dict.SetContainerType(ContainerType.End, this.Body[0].X, this.Body[0].Y); } else { dict.SetContainerType(ContainerType.End, this.Tail.X, this.Tail.Y); } }
public OptionsForm(Disassembler op, Assembler ap, LabelContainer lc, MainFormOptions mf) { InitializeComponent(); disassembler = op; assembler = ap; lcs = lc; mfo = mf; printOffsetsCheckBox.Checked = op.PrintOffsets; hideDataSectionsCheckBox.Checked = op.HideDefinedData; printBitPatternCheckBox.Checked = op.PrintBitPattern; printCommentsCheckBox.Checked = op.PrintComments; wordWrapCheckBox.Checked = mf.isWordWrap; switch (op.PrintedOffsetFormat) { case OffsetFormat.BankOffset: offsetNumberFormatBox.SelectedIndex = 0; break; case OffsetFormat.Hex: offsetNumberFormatBox.SelectedIndex = 1; break; case OffsetFormat.Decimal: offsetNumberFormatBox.SelectedIndex = 2; break; } switch (op.InstructionNumberFormat) { case OffsetFormat.Hex: instructionNumberFormatBox.SelectedIndex = 0; break; case OffsetFormat.Decimal: instructionNumberFormatBox.SelectedIndex = 1; break; } dsmColor00Box.Text = op.GameboyFormatChars.Length > 0 ? op.GameboyFormatChars[0].ToString() : "0"; dsmColor01Box.Text = op.GameboyFormatChars.Length > 1 ? op.GameboyFormatChars[1].ToString() : "1"; dsmColor10Box.Text = op.GameboyFormatChars.Length > 2 ? op.GameboyFormatChars[2].ToString() : "2"; dsmColor11Box.Text = op.GameboyFormatChars.Length > 3 ? op.GameboyFormatChars[3].ToString() : "3"; asmColor00Box.Text = ap.GameboyFormatChars.Length > 0 ? ap.GameboyFormatChars[0].ToString() : "0"; asmColor01Box.Text = ap.GameboyFormatChars.Length > 1 ? ap.GameboyFormatChars[1].ToString() : "1"; asmColor10Box.Text = ap.GameboyFormatChars.Length > 2 ? ap.GameboyFormatChars[2].ToString() : "2"; asmColor11Box.Text = ap.GameboyFormatChars.Length > 3 ? ap.GameboyFormatChars[3].ToString() : "3"; }
private void ItemOnOverheadAdded(object sender, EventArgs e) { LabelContainer container = Engine.UI.GetByLocalSerial <LabelContainer>(Item); if (container == null) { container = new LabelContainer(Item); Engine.UI.Add(container); } TextOverhead overhead = (TextOverhead)sender; overhead.TimeToLive = 4000; FadeOutLabel label = new FadeOutLabel(overhead.Text, overhead.IsUnicode, overhead.Hue, overhead.TimeToLive, overhead.MaxWidth, overhead.Font, overhead.Style, TEXT_ALIGN_TYPE.TS_CENTER); container.Add(label); }
public void AddLabel(string text, Hue hue, byte font, bool isunicode) { if (World.ClientFlags.TooltipsEnabled) { return; } LabelContainer container = Engine.UI.GetByLocalSerial <LabelContainer>(Item); if (container == null || container.From != this) { container = new LabelContainer(Item, this); Engine.UI.Add(container); } container.SetOffsetCoordinates(_lastClickPosition); container.Add(new FadeOutLabel(text, isunicode, hue, 4000, 0, font, FontStyle.BlackBorder, TEXT_ALIGN_TYPE.TS_CENTER)); }
//初始化界面 private void InitializeUI() { dict = new ContainerDictionary(col - 1, row - 1); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(259, 210); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.MaximizeBox = false; this.Name = "Form1"; this.Text = "寻路"; this.PerformLayout(); this.Size = new Size(32 + col * howbig, 140 + row * howbig); int id = 0; for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { LabelContainer lab = new LabelContainer(); lab.CanPass = true; lab.AutoSize = false; lab.ID = id++; lab.X = j; lab.Y = i; lab.Width = howbig; lab.Height = howbig; lab.Location = new Point(howbig * j + 10, 60 + howbig * (row - i)); //lab.BorderStyle = BorderStyle.FixedSingle; lab.BorderStyle = BorderStyle.None; lab.BackColor = Color.White; lab.ContainerColor = Color.White; //lab.Text = j + "" + i; lab.Click += lab_Click; lab.MouseMove += lab_MouseMove; dict.AddOrUpdate(lab); this.Controls.Add(lab); } } }
public AddVarLabelForm(LabelContainer lblContainer, LabelEditMode editMode, VarLabel newPriorLabel = null) { InitializeComponent(); labelContainer = lblContainer; editingMode = editMode; editedLabel = newPriorLabel; if (editMode == LabelEditMode.Edit) { Text = "Edit Variable"; if (editedLabel != null) { nameBox.Text = editedLabel.Name; offsetBox.Text = editedLabel.Value.ToString("X"); if (!String.IsNullOrEmpty(editedLabel.Comment)) { commentBox.Text = editedLabel.Comment; } } } }
public void MoveOneStep(LabelContainer next) { //Thread.Sleep(moveSpeed); LastTail = Tail; LastHead = Head; LastBody = Body; if (next.SnakeType != SnakeTypeEnum.Apple) { Tail.SnakeType = SnakeTypeEnum.None; Tail.BackColor = noneColor; Tail = Body.Dequeue(); var key = string.Format("{0}{1}{2}{3}", Tail.X > LastTail.X ? LastTail.X : Tail.X, Tail.Y > LastTail.Y ? LastTail.Y : Tail.Y, Tail.X > LastTail.X ? Tail.X : LastTail.X, Tail.Y > LastTail.Y ? Tail.Y : LastTail.Y); var fill = fillDict[key]; fill.BackColor = noneColor; Tail.BackColor = TailColor; Tail.SnakeType = SnakeTypeEnum.Tail; } Head.SnakeType = SnakeTypeEnum.Body; Body.Enqueue(Head); Head.BackColor = snakeColor; Head = next; Head.SnakeType = SnakeTypeEnum.Head; Head.BackColor = HeadColor; var key2 = string.Format("{0}{1}{2}{3}", Head.X > LastHead.X ? LastHead.X : Head.X, Head.Y > LastHead.Y ? LastHead.Y : Head.Y, Head.X > LastHead.X ? Head.X : LastHead.X, Head.Y > LastHead.Y ? Head.Y : LastHead.Y); var fill2 = fillDict[key2]; fill2.BackColor = snakeColor; }
protected virtual void UpdateLabel() { if (World.ClientFlags.TooltipsEnabled) { return; } if (!Item.IsDisposed && Item.Overheads.Count > 0) { LabelContainer container = Engine.UI.GetByLocalSerial <LabelContainer>(Item); if (container == null) { container = new LabelContainer(Item); Engine.UI.Add(container); } container.X = ScreenCoordinateX + (Width >> 1) /*- (container.Width >> 1)*/; container.Y = ScreenCoordinateY /*- (Height >> 1) */ - (container.Height); Engine.UI.MakeTopMostGumpOverAnother(container, this); } }
protected override void UpdateLabel() { if (World.ClientFlags.TooltipsEnabled) { return; } if (!Item.IsDisposed && Item.HasOverheads && Item.Overheads.Count > 0) { LabelContainer container = Engine.UI.GetByLocalSerial <LabelContainer>(Item); if (container == null) { container = new LabelContainer(Item); Engine.UI.Add(container); } container.X = ScreenCoordinateX + _clickedPoint.X - (container.Width >> 1); container.Y = ScreenCoordinateY + _clickedPoint.Y - (container.Height >> 1); Engine.UI.MakeTopMostGumpOverAnother(container, this); } }
/// <summary> /// 寻找吃掉苹果之后,头到尾的路径 /// </summary> public void FromAppleToTail(ContainerDictionary dict, LabelContainer apple, List <Coordinate> road) { var newSnake = new List <Coordinate>(); newSnake.Add(new Coordinate { X_ = Tail.X, Y_ = Tail.Y }); foreach (var body in Body) { newSnake.Add(new Coordinate { X_ = body.X, Y_ = body.Y }); } newSnake.Add(new Coordinate { X_ = Head.X, Y_ = Head.Y }); foreach (var r in road) { newSnake.Add(new Coordinate { X_ = r.X_, Y_ = r.Y_ }); } var snakeLength = Body.Count + 2; //蛇长 var roadLength = newSnake.Count; //总长 //移除多余的 newSnake.RemoveRange(0, roadLength - snakeLength); dict.SetContainerType(ContainerType.Start, apple.X, apple.Y); dict.SetContainerType(ContainerType.End, newSnake[0].X_, newSnake[0].Y_); newSnake.RemoveAt(0); foreach (var r in newSnake) { dict.SetContainerType(ContainerType.Wall, r.X_, r.Y_); } }
public AddDataLabelForm(LabelContainer lblContainer, LabelEditMode editMode, DataLabel newPriorLabel = null) { InitializeComponent(); labelContainer = lblContainer; editingMode = editMode; editedLabel = newPriorLabel; dataTypeBox.SelectedIndex = 0; if (editMode == LabelEditMode.Edit) { Text = "Edit Data Section"; if (editedLabel != null) { nameBox.Text = editedLabel.Name; offsetBox.Text = editedLabel.Offset.ToString("X"); lengthBox.Text = editedLabel.Length.ToString("X"); dataTypeBox.SelectedIndex = (int)editedLabel.DSectionType; if (!String.IsNullOrEmpty(editedLabel.Comment)) { commentBox.Text = editedLabel.Comment; } dataTemplateBox.Text = TemplateBuilder.TemplateToString(editedLabel.PrintTemplate); } } }
private void InitializeUI() { this.BackColor = Color.White; var dict = new ContainerDict(col - 1, row - 1); this.panel1.Width = col * (howbig + padding) + (col - 1) * padding + 18; this.panel1.Height = row * (howbig + padding) + (row - 1) * padding + 4; this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(259, 210); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.MaximizeBox = false; this.Name = "Form1"; this.Text = "自动贪吃蛇"; this.PerformLayout(); this.Size = new Size(32 + col * (howbig + padding), 140 + row * (howbig + padding)); for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { LabelContainer lab = new LabelContainer(); lab.AutoSize = false; lab.X = j; lab.Y = i; lab.Width = howbig; lab.Height = howbig; //lab.Location = new Point((howbig + padding) * j + 10, 60 + (howbig + padding) * (row - i)); lab.Location = new Point((howbig + padding) * j, (howbig + padding) * (row - i - 1)); //lab.Text = j + " " + i; //lab.BorderStyle = BorderStyle.None; lab.Click += lab_Click; //lab.MouseMove += lab_MouseMove; //设置格子属性 lab.SnakeType = SnakeTypeEnum.None; dict.AddOrUpdate(lab); this.panel1.Controls.Add(lab); } } foreach (var l in dict) { //if (ii++ > 1) //{ // break; //} foreach (var dir in Direction.DirectionArray) { var curX = l.X + dir.X_; var curY = l.Y + dir.Y_; if (!(curX < 0 || curX > col - 1 || curY < 0 || curY > row - 1))//超出范围 { var key = string.Format("{0}{1}{2}{3}", l.X, l.Y, curX, curY); if (!fillDict.ContainsKey(key)) { var lab = new Label(); lab.AutoSize = false; if (l.X == curX) { lab.Width = howbig; lab.Height = padding; } if (l.Y == curY) { lab.Width = padding; lab.Height = howbig; } lab.Location = new Point(l.Location.X + dir.X_ * howbig, l.Location.Y - dir.Y_ * padding); //lab.Text = key; lab.BackColor = Color.White; //lab.BorderStyle = BorderStyle.FixedSingle; fillDict.Add(key, lab); this.panel1.Controls.Add(lab); } } } } map = new MapManager(dict, fillDict, this.StartTextBox); }
/// <summary> /// 走向离苹果最远的格子一步 /// </summary> public bool RunFaraway() { try { var head = snake.Head; LabelContainer label = null; //处理多选项 var tuple = Tuple.Create(head.X, head.Y); List <MapHelper> choiseList; //if (choiseDict.ContainsKey(tuple)) //{ // //由于一旦改变了某一个格子的前进方向,就会导致其后的所有选择都失效 // //所以必须清空其他选项,并保留当前选项 // choiseList = choiseDict[tuple]; //} //else //{ // choiseList = ManagerMapHelperList(); // choiseDict.Add(tuple, choiseList); //} //if (choiseList.Count > 0) //{ // var nextCoord = choiseList[0]; // var next = dict[nextCoord.Coor.X_, nextCoord.Coor.Y_]; // while (true) // { // if (next.SnakeType == SnakeTypeEnum.Tail) // break; // if (!(next == null || next.SnakeType == SnakeTypeEnum.Body)) // { // var containerDict = new ContainerDictionary(dict.TotalX, dict.TotalY); // snake.FromNextHeadToTail(containerDict, dict[nextCoord.Coor.X_, nextCoord.Coor.Y_]);//判断走到下一格之后,是否有路找到尾 // var finder = CreateNewFinder(); // if (finder.Execute(containerDict) == "成功") // break; // } // choiseList.RemoveAt(0); // choiseList.Add(nextCoord); // nextCoord = choiseList[0]; // next = dict[nextCoord.Coor.X_, nextCoord.Coor.Y_]; // } // choiseList.RemoveAt(0); // choiseList.Add(nextCoord); // label = dict[nextCoord.Coor.X_, nextCoord.Coor.Y_]; //} //choiseList = ManagerMapHelperList(); //if (choiseList.Count > 0) // label = dict[choiseList[0].Coor.X_, choiseList[0].Coor.Y_]; var choise = ManagerMapHelper(); if (choise != null) { label = dict[choise.Coor.X_, choise.Coor.Y_]; } //如果能找到这样一个格子,就走一步,如果这样的格子找不到了,就说明游戏结束 if (label != null) { if (label.SnakeType == SnakeTypeEnum.Apple) { this.Apple = null; } snake.MoveOneStep(label); return(true); } } catch (Exception e) { } return(false); }