public List <Point> helping(int kk, int[,] mat4, int x11, int y11, PictureBox[] picbox3, int[] kings3, int[] rooks3) { int[,] help = new int[8, 8]; Point pos11 = new Point(x11, y11); king k13 = new king(pos11, mat4, picbox3, kk, kings3, rooks3); Point poo = new Point(); Point po = k13.toking(x11, y11, mat4, picbox3, kk); List <Point> lst5 = new List <Point>(); Node <Point> nd5 = lst5.GetFirst(); for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { help[i, j] = mat4[i, j]; } } help[x11, y11] = kk; if (k13.toking(po.X, po.Y, help, picbox3, kk * -1) == new Point(-1, -1)) { return(lst5); } else { poo = k13.toking(po.X, po.Y, help, picbox3, kk * -1); nd5 = lst5.Insert(nd5, poo); help[poo.X, poo.Y] = kk; while (k13.toking(po.X, po.Y, help, picbox3, kk * -1) != new Point(-1, -1)) { Point pt = k13.toking(po.X, po.Y, help, picbox3, kk * -1); nd5 = lst5.Insert(nd5, pt); help[pt.X, pt.Y] = kk; } } Node <Point> pos = lst5.GetFirst(); while (pos != null) { picbox3[pos.GetInfo().X * 10 + pos.GetInfo().Y - 2 * pos.GetInfo().X].Enabled = true; pos = pos.GetNext(); } return(lst5); }
private void Game_Paint(object sender, PaintEventArgs e) { g = e.Graphics; s.PaintPlayer(g); game.PaintBoard(g); pos = ls.GetFirst(); while (pos != null) { Shoot s1 = new Shoot(); s1 = pos.GetInfo(); s1.PaintShoot(g); pos = pos.GetNext(); } }
public void shah(int x, int y, PictureBox[] pics, int[,] mat, int playernum) { king k = new king(new Point(x, y), mat, picbox, playernum, kings, rooks); List <Point> lst = k.helping(playernum * -1, mat, x, y, picbox, kings, rooks); Node <Point> pos = lst.GetFirst(); for (int i = 0; i < 64; i++) { if (picbox[i].BackColor == Color.Green) { picbox[i].Enabled = true; } else { picbox[i].Enabled = false; } } while (pos != null) { picbox[pos.GetInfo().X * 10 + pos.GetInfo().Y - 2 * pos.GetInfo().X].Enabled = true; pos = pos.GetNext(); } picbox[x * 10 + y - 2 * x].Enabled = true; MessageBox.Show("shaaaaaaaaaaaaaaaaaaaa7"); }
public PathResolver(IEnumerable <Variable> v) { variables = v.ToList(); input_type = variables.GetFirst().GetDeclaringType(); output_type = variables.GetLast().GetVariableType(); }
private void OnPatternAdded(PathPatternType patternType, List<ContourSegment> topSections, List<ContourSegment> bottomSections) { if (patternType != PathPatternType.Flat) return; ContourSegment section = bottomSections.GetFirst(); Ice ice = GenerateItem<Ice>(); ice.SetSection(section); }
/// <returns> /// the image files that have the most recent associated /// transaction IDs. If there are multiple storage directories which /// contain equal images, we'll return them all. /// </returns> /// <exception cref="System.IO.FileNotFoundException">if not images are found.</exception> /// <exception cref="System.IO.IOException"/> internal override IList <FSImageStorageInspector.FSImageFile> GetLatestImages() { List <FSImageStorageInspector.FSImageFile> ret = new List <FSImageStorageInspector.FSImageFile >(); foreach (FSImageStorageInspector.FSImageFile img in foundImages) { if (ret.IsEmpty()) { ret.AddItem(img); } else { FSImageStorageInspector.FSImageFile cur = ret.GetFirst(); if (cur.txId == img.txId) { ret.AddItem(img); } else { if (cur.txId < img.txId) { ret.Clear(); ret.AddItem(img); } } } } if (ret.IsEmpty()) { throw new FileNotFoundException("No valid image files found"); } return(ret); }
public static T DrawFirstElementOfFirstSubList <T>( this List <List <T> > listOfLists ) { var firstSubList = listOfLists.GetFirst(); if (firstSubList.Count > 0) { int firstItemIndex = 0; T item = firstSubList[firstItemIndex]; firstSubList.RemoveAt(firstItemIndex); if (firstSubList.Count <= 0) { // remove first sublist listOfLists.RemoveAt(0); } return(item); } else { throw new System.Exception("List is empty, cannot draw last element of empty list."); } }
private async Task <ReactionRole> GetReactionRoleIfValid(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction) { // Don't modify bot roles if (reaction.UserId == Program.DiscordClient.CurrentUser.Id) { return(new ReactionRole()); } // Don't process if message is not a reaction role message if (!this.messageReactionRoleLookup.ContainsKey(message.Id)) { return(new ReactionRole()); } // Load Reaction Roles for Message List <ReactionRole> reactionRoles = await ReactionRoleDatabase.LoadAll(new Dictionary <string, object> { { "MessageId", message.Id } }); // Get first reaction role (should only be one for each message id) ReactionRole reactionRole = reactionRoles.GetFirst(); // Load Reaction Role itemsfor Message reactionRole.Reactions = await ReactionRoleItemDatabase.LoadAll(new Dictionary <string, object> { { "ReactionRoleId", reactionRole.Id }, }); return(reactionRole); }
//רוזמרין اقليل الجبل public void Filllist(int n, Point[] pt, List <Point>[] lpt) { if (n >= 0) { List <Point> lst = new List <Point>(); Node <Point> np1 = lst.GetFirst(); Point pp = pt[n - 1]; int x = pp.X; int y = pp.Y; if (mat[x, y] * playernum > 0)//> { switch (mat[x, y]) { case 1: case -1: Pawn p2 = new Pawn(new Point(x, y), mat, picbox, playernum, kingsplace, kings, rooks); p2.showGreenplaces(x, y, picbox); break; case 2: case -2: rook r2 = new rook(new Point(x, y), mat, picbox, playernum, kingsplace, kings, rooks); r2.showGreenplaces(x, y, picbox); break; case 3: case -3: knight kn2 = new knight(new Point(x, y), mat, picbox, playernum, kingsplace, kings, rooks); kn2.showGreenplaces(x, y, picbox); break; case 4: case -4: fou f2 = new fou(new Point(x, y), mat, picbox, playernum, kingsplace, kings, rooks); f2.showGreenplaces(x, y, picbox); break; case 5: case -5: queen q2 = new queen(new Point(x, y), mat, picbox, playernum, kingsplace, kings, rooks); q2.showGreenplaces(x, y, picbox); break; case -6: king k2 = new king(new Point(x, y), mat, picbox, playernum, kings, rooks); k2.showGreenplaces(x, y, picbox); break; default: break; } for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { if (picbox[i * 10 + j - 2 * i].BackColor == Color.Green) { np1 = lst.Insert(np1, new Point(i, j)); } } } game_main gm = new game_main(); gm.refreshcolors(picbox, playernum, mat); } lpt[n - 1] = lst; if (n > 1) { Filllist(n - 1, pt, lpt); } } }
public static T GetOnly <T>(this List <T> list, string error) { if (list.Count != 1) { throw new ArgumentException(error); } return(list.GetFirst(error)); }
public void Drawlist(Graphics g) { pos = lb.GetFirst(); while (pos != null) { pos.GetInfo().PaintBlocks(g); pos = pos.GetNext(); } }
public static T GetFirstElementOfFirstSubList <T>( this List <List <T> > listOfLists ) { var firstSubList = listOfLists.GetFirst(); var firstElement = firstSubList.GetFirst(); return(firstElement); }
public void Drawlist(Graphics g)//פעולה המציירת רשימה של לבנים { pos = lb.GetFirst(); while (pos != null) { pos.GetInfo().PaintBlocks(g); pos = pos.GetNext(); } }
/** * Consumes the first item in the user's inventory. */ private void TestConsume() { Debug.Log("Testing consume"); UserData userData = BackendManager.Instance.GetUserData(); List<ItemInstance> inventory = userData.GetInventory(); userData.Consume(inventory.GetFirst(), m_request.OnSuccess, OnFailure); }
public override void AfterDo(object bp, ref object result) { if (result != null ) { //HBHTransferSV transSV = bp as HBHTransferSV; //if (transSV != null) //{ // svID = transSV.ID; //} List <TransferInResultDTO> resultTransfer = result as List <TransferInResultDTO>; List <ShipBackDTO> resultShipBack = result as List <ShipBackDTO>; List <SoBackDTO> resultSOBack = result as List <SoBackDTO>; if (resultTransfer != null) { TransferInResultDTO first = resultTransfer.GetFirst(); if (first != null) { HBHCommon.HBHCommonSVAfter(svID, resultTransfer, first.IsSuccess, first.ErrorInfo, first.ERPDocNo); } } else if (resultShipBack != null) { if (resultShipBack != null) { ShipBackDTO first = resultShipBack.GetFirst(); if (first != null) { HBHCommon.HBHCommonSVAfter(svID, result, first.IsSuccess, first.ErrorInfo, first.ERPDocNo); } } } else if (resultSOBack != null) { if (resultSOBack != null) { SoBackDTO first = resultSOBack.GetFirst(); if (first != null) { HBHCommon.HBHCommonSVAfter(svID, result, first.IsSuccess, first.ErrorInfo, first.ERPDocNo); } } } else { HBHCommon.HBHCommonSVAfter(svID, result, true, string.Empty, string.Empty); } } }
public bool deathofking(int i1, int j1, int[,] mat2, PictureBox[] picbox2, int[] kings2, int[] rooks2, int k11) { Node <Point> np1 = null; Point pos1 = new Point(i1, j1); List <Point> lst3 = new List <Point>(); king k12 = new king(pos1, mat2, picbox2, k11 * -1, kings2, rooks2); if (k12.toking(i1, j1, mat2, picbox2, k11) == new Point(-1, -1)) { return(false); } try { lst3 = k12.placestomove(); Point pp1 = lst3.GetFirst().GetInfo(); np1 = lst3.GetFirst(); } catch (Exception) { } while (np1 != null) { if (k12.toking(np1.GetInfo().X, np1.GetInfo().Y, mat2, picbox2, k11) != new Point(-1, -1)) { np1 = lst3.Remove(np1); } else { break; } } if (lst3.IsEmpty() == true) { return(true); } else { return(false); } }
static int GetNumOf(List <int> l) { int counter = 0; Node <int> n1 = l.GetFirst(); while (n1 != null) { counter++; n1 = n1.GetNext(); } return(counter); }
// default format string /// <exception cref="System.IO.IOException"/> protected internal override void ProcessOptions(List <string> args) { CommandFormat cf = new CommandFormat(1, int.MaxValue, "R"); cf.Parse(args); SetRecursive(cf.GetOpt("R")); if (args.GetFirst().Contains("%")) { format = args.RemoveFirst(); } cf.Parse(args); }
static void PrintEven(List <int> l) { Node <int> n1 = l.GetFirst(); while (n1 != null) { if (n1.GetInfo() % 2 == 0) { Console.WriteLine(n1); } n1 = n1.GetNext(); } }
/// <exception cref="System.IO.IOException"/> protected internal override void ProcessArguments(List <PathData> items) { base.ProcessArguments(items); if (numErrors != 0) { // check for error collecting paths return; } Preconditions.CheckArgument(items.Count == 1); PathData sroot = items.GetFirst(); sroot.fs.RenameSnapshot(sroot.path, oldName, newName); }
/// <exception cref="System.IO.IOException"/> protected internal override void ProcessArguments(List <PathData> items) { base.ProcessArguments(items); if (numErrors != 0) { // check for error collecting paths return; } System.Diagnostics.Debug.Assert((items.Count == 1)); PathData sroot = items.GetFirst(); sroot.fs.DeleteSnapshot(sroot.path, snapshotName); }
public void Work() { int location = 0; Node <Client> FirstVictim = Victims.GetFirst(); Node <RadioButton> FirstRB = RadioB.GetFirst(); while (FirstVictim != null) { FirstVictim.GetInfo().sendData("GetName"); FirstRB = RadioB.Insert(FirstRB, new RadioButton()); FirstRB.GetInfo().SetBounds(180, 60 + (12 * location), 12, 12); ConnctionItem[location] = new ListViewItem((location + 1).ToString(), 0); string[] ConnactionArr = FirstVictim.GetInfo().GetData().Split('#'); ConnctionItem[location].SubItems.Add(ConnactionArr[0]); ConnctionItem[location].SubItems.Add(ConnactionArr[1]); //ConnctionItem[location].SubItems.Add(ConnactionArr[2]); Connections.Items.Add(ConnctionItem[location]); CreateRB(FirstRB.GetInfo()); FirstVictim = FirstVictim.GetNext(); location++; } }
public float GetValue(float x) { if (x <= 0.0f) { return(percents.GetFirst()); } if (x >= 1.0f) { return(percents.GetLast()); } return(percents.GetInterpolate(percents.GetFinalIndex() * x)); }
static double Average(List <int> l) { double sum = 0; int counter = 0; Node <int> n1 = l.GetFirst(); while (n1 != null) { sum += n1.GetInfo(); counter++; n1 = n1.GetNext(); } return(sum / counter); }
//להציג מקומות האפשריות בצבע ירוק public void showGreenplaces(int i, int j, PictureBox[] pics) { Node <Point> np = null; Point pos = new Point(i, j); List <Point> lst2 = new List <Point>(); king k1 = new king(pos, mat, pics, playernum, kings, rooks); try { lst2 = k1.placestomove(); Point pp = lst2.GetFirst().GetInfo(); np = lst2.GetFirst(); } catch (Exception) { } while (np != null) { int x = np.GetInfo().X; int y = np.GetInfo().Y; int n = x * 10 + y - 2 * x; if (k1.toking(x, y, mat, picbox, playernum * -1) == new Point(-1, -1)) { pics[n].BackColor = Color.Green; pics[n].Enabled = true; } else { pics[n].BackColor = Color.Red; } pics[n].Enabled = true; pics[n].Visible = true; np = np.GetNext(); } }
static bool CheckPositive(List <int> l) { bool flag = true; Node <int> n1 = l.GetFirst(); while (flag && n1 != null) { if (n1.GetInfo() < 1) { flag = false; } n1 = n1.GetNext(); } return(flag); }
//// تكملة الكود public int getmaxtotalscore(List <chess_power> cplst) { Node <chess_power> chnd = cplst.GetFirst(); int max = chnd.GetInfo().totalscour(); while (chnd != null) { if (max < chnd.GetInfo().totalscour()) { max = chnd.GetInfo().totalscour(); } chnd = chnd.GetNext(); } return(max); }
bool RemergeTail(Seg hit) { // find the inactive tail that this bit is a part of List <Seg> hitWorm = null; foreach (var worm in worms) { // is the hit piece the tail or head of this tail? if (hit == worm.GetFirst() || hit == worm.GetLast()) { hitWorm = worm; break; } } if (hitWorm == null) { return(false); } else { // assimilate! worms.Remove(hitWorm); if (worm2key.ContainsKey(hitWorm)) { int key = worm2key[hitWorm]; worm2key.Remove(hitWorm); key2worm.Remove(key); } // reconnect so the new head is the OTHER end of the hit tail if (hit == hitWorm.GetFirst()) { hitWorm.Reverse(); } activeWorm.GetFirst().isHead = false; activeWorm.InsertRange(0, hitWorm); foreach (var seg in activeWorm) { seg.isActive = true; seg.isHead = false; } activeWorm.GetFirst().isHead = true; return(true); } }
/// <summary> /// Copy all entries which are still in untrackedParentFolders and which /// belong to a path this treewalk has left into untrackedFolders. /// </summary> /// <remarks> /// Copy all entries which are still in untrackedParentFolders and which /// belong to a path this treewalk has left into untrackedFolders. It is sure /// that we will not find any tracked files underneath these paths. Therefore /// these paths definitely belong to untracked folders. /// </remarks> /// <param name="currentPath">the current path of the treewalk</param> private void CopyUntrackedFolders(string currentPath) { string pathToBeSaved = null; while (!untrackedParentFolders.IsEmpty() && !currentPath.StartsWith(untrackedParentFolders .GetFirst() + "/")) { pathToBeSaved = untrackedParentFolders.RemoveFirst(); } if (pathToBeSaved != null) { while (!untrackedFolders.IsEmpty() && untrackedFolders.GetLast().StartsWith(pathToBeSaved )) { untrackedFolders.RemoveLast(); } untrackedFolders.AddLast(pathToBeSaved); } }
static void Main() { // create List container var list = new List <double>(); // use List insert methods list.InsertAtFront(3.5); list.Display(); list.InsertAtFront(4.2); list.Display(); list.InsertAtBack(5.3); list.Display(); list.InsertAtBack(2); list.Display(); //Ecervise 2(a and b) Console.WriteLine(list.GetFirst()); Console.WriteLine(list.GetLast()); try { object removedObject = list.RemoveFromFront(); Console.WriteLine($"{removedObject} removed"); list.Display(); removedObject = list.RemoveFromFront(); Console.WriteLine($"{removedObject} removed"); list.Display(); removedObject = list.RemoveFromBack(); Console.WriteLine($"{removedObject} removed"); list.Display(); removedObject = list.RemoveFromBack(); Console.WriteLine($"{removedObject} removed"); list.Display(); } catch (EmptyListException emptyListException) { Console.Error.WriteLine($"\n{emptyListException}"); } }
public chess_power whatthemorbestpaice(List <chess_power> cplst) { Node <chess_power> cpnd = cplst.GetFirst(); chess_power cp = cpnd.GetInfo(); chess_power cpmin = new chess_power(mat, cp.befor, cp.after, playernum, picbox, kings, rooks, kingsplace); int min = Math.Abs(mat[cp.befor.X, cp.befor.Y]); while (cpnd != null) { cp = cpnd.GetInfo(); int scour = cp.totalscour(); int item = Math.Abs(mat[cp.befor.X, cp.befor.Y]); if (Math.Abs(mat[cp.befor.X, cp.befor.Y]) < min) { min = Math.Abs(mat[cp.befor.X, cp.befor.Y]); cpmin = new chess_power(mat, cp.befor, cp.after, playernum, picbox, kings, rooks, kingsplace); } cpnd = cpnd.GetNext(); } return(cpmin); }
protected virtual IEnumerator ChangeInput() { if(!_checking) { _checking = true; EventSystem v_eventSystem = EventSystem.current; if(v_eventSystem != null) { bool v_moveBack = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift); GameObject v_currentSelectedGameObject = v_eventSystem.currentSelectedGameObject; Selectable v_currentSelectedComponent = v_currentSelectedGameObject != null? v_currentSelectedGameObject.GetComponent<Selectable>() : null; if(!(v_currentSelectedComponent is InputField) || !(((InputField)v_currentSelectedComponent).multiLine)) { List<Selectable> v_currentSelectables = new List<Selectable>(); for(int i=0; i<Selectable.allSelectables.Count; i++) { Selectable v_selectableComponent = Selectable.allSelectables[i]; v_currentSelectables.RemoveChecking(v_selectableComponent); if(v_selectableComponent != null && v_selectableComponent.navigation.mode != Navigation.Mode.None && FocusContainer.IsUnderFocus(v_selectableComponent.gameObject)) { //Sort with SelectionUpDown Index int v_indexDown = v_currentSelectables.IndexOf(v_selectableComponent.navigation.selectOnDown); int v_indexUp = v_currentSelectables.IndexOf(v_selectableComponent.navigation.selectOnUp); bool v_insertingComplete = false; int v_indexToInsert = v_indexDown >=0 && v_indexDown < v_currentSelectables.Count? v_indexDown : (v_indexUp >=0 && v_indexUp < v_currentSelectables.Count? v_indexUp + 1 : -1); if(v_indexToInsert >=0 && v_indexToInsert < v_currentSelectables.Count+1) { try { v_currentSelectables.Insert(v_indexToInsert, v_selectableComponent); v_insertingComplete = true; } catch{} } if(!v_insertingComplete) { v_insertingComplete = true; v_currentSelectables.Add(v_selectableComponent); } } } if(v_currentSelectedComponent != null) { int v_index = v_currentSelectables.IndexOf(v_currentSelectedComponent); v_index = v_moveBack? v_index-1 : v_index+1; v_currentSelectedComponent = v_index >= 0 && v_index < v_currentSelectables.Count? v_currentSelectables[v_index] : null; v_currentSelectedGameObject = v_currentSelectedComponent != null? v_currentSelectedComponent.gameObject : null; } if(v_currentSelectedComponent == null) { v_currentSelectedComponent = v_moveBack? v_currentSelectables.GetLast() : v_currentSelectables.GetFirst(); v_currentSelectedGameObject = v_currentSelectedComponent != null? v_currentSelectedComponent.gameObject : null; } v_eventSystem.SetSelectedGameObject(v_currentSelectedGameObject); if (v_currentSelectedComponent != null) { InputField v_inputfield = v_currentSelectedComponent.GetComponent<InputField>(); if (v_inputfield != null) v_inputfield.OnPointerClick(new PointerEventData(v_eventSystem)); yield return StartCoroutine(CoroutineUtil.WaitForRealSeconds(0.05f)); } } } _checking = false; } }
private void OnPatternAdded(PathPatternType patternType, List<ContourSegment> topSections, List<ContourSegment> bottomSections) { if (patternType == PathPatternType.End) { GenerateItemOnSegment(bottomSections.GetFirst(), 0); } }