Ejemplo n.º 1
0
        public void Create <TViewModel>(ViewModelBase ownerViewModel = null, bool isDialog = false) where TViewModel : ViewModelBase, new()
        {
            var viewModel = new TViewModel();

            var window = new DefaultWindow
            {
                DataContext           = viewModel,
                SizeToContent         = SizeToContent.WidthAndHeight,
                Owner                 = GetViewByViewModel(ownerViewModel),
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
            };

            if (ownerViewModel == null)
            {
                window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            }

            window.Loaded  += viewModel.OnLoaded;
            window.Closing += viewModel.OnClosing;

            Application.Current.Dispatcher.Invoke(() =>
            {
                if (!isDialog)
                {
                    window.Show();
                }
                else
                {
                    window.ShowDialog();
                }
            });
        }
Ejemplo n.º 2
0
        private void NewTest_Click(object sender, RoutedEventArgs e)
        {
            DefaultWindow  dw  = new DefaultWindow();
            NewProjectPage npp = new NewProjectPage();

            dw.Icon = BitmapFrame.Create(Application.GetResourceStream
                                             (new Uri(@"Images\edit.png", UriKind.RelativeOrAbsolute)).Stream);

            dw.MinHeight = npp.MinHeight;
            dw.MinWidth  = npp.MinWidth;
            dw.Content   = npp.Content;
            dw.Title     = npp.Title;

            dw.Height = 400;
            dw.Width  = 400;

            dw.ShowDialog();
        }
Ejemplo n.º 3
0
        private void fill_Click(object sender, RoutedEventArgs e)
        {
            DefaultWindow    dw  = new DefaultWindow();
            QuestionEditPage qep = new QuestionEditPage();

            dw.Icon = BitmapFrame.Create(System.Windows.Application.GetResourceStream
                                             (new Uri(@"Images\edit.png", UriKind.RelativeOrAbsolute)).Stream);

            dw.MinHeight = qep.MinHeight;
            dw.MinWidth  = qep.MinWidth;
            dw.Content   = qep.Content;
            dw.Title     = qep.Title;

            dw.Height = 500;
            dw.Width  = 900;

            dw.ShowDialog();
        }
Ejemplo n.º 4
0
        private void Next_Click(object sender, RoutedEventArgs e)
        {
            // TODO
            string file = Tools.CreateNewProject(projectName.Text);
            //add in project's list

            DefaultWindow   dw  = new DefaultWindow();
            ProjectEditPage pep = new ProjectEditPage(projectName.Text, file, dw);


            dw.Icon = BitmapFrame.Create(Application.GetResourceStream
                                             (new Uri(@"Images\edit.png", UriKind.RelativeOrAbsolute)).Stream);

            dw.MinHeight = pep.MinHeight;
            dw.MinWidth  = pep.MinWidth;
            dw.Content   = pep.Content;
            dw.Title     = pep.Title;

            Window.GetWindow(sender as Button).Close();
            dw.ShowDialog();
        }