public void CustomizeView(Watch3D model, NodeView nodeView) { var dynamoViewModel = nodeView.ViewModel.DynamoViewModel; watch3dModel = model; var renderingTier = (RenderCapability.Tier >> 16); if (renderingTier < 2) { return; } var dynamoModel = dynamoViewModel.Model; var vmParams = new Watch3DViewModelStartupParams(dynamoModel); watch3DViewModel = new HelixWatch3DNodeViewModel(watch3dModel, vmParams); watch3DViewModel.Setup(dynamoViewModel, dynamoViewModel.RenderPackageFactoryViewModel.Factory); if (model.initialCameraData != null) { try { // The deserialization logic is unified between the view model and this node model. // For the node model, we need to supply the deserialization method with the camera node. var cameraNode = model.initialCameraData.ChildNodes.Cast <XmlNode>().FirstOrDefault(innerNode => innerNode.Name.Equals("camera", StringComparison.OrdinalIgnoreCase)); var cameraData = watch3DViewModel.DeserializeCamera(cameraNode); watch3DViewModel.SetCameraData(cameraData); } catch { watch3DViewModel.SetCameraData(new CameraData()); } } model.Serialized += model_Serialized; watch3DViewModel.ViewCameraChanged += (s, args) => { var camera = watch3DViewModel.GetCameraInformation(); watch3dModel.Camera.Name = camera.Name; watch3dModel.Camera.EyeX = camera.EyePosition.X; watch3dModel.Camera.EyeY = camera.EyePosition.Y; watch3dModel.Camera.EyeZ = camera.EyePosition.Z; watch3dModel.Camera.LookX = camera.LookDirection.X; watch3dModel.Camera.LookY = camera.LookDirection.Y; watch3dModel.Camera.LookZ = camera.LookDirection.Z; watch3dModel.Camera.UpX = camera.UpDirection.X; watch3dModel.Camera.UpY = camera.UpDirection.Y; watch3dModel.Camera.UpZ = camera.UpDirection.Z; }; watch3DView = new Watch3DView() { Width = model.WatchWidth, Height = model.WatchHeight, DataContext = watch3DViewModel }; // When user sizes a watch node, only view gets resized. The actual // NodeModel does not get updated. This is where the view updates the // model whenever its size is updated. // Updated from (Watch3d)View.SizeChanged to nodeView.SizeChanged - height // and width should correspond to node model and not watch3Dview nodeView.SizeChanged += (sender, args) => model.SetSize(args.NewSize.Width, args.NewSize.Height); // set WatchSize in model watch3DView.View.SizeChanged += (sender, args) => model.SetWatchSize(args.NewSize.Width, args.NewSize.Height); var mi = new MenuItem { Header = Resources.ZoomToFit }; mi.Click += mi_Click; nodeView.MainContextMenu.Items.Add(mi); var backgroundRect = new Rectangle { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, IsHitTestVisible = false, }; var bc = new BrushConverter(); var strokeBrush = (Brush)bc.ConvertFrom("#313131"); backgroundRect.Stroke = strokeBrush; backgroundRect.StrokeThickness = 1; var backgroundBrush = new SolidColorBrush(Color.FromRgb(240, 240, 240)); backgroundRect.Fill = backgroundBrush; nodeView.PresentationGrid.Children.Add(backgroundRect); nodeView.PresentationGrid.Children.Add(watch3DView); nodeView.PresentationGrid.Visibility = Visibility.Visible; DataBridge.Instance.RegisterCallback( model.GUID.ToString(), obj => nodeView.Dispatcher.Invoke( new Action <object>(RenderData), DispatcherPriority.Render, obj)); }
public void SetInfo(int index) { var bc = new BrushConverter(); if (Data.webList.Count > 0) { Data.Selected = index; string players = ""; foreach (string part in Data.webList[index].Players) { players += part + ","; } players = players.Substring(0, players.Length - 1); string version = ""; if (Data.webList[index].ModOrigin == "Orig") { version = "Original"; } else { version = "Modified"; } try { Data.Inf.Dispatcher.Invoke(new Action(delegate() { Data.Inf.Document.Blocks.Clear(); Paragraph paragraph = new Paragraph(); paragraph.TextAlignment = TextAlignment.Left; paragraph.Foreground = (Brush)bc.ConvertFrom("#222222"); paragraph.Inlines.Add(new Bold(new Run("Lobby name:"))); paragraph.Inlines.Add(" . . . . . . . . . . " + Data.webList[index].Name + "\r\n"); paragraph.Inlines.Add(new Bold(new Run("Number of players:"))); paragraph.Inlines.Add(" . . . . . " + Data.webList[index].Count + "\r\n"); paragraph.Inlines.Add(new Bold(new Run("Map: "))); paragraph.Inlines.Add(" . . . . . . . . . . . . . . . . " + Data.webList[index].Map + "\r\n"); paragraph.Inlines.Add(new Bold(new Run("Number of deaths: "))); paragraph.Inlines.Add(" . . . . . " + Data.webList[index].Score + "\r\n"); paragraph.Inlines.Add(new Bold(new Run("Player list: "))); paragraph.Inlines.Add(" . . . . . . . . . . . . " + players + "\r\n"); paragraph.Inlines.Add(new Bold(new Run("Type: "))); paragraph.Inlines.Add(" . . . . . . . . . . . . . . . . " + Data.webList[index].Type + "\r\n"); paragraph.Inlines.Add(new Bold(new Run("Version: "))); paragraph.Inlines.Add(" . . . . . . . . . . . . . . " + version + "\r\n"); paragraph.Inlines.Add(new Bold(new Run("Password: "******" . . . . . . . . . . . . " + Data.webList[index].Password + "\r\n"); paragraph.Inlines.Add(new Bold(new Run("Information: "))); paragraph.Inlines.Add(" . . . . . . . . . . " + Data.webList[index].Comment + "\r\n"); Data.Inf.Document.Blocks.Add(paragraph); })); } catch { } } else { Data.Inf.Dispatcher.Invoke(new Action(delegate() { Data.Inf.Document.Blocks.Clear(); })); } }
private void btnGuardar_Click(object sender, RoutedEventArgs e) { BrushConverter bc = new BrushConverter(); txbContacto.Foreground = (Brush)bc.ConvertFrom("#FF000000"); try { PersonaMantenimiento persona = new PersonaMantenimiento(); ValidacionesMantenimiento validacion = new ValidacionesMantenimiento(); if ((String)cmbTipoContacto.SelectedValue == "Correo" && validacion.Validar(txbContacto.Text, 2) == true) { if (Accion == "Insertar") { persona.AgregarContacto(pPersona: pk_persona, pDato: txbContacto.Text, pTipoContacto: cmbTipoContacto.SelectedValue.ToString()); MessageBox.Show("Contacto añadido con éxito.", "SIGEEA", MessageBoxButton.OK); } else if (Accion == "Editar") { SIGEEA_Contacto editarContacto = new SIGEEA_Contacto(); editarContacto.PK_Id_Contacto = pk_contacto; editarContacto.Dato_Contacto = txbContacto.Text; editarContacto.FK_Id_Persona = pk_persona; DataClasses1DataContext dc = new DataClasses1DataContext(); editarContacto.FK_Id_TipContacto = dc.SIGEEA_TipContactos.First(c => c.Nombre_TipContacto == (String)cmbTipoContacto.SelectedValue).PK_Id_TipContacto; persona.EditarContacto(editarContacto); MessageBox.Show("Los cambios se realizaron con éxito.", "SIGEEA", MessageBoxButton.OK, MessageBoxImage.Exclamation); } this.Close(); wnwContactos ventana = new wnwContactos(pk_persona); ventana.ShowDialog(); } else if (((String)cmbTipoContacto.SelectedValue == "Tel. Movil" || (String)cmbTipoContacto.SelectedValue == "Tel. Residencia" || (String)cmbTipoContacto.SelectedValue == "Tel. Trabajo" || (String)cmbTipoContacto.SelectedValue == "Fax") && validacion.Validar(txbContacto.Text, 1) == true) { if (Accion == "Insertar") { persona.AgregarContacto(pPersona: pk_persona, pDato: txbContacto.Text, pTipoContacto: cmbTipoContacto.SelectedValue.ToString()); MessageBox.Show("Contacto añadido con éxito.", "SIGEEA", MessageBoxButton.OK); } else if (Accion == "Editar") { SIGEEA_Contacto editarContacto = new SIGEEA_Contacto(); editarContacto.PK_Id_Contacto = pk_contacto; editarContacto.Dato_Contacto = txbContacto.Text; editarContacto.FK_Id_Persona = pk_persona; DataClasses1DataContext dc = new DataClasses1DataContext(); editarContacto.FK_Id_TipContacto = dc.SIGEEA_TipContactos.First(c => c.Nombre_TipContacto == cmbTipoContacto.SelectedItem.ToString()).PK_Id_TipContacto; persona.EditarContacto(editarContacto); MessageBox.Show("Los cambios se realizaron con éxito.", "SIGEEA", MessageBoxButton.OK, MessageBoxImage.Exclamation); } this.Close(); wnwContactos ventana = new wnwContactos(pk_persona); ventana.ShowDialog(); } else { txbContacto.Foreground = (Brush)bc.ConvertFrom("#FFFF0404"); throw new ArgumentException("Error al registrar: Formatos incompatibles con el sistema"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "SIGEEA", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void makeDefaultAnswers(int number, int defaultNumber) { Grid grid = (Grid)controls["question_g_" + number]; StackPanel answer_stack = new StackPanel(); StackPanel answer_substack = new StackPanel(); answer_substack.Name = "answer_stack_" + number; controls.Add(answer_substack.Name, answer_substack); string[] question_num = grid.Name.Split('_');//get question number for (int i = 0; i < defaultNumber; i++) { Grid g = new Grid(); g.Name = "answer_g_" + (question_num[2]) + (i + 1); g.Margin = new Thickness(10, 0, 10, 10); BrushConverter bc = new BrushConverter(); g.Background = (Brush)bc.ConvertFrom("#FFC2C6C9"); ColumnDefinition col = new ColumnDefinition(); col.Width = new GridLength(5, GridUnitType.Star); g.ColumnDefinitions.Add(col); col = new ColumnDefinition(); col.Width = new GridLength(17, GridUnitType.Star); g.ColumnDefinitions.Add(col); RadioButton rb = new RadioButton(); rb.Margin = new Thickness(10); rb.Name = "answer_rb_" + (question_num[2]) + "_" + (i + 1); rb.GroupName = "question_rbg_" + (question_num[2]); g.Children.Add(rb); Grid.SetColumn(rb, 0); TextBox txt = new TextBox(); txt.Name = "answer_txt_" + (question_num[2]) + "_" + (i + 1); txt.Margin = new Thickness(10); // answers_txts.Add(txt); g.Children.Add(txt); Grid.SetColumn(txt, 1); controls[txt.Name] = txt; controls[rb.Name] = rb; controls[g.Name] = g; answer_substack.Margin = new Thickness(0, 10, 0, 0); answer_substack.Children.Add(g); } answer_stack.Background = Brushes.White; Grid.SetColumn(answer_stack, 2); answer_stack.Children.Add(answer_substack); grid.Children.Add(answer_stack); }
/// <summary> /// Converts a value. /// </summary> /// <param name="value">The value produced by the binding source.</param> /// <param name="targetType">The type of the binding target property.</param> /// <param name="parameter">The converter parameter to use.</param> /// <param name="culture">The culture to use in the converter.</param> /// <returns> /// A converted value. If the method returns null, the valid null value is used. /// </returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { return(null); } var brushConverter = new BrushConverter(); var accent = value.ToString(); switch (accent) { case "Amber": return(brushConverter.ConvertFrom("#CCF0A30A")); case "Blue": return(brushConverter.ConvertFrom("#CC119EDA")); case "Brown": return(brushConverter.ConvertFrom("#CC825A2C")); case "Cobalt": return(brushConverter.ConvertFrom("#FF003BB0")); case "Crimson": return(brushConverter.ConvertFrom("#CCA20025")); case "Cyan": return(brushConverter.ConvertFrom("#CC1BA1E2")); case "Emerald": return(brushConverter.ConvertFrom("#CC008A00")); case "Green": return(brushConverter.ConvertFrom("#CC60A917")); case "Indigo": return(brushConverter.ConvertFrom("#CC6A00FF")); case "Lime": return(brushConverter.ConvertFrom("#CCA4C400")); case "Magenta": return(brushConverter.ConvertFrom("#CCD80073")); case "Mauve": return(brushConverter.ConvertFrom("#CC76608A")); case "Olive": return(brushConverter.ConvertFrom("#CC6D8764")); case "Orange": return(brushConverter.ConvertFrom("#CCFA6800")); case "Pink": return(brushConverter.ConvertFrom("#CCF472D0")); case "Purple": return(brushConverter.ConvertFrom("#CC6459DF")); case "Red": return(brushConverter.ConvertFrom("#CCE51400")); case "Sienna": return(brushConverter.ConvertFrom("#CCA0522D")); case "Steel": return(brushConverter.ConvertFrom("#CC647687")); case "Taupe": return(brushConverter.ConvertFrom("#CC87794E")); case "Teal": return(brushConverter.ConvertFrom("#CC00ABA9")); case "Violet": return(brushConverter.ConvertFrom("#CCAA00FF")); case "Yellow": return(brushConverter.ConvertFrom("#CCFEDE06")); } return(null); }
} // backupFile /*- Draw log table ---------------------------------------------------------------------- */ private void drawLogTable() { Table oTable = new Table(); // Create n columns and add them to the table's Columns collection. int numberOfColumns = 3; for (int x = 0; x < numberOfColumns; x++) { oTable.Columns.Add(new TableColumn()); } // Create and add an empty TableRowGroup Rows. oTable.RowGroups.Add(new TableRowGroup()); // Add the table head row. oTable.RowGroups[0].Rows.Add(new TableRow()); // Configure the table head row TableRow currentRow = oTable.RowGroups[0].Rows[0]; var brushConverter = new BrushConverter(); currentRow.Background = (Brush)brushConverter.ConvertFrom("#FFe2e2e2"); // grey background currentRow.Foreground = (Brush)brushConverter.ConvertFrom("#FF000000"); // black text currentRow.FontFamily = new FontFamily("Segoe UI");; currentRow.FontSize = 16; currentRow.FontWeight = FontWeights.Bold; // Add the header row with content, currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Date time")))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Directory")))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("File")))); // Read file and add rows string userPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); string filePath = userPath + "\\" + "WindowsBackupFoldersToExternalDisk" + "\\" + "config" + "\\" + "log.txt"; if (File.Exists(filePath)) { // Read file string existingFolders = System.IO.File.ReadAllText(filePath); string[] stringSeparators = new string[] { "\n" }; string[] existsingFoldersArray = existingFolders.Split(stringSeparators, StringSplitOptions.None); // Loop trough file String lastDirectory = ""; int countLines = 1; Brush brushEven = (Brush)brushConverter.ConvertFrom("#FFf3f3f3"); // grey background Brush brushOdd = (Brush)brushConverter.ConvertFrom("#FFf8f8f8"); // grey background String styleHandler = "even"; foreach (string line in existsingFoldersArray) { if (!(line.Equals(""))) { string[] stringLineSeparators = new string[] { "|" }; string[] lineArray = line.Split(stringLineSeparators, StringSplitOptions.None); String dateTime = lineArray[0]; // Datetime String directory = lineArray[1]; // Directory String file = lineArray[2].Replace(directory.ToString(), ""); // File if (lastDirectory.Equals(directory.ToString())) { directory = ""; } // Add new row oTable.RowGroups[0].Rows.Add(new TableRow()); currentRow = oTable.RowGroups[0].Rows[countLines]; //Configure the row layout if (styleHandler.Equals("odd")) { currentRow.Background = brushOdd; styleHandler = "even"; } else { currentRow.Background = brushEven; styleHandler = "odd"; } currentRow.FontFamily = new FontFamily("Segoe UI");; currentRow.FontSize = 16; //Add the country name in the first cell currentRow.Cells.Add(new TableCell(new Paragraph(new Run(dateTime)))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run(directory)))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run(file)))); // Last directory lastDirectory = directory; countLines = countLines + 1; } // not empty } //foreach } // file exists //Add the given flow document to the window FlowDocument flowDocument = new FlowDocument(); flowDocument.Blocks.Add(oTable); contentControlDashboardLog.Content = flowDocument; }
private async void Load(List <Participant> allParticipants, PlatformGameLifecycleDTO n, ListView list) { bool isYourTeam = false; list.Items.Clear(); list.Items.Refresh(); try { string mmrJson; string url = Client.Region.SpectatorLink + "consumer/getGameMetaData/" + Client.Region.InternalName + "/" + n.Game.Id + "/token"; using (var client = new WebClient()) mmrJson = client.DownloadString(url); var serializer = new JavaScriptSerializer(); var deserializedJson = serializer.Deserialize <Dictionary <string, object> >(mmrJson); MMRLabel.Content = "Game MMR ≈ " + deserializedJson["interestScore"]; } catch { MMRLabel.Content = "Unable to calculate Game MMR"; } foreach (Participant par in allParticipants) { if (par is PlayerParticipant) { PublicSummoner scoutersum = await Client.PVPNet.GetSummonerByName(GSUsername); if ((par as PlayerParticipant).AccountId == scoutersum.AcctId) { isYourTeam = true; } } } foreach (Participant par in allParticipants) { if (par is PlayerParticipant) { var participant = par as PlayerParticipant; foreach (PlayerChampionSelectionDTO championSelect in n.Game.PlayerChampionSelections.Where(championSelect => championSelect.SummonerInternalName == participant.SummonerInternalName)) { GameScouterPlayer control = new GameScouterPlayer(); control.Tag = championSelect; GameStats = new List <MatchStats>(); control.Username.Content = championSelect.SummonerInternalName; //Make it so you can see yourself if (championSelect.SummonerInternalName == GSUsername) { control.Username.Foreground = (Brush)(new BrushConverter().ConvertFrom("#FF007A53")); } control.ChampIcon.Source = champions.GetChampion(championSelect.ChampionId).icon; var uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell1Id))), UriKind.Absolute); control.SumIcon1.Source = new BitmapImage(uriSource); uriSource = new Uri( Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell2Id))), UriKind.Absolute); control.SumIcon2.Source = new BitmapImage(uriSource); GameStats.Clear(); try { PublicSummoner summoner = await Client.PVPNet.GetSummonerByName(championSelect.SummonerInternalName); control.ProfileIcon.Source = Client.GetImage(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", summoner.ProfileIconId.ToString() + ".png")); RecentGames result = await Client.PVPNet.GetRecentGames(summoner.AcctId); result.GameStatistics.Sort((s1, s2) => s2.CreateDate.CompareTo(s1.CreateDate)); foreach (PlayerGameStats game in result.GameStatistics) { game.GameType = Client.TitleCaseString(game.GameType.Replace("_GAME", "").Replace("MATCHED", "NORMAL")); var match = new MatchStats(); foreach (RawStat stat in game.Statistics) { Type type = typeof(MatchStats); string fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", ""); FieldInfo f = type.GetField(fieldName); f.SetValue(match, stat.Value); } match.Game = game; GameStats.Add(match); } int Kills, ChampKills; int Deaths, ChampDeaths; int Assists, ChampAssists; int GamesPlayed, ChampGamesPlayed; Kills = 0; Deaths = 0; Assists = 0; GamesPlayed = 0; ChampKills = 0; ChampDeaths = 0; ChampAssists = 0; ChampGamesPlayed = 0; //Load average KDA for past 20 games if possible foreach (MatchStats stats in GameStats) { champions gameChamp = champions.GetChampion((int)Math.Round(stats.Game.ChampionId)); Kills = Kills + (Int32)stats.ChampionsKilled; Deaths = Deaths + (Int32)stats.NumDeaths; Assists = Assists + (Int32)stats.Assists; GamesPlayed++; if (championSelect.ChampionId == (int)Math.Round(stats.Game.ChampionId)) { ChampKills = ChampKills + (Int32)stats.ChampionsKilled; ChampDeaths = ChampDeaths + (Int32)stats.NumDeaths; ChampAssists = ChampAssists + (Int32)stats.Assists; ChampGamesPlayed++; } } //GetKDA String string KDAString = string.Format("{0}/{1}/{2}", (Kills / GamesPlayed), (Deaths / GamesPlayed), (Assists / GamesPlayed)); string ChampKDAString = ""; try { ChampKDAString = string.Format("{0}/{1}/{2}", (ChampKills / ChampGamesPlayed), (ChampDeaths / ChampGamesPlayed), (ChampAssists / ChampGamesPlayed)); } catch { } if (ChampGamesPlayed == 0) { ChampKDAString = "No Games lately"; } control.AverageKDA.Content = KDAString; control.ChampAverageKDA.Content = ChampKDAString; BrushConverter bc = new BrushConverter(); if (isYourTeam) { bc = new BrushConverter(); if (ChampKills < ChampDeaths) { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FFFF0000"); } else if (ChampKills == ChampDeaths) { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FF67FF67"); } else { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FF00FF3A"); } bc = new BrushConverter(); if (Kills < Deaths) { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FFFF0000"); } else if (Kills == Deaths) { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FF67FF67"); } else { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FF00FF3A"); } } else { bc = new BrushConverter(); if (ChampKills > ChampDeaths) { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FFFF0000"); } else if (ChampKills == ChampDeaths) { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FF67FF67"); } else { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FF00FF3A"); } bc = new BrushConverter(); if (Kills > Deaths) { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FFFF0000"); } else if (Kills == Deaths) { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FF67FF67"); } else { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FF00FF3A"); } } } catch { Client.Log("Failed to get stats about player", "GAME_SCOUTER_ERROR"); } if (participant.TeamParticipantId != null) { try { Brush myColor = color[(double)participant.TeamParticipantId]; control.QueueTeamColor.Fill = myColor; control.QueueTeamColor.Visibility = Visibility.Visible; } catch { BrushConverter bc = new BrushConverter(); Brush brush = Brushes.White; //I know that there is a better way in the InGamePage //I find that sometimes the colors (colours) are very hard to distinguish from eachother //This makes sure that each color is easy to see //because of hexa hill I put 12 in just in case switch (ColorId) { case 0: //blue brush = (Brush)bc.ConvertFrom("#FF00E8FF"); break; case 2: //Lime Green brush = (Brush)bc.ConvertFrom("#FF00FF00"); break; case 3: //Yellow brush = (Brush)bc.ConvertFrom("#FFFFFF00"); break; case 4: //Blue Green brush = (Brush)bc.ConvertFrom("#FF007A53"); break; case 5: //Purple brush = (Brush)bc.ConvertFrom("#FF5100FF"); break; case 6: //Pink brush = (Brush)bc.ConvertFrom("#FFCB46C5"); break; case 7: //Dark Green brush = (Brush)bc.ConvertFrom("#FF006409"); break; case 8: //Brown brush = (Brush)bc.ConvertFrom("#FF643200"); break; case 9: //White brush = (Brush)bc.ConvertFrom("#FFFFFFFF"); break; case 10: //Grey brush = (Brush)bc.ConvertFrom("#FF363636"); break; case 11: //Red Pink brush = (Brush)bc.ConvertFrom("#FF8F4242"); break; case 12: //Grey Blue brush = (Brush)bc.ConvertFrom("#FFFF0000"); break; } color.Add((Double)participant.TeamParticipantId, brush); ColorId++; control.QueueTeamColor.Fill = brush; control.QueueTeamColor.Visibility = Visibility.Visible; } } list.Items.Add(control); } } } }
private void edit_Click(object sender, RoutedEventArgs e) { front_canvas.Children.Remove(delete); XmlDoc.Load("xml_test2.xml"); XmlNodeList elemList = XmlDoc.SelectNodes("Root/Activity"); for (int i = 0; i < elemList.Count; i++) { if (elemList[i].Attributes["id"].Value == selected.ToString()) { elemList[i].InnerText = EditTextBox.Text; //elemList[i].Attributes["length"].Value = EditTextBox2.Text; elemList[i].Attributes["filelink"].Value = PathEditTextBox.Text; elemList[i].Attributes["weblink"].Value = WebEditTextBox.Text; elemList[i].Attributes["color"].Value = editcolor.Text; elemList[i].Attributes["start_time"].Value = start_timepicker.Value.Value.ToString("M/d HH:mm"); elemList[i].Attributes["end_time"].Value = end_timepicker.Value.Value.ToString("M/d HH:mm"); //set start position //DateTime oDate = DateTime.ParseExact(iString, "yyyy-MM-dd HH:mm", null); DateTime start_time = DateTime.ParseExact(elemList[i].Attributes["start_time"].Value, "M/d HH:mm", null); DateTime end_time = DateTime.ParseExact(elemList[i].Attributes["end_time"].Value, "M/d HH:mm", null); TimeSpan start_pos = start_time - DateTime.Now; TimeSpan end_pos = end_time - DateTime.Now; double start_min = start_pos.TotalMinutes; double end_min = end_pos.TotalMinutes; //set length elemList[i].Attributes["length"].Value = ((int)((end_min - start_min) / 2)).ToString(); elemList[i].Attributes["start_pos_x"].Value = ((int)(start_min / 2 + timeline_band * 5 + 10)).ToString(); String len = elemList[i].Attributes["length"].Value; //elemList[i]. int start_pos_x = int.Parse(elemList[i].Attributes["start_pos_x"].Value); int start_pos_y = int.Parse(elemList[i].Attributes["start_pos_y"].Value); string co = elemList[i].Attributes["color"].Value; //set time //start_time.Value = DateTime.Now; String activity_name = elemList[i].InnerText; float timeline_len = float.Parse(len); Button g1 = new Button(); g1.Height = 50; g1.Width = timeline_len; g1.HorizontalContentAlignment = HorizontalAlignment.Left; Canvas.SetLeft(g1, start_pos_x); Canvas.SetTop(g1, start_pos_y); //g1.Margin = new Thickness(p.X, p.Y, 0, 0); g1.Content = activity_name; g1.PreviewMouseLeftButtonUp += new MouseButtonEventHandler(canvas_MouseLeftButtonUp); g1.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(canvas_MouseLeftButtonDown); g1.PreviewMouseMove += new MouseEventHandler(canvas_MouseMove); g1.PreviewMouseDoubleClick += new MouseButtonEventHandler(canvas_MouseDoubleClick); g1.PreviewMouseRightButtonUp += new MouseButtonEventHandler(activity_click); //g1.PreviewMouseRightButtonDown += new MouseButtonEventHandler(activity_click); var bc = new BrushConverter(); g1.HorizontalContentAlignment = HorizontalAlignment.Left; if (co == "Red") { g1.Background = (Brush)bc.ConvertFrom("#FFFF6464"); } else if (co == "Blue") { g1.Background = (Brush)bc.ConvertFrom("#FF6464FF"); } else if (co == "Green") { g1.Background = (Brush)bc.ConvertFrom("#FF64FF64"); } else if (co == "Yellow") { g1.Background = (Brush)bc.ConvertFrom("#FFFFFF64"); } else { g1.Background = (Brush)bc.ConvertFrom("#FFFF64FF"); } g1.Uid = elemList[i].Attributes["id"].Value; front_canvas.Children.Add(g1); XmlDoc.Save("xml_test2.xml"); } } EditBox.Visibility = Visibility.Collapsed; }
private void SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs <System.Windows.Media.Color?> e) { if (richTextBox != null) { if (colorPicker.SelectedColor.HasValue) { BrushConverter brushConverter = new BrushConverter(); string color = colorPicker.SelectedColor.ToString(); richTextBox.Selection.ApplyPropertyValue(RichTextBox.ForegroundProperty, brushConverter.ConvertFrom(color)); } } }
void load_timeline() { ///////xml file load/////// XmlDoc.Load("xml_test2.xml"); XmlNodeList elemList = XmlDoc.SelectNodes("Root/Activity"); for (int i = 0; i < elemList.Count; i++) { /*string iString = "2005-05-05 22:12"; * DateTime oDate = DateTime.ParseExact(iString, "yyyy-MM-dd HH:mm", null); */ //MessageBox.Show(oDate.ToString("M/d H:mm")); string date_str2 = elemList[i].Attributes["start_time"].Value; DateTime date_rec = DateTime.ParseExact(date_str2, "M/d H:mm", null); TimeSpan sub = date_rec - DateTime.Now; double min_sub = sub.TotalMinutes; //if (hr_sub < 0) hr_sub++; //System.Windows.MessageBox.Show(hr_sub.ToString()); elemList[i].Attributes["start_pos_x"].Value = ((int)(min_sub / 2 + timeline_band * 5 + 10)).ToString(); String len = elemList[i].Attributes["length"].Value; //elemList[i]. int start_pos_x = int.Parse(elemList[i].Attributes["start_pos_x"].Value); int start_pos_y = int.Parse(elemList[i].Attributes["start_pos_y"].Value); string co = elemList[i].Attributes["color"].Value; String activity_name = elemList[i].InnerText; float timeline_len = float.Parse(len); Button g1 = new Button(); g1.Height = 50; g1.Width = timeline_len; g1.HorizontalContentAlignment = HorizontalAlignment.Left; Canvas.SetLeft(g1, start_pos_x); Canvas.SetTop(g1, start_pos_y); //g1.Margin = new Thickness(p.X, p.Y, 0, 0); g1.Content = activity_name; g1.PreviewMouseLeftButtonUp += new MouseButtonEventHandler(canvas_MouseLeftButtonUp); g1.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(canvas_MouseLeftButtonDown); g1.PreviewMouseMove += new MouseEventHandler(canvas_MouseMove); g1.PreviewMouseDoubleClick += new MouseButtonEventHandler(canvas_MouseDoubleClick); g1.PreviewMouseRightButtonUp += new MouseButtonEventHandler(activity_click); //g1.PreviewMouseRightButtonDown += new MouseButtonEventHandler(activity_click); var bc = new BrushConverter(); if (co == "Red") { g1.Background = (Brush)bc.ConvertFrom("#FFFF6464"); } else if (co == "Blue") { g1.Background = (Brush)bc.ConvertFrom("#FF6464FF"); } else if (co == "Green") { g1.Background = (Brush)bc.ConvertFrom("#FF64FF64"); } else if (co == "Yellow") { g1.Background = (Brush)bc.ConvertFrom("#FFFFFF64"); } else { g1.Background = (Brush)bc.ConvertFrom("#FFFF64FF"); } g1.Uid = elemList[i].Attributes["id"].Value; int num = int.Parse(elemList[i].Attributes["id"].Value); if (num >= maxnum) { maxnum = num; } maxnum++; front_canvas.Children.Add(g1); } XmlDoc.Save("xml_test2.xml"); /* * string iString = "2005-05-05 22:12"; * DateTime oDate = DateTime.ParseExact(iString, "yyyy-MM-dd HH:mm", null); * MessageBox.Show(oDate.ToString("M/d H:mm")); */ }
//to do list cancel control /////////////////// private void create_Click(object sender, RoutedEventArgs e) { //int timeline_len = int.Parse(InputTextBox2.Text); Button g1 = new Button(); g1.Height = 50; //time picker int pos_to_min = (int)(p.X - timeline_band * 5 - 10) * 2; string date_str = DateTime.Now.AddMinutes(pos_to_min).ToString("M/d HH:mm"); DateTime t1 = end_timepicker2.Value.Value; TimeSpan span = t1 - DateTime.Now.AddMinutes(pos_to_min); int timeline_len2 = (int)(span.TotalMinutes / 2); //System.Windows.MessageBox.Show(timeline_len2.ToString()); g1.HorizontalContentAlignment = HorizontalAlignment.Left; g1.Width = timeline_len2; Canvas.SetLeft(g1, p.X); Canvas.SetTop(g1, p.Y); //g1.Margin = new Thickness(p.X, p.Y, 0, 0); g1.Content = InputTextBox.Text; g1.PreviewMouseLeftButtonUp += new MouseButtonEventHandler(canvas_MouseLeftButtonUp); g1.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(canvas_MouseLeftButtonDown); g1.PreviewMouseMove += new MouseEventHandler(canvas_MouseMove); g1.PreviewMouseDoubleClick += new MouseButtonEventHandler(canvas_MouseDoubleClick); g1.PreviewMouseRightButtonUp += new MouseButtonEventHandler(activity_click); //g1.PreviewMouseRightButtonDown += new MouseButtonEventHandler(activity_click); //map position to timeline //set end time g1.Uid = maxnum.ToString(); maxnum++; var bc = new BrushConverter(); if (color.Text == "Red") { g1.Background = (Brush)bc.ConvertFrom("#FFFF6464"); } else if (color.Text == "Blue") { g1.Background = (Brush)bc.ConvertFrom("#FF6464FF"); } else if (color.Text == "Green") { g1.Background = (Brush)bc.ConvertFrom("#FF64FF64"); } else if (color.Text == "Yellow") { g1.Background = (Brush)bc.ConvertFrom("#FFFFFF64"); } else { g1.Background = (Brush)bc.ConvertFrom("#FFFF64FF"); } front_canvas.Children.Add(g1); //////save date////// XmlDoc.Load("xml_test2.xml"); XmlNode root = XmlDoc.SelectSingleNode("Root"); XmlElement elem = XmlDoc.CreateElement("Activity"); elem.SetAttribute("length", timeline_len2.ToString()); elem.SetAttribute("start_pos_x", p.X.ToString()); elem.SetAttribute("start_pos_y", p.Y.ToString()); elem.SetAttribute("id", g1.Uid); elem.SetAttribute("filelink", PathTextBox.Text); elem.SetAttribute("weblink", WebTextBox.Text); elem.SetAttribute("color", color.Text); elem.InnerText = InputTextBox.Text; elem.SetAttribute("start_time", date_str); elem.SetAttribute("end_time", end_timepicker2.Value.Value.ToString("M/d HH:mm")); root.AppendChild(elem); XmlDoc.Save("xml_test2.xml"); //g1.Name = "test"; /* * Rectangle rect = new Rectangle(); * //rect = new Rectangle(); * rect.Stroke = new SolidColorBrush(Colors.Blue); * rect.Fill = new SolidColorBrush(Colors.White); * rect.Opacity = 0.5; * rect.Width = timeline_len; * rect.Height = 50; * * //Canvas.SetLeft(rect, p.X); * //Canvas.SetTop(rect, p.Y); * g1.Children.Add(rect); * * //add label on the rectangle * Label label = new Label(); * label.Content = InputTextBox.Text; */ /*label.RenderTransform = new TranslateTransform * { * X = p.X, * Y = p.Y * };*/ //g1.Children.Add(label); //MessageBox.Show(InputTextBox.Text); InputBox.Visibility = Visibility.Collapsed; }
//Point startposition2; private void canvas_MouseDoubleClick2(object sender, MouseButtonEventArgs e) { //System.Windows.MessageBox.Show("ttt"); if (e.Source is Button) { Button ClickedRectangle = (Button)e.Source; front_canvas2.Children.Remove(ClickedRectangle); //p = Mouse.GetPosition(front_canvas); XmlDoc2.Load("xml_todo.xml"); XmlNode root2 = XmlDoc2.SelectSingleNode("Root"); XmlNodeList elemList2 = XmlDoc2.SelectNodes("Root/Activity"); XmlDoc.Load("xml_test2.xml"); XmlNode root = XmlDoc.SelectSingleNode("Root"); XmlElement elem = XmlDoc.CreateElement("Activity"); for (int i = 0; i < elemList2.Count; i++) { if (elemList2[i].Attributes["id"].Value == ClickedRectangle.Uid) { Button g1 = new Button(); g1.Height = 50; g1.Width = 60; Canvas.SetLeft(g1, 160); Canvas.SetTop(g1, 400); //g1.Margin = new Thickness(p.X, p.Y, 0, 0); g1.Content = elemList2[i].InnerText; g1.PreviewMouseLeftButtonUp += new MouseButtonEventHandler(canvas_MouseLeftButtonUp); g1.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(canvas_MouseLeftButtonDown); g1.PreviewMouseMove += new MouseEventHandler(canvas_MouseMove); g1.PreviewMouseDoubleClick += new MouseButtonEventHandler(canvas_MouseDoubleClick); g1.PreviewMouseRightButtonUp += new MouseButtonEventHandler(activity_click); g1.HorizontalContentAlignment = HorizontalAlignment.Left; g1.Uid = maxnum.ToString(); maxnum++; var bc = new BrushConverter(); g1.Background = (Brush)bc.ConvertFrom("#FFFF6464"); front_canvas.Children.Add(g1); //int pos_to_min = (int)(Canvas.GetLeft(ClickedRectangle) - timeline_band * 5 - 10) * 2; //string date_str = DateTime.Now.AddMinutes(pos_to_min).ToString("M/d HH:mm"); elem.SetAttribute("length", "60"); elem.SetAttribute("start_pos_x", "160"); elem.SetAttribute("start_pos_y", "400"); elem.SetAttribute("id", g1.Uid); elem.SetAttribute("filelink", elemList2[i].Attributes["filelink"].Value); elem.SetAttribute("weblink", elemList2[i].Attributes["weblink"].Value); elem.SetAttribute("color", "Red"); elem.InnerText = elemList2[i].InnerText; elem.SetAttribute("start_time", DateTime.Now.ToString("M/d HH:mm")); elem.SetAttribute("end_time", DateTime.Now.AddHours(2).ToString("M/d HH:mm")); root.AppendChild(elem); XmlDoc.Save("xml_test2.xml"); elemList2[i].ParentNode.RemoveChild(elemList2[i]); XmlDoc2.Save("xml_todo.xml"); } } } }
public Message(string data) { Message message; if (data != null) { message = JsonConvert.DeserializeObject <Message>(data); Text = message.Text; var bc = new BrushConverter(); switch (message.Type) { case "primary": System.Windows.Application.Current.Dispatcher.Invoke(delegate { MessageType = MessageDisplayType.MessagePrimary; IsInvitation = Visibility.Collapsed; IsResult = Visibility.Hidden; IsMessage = Visibility.Visible; IsInvitationSent = Visibility.Collapsed; Background = (SolidColorBrush)bc.ConvertFrom("#d6d6d6"); Borderbrush = (SolidColorBrush)bc.ConvertFrom("#c6c6c6"); }); break; case "secondary": System.Windows.Application.Current.Dispatcher.Invoke(delegate { MessageType = MessageDisplayType.Message; IsInvitation = Visibility.Collapsed; IsResult = Visibility.Hidden; IsMessage = Visibility.Visible; IsInvitationSent = Visibility.Collapsed; Background = (SolidColorBrush)bc.ConvertFrom("#dddddd"); Borderbrush = (SolidColorBrush)bc.ConvertFrom("#cfcfcf"); }); break; case "warning": System.Windows.Application.Current.Dispatcher.Invoke(delegate { MessageType = MessageDisplayType.MessageWarning; IsInvitation = Visibility.Collapsed; IsResult = Visibility.Hidden; IsMessage = Visibility.Visible; IsInvitationSent = Visibility.Collapsed; Background = (SolidColorBrush)bc.ConvertFrom("#fff3cd"); Borderbrush = (SolidColorBrush)bc.ConvertFrom("#ffc107"); }); break; case "info": System.Windows.Application.Current.Dispatcher.Invoke(delegate { MessageType = MessageDisplayType.MessageInfo; IsInvitation = Visibility.Collapsed; IsResult = Visibility.Hidden; IsMessage = Visibility.Visible; IsInvitationSent = Visibility.Collapsed; Background = (SolidColorBrush)bc.ConvertFrom("#d1ecf1"); Borderbrush = (SolidColorBrush)bc.ConvertFrom("#bee5eb"); }); break; case "danger": System.Windows.Application.Current.Dispatcher.Invoke(delegate { MessageType = MessageDisplayType.MessageDanger; IsInvitation = Visibility.Collapsed; IsResult = Visibility.Hidden; IsMessage = Visibility.Visible; IsInvitationSent = Visibility.Collapsed; Background = (SolidColorBrush)bc.ConvertFrom("#f8d7da"); Borderbrush = (SolidColorBrush)bc.ConvertFrom("#dc3545"); }); break; default: System.Windows.Application.Current.Dispatcher.Invoke(delegate { MessageType = MessageDisplayType.Message; IsInvitation = Visibility.Collapsed; IsResult = Visibility.Hidden; IsMessage = Visibility.Visible; IsInvitationSent = Visibility.Collapsed; Background = (SolidColorBrush)bc.ConvertFrom("#dddddd"); Borderbrush = (SolidColorBrush)bc.ConvertFrom("#cfcfcf"); }); break; } IsInvitation = Visibility.Collapsed; IsResult = Visibility.Hidden; IsMessage = Visibility.Visible; IsInvitationSent = Visibility.Collapsed; } }
public Message(string Text, MessageDisplayType MessageType) { this.Text = Text; this.MessageType = MessageType; var bc = new BrushConverter(); switch (MessageType) { case MessageDisplayType.ResultWin: IsInvitation = Visibility.Collapsed; IsResult = Visibility.Visible; IsMessage = Visibility.Hidden; IsInvitationSent = Visibility.Collapsed; Background = (SolidColorBrush)bc.ConvertFrom("#d4edda"); Borderbrush = (SolidColorBrush)bc.ConvertFrom("#28a745"); PlayAgainButtonVisible = Visibility.Collapsed; RevancheButtonVisible = Visibility.Collapsed; break; case MessageDisplayType.ResultLose: ResultButton = RevancheResult; IsInvitation = Visibility.Collapsed; IsResult = Visibility.Visible; IsMessage = Visibility.Hidden; IsInvitationSent = Visibility.Collapsed; Background = (SolidColorBrush)bc.ConvertFrom("#f8d7da"); Borderbrush = (SolidColorBrush)bc.ConvertFrom("#dc3545"); PlayAgainButtonVisible = Visibility.Collapsed; RevancheButtonVisible = Visibility.Visible; break; case MessageDisplayType.ResultDraw: ResultButton = PlayAgainResult; IsInvitation = Visibility.Collapsed; IsResult = Visibility.Visible; IsMessage = Visibility.Hidden; IsInvitationSent = Visibility.Collapsed; Background = (SolidColorBrush)bc.ConvertFrom("#fff3cd"); Borderbrush = (SolidColorBrush)bc.ConvertFrom("#ffc107"); PlayAgainButtonVisible = Visibility.Visible; RevancheButtonVisible = Visibility.Collapsed; break; case MessageDisplayType.PlayAgainInvitation: Title = PlayAgainInvitationTitle; SecondTitle = PlayAgainSecondTitle; AcceptString = PlayAgainAcc; DeclineString = PlayAgainDec; IsInvitation = Visibility.Visible; IsResult = Visibility.Hidden; IsMessage = Visibility.Hidden; IsInvitationSent = Visibility.Collapsed; Background = (SolidColorBrush)bc.ConvertFrom("#555"); Borderbrush = (SolidColorBrush)bc.ConvertFrom("#333"); break; case MessageDisplayType.RevancheInvitation: Title = RevancheInvitationTitle; SecondTitle = RevancheSecondTitle; AcceptString = RevancheAcc; DeclineString = RevancheDec; IsInvitation = Visibility.Visible; IsResult = Visibility.Hidden; IsMessage = Visibility.Hidden; IsInvitationSent = Visibility.Collapsed; Background = (SolidColorBrush)bc.ConvertFrom("#17a2b8"); Borderbrush = (SolidColorBrush)bc.ConvertFrom("#333"); break; case MessageDisplayType.PlayAgainInvitationSent: Title = PlayAgainInvitationTitle; SecondTitle = "Waiting for " + Client.OpponentsName + "s okay..."; IsInvitation = Visibility.Collapsed; IsResult = Visibility.Hidden; IsMessage = Visibility.Hidden; IsInvitationSent = Visibility.Visible; Background = (SolidColorBrush)bc.ConvertFrom("#555"); Borderbrush = (SolidColorBrush)bc.ConvertFrom("#333"); break; case MessageDisplayType.RevancheInvitationSent: Title = RevancheWaitingTitle; SecondTitle = "Waiting for " + Client.OpponentsName + "s okay..."; IsInvitation = Visibility.Collapsed; IsResult = Visibility.Hidden; IsMessage = Visibility.Hidden; IsInvitationSent = Visibility.Visible; Background = (SolidColorBrush)bc.ConvertFrom("#17a2b8"); Borderbrush = (SolidColorBrush)bc.ConvertFrom("#333"); break; case MessageDisplayType.Message: IsInvitation = Visibility.Collapsed; IsResult = Visibility.Hidden; IsMessage = Visibility.Visible; IsInvitationSent = Visibility.Collapsed; Background = (SolidColorBrush)bc.ConvertFrom("#dddddd"); Borderbrush = (SolidColorBrush)bc.ConvertFrom("#cfcfcf"); break; case MessageDisplayType.MessageDanger: IsInvitation = Visibility.Collapsed; IsResult = Visibility.Hidden; IsMessage = Visibility.Visible; IsInvitationSent = Visibility.Collapsed; Background = (SolidColorBrush)bc.ConvertFrom("#f8d7da"); Borderbrush = (SolidColorBrush)bc.ConvertFrom("#dc3545"); break; case MessageDisplayType.MessageInfo: IsInvitation = Visibility.Collapsed; IsResult = Visibility.Hidden; IsMessage = Visibility.Visible; IsInvitationSent = Visibility.Collapsed; Background = (SolidColorBrush)bc.ConvertFrom("#d1ecf1"); Borderbrush = (SolidColorBrush)bc.ConvertFrom("#bee5eb"); break; case MessageDisplayType.MessagePrimary: IsInvitation = Visibility.Collapsed; IsResult = Visibility.Hidden; IsMessage = Visibility.Visible; IsInvitationSent = Visibility.Collapsed; Background = (SolidColorBrush)bc.ConvertFrom("#d6d6d6"); Borderbrush = (SolidColorBrush)bc.ConvertFrom("#c6c6c6"); break; case MessageDisplayType.MessageWarning: IsInvitation = Visibility.Collapsed; IsResult = Visibility.Hidden; IsMessage = Visibility.Visible; IsInvitationSent = Visibility.Collapsed; Background = (SolidColorBrush)bc.ConvertFrom("#fff3cd"); Borderbrush = (SolidColorBrush)bc.ConvertFrom("#ffc107"); break; default: IsInvitation = Visibility.Collapsed; IsResult = Visibility.Hidden; IsMessage = Visibility.Visible; IsInvitationSent = Visibility.Collapsed; Background = (SolidColorBrush)bc.ConvertFrom("#dddddd"); Borderbrush = (SolidColorBrush)bc.ConvertFrom("#cfcfcf"); break; } }
private void setButtonHoverOutEvent(Grid container) { BrushConverter bc = new BrushConverter(); container.Background = (Brush)bc.ConvertFrom("#03FFFFFF"); }
public void GotRecentGames(RecentGames result) { GameStats.Clear(); result.GameStatistics.Sort((s1, s2) => s2.CreateDate.CompareTo(s1.CreateDate)); foreach (PlayerGameStats Game in result.GameStatistics) { Game.QueueType = Client.TitleCaseString(Game.QueueType.Replace("ODIN", "Dominion").Replace("UNRANKED", "").Replace("_5x5", "").Replace("_", " ")).Replace("Aram", "ARAM").Trim(); MatchStats Match = new MatchStats(); foreach (RawStat Stat in Game.Statistics) { var type = typeof(MatchStats); string fieldName = Client.TitleCaseString(Stat.StatType.Replace('_', ' ')).Replace(" ", ""); var f = type.GetField(fieldName); f.SetValue(Match, Stat.Value); } Match.Game = Game; GameStats.Add(Match); } Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { GamesListView.Items.Clear(); BlueListView.Items.Clear(); ItemsListView.Items.Clear(); PurpleListView.Items.Clear(); GameStatsListView.Items.Clear(); foreach (MatchStats stats in GameStats) { RecentGameOverview item = new RecentGameOverview(); champions GameChamp = champions.GetChampion((int)Math.Round(stats.Game.ChampionId)); item.ChampionImage.Source = GameChamp.icon; item.ChampionNameLabel.Content = GameChamp.displayName; item.ScoreLabel.Content = string.Format("{0}/{1}/{2} ({3})", stats.ChampionsKilled, stats.NumDeaths, stats.Assists, stats.Game.QueueType); item.MapLabel.Content = BaseMap.GetMap(stats.Game.GameMapId).DisplayName; item.DateLabel.Content = stats.Game.CreateDate; item.IPEarnedLabel.Content = "+" + stats.Game.IpEarned + " IP"; item.PingLabel.Content = stats.Game.UserServerPing + "ms"; BrushConverter bc = new BrushConverter(); Brush brush = (Brush)bc.ConvertFrom("#FF609E74"); if (stats.Lose == 1) { brush = (Brush)bc.ConvertFrom("#FF9E6060"); } item.GridView.Background = brush; item.GridView.Width = 250; GamesListView.Items.Add(item); } })); }
public static Brush HexToColor(String color) { BrushConverter bc = new BrushConverter(); return((Brush)bc.ConvertFrom(color)); }
private void btnSettings_Click(object sender, RoutedEventArgs e) { WindowSettings frm = new WindowSettings(); Session.IsSetColor = false; frm.ShowDialog(); try { if (Session.IsSetColor) { if (Session.IsBgColor) { bc = new BrushConverter(); this.Background = (Brush)bc.ConvertFrom(Session.BgColorCode); } else { bc = new BrushConverter(); this.Background = defaultBrush; string bgColor = Session.SelectedBgPath; if (bgColor.Contains("bg1.jpg")) { Image image = new Image(); image.Source = new BitmapImage(ResourceAccessor.Get("images/bg/bg1.jpg")); imgBrush.ImageSource = image.Source; } else if (bgColor.Contains("bg2.jpg")) { Image image = new Image(); image.Source = new BitmapImage(ResourceAccessor.Get("images/bg/bg2.jpg")); imgBrush.ImageSource = image.Source; } else if (bgColor.Contains("bg3.jpg")) { Image image = new Image(); image.Source = new BitmapImage(ResourceAccessor.Get("images/bg/bg3.jpg")); imgBrush.ImageSource = image.Source; } } imgClose.Source = Session.IsButtonColorBlack ? new BitmapImage(ResourceAccessor.Get("images/icon/cancel-button.png")) : imgClose.Source = new BitmapImage(ResourceAccessor.Get("images/icon/cancel-button-white.png")); imgMinimize.Source = Session.IsButtonColorBlack ? new BitmapImage(ResourceAccessor.Get("images/icon/minimize.png")) : imgMinimize.Source = new BitmapImage(ResourceAccessor.Get("images/icon/minimize-white.png")); if (Session.IsButtonColorBlack) { if (WindowState == WindowState.Maximized) { imgMaximize.Source = new BitmapImage(ResourceAccessor.Get("images/icon/expand-button.png")); } else { imgMaximize.Source = new BitmapImage(ResourceAccessor.Get("images/icon/compress-square.png")); } } else { if (WindowState == WindowState.Maximized) { imgMaximize.Source = new BitmapImage(ResourceAccessor.Get("images/icon/expand-button-white.png")); } else { imgMaximize.Source = new BitmapImage(ResourceAccessor.Get("images/icon/compress-square-white.png")); } } imgReset.Source = Session.IsButtonColorBlack ? new BitmapImage(ResourceAccessor.Get("images/icon/reset.png")) : imgReset.Source = new BitmapImage(ResourceAccessor.Get("images/icon/white-reset.png")); if (Session.IsButtonColorBlack) { if (timerState == TimerState.Play) { imgPlayPause.Source = new BitmapImage(ResourceAccessor.Get("images/icon/play.png")); } else { imgPlayPause.Source = new BitmapImage(ResourceAccessor.Get("images/icon/pause.png")); } } else { if (timerState == TimerState.Play) { imgPlayPause.Source = new BitmapImage(ResourceAccessor.Get("images/icon/white-play.png")); } else { imgPlayPause.Source = new BitmapImage(ResourceAccessor.Get("images/icon/white-pause.png")); } } imgSetTimer.Source = Session.IsButtonColorBlack ? new BitmapImage(ResourceAccessor.Get("images/icon/set-timer.png")) : imgSetTimer.Source = new BitmapImage(ResourceAccessor.Get("images/icon/white-set-timer.png")); } bc = new BrushConverter(); lblRemainingTime.Foreground = (Brush)bc.ConvertFrom(Session.RemaniningTimeColorCode); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
public LoginPage() { InitializeComponent(); Change(); Client.donepatch = true; Client.patching = false; Version.TextChanged += WaterTextbox_TextChanged; if (Client.Version == "4.20.1" || Client.Version == "0.0.0") { Client.Version = "4.21.14"; } bool x = Settings.Default.DarkTheme; if (!x) { var bc = new BrushConverter(); HideGrid.Background = (Brush)bc.ConvertFrom("#B24F4F4F"); LoggingInProgressRing.Foreground = (Brush)bc.ConvertFrom("#FFFFFFFF"); } //#B2C8C8C8 Version.Text = Client.Version; if (!Settings.Default.DisableLoginMusic) { SoundPlayer.Source = new Uri(Path.Combine(Client.ExecutingDirectory, "Client", "Login.mp3")); SoundPlayer.Play(); Sound.IsChecked = false; } else { Sound.IsChecked = true; } if (!String.IsNullOrEmpty(Settings.Default.devKeyLoc)) { if (Client.Authenticate(Settings.Default.devKeyLoc)) { Client.Dev = true; devKeyLabel.Content = "Dev"; } } if (Settings.Default.LoginPageImage == "") { LoginPic.Source = new Uri(Path.Combine(Client.ExecutingDirectory, "Client", "Login.mp4")); LoginPic.LoadedBehavior = MediaState.Manual; LoginPic.MediaEnded += LoginPic_MediaEnded; SoundPlayer.MediaEnded += SoundPlayer_MediaEnded; LoginPic.Play(); } else { if ( File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", Settings.Default.LoginPageImage.Replace("\r\n", "")))) { LoginImage.Source = new BitmapImage( new Uri( Path.Combine(Client.ExecutingDirectory, "Assets", "champions", Settings.Default.LoginPageImage), UriKind.Absolute)); } } Video.IsChecked = false; //Get client data after patcher completed Client.SQLiteDatabase = new SQLiteConnection(Path.Combine(Client.ExecutingDirectory, Client.sqlite)); Client.Champions = (from s in Client.SQLiteDatabase.Table <champions>() orderby s.name select s).ToList(); foreach (champions c in Client.Champions) { var source = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", c.iconPath), UriKind.Absolute); c.icon = new BitmapImage(source); Debugger.Log(0, "Log", "Requesting :" + c.name + " champ"); try { Champions.InsertExtraChampData(c); //why was this ever here? all of the needed info is already in the sqlite file } catch { Client.Log("error, file not found", "NotFound"); } } Client.ChampionSkins = (from s in Client.SQLiteDatabase.Table <championSkins>() orderby s.name select s).ToList(); Client.ChampionAbilities = (from s in Client.SQLiteDatabase.Table <championAbilities>() //Needs Fixed orderby s.name select s).ToList(); Client.SearchTags = (from s in Client.SQLiteDatabase.Table <championSearchTags>() orderby s.id select s).ToList(); Client.Keybinds = (from s in Client.SQLiteDatabase.Table <keybindingEvents>() orderby s.id select s).ToList(); Client.Items = Items.PopulateItems(); Client.Masteries = Masteries.PopulateMasteries(); Client.Runes = Runes.PopulateRunes(); //Retrieve latest client version /* * SWFReader reader = new SWFReader("ClientLibCommon.dat"); * foreach (Tag tag in reader.Tags) * { * if (tag is DoABC) * { * DoABC abcTag = (DoABC)tag; * if (abcTag.Name.Contains("riotgames/platform/gameclient/application/Version")) * { * var str = System.Text.Encoding.Default.GetString(abcTag.ABCData); * //Ugly hack ahead - turn back now! (http://pastebin.com/yz1X4HBg) * string[] firstSplit = str.Split((char)6); * string[] secondSplit = firstSplit[0].Split((char)18); * //Client.Version = secondSplit[1]; * } * } * }*/ if (!String.IsNullOrWhiteSpace(Settings.Default.SavedUsername)) { RememberUsernameCheckbox.IsChecked = true; LoginUsernameBox.Text = Settings.Default.SavedUsername; } if (!String.IsNullOrWhiteSpace(Settings.Default.SavedPassword)) { SHA1 sha = new SHA1CryptoServiceProvider(); RememberPasswordCheckbox.IsChecked = true; LoginPasswordBox.Password = Settings.Default.SavedPassword.DecryptStringAES( sha.ComputeHash(Encoding.UTF8.GetBytes(Settings.Default.Guid)).ToString()); } if (!String.IsNullOrWhiteSpace(Settings.Default.Region)) { RegionComboBox.SelectedValue = Settings.Default.Region; } invisibleLoginCheckBox.IsChecked = Settings.Default.incognitoLogin; var uriSource = new Uri( Path.Combine(Client.ExecutingDirectory, "Assets", "champions", champions.GetChampion(Client.LatestChamp).splashPath), UriKind.Absolute); //LoginImage.Source = new BitmapImage(uriSource);//*/ if (String.IsNullOrWhiteSpace(Settings.Default.SavedPassword) || String.IsNullOrWhiteSpace(Settings.Default.Region) || !Settings.Default.AutoLogin) { return; } AutoLoginCheckBox.IsChecked = true; LoginButton_Click(null, null); }
private void StackPanel_MouseEnter(object sender, MouseEventArgs e) { BrushConverter bc = new BrushConverter(); (sender as StackPanel).Background = (Brush)bc.ConvertFrom("#ededed"); }
public Grid makeQuestionGrid(int number) { //intialize grid Grid question_grid = new Grid(); question_grid.Name = "question_g_" + number; BrushConverter bc = new BrushConverter(); question_grid.Background = (Brush)bc.ConvertFrom("#FFC2C6C9"); question_grid.Margin = new Thickness(10, 10, 10, 0); System.Windows.Media.Effects.DropShadowEffect shadowEffect = new System.Windows.Media.Effects.DropShadowEffect(); shadowEffect.BlurRadius = 14; shadowEffect.Opacity = 0.5; question_grid.Effect = shadowEffect; grid_num = new TextBlock(); grid_num.Text = "Question " + (number) + " :"; grid_num.Foreground = Brushes.Black; question_grid.Children.Add(grid_num); //set cloumn ColumnDefinition col = new ColumnDefinition(); col.Width = new GridLength(4, GridUnitType.Star); question_grid.ColumnDefinitions.Add(col); col = new ColumnDefinition(); col.Width = new GridLength(); question_grid.ColumnDefinitions.Add(col); col = new ColumnDefinition(); col.Width = new GridLength(5, GridUnitType.Star); question_grid.ColumnDefinitions.Add(col); // textbox TextBox question_txt = new TextBox(); question_txt.Margin = new Thickness(10, 30, 10, 10); question_txt.Height = 70; question_txt.FontSize = 20; question_txt.TextWrapping = TextWrapping.Wrap; Grid.SetColumn(question_txt, 0); question_txt.Name = "question_txt_" + number; controls.Add(question_txt.Name, question_txt); question_grid.Children.Add(question_txt); //combobox ComboBox numOfAnmsers_cb = new ComboBox(); numOfAnmsers_cb.Margin = new Thickness(10); numOfAnmsers_cb.Height = 30; Grid.SetColumn(numOfAnmsers_cb, 1); numOfAnmsers_cb.Name = "question_cb_" + number; for (int i = 2; i <= 5; i++) { numOfAnmsers_cb.Items.Add(i); } numOfAnmsers_cb.SelectionChanged += new SelectionChangedEventHandler(makeAnswersGrid); question_grid.Children.Add(numOfAnmsers_cb); controls.Add(numOfAnmsers_cb.Name, numOfAnmsers_cb); controls.Add(question_grid.Name, question_grid); return(question_grid); }
void setter() { var bc = new BrushConverter(); //Stack Panels StackPanel motherPanel = new StackPanel { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Center }; for (int x = 0; x < SetterForCandidates.listID.Count; x++) { StackPanel sp = new StackPanel { Orientation = Orientation.Horizontal, Width = Double.NaN, Margin = new System.Windows.Thickness(20), Background = new SolidColorBrush(Colors.White), HorizontalAlignment = HorizontalAlignment.Center }; StackPanel spChild = new StackPanel { Margin = new System.Windows.Thickness(15), Orientation = Orientation.Vertical, }; StackPanel spSuperChild = new StackPanel { Orientation = Orientation.Horizontal }; StackPanel spGrandChild = new StackPanel { Orientation = Orientation.Vertical, Margin = new System.Windows.Thickness(10) }; StackPanel spGrandChild2 = new StackPanel { Orientation = Orientation.Vertical, Margin = new System.Windows.Thickness(10) }; StackPanel spSuperChild2 = new StackPanel { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; //Button Button btnVote = new Button { Width = 115, Height = 35, Background = (Brush)bc.ConvertFrom("#FF3827B4"), Content = "Vote", FontSize = 12, Foreground = new SolidColorBrush(Colors.White), VerticalAlignment = VerticalAlignment.Bottom, Margin = new System.Windows.Thickness(5), BorderThickness = new System.Windows.Thickness(0) }; //TextBlocks TextBlock textName = new TextBlock { Name = "txtName", Text = SetterForCandidates.listName[x] + "\t(" + SetterForCandidates.listNickname[x] + ")", HorizontalAlignment = HorizontalAlignment.Center, Margin = new System.Windows.Thickness(5), FontSize = 14, FontWeight = FontWeights.Medium }; TextBlock textPartylist = new TextBlock { Name = "txtPartylist", Text = SetterForCandidates.listPartylist[x], HorizontalAlignment = HorizontalAlignment.Center, FontSize = 13, FontWeight = FontWeights.Regular }; TextBlock textAchievement = new TextBlock { Text = "Achievement", HorizontalAlignment = HorizontalAlignment.Left, FontWeight = FontWeights.Light, FontSize = 14, Margin = new System.Windows.Thickness(5), Foreground = (Brush)bc.ConvertFrom("#FF3827B4") }; TextBlock textListAchievement = new TextBlock { // Text = SetterForCandidates.titleAchievement[x].ToString(), HorizontalAlignment = HorizontalAlignment.Left, FontWeight = FontWeights.Regular, Margin = new System.Windows.Thickness(5), Foreground = new SolidColorBrush(Colors.Black) }; TextBlock textPlatform = new TextBlock { Text = "Platform", HorizontalAlignment = HorizontalAlignment.Left, FontWeight = FontWeights.Light, FontSize = 14, Margin = new System.Windows.Thickness(5), Foreground = (Brush)bc.ConvertFrom("#FF3827B4") }; TextBlock textLisPlatform = new TextBlock { // Text = "Gold award, Annual Report: Educational School", HorizontalAlignment = HorizontalAlignment.Left, FontWeight = FontWeights.Regular, Margin = new System.Windows.Thickness(5), Foreground = new SolidColorBrush(Colors.Black) }; motherPanel.Children.Add(sp); sp.Children.Add(spChild); spChild.Children.Add(textName); spChild.Children.Add(textPartylist); spChild.Children.Add(spSuperChild); spChild.Children.Add(spSuperChild2); spSuperChild.Children.Add(spGrandChild); spGrandChild.Children.Add(textAchievement); spGrandChild.Children.Add(textListAchievement); spSuperChild2.Children.Add(btnVote); spSuperChild.Children.Add(spGrandChild2); spGrandChild2.Children.Add(textPlatform); //for candidate achievement list for (int y = 0; y < list.Count; y++) { if (list[y].Equals("|")) { list.RemoveAt(y); break; } textListAchievement.Text += list[y].ToString() + "\r"; list[y] = ""; } while (list.Remove("")) { } //for candidate platform list for (int y = 0; y < list2.Count; y++) { if (list2[y].Equals("|")) { list2.RemoveAt(y); break; } textLisPlatform.Text += list2[y].ToString() + "\r"; list2[y] = ""; } while (list2.Remove("")) { } //for buttons btnVote.Click += btn_Click; btnVote.Tag = SetterForCandidates.listName[x].ToString(); spGrandChild2.Children.Add(textLisPlatform); } SetterForCandidates.listID.Clear(); SetterForCandidates.listName.Clear(); SetterForCandidates.listPartylist.Clear(); SetterForCandidates.listNickname.Clear(); SetterForCandidates.listAchievement.Clear(); SetterForCandidates.listPlatform.Clear(); Principal.Children.Add(motherPanel); }
public void makeAnswersGrid(object sender, EventArgs e) { ComboBox comboBox = (ComboBox)sender; Grid grid = (Grid)comboBox.Parent; StackPanel answer_substack = (StackPanel)controls["answer_stack_" + comboBox.Name.Split('_')[comboBox.Name.Split('_').Length - 1]]; //get old answers string[] oldAnswers = new string[answer_substack.Children.Count]; TextBox answer_txt; RadioButton answer_radio; int oldAnswer = 0; bool isAnswerSelected = false; for (int i = 0; i < answer_substack.Children.Count; i++) { answer_txt = (TextBox)controls["answer_txt_" + comboBox.Name.Split('_')[comboBox.Name.Split('_').Length - 1] + "_" + (i + 1)]; answer_radio = (RadioButton)controls["answer_rb_" + comboBox.Name.Split('_')[comboBox.Name.Split('_').Length - 1] + "_" + (i + 1)]; oldAnswers[i] = answer_txt.Text; if (answer_radio.IsChecked == true) { oldAnswer = i; } } answer_substack.Children.Clear(); int selectednumber = Convert.ToInt16(comboBox.SelectedItem);//get selected number string[] question_num = grid.Name.Split('_');//get question number for (int i = 0; i < selectednumber; i++) { Grid g = new Grid(); g.Name = "answer_g_" + (question_num[2]) + (i + 1); g.Margin = new Thickness(10, 0, 10, 10); BrushConverter bc = new BrushConverter(); g.Background = (Brush)bc.ConvertFrom("#FFC2C6C9"); ColumnDefinition col = new ColumnDefinition(); col.Width = new GridLength(5, GridUnitType.Star); g.ColumnDefinitions.Add(col); col = new ColumnDefinition(); col.Width = new GridLength(17, GridUnitType.Star); g.ColumnDefinitions.Add(col); RadioButton rb = new RadioButton(); rb.Margin = new Thickness(10); rb.Name = "answer_rb_" + (question_num[2]) + "_" + (i + 1); rb.GroupName = "question_rbg_" + (question_num[2]); rb.Content = alpha[i]; rb.FontSize = 16; if (i == oldAnswer) { rb.IsChecked = true; isAnswerSelected = true; } g.Children.Add(rb); Grid.SetColumn(rb, 0); TextBox txt = new TextBox(); txt.Name = "answer_txt_" + (question_num[2]) + "_" + (i + 1); txt.Margin = new Thickness(10); if (i < oldAnswers.Length) { txt.Text = oldAnswers[i]; } // answers_txts.Add(txt); g.Children.Add(txt); Grid.SetColumn(txt, 1); Console.WriteLine(txt.Name); controls[txt.Name] = txt; controls[rb.Name] = rb; controls[g.Name] = g; answer_substack.Margin = new Thickness(0, 10, 0, 0); answer_substack.Children.Add(g); } if (!isAnswerSelected) { ((RadioButton)controls["answer_rb_" + comboBox.Name.Split('_')[comboBox.Name.Split('_').Length - 1] + "_1"]).IsChecked = true; } }
internal void PingElapsed(object sender, ElapsedEventArgs e) { //TeambuilderCorrect(); Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { var keys = new List <Button>(ButtonTimers.Keys); foreach (Button pair in keys) { ButtonTimers[pair]++; TimeSpan time = TimeSpan.FromSeconds(ButtonTimers[pair]); var realButton = (Button)pair.Tag; realButton.Content = string.Format("{0:D2}:{1:D2} Re-Click To Leave", time.Minutes, time.Seconds); } })); if (i++ < 10) //Ping every 10 seconds { return; } i = 0; if (!Client.IsOnPlayPage) { return; } Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async() => { if (!RunOnce) { RunOnce = true; WaitingForQueues.Visibility = Visibility.Visible; for (int b = 0; b < 3; b++) { seperators[b] = new GameSeperator(QueueListView) { Height = 80 }; switch (b) { case 0: seperators[b].QueueLabel.Content = "Bot Queues"; seperators[b].Tag = "Bot"; break; case 1: seperators[b].QueueLabel.Content = "Normal Queues"; seperators[b].Tag = "Normal"; break; case 2: seperators[b].QueueLabel.Content = "Ranked Queues"; seperators[b].Tag = "Ranked"; break; } QueueListView.Items.Add(seperators[b]); } //Ping var bc = new BrushConverter(); Brush brush = null; try { double pingAverage = HighestPingTime(Client.Region.PingAddresses); PingLabel.Content = Math.Round(pingAverage) + "ms"; if (pingAverage == 0) { PingLabel.Content = "Timeout"; } if (pingAverage == -1) { PingLabel.Content = "Ping not enabled for this region"; } if (pingAverage > 999 || pingAverage < 1) { brush = (Brush)bc.ConvertFrom("#FFFF6767"); } if (pingAverage > 110 && pingAverage < 999) { brush = (Brush)bc.ConvertFrom("#FFFFD667"); } if (pingAverage < 110 && pingAverage > 1) { brush = (Brush)bc.ConvertFrom("#FF67FF67"); } } catch (NotImplementedException ex) { PingLabel.Content = "Ping not enabled for this region"; brush = (Brush)bc.ConvertFrom("#FFFF6767"); Client.Log(ex.Message); } catch (Exception ex) { PingLabel.Content = "Error occured while pinging"; brush = (Brush)bc.ConvertFrom("#FFFF6767"); Client.Log(ex.Message); } finally { PingRectangle.Fill = brush; } //Queues GameQueueConfig[] openQueues = Client.Queues; Array.Sort(openQueues, (config, config2) => string.Compare(config.CacheName, config2.CacheName, StringComparison.Ordinal)); foreach (GameQueueConfig config in openQueues) { QueueButtonConfig settings = new QueueButtonConfig(); settings.GameQueueConfig = config; if (config.CacheName.Contains("INTRO")) { settings.BotLevel = "INTRO"; } else if (config.CacheName.Contains("EASY") || config.Id == 25 || config.Id == 52) { settings.BotLevel = "EASY"; } else if (config.CacheName.Contains("MEDIUM")) { settings.BotLevel = "MEDIUM"; } var item = new JoinQueue { Height = 80, QueueButton = { Tag = settings } }; item.QueueButton.Click += QueueButton_Click; //item.QueueButton.IsEnabled = false; item.QueueButton.Content = "Queue (Beta)"; item.TeamQueueButton.Tag = settings; item.TeamQueueButton.Click += TeamQueueButton_Click; item.QueueLabel.Content = Client.InternalQueueToPretty(config.CacheName); item.QueueId = config.Id; QueueInfo t = await RiotCalls.GetQueueInformation(config.Id); item.AmountInQueueLabel.Content = "People in queue: " + t.QueueLength; TimeSpan time = TimeSpan.FromMilliseconds(t.WaitTime); string answer = string.Format("{0:D2}m:{1:D2}s", time.Minutes, time.Seconds); item.WaitTimeLabel.Content = "Avg Wait Time: " + answer; if (config.TypeString == "BOT" || config.TypeString == "BOT_3x3") { seperators[0].Add(item); } else if (config.TypeString.StartsWith("RANKED_")) { seperators[2].Add(item); } else { seperators[1].Add(item); } switch (Client.InternalQueueToPretty(config.CacheName)) { case "Teambuilder 5v5 Beta (In Dev. Do Not Play)": item.QueueButton.IsEnabled = false; //item.TeamQueueButton.IsEnabled = false; break; case "Ranked Team 5v5": item.QueueButton.IsEnabled = false; break; case "Ranked Team 3v3": item.QueueButton.IsEnabled = false; break; } if (item.QueueId == 25 || item.QueueId == 52) //TT and Dominion: easy and medium bots have the same QueueId { settings.BotLevel = "MEDIUM"; var item2 = new JoinQueue { Height = 80, QueueButton = { Tag = settings } }; item2.QueueButton.Click += QueueButton_Click; item2.QueueButton.Content = "Queue (Beta)"; item2.TeamQueueButton.Tag = settings; item2.TeamQueueButton.Click += TeamQueueButton_Click; item2.QueueId = config.Id; item2.QueueLabel.Content = item.QueueLabel.Content.ToString().Replace("Easy", "Medium"); item2.AmountInQueueLabel.Content = "People in queue: " + t.QueueLength; item2.WaitTimeLabel.Content = "Avg Wait Time: " + answer; seperators[0].Add(item2); if (!Client.Dev) { item2.QueueButton.IsEnabled = false; } } currentAmount++; if (currentAmount != openQueues.Length) { continue; } WaitingForQueues.Visibility = Visibility.Hidden; foreach (GameSeperator seperator in seperators) { seperator.UpdateLabels(); } DoneLoading = true; } } else if (seperators[seperators.Length - 1] != null) { foreach (GameSeperator seperator in seperators) { seperator.UpdateLabels(); } } })); }
private void dgTagResults_LoadingRow(object sender, DataGridRowEventArgs e) { try { if (chkEnableTagAging) { var data = (TagReadRecord)e.Row.DataContext; TimeSpan difftimeInSeconds = (DateTime.UtcNow - data.TimeStamp.ToUniversalTime()); BrushConverter brush = new BrushConverter(); if (enableTagAgingOnRead) { if (difftimeInSeconds.TotalSeconds < 12) { switch (Math.Round(difftimeInSeconds.TotalSeconds).ToString()) { case "5": e.Row.Background = (Brush)brush.ConvertFrom("#FFEEEEEE"); break; case "6": e.Row.Background = (Brush)brush.ConvertFrom("#FFD3D3D3"); break; case "7": e.Row.Background = (Brush)brush.ConvertFrom("#FFCCCCCC"); break; case "8": e.Row.Background = (Brush)brush.ConvertFrom("#FFC3C3C3"); break; case "9": e.Row.Background = (Brush)brush.ConvertFrom("#FFBBBBBB"); break; case "10": e.Row.Background = (Brush)brush.ConvertFrom("#FFA1A1A1"); break; case "11": e.Row.Background = new SolidColorBrush(Colors.Gray); break; } Dispatcher.BeginInvoke(new System.Threading.ThreadStart(delegate() { RetainAgingOnStopRead(data.SerialNumber.ToString(), e.Row.Background); })); } else { e.Row.Background = (Brush)brush.ConvertFrom("#FF888888"); Dispatcher.BeginInvoke(new System.Threading.ThreadStart(delegate() { RetainAgingOnStopRead(data.SerialNumber.ToString(), e.Row.Background); })); } } else { if (tagagingColourCache.ContainsKey(data.SerialNumber.ToString())) { e.Row.Background = tagagingColourCache[data.SerialNumber.ToString()]; } else { e.Row.Background = Brushes.White; } } } } catch { } }
public static void addColorToCell(DataGridCell dgc, string color) { BrushConverter bc = new BrushConverter(); dgc.Background = (Brush)bc.ConvertFrom(color); //Конвертирование строки в цвет }
private void SetDefaultSettings() { // Fields for password change foreach (Control c in changePasswordControlsList) { c.Visibility = Visibility.Hidden; c.IsEnabled = true; } OldPassword.Text = "Old password ..."; var bc = new BrushConverter(); OldPassword.Foreground = (Brush)bc.ConvertFrom("#CC119EDA"); OldPassword.FontStyle = FontStyles.Italic; NewPassword1.Text = "New password ..."; NewPassword1.Foreground = (Brush)bc.ConvertFrom("#CC119EDA"); NewPassword1.FontStyle = FontStyles.Italic; NewPassword2.Text = "New password ..."; NewPassword2.Foreground = (Brush)bc.ConvertFrom("#CC119EDA"); NewPassword2.FontStyle = FontStyles.Italic; OldPassword_NoIcon.Visibility = Visibility.Hidden; OldPassword_YesIcon.Visibility = Visibility.Hidden; NewPassword1_NoIcon.Visibility = Visibility.Hidden; NewPassword1_YesIcon.Visibility = Visibility.Hidden; NewPassword2_NoIcon.Visibility = Visibility.Hidden; NewPassword2_YesIcon.Visibility = Visibility.Hidden; // Confirm and Storno Button ConfirmButton.Visibility = Visibility.Hidden; ConfirmButton.IsEnabled = true; StornoButton.Visibility = Visibility.Hidden; StornoButton.IsEnabled = true; // Fields for Add, Update foreach (Control c in userControlsList) { c.Visibility = Visibility.Hidden; c.IsEnabled = true; } NameTextBox.Text = ""; SurnameTextBox.Text = ""; EmailTextBox.Text = "@"; PhoneTextBox.Text = "+420"; ValidTextBox.Text = "Yes"; LoginTextBox.Text = ""; UserTypeComboBox.SelectedItem = UserTypeComboBox_Official; OfficialSubTypeComboBox.SelectedItem = OfficialSubTypeComboBox_Junior; CustomerSubTypeComboBox.SelectedItem = CustomerSubTypeComboBox_Person; NameTextBox_NoIcon.Visibility = Visibility.Hidden; SurnameTextBox_NoIcon.Visibility = Visibility.Hidden; EmailTextBox_NoIcon.Visibility = Visibility.Hidden; PhoneTextBox_NoIcon.Visibility = Visibility.Hidden; StreetTextBox_NoIcon.Visibility = Visibility.Hidden; StreetNumberTextBox_NoIcon.Visibility = Visibility.Hidden; CityTextBox_NoIcon.Visibility = Visibility.Hidden; PostalCodeTextBox_NoIcon.Visibility = Visibility.Hidden; LoginTextBox_NoIcon.Visibility = Visibility.Hidden; foreach (Control c in addressControlsList) { c.Visibility = Visibility.Hidden; c.IsEnabled = true; } StreetTextBox.Text = ""; StreetNumberTextBox.Text = ""; CityTextBox.Text = ""; PostalCodeTextBox.Text = ""; CountryTextBox.Text = ""; EditModeButton.Visibility = Visibility.Hidden; EditModeButton.IsEnabled = true; UpdateUserButton.Visibility = Visibility.Hidden; UpdateUserButton.IsEnabled = true; CreateCustomerButton.Visibility = Visibility.Hidden; CreateCustomerButton.IsEnabled = true; LoginLabel.Content = "Login"; // All Users view AllCustomersListView.Visibility = Visibility.Hidden; AllCustomersListView.IsEnabled = true; ViewDetails.Visibility = Visibility.Hidden; ViewDetails.IsEnabled = true; // Search SearchTextBox.Visibility = Visibility.Hidden; SearchTextBox.Text = "Enter user name ..."; SearchTextBox.FontStyle = FontStyles.Italic; SearchButton.Visibility = Visibility.Hidden; CustomerNotFoundLabel.Visibility = Visibility.Hidden; // Products AllProductsListView.Visibility = Visibility.Hidden; ListOfProductsLabel.Visibility = Visibility.Hidden; AllProductsListView.ItemsSource = null; }
public void afficher(List <tache> list) { foreach (tache con in list) { Grid Item = new Grid(); //header StackPanel big = new StackPanel(); big.Orientation = Orientation.Horizontal; big.HorizontalAlignment = HorizontalAlignment.Left; big.Width = 1200; /*StackPanel info = new StackPanel(); * info.Orientation = Orientation.Horizontal; * info.Width = 670; * /*Label lbl = new Label(); * lbl.Content = con.get_des(); * CheckBox check = new CheckBox(); * info.Children.Add(check); * check.Margin = new Thickness(5, 10, 5, 0); * info.Children.Add(lbl);*/ Image prio = new Image(); prio.Margin = new Thickness(10, -132, 5, 0); prio.Height = 20; prio.Width = 20; switch (con.get_prio()) { case "Elevée": prio.Source = new BitmapImage(new Uri("prio_elevé.png", UriKind.Relative)); break; case "Moyenne": prio.Source = new BitmapImage(new Uri("pro.png", UriKind.Relative)); break; case "Faible": prio.Source = new BitmapImage(new Uri("prio_faible.png", UriKind.Relative)); break; } StackPanel info = new StackPanel(); info.Orientation = Orientation.Horizontal; info.Width = 470; Label lbl = new Label(); lbl.Content = con.get_des(); CheckBox check = new CheckBox(); info.Children.Add(check); info.Children.Add(prio); check.Margin = new Thickness(17, 12, 5, 0); info.Children.Add(lbl); //add some buttons to header //modify StackPanel option = new StackPanel(); option.Orientation = Orientation.Horizontal; option.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; option.Width = 80; Button modif = new Button(); Image ch = new Image(); ch.Source = new BitmapImage(new Uri("modif.png", UriKind.Relative)); modif.Content = ch; modif.Height = 30; modif.Width = 30; modif.Background = null; modif.Click += new RoutedEventHandler(modif_Click); option.Children.Add(modif); //delete button Button delete = new Button(); Image del = new Image(); del.Source = new BitmapImage(new Uri("delete1.png", UriKind.Relative)); delete.Click += new RoutedEventHandler(delete_Click); delete.Content = del; delete.Height = 30; delete.Width = 30; delete.Background = null; option.Children.Add(delete); big.Children.Add(info); //stack in the middle /* StackPanel mid = new StackPanel(); * mid.Width = 500; * big.Children.Add(mid);*/ option.Margin = new Thickness(600, -130, 0, 0); DropShadowBitmapEffect shadow = new DropShadowBitmapEffect(); shadow.Direction = 320; shadow.Opacity = 0.6; Item.BitmapEffect = shadow; BrushConverter bc = new BrushConverter(); Item.Background = (Brush)bc.ConvertFrom("#FFFFFF"); big.Children.Add(option); Item.Children.Add(big); //grid of expander StackPanel bigstack = new StackPanel(); bigstack.Width = 700; //priorité /*StackPanel stack1 = new StackPanel(); * stack1.Orientation = Orientation.Horizontal; * Label symb1 = new Label(); * symb1.Content = "Priorité :"; ; * symb1.Height = 30; * symb1.Width = 122; * Label lbl1 = new Label(); * lbl1.Content = con.get_prio(); * stack1.Children.Add(symb1); * stack1.Children.Add(lbl1); * stack1.Margin = new Thickness(0, 30, 0, 0); * bigstack.Children.Add(stack1);*/ //etat StackPanel stack2 = new StackPanel(); stack2.Orientation = Orientation.Horizontal; Label symb2 = new Label(); symb2.Content = "Etat :";; symb2.Height = 30; symb2.Width = 122; Label lbl2 = new Label(); lbl2.Content = con.get_etat(); stack2.Children.Add(symb2); stack2.Children.Add(lbl2); stack2.Margin = new Thickness(0, 30, 0, 0); bigstack.Children.Add(stack2); //temps StackPanel stack3 = new StackPanel(); stack3.Orientation = Orientation.Horizontal; Label symb3 = new Label(); symb3.Content = "Date :";; symb3.Height = 30; symb3.Width = 122; Label lbl3 = new Label(); lbl3.Content = con.get_date().Date.ToString("dd/MM/yyyy"); stack3.Children.Add(symb3); stack3.Children.Add(lbl3); bigstack.Children.Add(stack3); StackPanel stack4 = new StackPanel(); stack4.Orientation = Orientation.Horizontal; Label symb4 = new Label(); symb4.Content = "Heure Début :";; symb4.Height = 30; symb4.Width = 122; Label lbl4 = new Label(); lbl4.Height = 30; lbl4.Content = con.get_date().ToString("HH:mm"); stack4.Children.Add(symb4); stack4.Children.Add(lbl4); bigstack.Children.Add(stack4); StackPanel stack5 = new StackPanel(); stack5.Orientation = Orientation.Horizontal; Label symb5 = new Label(); symb5.Content = "Heure Fin :";; symb5.Height = 30; symb5.Width = 122; Label lbl5 = new Label(); lbl5.Content = con.getfin().ToString("HH:mm"); lbl5.Height = 30; stack5.Children.Add(symb5); stack5.Children.Add(lbl5); bigstack.Children.Add(stack5); bigstack.Margin = new Thickness(-400, 0, 0, 0); Item.Children.Add(bigstack); alerte_class a = con.get_alert(); if (a != null) { StackPanel stackofalert = new StackPanel(); prio.Margin = new Thickness(0, -165, 0, 0); option.Margin = new Thickness(600, -165, 0, 0); stackofalert.Orientation = Orientation.Horizontal; stackofalert.Width = 1200; Image reveil = new Image(); reveil.Source = new BitmapImage(new Uri("reveil.png", UriKind.Relative)); reveil.Height = 20; reveil.Width = 20; stackofalert.Children.Add(reveil); Label labl6 = new Label(); labl6.Content = a.gettemps().ToString("dd/MM/yyyy HH:mm"); stackofalert.Children.Add(labl6); //modify StackPanel options_alerte = new StackPanel(); options_alerte.Orientation = Orientation.Horizontal; options_alerte.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; options_alerte.Width = 80; Button modify = new Button(); Image pen = new Image(); pen.Source = new BitmapImage(new Uri("modif.png", UriKind.Relative)); modify.Content = pen; modify.Height = 30; modify.Width = 30; modify.Background = null; modify.Click += new RoutedEventHandler(modifyAlert_Click); options_alerte.Children.Add(modify); options_alerte.Margin = new Thickness(800, 0, 0, 0); //delete button Button supp = new Button(); Image su = new Image(); su.Source = new BitmapImage(new Uri("delete1.png", UriKind.Relative)); supp.Click += new RoutedEventHandler(deleteAlert_Click); supp.Content = su; supp.Height = 30; supp.Width = 30; supp.Background = null; options_alerte.Children.Add(supp); stackofalert.Margin = new Thickness(100, 160, 0, 0); stackofalert.Children.Add(options_alerte); Item.Children.Add(stackofalert); } list_box.Items.Add(Item); } }
public WrapPanel PanelAdd(Pages.Detail detail) { Model.cab++; WrapPanel ana = new WrapPanel(); ana.Name = $"panel{Model.cab}"; detail.upanel.RegisterName(ana.Name, ana); ana.MouseUp += detail.Ana_MouseUp; ana.MouseMove += detail.Ana_MouseMove; ana.MouseLeave += detail.Ana_MouseLeave; ana.Cursor = Cursors.Hand; ana.Margin = new Thickness(0, 0, 0, 10); ana.Cursor = Cursors.Hand; ana.Background = (Brush)bc.ConvertFrom("#e6e6e6"); RichTextBox rctyp = new RichTextBox(); rctyp.Padding = new Thickness(3, 6, 3, 6); rctyp.BorderThickness = new Thickness(0); rctyp.HorizontalContentAlignment = HorizontalAlignment.Center; rctyp.Background = (Brush)bc.ConvertFrom("transparent"); rctyp.Width = 70; rctyp.Height = 40; rctyp.FontSize = 16; rctyp.Document.Blocks.Clear(); rctyp.Document.Blocks.Add( new Paragraph(new Run( "TEST" )) ); ana.Children.Add(rctyp); RichTextBox rcprt = new RichTextBox(); rcprt.BorderThickness = new Thickness(0); rcprt.Background = (Brush)bc.ConvertFrom("transparent"); rcprt.Width = 340; rcprt.Height = 40; rcprt.VerticalContentAlignment = VerticalAlignment.Center; rcprt.FontSize = 16; rcprt.Document.Blocks.Clear(); rcprt.Document.Blocks.Add( new Paragraph(new Run( "TEST" )) ); ana.Children.Add(rcprt); WrapPanel yakala = new WrapPanel(); yakala.Height = 40; yakala.Width = 40; yakala.Name = "Yakala" + Model.cab; yakala.Background = (Brush)bc.ConvertFrom("transparent"); yakala.MouseUp += detail.Btn_MouseUp; yakala.MouseMove += detail.Btn_MouseMove; yakala.MouseLeave += detail.Btn_MouseLeave; ana.Children.Add(yakala); return(ana); }
private void PrintResult(object sender, EventArgs e) { var bc = new BrushConverter(); switch ((string)sender) { case "diagonal0": System.Windows.Application.Current.Dispatcher.Invoke(delegate { Button0.Background = (Brush)bc.ConvertFrom("#ff4081"); Button4.Background = (Brush)bc.ConvertFrom("#ff4081"); Button8.Background = (Brush)bc.ConvertFrom("#ff4081"); }); break; case "diagonal1": System.Windows.Application.Current.Dispatcher.Invoke(delegate { Button2.Background = (Brush)bc.ConvertFrom("#ff4081"); Button4.Background = (Brush)bc.ConvertFrom("#ff4081"); Button6.Background = (Brush)bc.ConvertFrom("#ff4081"); }); break; case "vertical0": System.Windows.Application.Current.Dispatcher.Invoke(delegate { Button0.Background = (Brush)bc.ConvertFrom("#ff4081"); Button3.Background = (Brush)bc.ConvertFrom("#ff4081"); Button6.Background = (Brush)bc.ConvertFrom("#ff4081"); }); break; case "vertical1": System.Windows.Application.Current.Dispatcher.Invoke(delegate { Button1.Background = (Brush)bc.ConvertFrom("#ff4081"); Button4.Background = (Brush)bc.ConvertFrom("#ff4081"); Button7.Background = (Brush)bc.ConvertFrom("#ff4081"); }); break; case "vertical2": System.Windows.Application.Current.Dispatcher.Invoke(delegate { Button2.Background = (Brush)bc.ConvertFrom("#ff4081"); Button5.Background = (Brush)bc.ConvertFrom("#ff4081"); Button8.Background = (Brush)bc.ConvertFrom("#ff4081"); }); break; case "horizontal0": System.Windows.Application.Current.Dispatcher.Invoke(delegate { Button0.Background = (Brush)bc.ConvertFrom("#ff4081"); Button1.Background = (Brush)bc.ConvertFrom("#ff4081"); Button2.Background = (Brush)bc.ConvertFrom("#ff4081"); }); break; case "horizontal1": System.Windows.Application.Current.Dispatcher.Invoke(delegate { Button3.Background = (Brush)bc.ConvertFrom("#ff4081"); Button4.Background = (Brush)bc.ConvertFrom("#ff4081"); Button5.Background = (Brush)bc.ConvertFrom("#ff4081"); }); break; case "horizontal2": System.Windows.Application.Current.Dispatcher.Invoke(delegate { Button6.Background = (Brush)bc.ConvertFrom("#ff4081"); Button7.Background = (Brush)bc.ConvertFrom("#ff4081"); Button8.Background = (Brush)bc.ConvertFrom("#ff4081"); }); break; } }