Exemplo n.º 1
0
 public async Task SetLayout(SettingsModel sm)
 {
     lock (_syncRootLayout)
     {
         _currentLayout          = new RootGrid();
         _currentLayout.elements = new List <Element>();
         int currRow = 0;
         if (sm.ShutdownControlEnabled)
         {
             _currentLayout.elements.Add(new Button {
                 id = _elementIds[Elements.ButtonShutdown], column = 0, row = currRow++, row_weight = 0.5f, column_weight = 0.5f, text = "Shutdown"
             });
         }
         if (sm.VolumeControlEnabled)
         {
             _currentLayout.elements.Add(new Label {
                 id = "labelVolume", column = 0, row = currRow, row_weight = 2.0f, column_weight = 1.0f, text = "Volume:"
             });
             _currentLayout.elements.Add(new Slider {
                 id = _elementIds[Elements.SliderVolume], column = 1, row = currRow++, min = 0, max = 100, step_size = 3, row_weight = 2.0f, column_weight = 3.0f, progress = VolumeModel.Instance.Volume
             });
         }
     }
     if (_anperi.HasControl && _anperi.IsPeripheralConnected)
     {
         RootGrid grid;
         lock (_syncRootLayout)
         {
             grid = _currentLayout;
         }
         await _anperi.SetLayout(grid, Anperi.ScreenOrientation.portrait).ConfigureAwait(false);
     }
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Trace.Listeners.Add(new ConsoleTraceListener());
            Anperi anperi = new Anperi();

            anperi.Message += Anperi_Message;

            bool exit = false;

            while (!exit)
            {
                Console.WriteLine("type a line to do stuff: periinf, perilay");
                string text = Console.ReadLine();
                anperi.ClaimControl();
                switch (text)
                {
                case "periinf":
                    anperi.RequestPeripheralInfo();
                    break;

                case "perilay":
                    RootGrid rg  = new RootGrid();
                    int      rnd = new Random().Next(1, 10);
                    for (int i = 0; i < rnd; i++)
                    {
                        rg.elements.Add(new Button {
                            column = 1, row = i, id = i, text = "button_" + i
                        });
                    }
                    anperi.SetLayout(rg);
                    break;

                case "exit":
                    exit = true;
                    break;
                }
            }
        }