public void Swap(SortBox other) { if (this != other) { var temp = this.Data; this.Data = other.Data; other.Data = temp; } }
private void sort_Click(object sender, EventArgs e) { var p = new Popup(); var box = new SortBox(); box.SortSelectCompleted += new EventHandler <SortSelectEventArgs>(async(sd, ea) => { p.IsOpen = false; if (ea.IsChanged) { islistbusy = true; await getListNew(); islistbusy = false; } }); p.Child = box; p.IsOpen = true; }
void SetupMegaBoxes() { mainContainer.AddChild(newPlayerBox = new NewPlayerBox()); newPlayerBox.SetToCell(CellManager.megaNewPlayer); megaBoxes.Add(newPlayerBox); mainContainer.AddChild(resetBox = new ResetBox()); resetBox.SetToCell(CellManager.megaReset); megaBoxes.Add(resetBox); mainContainer.AddChild(sortBox = new SortBox()); sortBox.SetToCell(CellManager.megaSort); megaBoxes.Add(sortBox); mainContainer.AddChild(volumeBox = new VolumeBox()); volumeBox.SetToCell(CellManager.megaVolume); megaBoxes.Add(volumeBox); newPlayerBox.SignalPress += HandleNewPlayerTap; resetBox.SignalPress += HandleResetTap; sortBox.SignalPress += HandleSortTap; volumeBox.SignalPress += HandleVolumeTap; }
public List <SortBox> InitData(ref int nTotal, int maxDatalength, bool ltrsOnly) { var arrData = new List <SortBox>(); var rand = new Random(1); /* to use without the dictionary (using random letters) comment the current line and the new Dictionary line below * * dynamic dict = null; * maxDatalength = 5; * * /*/ // get the dictionary from my OneDrive: // https://onedrive.live.com/redir?resid=D69F3552CEFC21!99083&authkey=!AFjyjUlZpH5sQy0&ithint=file%2cdll // then run the command RegSvr32 dictionary.dll // then add a reference to COM ->Dictionary 1.0 Type Library Dictionary.CDict dict = null; //*/ int colWidth; // we will try to fill the screen with sort data. // However, there are times when a particular # of items is desired, // such as debugging a list of 5 items. // so we limit by nTotal or screen capacity if (maxDatalength == 0) { dict = new Dictionary.CDict(); // comment out this line if no dictionary dict.DictNum = 2; maxDatalength = 11; colWidth = 8 * (maxDatalength - 1); } else { colWidth = 20 + 8 * (maxDatalength - 1); } int nCols = (int)this.ActualWidth / colWidth; if (nCols == 0) //tests { nCols = 80; } for (int i = 0; i < _nRows; i++) { for (int j = 0; j < nCols; j++) { if (arrData.Count < nTotal) { string dat = string.Empty; switch (arrData.Count) { // set the first few items to const so easier to debug algorithms case 0: dat = "zero"; break; case 1: dat = "one"; break; case 2: dat = "two"; break; case 3: dat = "three"; break; case 4: dat = "four"; break; case 5: dat = "five"; break; default: var len = 1 + rand.Next(maxDatalength); var datarray = new char[len]; for (int k = 0; k < len; k++) { // "A" is 65,"!" is 33 datarray[k] = (char)(ltrsOnly == true ? 65 + rand.Next(26) : 33 + rand.Next(90)); } dat = new string(datarray); break; } var box = new SortBox(); if (dict == null) { box.Data = dat.Substring(0, Math.Min(maxDatalength, dat.Length)); } else { box.Data = dict.RandWord(0); } box.Content = box.Data; arrData.Add(box); if (_ShowSort) { Canvas.SetTop(box, 3 + _spControlsHeight + i * 10); Canvas.SetLeft(box, j * colWidth); _canvas.Children.Add(box); } } } } nTotal = arrData.Count; // could be less if (!_ShowSort) { // show initial values for (int i = 0; i < nTotal; i++) { arrData[i].Content = arrData[i].Data; } } SortBox.InitStats(nTotal); return(arrData); }