Exemplo n.º 1
0
        public WinFormsUiFacade(AlphaTabControl scrollViewer, AlphaTabLayoutPanel layoutPanel)
        {
            _layoutPanel  = layoutPanel;
            RootContainer = new ControlContainer(scrollViewer);
            RootContainerBecameVisible = new DelegatedEventEmitter(
                value =>
            {
                if (RootContainer.IsVisible)
                {
                    value();
                }
                else
                {
                    void OnSizeChanged(object?sender, EventArgs e)
                    {
                        SettingsContainer.VisibleChanged -= OnVisibilityChanged;
                        SettingsContainer.SizeChanged    -= OnSizeChanged;
                        if (SettingsContainer.Visible && SettingsContainer.Width > 0)
                        {
                            InternalRootContainerBecameVisible?.Invoke();
                            InternalRootContainerBecameVisible = null;
                        }
                    }

                    void OnVisibilityChanged(object?sender, EventArgs e)
                    {
                        SettingsContainer.VisibleChanged -= OnVisibilityChanged;
                        SettingsContainer.SizeChanged    -= OnSizeChanged;
                        if (SettingsContainer.Visible && SettingsContainer.Width > 0)
                        {
                            InternalRootContainerBecameVisible?.Invoke();

                            InternalRootContainerBecameVisible = null;
                        }
                    }

                    InternalRootContainerBecameVisible += value;
                    SettingsContainer.VisibleChanged   += OnVisibilityChanged;
                    SettingsContainer.SizeChanged      += OnSizeChanged;
                }
            },
                value => { InternalRootContainerBecameVisible -= value; }
                );
        }
Exemplo n.º 2
0
        public WpfUiFacade(ScrollViewer scrollViewer)
        {
            _scrollViewer = scrollViewer;
            RootContainer = new FrameworkElementContainer(scrollViewer);
            RootContainerBecameVisible = new DelegatedEventEmitter(
                value =>
            {
                if (RootContainer.IsVisible)
                {
                    value();
                }
                else
                {
                    void OnSizeChanged(object sender, SizeChangedEventArgs e)
                    {
                        _scrollViewer.IsVisibleChanged -= OnVisibilityChanged;
                        _scrollViewer.SizeChanged      -= OnSizeChanged;
                        if (_scrollViewer.IsVisible && _scrollViewer.ActualWidth > 0)
                        {
                            InternalRootContainerBecameVisible?.Invoke();
                            InternalRootContainerBecameVisible = null;
                        }
                    }

                    void OnVisibilityChanged(object sender,
                                             DependencyPropertyChangedEventArgs e)
                    {
                        _scrollViewer.IsVisibleChanged -= OnVisibilityChanged;
                        _scrollViewer.SizeChanged      -= OnSizeChanged;
                        if (_scrollViewer.IsVisible && _scrollViewer.ActualWidth > 0)
                        {
                            InternalRootContainerBecameVisible?.Invoke();
                            InternalRootContainerBecameVisible = null;
                        }
                    }

                    InternalRootContainerBecameVisible += value;
                    _scrollViewer.IsVisibleChanged     += OnVisibilityChanged;
                    _scrollViewer.SizeChanged          += OnSizeChanged;
                }
            },
                value => { InternalRootContainerBecameVisible -= value; }
                );
        }