public EditDrinksPage() { InitializeComponent(); DataContext = App.ViewModel; Drink TapToAdd = new Drink() { Name = "Tap to add a drink", Size = 0, mg = 0, drinkId = 1, IsActive = false }; Drink AddedDrinks = new Drink() { Name = "------ Added Drinks ------", Size = 0, mg = 0 }; var drinkList = new List<Drink>(App.ViewModel.drinkList); int i; for (i = 0; i < drinkList.Count; i++) { if ((drinkList[i] as Drink).Name == "Tap to add a drink") { var drink = (drinkList[i] as Drink); if (drinkList.Contains(drink)) drinkList.Remove(drink); } else if ((drinkList[i] as Drink).Name == "------ Added Drinks ------") { var drink = (drinkList[i] as Drink); if (drinkList.Contains(drink)) drinkList.Remove(drink); } } drinkList.Remove(TapToAdd); if (drinkList.Contains(AddedDrinks)) drinkList.Remove(AddedDrinks); drinksListBox.ItemsSource = drinkList; }
public TreatmentForm() { InitializeComponent(); db = DentalSmileDBFactory.GetInstance(); phases = Smile.Phases = db.SelectAllPhases(); //phases = Smile.GetPhases(); phases.Remove(Smile.GetPhase(Smile.SCANNING)); phases.Remove(Smile.GetPhase(Smile.MANIPULATION)); phaseCombo.ItemsSource = phases; roomTextBox.Text = Smile.Room; }
// takes list of participants sorted by place in age division, returns top 3..ish List<AgeChampion> CalcAgeChampions(List<AgeChampion> champions, List<Participant> participants, int place = 1) { Participant p = participants.First(); participants.Remove(p); // no points scored, cannot be a champion if (ParticipantPoints(p) == 0) return champions; champions.Add(new AgeChampion(p, place, ParticipantPoints(p))); // no more possible champions if (participants.Count == 0) return champions; // if the same number of points, equal age champion w/ same place if (champions.Last().Points == ParticipantPoints(participants.First())) CalcAgeChampions(champions, participants, place); // room for more champions else if (champions.Count < 3) CalcAgeChampions(champions, participants, place + 1); return champions; }
void CollectionOperation() { List<string> lists = new List<string>(); for (int i = 0; i < 100; i++) { lists.Add("string" + i); } try { //foreach (string str in lists) //{ // if (str.Contains("0")) // lists.Remove(str); //} for (int i = 0; i < lists.Count; i++) { if (lists[i].Contains("0")) lists.Remove(lists[i]); } Tbox.Text= lists.Count.ToString(); } catch (Exception ex) { Tbox.Text = ex.ToString(); } }
//******************* //* BLACKLIST CTRL * //******************* List<string> BlackListCtrl(List<string> orgCtrl) { List<string> edCtrl = new List<string>(orgCtrl); //search whole element int skipTwo = 2; foreach (string line in orgCtrl) { //skip two times till after the 1st { if (skipTwo > 0 || line.Equals("}")) { skipTwo--; continue; } bool removeLine = false; //bool ourObj = false; foreach (string keyWord in keyWords_org_list) { if (line.Contains(keyWord)) { removeLine = true; //ourObj = true; break; } } if (removeLine) edCtrl.Remove(line); //if (ourObj) //FoundCtrl = true; } return edCtrl; }
public ComponentFilterFileLoader() { List<string> modCompTypes = new List<string>(EngineManagerViewModel.instance.ComponentTypes); using (XmlReader reader = XmlReader.Create("Assets/Config/ComponentFilters.xml")) { while (reader.ReadToFollowing("Filter")) { reader.MoveToAttribute("name"); string filter_type = reader.Value; raw_filter.Add(new SubFilterList() {header = filter_type}); do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { string comp_types = reader.ReadElementContentAsString(); modCompTypes.Remove(comp_types); raw_filter.Last().sub_list.Add(comp_types); } } while (reader.Name != "Filter"); } raw_filter.Last().sub_list.AddRange(modCompTypes); } }
public IEnumerable<string> ConvertTagsToHtml(string[] lines) { var tables = new Dictionary<string, List<string>>(); var lastLine = ""; var tableCount = 0; var list = new List<string>(); foreach (var line in lines) { if (line.StartsWith("<F>") && line.Length > 3) list.Add(string.Format("<span>{0}</span>", line[3].ToString().PadLeft(lines.Max(x => x.Length), line[3]))); if (line.StartsWith("<T>")) list.Add(string.Format("<B>{0}</B>", RemoveTag(line))); if (line.StartsWith("<C") && line.Length > 3 && (line[2] == '>' || char.IsDigit(line[2]))) list.Add(string.Format("<span>{0}</span>", RemoveTag(line))); if (line.StartsWith("<L") && line.Length > 3 && (line[2] == '>' || char.IsDigit(line[2]))) list.Add(string.Format("<span>{0}</span>", RemoveTag(line))); if (line.StartsWith("<EB>")) list.Add("<B>"); if (line.StartsWith("<DB>")) list.Add("</B>"); if (line.StartsWith("<J") && line.Length > 3 && (line[2] == '>' || char.IsDigit(line[2]))) { if (!lastLine.StartsWith("<J")) { tableCount++; list.Add("tbl" + tableCount); } var tableName = "tbl" + tableCount; if (!tables.ContainsKey(tableName)) tables.Add(tableName, new List<string>()); tables[tableName].Add(RemoveTag(line)); } if (!line.Contains("<") && !string.IsNullOrEmpty(line.Trim())) list.Add(line); lastLine = line; } foreach (var table in tables) { list.InsertRange(list.IndexOf(table.Key), GetTableLines(table.Value, Printer.CharsPerLine)); list.Remove(table.Key); } for (int i = 0; i < list.Count; i++) { list[i] = list[i].TrimEnd(); if ((!list[i].ToLower().EndsWith("<BR>") && RemoveTag(list[i]).Trim().Length > 0) || list[i].Trim().Length == 0) list[i] += "<BR>"; list[i] = list[i].Replace(" ", " "); } return list; }
internal void SetComponentLinks(IEnumerable<AbstractEndpoint.IAbstractComponentLink> componentLinks) { var links = new List<ComponentsOrderingViewModel>(); var setOrder = new Action(() => { var worker = new BackgroundWorker(); worker.DoWork += (e, s) => { foreach (var cl in links.AsEnumerable().Reverse()) { cl.Link.Order = links.IndexOf(cl) + 1; } }; worker.RunWorkerAsync(); }); foreach (var cl in componentLinks.OrderBy(x => x.Order)) { var vm = new ComponentsOrderingViewModel { Link = cl }; links.Add(vm); vm.UpCommand = new RelayCommand( () => { var prevIndex = links.IndexOf(vm); links.Remove(vm); links.Insert(prevIndex - 1, vm); this.ComponentList.ItemsSource = null; this.ComponentList.ItemsSource = links; this.ComponentList.SelectedItem = vm; setOrder(); }, () => links.IndexOf(vm) > 0); vm.DownCommand = new RelayCommand( () => { var prevIndex = links.IndexOf(vm); links.Remove(vm); links.Insert(prevIndex + 1, vm); this.ComponentList.ItemsSource = null; this.ComponentList.ItemsSource = links; this.ComponentList.SelectedItem = vm; setOrder(); }, () => links.IndexOf(vm) < links.Count - 1); } this.ComponentList.ItemsSource = links; }
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); }
public MainWindow() { //hardcoded vJoyFeeder class for testing, is this where we want to call the class? vJoyFeeder vj = new vJoyFeeder(); InitializeComponent(); //var server = new WebSocketServer("http://localhost:8080"); //server.Start(socket => //{ // socket.OnOpen = () => Console.WriteLine("Open!"); // socket.OnClose = () => Console.WriteLine("Close!"); // //socket.OnMessage = message => socket.Send(message); //}); FleckLog.Level = LogLevel.Debug; var allSockets = new List<IWebSocketConnection>(); var server = new WebSocketServer("localhost:8181"); server.Start(socket => { socket.OnOpen = () => { Console.WriteLine("Open!"); allSockets.Add(socket); }; socket.OnClose = () => { Console.WriteLine("Close!"); allSockets.Remove(socket); }; socket.OnMessage = message => { // This is the only line of code that outputs to console. Each instruction given to parser will return a string, which // can then be used in the windows APP UI. //Console.WriteLine(vj.parseInstructionString(message)); allSockets.ToList().ForEach(s => s.Send("Echo: " + message)); allSockets.ToList().ForEach(s => s.Send("Return: " + vj.parseInstructionString(message))); }; }); var input = Console.ReadLine(); while (input != "exit") { foreach (var socket in allSockets.ToList()) { socket.Send(input); } input = Console.ReadLine(); } }
static ColorPicker() { colorsList = new List<ColorNamePair>(); Type t = typeof(Colors); PropertyInfo[] properties = t.GetProperties(); foreach (PropertyInfo property in properties) { ColorNamePair c = new ColorNamePair(property.Name, (Color)property.GetValue(null, null)); colorsList.Add(c); } ColorNamePair transparent = colorsList.Find(c => c.Name == "Transparent"); colorsList.Remove(transparent); }
public void SetNonOverflowButton(ToolboxButton button) { ToolboxButton currentNonOverflowButton = this.Children.OfType<ToolboxButton>().First(); if (currentNonOverflowButton != button) { List<ToolboxButton> allButtons = new List<ToolboxButton>(); allButtons.Add(currentNonOverflowButton); foreach (ToolboxButton item in Overflow.Items) allButtons.Add(item); allButtons.Remove(button); allButtons.Sort(delegate(ToolboxButton one, ToolboxButton two) { return one.DisplayIndex.CompareTo(two.DisplayIndex); }); Overflow.Items.Clear(); allButtons.ForEach(delegate(ToolboxButton item) { Overflow.Items.Add(item); }); } }
private void tbxParticipant_TextChanged(object sender, TextChangedEventArgs e) { TextBox textBox = (TextBox)sender; List<char> lettersList = textBox.Text.ToList(); List<char> checkedList = new List<Char>(lettersList); foreach (char letter in lettersList) { if (!Char.IsLetter(letter)) { checkedList.Remove(letter); } } textBox.Text = new string(checkedList.ToArray()); }
static int GetEyeIndex(IEnumerable<Dot> dots) { List<int> indices = new List<int>() { 1, 2, 3 }; foreach (Dot d in dots) { int index = (int)d.Tag; if (indices.Contains(index)) indices.Remove(index); } if (indices.Count != 1) { LogEvent.Engine.Write("Error: indices exclusion failed"); return -1; } return indices[0]; }
public IEnumerable<Edge> GroupToEdges(List<Point> points) { List<Edge> edges = new List<Edge>(); while (points.Any()) { creatingTime.Start(); var point = points.First(); points.Remove(point); var edge = new Edge(point); creatingTime.Stop(); edges.Add(GrowEdge(edge, points)); } return edges; }
public void load() { listBox1.Items.Clear(); textBlock1.Text = attrId; //Load Process data List<string> ppId = new List<string>(); foreach (var o in Factory.Instance.getAllPostProcessObj()) { string _id = (string)o.GetType().GetProperty("id").GetValue(o, null); string type = (string)o.GetType().Name; string val = _id + " (" + type + ")"; ppId.Add(val); } if (this.rule != null) { if (this.rule.postProcessTriggerGroup != null) { var gr = (from x in this.rule.postProcessTriggerGroup where x.id == this.attrId select x).FirstOrDefault(); if (gr != null) { if (gr.postProcessTrigger != null) { foreach (var pp in gr.postProcessTrigger) { listBox1.Items.Add(pp.id + " (" + pp.type.ToString() + ")"); string val = pp.id + " (" + pp.type.ToString() + ")"; ppId.Remove(val); } } } } } cmbPp.Items.Clear(); foreach (string p in ppId) cmbPp.Items.Add(p); }
public Bannissement() { CultureManager.UICultureChanged += CultureManager_UICultureChanged; InitializeComponent(); // Header de la fenetre App.Current.MainWindow.Title = Nutritia.UI.Ressources.Localisation.FenetreBannissement.Titre; LstMembre = new ObservableCollection<Membre>(); LstBanni = new ObservableCollection<Membre>(); TousLesMembres = new List<Membre>(ServiceFactory.Instance.GetService<IMembreService>().RetrieveAll()); TousLesMembres.Remove(TousLesMembres.First(membre => membre.IdMembre == App.MembreCourant.IdMembre)); RemplirListe(); //SearchBox dgRecherche.DataGridCollection = CollectionViewSource.GetDefaultView(LstMembre); dgRecherche.DataGridCollection.Filter = new Predicate<object>(Filter); }
public void runFleck() { FleckLog.Level = LogLevel.Debug; var allSockets = new List<IWebSocketConnection>(); var server = new WebSocketServer("localhost:8181"); server.Start(socket => { socket.OnOpen = () => { Console.WriteLine("Open!"); allSockets.Add(socket); }; socket.OnClose = () => { Console.WriteLine("Close!"); allSockets.Remove(socket); }; socket.OnMessage = message => { // This is the only line of code that outputs to console. Each instruction given to parser will return a string, which // can then be used in the windows APP UI. //Console.WriteLine(vj.parseInstructionString(message)); allSockets.ToList().ForEach(s => s.Send("Echo: " + message)); allSockets.ToList().ForEach(s => s.Send("Return: " + vj.parseInstructionString(message))); }; }); var input = Console.ReadLine(); while (input != "exit") { foreach (var socket in allSockets.ToList()) { socket.Send(input); } input = Console.ReadLine(); } }
/// <summary> /// Dequeue the first record /// </summary> public static RequestRecord DequeueRequestRecord() { List<RequestRecord> requests = new List<RequestRecord>(); DataContractJsonSerializer dc = new DataContractJsonSerializer(requests.GetType()); using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication()) { lock (fileLock) { using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(@"RequestRecords.xml", FileMode.Open, file)) { try { // if the file opens, read the contents requests = dc.ReadObject(stream) as List<RequestRecord>; if (requests.Count > 0) { RequestRecord record = requests[0]; requests.Remove(record); // remove the first entry stream.SetLength(0); stream.Position = 0; dc.WriteObject(stream, requests); record.DeserializeBody(); return record; } else return null; } catch (Exception) { stream.Position = 0; string s = new StreamReader(stream).ReadToEnd(); return null; } } } } }
public Node aStarSearch(List<Node> parentNode) { //exploredSet = new List<Node>(); allNodesList.Clear(); clearExploredSet(); while (true) { if (isGoalState(parentNode[0].state)) { return parentNode[0]; } else if (parentNode[0].state != null) { List<Node> temp = parentNode[0].generateChildNodes(); exploredSet[parentNode[0].hValue].Add(parentNode[0]); foreach (Node n in temp) { allNodesList.Add(n); if (!(isItInSet(n, exploredSet[n.hValue]))) { parentNode.Add(n); nodeCount++; } } parentNode.Remove(parentNode[0]); parentNode.Sort(CustomCompare); Console.Write("\r{0}", parentNode.Count); } } //return null; }
private void Init() { currentNumber = 0; GameOverGrid.Visibility = System.Windows.Visibility.Collapsed; ContentPanel.Visibility = System.Windows.Visibility.Visible; AboutGrid.Visibility = System.Windows.Visibility.Collapsed; List<int> lst = new List<int>(); for (int i = 0; i < 25; i++) { lst.Add(i + 1); } foreach (Button btn in Schulte_Grid.Children) { ControlTemplate ct = btn.Template; btn.Template = null; btn.Template = ct; int index = lst[ran.Next(lst.Count)]; string str = index.ToString(); btn.Content = str; lst.Remove(index); } dt = DateTime.Now; timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(10); timer.Tick += new EventHandler(timer_Tick); timer.Start(); }
public DeleteDataWindow() { InitializeComponent(); _controller = PAZController.GetInstance(); _users = _controller.UserMapper.FindAll(); _deleteList = new List<object>(); List<User> _admins = new List<User>(); foreach (User user in _users) { if (user.User_type == "admin") _admins.Add(user); } // Dit moet wel zo, omdat de admins niet direct in de users list kunnen worden verwijderd tijdens een loop foreach (User admin in _admins) _users.Remove(admin); _users.Sort(); PersonenToevoegen(); }
/// <summary> /// Handles the filling of the gadget's combo boxes /// </summary> private void FillComboboxes(bool update = false) { LoadingCombos = true; string prevField = string.Empty; string prevWeightField = string.Empty; string prevStrataField = string.Empty; if (lbxColumns.Items.Count == 0) { lbxColumns.Items.Add("Frequency"); lbxColumns.Items.Add("Percent"); lbxColumns.Items.Add("Cumulative Percent"); lbxColumns.Items.Add("95% CI Lower"); lbxColumns.Items.Add("95% CI Upper"); lbxColumns.Items.Add("Percent bars"); lbxColumns.SelectAll(); } if (update) { if (cbxField.SelectedIndex >= 0) { prevField = cbxField.SelectedItem.ToString(); } if (cbxFieldWeight.SelectedIndex >= 0) { prevWeightField = cbxFieldWeight.SelectedItem.ToString(); } if (cbxFieldStrata.SelectedIndex >= 0) { prevStrataField = cbxFieldStrata.SelectedItem.ToString(); } } cbxField.ItemsSource = null; cbxField.Items.Clear(); cbxFieldWeight.ItemsSource = null; cbxFieldWeight.Items.Clear(); cbxFieldStrata.ItemsSource = null; cbxFieldStrata.Items.Clear(); List<string> fieldNames = new List<string>(); List<string> weightFieldNames = new List<string>(); List<string> strataFieldNames = new List<string>(); weightFieldNames.Add(string.Empty); strataFieldNames.Add(string.Empty); ColumnDataType columnDataType = ColumnDataType.Boolean | ColumnDataType.DateTime | ColumnDataType.Numeric | ColumnDataType.Text | ColumnDataType.UserDefined | ColumnDataType.UserDefined; fieldNames = dashboardHelper.GetFieldsAsList(columnDataType); columnDataType = ColumnDataType.Numeric | ColumnDataType.UserDefined; weightFieldNames.AddRange(dashboardHelper.GetFieldsAsList(columnDataType)); columnDataType = ColumnDataType.Numeric | ColumnDataType.Boolean | ColumnDataType.Text | ColumnDataType.UserDefined; strataFieldNames.AddRange(dashboardHelper.GetFieldsAsList(columnDataType)); fieldNames.Sort(); weightFieldNames.Sort(); strataFieldNames.Sort(); if (fieldNames.Contains("SYSTEMDATE")) { fieldNames.Remove("SYSTEMDATE"); } if (DashboardHelper.IsUsingEpiProject) { if (fieldNames.Contains("RecStatus")) fieldNames.Remove("RecStatus"); if (weightFieldNames.Contains("RecStatus")) weightFieldNames.Remove("RecStatus"); if (strataFieldNames.Contains("RecStatus")) strataFieldNames.Remove("RecStatus"); if (strataFieldNames.Contains("FKEY")) strataFieldNames.Remove("FKEY"); if (strataFieldNames.Contains("GlobalRecordId")) strataFieldNames.Remove("GlobalRecordId"); } cbxField.ItemsSource = fieldNames; cbxFieldWeight.ItemsSource = weightFieldNames; cbxFieldStrata.ItemsSource = strataFieldNames; if (cbxField.Items.Count > 0) { cbxField.SelectedIndex = -1; } if (cbxFieldWeight.Items.Count > 0) { cbxFieldWeight.SelectedIndex = -1; } if (cbxFieldStrata.Items.Count > 0) { cbxFieldStrata.SelectedIndex = -1; } if (update) { cbxField.SelectedItem = prevField; cbxFieldWeight.SelectedItem = prevWeightField; cbxFieldStrata.SelectedItem = prevStrataField; } LoadingCombos = false; }
/// <summary> /// Main logic behind Champion Select /// </summary> /// <param name="sender"></param> /// <param name="message"></param> private void ChampSelect_OnMessageReceived(object sender, object message) { if (message.GetType() == typeof(GameDTO)) { #region In Champion Select GameDTO ChampDTO = message as GameDTO; LatestDto = ChampDTO; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async () => { //Allow all champions to be selected (reset our modifications) ListViewItem[] ChampionArray = new ListViewItem[ChampionSelectListView.Items.Count]; ChampionSelectListView.Items.CopyTo(ChampionArray, 0); foreach (ListViewItem y in ChampionArray) { y.IsHitTestVisible = true; y.Opacity = 1; } //Push all teams into one array to save a foreach call (looks messy) List<Participant> AllParticipants = new List<Participant>(ChampDTO.TeamOne.ToArray()); AllParticipants.AddRange(ChampDTO.TeamTwo); foreach (Participant p in AllParticipants) { if (p is PlayerParticipant) { PlayerParticipant play = (PlayerParticipant)p; //If it is our turn to pick if (play.PickTurn == ChampDTO.PickTurn) { if (play.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId) { ChampionSelectListView.IsHitTestVisible = true; ChampionSelectListView.Opacity = 1; GameStatusLabel.Content = "Your turn to pick!"; break; } } } //Otherwise block selection of champions unless in dev mode if (!DevMode) { ChampionSelectListView.IsHitTestVisible = false; ChampionSelectListView.Opacity = 0.5; } GameStatusLabel.Content = "Waiting for others to pick..."; } //Champion select was cancelled if (ChampDTO.GameState == "TEAM_SELECT") { if (CountdownTimer != null) { CountdownTimer.Stop(); } Client.FixChampSelect(); FakePage fakePage = new FakePage(); fakePage.Content = Client.LastPageContent; Client.SwitchPage(fakePage); return; } else if (ChampDTO.GameState == "PRE_CHAMP_SELECT") { //Banning phase. Enable banning phase and this will render only champions for ban BanningPhase = true; PurpleBansLabel.Visibility = Visibility.Visible; BlueBansLabel.Visibility = Visibility.Visible; BlueBanListView.Visibility = Visibility.Visible; PurpleBanListView.Visibility = Visibility.Visible; GameStatusLabel.Content = "Bans are on-going"; counter = configType.BanTimerDuration - 3; #region Render Bans BlueBanListView.Items.Clear(); PurpleBanListView.Items.Clear(); foreach (var x in ChampDTO.BannedChampions) { Image champImage = new Image(); champImage.Height = 58; champImage.Width = 58; champImage.Source = champions.GetChampion(x.ChampionId).icon; if (x.TeamId == 100) { BlueBanListView.Items.Add(champImage); } else { PurpleBanListView.Items.Add(champImage); } foreach (ListViewItem y in ChampionArray) { if ((int)y.Tag == x.ChampionId) { ChampionSelectListView.Items.Remove(y); //Remove from arrays foreach (ChampionDTO PlayerChamps in ChampList.ToArray()) { if (x.ChampionId == PlayerChamps.ChampionId) { ChampList.Remove(PlayerChamps); break; } } foreach (ChampionBanInfoDTO BanChamps in ChampionsForBan.ToArray()) { if (x.ChampionId == BanChamps.ChampionId) { ChampionsForBan.Remove(BanChamps); break; } } } } } #endregion Render Bans } else if (ChampDTO.GameState == "CHAMP_SELECT") { //Picking has started. If pickturn has changed reset timer LastPickTurn = ChampDTO.PickTurn; BanningPhase = false; } else if (ChampDTO.GameState == "POST_CHAMP_SELECT") { //Post game has started. Allow trading CanTradeWith = await Client.PVPNet.GetPotentialTraders(); HasLockedIn = true; GameStatusLabel.Content = "All players have picked!"; if (configType != null) counter = configType.PostPickTimerDuration - 2; else counter = 10; } else if (ChampDTO.GameState == "START_REQUESTED") { GameStatusLabel.Content = "The game is about to start!"; DodgeButton.IsEnabled = false; //Cannot dodge past this point! counter = 1; } #region Display players BlueListView.Items.Clear(); PurpleListView.Items.Clear(); int i = 0; bool PurpleSide = false; //Aram hack, view other players champions & names (thanks to Andrew) List<PlayerChampionSelectionDTO> OtherPlayers = new List<PlayerChampionSelectionDTO>(ChampDTO.PlayerChampionSelections.ToArray()); bool AreWePurpleSide = false; foreach (Participant participant in AllParticipants) { Participant tempParticipant = participant; i++; ChampSelectPlayer control = new ChampSelectPlayer(); //Cast AramPlayers as PlayerParticipants. This removes reroll data if (tempParticipant is AramPlayerParticipant) { tempParticipant = new PlayerParticipant(tempParticipant.GetBaseTypedObject()); } if (tempParticipant is PlayerParticipant) { PlayerParticipant player = tempParticipant as PlayerParticipant; control.PlayerName.Content = player.SummonerName; foreach (PlayerChampionSelectionDTO selection in ChampDTO.PlayerChampionSelections) { #region Disable picking selected champs foreach (ListViewItem y in ChampionArray) { if ((int)y.Tag == selection.ChampionId) { y.IsHitTestVisible = false; y.Opacity = 0.5; if (configType != null) { if (configType.DuplicatePick) { y.IsHitTestVisible = true; y.Opacity = 1; } } } } #endregion Disable picking selected champs if (selection.SummonerInternalName == player.SummonerInternalName) { //Clear our teams champion selection for aram hack OtherPlayers.Remove(selection); control = RenderPlayer(selection, player); //If we have locked in render skin select if (HasLockedIn && selection.SummonerInternalName == Client.LoginPacket.AllSummonerData.Summoner.InternalName && !DevMode) { if (PurpleSide) AreWePurpleSide = true; RenderLockInGrid(selection); } } } } else if (tempParticipant is ObfuscatedParticipant) { control.PlayerName.Content = "Summoner " + i; } else if (tempParticipant is BotParticipant) { BotParticipant bot = tempParticipant as BotParticipant; string botChamp = bot.SummonerName.Split(' ')[0]; //Why is this internal name rito? champions botSelectedChamp = champions.GetChampion(botChamp); PlayerParticipant part = new PlayerParticipant(); PlayerChampionSelectionDTO selection = new PlayerChampionSelectionDTO(); selection.ChampionId = botSelectedChamp.id; part.SummonerName = botSelectedChamp.displayName + " bot"; control = RenderPlayer(selection, part); } else { control.PlayerName.Content = "Unknown Summoner"; } //Display purple side if we have gone through our team if (i > ChampDTO.TeamOne.Count) { i = 0; PurpleSide = true; } if (!PurpleSide) { BlueListView.Items.Add(control); } else { PurpleListView.Items.Add(control); } } //Do aram hack! if (OtherPlayers.Count > 0) { if (AreWePurpleSide) { BlueListView.Items.Clear(); } else { PurpleListView.Items.Clear(); } foreach (PlayerChampionSelectionDTO hackSelection in OtherPlayers) { ChampSelectPlayer control = new ChampSelectPlayer(); PlayerParticipant player = new PlayerParticipant(); player.SummonerName = hackSelection.SummonerInternalName; control = RenderPlayer(hackSelection, player); if (AreWePurpleSide) { BlueListView.Items.Add(control); } else { PurpleListView.Items.Add(control); } } } #endregion Display players })); #endregion In Champion Select } else if (message.GetType() == typeof(PlayerCredentialsDto)) { #region Launching Game PlayerCredentialsDto dto = message as PlayerCredentialsDto; Client.CurrentGame = dto; if (!HasLaunchedGame) { HasLaunchedGame = true; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { if (CountdownTimer != null) { CountdownTimer.Stop(); } Client.QuitCurrentGame(); })); Client.LaunchGame(); } #endregion Launching Game } else if (message.GetType() == typeof(TradeContractDTO)) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { TradeContractDTO TradeDTO = message as TradeContractDTO; if (TradeDTO.State == "PENDING") { PlayerTradeControl.Visibility = System.Windows.Visibility.Visible; PlayerTradeControl.Tag = TradeDTO; PlayerTradeControl.AcceptButton.Visibility = System.Windows.Visibility.Visible; PlayerTradeControl.DeclineButton.Content = "Decline"; champions MyChampion = champions.GetChampion((int)TradeDTO.ResponderChampionId); PlayerTradeControl.MyChampImage.Source = MyChampion.icon; PlayerTradeControl.MyChampLabel.Content = MyChampion.displayName; champions TheirChampion = champions.GetChampion((int)TradeDTO.RequesterChampionId); PlayerTradeControl.TheirChampImage.Source = TheirChampion.icon; PlayerTradeControl.TheirChampLabel.Content = TheirChampion.displayName; PlayerTradeControl.RequestLabel.Content = string.Format("{0} wants to trade!", TradeDTO.RequesterInternalSummonerName); } else if (TradeDTO.State == "CANCELED" || TradeDTO.State == "DECLINED" || TradeDTO.State == "BUSY") { PlayerTradeControl.Visibility = System.Windows.Visibility.Hidden; NotificationPopup pop = new NotificationPopup(ChatSubjects.INVITE_STATUS_CHANGED, string.Format("{0} has {1} this trade", TradeDTO.RequesterInternalSummonerName, TradeDTO.State)); if (TradeDTO.State == "BUSY") pop.NotificationTextBox.Text = string.Format("{0} is currently busy", TradeDTO.RequesterInternalSummonerName); pop.Height = 200; pop.OkButton.Visibility = System.Windows.Visibility.Visible; pop.HorizontalAlignment = HorizontalAlignment.Right; pop.VerticalAlignment = VerticalAlignment.Bottom; Client.NotificationGrid.Children.Add(pop); } })); } }
private void EntryChanged_Event(object sender, System.Windows.RoutedEventArgs e) { object[] entries = e.OriginalSource as object[]; TimelineEntry oldEntry = entries[0] as TimelineEntry; TimelineEntry newEntry = entries[1] as TimelineEntry; RouteTimeTableEntry oEntry = (RouteTimeTableEntry)oldEntry.Source; RouteTimeTable rt = new RouteTimeTable(oEntry.TimeTable.Route); RouteTimeTableEntry nEntry = new RouteTimeTableEntry(rt,(DayOfWeek)newEntry.StartTime.Days,newEntry.StartTime,oEntry.Destination); nEntry.Airliner = this.Airliner; rt.addEntry(nEntry); List<RouteTimeTableEntry> tEntries = new List<RouteTimeTableEntry>(this.Entries); tEntries.Remove(oEntry); if (!TimeTableHelpers.IsTimeTableValid(rt, this.Airliner, tEntries)) WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2706"), Translator.GetInstance().GetString("MessageBox", "2706", "message"), WPFMessageBoxButtons.Ok); else { this.Entries.Remove(oEntry); this.Entries.Add(nEntry); } }
private static void CreateAndAddComponentBox(VCN3dsExporterPropertyEditorWindow referenceWindow, List<BaseComponent> components, StackPanel stack, BaseComponent component) { GroupBox grpBox = new GroupBox { Header = component.Name }; grpBox.BorderThickness = new Thickness(3); grpBox.BorderBrush = new SolidColorBrush(Color.FromRgb(0, 0, 0)); Dictionary<string, object> dict = component.GetAttributes(); StackPanel sp = new StackPanel(); grpBox.Content = sp; foreach (var item in dict) { StackPanel sp2 = new StackPanel(); sp2.Orientation = Orientation.Horizontal; Label lbl = new Label(); lbl.Content = item.Key; sp2.Children.Add(lbl); TextBox txt = new TextBox(); txt.Text = item.Value.ToString(); txt.TextChanged += (object sender, TextChangedEventArgs args) => { component.SetAttribute(item.Key, txt.Text); referenceWindow.SendDataUpdate(); }; sp2.Children.Add(txt); sp.Children.Add(sp2); } Button remove = new Button(); remove.Content = "Remove Component"; remove.Click += (object sender, RoutedEventArgs e) => { stack.Children.Remove(grpBox); components.Remove(component); referenceWindow.SendDataUpdate(); }; sp.Children.Add(remove); stack.Children.Add(grpBox); }
private void FillComboboxes(bool update = false) { LoadingCombos = true; string prevDateField = string.Empty; string prevWeightField = string.Empty; string prevSyndromeField = string.Empty; if (update) { if (cbxDate.SelectedIndex >= 0) { prevDateField = cbxDate.SelectedItem.ToString(); } if (cbxFieldWeight.SelectedIndex >= 0) { prevWeightField = cbxFieldWeight.SelectedItem.ToString(); } if (cbxSyndrome.SelectedIndex >= 0) { prevSyndromeField = cbxSyndrome.SelectedItem.ToString(); } } cbxDate.ItemsSource = null; cbxDate.Items.Clear(); cbxFieldWeight.ItemsSource = null; cbxFieldWeight.Items.Clear(); cbxSyndrome.ItemsSource = null; cbxSyndrome.Items.Clear(); List<string> fieldNames = new List<string>(); List<string> weightFieldNames = new List<string>(); List<string> strataFieldNames = new List<string>(); weightFieldNames.Add(string.Empty); strataFieldNames.Add(string.Empty); ColumnDataType columnDataType = ColumnDataType.DateTime; fieldNames = dashboardHelper.GetFieldsAsList(columnDataType); columnDataType = ColumnDataType.Numeric | ColumnDataType.UserDefined; weightFieldNames.AddRange(dashboardHelper.GetFieldsAsList(columnDataType)); columnDataType = ColumnDataType.Numeric | ColumnDataType.Boolean | ColumnDataType.Text | ColumnDataType.UserDefined; strataFieldNames.AddRange(dashboardHelper.GetFieldsAsList(columnDataType)); fieldNames.Sort(); weightFieldNames.Sort(); strataFieldNames.Sort(); if (fieldNames.Contains("SYSTEMDATE")) { fieldNames.Remove("SYSTEMDATE"); } cbxDate.ItemsSource = fieldNames; cbxFieldWeight.ItemsSource = weightFieldNames; cbxSyndrome.ItemsSource = strataFieldNames; if (cbxDate.Items.Count > 0) { cbxDate.SelectedIndex = -1; } if (cbxFieldWeight.Items.Count > 0) { cbxFieldWeight.SelectedIndex = -1; } if (cbxSyndrome.Items.Count > 0) { cbxSyndrome.SelectedIndex = -1; } if (update) { cbxDate.SelectedItem = prevDateField; cbxFieldWeight.SelectedItem = prevWeightField; cbxSyndrome.SelectedItem = prevSyndromeField; } LoadingCombos = false; }
private void InspectorsRefresh(Inspector inspector, Boolean added = false) { List<Inspector> lstInspectors = new List<Inspector>(); if (inspector == null) { using (var db = new DataContext()) { lstInspectors = db.Inspectors.ToList(); lstInspectors.ForEach(insp => FillRulesAux(insp)); } } else { lstInspectors = (List<Inspector>)lstVInspectors.ItemsSource; if (added) { FillRulesAux(inspector); lstInspectors.Add(inspector); } else lstInspectors.Remove(inspector); } lstVInspectors.ItemsSource = null; lstVInspectors.ItemsSource = lstInspectors; }
//This method returns which connection points should be shown on hover of a shape. List<ConnectionPoint> ConnectionPointsToShow(UIElement element, ModelItem model) { bool isInComingConnection = false; //This condition checks if it is an incoming connection. if (this.srcConnectionPoint != null || (this.panel.connectorEditor != null && this.panel.connectorEditor.IsConnectorEndBeingMoved)) { isInComingConnection = true; } List<ConnectionPoint> connectionPointsToShow = new List<ConnectionPoint>(); if (GenericFlowSwitchHelper.IsGenericFlowSwitch(model.ItemType)) { connectionPointsToShow.AddRange(FlowchartDesigner.GetConnectionPoints(element)); } else if (typeof(FlowDecision).IsAssignableFrom(model.ItemType)) { if (isInComingConnection) { connectionPointsToShow.AddRange(FlowchartDesigner.GetConnectionPoints(element)); } else { connectionPointsToShow.Add(FlowchartDesigner.GetTrueConnectionPoint(element)); connectionPointsToShow.Add(FlowchartDesigner.GetFalseConnectionPoint(element)); List<Connector> outGoingConnectors = GetOutGoingConnectors(element); if (this.panel.connectorEditor != null && this.panel.connectorEditor.IsConnectorStartBeingMoved) { //If the start of an outgoing connector is moved, its not an outgoing connector any more. outGoingConnectors.Remove(this.panel.connectorEditor.Connector); } //Do not show True/False connection point if a link already exists. foreach (Connector connector in outGoingConnectors) { connectionPointsToShow.Remove(FreeFormPanel.GetSourceConnectionPoint(connector)); } } } else// Case where only one out going connector is allowed - Start and FlowStep. { ConnectionPointKind allowedType = ConnectionPointKind.Default; bool isConnectionAllowed = false; if (isInComingConnection) { allowedType = ConnectionPointKind.Incoming; isConnectionAllowed = true; } else { List<Connector> outGoingConnectors = GetOutGoingConnectors(element); if (this.panel.connectorEditor != null && this.panel.connectorEditor.IsConnectorStartBeingMoved) { outGoingConnectors.Remove(this.panel.connectorEditor.Connector); } //Outgoing Connection is allowed only if there are no outgoing connectors already. if (outGoingConnectors.Count == 0) { allowedType = ConnectionPointKind.Outgoing; isConnectionAllowed = true; } } if (isConnectionAllowed) { foreach (ConnectionPoint connPoint in FlowchartDesigner.GetConnectionPoints(element)) { if (connPoint.PointType == allowedType || connPoint.PointType == ConnectionPointKind.Default) { connectionPointsToShow.Add(connPoint); } } } } //Do not show the connection points of a selected connector. if (this.selectedConnector != null) { connectionPointsToShow.Remove(FreeFormPanel.GetSourceConnectionPoint(this.selectedConnector)); connectionPointsToShow.Remove(FreeFormPanel.GetDestinationConnectionPoint(this.selectedConnector)); } return connectionPointsToShow; }
// ------------------------------------------------------------- // // Private Methods // // ------------------------------------------------------------- #region Private Methods // ............................................................. // // Serialization // // ............................................................. /// <summary> /// This function serializes text segment formed by rangeStart and rangeEnd to valid xml using xmlWriter. /// </summary> /// <SecurityNote> /// To mask the security exception from XamlWriter.Save in partial trust case, /// this function checks if the current call stack has the all clipboard permission. /// </SecurityNote> private static void WriteXamlTextSegment(XmlWriter xmlWriter, ITextPointer rangeStart, ITextPointer rangeEnd, XamlTypeMapper xamlTypeMapper, ref int elementLevel, WpfPayload wpfPayload, bool ignoreWriteHyperlinkEnd, List<int> ignoreList, bool preserveTextElements) { // Special case for pure text selection - we need a Run wrapper for it. if (elementLevel == EmptyDocumentDepth && typeof(Run).IsAssignableFrom(rangeStart.ParentType)) { elementLevel++; xmlWriter.WriteStartElement(typeof(Run).Name); } // Create text navigator for reading the range's content ITextPointer textReader = rangeStart.CreatePointer(); // Exclude last opening tag from serialization - we don't need to create extra element // is cases when we have whole paragraphs/cells selected. // NOTE: We do this slightly differently than in TextRangeEdit.AdjustRangeEnd, where we use normalization for adjusted position. // In this case normalized position does not work, because we need to keep information about crossed paragraph boundary. while (rangeEnd.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart) { rangeEnd = rangeEnd.GetNextContextPosition(LogicalDirection.Backward); } // Write the range internal contents while (textReader.CompareTo(rangeEnd) < 0) { TextPointerContext runType = textReader.GetPointerContext(LogicalDirection.Forward); switch (runType) { case TextPointerContext.ElementStart: TextElement nextElement = (TextElement)textReader.GetAdjacentElement(LogicalDirection.Forward); if (nextElement is Hyperlink) { // Don't write Hyperlink start element if Hyperlink is invalid // in case of having a UiElement except Image or stated the range end // position before the end position of the Hyperlink. if (IsHyperlinkInvalid(textReader, rangeEnd)) { ignoreWriteHyperlinkEnd = true; textReader.MoveToNextContextPosition(LogicalDirection.Forward); continue; } } else if (nextElement != null) { // TextElementEditingBehaviorAttribute att = (TextElementEditingBehaviorAttribute)Attribute.GetCustomAttribute(nextElement.GetType(), typeof(TextElementEditingBehaviorAttribute)); if (att != null && !att.IsTypographicOnly) { if (IsPartialNonTypographic(textReader, rangeEnd)) { // Add pointer to ignore list ITextPointer ptr = textReader.CreatePointer(); ptr.MoveToElementEdge(ElementEdge.BeforeEnd); ignoreList.Add(ptr.Offset); textReader.MoveToNextContextPosition(LogicalDirection.Forward); continue; } } } elementLevel++; textReader.MoveToNextContextPosition(LogicalDirection.Forward); WriteStartXamlElement(/*range:*/null, textReader, xmlWriter, xamlTypeMapper, /*reduceElement:*/wpfPayload == null, preserveTextElements); break; case TextPointerContext.ElementEnd: // Don't write Hyperlink end element if Hyperlink include the invalid // in case of having a UiElement except Image or stated the range end // before the end position of the Hyperlink or Hyperlink opening tag is // skipped from WriteOpeningTags by selecting of the partial of Hyperlink. if (ignoreWriteHyperlinkEnd && (textReader.GetAdjacentElement(LogicalDirection.Forward) is Hyperlink)) { // Reset the flag to keep walk up the next Hyperlink tag ignoreWriteHyperlinkEnd = false; textReader.MoveToNextContextPosition(LogicalDirection.Forward); continue; } // Check the ignore list ITextPointer endPointer = textReader.CreatePointer(); endPointer.MoveToElementEdge(ElementEdge.BeforeEnd); // if (ignoreList.Contains(endPointer.Offset)) { ignoreList.Remove(endPointer.Offset); textReader.MoveToNextContextPosition(LogicalDirection.Forward); continue; } elementLevel--; if (TextSchema.IsBreak(textReader.ParentType)) { // For LineBreak, etc. use empty element syntax xmlWriter.WriteEndElement(); } else { // // For all other textelements use explicit closing tag. xmlWriter.WriteFullEndElement(); } textReader.MoveToNextContextPosition(LogicalDirection.Forward); break; case TextPointerContext.Text: int textLength = textReader.GetTextRunLength(LogicalDirection.Forward); char[] text = new Char[textLength]; textLength = TextPointerBase.GetTextWithLimit(textReader, LogicalDirection.Forward, text, 0, textLength, rangeEnd); // XmlWriter will throw an ArgumentException if text contains // any invalid surrogates, so strip them out now. textLength = StripInvalidSurrogateChars(text, textLength); xmlWriter.WriteChars(text, 0, textLength); textReader.MoveToNextContextPosition(LogicalDirection.Forward); break; case TextPointerContext.EmbeddedElement: object embeddedObject = textReader.GetAdjacentElement(LogicalDirection.Forward); textReader.MoveToNextContextPosition(LogicalDirection.Forward); WriteEmbeddedObject(embeddedObject, xmlWriter, wpfPayload); break; default: Invariant.Assert(false, "unexpected value of runType"); textReader.MoveToNextContextPosition(LogicalDirection.Forward); break; } } }