示例#1
0
        public static void Main()
        {

            MultiButtonHelper mbh = new MultiButtonHelper();
            mbh.AddButtonHandler(new Buttons[] {Buttons.TopRight, Buttons.BottomRight,},
                                 new MultiButtonHelper.HandleClicks(ResetAll));

            // initialize display buffer
            _display = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight);
            _drawing = new Drawing(_display);

            menu = new Menu(menuFont, _display);
            menu.OnMenuItemClicked += menu_OnMenuItemClicked;
            menu.Items.Add(new MenuItem() {Title = "1 Minute", CommandArg = "1"});
            menu.Items.Add(new MenuItem() {Title = "2 Minutes", CommandArg = "2"});
            menu.Items.Add(new MenuItem() {Title = "3 Minutes", CommandArg = "3"});
            menu.Items.Add(new MenuItem() {Title = "4 Minutes", CommandArg = "4"});
            menu.Items.Add(new MenuItem() {Title = "5 Minutes", CommandArg = "5"});
            menu.Items.Add(new MenuItem() {Title = "10 Minutes", CommandArg = "10"});
            menu.Items.Add(new MenuItem() {Title = "15 Minutes", CommandArg = "15"});
            menu.Items.Add(new MenuItem() {Title = "20 Minutes", CommandArg = "20"});
            menu.Items.Add(new MenuItem() {Title = "30 Minutes", CommandArg = "30"});
            menu.Items.Add(new MenuItem() {Title = "45 Minutes", CommandArg = "45"});
            menu.Items.Add(new MenuItem() {Title = "60 Minutes", CommandArg = "60"});

            ShowMenu();
            // go to sleep; all further code should be timer-driven or event-driven
            Thread.Sleep(Timeout.Infinite);
        }
示例#2
0
        static void p_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            LastResult = (channel.Read(p) as Coordinate);
            _display.Clear();
            var drawing = new Agent.Contrib.Drawing.Drawing();
            if (LastResult.Action == Action.Data || LastResult.Action == Action.Start || LastResult.Action == Action.Stop)
            {
                drawing.DrawAlignedText(_display, Color.White, font, LastResult.Time, HAlign.Center, 0, VAlign.Top, 0);
                drawing.DrawAlignedText(_display, Color.White, font, LastResult.Distance, HAlign.Center, 0, VAlign.Middle, 0);
                drawing.DrawAlignedText(_display, Color.White, font, LastResult.Pace, HAlign.Center, 0, VAlign.Bottom, 0);

                //_display.DrawText("Calories:" + LastResult.Calories, fontNinaB, Color.White, 1, fontNinaB.Height*2);
                if (LastResult.Action == Action.Start)
                {
                    _startStopState = Action.Start;
                }
                if (LastResult.Action == Action.Stop)
                {
                    _startStopState = Action.Stop;
                }

            }
            else if (LastResult.Action == Action.Hello)
            {
                drawing.DrawAlignedText(_display, Color.White, font, "Connected!", HAlign.Center, 0, VAlign.Middle, 0);
                
            }
            if (_startStopState == Action.Start)
            {
                //_display.DrawText("State: Started", font, Color.White, 1, top);
            }
            if (_startStopState == Action.Stop)
            {
                //_display.DrawText("State: Stopped", font, Color.White, 1, top);
            }

            _display.Flush();


        }
示例#3
0
        public static void Main()
        {
            ButtonHelper.ButtonSetup = new Buttons[]{Buttons.BottomRight, Buttons.MiddleRight, Buttons.TopRight,  };
            ButtonHelper.Current.OnButtonPress += Current_OnButtonPress;
            // initialize display buffer
            _display = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight);

            // sample "hello world" code
            _display.Clear();
            var drawing = new Agent.Contrib.Drawing.Drawing();
            drawing.DrawAlignedText(_display, Color.White, font, "Connect...", HAlign.Center, 0, VAlign.Middle, 0);
            _display.Flush();
            

            p = new SerialPort("COM1");
            p.DataReceived += p_DataReceived;
            p.Open();




            // go to sleep; all further code should be timer-driven or event-driven
            Thread.Sleep(Timeout.Infinite);
        }