Exemplo n.º 1
0
        internal static void ToggleFindToolBar(Decorator findToolBarHost, EventHandler handlerFindClicked, bool enable)
        {
            if (enable)
            {
                // Create FindToolBar and attach it to the host.
                FindToolBar findToolBar = new FindToolBar();
                findToolBarHost.Child = findToolBar;
                findToolBarHost.Visibility = Visibility.Visible;
                KeyboardNavigation.SetTabNavigation(findToolBarHost, KeyboardNavigationMode.Continue);
                FocusManager.SetIsFocusScope(findToolBarHost, true);

                // Initialize FindToolBar
                findToolBar.SetResourceReference(Control.StyleProperty, FindToolBarStyleKey);
                findToolBar.FindClicked += handlerFindClicked;
                findToolBar.DocumentLoaded = true;
                findToolBar.GoToTextBox();
            }
            else
            {
                // Reset FindToolBar state to its initial state.
                FindToolBar findToolBar = findToolBarHost.Child as FindToolBar;
                findToolBar.FindClicked -= handlerFindClicked;
                findToolBar.DocumentLoaded = false;

                // Remov FindToolBar form its host.
                findToolBarHost.Child = null;
                findToolBarHost.Visibility = Visibility.Collapsed;
                KeyboardNavigation.SetTabNavigation(findToolBarHost, KeyboardNavigationMode.None);
                findToolBarHost.ClearValue(FocusManager.IsFocusScopeProperty);
            }
        }
Exemplo n.º 2
0
 public void Show(Decorator placeholder, Action action, string argtitle, string argmessage)
 {
     Placeholder = placeholder;
     placeholder.Child = this;
     Title = argtitle;
     Message = argmessage;
     var task = new Task(action);
     task.ContinueWith((x) => this.Close());
     task.Start();
 }
Exemplo n.º 3
0
		public FlushAdorner(Decorator canvas)
			: base(canvas)
		{
			Canvas = canvas;
			_flushControl = new FlushViewModel();
			_contentPresenter = new ContentPresenter();
			_contentPresenter.Content = _flushControl;
			_visuals = new VisualCollection(this);
			_visuals.Add(_contentPresenter);
			_timer = new DispatcherTimer();
			_timer.Interval = TimeSpan.FromSeconds(Length);
			_timer.Tick += (s, e) => Hide();
		}
        /// <summary>
        /// Constructs the InteractiveViewport3D
        /// </summary>
        public Interactive3DDecorator() : base()
        {
            // keep everything within our bounds so that the hidden visuals are only
            // accessable over the Viewport3D
            ClipToBounds = true;
            
            // the offset of the hidden visual and the transform associated with it
            _offsetX = _offsetY = 0.0;
            _scale = 1;

            // set up the hidden visual transforms
            _hiddenVisTranslate = new TranslateTransform(_offsetX, _offsetY);
            _hiddenVisScale = new ScaleTransform(_scale, _scale);
            _hiddenVisTransform = new TransformGroup();
            _hiddenVisTransform.Children.Add(_hiddenVisScale);
            _hiddenVisTransform.Children.Add(_hiddenVisTranslate);            

            // the layer that contains our moving visual
            _hiddenVisual = new Decorator();            
            _hiddenVisual.Opacity = 0.0;
            _hiddenVisual.RenderTransform = _hiddenVisTransform;                       

            // where we store the previous hidden visual so that it can be in the tree
            // after it is removed so any state (i.e. mouse over) can be updated.
            _oldHiddenVisual = new Decorator();
            _oldHiddenVisual.Opacity = 0.0;
            
            // the keyboard focus visual
            _oldKeyboardFocusVisual = new Decorator();
            _oldKeyboardFocusVisual.Opacity = 0.0;

            // add all of the hidden visuals
            PostViewportChildren.Add(_oldHiddenVisual);
            PostViewportChildren.Add(_oldKeyboardFocusVisual);
            PostViewportChildren.Add(_hiddenVisual);
            
            // initialize other member variables to null
            _closestIntersectInfo = null;
            _lastValidClosestIntersectInfo = null;     

            AllowDrop = true;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Walk the visual tree until we find a Text control with IsPasswordBoxContent == true
        /// and a ScrollViewer
        /// </summary>
        private void SetRenderScopeToContentHost(TextBoxView renderScope)
        {
            // Clear the content host from previous render scope (if any)
            ClearContentHost();

            // Find ContentHostTemplateName in the style
            _passwordBoxContentHost = GetTemplateChild(ContentHostTemplateName) as FrameworkElement;

            // Note that we allow ContentHostTemplateName to be optional.
            // This simplifies toolability of our control styling.
            // When the ContentHostTemplateName is not found or incorrect
            // PasswordBox goes into disabled state, but does not throw.

            // Add renderScope as a child of ContentHostTemplateName
            _renderScope = renderScope;
            if (_passwordBoxContentHost is ScrollViewer)
            {
                ScrollViewer scrollViewer = (ScrollViewer)_passwordBoxContentHost;
                if (scrollViewer.Content != null)
                {
                    throw new NotSupportedException(SR.Get(SRID.TextBoxScrollViewerMarkedAsTextBoxContentMustHaveNoContent));
                }
                else
                {
                    scrollViewer.Content = _renderScope;
                }
            }
            else if (_passwordBoxContentHost is Decorator)
            {
                Decorator decorator = (Decorator)_passwordBoxContentHost;
                if (decorator.Child != null)
                {
                    throw new NotSupportedException(SR.Get(SRID.TextBoxDecoratorMarkedAsTextBoxContentMustHaveNoContent));
                }
                else
                {
                    decorator.Child = _renderScope; // this may replace old render scope in case of upgrade scenario in TextBox
                }
            }
            else
            {
                // When we implement TextContainer setting via TextView interface
                // all text containing element will become allowed here.
                _renderScope = null;

                // Explicitly not throwing an exception here when content host = null
                // -- designers need us to support no content scenarios
                if (_passwordBoxContentHost != null)
                {
                    _passwordBoxContentHost = null;
                    //
                    throw new NotSupportedException(SR.Get(SRID.PasswordBoxInvalidTextContainer));
                }
            }

            // Attach render scope to TextEditor
            InitializeRenderScope();

            FrameworkElement element = _renderScope;

            while (element != this && element != null)  // checking both just to be safe
            {
                if (element is Border)
                {
                    _border = (Border)element;
                }
                element = element.Parent as FrameworkElement;
            }
        }
Exemplo n.º 6
0
        private static Decorator CreateDecorator(UIElement element)
        {
            var decorator = new Decorator
            {
                Child = element
            };

            KeyboardNavigation.SetTabNavigation(decorator, KeyboardNavigationMode.Cycle);
            KeyboardNavigation.SetControlTabNavigation(decorator, KeyboardNavigationMode.Cycle);
            KeyboardNavigation.SetDirectionalNavigation(decorator, KeyboardNavigationMode.Cycle);

            return decorator;
        }
Exemplo n.º 7
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     
     #line 4 "..\..\MainWindow.xaml"
     ((HCITargetSelection.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);
     
     #line default
     #line hidden
     
     #line 5 "..\..\MainWindow.xaml"
     ((HCITargetSelection.MainWindow)(target)).MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.Window_MouseUp);
     
     #line default
     #line hidden
     
     #line 6 "..\..\MainWindow.xaml"
     ((HCITargetSelection.MainWindow)(target)).MouseMove += new System.Windows.Input.MouseEventHandler(this.Window_MouseMove);
     
     #line default
     #line hidden
     return;
     case 2:
     this.deco = ((System.Windows.Controls.Decorator)(target));
     return;
     case 3:
     
     #line 10 "..\..\MainWindow.xaml"
     ((System.Windows.Controls.Image)(target)).MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.Image_MouseUp);
     
     #line default
     #line hidden
     return;
     case 4:
     this.imgParent = ((System.Windows.Controls.Canvas)(target));
     return;
     case 5:
     this.btn_1 = ((System.Windows.Controls.Image)(target));
     
     #line 12 "..\..\MainWindow.xaml"
     this.btn_1.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.Image_MouseUp);
     
     #line default
     #line hidden
     return;
     case 6:
     this.btn_2 = ((System.Windows.Controls.Image)(target));
     
     #line 13 "..\..\MainWindow.xaml"
     this.btn_2.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.Image_MouseUp);
     
     #line default
     #line hidden
     return;
     case 7:
     this.btn_3 = ((System.Windows.Controls.Image)(target));
     
     #line 14 "..\..\MainWindow.xaml"
     this.btn_3.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.Image_MouseUp);
     
     #line default
     #line hidden
     return;
     case 8:
     this.btn_4 = ((System.Windows.Controls.Image)(target));
     
     #line 15 "..\..\MainWindow.xaml"
     this.btn_4.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.Image_MouseUp);
     
     #line default
     #line hidden
     return;
     case 9:
     this.btn_5 = ((System.Windows.Controls.Image)(target));
     
     #line 16 "..\..\MainWindow.xaml"
     this.btn_5.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.Image_MouseUp);
     
     #line default
     #line hidden
     return;
     case 10:
     this.btn_6 = ((System.Windows.Controls.Image)(target));
     
     #line 17 "..\..\MainWindow.xaml"
     this.btn_6.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.Image_MouseUp);
     
     #line default
     #line hidden
     return;
     case 11:
     this.btn_7 = ((System.Windows.Controls.Image)(target));
     
     #line 18 "..\..\MainWindow.xaml"
     this.btn_7.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.Image_MouseUp);
     
     #line default
     #line hidden
     return;
     case 12:
     this.btn_8 = ((System.Windows.Controls.Image)(target));
     
     #line 19 "..\..\MainWindow.xaml"
     this.btn_8.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.Image_MouseUp);
     
     #line default
     #line hidden
     return;
     case 13:
     this.btn_9 = ((System.Windows.Controls.Image)(target));
     
     #line 20 "..\..\MainWindow.xaml"
     this.btn_9.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.Image_MouseUp);
     
     #line default
     #line hidden
     return;
     case 14:
     this.btn_10 = ((System.Windows.Controls.Image)(target));
     
     #line 21 "..\..\MainWindow.xaml"
     this.btn_10.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.Image_MouseUp);
     
     #line default
     #line hidden
     return;
     case 15:
     this.target = ((System.Windows.Controls.Image)(target));
     return;
     case 16:
     this.counter = ((System.Windows.Controls.TextBlock)(target));
     return;
     case 17:
     this.start = ((System.Windows.Controls.TextBlock)(target));
     return;
     }
     this._contentLoaded = true;
 }
Exemplo n.º 8
0
 public static void SetIsApplicationBarHost(Decorator obj, bool value)
 {
     ValidationHelper.NotNull(obj, () => obj);
     obj.SetValue(IsApplicationBarHostProperty, BooleanBoxingHelper.Box(value));
 }
Exemplo n.º 9
0
            internal PopupAdorner(UIElement element, PlacementMode placementMode, Style previewStyle)
                : base(element)
            {
                PlacementMode = placementMode;

                Control control = new Control();
                control.SnapsToDevicePixels = true;
                control.Style = previewStyle;
                control.IsEnabled = false;
                Translation = new TranslateTransform();
                _decorator = new Decorator();
                _decorator.Child = control;
                _decorator.RenderTransform = Translation;
                AddVisualChild(_decorator);
            }
Exemplo n.º 10
0
 public ContentManager(TabControl tabControl, Decorator border)
 {
     _tabControl = tabControl;
     _border = border;
     _tabControl.SelectionChanged += (sender, args) => { UpdateSelectedTab(); };
 }
Exemplo n.º 11
0
            public PreviewAdorner(GridSplitter gridSplitter, Style previewStyle)
                : base(gridSplitter)
            {
                // Create a preview control to overlay on top of the GridSplitter
                Control previewControl = new Control();
                previewControl.Style = previewStyle;
                previewControl.IsEnabled = false;

                // Add a decorator to perform translations
                Translation = new TranslateTransform();                
                _decorator = new Decorator();
                _decorator.Child = previewControl;
                _decorator.RenderTransform = Translation;
 
                this.AddVisualChild(_decorator);  
            }
Exemplo n.º 12
0
        public void Show(Decorator placeholder)
        {
            this.Placeholder = placeholder;

            placeholder.Child = this;
        }
Exemplo n.º 13
0
        public static void FlashForeground(Decorator control)
        {
            var thread = new Thread(new ThreadStart(delegate
                                                        {
                                                            Tutorial.Main.Dispatcher.Invoke(new Action(delegate { }));

                                                            for (int i = 0; i < 16; i++)
                                                            {
                                                                int ii = i%4;
                                                                switch (ii)
                                                                {
                                                                    case 0:
                                                                        Tutorial.Main.Dispatcher.Invoke(
                                                                            new Action(
                                                                                delegate { control.Opacity = .75; }));
                                                                        break;

                                                                    case 1:
                                                                        Tutorial.Main.Dispatcher.Invoke(
                                                                            new Action(
                                                                                delegate { control.Opacity = .5; }));
                                                                        break;

                                                                    case 2:
                                                                        Tutorial.Main.Dispatcher.Invoke(
                                                                            new Action(
                                                                                delegate { control.Opacity = .75; }));
                                                                        break;

                                                                    case 3:
                                                                        Tutorial.Main.Dispatcher.Invoke(
                                                                            new Action(delegate { control.Opacity = 1; }));
                                                                        break;
                                                                }
                                                                Thread.Sleep(175);
                                                            }
                                                            Tutorial.Main.Dispatcher.Invoke(
                                                                new Action(delegate { control.Opacity = 1; }));
                                                        }));
            thread.Start();
        }
Exemplo n.º 14
0
        private void OnApplyTemplateInternal()
        {
            if (Template != null)
            {
                _layoutRoot = Template.FindName(LayoutRootName, this) as Panel;
                if (_layoutRoot == null)
                {
                    Trace.TraceError(LayoutRootName + " not found.");
                }

                _caption = Template.FindName(CaptionName, this) as FrameworkElement;
                if (_caption == null)
                {
                    Trace.TraceError(CaptionName + " not found.");
                }
                else
                {
                    _caption.SizeChanged += OnCaptionSizeChanged;
                }

                if (_titleBarHost != null)
                {
                    _titleBarHost.Child = null;
                }
                _titleBarHost = Template.FindName(TitleBarHostName, this) as Decorator;
                if (_titleBarHost == null)
                {
                    Trace.TraceError(TitleBarHostName + " not found.");
                }
                else
                {
                    _titleBarHost.Child = TitleBar;
                }
            }
        }
Exemplo n.º 15
0
 public void Show(Decorator placeholder)
 {
     Placeholder = placeholder;
     RefreshInstalledGameList();
     placeholder.Child = this;
     var game = GameManager.Get().GetById(Prefs.LastHostedGameType);
     if (game != null)
     {
         ComboBoxGame.SelectedItem = Games.First(x => x.Id == game.Id);
     }
 }
Exemplo n.º 16
0
        public void Show(Decorator placeholder)
        {
            Placeholder = placeholder;
            this.RefreshInstalledGameList();
            
            if (lastHostedGameType != Guid.Empty)
            {
                var game = GameManager.Get().Games.FirstOrDefault(x => x.Id == lastHostedGameType);
                if (game != null)
                {
                    var model = Games.FirstOrDefault(x => x.Id == game.Id);
                    if (model != null) this.ComboBoxGame.SelectedItem = model;
                }
            }

            placeholder.Child = this;
        }
Exemplo n.º 17
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (Template == null)
            {
                contentHost = null;
            }
            else
            {
                contentHost = Template.FindName("PART_ContentHost", this) as Decorator;
                contentHost.Child = textBoxView;
            }
        }
Exemplo n.º 18
0
        private static ContentManager GetContentManager(TabControl tabControl, Decorator container)
        {
            var contentManager = (ContentManager) GetInternalContentManager(tabControl);
            if (contentManager != null)
            {
                /*
                 * Content manager already exists for the tab control. This means that tab content template is applied 
                 * again, and new instance of the Border control (container) has been created. The old container 
                 * referenced by the content manager is no longer visible and needs to be replaced
                 */
                contentManager.ReplaceContainer(container);
            }
            else
            {
                // create content manager for the first time
                contentManager = new ContentManager(tabControl, container);
                SetInternalContentManager(tabControl, contentManager);
            }

            return contentManager;
        }
Exemplo n.º 19
0
 public void Show(Decorator placeholder)
 {
     Placeholder = placeholder;
     RefreshInstalledGameList();
     placeholder.Child = this;
 }
Exemplo n.º 20
0
            public void ReplaceContainer(Decorator newBorder)
            {
                if (ReferenceEquals(_border, newBorder)) return;

                _border.Child = null; // detach any tab content that old border may hold
                _border = newBorder;
            }
Exemplo n.º 21
0
 public static bool GetIsApplicationBarHost(Decorator obj)
 {
     ValidationHelper.NotNull(obj, () => obj);
     return BooleanBoxingHelper.Unbox(obj.GetValue(IsApplicationBarHostProperty));
 }