Exemple #1
0
        /// <summary>
        /// インスタンスを生成します。
        /// </summary>
        /// <param name="owner">FocusScope を管理する Control。</param>
        public FocusScope(Control owner)
        {
            if (owner == null) throw new ArgumentNullException("owner");
            this.owner = owner;

            FocusNavigationMode = FocusNavigationMode.Cycle;
        }
Exemple #2
0
        /// <summary>
        /// control が属する FocusScope を取得します。
        /// </summary>
        /// <param name="control">Control。</param>
        /// <returns>
        /// control が属する FocusScope。属する FocusScope が存在しない場合は null。
        /// </returns>
        public static FocusScope GetFocusScope(Control control)
        {
            if (control == null) throw new ArgumentNullException("control");

            var focusScopeControl = control as IFocusScopeControl;
            if (focusScopeControl != null) return focusScopeControl.FocusScope;

            if (control.Parent != null) return GetFocusScope(control.Parent);

            return null;
        }
        // I/F
        public virtual ILookAndFeel GetLookAndFeel(Control control)
        {
            if (control == null) throw new ArgumentNullException("control");

            var type = control.GetType();

            ILookAndFeel lookAndFeel = null;
            while (type != typeof(object))
            {
                if (LookAndFeelMap.TryGetValue(type, out lookAndFeel)) break;

                type = type.BaseType;
            }

            return lookAndFeel;
        }
            void OnListItemButtonClick(Control sender, ref RoutedEventContext context)
            {
                var itemButton = sender as ItemButton;

                if (owner.Selected != null) owner.Selected(itemButton.DataContext as PredefinedColor);

                owner.Close();
            }
            void OnItemButtonLostFocus(Control sender, ref RoutedEventContext context)
            {
                var itemButton = sender as ItemButton;

                itemButton.Padding = new Thickness(4);
            }
        void OnSortByNameClick(Control sender, ref RoutedEventContext context)
        {
            PredefinedColors.Sort((x, y) => x.Name.CompareTo(y.Name));

            // ページをリセットしてからリロードします。
            predefinedColorGrid.ResetCurrentPageIndex();
            predefinedColorGrid.ReloadPage();
            predefinedColorList.ResetCurrentPageIndex();
            predefinedColorList.ReloadPage();
        }
 // I/F
 public ILookAndFeel GetLookAndFeel(Control control)
 {
     if (SelectedItem == null) return null;
     return SelectedItem.GetLookAndFeel(control);
 }
 void OnStartButtonClick(Control sender, ref RoutedEventContext context)
 {
     var overlay = new FadeOverlay(Screen);
     overlay.OpacityAnimation.To = 1;
     overlay.OpacityAnimation.Duration = TimeSpan.FromSeconds(0.5d);
     overlay.OpacityAnimation.Completed += (s, e) => Screen.ShowScreen(ScreenNames.Main);
     overlay.Show();
 }
        void OnInstallDemoBlocksButtonClick(Control sender, ref RoutedEventContext context)
        {
            if (confirmInstallDialog == null)
            {
                confirmInstallDialog = new ConfirmationDialog(Screen)
                {
                    Message = new TextBlock(Screen)
                    {
                        Width = 320,
                        Text = Strings.InstallDemoBlocksConfirmation,
                        TextWrapping = TextWrapping.Wrap,
                        TextHorizontalAlignment = HorizontalAlignment.Left,
                        ForegroundColor = Color.White,
                        BackgroundColor = Color.Black
                    }
                };
                confirmInstallDialog.Closed += OnConfirmInstallDialogClosed;
            }

            confirmInstallDialog.Show();
        }
        void OnFileNameButtonKeyDown(Control sender, ref RoutedEventContext context)
        {
            if (Screen.KeyboardDevice.IsKeyPressed(Keys.Left))
            {
                var sound = Screen.GetSound(SoundKey.FocusNavigation);
                if (sound != null)
                {
                    if (sound.State != SoundState.Stopped) sound.Stop();
                    sound.Play();
                }

                ViewModel.BackPage();
                context.Handled = true;
            }
            else if (Screen.KeyboardDevice.IsKeyPressed(Keys.Right))
            {
                var sound = Screen.GetSound(SoundKey.FocusNavigation);
                if (sound != null)
                {
                    if (sound.State != SoundState.Stopped) sound.Stop();
                    sound.Play();
                }

                ViewModel.ForwardPage();
                context.Handled = true;
            }
        }
        void OnFileButtonClick(Control sender, ref RoutedEventContext context)
        {
            if (confirmationDialog == null)
            {
                confirmationDialog = new ConfirmationDialog(Screen)
                {
                    Message = new TextBlock(Screen)
                    {
                        Text = Strings.OpenFileConfirmation,
                        HorizontalAlignment = HorizontalAlignment.Left,
                        ForegroundColor = Color.White,
                        BackgroundColor = Color.Black,
                        ShadowOffset = new Vector2(2)
                    }
                };
                confirmationDialog.Closed += OnOpenFileConfirmationDialogClosed;
            }

            // 仮選択。
            ViewModel.SelectedFileName = (sender.DataContext as ViewerViewModel).MeshName;

            confirmationDialog.Show();

            context.Handled = true;
        }
        void OnSwitchLightButtonClick(Control sender, ref RoutedEventContext context)
        {
            ViewModel.Enabled = !ViewModel.Enabled;

            UpdateSwitchLightButtonText();
        }
 void OnSpecularColorButtonClick(Control sender, ref RoutedEventContext context)
 {
     ShowPredefinedColorDialog(PredefinedColorSelectedForSpecular);
 }
 void OnDiffuseColorButtonClick(Control sender, ref RoutedEventContext context)
 {
     ShowPredefinedColorDialog(PredefinedColorSelectedForDiffuse);
 }
Exemple #15
0
        /// <summary>
        /// 指定の Control へフォーカスを設定します。
        /// </summary>
        /// <param name="control">フォーカスを設定する Control。</param>
        /// <returns>
        /// true (フォーカスが設定された場合)、
        /// false (論理フォーカスの設定のみが行われた場合、
        /// あるいは、フォーカス設定不能な Control の場合)。
        /// </returns>
        internal bool MoveFocusTo(Control control)
        {
            if (control == null) throw new ArgumentNullException("control");

            if (!control.Focusable || !control.Enabled || !control.Visible) return false;

            // アクティブ Window の Control ならばフォーカスを設定します。
            var window = Window.GetWindow(control);
            if (window != null && window.Active)
            {
                FocusedControl = control;
                return true;
            }

            return false;
        }
Exemple #16
0
 protected virtual void OnContentChanged(Control oldContent, Control newContent)
 {
 }
Exemple #17
0
 void OnChangeLookAndFeelButtonClick(Control sender, ref RoutedEventContext context)
 {
     var startScreen = Screen as StartScreen;
     if (startScreen.SelectedLookAndFeelSourceIndex == StartScreen.DefaultLookAndFeelIndex)
     {
         startScreen.SelectedLookAndFeelSourceIndex = StartScreen.DebugLookAndFeelIndex;
         (changeLookAndFeelButton.Content as TextBlock).Text = "Look & Feel [Default]";
     }
     else
     {
         startScreen.SelectedLookAndFeelSourceIndex = StartScreen.DefaultLookAndFeelIndex;
         (changeLookAndFeelButton.Content as TextBlock).Text = "Look & Feel [Debug]";
     }
 }
Exemple #18
0
        /// <summary>
        /// 子 Control を描画します。
        /// </summary>
        /// <param name="gameTime"></param>
        /// <param name="drawContext"></param>
        /// <param name="child">子 Control。</param>
        protected virtual void DrawChild(GameTime gameTime, IDrawContext drawContext, Control child)
        {
            //
            // TODO
            //
            // 暫定的な描画領域決定アルゴリズムです。
            // スクロール処理なども考慮して描画領域を算出する必要があります。

            drawContext.Location = child.PointToScreen(Vector2.Zero);
            drawContext.PushOpacity(child.Opacity);

            child.Draw(gameTime, drawContext);

            drawContext.PopOpacity();
        }
Exemple #19
0
        void OnLanguageSettingButtonClick(Control sender, ref RoutedEventContext context)
        {
            if (selectLanguageDialog == null)
                selectLanguageDialog = new SelectLanguageDialog(Screen);

            selectLanguageDialog.Show();
        }
Exemple #20
0
        /// <summary>
        /// マウス カーソルが領域外に移動した時に呼び出されます。
        /// </summary>
        internal void ProcessMouseLeave()
        {
            // 元々カーソルが Control 上にないならば、mouseOverControl は null です。
            if (mouseOverControl == null) return;

            if (mouseOverControl != this)
            {
                // mouseOverControl が子であるならば、子に通知します。
                mouseOverControl.ProcessMouseLeave();
            }
            else
            {
                // mouseOverControl が自分であるならば、自分に通知します。
                RaiseEvent(PreviewMouseLeaveEvent, MouseLeaveEvent);
            }

            // mouseOverControl を解除します。
            mouseOverControl = null;
        }
Exemple #21
0
        void OnUploadDemoBlocksButtonClick(Control sender, ref RoutedEventContext context)
        {
            var boxIntegration = (Screen.Game as BlockViewerGame).BoxIntegration;

            // 保存されている設定からの BoxSession の復元を試みます。
            viewModel.RestoreSessionAsync(RestoreSessionCallback);

            ShowProgressDialog(Strings.CheckingBoxSettingsMessage);
        }
Exemple #22
0
        /// <summary>
        /// mouseOverControl を newControl に設定します。
        /// </summary>
        /// <param name="newControl">Control。</param>
        void SwitchMouseOverControl(Control newControl)
        {
            if (mouseOverControl == newControl) return;

            // これまでの mouseOverControl へ変更を通知します。
            if (mouseOverControl != null) mouseOverControl.ProcessMouseLeave();

            // 新たな mouseOverControl を設定して変更を通知します。
            mouseOverControl = newControl;
            mouseOverControl.RaiseEvent(PreviewMouseEnterEvent, MouseEnterEvent);
        }
 public RoutedEventContext(Control source)
     : this()
 {
     Source = source;
 }
Exemple #24
0
 /// <summary>
 /// この Control が descendant の先祖かどうかを判定します。
 /// </summary>
 /// <param name="descendant">Control。</param>
 /// <returns>
 /// true (この Control が descendant の先祖である場合)、false (それ以外の場合)。
 /// </returns>
 public bool IsAncestorOf(Control descendant)
 {
     for (var parent = descendant.Parent; parent != null; parent = parent.Parent)
     {
         if (parent == this) return true;
     }
     return false;
 }
 void OnViewModeButtonClick(Control sender, ref RoutedEventContext context)
 {
     if (tab.SelectedIndex == 0)
     {
         tab.SelectedIndex = 1;
         (viewModeButton.Content as TextBlock).Text = Strings.GridViewModeButton;
     }
     else
     {
         tab.SelectedIndex = 0;
         (viewModeButton.Content as TextBlock).Text = Strings.ListViewModeButton;
     }
 }
Exemple #26
0
 /// <summary>
 /// この Control が ancestor の子孫かどうかを判定します。
 /// </summary>
 /// <param name="ancestor"></param>
 /// <returns>
 /// true (この Control が ancestor の子孫である場合)、false (それ以外の場合)。
 /// </returns>
 public bool IsDescendantOf(Control ancestor)
 {
     return ancestor.IsAncestorOf(this);
 }
 void OnRightColorButtonKeyDown(Control sender, ref RoutedEventContext context)
 {
     if (Screen.KeyboardDevice.IsKeyPressed(Keys.Right))
     {
         ForwardPage();
         context.Handled = true;
     }
 }
Exemple #28
0
        /// <summary>
        /// 指定の Control をとして関連付けます。
        /// </summary>
        /// <param name="child">子として関連付ける Control。</param>
        protected void AddChild(Control child)
        {
            if (child.IsAncestorOf(this))
                throw new InvalidOperationException("Control can not be the descendant of one's own.");

            child.Parent = this;
        }
 void OnListItemButtonKeyDown(Control sender, ref RoutedEventContext context)
 {
     if (Screen.KeyboardDevice.IsKeyPressed(Keys.Left))
     {
         BackPage();
         context.Handled = true;
     }
     else if (Screen.KeyboardDevice.IsKeyPressed(Keys.Right))
     {
         ForwardPage();
         context.Handled = true;
     }
 }
Exemple #30
0
        /// <summary>
        /// 子 Control との関連付けを削除します。
        /// </summary>
        /// <param name="child">関連付けを削除する子 Control。</param>
        protected void RemoveChild(Control child)
        {
            if (this != child.Parent)
                throw new InvalidOperationException("This control is not a parent of the specified control.");

            if (mouseOverControl == child) mouseOverControl = this;

            child.Parent = null;
        }