/// <summary> /// Constructs the Communicator class and registers callbacks /// No commands are sent. /// /// Definitions: /// UpdateCell - Callback that sends back successful cell edits. /// ErrorCB - Callback that sends back error codes and information about the error. /// isEditable- Callback that initiates when all cells have been received from the initial cell population. /// /// </summary> /// <param name="port"></param> /// <param name="serverIP"></param> /// <param name="e"></param> public Communicator(UpdateCell c, ErrorCB error, isEditable editable) { //Registering all callbacks updateCell = c; this.error = error; this.editable = editable; }
private void InitializeTable() { Color toUse = (Visibility)Application.Current.Resources["PhoneLightThemeVisibility"] == Visibility.Visible ? Colors.Black : Colors.White; //Uri iconUri = new Uri("/WP7StockListDemo;component/res/" + (toUse == Colors.White ? "lslogo.png" : "lslogo_black.png"),UriKind.Relative); //BitmapImage iconSource = new BitmapImage(iconUri); //logoImage.Source = iconSource; // Add TextBlocks to Cells for (int i = 0; i < ContentPanel.RowDefinitions.Count; i++) { if (i == 0) // title row continue; Dictionary<int, UpdateCell> TextMap = new Dictionary<int, UpdateCell>(); RowMap.Add(i - 1, TextMap); // for each column for (int y = 0; y < ContentPanel.ColumnDefinitions.Count; y++) { TextBlock tb = new TextBlock(); if (i > 1) tb.Text = "--"; SolidColorBrush colorB = new SolidColorBrush(toUse); tb.Foreground = colorB; Grid.SetRow(tb, i - 1); Grid.SetColumn(tb, y); Storyboard sbUp = new Storyboard(); Storyboard sbDown = new Storyboard(); Storyboard sbSame = new Storyboard(); // highlight color animation (in case of positive update) ColorAnimation colorUp = new ColorAnimation(); colorUp.From = toUse; colorUp.To = Colors.Green; colorUp.AutoReverse = true; colorUp.Duration = new Duration(TimeSpan.FromSeconds(0.6)); Storyboard.SetTarget(colorUp, tb.Foreground); Storyboard.SetTargetProperty(colorUp, new PropertyPath("Color")); sbUp.Children.Add(colorUp); // highlight color animation (in case of negative update) ColorAnimation colorDown = new ColorAnimation(); colorDown.From = toUse; colorDown.To = Colors.Red; colorDown.AutoReverse = true; colorDown.Duration = new Duration(TimeSpan.FromSeconds(0.6)); Storyboard.SetTarget(colorDown, tb.Foreground); Storyboard.SetTargetProperty(colorDown, new PropertyPath("Color")); sbDown.Children.Add(colorDown); // highlight color animation (in case of stable) ColorAnimation colorSame = new ColorAnimation(); colorSame.From = toUse; colorSame.To = Colors.Orange; colorSame.AutoReverse = true; colorSame.Duration = new Duration(TimeSpan.FromSeconds(0.6)); Storyboard.SetTarget(colorSame, tb.Foreground); Storyboard.SetTargetProperty(colorSame, new PropertyPath("Color")); sbSame.Children.Add(colorSame); UpdateCell cell = new UpdateCell(tb, sbUp, sbDown, sbSame); TextMap.Add(y, cell); ContentPanel.Children.Add(tb); } } }
private void InitializeTable() { Color toUse = (Visibility)Application.Current.Resources["PhoneLightThemeVisibility"] == Visibility.Visible ? Colors.Black : Colors.White; Uri iconUri = new Uri("/WP7StockListDemo;component/res/" + (toUse == Colors.White ? "lslogo.png" : "lslogo_black.png"), UriKind.Relative); BitmapImage iconSource = new BitmapImage(iconUri); logoImage.Source = iconSource; // Add TextBlocks to Cells for (int i = 0; i < ContentPanel.RowDefinitions.Count; i++) { if (i == 0) { // title row continue; } Dictionary <int, UpdateCell> TextMap = new Dictionary <int, UpdateCell>(); RowMap.Add(i - 1, TextMap); // for each column for (int y = 0; y < ContentPanel.ColumnDefinitions.Count; y++) { TextBlock tb = new TextBlock(); if (i > 1) { tb.Text = "--"; } SolidColorBrush colorB = new SolidColorBrush(toUse); tb.Foreground = colorB; Grid.SetRow(tb, i - 1); Grid.SetColumn(tb, y); Storyboard sbUp = new Storyboard(); Storyboard sbDown = new Storyboard(); Storyboard sbSame = new Storyboard(); // highlight color animation (in case of positive update) ColorAnimation colorUp = new ColorAnimation(); colorUp.From = toUse; colorUp.To = Colors.Green; colorUp.AutoReverse = true; colorUp.Duration = new Duration(TimeSpan.FromSeconds(0.6)); Storyboard.SetTarget(colorUp, tb.Foreground); Storyboard.SetTargetProperty(colorUp, new PropertyPath("Color")); sbUp.Children.Add(colorUp); // highlight color animation (in case of negative update) ColorAnimation colorDown = new ColorAnimation(); colorDown.From = toUse; colorDown.To = Colors.Red; colorDown.AutoReverse = true; colorDown.Duration = new Duration(TimeSpan.FromSeconds(0.6)); Storyboard.SetTarget(colorDown, tb.Foreground); Storyboard.SetTargetProperty(colorDown, new PropertyPath("Color")); sbDown.Children.Add(colorDown); // highlight color animation (in case of stable) ColorAnimation colorSame = new ColorAnimation(); colorSame.From = toUse; colorSame.To = Colors.Orange; colorSame.AutoReverse = true; colorSame.Duration = new Duration(TimeSpan.FromSeconds(0.6)); Storyboard.SetTarget(colorSame, tb.Foreground); Storyboard.SetTargetProperty(colorSame, new PropertyPath("Color")); sbSame.Children.Add(colorSame); UpdateCell cell = new UpdateCell(tb, sbUp, sbDown, sbSame); TextMap.Add(y, cell); ContentPanel.Children.Add(tb); } } }
public Game(UpdateCell updateCell, UpdatePlayerId updatePlayerId) { this.updatePlayerId = updatePlayerId; this.updateCell = updateCell; Update(); }