Пример #1
0
        private void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {
            AboutView     view   = new AboutView();
            ContentWindow window = ContentWindow.Create(view);

            window.Title = "About Judge Sharp";
            window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            window.ShowDialog();
        }
Пример #2
0
        public static void Show(TestCaseViewModel tc)
        {
            EditTestCaseView tce    = new EditTestCaseView(tc);
            ContentWindow    window = ContentWindow.Create(tce, 700, 500);

            window.Title            = "Edit Test Case";
            tce.CancelButton.Click += delegate { window.Close(); };
            tce.OKButton.Click     += delegate { tce.OKButton_Click(); window.Close(); };
            window.ShowDialog();
        }
Пример #3
0
        public static string Show(string lable, string title)
        {
            InputBoxView  view   = new InputBoxView();
            ContentWindow window = ContentWindow.Create(view, 400, 150, false, false, false);

            window.Title             = title;
            view.HeaderText.Text     = lable;
            view.OKButton.Click     += delegate { window.DialogResult = true; window.Close(); };
            view.CancelButton.Click += delegate { window.DialogResult = false; };
            window.ShowDialog();
            if (window.DialogResult.HasValue && window.DialogResult.Value)
            {
                return(view.ContentTextBox.Text);
            }
            else
            {
                return(null);
            }
        }
Пример #4
0
        public static ContentWindow Create(Object view, double width = 1024, double height = 600, bool canClose = true, bool canMinimize = true, bool canMaximize = true)
        {
            ContentWindow window = new ContentWindow();

            window.Width  = width;
            window.Height = height;
            FrameworkElement fkview = view as FrameworkElement;

            if (fkview != null)
            {
                window.DataContext = fkview.DataContext;
                //if the data context have a Name property then bind it to the window title
                Binding b = new Binding("Name");
                BindingOperations.SetBinding(window, Window.TitleProperty, b);
            }
            window.ContentControl.Content    = view;
            window.CloseButton.Visibility    = canClose ? Visibility.Visible : Visibility.Collapsed;
            window.MinimizeButton.Visibility = canMinimize ? Visibility.Visible : Visibility.Collapsed;
            window.MaximizeButton.Visibility = canMaximize ? Visibility.Visible : Visibility.Collapsed;
            window.ResizeMode = (canMinimize && canMaximize) ? ResizeMode.CanResize : ((canMinimize) ? ResizeMode.CanMinimize : ResizeMode.NoResize);
            return(window);
        }