public void LoadDrawing() { // Get items from server String[] items = App.client.GetItemsFromServer().ToArray(); // Shuffle elements of items Random random = new Random(); for (int i = 0; i < items.Length-1; i += 1) { int swapIndex = random.Next(i + 1, items.Length); String temp = items[i]; items[i] = items[swapIndex]; items[swapIndex] = temp; } // Check if a drawing exists for this item foreach (String item in items) { drawingToGuess = App.client.GetDrawingFromServer(item); Console.Write("Check drawing for " + item+"? "); Console.WriteLine(drawingToGuess != null); if (drawingToGuess != null) break; } drawingLoaded = (drawingToGuess!=null); }
//private readonly Action _graphicObjectSelected; //private readonly Action _verticleSelected; //private readonly Func<int, bool> _lineSelected; //private readonly Action _nullSelected; //private readonly Action _circleSelected; public FormLogic(Drawing.Drawing drawing, TextBox timeTextBox, MainForm.ButtonControl buttonControl) { GraphicObjects = new Dictionary <Guid, GraphicObject>(); //Lines = new Dictionary<Guid, Line>(); _timeTextBox = timeTextBox; _buttonControl = buttonControl; //this._graphicObjectSelected = graphicObjectSelected; //this._verticleSelected = verticleSelected; //this._lineSelected = lineSelected; //_nullSelected = nullSelected; //_circleSelected = circleSelected; Drawing = drawing; _formAction = FormAction.NoAction; _clicksDrawLine = new List <Point>(128); _clicksStartDrawPolygon = new List <Point>(128); _clicksDrawCircleOptimized = new List <Point>(128); _clicksOther = new List <Point>(128); _clicksSetConcerntic = new List <Point>(128); GuidMapLogic = new GuidMapLogic(drawing.Height, drawing.Width); }
public AfterGuessingPanel(Drawing.Drawing drawingGuessed, ulong userScore) { this.InitializeComponent(); this.userScore = userScore; bool isHighscore = false; IsHighScoreFeedback.Visibility = System.Windows.Visibility.Collapsed; IsNotHighScoreFeedback.Visibility = System.Windows.Visibility.Collapsed; SaveFeedbackOK.Visibility = System.Windows.Visibility.Collapsed; SaveFeedbackNOTOK.Visibility = System.Windows.Visibility.Collapsed; ButtonGoBackHome.Visibility = System.Windows.Visibility.Collapsed; currentDrawing = drawingGuessed; UserScore.Text = FormatScore(userScore); Highscores.Highscore high = App.client.GetHighscoreFromServer(drawingGuessed); if (high != null) { ChampionScore.Text = FormatScore(high.score); ChampionIdentity.Text = "By " + high.scorerName + " at " + high.scoreTimestamp; isHighscore = Highscores.Highscore.CompareScores(userScore, high.score); } else { ChampionScore.Text = FormatScore(userScore); ChampionIdentity.Text = ""; ChampionIdentity.Visibility = System.Windows.Visibility.Collapsed; isHighscore = true; } if (isHighscore) { IsHighScoreFeedback.Visibility = System.Windows.Visibility.Visible; IsNotHighScoreFeedback.Visibility = System.Windows.Visibility.Collapsed; } else { IsHighScoreFeedback.Visibility = System.Windows.Visibility.Collapsed; IsNotHighScoreFeedback.Visibility = System.Windows.Visibility.Visible; } }
private IEnumerator<SampledStroke> strokesEnum; // return the next sampledStroke to start to be drawn #endregion Fields #region Constructors /// <summary> /// Default constructor. /// </summary> public DrawingPanel(String itemToDraw, Boolean addingNewDrawing) { InitializeComponent(); item = itemToDraw; this.addingNewDrawing = addingNewDrawing; currentDrawing = new Drawing.Drawing(item); // Hide buttons and everything SaveFeedbackOK.Visibility = System.Windows.Visibility.Collapsed; SaveFeedbackNOTOK.Visibility = System.Windows.Visibility.Collapsed; ButtonGoBackHome.Visibility = System.Windows.Visibility.Collapsed; // If the user wants to add his own title if (addingNewDrawing) { DrawingToDraw.Visibility = System.Windows.Visibility.Collapsed; FieldTitle.Visibility = System.Windows.Visibility.Visible; Console.WriteLine("Entering Draw mode with adding New Drawing"); } // If the user uses what was written on the card else { DrawingToDraw.Visibility = System.Windows.Visibility.Visible; FieldTitle.Visibility = System.Windows.Visibility.Collapsed; DrawingToDraw.Text = item; Console.WriteLine("Entering Draw mode with item given on card"); } saveTimer = new System.Windows.Threading.DispatcherTimer(); saveTimer.Tick += new EventHandler(SaveFrame); saveTimer.Interval = new TimeSpan(0, 0, 0, 0, REFRESH_TIME_SAVE); drawTimer = new System.Windows.Threading.DispatcherTimer(); drawTimer.Tick += new EventHandler(DrawFrame); drawTimer.Interval = new TimeSpan(0, 0, 0, 0, REFRESH_TIME_DRAW); ChangeBrushColor(Colors.Black); }
// // // // --------------- \\ \\ \\ \\ // // // // Clear the board \\ \\ \\ \\ // // // // --------------- \\ \\ \\ \\ private void Reset(object sender, RoutedEventArgs e) { ClearBoard(); drawTimer.Stop(); canvas.EditingMode = SurfaceInkEditingMode.Ink; currentDrawing = new Drawing.Drawing(item); currentDrawing.SetBackgroundAsColor(((SolidColorBrush)canvas.Background).Color); }
public void SaveDrawing(string item) { Drawing.Drawing drawing = new Drawing.Drawing(item); Console.Write("Saving drawing of "+item+": "); Console.WriteLine(client.SaveDrawingToServer(drawing)); }