示例#1
0
        public static SnapsManager SetupManager(CoreDispatcher dispatcher, Grid xamlPanel)
        {
            int debugOption = 0;

            manager = new SnapsManager(dispatcher, xamlPanel, debugOption);
            return(manager);
        }
        public JoyPadPanel(SnapsManager manager)
        {
            this.manager = manager;

            this.Width      = 200;
            this.Background = new SolidColorBrush(Color.FromArgb(120, 100, 100, 100));

            up         = new Pad();
            up.PadText = "UP";
            JoyPads.Add("UP", up);

            down         = new Pad();
            down.PadText = "DOWN";
            JoyPads.Add("DOWN", down);

            left         = new Pad();
            left.PadText = "LEFT";
            JoyPads.Add("LEFT", left);

            right         = new Pad();
            right.PadText = "RIGHT";
            JoyPads.Add("RIGHT", right);

            fire         = new Pad();
            fire.PadText = "FIRE";
            JoyPads.Add("FIRE", fire);

            foreach (Pad r in JoyPads.Values)
            {
                r.Width               = PAD_WIDTH;
                r.Height              = PAD_HEIGHT;
                r.Background          = padBrush;
                r.HorizontalAlignment = HorizontalAlignment.Center;
                r.Margin              = new Thickness(8, 8, 8, 8);
                r.PointerEntered     += pad_pointerEntered;
                r.PointerExited      += pad_pointerExited;
            }

            StackPanel topRow = new StackPanel();

            topRow.Children.Add(up);
            this.Children.Add(topRow);
            StackPanel middleRow = new StackPanel();

            middleRow.Orientation = Orientation.Horizontal;
            middleRow.Children.Add(left);
            middleRow.Children.Add(fire);
            middleRow.Children.Add(right);
            this.Children.Add(middleRow);
            StackPanel bottomRow = new StackPanel();

            bottomRow.Children.Add(down);
            this.Children.Add(bottomRow);
            this.HorizontalAlignment = HorizontalAlignment.Right;
            this.VerticalAlignment   = VerticalAlignment.Bottom;

            Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown;
            Window.Current.CoreWindow.KeyUp   += CoreWindow_KeyUp;
        }
        public TouchInputCanvas(SnapsManager manager)
        {
            this.manager             = manager;
            this.HorizontalAlignment = HorizontalAlignment.Stretch;
            this.VerticalAlignment   = VerticalAlignment.Stretch;
            Color background = Colors.Orange;

            background.A    = 0;
            this.Background = new SolidColorBrush(background);
            this.Visibility = Visibility.Collapsed;
        }
示例#4
0
 public ButtonPanel(SnapsManager manager)
 {
     this.manager = manager;
     for (int i = 0; i < MAX_NO_OF_BUTTONS; i++)
     {
         Button b = new Button();
         b.Visibility          = Visibility.Collapsed;
         b.HorizontalAlignment = HorizontalAlignment.Stretch;
         b.Width  = 400;
         b.Margin = new Thickness(4);
         this.Children.Add(b);
     }
 }
示例#5
0
 public void SetDrawingColor(int red, int green, int blue)
 {
     manager.InvokeOnUIThread(
         () =>
     {
         Color newBackground = Color.FromArgb(
             255,
             SnapsManager.ColorClamp(red),
             SnapsManager.ColorClamp(green),
             SnapsManager.ColorClamp(blue));
         graphicsBrush = new SolidColorBrush(newBackground);
     }
         );
 }
        public LightPanel(SnapsManager manager, double width, double height, int xCells, int yCells)
        {
            this.manager = manager;

            this.Width  = width;
            this.Height = height;

            if (xCells > 32 || yCells > 32)
            {
                throw new Exception("Maximum panel dimension exceeded. No more than 32 panels in each direction");
            }

            AutoResetEvent lightPanelBuiltEvent = new AutoResetEvent(false);

            manager.InvokeOnUIThread(
                async() =>
            {
                if (this.Opacity != 1)
                {
                    await FadeElements.FadeElementOpacityAsync(this, 0, 1, new TimeSpan(0, 0, 1));
                }

                clearLightPanel();

                lightPanels = new Rectangle[xCells, yCells];

                float panelWidth  = (float)this.ActualWidth / xCells;
                float panelHeight = (float)this.ActualHeight / yCells;

                for (int x = 0; x < xCells; x++)
                {
                    for (int y = 0; y < yCells; y++)
                    {
                        Rectangle p = new Rectangle();
                        p.Fill      = new SolidColorBrush(Colors.White);
                        p.Stroke    = new SolidColorBrush(Colors.Black);
                        p.Width     = panelWidth;
                        p.Height    = panelHeight;
                        Canvas.SetLeft(p, x * panelWidth);
                        Canvas.SetTop(p, y * panelHeight);
                        lightPanels[x, y] = p;
                        this.Children.Add(p);
                    }
                }

                lightPanelBuiltEvent.Set();
            });

            lightPanelBuiltEvent.WaitOne();
        }
示例#7
0
 public void DoSetTextColor(int red, int green, int blue)
 {
     manager.InvokeOnUIThread(
         () =>
     {
         Color newBackground = Color.FromArgb(
             255,
             SnapsManager.ColorClamp(red),
             SnapsManager.ColorClamp(green),
             SnapsManager.ColorClamp(blue));
         SolidColorBrush brush       = new SolidColorBrush(newBackground);
         displayTextBlock.Foreground = brush;
     }
         );
 }
示例#8
0
        public ReadStringStackPanel(SnapsManager manager)
        {
            this.manager             = manager;
            this.Opacity             = 0;
            this.VerticalAlignment   = VerticalAlignment.Center;
            this.HorizontalAlignment = HorizontalAlignment.Center;
            this.Margin      = new Thickness(10, 10, 10, 10);
            this.Orientation = Orientation.Vertical;

            InputPromptTextBlock          = new TextBlock();
            InputPromptTextBlock.Text     = "Prompt for input goes here";
            InputPromptTextBlock.FontSize = 25;
            this.Children.Add(InputPromptTextBlock);

            UserInputStackPanel             = new StackPanel();
            UserInputStackPanel.Orientation = Orientation.Horizontal;
            this.Children.Add(UserInputStackPanel);

            /*
             *
             *         <StackPanel Opacity="0" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10,10,10,10"  Orientation="Vertical" Name="InputStackPanel" Grid.ColumnSpan="2" Grid.Row="3" Visibility="Collapsed">
             *          <TextBlock Name="InputPromptTextBlock" Text="Prompt for the input goes here" FontSize="25"></TextBlock>
             *          <StackPanel Orientation="Horizontal">
             *              <TextBox Width="400" IsEnabled="True" VerticalAlignment="Center" Margin="10,10,10,10" Name="TextInputTextBox" PlaceholderText="Enter Your Text"/>
             *              <Button VerticalAlignment="Center" IsEnabled="True" Name="ReadTextButton" Margin="10,10,10,10" Content="Enter" Width="Auto"/>
             *          </StackPanel>
             *      </StackPanel>
             *
             *
             * */

            TextInputTextBox = new TextBox();

            TextInputTextBox.Width             = 400;
            TextInputTextBox.Height            = TextBoxSingleLineHeight;
            TextInputTextBox.VerticalAlignment = VerticalAlignment.Center;
            TextInputTextBox.Margin            = new Thickness(10, 10, 10, 10);
            UserInputStackPanel.Children.Add(TextInputTextBox);

            ReadTextButton = new Button();
            ReadTextButton.VerticalAlignment = VerticalAlignment.Center;
            ReadTextButton.IsEnabled         = true;
            ReadTextButton.Margin            = new Thickness(10, 10, 10, 10);
            ReadTextButton.Content           = "Enter";
            ReadTextButton.Width             = double.NaN;
            this.Children.Add(ReadTextButton);
        }
示例#9
0
 public void DoSetButtonColor(int red, int green, int blue)
 {
     manager.InvokeOnUIThread(
         () =>
     {
         Color newBackground = Color.FromArgb(
             255,
             SnapsManager.ColorClamp(red),
             SnapsManager.ColorClamp(green),
             SnapsManager.ColorClamp(blue));
         SolidColorBrush brush = new SolidColorBrush(newBackground);
         foreach (Button b in this.Children)
         {
             b.Foreground = brush;
         }
     }
         );
 }
示例#10
0
        public DisplayTextBlock(SnapsManager manager)
        {
            this.manager                         = manager;
            this.HorizontalAlignment             = HorizontalAlignment.Stretch;
            displayTextBlock                     = new TextBlock();
            displayTextBlock.HorizontalAlignment = HorizontalAlignment.Stretch;
            displayTextBlock.Width               = double.NaN;
            displayTextBlock.TextAlignment       = TextAlignment.Left;
            displayTextBlock.TextWrapping        = TextWrapping.WrapWholeWords;
            displayTextBlock.Width               = defaultWidth;
            displayTextBlock.Margin              = new Thickness(10, 10, 10, 10);
            displayTextBlock.Name                = "writeOutputTextBlock";
            originalTextColor                    = displayTextBlock.Foreground;
            displayTextBlock.FontSize            = defaultFontSize;
            displayTextBlock.Text                = "";

            this.Children.Add(displayTextBlock);
        }
示例#11
0
        public void SetPanelCell(int x, int y, int red, int green, int blue)
        {
            if (LightPanel == null)
            {
                throw new Exception("No LightPanel has been created");
            }

            AutoResetEvent setPanelCompletedEvent = new AutoResetEvent(false);

            manager.InvokeOnUIThread(
                () =>
            {
                if (x < 0)
                {
                    x = 0;
                }
                if (x >= LightPanel.GetLength(0))
                {
                    x = LightPanel.GetLength(0) - 1;
                }
                if (y < 0)
                {
                    y = 0;
                }
                if (y >= LightPanel.GetLength(1))
                {
                    y = LightPanel.GetLength(1) - 1;
                }

                Color color = Color.FromArgb(
                    255,
                    SnapsManager.ColorClamp(red),
                    SnapsManager.ColorClamp(green),
                    SnapsManager.ColorClamp(blue));

                Brush b = new SolidColorBrush(color);
                LightPanel[x, y].Fill = b;
                //LightPanel[x, y].Stroke = b;
                setPanelCompletedEvent.Set();
            });
            setPanelCompletedEvent.WaitOne();
        }
示例#12
0
        public SnapsGraphicsCanvas(SnapsManager manager)
        {
            this.manager = manager;

            backgroundImageValue = new Image();
            backgroundImageValue.HorizontalAlignment = HorizontalAlignment.Center;
            backgroundImageValue.VerticalAlignment   = VerticalAlignment.Center;
            backgroundImageValue.Stretch             = Stretch.UniformToFill;
            Canvas.SetTop(backgroundImageValue, 0);
            Canvas.SetLeft(backgroundImageValue, 0);
            Children.Add(backgroundImageValue);

            displayImageValue = new Image();
            displayImageValue.HorizontalAlignment = HorizontalAlignment.Center;
            displayImageValue.VerticalAlignment   = VerticalAlignment.Center;
            displayImageValue.Stretch             = Stretch.Uniform;
            Canvas.SetTop(displayImageValue, 0);
            Canvas.SetLeft(displayImageValue, 0);
            Children.Add(displayImageValue);
        }
示例#13
0
 public SoundAndSpeech(SnapsManager manager)
 {
     this.manager       = manager;
     soundOutputElement = new MediaElement();
 }
示例#14
0
 public static SnapsManager SetupManager(Grid displayGrid)
 {
     return(SnapsManager.SetupManager(CoreWindow.GetForCurrentThread().Dispatcher, displayGrid));
 }
        public SnapsControlPanelStackPanel(SnapsManager manager)
        {
            this.manager = manager;

            this.Opacity           = 0;
            this.VerticalAlignment = VerticalAlignment.Top;

            StackPanel DemoSelect = new StackPanel();

            DemoSelect.Orientation     = Orientation.Horizontal;
            DemoSelect.BorderBrush     = new SolidColorBrush(Colors.Gray);
            DemoSelect.BorderThickness = new Thickness(2);

            StackPanel ChapterSelection = new StackPanel();

            ChapterSelection.Orientation = Orientation.Vertical;
            DemoSelect.Children.Add(ChapterSelection);

            TextBlock chapterTitleTextBlock = new TextBlock();

            chapterTitleTextBlock.Text = "Folder";
            ChapterSelection.Children.Add(chapterTitleTextBlock);

            chapterListView = new ListView();
            List <string> foldernames = manager.GetDemoFolders();

            chapterListView.ItemsSource       = manager.GetDemoFolders();
            chapterListView.SelectionChanged += ChapterListView_SelectionChanged;
            chapterListView.Height            = 200;
            chapterListView.Width             = 400;
            ChapterSelection.Children.Add(chapterListView);

            StackPanel DemoSelection = new StackPanel();

            DemoSelection.Orientation = Orientation.Vertical;
            DemoSelect.Children.Add(DemoSelection);

            TextBlock exampleTitleTextBlock = new TextBlock();

            exampleTitleTextBlock.Text = "Snaps apps";
            DemoSelection.Children.Add(exampleTitleTextBlock);

            demoSelectListView                   = new ListView();
            demoSelectListView.Height            = 200;
            demoSelectListView.Width             = 400;
            demoSelectListView.SelectionChanged += DemoSelectListView_SelectionChanged;
            DemoSelection.Children.Add(demoSelectListView);

            DemoSelect.VerticalAlignment   = VerticalAlignment.Center;
            DemoSelect.HorizontalAlignment = HorizontalAlignment.Center;

            this.Children.Add(DemoSelect);

            StackPanel buttonsStackPanel = new StackPanel();

            buttonsStackPanel.Orientation         = Orientation.Horizontal;
            buttonsStackPanel.Margin              = new Thickness(10, 10, 10, 10);
            buttonsStackPanel.Width               = double.NaN;
            buttonsStackPanel.VerticalAlignment   = VerticalAlignment.Center;
            buttonsStackPanel.HorizontalAlignment = HorizontalAlignment.Center;

            stopButton                     = new Button();
            stopButton.Name                = "StopButton";
            stopButton.Margin              = new Thickness(10, 10, 10, 10);
            stopButton.VerticalAlignment   = VerticalAlignment.Bottom;
            stopButton.Content             = "Stop";
            stopButton.HorizontalAlignment = HorizontalAlignment.Right;
            stopButton.Click              += stopButton_Click;
            stopButton.Width               = double.NaN; // select the auto width

            //buttonsStackPanel.Children.Add(stopButton);

            snapAppButton                     = new Button();
            snapAppButton.Name                = "snapAppButton";
            snapAppButton.Margin              = new Thickness(10, 10, 10, 10);
            snapAppButton.VerticalAlignment   = VerticalAlignment.Bottom;
            snapAppButton.Content             = "Run an app";
            snapAppButton.HorizontalAlignment = HorizontalAlignment.Right;
            snapAppButton.Click              += SnapAppButton_Click;
            snapAppButton.Width               = double.NaN; // select the auto width

            buttonsStackPanel.Children.Add(snapAppButton);

            repeatAppButton                     = new Button();
            repeatAppButton.Name                = "repeatAppButton";
            repeatAppButton.Margin              = new Thickness(10, 10, 10, 10);
            repeatAppButton.VerticalAlignment   = VerticalAlignment.Bottom;
            repeatAppButton.Content             = "Run that app again";
            repeatAppButton.HorizontalAlignment = HorizontalAlignment.Right;
            repeatAppButton.Click              += repeatAppButton_Click;
            repeatAppButton.Width               = double.NaN; // select the auto width

            buttonsStackPanel.Children.Add(repeatAppButton);

            this.Children.Add(buttonsStackPanel);

            versionTextBlock = new TextBlock();
            versionTextBlock.HorizontalAlignment = HorizontalAlignment.Right;
            versionTextBlock.VerticalAlignment   = VerticalAlignment.Bottom;
            versionTextBlock.Text   = "Version " + manager.Version;
            versionTextBlock.Margin = new Thickness(10, 10, 10, 10);

            this.Children.Add(versionTextBlock);

            this.Background = manager.BackgroundBrush;
        }
示例#16
0
 public TapDetection(SnapsManager manager)
 {
     this.manager = manager;
 }