当前位置: 首页>>代码示例>>C#>>正文


C# MainWindow.FindName方法代码示例

本文整理汇总了C#中MainWindow.FindName方法的典型用法代码示例。如果您正苦于以下问题:C# MainWindow.FindName方法的具体用法?C# MainWindow.FindName怎么用?C# MainWindow.FindName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MainWindow的用法示例。


在下文中一共展示了MainWindow.FindName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ViewManager

        public ViewManager(MainWindow window)
        {
            _window = window;
            _mainContainer = (Grid)window.FindName("mainGrid");
            _imageScrollBar = (ScrollBar)window.FindName("imageScrollBar");
            _progressScrollBar = (ScrollBar)window.FindName("progressScrollBar");
            _rotateTransform = (RotateTransform)window.FindName("displayRotateTransform");
            _imageTranslateTransform = (TranslateTransform)window.FindName("imageTranslateTransform");

            _comicImage = (Image)window.FindName("comicImage");

            /*
            // NOTE: keep this code as an example on how to monitor property changes
            // This code is required because WPF Image control does not have a ImageLoaded event.
            DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromProperty(Image.SourceProperty, typeof(Image));
            dpd.AddValueChanged(_comicImage, OnImageChanged);
            */

            _imageViewbox = (Viewbox)window.FindName("imageViewbox");
            _imageViewbox.SizeChanged += OnImageViewboxSizeChanged;

            _pixelMatrix = PresentationSource.FromVisual(_window).CompositionTarget.TransformToDevice;

            _portraitStoryboard = (Storyboard)_window.TryFindResource("portraitStoryboard");
            _landscapeStoryboard = (Storyboard)_window.TryFindResource("landscapeStoryboard");
            _portraitStoryboard.Completed += OnRotationStoryboardCompleted;
            _landscapeStoryboard.Completed += OnRotationStoryboardCompleted;

            _translateXStoryboard = (Storyboard)_window.TryFindResource("translateXStoryboard");
            _translateYStoryboard = (Storyboard)_window.TryFindResource("translateYStoryboard");
            _translateXDoubleAnimation = (DoubleAnimation)_translateXStoryboard.Children[0];
            _translateYDoubleAnimation = (DoubleAnimation)_translateYStoryboard.Children[0];

            // Assumes both X and Y double animation have the same duration
            TRANSLATE_DURATION = _translateXDoubleAnimation.Duration;

            _numberingContainer = (Border)window.FindName("numberingBorder");

            _imageScrollBarAnimation = new DoubleAnimation();
            _imageScrollBarAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(300));
            _imageScrollBarAnimation.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };

            //TODO: add gesture handling
            /*_window.PreviewMouseMove += _window_MouseMove;*/
        }
开发者ID:theahuramazda,项目名称:Saluse-ComicReader,代码行数:45,代码来源:ViewManager.cs

示例2: OnPreviewMouseLeftButtonDown

        public void OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            _LastDropTarget = null;

            Visual visual = e.OriginalSource as Visual;
            _TopWindow = DragController.FindAncestor(typeof(MainWindow), visual) as MainWindow;
            if (_TopWindow == null && !_TopWindow.IsActive)
                return;

            _DownPointInTopWindow = e.GetPosition(_TopWindow);
            _DownPointGapOfBlock = e.GetPosition(sender as IInputElement);
            _BlockBoard = _TopWindow.FindName("blocksBoard") as BlocksBoard;
            _DragCanvas = _TopWindow.FindName("dragCanvas") as Canvas;

            FrameworkElement fe = sender as FrameworkElement;
            if ( fe == null)
            {
                System.Diagnostics.Debug.WriteLine("create block datacontext null");
                System.Diagnostics.Debug.Assert(fe != null);
                return;
            }
            _DraggedData = sender;
            _bDragCreate = (fe.DataContext != null) ? true : false;
        }
开发者ID:yoursalary,项目名称:EPL,代码行数:24,代码来源:DragController.cs


注:本文中的MainWindow.FindName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。