/// <summary> /// Converts the name of a color to a <see cref="System.Windows.Media.Brush"/> object. /// </summary> /// <param name="value"></param> /// <param name="targetType"></param> /// <param name="parameter"></param> /// <param name="culture"></param> /// <returns></returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var purpose = System.Convert.ToString(parameter); switch (purpose) { case AppConstants.CONVERT_ACCENT: var aceentColorName = System.Convert.ToString(value); var accent = ThemeManager.DefaultAccents.FirstOrDefault(a => string.CompareOrdinal(a.Name, aceentColorName) == 0); if (null != accent) return accent.Resources["AccentColorBrush"] as Brush; break; case AppConstants.CONVERT_BASE: var baseColorName = System.Convert.ToString(value); var converter = new BrushConverter(); if (string.CompareOrdinal(baseColorName, AppConstants.LIGHT_BASE) == 0) { var brush = (Brush)converter.ConvertFromString("#FFFFFFFF"); return brush; } if (string.CompareOrdinal(baseColorName, AppConstants.DARK_BASE) == 0) { var brush = (Brush)converter.ConvertFromString("#FF000000"); return brush; } break; } return null; }
static BrushProvider() { var brushConverter = new BrushConverter(); _brushes.Insert(0, brushConverter.ConvertFromString("#88FFB7A5") as SolidColorBrush); _brushes.Insert(0, brushConverter.ConvertFromString("#88BFE0FF") as SolidColorBrush); _brushes.Insert(0, brushConverter.ConvertFromString("#88D2FFB5") as SolidColorBrush); }
public static Brush ConvertBrush(System.Drawing.Color color) { var b = new BrushConverter(); if (b.IsValid(color.Name)) { return b.ConvertFromString(color.Name) as SolidColorBrush; } return b.ConvertFromString("Black") as SolidColorBrush; }
/// <summary> /// Extension method for writing color to a RichTextBox. /// </summary> /// <param name="box">the RichTextBox to be written to.</param> /// <param name="text">the text to be written to the RichTextBox.</param> /// <param name="color">the color of the text, defined by the Color structure.</param> /// <param name="sameLine">True if the text is to be written to the same line as the last text.</param> public static void AppendText(this RichTextBox box, string text, string color, bool sameLine) { BrushConverter bc = new BrushConverter(); TextRange tr = new TextRange(box.Document.ContentEnd, box.Document.ContentEnd); if (!sameLine) tr.Text = "\r\n" + text; else tr.Text = text; try { tr.ApplyPropertyValue(TextElement.ForegroundProperty, bc.ConvertFromString(color)); } catch (FormatException) { tr.ApplyPropertyValue(TextElement.ForegroundProperty, bc.ConvertFromString("Black")); } }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { int? v = (int?)value; BrushConverter conv = new BrushConverter(); if (v == null) return conv.ConvertFromString("White"); else if (v == 0) return conv.ConvertFromString("SpringGreen"); else return conv.ConvertFromString("MistyRose"); }
/// <summary> /// Extension method for writing color to a RichTextBox. /// </summary> /// <param name="box">the RichTextBox to be written to.</param> /// <param name="text">the text to be written to the RichTextBox.</param> /// <param name="color">the color of the text, defined by the Color structure.</param> public static void AppendText(this RichTextBox box, string text, string color) { //initialize a class to convert strings to brush colors BrushConverter bc = new BrushConverter(); //initialize a class for writing to a richtextbox TextRange tr = new TextRange(box.Document.ContentEnd, box.Document.ContentEnd); tr.Text = "\r\n" + text; //try to write the color given try { tr.ApplyPropertyValue(TextElement.ForegroundProperty, bc.ConvertFromString(color)); } //if it fails, write it in black catch (FormatException) { tr.ApplyPropertyValue(TextElement.ForegroundProperty, bc.ConvertFromString("Black")); } }
//r:203,g:255,b:198,a:60 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { bool valor = (bool)value; BrushConverter conver = new BrushConverter(); //R:# V:# if (valor){ return conver.ConvertFromString("#CCC0FFAD") as SolidColorBrush; } else { return conver.ConvertFromString("#CCFFADAD") as SolidColorBrush; } }
private void Initialize(ButtonType buttonType, string iconFilePath, string buttonTitle, string buttonColour, string brushMouseEnterHexCode, string brushMouseLeaveHexCode, string brushMouseDownHexCode, string brushMouseUpHexCode) { BrushConverter bc = new BrushConverter(); _brushMouseEnter = (Brush)bc.ConvertFromString(brushMouseEnterHexCode); _brushMouseLeave = (Brush)bc.ConvertFromString(brushMouseLeaveHexCode); _brushMouseDown = (Brush)bc.ConvertFromString(brushMouseDownHexCode); _brushMouseUp = brushMouseUpHexCode == null ? Brushes.Transparent : (Brush)bc.ConvertFromString(brushMouseUpHexCode); TextBlockTitle.Background = (Brush)bc.ConvertFromString(buttonColour); TextBlockTitle.Text = buttonTitle; ImageIcon.Source = PlusPlayTools.ImageEditing.GenerateImage_FileStream(iconFilePath); _buttonType = buttonType; }
/// <summary> /// Initializes a new instance of the <see cref="DiagramInheritanceConnector"/> class. /// </summary> /// <param name="startConnector">The start connector.</param> /// <param name="endConnector">The end connector.</param> /// <remarks> /// Consturctor that specifies the two nodes that are connected. /// </remarks> internal DiagramInheritanceConnector(DiagramConnectorNode startConnector, DiagramConnectorNode endConnector) : base(startConnector, endConnector) { BrushConverter bc = new BrushConverter(); Brush brush = bc.ConvertFromString("#716F64") as Brush; this.ResourcePen = new Pen(brush != null ? brush : Brushes.DimGray, 1); }
private async void WatermarkTextBox_TextChanged(object sender, TextChangedEventArgs e) { if (string.IsNullOrEmpty(previousID)) previousID = (sender as TextBox).Text; try { if ((sender as TextBox).IsFocused == true) { bool result = true; var doc = (DataContext as DocumentEditViewModel).Document; doc.DocumentID = (sender as TextBox).Text; try { result = await (DataContext as DocumentEditViewModel).ParentViewModel.ParentViewModel.Database.DocumentExists(doc); } catch { } if (result && (DataContext as DocumentEditViewModel).EditMode == true) { (sender as TextBox).BorderBrush = Brushes.Red; (sender as TextBox).BorderThickness = new System.Windows.Thickness(2); } else { var converter = new System.Windows.Media.BrushConverter(); var brush = (Brush)converter.ConvertFromString("#FFABADB3"); (sender as TextBox).BorderBrush = brush; (sender as TextBox).BorderThickness = new System.Windows.Thickness(1); } result = await (DataContext as DocumentEditViewModel).ParentViewModel.ParentViewModel.Database.UpdateTemporaryUsedDocumentID(previousID, (sender as TextBox).Text, doc.DocumentType); previousID = (sender as TextBox).Text; } } catch { } }
private void click(object sender, RoutedEventArgs e) { Button b = sender as Button; switch (b.Name) { case "activator": if (!CManager.Properties.Settings.Default.activator) { this.activator.IsEnabled = false; this.activator.BorderThickness = new Thickness(1); BrushConverter c = new BrushConverter(); this.activator.BorderBrush = (Brush)c.ConvertFromString("#FF828282"); this.activator.ToolTip = "This options is avaible only in extended version of program"; ToolTipService.SetInitialShowDelay(this.activator, 1500); ToolTipService.SetShowDuration(this.activator, 5000); ToolTipService.SetShowOnDisabled(this.activator, true); } else { sel(this, new program() { page = 2 }); } break; case "manager": sel(this, new program() { page = 3 }); break; } }
public LoginWindow() { Logger.MonitoringLogger.Debug("Initializing LoginWindow"); InitializeComponent(); //Title Bar color change var converter = new System.Windows.Media.BrushConverter(); var brush = (Brush)converter.ConvertFromString("#404040"); this.TitleBarBackground = brush; this.DataContext = loginDataView; //Event handler this.Loaded += new RoutedEventHandler(LoadedEventHandler); this.Closing += new CancelEventHandler(ClosedEventHandler); loginDataView.ServersProfiles.CollectionChanged += new NotifyCollectionChangedEventHandler(CollectionChangedEventHandler); ResourceDictionary resourceDictionary = new ResourceDictionary() { Source = new Uri("/Framework.UI;component/Themes/ElysiumExtra/GeometryIcon.xaml", UriKind.RelativeOrAbsolute) }; //BattlEyeLoginCredentials loginCredentials = new BattlEyeLoginCredentials(); Logger.MonitoringLogger.Debug("Login Window Initialized"); }
private void cpColor_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs<Color> e) { Color selected = cpColor.SelectedColor; var bc = new BrushConverter(); TheBackground = bc.ConvertFromString(selected.ToString()) as Brush; colorDisplay.Background = TheBackground; }
protected override void OnDrop(DragEventArgs e) { base.OnDrop(e); if (e.Data.GetDataPresent(DataFormats.StringFormat)) { string dataString = (string) e.Data.GetData(DataFormats.StringFormat); BrushConverter converter = new BrushConverter(); if (converter.IsValid(dataString)) { Brush newFill = (Brush) converter.ConvertFromString(dataString); circleUI.Fill = newFill; if (e.KeyStates.HasFlag(DragDropKeyStates.ControlKey)) { e.Effects = DragDropEffects.Copy; } else { e.Effects = DragDropEffects.Move; } } } e.Handled = true; }
private static Inline BuildFont(ElementToken token, Hint hint) { var span = new Span(); string size; if (token.Attributes.TryGetValue("size", out size)) { var fc = new FontSizeConverter(); var sz = (double)fc.ConvertFromString(size); span.FontSize = sz; } string face; if (token.Attributes.TryGetValue("face", out face)) { span.FontFamily = new FontFamily(face); } string color; if (token.Attributes.TryGetValue("color", out color)) { var bc = new BrushConverter(); var br = (Brush)bc.ConvertFromString(color); span.Foreground = br; } return span.Fill(token, hint); }
/// <summary> /// Initializes a new instance of the <see cref="DiagramAssociationConnector"/> class. /// </summary> /// <param name="startConnector">The start connector.</param> /// <param name="endConnector">The end connector.</param> /// <remarks> /// Consturctor that specifies the two nodes that are connected. /// </remarks> internal DiagramAssociationConnector(DiagramConnectorNode startConnector, DiagramConnectorNode endConnector) : base(startConnector, endConnector) { BrushConverter bc = new BrushConverter(); Brush brush = bc.ConvertFromString("#B0764F") as Brush; this.ResourcePen = new Pen(brush != null ? brush : Brushes.Sienna, 1); }
private void ChangeColor(object sender, SelectionChangedEventArgs args) { var li2 = ((sender as ListBox).SelectedItem as ListBoxItem); var myBrushConverter = new BrushConverter(); border1.BorderBrush = (Brush) myBrushConverter.ConvertFromString((string) li2.Content); bColor.Text = "Border.Borderbrush =" + li2.Content; }
protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes) { if (drawingContext == null) { throw new ArgumentNullException("drawingContext"); } if (null == drawingAttributes) { throw new ArgumentNullException("drawingAttributes"); } Pen pen = new Pen { StartLineCap = PenLineCap.Round, EndLineCap = PenLineCap.Round, Brush = new SolidColorBrush(drawingAttributes.Color), Thickness = drawingAttributes.Width }; BrushConverter bc = new BrushConverter(); Brush BackGround = (Brush)bc.ConvertFromString(drawingAttributes.GetPropertyData(DrawAttributesGuid.BackgroundColor).ToString()); GeometryConverter gc = new GeometryConverter(); Geometry geometry = (Geometry)gc.ConvertFromString(string.Format("M {0},{1} {2},{3} {4},{5} Z", StylusPoints[0].X, StylusPoints[1].Y, (Math.Abs(StylusPoints[1].X - StylusPoints[0].X))/2 + StylusPoints[0].X, StylusPoints[0].Y, StylusPoints[1].X, StylusPoints[1].Y)); GeometryDrawing gd = new GeometryDrawing(BackGround, pen, geometry); drawingContext.DrawDrawing(gd); }
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { try { // get brush from runtime property info if (value is PropertyInfo) { // create converter BrushConverter converter = new BrushConverter(); // convert neme to brush Brush selectedBrush = (Brush)converter.ConvertFromString(((PropertyInfo)value).Name.ToString()); // get brush return selectedBrush; } else { // return black return Brushes.Black; } } catch (Exception e) { // display Console.WriteLine("Exception caught converting property info: {0}", e.Message); // return black return Brushes.Black; } }
/// <summary> /// Checks if the entered <see cref="ArticleID"/> already exists or not. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void TextBox_TextChanged(object sender, TextChangedEventArgs e) { try { if ((sender as TextBox).IsFocused == true) { bool result = true; try { result = await (DataContext as ArticleEditViewModel).ParentViewModel.ParentViewModel.Database.ArticleExists((sender as TextBox).Text); } catch { } if (result && (DataContext as ArticleEditViewModel).EditMode == false) { (sender as TextBox).BorderBrush = Brushes.Red; (sender as TextBox).BorderThickness = new System.Windows.Thickness(2); } else { var converter = new System.Windows.Media.BrushConverter(); var brush = (Brush)converter.ConvertFromString("#FFABADB3"); (sender as TextBox).BorderBrush = brush; (sender as TextBox).BorderThickness = new System.Windows.Thickness(1); } result = await (DataContext as ArticleEditViewModel).ParentViewModel.ParentViewModel.Database.UpdateTemporaryUsedArticleID(previousID, (sender as TextBox).Text); previousID = (sender as TextBox).Text; } } catch { } }
protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes) { if (drawingContext == null) { throw new ArgumentNullException("drawingContext"); } if (null == drawingAttributes) { throw new ArgumentNullException("drawingAttributes"); } Pen pen = new Pen { StartLineCap = PenLineCap.Round, EndLineCap = PenLineCap.Round, Brush = new SolidColorBrush(drawingAttributes.Color), Thickness = drawingAttributes.Width }; BrushConverter bc = new BrushConverter(); Brush BackGround = (Brush)bc.ConvertFromString(drawingAttributes.GetPropertyData(DrawAttributesGuid.BackgroundColor).ToString()); drawingContext.DrawRectangle( BackGround, pen, new Rect(new Point(StylusPoints[0].X, StylusPoints[0].Y), new Point(StylusPoints[1].X, StylusPoints[1].Y))); }
public SelfmadeSVI(ProtoDefinition protoDefinition = null) { InitializeComponent(); if (protoDefinition != null) { this.ProtoDefinition = protoDefinition; } //apply width and height this.MainCanvas.Width = this.ProtoDefinition.Width; this.MainCanvas.Height = this.ProtoDefinition.Height; // applying the color BrushConverter cConverter = new BrushConverter(); this.OwnColoredRectangle.Fill = cConverter.ConvertFromString(this.ProtoDefinition.Color) as SolidColorBrush; //TODO: apply the given image // initial position MatrixTransform matrixTransform = this.RenderTransform as MatrixTransform; Matrix rectsMatrix = matrixTransform.Matrix; rectsMatrix.Translate(this.ProtoDefinition.X, this.ProtoDefinition.Y); this.RenderTransform = new MatrixTransform(rectsMatrix); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { Debug.Assert(value != null, "Value must not be null"); Brush brush = null; if (value is Color) { brush = new SolidColorBrush((Color)value); } else if (value is string) { try { BrushConverter converter = new BrushConverter(); brush = converter.ConvertFromString((string)value) as SolidColorBrush; } catch { // We want to eat the exception } } if (brush == null) { Debug.Fail(string.Format("Unable to convert {0} to a Brush. Using a Colors.Black as a default.", value ?? "NULL")); brush = new SolidColorBrush(Colors.Black); } return brush; }
private MdiChild GenerateChild(string windowName) { UIElement windowContent = null; System.Windows.WindowState windowState = System.Windows.WindowState.Normal; switch (windowName) { case "Produtos" : windowContent = new ManageProduct() { Visibility = Visibility.Visible }; break; case "Categorias": windowContent = new ManageCategory() { Visibility = Visibility.Visible }; break; case "Fornecedores": windowContent = new ManageProvider() { Visibility = Visibility.Visible }; break; case "Fabricantes": windowContent = new ManageMake() { Visibility = Visibility.Visible }; break; case "Clientes": windowContent = new ManageClient() { Visibility = Visibility.Visible }; break; } var converter = new System.Windows.Media.BrushConverter(); var white = (Brush)converter.ConvertFromString("#FFFFFFFF"); var black = (Brush)converter.ConvertFromString("#FF000000"); return new MdiChild() { Title = "GERENCIAMENTO DE " + windowName.ToUpper(), Foreground = white, Resizable = true, MinimizeBox = false, WindowState = windowState, VerticalContentAlignment = System.Windows.VerticalAlignment.Top, HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left, Background = white, BorderBrush = white, Width = ((UserControl)windowContent).Width, Height = ((UserControl)windowContent).Height, MaxWidth = WindowContainer.ActualWidth, MaxHeight = WindowContainer.ActualHeight, BorderThickness = new Thickness(0), Content = windowContent }; }
private void DisplayUi(CustomerViewModel o) { lblCustomerName.Content = o.txtCustomerName; lblSalesAmount.Content = o.txtAmount; BrushConverter brushconv = new BrushConverter(); lblHabits.Background = brushconv.ConvertFromString(o.lblAmountColor) as SolidColorBrush; chkMarried.IsChecked = o.IsMarried; }
void InitialSet() { text = textMessage.Child<TextBox>(); text = textMessage.Child<TextBox>(); text.TextChanged += new TextChangedEventHandler(SMSMessage_TextChanged); BrushConverter bc = new BrushConverter(); greenBrush = (Brush)bc.ConvertFromString("Green"); redBrush = (Brush)bc.ConvertFromString("Red"); pinkBackground = new LinearGradientBrush(new GradientStopCollection { new GradientStop(Color.FromRgb(255, 237, 237), 0), new GradientStop(Color.FromRgb(255, 231, 231), 0.527), new GradientStop(Color.FromRgb(255, 204, 204), 1) }, new Point(0.5, 1), new Point(0.5, 0)); normalBackGround = text.Background; VisualCharactersToEnd(); }
public Test(int countQuestion) { InitializeComponent(); timer = new DispatcherTimer(); converter = new BrushConverter(); green = converter.ConvertFromString("#FF27AC5E") as Brush; red = converter.ConvertFromString("#FFC91329") as Brush; da = new DoubleAnimation(); culture = App.Language.Name; this.countQuestion = countQuestion; progressBarPartWidth = 340 / countQuestion; Init(); }
public PropertyLabel(OSAEObject sObj) { InitializeComponent(); screenObject = sObj; ObjectName = screenObject.Property("Object Name").Value; PropertyName = screenObject.Property("Property Name").Value; string sPropertyValue = osae.GetObjectPropertyValue(ObjectName, PropertyName).Value; string sBackColor = screenObject.Property("Back Color").Value; string sForeColor = screenObject.Property("Fore Color").Value; string sPrefix = screenObject.Property("Prefix").Value; string sSuffix = screenObject.Property("Suffix").Value; string iFontSize = screenObject.Property("Font Size").Value; string sFontName = screenObject.Property("Font Name").Value; if (sPropertyValue != "") { if (sBackColor != "") { try { BrushConverter conv = new BrushConverter(); SolidColorBrush brush = conv.ConvertFromString(sBackColor) as SolidColorBrush; propLabel.Background = brush; } catch (Exception myerror) { } } if (sForeColor != "") { try { BrushConverter conv = new BrushConverter(); SolidColorBrush brush = conv.ConvertFromString(sForeColor) as SolidColorBrush; propLabel.Foreground = brush; } catch (Exception myerror) { } } if (iFontSize != "") { try { propLabel.FontSize = Convert.ToDouble(iFontSize); } catch (Exception myerror) { } } propLabel.Content = sPrefix + sPropertyValue + sSuffix; } else { propLabel.Content = ""; } }
public MainWindow() { InitializeComponent(); vm = new GraphViewModel(); DataContext = vm; //Set colors used by points InputPointColoBrush = this.Resources["InputPointColorBrush"] as SolidColorBrush; OutputPointColoBrush = this.Resources["OutputPointColoBrush"] as SolidColorBrush; BrushConverter converter = new System.Windows.Media.BrushConverter(); string inputStrokeColor = converter.ConvertToString(InputPointColoBrush); string outputStrokeColor = converter.ConvertToString(OutputPointColoBrush); InputStroke = (Brush)converter.ConvertFromString(inputStrokeColor); OutputStroke = (Brush)converter.ConvertFromString(outputStrokeColor); }
/// <summary> /// Постройка формы через блокнот /// </summary> /// <param name="obj">Путь до файла</param> private void ThreadFileRead(object obj) { StreamReader file = null; try { file = new StreamReader((string)obj); String[] ss; do { ss = new String[6]; ss = file.ReadLine().Replace(" :", "").Split(' '); if (ss[0].Equals("Rec")) { gg.Dispatcher.Invoke(new ThreadStart(() => { Rectangle cek = new Rectangle(); var converter = new System.Windows.Media.BrushConverter(); var brush = (Brush)converter.ConvertFromString(ss[9]); cek.Fill = brush; cek.Opacity = Double.Parse(ss[7]); cek.Margin = new Thickness(Double.Parse(ss[1]), Double.Parse(ss[2]), 0, 0); cek.VerticalAlignment = VerticalAlignment.Top; cek.HorizontalAlignment = HorizontalAlignment.Left; cek.Width = Double.Parse(ss[4]); cek.Height = Double.Parse(ss[5]); cek.MouseLeftButtonDown += TrCl; cek.MouseRightButtonDown += DeleteObj; gg.Children.Add(cek); reces.Add(cek); Zitem.Add('r'); })); } else { gg.Dispatcher.Invoke(new ThreadStart(() => { try { Ellipse cek = new Ellipse(); var converter = new System.Windows.Media.BrushConverter(); var brush = (Brush)converter.ConvertFromString(ss[9]); cek.Fill = brush; cek.Opacity = Double.Parse(ss[7]); cek.Margin = new Thickness(Double.Parse(ss[1]), Double.Parse(ss[2]), 0, 0); cek.VerticalAlignment = VerticalAlignment.Top; cek.HorizontalAlignment = HorizontalAlignment.Left; cek.Width = Double.Parse(ss[4]); cek.Height = Double.Parse(ss[5]); cek.MouseLeftButtonDown += TrCl; cek.MouseRightButtonDown += DeleteObj; gg.Children.Add(cek); elleps.Add(cek); Zitem.Add('e'); } catch (Exception) { } })); } for (int i = 0; i < ss.Length; i++) { Console.WriteLine(ss[i]); } } while (ss[1] != null); } catch (NullReferenceException) { } catch (FormatException) { } catch (IndexOutOfRangeException) { } finally { if (file != null) { file.Close(); } } }
private void SearchBtn_Click(object sender, RoutedEventArgs e) { //이전 데이터 제거 searchTable.Children.RemoveRange(8, searchTable.Children.Count - 8); String sql; if (yearOption) { sql = String.Format("SELECT * from (SELECT date, '일정' classify, calendar content FROM calendar WHERE calendar LIKE '%{0}%' UNION ", searchBox.Text); sql += String.Format("SELECT date, '보고공문' classify, report content FROM calendar WHERE report LIKE '%{0}%' UNION ", searchBox.Text); sql += String.Format("SELECT date, '복무' classify, service content FROM calendar WHERE service LIKE '%{0}%') WHERE date BETWEEN date('now', '-1 year') AND date('now', '+1 year')", searchBox.Text); } else { sql = String.Format("SELECT date, '일정' classify, calendar content FROM calendar WHERE calendar LIKE '%{0}%' UNION ", searchBox.Text); sql += String.Format("SELECT date, '보고공문' classify, report content FROM calendar WHERE report LIKE '%{0}%' UNION ", searchBox.Text); sql += String.Format("SELECT date, '복무' classify, service content FROM calendar WHERE service LIKE '%{0}%'", searchBox.Text); } var conn = new SQLiteConnection(App.filePath); conn.Open(); SQLiteCommand cmd = new SQLiteCommand(sql, conn); SQLiteDataReader rdr = cmd.ExecuteReader(); //검색 결과 수 만큼 행 생성 int rowCount = 1; while (rdr.Read()) { RowDefinition gridRow = new RowDefinition(); //gridRow.Height = new GridLength(50); searchTable.RowDefinitions.Add(gridRow); //경계 선 만들기 Border border1 = new Border(); Grid.SetRow(border1, rowCount); Grid.SetColumn(border1, 0); border1.BorderThickness = new Thickness(1, 0, 0, 1); border1.Background = Brushes.Transparent; border1.BorderBrush = Brushes.Black; searchTable.Children.Add(border1); Border border2 = new Border(); Grid.SetRow(border2, rowCount); Grid.SetColumn(border2, 1); border2.BorderThickness = new Thickness(1, 0, 0, 1); border2.Background = Brushes.Transparent; border2.BorderBrush = Brushes.Black; searchTable.Children.Add(border2); Border border3 = new Border(); Grid.SetRow(border3, rowCount); Grid.SetColumn(border3, 2); border3.BorderThickness = new Thickness(1, 0, 0, 1); border3.Background = Brushes.Transparent; border3.BorderBrush = Brushes.Black; searchTable.Children.Add(border3); Border border4 = new Border(); Grid.SetRow(border4, rowCount); Grid.SetColumn(border4, 3); border4.BorderThickness = new Thickness(1, 0, 1, 1); border4.Background = Brushes.Transparent; border4.BorderBrush = Brushes.Black; searchTable.Children.Add(border4); //텍스트 만들기 TextBlock dateText = new TextBlock(); DateTime tempDateTime = Convert.ToDateTime(rdr["date"].ToString()); dateText.Text = tempDateTime.ToString("yyyy-MM-dd (ddd)"); dateText.Padding = new Thickness(5); dateText.TextAlignment = TextAlignment.Center; dateText.VerticalAlignment = VerticalAlignment.Center; Grid.SetRow(dateText, rowCount); Grid.SetColumn(dateText, 0); TextBlock classText = new TextBlock(); classText.Text = rdr["classify"].ToString(); classText.Padding = new Thickness(5); classText.TextAlignment = TextAlignment.Center; classText.VerticalAlignment = VerticalAlignment.Center; Grid.SetRow(classText, rowCount); Grid.SetColumn(classText, 1); TextBlock CoincideText = new TextBlock(); CoincideText.Text = rdr["content"].ToString(); CoincideText.Padding = new Thickness(5); CoincideText.TextWrapping = TextWrapping.Wrap; CoincideText.TextTrimming = TextTrimming.CharacterEllipsis; Grid.SetRow(CoincideText, rowCount); Grid.SetColumn(CoincideText, 2); Button linkBtn = new Button(); ////리소스에서 이미지 가져오기 //System.Drawing.Bitmap image = Properties.Resources._2268137; //MemoryStream imgStream = new MemoryStream(); //image.Save(imgStream, System.Drawing.Imaging.ImageFormat.Bmp); //imgStream.Seek(0, SeekOrigin.Begin); //BitmapFrame newimg = BitmapFrame.Create(imgStream); var converter = new System.Windows.Media.BrushConverter(); var brush = (Brush)converter.ConvertFromString("#673AB7"); linkBtn.Content = new PackIcon { Kind = PackIconKind.Launch, Foreground = brush, Background = System.Windows.Media.Brushes.Transparent }; linkBtn.HorizontalAlignment = HorizontalAlignment.Center; linkBtn.VerticalAlignment = VerticalAlignment.Center; linkBtn.Background = System.Windows.Media.Brushes.Transparent; linkBtn.BorderThickness = new Thickness(0); linkBtn.Click += (object eventSender, RoutedEventArgs eventArgs) => { int index = 0; CultureInfo provider = CultureInfo.InvariantCulture; DateTime dtDate = tempDateTime; _window.calendar.SelectedDate = dtDate; _window.calendar.DisplayDate = dtDate; switch (classText.Text) { case "일정": index = 0; break; case "보고공문": index = 1; break; case "복무": index = 2; break; } _window.ComboBox.SelectedIndex = index; }; Grid.SetRow(linkBtn, rowCount); Grid.SetColumn(linkBtn, 3); searchTable.Children.Add(dateText); searchTable.Children.Add(CoincideText); searchTable.Children.Add(classText); searchTable.Children.Add(linkBtn); rowCount++; } rdr.Close(); conn.Close(); }
public FlowDocument createDocument(string text) { string zeile; var document = new FlowDocument(); Paragraph p; char firstind; var converter = new System.Windows.Media.BrushConverter(); string word = string.Empty; bool specialkeyword = false, IsKeyword; typeOfKeyword type = typeOfKeyword.normal; string color = "0"; text = text.Replace(Environment.NewLine, "-/-"); if (text.Contains("-/-")) { do { p = new Paragraph(); zeile = text.Substring(0, text.IndexOf("-/-")); while (zeile != "") { if (zeile.Length > 2 && zeile.Substring(0, 2) == "//") { p.Inlines.Add(new Run(zeile) { Foreground = Brushes.Green }); zeile = ""; } else { IsKeyword = false; firstind = getfirstindex(zeile); if (firstind != 'n') { word = zeile.Substring(0, zeile.IndexOf(firstind)); if (specialkeyword) { if (type == typeOfKeyword.allgreen) { p.Inlines.Add(new Run(zeile) { Foreground = (Brush)converter.ConvertFromString(color) }); specialkeyword = false; type = typeOfKeyword.normal; break; } else { p.Inlines.Add(new Run(word) { Foreground = (Brush)converter.ConvertFromString(color) }); } specialkeyword = false; type = typeOfKeyword.normal; } else { foreach (var keyword in keywords) { if (keyword.Name == word.ToLower()) { IsKeyword = true; if (keyword.Type == typeOfKeyword.green) { p.Inlines.Add(new Run(word) { Foreground = (Brush)converter.ConvertFromString(keyword.Color) }); continue; } else { p.Inlines.Add(new Run(word) { Foreground = (Brush)converter.ConvertFromString(keyword.Color) }); } if (keyword.Type != typeOfKeyword.normal) { specialkeyword = true; type = keyword.Type; if (type == typeOfKeyword.allgreen) { color = "#4ac9a7"; } else { color = "#b8c068"; } } } } if (!IsKeyword) { p.Inlines.Add(new Run(word)); } } zeile = zeile.Remove(0, word.Length + 1); p.Inlines.Add(new Run(firstind.ToString())); } else { if (specialkeyword) { if (type == typeOfKeyword.allgreen) { p.Inlines.Add(new Run(zeile) { Foreground = (Brush)converter.ConvertFromString(color) }); specialkeyword = false; type = typeOfKeyword.normal; break; } else { p.Inlines.Add(new Run(word) { Foreground = (Brush)converter.ConvertFromString(color) }); } specialkeyword = false; type = typeOfKeyword.normal; } else { p.Inlines.Add(new Run(zeile)); } break; } } } document.Blocks.Add(p); text = text.Remove(0, text.IndexOf("-/-") + 3); } while (text.IndexOf("-/-") != text.LastIndexOf("-/-")); } else { document.Blocks.Add(new Paragraph(new Run(text))); } return(document); }
public institutoPage(int id, Page paginaanterior) { if (id == -1) { return; } InitializeComponent(); paginaAnterior = paginaanterior; Console.WriteLine(paginaAnterior); List<InstitutoInfo> institutos = readInstituto(); foreach (InstitutoInfo i in institutos) { if (i.id == id) { currentInstituto = i; } } nomeInstituto.Content = currentInstituto.nome; rating.Content = currentInstituto.rating; descricaoServico.Document.Blocks.Clear(); descricaoServico.Document.Blocks.Add(new Paragraph(new Run(currentInstituto.descricao)) { FontSize = 18 }); if (currentInstituto.foto != "null") { ImageBrush myBrush = new ImageBrush(); Image image = new Image(); image.Source = new BitmapImage( new Uri( BaseUriHelper.GetBaseUri(this), currentInstituto.foto)); myBrush.ImageSource = image.Source; userfotogrid.Background = myBrush; } int flag = 0; LoginPage logPage = new LoginPage(); currentUser = logPage.getCurrentUser(); foreach (int service_id in currentInstituto.servicos_id) { servicePage ServicePage = new servicePage(service_id,paginaAnterior); ServiceInfo servico = ServicePage.getCurrentService(); Grid novaGrid = new Grid(); novaGrid.Height = 40; ColumnDefinition colDef0 = new ColumnDefinition(); colDef0.Width = new GridLength(15, GridUnitType.Star); ColumnDefinition colDef1 = new ColumnDefinition(); colDef1.Width = new GridLength(30, GridUnitType.Star); ColumnDefinition colDef2 = new ColumnDefinition(); colDef2.Width = new GridLength(160, GridUnitType.Star); ColumnDefinition colDef3 = new ColumnDefinition(); colDef3.Width = new GridLength(85, GridUnitType.Star); ColumnDefinition colDef4 = new ColumnDefinition(); colDef4.Width = new GridLength(50, GridUnitType.Star); novaGrid.ColumnDefinitions.Add(colDef0); novaGrid.ColumnDefinitions.Add(colDef1); novaGrid.ColumnDefinitions.Add(colDef2); novaGrid.ColumnDefinitions.Add(colDef3); novaGrid.ColumnDefinitions.Add(colDef4); var icon = new nova { Kind = PackIconKind.StarBorder }; foreach (int i in currentUser.favoritos) { if (i == service_id) { icon = new nova { Kind = PackIconKind.Star }; } } icon.Width = 30; icon.Height = 45; icon.SetValue(Grid.ColumnProperty, 1); icon.Name = "seta" + service_id; icon.PreviewMouseLeftButtonDown += FavIcon_PreviewMouseLeftButtonDown; nova2 novo = new nova2(); novo.SetValue(Grid.ColumnProperty, 1); novo.Width = 30; novo.Height = 45; novo.Opacity = 0; novaGrid.Children.Add(novo); novo.Name = "seta" + service_id; novo.PreviewMouseLeftButtonDown += FavIcon_PreviewMouseLeftButtonDown; TextBlock newTextBox = new TextBlock(); newTextBox.Text = servico.tipo; newTextBox.VerticalAlignment = VerticalAlignment.Center; newTextBox.FontSize = 18; newTextBox.Margin = new Thickness(10, 10, 0, 0); newTextBox.SetValue(Grid.ColumnProperty, 2); TextBlock newTextBox2 = new TextBlock(); newTextBox2.Text = servico.preco + " €"; newTextBox2.FontSize = 18; newTextBox2.Margin = new Thickness(10, 10, 0, 0); newTextBox2.VerticalAlignment = VerticalAlignment.Center; newTextBox2.SetValue(Grid.ColumnProperty, 3); var icon2 = new nova { Kind = PackIconKind.ArrowRight }; icon2.Width = 25; icon2.Height = 25; icon2.VerticalAlignment = VerticalAlignment.Center; icon2.HorizontalAlignment = HorizontalAlignment.Left; icon2.SetValue(Grid.ColumnProperty, 4); icon2.Name = "seta" + service_id; icon2.PreviewMouseLeftButtonDown += PackIcon_PreviewMouseLeftButtonDown; painel.Children.Add(novaGrid); novaGrid.Children.Add(newTextBox); novaGrid.Children.Add(newTextBox2); novaGrid.Children.Add(icon); novaGrid.Children.Add(icon2); if (flag % 2 == 0) { var converter = new System.Windows.Media.BrushConverter(); var brush = (Brush)converter.ConvertFromString("#FFD0EDED"); novaGrid.Background = brush; } else { var converter = new System.Windows.Media.BrushConverter(); var brush = (Brush)converter.ConvertFromString("#FFC2DCDC"); novaGrid.Background = brush; } flag++; } Console.WriteLine(paginaAnterior); }
private void Button_Click(object sender, RoutedEventArgs e) { var converter = new System.Windows.Media.BrushConverter(); if (sender.Equals(OnButton)) { var outputFolder = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NAudio"); var outputFilePath = System.IO.Path.Combine(outputFolder, "recorded" + counter + ".wav"); if (!running) { //Console.Write("\nON\n\n"); OnButton.Content = "ON"; OnButton.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, (byte)78, (byte)198, (byte)98)); running = true; initializeDevices(); counter++; timer.Start(); if (DeviceSelect.Text != "Select a Device") { writer = null; writer = new WaveFileWriter(outputFilePath, captureDevice.WaveFormat); } } else { //Console.Write("\nOFF\n\n"); OnButton.Content = "OFF"; OnButton.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, (byte)228, (byte)58, (byte)58)); InLevel.Value = 0; OutLevel.Value = 0; running = false; timer.Stop(); //DeleteDirectory(outputFolder); //Directory.Delete(outputFolder, true); } } else if (sender.Equals(DeviceRefresh)) { //Console.Write("\nDevices Refreshed\n\n"); OnButton.Content = "OFF"; OnButton.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, (byte)228, (byte)58, (byte)58)); running = false; InLevel.Value = 0; OutLevel.Value = 0; timer.Stop(); populateDevices(); } else if (sender.Equals(MainButton)) { DataContext = null; openWindow = winState.MAIN; MainButton.Background = (System.Windows.Media.Brush)converter.ConvertFromString("#FFF4364A"); HelpButton.Background = (System.Windows.Media.Brush)converter.ConvertFromString("#FF0B0A1D"); } else if (sender.Equals(HelpButton)) { DataContext = new HelpViewModel(); openWindow = winState.HELP; HelpButton.Background = (System.Windows.Media.Brush)converter.ConvertFromString("#FFF4364A"); MainButton.Background = (System.Windows.Media.Brush)converter.ConvertFromString("#FF0B0A1D"); } }
public favoritesPage() { InitializeComponent(); LoginPage logPage = new LoginPage(); currentUser = logPage.getCurrentUser(); foreach (int service_id in currentUser.favoritos) { servicePage ServicePage = new servicePage(service_id, this); ServiceInfo servico = ServicePage.getCurrentService(); Grid novaGrid = new Grid(); novaGrid.Height = 50; ColumnDefinition colDef0 = new ColumnDefinition(); colDef0.Width = new GridLength(30, GridUnitType.Star); ColumnDefinition colDef1 = new ColumnDefinition(); colDef1.Width = new GridLength(40, GridUnitType.Star); ColumnDefinition colDef2 = new ColumnDefinition(); colDef2.Width = new GridLength(130, GridUnitType.Star); ColumnDefinition colDef3 = new ColumnDefinition(); colDef3.Width = new GridLength(100, GridUnitType.Star); ColumnDefinition colDef4 = new ColumnDefinition(); colDef4.Width = new GridLength(40, GridUnitType.Star); ColumnDefinition colDef5 = new ColumnDefinition(); colDef5.Width = new GridLength(30, GridUnitType.Star); novaGrid.ColumnDefinitions.Add(colDef0); novaGrid.ColumnDefinitions.Add(colDef1); novaGrid.ColumnDefinitions.Add(colDef2); novaGrid.ColumnDefinitions.Add(colDef3); novaGrid.ColumnDefinitions.Add(colDef4); novaGrid.ColumnDefinitions.Add(colDef5); var bin = new nova { Kind = PackIconKind.Bin }; bin.Width = 25; bin.Height = 25; bin.VerticalAlignment = VerticalAlignment.Center; bin.HorizontalAlignment = HorizontalAlignment.Left; bin.SetValue(Grid.ColumnProperty, 1); bin.Name = "bin" + service_id; bin.PreviewMouseLeftButtonDown += BinIcon_PreviewMouseLeftButtonDown; TextBlock newTextBox = new TextBlock(); newTextBox.Text = servico.tipo; newTextBox.VerticalAlignment = VerticalAlignment.Center; newTextBox.FontSize = 16; newTextBox.SetValue(Grid.ColumnProperty, 2); TextBlock newTextBox2 = new TextBlock(); newTextBox2.Text = servico.instituto_nome; newTextBox2.FontSize = 16; newTextBox2.VerticalAlignment = VerticalAlignment.Center; newTextBox2.SetValue(Grid.ColumnProperty, 3); var icon = new nova { Kind = PackIconKind.ArrowRight }; icon.Width = 25; icon.Height = 25; icon.VerticalAlignment = VerticalAlignment.Center; icon.HorizontalAlignment = HorizontalAlignment.Right; icon.SetValue(Grid.ColumnProperty, 4); icon.Name = "seta" + service_id; icon.PreviewMouseLeftButtonDown += PackIcon_PreviewMouseLeftButtonDown; painel.Children.Add(novaGrid); novaGrid.Children.Add(bin); novaGrid.Children.Add(newTextBox); novaGrid.Children.Add(newTextBox2); novaGrid.Children.Add(icon); if (flag % 2 == 0) { var converter = new System.Windows.Media.BrushConverter(); var brush = (Brush)converter.ConvertFromString("#FFD0EDED"); novaGrid.Background = brush; } else { var converter = new System.Windows.Media.BrushConverter(); var brush = (Brush)converter.ConvertFromString("#FFC2DCDC"); novaGrid.Background = brush; } flag++; } }
/// <summary> /// Render individual players /// </summary> /// <param name="selection">The champion the player has selected</param> /// <param name="player">The participant details of the player</param> /// <returns></returns> internal ChampSelectPlayer RenderPlayer(PlayerChampionSelectionDTO selection, PlayerParticipant player) { ChampSelectPlayer control = new ChampSelectPlayer(); //Render champion if (selection.ChampionId != 0) { control.ChampionImage.Source = champions.GetChampion(selection.ChampionId).icon; } //Render summoner spells if (selection.Spell1Id != 0) { string uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName((int)selection.Spell1Id)); control.SummonerSpell1.Source = Client.GetImage(uriSource); uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName((int)selection.Spell2Id)); control.SummonerSpell2.Source = Client.GetImage(uriSource); } //Set our summoner spells in client if (player.SummonerName == Client.LoginPacket.AllSummonerData.Summoner.Name) { string uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName((int)selection.Spell1Id)); SummonerSpell1Image.Source = Client.GetImage(uriSource); uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName((int)selection.Spell2Id)); SummonerSpell2Image.Source = Client.GetImage(uriSource); MyChampId = selection.ChampionId; } //Has locked in if (player.PickMode == 2 || LatestDto.GameState == "POST_CHAMP_SELECT" || LatestDto.GameState == "START_REQUESTED") { string uriSource = "/LegendaryClient;component/Locked.png"; control.LockedInIcon.Source = Client.GetImage(uriSource); } //Make obvious whos pick turn it is if (player.PickTurn != LatestDto.PickTurn && (LatestDto.GameState == "CHAMP_SELECT" || LatestDto.GameState == "PRE_CHAMP_SELECT")) { control.Opacity = 0.5; } else { //Full opacity when not picking or banning control.Opacity = 1; } //If trading with this player is possible if (CanTradeWith != null && (CanTradeWith.PotentialTraders.Contains(player.SummonerInternalName) || DevMode)) { control.TradeButton.Visibility = System.Windows.Visibility.Visible; } //If this player is duo/trio/quadra queued with players if (player.TeamParticipantId != null && (double)player.TeamParticipantId != 0) { //Byte hack to get individual hex colors byte[] values = BitConverter.GetBytes((double)player.TeamParticipantId); if (!BitConverter.IsLittleEndian) { Array.Reverse(values); } byte r = values[2]; byte b = values[3]; byte g = values[4]; System.Drawing.Color myColor = System.Drawing.Color.FromArgb(r, b, g); var converter = new System.Windows.Media.BrushConverter(); var brush = (Brush)converter.ConvertFromString("#" + myColor.Name); control.TeamRectangle.Fill = brush; control.TeamRectangle.Visibility = System.Windows.Visibility.Visible; } control.LockedInIcon.Visibility = System.Windows.Visibility.Visible; control.TradeButton.Tag = new KeyValuePair <PlayerChampionSelectionDTO, PlayerParticipant>(selection, player); control.TradeButton.Click += TradeButton_Click; control.PlayerName.Content = player.SummonerName; return(control); }
private void Start() { System.Globalization.CultureInfo.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; ShopUtils.CreateFiles(); productList = ShopUtils.DeserializeProducts(ShopUtils.GetFilePath("Products.json")); shoppingCart = ShopUtils.DeserializeProducts(ShopUtils.GetFilePath("Cart.json")); couponList = Coupon.DeserializeCoupons(); #region Custom brushes // declare a brushconverter to convert a hex color code string to a Brush color BrushConverter brushConverter = new System.Windows.Media.BrushConverter(); Brush backgroundBrush = (Brush)brushConverter.ConvertFromString("#2F3136"); Brush listBoxBrush = (Brush)brushConverter.ConvertFromString("#36393F"); Brush textBoxBrush = (Brush)brushConverter.ConvertFromString("#40444B"); Brush expanderBrush = (Brush)brushConverter.ConvertFromString("#202225"); #endregion // Set Window properties Title = "Butiken"; Width = 900; Height = 600; WindowStartupLocation = WindowStartupLocation.CenterScreen; // Changes the Window icon Uri iconUri = new Uri("Images/Ica.png", UriKind.RelativeOrAbsolute); this.Icon = BitmapFrame.Create(iconUri); // Scrolling ScrollViewer root = new ScrollViewer(); root.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; Content = root; // Main grid definition Grid mainGrid = new Grid(); root.Content = mainGrid; mainGrid.RowDefinitions.Add(new RowDefinition()); // First column contains the shoppingcart and product assortment. mainGrid.ColumnDefinitions.Add(new ColumnDefinition()); // The second column displays the selected product and upon payment displays the receipt mainGrid.ColumnDefinitions.Add(new ColumnDefinition()); mainGrid.Background = backgroundBrush; #region grid definiton for the Expander in leftGrid Grid expanderCartGrid = new Grid(); expanderCartGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); expanderCartGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); expanderCartGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); expanderCartGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); expanderCartGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); expanderCartGrid.RowDefinitions.Add(new RowDefinition()); expanderCartGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); expanderCartGrid.ColumnDefinitions.Add(new ColumnDefinition()); expanderCartGrid.ColumnDefinitions.Add(new ColumnDefinition()); TextBlock cartTextBlock = ShopUtils.CreateTextBlock("Varukorg", 18, TextAlignment.Center); expanderCartGrid.Children.Add(cartTextBlock); Grid.SetRow(cartTextBlock, 0); Grid.SetColumn(cartTextBlock, 0); Grid.SetColumnSpan(cartTextBlock, 2); TextBlock discountTextBlock = ShopUtils.CreateTextBlock("Mata in rabattkod nedan", 12, TextAlignment.Center); expanderCartGrid.Children.Add(discountTextBlock); Grid.SetRow(discountTextBlock, 1); Grid.SetColumn(discountTextBlock, 0); Grid.SetColumnSpan(discountTextBlock, 1); // A combobox to display available coupons to the user couponComboBox = new ComboBox { HorizontalAlignment = HorizontalAlignment.Right, Height = 18, Margin = new Thickness(0, 5, 5, 5), BorderThickness = new Thickness(0), VerticalContentAlignment = VerticalAlignment.Top, Padding = new Thickness(5, 1, 5, 0), }; expanderCartGrid.Children.Add(couponComboBox); Grid.SetRow(couponComboBox, 1); Grid.SetColumn(couponComboBox, 1); // add a default index at 0, can be selected to clear the couponTextBox.Text couponComboBox.Items.Add("Dina rabattkoder"); couponComboBox.SelectedIndex = 0; couponComboBox.SelectionChanged += AddToCouponTextBox; // Adds all available coupons to the couponComboBox items from the couponList which recieves predetermined coupons from file foreach (var coupon in couponList) { couponComboBox.Items.Add(coupon.Code + " " + (100 - Math.Round(coupon.Discount * 100, 0)) + "%"); } // A textbox for the user to enter coupon codes couponTextBox = new TextBox { Margin = new Thickness(5), Background = textBoxBrush, Foreground = Brushes.White, BorderThickness = new Thickness(0), FontWeight = FontWeights.SemiBold }; expanderCartGrid.Children.Add(couponTextBox); Grid.SetRow(couponTextBox, 2); Grid.SetColumnSpan(couponTextBox, 1); ShopUtils.CreateButton("Använd rabattkod", expanderCartGrid, 2, 2, 1, ValidateCoupon); ShopUtils.CreateButton("Rensa varukorg", expanderCartGrid, row: 3, column: 0, columnspan: 1, ClearCartClick); ShopUtils.CreateButton("Spara varukorg", expanderCartGrid, 3, 1, 1, SaveCartClick); ShopUtils.CreateButton("Ta bort en vald produkt", expanderCartGrid, row: 4, column: 0, columnspan: 1, RemoveProductClick); ShopUtils.CreateButton("Ta bort varje vald produkt", expanderCartGrid, 4, 1, 1, RemoveAllSelectedProductsClick); // the cartListBox display all products in the shoppingCart list cartListBox = new ListBox { Margin = new Thickness(5), VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch, MaxHeight = 200, MinHeight = 200, Background = listBoxBrush, Foreground = Brushes.White, BorderThickness = new Thickness(0), FontWeight = FontWeights.SemiBold }; expanderCartGrid.Children.Add(cartListBox); Grid.SetRow(cartListBox, 5); Grid.SetColumnSpan(cartListBox, 2); sumTextBlock = ShopUtils.CreateTextBlock("Varukorgens summa: 0 kr", 12, TextAlignment.Left); expanderCartGrid.Children.Add(sumTextBlock); Grid.SetRow(sumTextBlock, 6); Grid.SetColumn(sumTextBlock, 0); Grid.SetColumnSpan(sumTextBlock, 1); ShopUtils.CreateButton("Till kassan", expanderCartGrid, 6, 1, 1, ShowReceipt); #endregion #region leftGrid definition Grid leftGrid = new Grid(); mainGrid.Children.Add(leftGrid); leftGrid.ColumnDefinitions.Add(new ColumnDefinition()); leftGrid.ColumnDefinitions.Add(new ColumnDefinition()); leftGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); leftGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); leftGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); leftGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); leftGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); leftGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); leftGrid.RowDefinitions.Add(new RowDefinition()); Grid.SetRow(leftGrid, 0); Grid.SetColumn(leftGrid, 0); // Expander definition, when expanded the expanderCartGrid will be displayed in the leftGrid cartExpander = new Expander { // sets the expanders content to the expanderCartGrid defined above Content = expanderCartGrid, Header = "Din varukorg 0 kr", FontWeight = FontWeights.SemiBold, Foreground = Brushes.White, Background = expanderBrush }; leftGrid.Children.Add(cartExpander); Grid.SetRow(cartExpander, 0); Grid.SetColumn(cartExpander, 0); // when expanded the cartExpander's columnspan increases to take up two columns and when collapsed shrinks to one column cartExpander.Collapsed += DecreaseCartColumnSpan; cartExpander.Expanded += IncreaseCartColumnSpan; // Update the cartListBox in the Expander to add items from the shoppingCart list UpdateCartListBox(); TextBlock products = ShopUtils.CreateTextBlock("Produkter", 18, TextAlignment.Center); leftGrid.Children.Add(products); Grid.SetRow(products, 1); Grid.SetColumn(products, 0); Grid.SetColumnSpan(products, 2); TextBlock searchHeading = ShopUtils.CreateTextBlock("Sök efter produkt", 12, TextAlignment.Center); leftGrid.Children.Add(searchHeading); Grid.SetRow(searchHeading, 2); Grid.SetColumn(searchHeading, 0); Grid.SetColumnSpan(searchHeading, 2); // A textbox definition where the user can input a search term searchBox = new TextBox { Margin = new Thickness(5), Background = textBoxBrush, Foreground = Brushes.White, BorderThickness = new Thickness(0), FontWeight = FontWeights.SemiBold }; leftGrid.Children.Add(searchBox); Grid.SetRow(searchBox, 3); Grid.SetColumnSpan(searchBox, 2); // when the searchbox text changes the ShowSearch event will run searchBox.TextChanged += ShowSearch; // A combobox which displays available categories categoryBox = new ComboBox { Margin = new Thickness(5), BorderThickness = new Thickness(0), FontWeight = FontWeights.SemiBold, Height = 22, }; leftGrid.Children.Add(categoryBox); Grid.SetRow(categoryBox, 4); Grid.SetColumn(categoryBox, 0); Grid.SetColumnSpan(categoryBox, 2); categoryBox.Items.Add("Välj kategori"); categoryBox.SelectedIndex = 0; categoryList = ShopUtils.GenerateCategories(productList); // adds categories to the categoryBox foreach (string category in categoryList) { categoryBox.Items.Add(category); } categoryBox.SelectionChanged += ShowCategory; ShopUtils.CreateButton("Lägg till vald produkt", leftGrid, row: 5, column: 0, columnspan: 2, AddProductToCart); // Listbox definition, used to display the product assortment from the searchTermList productListBox = new ListBox { Margin = new Thickness(5), VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch, MaxHeight = 425, Background = listBoxBrush, Foreground = Brushes.White, BorderThickness = new Thickness(0), FontWeight = FontWeights.SemiBold }; leftGrid.Children.Add(productListBox); Grid.SetRow(productListBox, 6); Grid.SetColumn(productListBox, 0); Grid.SetColumnSpan(productListBox, 2); // set the searchTerm to empty string in order to add every product from the productList upon start UpdateProductListBox(""); // selecting an item in the listbox will display productinformation in the stackpanel to the right productListBox.SelectionChanged += DisplaySelectedProduct; #endregion #region rightStackPanel definition StackPanel rightStackPanel = new StackPanel(); mainGrid.Children.Add(rightStackPanel); Grid.SetRow(rightStackPanel, 0); Grid.SetColumn(rightStackPanel, 1); productHeading = ShopUtils.CreateTextBlock("Välj produkt", 18, TextAlignment.Center, rightStackPanel); productHeading.Margin = new Thickness(5, 30, 5, 32); imageGrid = new Grid(); rightStackPanel.Children.Add(imageGrid); // sets a startup image currentImage = ShopUtils.CreateImage("Images/Ica.png", false); imageGrid.Children.Add(currentImage); productDescriptionHeading = ShopUtils.CreateTextBlock("", 16, TextAlignment.Center, rightStackPanel); productDescription = ShopUtils.CreateTextBlock("", 12, TextAlignment.Center, rightStackPanel); productDescription.FontWeight = FontWeights.Thin; productDescription.Margin = new Thickness(30, 5, 30, 5); #endregion }
public void atualizarLista(String nomeInstituto) { painel.Children.Clear(); foreach (UtilizadorInfo u in listaUtilizadores) { foreach (String s in u.reservas) { int service_id = Convert.ToInt32(s.Split("|")[0]); String horas = s.Split("|")[1]; String dia = s.Split("|")[2]; foreach (InstitutoInfo i in listaInstitutos) { if ((currentUser.user_institutos_id.Contains(i.id) == true) && (i.servicos_id.Contains(service_id) == true) && (i.nome.Equals(nomeInstituto) || i.nome.Equals(""))) { String servico_tipo = ""; foreach (ServiceInfo servico in listaServicos) { if (servico.id == service_id) { servico_tipo = servico.tipo; } } Grid firstGrid = new Grid(); firstGrid.Height = 70; RowDefinition rowDef0 = new RowDefinition(); rowDef0.Height = new GridLength(40, GridUnitType.Star); RowDefinition rowDef1 = new RowDefinition(); rowDef1.Height = new GridLength(20, GridUnitType.Star); firstGrid.RowDefinitions.Add(rowDef0); firstGrid.RowDefinitions.Add(rowDef1); Grid secondGrid = new Grid(); ColumnDefinition colDef0 = new ColumnDefinition(); colDef0.Width = new GridLength(60, GridUnitType.Star); ColumnDefinition colDef1 = new ColumnDefinition(); colDef1.Width = new GridLength(230, GridUnitType.Star); ColumnDefinition colDef2 = new ColumnDefinition(); colDef2.Width = new GridLength(50, GridUnitType.Star); ColumnDefinition colDef3 = new ColumnDefinition(); colDef3.Width = new GridLength(50, GridUnitType.Star); ColumnDefinition colDef4 = new ColumnDefinition(); colDef4.Width = new GridLength(20, GridUnitType.Star); secondGrid.ColumnDefinitions.Add(colDef0); secondGrid.ColumnDefinitions.Add(colDef1); secondGrid.ColumnDefinitions.Add(colDef2); secondGrid.ColumnDefinitions.Add(colDef3); secondGrid.ColumnDefinitions.Add(colDef4); secondGrid.SetValue(Grid.RowProperty, 0); TextBlock newTextBox = new TextBlock(); newTextBox.Text = servico_tipo; newTextBox.VerticalAlignment = VerticalAlignment.Center; newTextBox.SetValue(Grid.ColumnProperty, 1); newTextBox.FontSize = 20; TextBlock newTextBox1 = new TextBlock(); newTextBox1.Text = dia; newTextBox1.VerticalAlignment = VerticalAlignment.Center; newTextBox1.SetValue(Grid.ColumnProperty, 2); newTextBox1.FontSize = 20; TextBlock newTextBox2 = new TextBlock(); newTextBox2.Text = horas; newTextBox2.VerticalAlignment = VerticalAlignment.Center; newTextBox2.SetValue(Grid.ColumnProperty, 3); newTextBox2.FontSize = 20; secondGrid.Children.Add(newTextBox); secondGrid.Children.Add(newTextBox1); secondGrid.Children.Add(newTextBox2); Grid thirdGrid = new Grid(); ColumnDefinition colDef00 = new ColumnDefinition(); colDef00.Width = new GridLength(60, GridUnitType.Star); ColumnDefinition colDef01 = new ColumnDefinition(); colDef01.Width = new GridLength(280, GridUnitType.Star); ColumnDefinition colDef02 = new ColumnDefinition(); colDef02.Width = new GridLength(50, GridUnitType.Star); ColumnDefinition colDef03 = new ColumnDefinition(); colDef03.Width = new GridLength(20, GridUnitType.Star); thirdGrid.ColumnDefinitions.Add(colDef00); thirdGrid.ColumnDefinitions.Add(colDef01); thirdGrid.ColumnDefinitions.Add(colDef02); thirdGrid.ColumnDefinitions.Add(colDef03); thirdGrid.SetValue(Grid.RowProperty, 1); TextBlock newTextBox3 = new TextBlock(); newTextBox3.Text = u.username; newTextBox3.HorizontalAlignment = HorizontalAlignment.Right; newTextBox3.VerticalAlignment = VerticalAlignment.Center; newTextBox3.SetValue(Grid.ColumnProperty, 1); newTextBox3.FontSize = 16; var converter = new System.Windows.Media.BrushConverter(); var brush = (Brush)converter.ConvertFromString("#FF60C4E5"); var icon = new nova { Kind = PackIconKind.ArrowRight }; icon.Width = 25; icon.Height = 25; icon.HorizontalAlignment = HorizontalAlignment.Center; icon.VerticalAlignment = VerticalAlignment.Center; icon.SetValue(Grid.ColumnProperty, 2); icon.Name = "seta" + u.id; icon.PreviewMouseLeftButtonDown += Icon_PreviewMouseLeftButtonDown; thirdGrid.Children.Add(icon); thirdGrid.Children.Add(newTextBox3); painel.Children.Add(firstGrid); firstGrid.Children.Add(secondGrid); firstGrid.Children.Add(thirdGrid); } } } } }
private void StartCompanyButton_Click(object sender, RoutedEventArgs e) { int readyToContinue = 5; var converter = new System.Windows.Media.BrushConverter(); var brush = (Brush)converter.ConvertFromString("#F29705"); // Cheking if statements for invalid fields if (companyBudgetTextBox.Text == "") { MessageBox.Show("Invalid Budget.", "Invalid Data", MessageBoxButton.OK, MessageBoxImage.Error); brush = (Brush)converter.ConvertFromString("#F29705"); companyBudget.Foreground = brush; readyToContinue -= 1; } else { CompanyVariables.CurrentMonthBudget = companyBudgetTextBox.Text; brush = (Brush)converter.ConvertFromString("#ffffff"); companyBudget.Foreground = brush; } if (companyNameTextBox.Text == "") { MessageBox.Show("Invalid Company Name.", "Invalid Data", MessageBoxButton.OK, MessageBoxImage.Error); brush = (Brush)converter.ConvertFromString("#F29705"); companyName.Foreground = brush; readyToContinue -= 1; } else { CompanyVariables.CompanyName = companyNameTextBox.Text; brush = (Brush)converter.ConvertFromString("#ffffff"); companyName.Foreground = brush; } if (currencyComboBox.SelectedItem == null) { MessageBox.Show("Please select a Currency.", "Invalid Data", MessageBoxButton.OK, MessageBoxImage.Error); readyToContinue -= 1; } else { CompanyVariables.Currency = (String)currencyComboBox.SelectedItem; } if (companyCurrentSpendingTextBox.Text == "") { MessageBox.Show("Invalid Spendings.", "Invalid Data", MessageBoxButton.OK, MessageBoxImage.Error); brush = (Brush)converter.ConvertFromString("#F29705"); companySpendings.Foreground = brush; readyToContinue -= 1; } else { CompanyVariables.CurrentMonthSpent = companyCurrentSpendingTextBox.Text; brush = (Brush)converter.ConvertFromString("#ffffff"); companySpendings.Foreground = brush; } // By having this temp var the app assures that it won't start any mroe funtions before the data is all complete if (readyToContinue == 5) { // Database communication CreateCompanyModel(); // Starts the dashboard MainWindow window = new MainWindow("RetailStore"); window.Owner = this; window.WindowStartupLocation = WindowStartupLocation.CenterOwner; window.Show(); // Sets the owner to the new window so that the user can close the StarterWindow and // the program not close. window.Owner = null; this.Owner = window; this.Close(); } }
/// <summary> /// The GetMessages /// </summary> public void GetMessages() { var id = current_User.Chat_id; if (id != 0) { String request = BackendConnect.server + "messages/" + id.ToString() + "/since/" + current_User.Lastest_message.ToString(); var content = Backend.Get(request); if (content != null) { current_User.Lastest_message = content[content.Count - 1].Time_submitted; for (int i = 0; i < content.Count; i++) { String Users_Name = BackendConnect.server + "user/" + content[i].User_id.ToString(); var ListUsers_Name = Backend.Get(Users_Name); Users_Name = ListUsers_Name[0].Username; var time = Tools.ConvertFromUnixTimestamp(content[i].Time_submitted); var converter = new System.Windows.Media.BrushConverter(); Button Delete_button = new Button { Content = "[x]", Background = (Brush)converter.ConvertFromString("transparent"), BorderBrush = (Brush)converter.ConvertFromString("transparent"), Foreground = (Brush)converter.ConvertFromString("white") }; Delete_button.Click += new RoutedEventHandler(Message_Click); Delete_button.Tag = content[i].Id; if (content[i].Message != null) { TextBlock Message = new TextBlock { Text = time + " | " + Users_Name + ": " + content[i].Message, Margin = new Thickness(20, 0, 0, 0) }; Canvas all = new Canvas { Height = 25 }; all.Children.Add(Delete_button); all.Children.Add(Message); Chat_ListBox.Items.Add(all); } else if (content[i].File_id != null) { List <string> ImageExtensions = new List <string> { ".JPG", ".JPE", ".BMP", ".GIF", ".PNG" }; var Source = BackendConnect.server + "file/" + current_User.Chat_id + '/' + content[i].File_id; Canvas all = new Canvas { }; Button download_button = new Button { Content = time + " | " + Users_Name + ": " + content[i].File_name, Background = (Brush)converter.ConvertFromString("transparent"), BorderBrush = (Brush)converter.ConvertFromString("transparent"), Foreground = (Brush)converter.ConvertFromString("white"), Margin = new Thickness(20, 0, 0, 0) }; download_button.Click += new RoutedEventHandler(Download_click); download_button.Tag = content[i]; if (ImageExtensions.Contains(Path.GetExtension(content[i].File_name).ToUpperInvariant())) { all.Height = 125; Uri uri = new Uri(Source, UriKind.Absolute); ImageSource imgSource = new BitmapImage(uri); Image image = new Image { Source = imgSource, Height = 100, Margin = new Thickness(0, 20, 0, 0) }; image.MouseLeftButtonUp += (s, e) => { Image image_clicked = (Image)s; Image_Page image_Page = new Image_Page(image_clicked.Source); image_Page.Show(); }; all.Children.Add(image); } else { all.Height = 25; } all.Children.Add(Delete_button); all.Children.Add(download_button); Chat_ListBox.Items.Add(all); } else if (content[i].Collab != null) { Canvas all = new Canvas { Height = 25 }; Button Collab_button = new Button { Content = time + " | " + Users_Name + ": " + content[i].File_name, Background = (Brush)converter.ConvertFromString("transparent"), BorderBrush = (Brush)converter.ConvertFromString("transparent"), Foreground = (Brush)converter.ConvertFromString("white"), Margin = new Thickness(20, 0, 0, 0) }; Collab_button.Click += new RoutedEventHandler(Collab_click); Collab_button.Tag = content[i]; all.Children.Add(Delete_button); all.Children.Add(Collab_button); Chat_ListBox.Items.Add(all); } } } } }
public void Update(PlatformGameLifecycleDTO CurrentGame) { Game = CurrentGame; BlueBansLabel.Visibility = System.Windows.Visibility.Hidden; PurpleBansLabel.Visibility = System.Windows.Visibility.Hidden; PurpleBanListView.Items.Clear(); BlueBanListView.Items.Clear(); BlueListView.Items.Clear(); PurpleListView.Items.Clear(); ImageGrid.Children.Clear(); List <Participant> AllParticipants = new List <Participant>(CurrentGame.Game.TeamOne.ToArray()); AllParticipants.AddRange(CurrentGame.Game.TeamTwo); int i = 0; int y = 0; foreach (Participant part in AllParticipants) { ChampSelectPlayer control = new ChampSelectPlayer(); if (part is PlayerParticipant) { PlayerParticipant participant = part as PlayerParticipant; foreach (PlayerChampionSelectionDTO championSelect in CurrentGame.Game.PlayerChampionSelections) { if (championSelect.SummonerInternalName == participant.SummonerInternalName) { control.ChampionImage.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.SummonerSpell1.Source = new BitmapImage(uriSource); uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell2Id))), UriKind.Absolute); control.SummonerSpell2.Source = new BitmapImage(uriSource); #region Generate Background Image m = new Image(); Canvas.SetZIndex(m, -2); m.Stretch = Stretch.None; m.Width = 100; m.Opacity = 0.50; m.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; m.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; m.Margin = new System.Windows.Thickness(y++ *100, 0, 0, 0); System.Drawing.Rectangle cropRect = new System.Drawing.Rectangle(new System.Drawing.Point(100, 0), new System.Drawing.Size(100, 560)); System.Drawing.Bitmap src = System.Drawing.Image.FromFile(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", champions.GetChampion(championSelect.ChampionId).portraitPath)) as System.Drawing.Bitmap; System.Drawing.Bitmap target = new System.Drawing.Bitmap(cropRect.Width, cropRect.Height); using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(target)) { g.DrawImage(src, new System.Drawing.Rectangle(0, 0, target.Width, target.Height), cropRect, System.Drawing.GraphicsUnit.Pixel); } m.Source = Client.ToWpfBitmap(target); ImageGrid.Children.Add(m); #endregion Generate Background } } control.PlayerName.Content = participant.SummonerName; if (participant.TeamParticipantId != null) { byte[] values = BitConverter.GetBytes((double)participant.TeamParticipantId); if (!BitConverter.IsLittleEndian) { Array.Reverse(values); } byte r = values[2]; byte b = values[3]; byte g = values[4]; System.Drawing.Color myColor = System.Drawing.Color.FromArgb(r, b, g); var converter = new System.Windows.Media.BrushConverter(); var brush = (Brush)converter.ConvertFromString("#" + myColor.Name); control.TeamRectangle.Fill = brush; control.TeamRectangle.Visibility = System.Windows.Visibility.Visible; } } i++; if (i <= 5) { BlueListView.Items.Add(control); } else { PurpleListView.Items.Add(control); } } if (CurrentGame.Game.BannedChampions.Count > 0) { BlueBansLabel.Visibility = System.Windows.Visibility.Visible; PurpleBansLabel.Visibility = System.Windows.Visibility.Visible; } foreach (var x in CurrentGame.Game.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); } } try { string mmrJSON = ""; string url = Client.Region.SpectatorLink + "consumer/getGameMetaData/" + Client.Region.InternalName + "/" + CurrentGame.Game.Id + "/token"; using (WebClient client = new WebClient()) { mmrJSON = client.DownloadString(url); } JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary <string, object> deserializedJSON = serializer.Deserialize <Dictionary <string, object> >(mmrJSON); MMRLabel.Content = "≈" + deserializedJSON["interestScore"]; } catch { MMRLabel.Content = "N/A"; } }