public static void Normalize(this MDIWindow window)
        {
            Canvas.SetTop(window, window.LastTop);
            Canvas.SetLeft(window, window.LastLeft);

            AnimateResize(window, window.LastWidth, window.LastHeight, false);

            window.WindowState = WindowState.Normal;
        }
 public static void ToggleMaximize(this MDIWindow window)
 {
     if (window.WindowState == WindowState.Maximized)
     {
         window.Normalize();
     }
     else
     {
         window.Maximize();
     }
 }
        public static void Maximize(this MDIWindow window)
        {
            if (window.IsResizable)
            {
                Canvas.SetTop(window, 0.0);
                Canvas.SetLeft(window, 0.0);

                AnimateResize(window, window.Container.ActualWidth - 4, window.Container.ActualHeight - 4, true);

                window.WindowState = WindowState.Maximized;
            }
        }
        /// <summary>
        /// Handles the mouse up event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void HandleMouseUp(object sender, MouseEventArgs e)
        {
            base.HandleMouseUp(sender, e);

            if (XDelta > 0 && Runner != null)
            {
                int steps = XDelta / (SIZE.Width + TimeLineControl.BUTTON_MARGIN_SIZE);
                if (steps > 0)
                {
                    Runner.RunUntilTime(Runner.Time + steps * Runner.Step);
                }
                MDIWindow.Refresh();
            }
        }
Beispiel #5
0
        public static RenderTargetBitmap CreateSnapshot(this MDIWindow window)
        {
            var bitmap        = new RenderTargetBitmap((int)Math.Round(window.ActualWidth), (int)Math.Round(window.ActualHeight), 96, 96, PixelFormats.Default);
            var drawingVisual = new DrawingVisual();

            using (var context = drawingVisual.RenderOpen())
            {
                var brush = new VisualBrush(window);
                context.DrawRectangle(brush, null, new Rect(new Point(), new Size(window.ActualWidth, window.ActualHeight)));
                context.Close();
            }

            bitmap.Render(drawingVisual);

            return(bitmap);
        }
        private static void AnimateResize(MDIWindow window, double newWidth, double newHeight, bool lockWindow)
        {
            window.LayoutTransform = new ScaleTransform();

            var widthAnimation  = new DoubleAnimation(window.ActualWidth, newWidth, new Duration(TimeSpan.FromMilliseconds(10)));
            var heightAnimation = new DoubleAnimation(window.ActualHeight, newHeight, new Duration(TimeSpan.FromMilliseconds(10)));

            if (lockWindow == false)
            {
                widthAnimation.Completed  += (s, e) => window.BeginAnimation(FrameworkElement.WidthProperty, null);
                heightAnimation.Completed += (s, e) => window.BeginAnimation(FrameworkElement.HeightProperty, null);
            }

            window.BeginAnimation(FrameworkElement.WidthProperty, widthAnimation, HandoffBehavior.Compose);
            window.BeginAnimation(FrameworkElement.HeightProperty, heightAnimation, HandoffBehavior.Compose);
        }
        public static void Minimize(this MDIWindow window)
        {
            var index = window.Container.MinimizedWindowsCount;

            window.LastWidth  = window.ActualWidth;
            window.LastHeight = window.ActualHeight;
            Canvas.SetTop(window, window.Container.ActualHeight - 32);
            Canvas.SetLeft(window, index * 205);

            RemoveWindowLock(window);
            AnimateResize(window, 200, 32, true);

            window.WindowState = WindowState.Minimized;

            window.Tumblr.Source = window.CreateSnapshot();
        }
        /// <summary>
        /// Handles the mouse up event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void HandleMouseUp(object sender, MouseEventArgs e)
        {
            base.HandleMouseUp(sender, e);

            if (XDelta < 0 && Runner != null)
            {
                int steps = -XDelta / (SIZE.Width + TimeLineControl.BUTTON_MARGIN_SIZE);
                if (steps > 0)
                {
                    for (int i = 0; i < steps; i++)
                    {
                        Runner.StepBack();
                    }
                }
                MDIWindow.Refresh();
            }
        }
        private void mdiLayout_ActiveWindowChanged(object sender, EventArgs e)
        {
            //Check to see if the active window is one of the SceneViewWindow's MDIWindow
            bool      foundWindow     = false;
            MDIWindow activeMDIWindow = mdiLayout.ActiveWindow;

            foreach (SceneViewWindow window in mdiWindows)
            {
                MDISceneViewWindow mdiSceneWindow = window as MDISceneViewWindow;
                if (mdiSceneWindow != null && mdiSceneWindow._getMDIWindow() == activeMDIWindow)
                {
                    ActiveWindow = window;
                    foundWindow  = true;
                    break;
                }
            }
            //If we did not find the window specified and we don't already have an active window, use the first window as the current window
            if (!foundWindow && activeWindow == null)
            {
                ActiveWindow = mdiWindows.FirstOrDefault();
            }
        }
        /// <summary>
        /// Selects a model element
        /// </summary>
        /// <param name="model"></param>
        public void Select(object model)
        {
            if (StateDiagramWindow != null)
            {
                StateDiagramWindow.Select(model);
            }
            else
            {
                if (model is StateControl)
                {
                    StateControl control = model as StateControl;
                    MDIWindow.Select(control.State);
                }
                else if (model is TransitionControl)
                {
                    TransitionControl control = model as TransitionControl;
                    MDIWindow.Select(control.Transition.RuleCondition);
                }
            }

            Refresh();
        }
        public static void ToggleMinimize(this MDIWindow window)
        {
            if (window.WindowState != WindowState.Minimized)
            {
                window.Minimize();
            }
            else
            {
                switch (window.PreviousWindowState)
                {
                case WindowState.Maximized:
                    window.Maximize();
                    break;

                case WindowState.Normal:
                    window.Normalize();
                    break;

                default:
                    throw new NotSupportedException("Invalid WindowState");
                }
            }
        }
 /// <summary>
 /// Handles the close event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void GraphView_FormClosed(object sender, FormClosedEventArgs e)
 {
     CleanUp();
     MDIWindow.HandleSubWindowClosed(this);
 }
 /// <summary>
 /// Handles the close event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void Window_FormClosed(object sender, FormClosedEventArgs e)
 {
     MDIWindow.HandleSubWindowClosed(this);
 }
Beispiel #14
0
        private void btnSubmitLogin_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (txtEmail.Text.Trim().Length == 0)
                {
                    lblMsg.Content = "Enter an email.";
                    txtEmail.Focus();
                    return;
                }
                else if (!Regex.IsMatch(txtEmail.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"))
                {
                    lblMsg.Content = "Enter a valid email.";
                    txtEmail.Select(0, txtEmail.Text.Length);
                    txtEmail.Focus();
                    return;
                }
                else if (txtPin.Password.Trim().Length == 0)
                {
                    lblMsg.Content = "Enter password.";
                    txtPin.Focus();
                    //return;
                }
                else
                {
                    TResponse objTResponse = new UserProfileBusiness().UserProfileLogin(new LoginModel {
                        Email = txtEmail.Text.Trim(), Password = txtPin.Password.Trim(), RememberMe = false, Type = "Pilot"
                    });

                    if (objTResponse.ResponsePacket != null)
                    {
                        UserProfileModel objPilotModel = objTResponse.ResponsePacket as UserProfileModel;
                        if (objPilotModel != null)
                        {
                            PilotSession.UserName  = objPilotModel.FName + " " + objPilotModel.LName;
                            PilotSession.UserId    = objPilotModel.UserId;
                            PilotSession.UserEmail = objPilotModel.Email;
                            txtEmail.Text          = string.Empty;
                            txtPin.Password        = string.Empty;

                            MDIWindow md = new MDIWindow();
                            this.Close();
                            md.Show();
                        }
                        else
                        {
                            lblMsg.Content = "Sorry! Please enter existing emailid/password.";
                            reset();
                        }
                    }
                    else
                    {
                        lblMsg.Content = "Sorry! Please enter existing emailid/password.";
                        reset();
                    }
                }
            }
            catch (Exception ex)
            {
                //PopupBox frmPopup = new PopupBox("Error", ex.Message, MessageBoxImage.Error);
                //frmPopup.ShowDialog();
            }
        }
 public static void RemoveWindowLock(this MDIWindow window)
 {
     window.BeginAnimation(FrameworkElement.WidthProperty, null);
     window.BeginAnimation(FrameworkElement.HeightProperty, null);
 }