예제 #1
0
        private void InitializeWelcomePopup()
        {
            welcomePopup = UILibrary.InstantiateElement <ModalElement>("WelcomePopup");
            welcomePopup.SetPanelZIndex(1);

            // FIXME: UI asset should support multiline text
            var welcomeText = welcomePopup.FindVisualChildOfType <TextBlock>("welcomeText");

            welcomeText.Text = "Welcome to stride UI sample.\nPlease name your character";

            var cancelButton = welcomePopup.FindVisualChildOfType <Button>("cancelButton");

            cancelButton.Click += delegate
            {
                nameTextBlock.Text = DefaultName;
                CloseWelcomePopup();
            };

            var nameEditText = welcomePopup.FindVisualChildOfType <EditText>("nameEditText");

            nameEditText.Text = DefaultName;
            var validateButton = welcomePopup.FindVisualChildOfType <Button>("validateButton");

            validateButton.Click += delegate
            {
                nameTextBlock.Text = nameEditText.Text.Trim();
                CloseWelcomePopup();
            };
        }
예제 #2
0
    static public void DisplayData(Windows.UI.Xaml.Controls.TextBlock outputBlock)
    {
        // Get the data from some data source.
        var employees = InitializeData();

        outputBlock.FontFamily = new FontFamily("Courier New");
        // Display application title.
        string title = UILibrary.GetTitle();

        outputBlock.Text += title + Environment.NewLine + Environment.NewLine;

        // Retrieve resources.
        string[] fields    = UILibrary.GetFieldNames();
        int[]    lengths   = UILibrary.GetFieldLengths();
        string   fmtString = String.Empty;

        // Create format string for field headers and data.
        for (int ctr = 0; ctr < fields.Length; ctr++)
        {
            fmtString += String.Format("{{{0},-{1}{2}{3}   ", ctr, lengths[ctr], ctr >= 2 ? ":d" : "", "}");
        }

        // Display the headers.
        outputBlock.Text += String.Format(fmtString, fields) + Environment.NewLine + Environment.NewLine;
        // Display the data.
        foreach (var e in employees)
        {
            outputBlock.Text += String.Format(fmtString, e.Item1, e.Item2, e.Item3, e.Item4) + Environment.NewLine;
        }
    }
예제 #3
0
        private void InitializeShipSelectionPopup()
        {
            shipSelectPopup = UILibrary.InstantiateElement <ModalElement>("ShipSelectPopup");
            shipSelectPopup.SetPanelZIndex(1);

            // Layout elements in vertical StackPanel
            var contentStackpanel = shipSelectPopup.FindVisualChildOfType <StackPanel>("contentStackPanel");

            // Create and Add SpaceShip to the stack layout
            foreach (var ship in shipList)
            {
                contentStackpanel.Children.Add(CreateShipSelectionItem(ship));
            }

            // Uncomment those lines to have an example of stack panel item virtualization
            //var shipInitialCount = shipList.Count;
            //contentStackpanel.ItemVirtualizationEnabled = true;
            //for (var i = 0; i < 200; i++)
            //{
            //    shipList.Add(new SpaceShip { Name = shipList[i % shipInitialCount].Name });
            //    contentStackpanel.Children.Add(CreateShipSelectionItem(shipList[shipList.Count - 1]));
            //}

            UpdateShipStatus();
            CloseShipSelectPopup();
        }
예제 #4
0
    static void Main()
    {
        // Get the data from some data source.
        var employees = InitializeData();

        // Display application title.
        string title    = UILibrary.GetTitle();
        int    start    = (Console.WindowWidth + title.Length) / 2;
        string titlefmt = String.Format("{{0,{0}{1}", start, "}");

        Console.WriteLine(titlefmt, title);
        Console.WriteLine();

        // Retrieve resources.
        string[] fields    = UILibrary.GetFieldNames();
        int[]    lengths   = UILibrary.GetFieldLengths();
        string   fmtString = String.Empty;

        // Create format string for field headers and data.
        for (int ctr = 0; ctr < fields.Length; ctr++)
        {
            fmtString += String.Format("{{{0},-{1}{2}{3}   ", ctr, lengths[ctr], ctr >= 2 ? ":d" : "", "}");
        }

        // Display the headers.
        Console.WriteLine(fmtString, fields);
        Console.WriteLine();
        // Display the data.
        foreach (var e in employees)
        {
            Console.WriteLine(fmtString, e.Item1, e.Item2, e.Item3, e.Item4);
        }

        Console.ReadLine();
    }
예제 #5
0
    /// <summary>
    /// Intialize all UI
    /// </summary>
    protected void Intialize()
    {
        Connect();
        UILibrary.GetCanvasChildrens();

        if (string.IsNullOrEmpty(PlayerName))
        {
            UILibrary.ShowElement(UILibrary.LoggingUI);
        }

        UILibrary.ShowElement(UILibrary.LobbyUI);
        UILibrary.LobbyUI.transform.FindChild("Nickname").GetComponent <Text>().text = "Nickname: " + PlayerName;
    }
예제 #6
0
 /// <summary>
 /// Make a GridList for the given Grid
 /// </summary>
 /// <param name="grid">What grid will the list be in?</param>
 /// <param name="entryTemplate">What template to use for entries?</param>
 /// <param name="templateRootName">Optional specified name for the root UIElement in the entryTemplate</param>
 public GridList(Grid grid, UILibrary entryTemplate, string templateRootName = null)
 {
     myGrid   = grid;
     template = entryTemplate;
     if (templateRootName == null)
     {
         foreach (string name in entryTemplate.UIElements.Keys)
         {
             // just grab the first name
             templateName = name;
             break;
         }
     }
     else
     {
         templateName = templateRootName;
     }
     entryHeight = entryTemplate.UIElements[templateName].Height;
     UpdateEntryWidth();
 }
예제 #7
0
        private UIElement CreateShipSelectionItem(SpaceShip spaceShip)
        {
            var shipPanel  = UILibrary.InstantiateElement <Panel>("ShipButton");
            var shipButton = shipPanel.FindVisualChildOfType <ButtonBase>("shipButton");
            var shipImage  = shipButton.FindVisualChildOfType <ImageElement>("shipImage");

            // Update spaceship
            spaceShip.PowerImageElement   = shipButton.FindVisualChildOfType <ImageElement>("powerImage");
            spaceShip.ControlImageElement = shipButton.FindVisualChildOfType <ImageElement>("controlImage");
            spaceShip.SpeedImageElement   = shipButton.FindVisualChildOfType <ImageElement>("speedImage");

            var shipIndex = MainSceneImages.FindImageIndex(spaceShip.Name);

            ((SpriteFromSheet)shipImage.Source).CurrentFrame = shipIndex;

            shipButton.Click += delegate
            {
                activeShipIndex = shipList.FindIndex(w => w.Name == spaceShip.Name);
                ((SpriteFromSheet)currentShipImage.Source).CurrentFrame = shipIndex;

                PowerStatus   = spaceShip.Power;
                ControlStatus = spaceShip.Control;
                SpeedStatus   = spaceShip.Speed;

                CloseShipSelectPopup();
            };
            shipButton.IsEnabled = !spaceShip.IsLocked;

            if (spaceShip.IsLocked)
            {
                var lockIconElement = shipPanel.FindVisualChildOfType <ImageElement>("lockIcon");
                lockIconElement.Visibility = Visibility.Visible;
            }

            return(shipPanel);
        }
예제 #8
0
 /// <summary>
 /// Make a GridList for the given Grid
 /// </summary>
 /// <param name="grid">What grid will the list be in?</param>
 /// <param name="entryTemplate">What template to use for entries?</param>
 /// <param name="templateRootName">Optional specified name for the root UIElement in the entryTemplate</param>
 public GridList(Grid grid, UILibrary entryTemplate, string templateRootName = null)
 {
     myGrid   = grid;
     template = entryTemplate;
     if (templateRootName == null)
     {
         foreach (string name in entryTemplate.UIElements.Keys)
         {
             // just grab the first name
             templateName = name;
             break;
         }
     }
     else
     {
         templateName = templateRootName;
     }
     entryHeight = entryTemplate.UIElements[templateName].Height;
     entryWidth  = myGrid.Width;
     if (float.IsNaN(entryWidth))
     {
         entryWidth = myGrid.ActualWidth;
     }
 }
예제 #9
0
 public MyStream(UILibrary.ShellControl _shell)
 {
     shell = _shell;
 }
예제 #10
0
 void Shell_CommandEntered(object sender, UILibrary.CommandEnteredEventArgs e)
 {
     try
     {
         string input = e.Command;
         ProcessCommands(input, false);
     }
     catch (Exception ex)
     {
         Shell.WriteText("An application-level error occurred. See the trace tab for details.");
         TraceShell.WriteText(ex.ToString());
     }
 }
예제 #11
0
        public ChatRoomPlayStatus(INotifierQueryable queryer, UIComponent room, UILibrary library)
        {
            _ReleaseHelper = new ReleaseHelper();
            room.Page.RootElement.Visibility = Visibility.Visible;

            _ReleaseHelper.Actions.Add(() => {
                room.Page.RootElement.Visibility = Visibility.Hidden;
            });


            var messageContol = room.Page.RootElement.FindName("Message") as global::Stride.UI.Controls.EditText;
            var targetContol  = room.Page.RootElement.FindName("Target") as global::Stride.UI.Controls.EditText;
            var sendControl   = room.Page.RootElement.FindName("Send") as global::Stride.UI.Controls.Button;
            var quitControl   = room.Page.RootElement.FindName("Quit") as global::Stride.UI.Controls.Button;
            var listPanel     = room.Page.RootElement.FindName("List") as global::Stride.UI.Panels.Grid;



            var sendObs = from handler in sendControl.TouchUpObs()
                          where messageContol.Text.Length > 0 && string.IsNullOrWhiteSpace(targetContol.Text)
                          from player in queryer.QueryNotifier <Regulus.Samples.Chat1.Common.IPlayer>().SupplyEvent()
                          from unit in new System.Action(() => player.Send(messageContol.Text)).ReturnVoid()
                          select unit;

            var sendObsDispose = sendObs.Subscribe(_ => messageContol.Text = "");

            _ReleaseHelper.Actions.Add(() => {
                sendObsDispose.Dispose();
            });

            var privateSendObs = from handler in sendControl.TouchUpObs()
                                 where messageContol.Text.Length > 0 && !string.IsNullOrWhiteSpace(targetContol.Text)
                                 from player in queryer.QueryNotifier <Regulus.Samples.Chat1.Common.IPlayer>().SupplyEvent()
                                 from target in player.Chatters.SupplyEvent()
                                 where target.Name.Value == targetContol.Text
                                 from unit in new System.Action(() => target.Whisper(messageContol.Text)).ReturnVoid()
                                 select unit;

            var privateSendObsDispose = privateSendObs.Subscribe(_ => messageContol.Text = "");

            _ReleaseHelper.Actions.Add(() => {
                privateSendObsDispose.Dispose();
            });


            var quitObs = from handler in quitControl.TouchUpObs().Take(1)
                          from player in queryer.QueryNotifier <Regulus.Samples.Chat1.Common.IPlayer>().SupplyEvent()
                          from unit in new System.Action(() => player.Quit()).ReturnVoid()
                          select unit;

            var quitObsDispose = quitObs.Subscribe(unit => DoneEvent());

            _ReleaseHelper.Actions.Add(() => {
                quitObsDispose.Dispose();
            });


            var publicMessageObs =
                from player in queryer.QueryNotifier <Regulus.Samples.Chat1.Common.IPlayer>().SupplyEvent()
                from message in Regulus.Remote.Reactive.Extensions.EventObservable <Common.Message>(h => player.PublicMessageEvent += h, h => player.PublicMessageEvent -= h)
                select message;

            var publicMessageObsDispose = publicMessageObs.Subscribe(msg => _ReceiveMessage(listPanel, $"{msg.Name}:{msg.Context}"));

            _ReleaseHelper.Actions.Add(() => {
                publicMessageObsDispose.Dispose();
            });

            var privateMessageObs =
                from player in queryer.QueryNotifier <Regulus.Samples.Chat1.Common.IPlayer>().SupplyEvent()
                from message in Regulus.Remote.Reactive.Extensions.EventObservable <Common.Message>(h => player.PrivateMessageEvent += h, h => player.PrivateMessageEvent -= h)
                select message;

            var privateMessageObsDispose = privateMessageObs.Subscribe(msg => _ReceiveMessage(listPanel, $"<private>{msg.Name}:{msg.Context}"));

            _ReleaseHelper.Actions.Add(() => {
                privateMessageObsDispose.Dispose();
            });
            this.library = library;
        }
예제 #12
0
 public static extern IntPtr SetWindowsHookEx(int idHook, UILibrary.Win32.Callback.HookProc lpfn, int hMod, int dwThreadId);
예제 #13
0
 public static extern int RtlMoveMemory(ref UILibrary.Win32.Struct.POINT destination, ref RECT Source, int length);
예제 #14
0
 private void MoveItemBottom_Button_Click(object sender, RoutedEventArgs e)
 {
     UILibrary.Bottom_Button_Click(null, null, DependencyList.SelectedItems, this.DependencyItems);
 }
예제 #15
0
 protected void SetButtomImageGray(UILibrary.SkinButtom btn)
 {
     btn.DrawType = UILibrary.DrawStyle.Img;
     string imagePath = Application.StartupPath + "\\Images\\gray_button_normal.png";
     if (File.Exists(imagePath))
     {
         btn.NormlBack = Image.FromFile(imagePath);
     }
     string downPath = Application.StartupPath + "\\Images\\gray_button_down.png";
     if (File.Exists(downPath))
     {
         btn.DownBack = Image.FromFile(downPath);
     }
     string hoverPath = Application.StartupPath + "\\Images\\gray_button_hover.png";
     if (File.Exists(downPath))
     {
         btn.MouseBack = Image.FromFile(downPath);
     }
 }