Exemplo n.º 1
0
        public async Task LoadLayout(string layoutFile)
        {
            try
            {
                var uri         = new Uri($"ms-appx:///EyeGazeUserControls/Layouts/{layoutFile}");
                var storageFile = await StorageFile.GetFileFromApplicationUriAsync(uri);

                var xaml = await FileIO.ReadTextAsync(storageFile);

                var xamlNode = XamlReader.Load(xaml) as FrameworkElement;

                _keyboardButtons = new List <ButtonBase>();
                FindChildren <ButtonBase>(_keyboardButtons, xamlNode);

                foreach (var button in _keyboardButtons)
                {
                    button.Click += OnKeyboardButtonClick;
                }

                _rootPage = new KeyboardPage(xamlNode, null);
                BuildPageHierarchy(_rootPage);

                LayoutRoot.Children.Add(xamlNode);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
        }
Exemplo n.º 2
0
 public KeyboardPage(FrameworkElement page, KeyboardPage parent)
 {
     Page          = page;
     Parent        = parent;
     ChildrenNames = new List <string>();
     Children      = new List <KeyboardPage>();
 }
Exemplo n.º 3
0
        private KeyboardPage FindContainer(KeyboardPage kbdPage, string containerName)
        {
            if (kbdPage.Page.Name == containerName)
            {
                return(kbdPage);
            }
            KeyboardPage containerPage = null;

            for (int i = 0; i < kbdPage.Children.Count; i++)
            {
                containerPage = FindContainer(kbdPage.Children[i], containerName);
                if (containerPage != null)
                {
                    return(containerPage);
                }
            }
            return(null);
        }
Exemplo n.º 4
0
        private void BuildPageHierarchy(KeyboardPage parent)
        {
            var children = Keyboard.GetPageList(parent.Page);

            foreach (var childName in children)
            {
                var node = parent.Page.FindName(childName) as FrameworkElement;
                if (node != null)
                {
                    var childPage = new KeyboardPage(node, parent);
                    parent.ChildrenNames.Add(childName);
                    parent.Children.Add(childPage);
                    BuildPageHierarchy(childPage);
                }
            }

            if (parent.Children.Count > 0)
            {
                parent.CurrentChild = parent.Children[0];
            }
        }