Esempio n. 1
0
        public void Redimensionar(Window window)//, System.Windows.Size sizePantalla)
        {
            if (window == null)
            {
                return;
            }
            if (window.WindowState == WindowState.Maximized)
            {
                contentControl.Margin = new Thickness(20, 30, 20, 30);
            }
            else
            {
                //contentControl.Content = window.Content;
                #region calculando el centrado de los elementos en la pantalla
                //HerramientasWindow.PrincipalOnTOP(true);

                FrameworkElement pnlClient = window as FrameworkElement;
                double           dWidth    = 0;
                double           dHeight   = 0;
                if (pnlClient != null)
                {
                    dWidth  = pnlClient.Width;
                    dHeight = pnlClient.Height;
                }

                //window.Show();
                //window.Hide();
                //HerramientasWindow.PrincipalOnTOP(false);
                double windowHeight = dHeight;
                double windowWidth  = dWidth;


                //this.tamPrincipal = sizePantalla;
                double heightPrincipal = HerramientasWindow.ObtenerSizePrincipal().Height;
                double widhtPrincipal  = HerramientasWindow.ObtenerSizePrincipal().Width;//sizePantalla.Width;

                double diferenciaHeight      = heightPrincipal - (windowHeight + 100);
                double diferenciaWidht       = widhtPrincipal - (windowWidth + 60);
                double mitadDiferenciaHeight = diferenciaHeight / 2;
                double mitadDiferenciaWidht  = diferenciaWidht / 2;
                if (mitadDiferenciaHeight < 0)
                {
                    mitadDiferenciaHeight = 0;
                }
                if (mitadDiferenciaWidht < 0)
                {
                    mitadDiferenciaWidht = 0;
                }
                contentControl.Margin = new Thickness(mitadDiferenciaWidht, mitadDiferenciaHeight, mitadDiferenciaWidht, mitadDiferenciaHeight);
                //contentControl.Foreground = System.Windows.Media.Brushes.White;
                #endregion
            }
            //gridTemp.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            contentControl.UpdateLayout();
        }