private void generar(object sender, RoutedEventArgs e) { List<OrdenDeCompra> lstOrdenCompra = new List<OrdenDeCompra>(); lstOrdenCompra = DataObjects.Reportes.ReporteOrdenCompraSQL.BuscarOrdenesCompra(); for (int i = 0; i < lstOrdenCompra.Count;i++ ) { if (lstOrdenCompra[i].Estado == "0") lstOrdenCompra[i].Estado = "CANCELADA"; if (lstOrdenCompra[i].Estado == "1") lstOrdenCompra[i].Estado = "BORRADOR"; if (lstOrdenCompra[i].Estado == "2") lstOrdenCompra[i].Estado = "EMITIDA"; if (lstOrdenCompra[i].Estado == "3") lstOrdenCompra[i].Estado = "ATENDIDA"; for (int j = 0; j < lstProveedor.Count; j++) { if (lstProveedor[j].IdProveedor.ToString() == lstOrdenCompra[i].Proveedor) lstOrdenCompra[i].Proveedor = lstProveedor[j].RazonSocial; } } for (int i = 0; i < lstOrdenCompra.Count; i++) { for (int j = 0; j < ListBoxEstado1.Items.Count; j++) { if (lstOrdenCompra[i].Estado == ListBoxEstado1.Items[j].ToString()) { lstOrdenCompra.RemoveAt(i); i = -1; break; } } } for (int i = 0; i < lstOrdenCompra.Count; i++) { for (int j = 0; j < ListBoxProveedor1.Items.Count; j++) { if (lstOrdenCompra[i].Proveedor == ListBoxProveedor1.Items[j].ToString()) { lstOrdenCompra.RemoveAt(i); i = -1; break; } } } DateTime inicio = Convert.ToDateTime(FechaDesde.Text); DateTime fin = Convert.ToDateTime(FechaHasta.Text); for (int i = 0; i < lstOrdenCompra.Count; i++) { if (Convert.ToDateTime(lstOrdenCompra[i].FechaReg) < inicio || Convert.ToDateTime(lstOrdenCompra[i].FechaReg) > fin) { lstOrdenCompra.RemoveAt(i); i = -1; } } Reportes.reportViewerCompras win = new reportViewerCompras(lstOrdenCompra); win.Show(); }
private void DeleteButton_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure you want to drop the course? This action can't be reverted.", "Confirm Drop", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { XmlWriterSettings xmlWriterSettings = new XmlWriterSettings(); xmlWriterSettings.Indent = true; using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication()) { List<Gradecard> temp = new List<Gradecard>(); if (myIsolatedStorage.FileExists("Gradecards.xml")) { using (IsolatedStorageFileStream stream1 = new IsolatedStorageFileStream("Gradecards.xml", FileMode.Open, FileAccess.Read, myIsolatedStorage)) { XmlSerializer serializer = new XmlSerializer(typeof(List<Gradecard>)); temp = (List<Gradecard>)serializer.Deserialize(stream1); } temp.RemoveAt(index); GlobalVars.UserGc = temp; } using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream("Gradecards.xml", FileMode.Create, myIsolatedStorage)) { XmlSerializer serializer = new XmlSerializer(typeof(List<Gradecard>)); using (XmlWriter xmlWriter = XmlWriter.Create(stream, xmlWriterSettings)) { serializer.Serialize(xmlWriter, GlobalVars.UserGc); } } index = -1; NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); } } }
static int tirer(List<int> w) { int index = r.Next(w.Count); int p = w[index]; w.RemoveAt(index); return p; }
/// <summary> /// Transform collection of inlines /// </summary> public List<Inline> Decorate(IConferenceMessage msg, List<Inline> inlines) { const string pattern = @"((https?|ftp|dchub|magnet|mailto|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)"; for (int i = 0; i < inlines.Count; i++) { // splite one Inline element (text (Run)) into several inlines (Runs and Hyperlinks) var inline = inlines[i] as Run; if (inline == null) continue; var matches = Regex.Matches(inline.Text, pattern).OfType<Match>().Select(item => item.Value).ToArray(); if (matches.Length < 1) continue; inlines.RemoveAt(i); var parts = inline.Text.SplitAndIncludeDelimiters(matches).ToArray(); for (int j = i; j < parts.Length + i; j++) { var part = parts[j]; if (matches.Contains(part)) inlines.Insert(j, DecorateAsHyperlink(part)); else inlines.Insert(j, CommonMessageDecorator.Decorate(msg, part)); } } return inlines; }
public DirectionsResultView(MapWidget mapWidget, FindCloseFacilityResultView fcfResultView, RouteResult routeResult, FindClosestResourceToolbar fcrToolbar) { InitializeComponent(); base.DataContext = this; // Store a reference to the MapWidget that the toolbar has been installed to. _mapWidget = mapWidget; _closestFaculityResult = fcfResultView; _findClosestFacilityToolbar = fcrToolbar; RouteName = routeResult.Directions.RouteName; Summary = string.Format("{0:F1} {1}, {2}", routeResult.Directions.TotalLength, "miles", FormatTime(routeResult.Directions.TotalTime)); List<Graphic> features = new List<Graphic>(routeResult.Directions.Features); features.RemoveAt(0); List<ManeuverViewModel> directionElements = new List<ManeuverViewModel>(); Graphic previous = null; int i = 1; foreach (var next in features) { ManeuverViewModel maneuver = new ManeuverViewModel(previous, next, i++); maneuver.Graphic.MouseLeftButtonDown += Graphic_MouseLeftButtonDown; directionElements.Add(maneuver); previous = next; } Maneuvers = directionElements; }
private void salvaScore_Click(object sender, RoutedEventArgs e) { List<itemRanking> ranking = new List<itemRanking>(); ranking.Capacity = 3; itemRanking itemRanking = new itemRanking(); itemRanking.nomeJogador = campoJogador.Text; itemRanking.pontuacao = this.pontuacao; IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings; if (settings.Contains("ranking")) { ranking = (List<itemRanking>)settings["ranking"]; ranking.Add(itemRanking); Comparison<itemRanking> comparador = new Comparison<itemRanking>(itemRanking.comparaPontuacao); ranking.Sort(comparador); if (ranking.Count > 3) { ranking.RemoveAt(3); } } else { ranking.Add(itemRanking); } settings["ranking"] = ranking; settings.Save(); NavigationService.Navigate(new Uri("/Ranking.xaml", UriKind.Relative)); }
private void Button_Click(object sender, RoutedEventArgs e) { // URL: http://en.wikipedia.org/wiki/Main_Page WebClient w = new WebClient(); string s = w.DownloadString("http://www.rotowire.com/daily/nba/defense-vspos.htm"); //string s = w.DownloadString("http://rotoguru1.com/cgi-bin/hstats.cgi?pos=0&sort=4&game=d&colA=0&daypt=0&xavg=4&show=2&fltr=00"); // 2. List <string> xList = new List <string>(); //string[] result; foreach (LinkItem i in LinkFinder.Find(s)) { //var result = i.ToString().Split(new[] { '\r', '\n' }); //xList = result.ToList<string>(); Debug.WriteLine(i); } for (int i = xList.Count - 1; i >= 0; i--) { if (xList[i].Length > 3) { string input = xList[i].Substring(0, 4); if (Regex.IsMatch(input, @"^\d+$") == true) { //InsertData(xList[i]); } } else { xList.RemoveAt(i); } } }
internal void GotoSummaryItem(int changeNum) { SummaryNode rootNode = DataContext as SummaryNode; if (rootNode != null) { Stack<SummaryNode> changeLocation = rootNode.FindPathToChangeNumber(changeNum); if (changeLocation != null) { SummaryNode snChange = changeLocation.Peek(); Debug.Assert(snChange.SummaryItem.FirstChangeNumber == changeNum || snChange.SummaryItem.LastChangeNumber == changeNum); List<object> locationList = new List<object>(); foreach (SummaryNode sn in changeLocation) { locationList.Insert(0,sn); } locationList.RemoveAt(0); TreeViewItem tvi = theTreeView.ContainerFromItem(locationList); snChange.Selected = true; Debug.Assert(tvi != null); if (tvi != null) { SelectAndShow(tvi); } } } }
private void Button_Click_1(object sender, RoutedEventArgs e) { Tienda tienda = cmbTienda.SelectedItem as Tienda; Cliente cliente = cmbCliente.SelectedItem as Cliente; Servicio servicio = cmbServicio.SelectedItem as Servicio; DateTime ini = Convert.ToDateTime(FechaDesde.Text); DateTime fin = Convert.ToDateTime(FechaHasta.Text); if (servicio.Nombre == "TODOS") { lista = DataObjects.Reportes.reporteServiciosSQL.BuscarServiTodos(tienda.IdTienda, cliente.Id); for (int i = 0; i < lista.Count; i++) { if (Convert.ToDateTime(lista[i].Fecha) < ini || Convert.ToDateTime(lista[i].Fecha) > fin) { lista.RemoveAt(i); i = 0; } } } else { lista = DataObjects.Reportes.reporteServiciosSQL.BuscarServi(tienda.IdTienda, cliente.Id, servicio.IdServicio); for (int i = 0; i < lista.Count; i++) { if (Convert.ToDateTime(lista[i].Fecha) < ini || Convert.ToDateTime(lista[i].Fecha) > fin) { lista.RemoveAt(i); i = 0; } } } Window_Loaded(sender, e); }
// Methods internal static void AddBlocksToSpan(FlowDocument tempFlowDocument, Span newspan) { List<Inline> ic = new List<Inline>(); CollectInlineFromBlocks(tempFlowDocument.Blocks, ic); if ((ic.Count > 0) && (ic[ic.Count - 1] is LineBreak)) { ic.RemoveAt(ic.Count - 1); } newspan.Inlines.AddRange(ic); }
private void AddToSearchHistory(ref List<string> history, string newSearch) { if (history.Contains(newSearch)) history.Remove(newSearch); if (history.Count == 100) history.RemoveAt(99); history.Insert(0, newSearch); }
private void removeItem(ListBox lb, int index) { List<string> lst = new List<string>(); for (int i = 0; i < lb.Items.Count; i++) { lst.Add(lb.Items[i].ToString()); } lst.RemoveAt(index); lb.ItemsSource = lst; }
private void DeleteData() { List<Data> newData = new List<Data>((List<Data>)dataGrid1.ItemsSource); int j = 0; for (int i = 0; i < dataGrid1.Items.Count; ++i) { DataGridRow row = (DataGridRow)dataGrid1.ItemContainerGenerator.ContainerFromIndex(i); if (row.IsSelected) { newData.RemoveAt(i - j); ++j; } } dataGrid1.ItemsSource = newData; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var inlines = new List<Inline>(); if (value != null) { foreach (var line in value.ToString().Split(',')) { inlines.Add(new Run() { Text = line }); inlines.Add(new LineBreak()); } inlines.RemoveAt(inlines.Count - 1); } return inlines; }
private void Button_Click(object sender, RoutedEventArgs e) { // Scrape links from wikipedia.org // 1. // URL: http://en.wikipedia.org/wiki/Main_Page WebClient w = new WebClient(); //string s = w.DownloadString("http://www.basketball-reference.com/leagues/NBA_2015_ratings.html"); string s = w.DownloadString("http://rotoguru1.com/cgi-bin/hstats.cgi?pos=0&sort=4&game=d&colA=0&daypt=0&xavg=4&show=2&fltr=00"); // 2. List <string> xList = new List <string>(); //string[] result; foreach (LinkItem i in LinkFinder.Find(s, "pre")) { var result = i.ToString().Split(new[] { '\r', '\n' }); xList = result.ToList<string>(); Debug.WriteLine(i); } for (int i = xList.Count - 1; i >= 0; i--) { if (xList[i].Length > 3) { string input = xList[i].Substring(0, 4); if (Regex.IsMatch(input, @"^\d+$") == false) { xList.RemoveAt(i); } } else { xList.RemoveAt(i); } } }
private void btnDraw_Click(object sender, RoutedEventArgs e) { try { int rows = Int32.Parse(drawNumber.Text); List<int> randomNumbers = new List<int>(); int count = 0; int max = 1; Random rand = new Random(); switch (theGameBox.SelectedItem.ToString()) { case "Suomi": count = 7; max = 40; break; case "VikingLotto": count = 6; max = 49; break; case "Eurojackpot": count = 5; max = 51; break; } for (int j = 0; j < rows; j++) { for (int i = 1; i < max; i++) { randomNumbers.Add(i); } for (int i = 0; i < count; i++) { int index; //drawnRandomNumbers.Text += rand.Next(1, max).ToString() + " "; index = rand.Next(0, randomNumbers.Count); drawnRandomNumbers.Text += randomNumbers[index].ToString() + " "; randomNumbers.RemoveAt(index); } drawnRandomNumbers.Text += "\n"; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnRemove_Click(object sender, RoutedEventArgs e) { if (list.SelectedItems.Count > 0) { List<DateTime> l = new List<DateTime>(); foreach (DateTime d in list.SelectedItems) { l.Add(d); } while (l.Count > 0) { DateTime date = l[0].Date; if (Days.Contains(date)) { Days.Remove(date); } l.RemoveAt(0); Days = Days; } } }
private void SourceFilters_Helper(bool Checked, bool Reset=false) { if (Reset) { Checked = true; } Character.IsLoading = true; #if SILVERLIGHT List<object> sourceFiltersItems = FilterTree.Items.ToList(); #else List<object> sourceFiltersItems = new List<object>(FilterTree.Items.Cast<object>()); #endif object last = sourceFiltersItems.Last<object>(); sourceFiltersItems.RemoveAt(sourceFiltersItems.Count-1); ItemFilterOther TheOtherOne = last as ItemFilterOther; foreach(ItemFilterRegex c in sourceFiltersItems) { if (c.Enabled != Checked) { c.Enabled = Checked; } if (Reset && c.Name.Contains("Disable")) { c.Enabled = false; } } TheOtherOne.Enabled = Checked; // I think this will cut back substantially on the time to process Reset and other commands Character.IsLoading = false; Character.OnCalculationsInvalidated(); }
private void RemoveInvalidUrls(List<string> loUrlList) { // remove all invalid entries from the list of playback urls if (loUrlList != null) { int i = 0; while (i < loUrlList.Count) { if (String.IsNullOrEmpty(loUrlList[i]) || !UriUtils.IsValidUri(loUrlList[i])) { OnlineVideoSettings.Instance.Logger.Debug("removed invalid url {0}", loUrlList[i]); loUrlList.RemoveAt(i); } else { i++; } } } }
public string[] GetLinks(StringBuilder website) { Regex FindLink = new Regex("href=\"/title/tt[0-9]+/"); List<Match> PossibleLines = new List<Match>(); //For each link found, write it to console and add to lsit foreach (Match M in FindLink.Matches(website.ToString())) { PossibleLines.Add(M); } //Following removes duplicate entries for (int i = 0; i < PossibleLines.Count; i++) { for (int x = 0; x < PossibleLines.Count; x++) { if (x != i) { if (PossibleLines[i].Value == PossibleLines[x].Value) { PossibleLines.RemoveAt(x); } } } } //Reduce list to top 3 string[] Links; if (PossibleLines.Count >= 3) { Links = new string[3]; } else { Links = new string[PossibleLines.Count]; } for (int i = 0; (i < PossibleLines.Count) & (i < 3); i++) { Links[i] = PossibleLines[i].Value; Links[i] = rgxRemoveHref.Match(Links[i]).Value.ToString(); } return Links; }
// Функція самого процесу, яка виконується в іншому потоці private void ThreadTaskProcesing() { byte[] source = File.ReadAllBytes(fileDialog.FileName); switch (choice) { case "Encoder": { int offset = 0; ArchivingLibrary.BWT.Encoder(ref source, ref offset); List<byte> tmpSource = new List<byte>(source); // Запис індексу оригінального рядку. byte[] tmpOffset = BitConverter.GetBytes((ushort)offset); tmpSource.AddRange(tmpOffset); source = tmpSource.ToArray(); } break; case "Decoder": { #region Зчитування і видалення індексу оригінального рядку int size = source.Length; List<byte> tmpSource = new List<byte>(source); int offset = (int)BitConverter.ToUInt16(tmpSource.ToArray(), (size - 2)); tmpSource.RemoveAt(size - 2); tmpSource.RemoveAt(size - 2); source = tmpSource.ToArray(); #endregion ArchivingLibrary.BWT.Decoder(ref source, offset); } break; case "Compress": { ArchivingLibrary.BWT.Compress(ref source); } break; case "Decompress": { ArchivingLibrary.BWT.Decompress(ref source); } break; } File.WriteAllBytes(FolderSave + "/" + choice, source); trdProcess.Abort(); }
private static List<Skeleton> RemoveFrames(List<Skeleton> skels, int nFrames) { int diff = skels.Count - nFrames; List<Skeleton> result = new List<Skeleton>(); List<double> dists = new List<double>(); for (int i = 0; i < skels.Count - 1; i++) { dists.Add(GetDistBetweenFrames(skels.ElementAt(i), skels.ElementAt(i + 1))); } List<int> ignore = new List<int>(); int j = 0; while (j < diff) { double min = dists.Min(); int index = dists.IndexOf(min); if (index < skels.Count - 3) { ignore.Add(index); j++; } dists.RemoveAt(index); } for (int i = 0; i < skels.Count; i++) { if (ignore.Contains(i)) { continue; } result.Add(skels.ElementAt(i)); } return AlignFrames(result, nFrames); }
private void BtSearch_Click(object sender, System.Windows.RoutedEventArgs e) { string search = "http://www.imdb.com/find?s=all&q="; //Basic Search Link string temp = TxBoxSearchTerm.Text; //Take search term temp = temp.Replace(" ", "+"); //Remove spaces, replace with '+' search += temp; //Add to end of Base Search Link StringBuilder BaseSearch = GetHtml(search); //Get Basic Search Website string[] links; links = GetLinks(BaseSearch); //Take top 3 links of search page (3 most popular / mentioned) Films = new Film[links.Length]; StringBuilder[] filmsites = new StringBuilder[3]; Parallel.For(0, Films.Length, i => //For each link (each different movie) { filmsites[i] = GetHtml("http://www.imdb.com" + links[i]); //First get the HTML of the film page "filmsite" is now a string of entire website //Use GrabImage function to download picture Films[i] = new Film(); Films[i].Name = rgxFindFilmName.Match(filmsites[i].ToString()).Groups[1].Value; //Find the name of the film in the HTML Films[i].Rating = rgxFindRating.Match(filmsites[i].ToString()).Groups[1].Value; //Find the rating of the film in the HTML if ((rgxFindDate.Match(filmsites[i].ToString()).Groups[1].Value) == string.Empty) { Films[i].ReleaseYear = 1000; } else { Films[i].ReleaseYear = Convert.ToInt32(rgxFindDate.Match(filmsites[i].ToString()).Groups[1].Value); //Find the release year of the film in the HTML } List<string> lsGenres = new List<string>(); //Create a list of genres foreach (Match m in rgxFindGenres.Matches(filmsites[i].ToString())) { lsGenres.Add(m.Groups[1].Value); //Foreach genre found add it to the list } for (int inte = 0; inte < lsGenres.Count; inte++) //For each value item of list { for (int x = 0; x < lsGenres.Count; x++) //For each item of list { if (inte != x) //If the items are not the same index { if (lsGenres[inte] == lsGenres[x]) //If they have equal value, but not equal index { lsGenres.RemoveAt(x); //Remove copy } } } } StringBuilder sbGenres = new StringBuilder(); foreach (string s in lsGenres) { sbGenres.Append(s + " "); } Films[i].Genres = sbGenres.ToString(); Films[i].Plot = rgxFindStoryline.Match(filmsites[i].ToString()).Groups[1].Value; } ); //Fill In Details for (int i = 0; i < Films.Length; i++) { LbNames[i].Content = "Name: " + Films[i].Name; LbRatings[i].Content = "Rating: " + Films[i].Rating; LbReleases[i].Content = "Release: " + Films[i].ReleaseYear; Films[i].Image = new BitmapImage(); Films[i].Image.BeginInit(); } Stream[] ms = new Stream[Films.Length]; Parallel.For(0, Films.Length, i => { string ImageURL = rgxGrabPicture.Match(filmsites[i].ToString()).Groups[1].Value; if (string.IsNullOrEmpty(ImageURL)) { ms[i] = null; } else { WebClient wc = new WebClient(); byte[] pic = wc.DownloadData(ImageURL); ms[i] = new MemoryStream(pic); } } ); for (int i = 0; i < Films.Length; i++) { if (ms[i] == null) { Films[i].Image.UriSource = noimage.UriSource; } else { Films[i].Image.StreamSource = ms[i]; } Films[i].Image.EndInit(); MovImages[i].Source = Films[i].Image; } }
public static List<Skeleton> GetStartCorrectedFrames(List<Skeleton> test, List<Skeleton> action) { test = KinectFrameUtils.AlignFrames(test, action.Count); double dist = GetTotalDistTraveled(action); int frameStart = -1; int rawStart = -1; for (int i = 0; i < action.Count; i++) { if (KinectFrameUtils.GetTotalDistTraveled(action.GetRange(0, i)) > (dist / 5) && frameStart < 0) { frameStart = i; } if (KinectFrameUtils.GetTotalDistTraveled(test.GetRange(0, i)) > (dist / 5) && rawStart < 0) { rawStart = i; } } int diff = frameStart - rawStart; if (diff > 0) { for (int i = 0; i < diff; i++) { test = AlignFrames(test, test.Count - 1); test.Insert(0, test[0]); } } else { for (int i = 0; i < -diff; i++) { test.RemoveAt(0); test.Add(test[test.Count - 1]); } } return test; }
private static List<Skeleton> InterpolateFrames(List<Skeleton> skels, int nFrames) { int diff = nFrames - skels.Count; List<Skeleton> result = skels; List<double> dists = new List<double>(); for (int i = 0; i < skels.Count - 1; i++) { dists.Add(GetDistBetweenFrames(skels.ElementAt(i), skels.ElementAt(i + 1))); } for (int i = 0; i < diff; i++) { if (dists.Count == 0) { break; } double max = dists.Min(); int index = dists.IndexOf(max); Skeleton insert = GetMidFrame(skels.ElementAt(index), skels.ElementAt(index + 1)); result.Insert(index, insert); dists.RemoveAt(index); } return AlignFrames(result, nFrames); }
private async Task<bool> ConnectToFirstWorking(List<IPEndPoint> endpoints) { bool connected = false; while (!connected && endpoints.Count > 0) { IPEndPoint endpoint = null; try { endpoint = endpoints.Last(); _mainChannel = await _node.ConnectToServer(endpoint); connected = true; } catch (Exception) { endpoints.RemoveAt(endpoints.Count - 1); MessageBox.Show("Can't connect to " + endpoint); } } return connected; }
public List<ToolbarItem> GetToolBarItems() { if (FormType == FormTypes.New) { ToolbarItems = Utility.CreateFormSaveButton(); } else if (FormType == FormTypes.Edit) { ToolbarItems = Utility.CreateFormEditButton(); if (Department != null) { if (Department.CHECKSTATE == "0") { ToolbarItems.Add(ToolBarItems.Delete); } } } else if (FormType == FormTypes.Browse) { ToolbarItems = new List<ToolbarItem>(); } else if (FormType == FormTypes.Resubmit) { ToolbarItems = Utility.CreateFormEditButton(); ToolbarItems.RemoveAt(0); ToolbarItems.RemoveAt(0); } else { ToolbarItems = Utility.CreateFormEditButton("T_HR_DEPARTMENT", Department.OWNERID, Department.OWNERPOSTID, Department.OWNERDEPARTMENTID, Department.OWNERCOMPANYID); } return ToolbarItems; }
private void _FillTables(List<FixedSOMTableRow> tableRows) { List<FixedSOMTable> tables = new List<FixedSOMTable>(); foreach (FixedSOMTableRow row in tableRows) { FixedSOMTable table = null; double fudge = 0.01; foreach (FixedSOMTable t in tables) { if (Math.Abs(t.BoundingRect.Left - row.BoundingRect.Left) < fudge && Math.Abs(t.BoundingRect.Right - row.BoundingRect.Right) < fudge && Math.Abs(t.BoundingRect.Bottom - row.BoundingRect.Top) < fudge) { table = t; break; } } if (table == null) { table = new FixedSOMTable(_fixedSOMPage); tables.Add(table); } table.AddRow(row); } //Check for nested tables first for (int i=0; i<tables.Count-1; i++) { for (int j=i+1; j<tables.Count; j++) { if (tables[i].BoundingRect.Contains(tables[j].BoundingRect) && tables[i].AddContainer(tables[j])) { tables.RemoveAt(j--); } else if (tables[j].BoundingRect.Contains(tables[i].BoundingRect) && tables[j].AddContainer(tables[i])) { tables.RemoveAt(i--); if (i < 0) { break; } } } } foreach (FixedSOMTable table in tables) { if (table.IsSingleCelled) { continue; } bool containsAnything = false; for (int i = 0; i < _fixedSOMPage.SemanticBoxes.Count;) { //Only FixedBlocks are added to tables at this stage if (_fixedSOMPage.SemanticBoxes[i] is FixedSOMFixedBlock && table.AddContainer(_fixedSOMPage.SemanticBoxes[i] as FixedSOMContainer)) { _fixedSOMPage.SemanticBoxes.RemoveAt(i); containsAnything = true; } else { i++; } } if (containsAnything) { table.DeleteEmptyRows(); table.DeleteEmptyColumns(); //Remove any internal empty tables //Do grouping and sorting inside cells foreach (FixedSOMTableRow row in table.SemanticBoxes) { foreach (FixedSOMTableCell cell in row.SemanticBoxes) { for (int i=0; i<cell.SemanticBoxes.Count;) { FixedSOMTable innerTable = cell.SemanticBoxes[i] as FixedSOMTable; if (innerTable != null && innerTable.IsEmpty) { cell.SemanticBoxes.Remove(innerTable); } else { i++; } } _CreateGroups(cell); cell.SemanticBoxes.Sort(); } } _fixedSOMPage.AddTable(table); } } }
private List<string> GetListGroupString(string groupListStr) { string[] splits = groupListStr.Split(GroupDB.SEPARATE_TOKEN); List<string> listGroupSplits = new List<string>(); foreach (string str in splits) { string group = str.TrimStart().TrimEnd(); if (group.Length > 0) { listGroupSplits.Add(group); } } int len = listGroupSplits.Count(); for (int i = 0; i < len - 1; i++) { for (int j = i + 1; j < len;) { if (String.Compare(listGroupSplits[i].ToLower(), listGroupSplits[j].ToLower()) == 0) { listGroupSplits.RemoveAt(j); len--; } else { j++; } } } return listGroupSplits; }
public void StartTurn(ref List<Tile> tiles, MainPage page) { mode = Mode.PlaceTile; // Deal the tile and remove it from the deck activeTile = tiles[0]; tiles.RemoveAt(0); // Add the tile to the game surface page.gameSurface.Children.Add(activeTile); Canvas.SetLeft(activeTile.rect, 10); Canvas.SetTop(activeTile.rect, 10); }