Ejemplo n.º 1
0
        private void OnViewPropertyChanged(object sender, ApplicationSharingViewPropertyChangedEventArgs e)
        {
            ApplicationSharingView view = (ApplicationSharingView)sender;

            if (view.Properties == null)
            {
                return;
            }

            //If the changed viewer property is a dimension property then resize parent container control
            if (e.Property == ApplicationSharingViewProperty.Height || e.Property == ApplicationSharingViewProperty.Width)
            {
                //If user chose FitToParent, the parent container control is not resized.
                if (SharingModality.View.DisplayMode == ApplicationSharingViewDisplayMode.FitToParent)
                {
                    return;
                }
            }
            else if (e.Property == ApplicationSharingViewProperty.ParentWindow)
            {
                if (SharingModality.View.State == ApplicationSharingViewState.Active)
                {
                    SharingModality.View.SyncRectangle();
                }
            }
        }
        /// <summary>
        /// Sets dimensions for container control parent of application sharing view when the
        /// dimensions of the view change
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void View_PropertyChanged(object sender, ApplicationSharingViewPropertyChangedEventArgs e)
        {
            ApplicationSharingView view = (ApplicationSharingView)sender;

            if (view.Properties == null)
            {
                return;
            }

            //If the changed viewer property is a dimension property then resize parent container control
            if (e.Property == ApplicationSharingViewProperty.Height || e.Property == ApplicationSharingViewProperty.Width)
            {
                //If user chose FitToParent, the parent container control is not resized.
                if (_sharingModality.View.DisplayMode == ApplicationSharingViewDisplayMode.FitToParent)
                {
                    this.Invoke(new NoParamDelegate(ResetFormToOriginalDimensions));

                    return;
                }


                this.Invoke(
                    new ResizeFormForPanelDelegate(ResizeFormForPanel),
                    new object[] { view });
            }
            else if (e.Property == ApplicationSharingViewProperty.ParentWindow)
            {
                if (_sharingModality.View.State == ApplicationSharingViewState.Active)
                {
                    _sharingModality.View.SyncRectangle();
                }
            }
        }
        void View_StateChanged(object sender, ApplicationSharingViewStateChangedEventArgs e)
        {
            ApplicationSharingView view = (ApplicationSharingView)sender;

            if (view.State == ApplicationSharingViewState.Active)
            {
                System.Diagnostics.Debug.WriteLine("Sync rectangle in View_StateChanged event");
                try
                {
                    view.SyncRectangle();
                }
                catch (InvalidStateException ise)
                {
                    System.Diagnostics.Debug.WriteLine("View state is invalid on call to SyncRectangle: " + ise.Message);
                }
            }
            else if (e.NewState == ApplicationSharingViewState.Inactive || e.NewState == ApplicationSharingViewState.Minimized)
            {
                this.Invoke(new NoParamDelegate(ResetFormToOriginalDimensions));
            }
        }
Ejemplo n.º 4
0
        private void ShowApplicationSharingView(System.Windows.Forms.Panel applicaionViewPanel, ApplicationSharingView view)
        {
            _log.Debug("ShowApplicationSharingView  applicaionViewPanel:{0}", applicaionViewPanel.Handle.ToInt32());

            try
            {
                view.PropertyChanged += OnViewPropertyChanged;
                view.SetParent(applicaionViewPanel.Handle.ToInt32());
                if (view.Properties == null)
                {
                    return;
                }
            }
            catch (Exception exception)
            {
                _log.ErrorException("", exception);
            }
        }
Ejemplo n.º 5
0
 private void ShowApplicationSharingView(ApplicationSharingView obj)
 {
     showSharingDesktopPartView.Visibility  = Visibility.Visible;
     showSharingDesktopPartView.DataContext = ViewModel;
 }
        /// <summary>
        /// Changes the dimensions of the main form and container control to fit
        /// the new size of the viewer. The maximum dimensions of the form are
        /// constrained by the dimensions of the screen work area.
        /// </summary>
        /// <param name="newHeight">int. The new height of the viewer</param>
        /// <param name="newWidth">int. The new width of the viewer</param>
        private void ResizeFormForPanel(ApplicationSharingView view)
        {
            //Add 4 display units to prevent scroll bars from appearing on container.
            int newViewWidth  = (int)view.Properties[ApplicationSharingViewProperty.Width] + 4;
            int newViewHeight = (int)view.Properties[ApplicationSharingViewProperty.Height] + 4;

            //Get the maximum possible dimensions as constrained by the screen
            int screenHeight = SystemInformation.WorkingArea.Height;
            int screenWidth  = SystemInformation.WorkingArea.Width;


            //If the original width of the form is less than the
            //proposed new width, then widen the form to fit the new
            //panel dimensions
            if (_windowSize._originalFormWidth < (newViewWidth + _windowSize._horizontalMargin))
            {
                //If the proposed width is less than or equal to the
                //working area of the desktop, set the width to the
                //proposed width
                if ((newViewWidth + _windowSize._horizontalMargin) <= screenWidth)
                {
                    _ViewPanel.Width = newViewWidth;
                    this.Width       = newViewWidth + _windowSize._horizontalMargin;
                }
                else
                {
                    //Set the form to maximum width
                    _ViewPanel.Width = screenWidth - _windowSize._horizontalMargin;
                    this.Width       = screenWidth;
                }
            }
            //Otherwise, set the form to it's original width.
            else
            {
                this.Width       = _windowSize._originalFormWidth;
                _ViewPanel.Width = _windowSize._originalPanelWidth;
            }


            //If the original Height of the form is less than the
            //proposed new height, then set the height of the form to
            //the new height
            if (_windowSize._originalFormHeight < (newViewHeight + _windowSize._verticalMargin))
            {
                //If the proposed height is less than or equal to the
                //working area of the desktop, set the height to the
                //proposed height
                if ((newViewHeight + _windowSize._verticalMargin) <= screenHeight)
                {
                    _ViewPanel.Height = newViewHeight;
                    this.Height       = newViewHeight + _windowSize._verticalMargin;
                }
                else
                {
                    _ViewPanel.Height = screenHeight - _windowSize._verticalMargin;
                    this.Height       = screenHeight;
                }
            }
            else
            {
                this.Height       = _windowSize._originalFormHeight;
                _ViewPanel.Height = _windowSize._originalPanelHeight;
            }
            //Resynch the view if it is docked in a parent container
            if (_sharingModality.View.Properties[ApplicationSharingViewProperty.ParentWindow] != null)
            {
                _sharingModality.View.SyncRectangle();
            }
        }