Exemplo n.º 1
0
        private static void checkSegmentMap()
        {
            var boundSegments = Options.SegmentMap.Where(x => x.Value != null);
            var count = boundSegments.Count();
            if (count == 0)
            {
                var mb = new MessageBoxScreen("Segment Map Warning",
                    "The segment map does not contain any bindings.\nEnter options to create the segment map.",
                    MessageBoxButtons.Ok);
                ScreenManager.AddScreen(mb);
            }
            else if (count != 62)
            {
                var mb = new MessageBoxScreen("Segment Map Warning",
                    "It seems like not all segments are bound\n(The segment map contains " + count +
                    " values,\nbut there are 62 segments on a dart board).\nEnter options to create the segment map.",
                    MessageBoxButtons.Ok);
                ScreenManager.AddScreen(mb);
            }

            foreach (var p1 in boundSegments)
            {
                foreach (var p2 in boundSegments)
                {
                    if (!p1.Key.Equals(p2.Key) && p1.Value.Equals(p2.Value))
                    {
                        Color c;
                        string text1, text2;
                        var dart1 = new Dart(null, p1.Key.X, p1.Key.Y);
                        dart1.GetVerbose(out text1, out c);
                        var dart2 = new Dart(null, p2.Key.X, p2.Key.Y);
                        dart2.GetVerbose(out text2, out c);
                        var mb = new MessageBoxScreen("Segment Map Warning",
                            "The segment: " + text1 + " and " + text2 + "\ncontains the same coordinates: " + p1.Value +
                            "!", MessageBoxButtons.Ok);
                        ScreenManager.AddScreen(mb);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void OpenPort()
        {
            if (_serialPort.IsOpen)
            {
                ClosePort();
            }

            try
            {
                _serialPort.Open();
            }
            catch (Exception ex)
            {
                var sb = new StringBuilder();

                sb.AppendLine("Could not establish a connection with the dart board:");
                sb.AppendLine("\"" + ex.Message + "\"");
                sb.AppendLine();
                sb.AppendLine("Please make sure that the dart board is connected and");
                sb.AppendLine("that the correct settings have been configured in the options.");

                var mb = new MessageBoxScreen("Error", sb.ToString(), MessageBoxButtons.Ok);

                var messageBoxTitle = ((TextBlock) mb.StackPanel.Items[0]);
                messageBoxTitle.Color = Color.Red;

                XnaDartsGame.ScreenManager.AddScreen(mb);
            }
        }