public MainWindow(App parent) { this.parent = parent; InitializeComponent(); try { // initialize data models ViewModel = new WindowViewModel(parent, this); } catch (Exception exception) { Console.WriteLine(exception); throw; } Debug.Assert(ViewModel != null); DataContext = ViewModel; Width = Properties.Settings.Default.WindowSizeX; Height = Properties.Settings.Default.WindowSizeY; if (Properties.Settings.Default.IsMaximized) { WindowState = WindowState.Maximized; } }
public MainWindow() { InitializeComponent(); DataContext = new WindowViewModel(this); MainFrame1.Content = new MainPage(); }
public OpenGlHostContextMenu(WindowViewModel viewModel) { var colorItem = Items.Add("Pixel Color"); { var sri = System.Windows.Application.GetResourceStream(new Uri($@"pack://*****:*****@"pack://application:,,,/{App.AppName};component/Icons/displayconfig.png", UriKind.Absolute)); if (sri != null) { pixelDisplayItem.Image = System.Drawing.Image.FromStream(sri.Stream); } pixelDisplayItem.Click += (o, args) => { viewModel.ShowPixelDisplayCommand.Execute(null); }; } }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); ApplicationSetup(); ViewModelApplication.GoToPage(ApplicationPage.Notebook); Current.MainWindow = new MainWindow(); var windowViewModel = new WindowViewModel(Current.MainWindow); using var db = new AppDbContext(); //var _top = db.AppSettings.FirstOrDefault(x => x.SettingName == "WindowTop"); //double.TryParse(_top.Value ?? _top.DefaultValue, out var top); //var _left = db.AppSettings.FirstOrDefault(x => x.SettingName == "WindowLeft"); //double.TryParse(_left.Value ?? _left.DefaultValue, out var left); //var _height = db.AppSettings.FirstOrDefault(x => x.SettingName == "WindowHeight"); //double.TryParse(_height.Value ?? _height.DefaultValue, out var height); //var _width = db.AppSettings.FirstOrDefault(x => x.SettingName == "WindowWidth"); //double.TryParse(_width.Value ?? _width.DefaultValue, out var width); //windowViewModel.SetWindowSizeAndPosition(top, left, height, width); Current.MainWindow.DataContext = windowViewModel; Current.MainWindow.Show(); }
internal override void SetParent(SplitViewModel parentModel, WindowViewModel parentViewModel) { base.SetParent(parentModel, parentViewModel); Item1?.SetParent(this, parentViewModel); Item2?.SetParent(this, parentViewModel); }
private void Page_Loaded(object sender, RoutedEventArgs e) { // Find the frame. Frame pageFrame = null; DependencyObject currParent = VisualTreeHelper.GetParent(this); while (currParent != null && pageFrame == null) { pageFrame = currParent as Frame; currParent = VisualTreeHelper.GetParent(currParent); } //Change the page of the frame. if (pageFrame.DataContext != null) { WindowViewModel windowViewModel = pageFrame.DataContext as WindowViewModel; serverId = windowViewModel.ServerId; playerId = windowViewModel.PlayerId; worldId = DatabaseOperations.OphalenWorldViaSpeler(playerId).id; Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Server ID: " + serverId + "\nWorld ID: " + worldId + "\nPlayer ID: " + playerId + "\n"); } advButtons = new List <ToggleButton>() { btnAdvancementGrasBlok, btnAdvancementHoutenPikhouweel, btnAdvancementStenenPikhouweel, btnAdvancementIjzerKlomp, btnAdvancementIjzerBorst, btnAdvancementHoutenSchild, btnAdvancementEmmerLava, btnAdvancementObsidiaan, btnAdvancementVuursteen, btnAdvancementGoudenAppel, btnAdvancementEnderOog, btnAdvancementEindeSteen, btnAdvancementIjzerenPikhouweel, btnAdvancementDiamant, btnAdvancementDiamantenBorst, btnAdvancementBetoverdBoek, }; LoadAdvancements(0); }
public ApplicationViewModelBuilder(Window wpfWindow) { var window = new WindowViewModel(wpfWindow); var routeSolver = new RouterSolver(); ApplicationViewModel = new ApplicationViewModel(window, new NavigationViewModel(routeSolver)); }
public MainWindow() { InitializeComponent(); WindowViewModel = new WindowViewModel(); this.DataContext = WindowViewModel; }
/// <summary> /// Present the user with a <see cref="DialogWindow"/>. /// </summary> /// <returns> /// Returns `<see langword="true"/>` if the user completed the dialog and the view model is valid; /// otherwise `<see langword="false"/>` if the user canceled or abandoned the dialog, or the view /// model is invalid. /// </returns> /// <param name="viewModel">Window view model.</param> /// <param name="contentCreator">Window content factory.</param> /// <param name="parentHwnd">Parent window handle.</param> public static Task ShowDialogWindow(WindowViewModel viewModel, Func <UserControl> contentCreator, IntPtr parentHwnd) { return(ShowWindow(() => new DialogWindow(contentCreator()) { DataContext = viewModel }, parentHwnd)); }
public void verify_ExecuteFluenceSolverCommand_returns_correct_values() { // WindowViewModel needs to be instantiated for default constructor var windowViewModel = new WindowViewModel(); var viewModel = windowViewModel.FluenceSolverVM; viewModel.ForwardSolverTypeOptionVM.SelectedValue = ForwardSolverType.PointSourceSDA; viewModel.FluenceSolutionDomainTypeOptionVM.SelectedValue = FluenceSolutionDomainType.FluenceOfRhoAndZ; var result = viewModel.GetMapData(); result.Wait(); // ExecuteForwardSolver default settings PlotViewModel plotViewModel = windowViewModel.PlotVM; Assert.AreEqual(plotViewModel.Labels.Count, 0); Assert.AreEqual(plotViewModel.Title, null); TextOutputViewModel textOutputViewModel = windowViewModel.TextOutputVM; double d1 = 0.01; int i1 = 1; double g = 0.8; double n = 1.4; var s1 = StringLookup.GetLocalizedString("Label_FluenceSolver") + StringLookup.GetLocalizedString("Label_MuA") + "=" + d1.ToString(CultureInfo.CurrentCulture) + " " + StringLookup.GetLocalizedString("Label_MuSPrime") + "=" + i1.ToString(CultureInfo.CurrentCulture) + " g=" + g.ToString(CultureInfo.CurrentCulture) + " n=" + n.ToString(CultureInfo.CurrentCulture) + "; " + StringLookup.GetLocalizedString("Label_Units") + " = 1/mm\r"; Assert.AreEqual(textOutputViewModel.Text, s1); }
public void OpenWindow(WindowViewModel viewModel) { var window = WPFPageHelper.InstantiateWindow(viewModel); window.WindowStartupLocation = WindowStartupLocation.CenterScreen; window.Show(); }
private void Page_Loaded(object sender, RoutedEventArgs e) { // Find the frame. Frame pageFrame = null; DependencyObject currParent = VisualTreeHelper.GetParent(this); while (currParent != null && pageFrame == null) { pageFrame = currParent as Frame; currParent = VisualTreeHelper.GetParent(currParent); } //Change the page of the frame. if (pageFrame.DataContext != null) { WindowViewModel windowViewModel = pageFrame.DataContext as WindowViewModel; serverId = windowViewModel.ServerId; playerId = windowViewModel.PlayerId; worldId = DatabaseOperations.OphalenWorldViaSpeler(playerId).id; Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Server ID: " + serverId + "\nWorld ID: " + worldId + "\nPlayer ID: " + playerId + "\n"); } player_Recipes = DatabaseOperations.OphalenPlayerRecipes(playerId); drawRecipes(0); }
public SettingsWindow() { WindowViewModel = new WindowViewModel(); DataContext = WindowViewModel; InitializeComponent(); InteropHelper = new WindowInteropHelper(this); }
private bool IsCollisionWithBorder(SnakeViewModel snakeVM, WindowViewModel windowVM) { return(snakeVM.HeadX < 0 || snakeVM.HeadX + snakeVM.Width > windowVM.BoardWidth || snakeVM.HeadY < 0 || snakeVM.HeadY + snakeVM.Height > windowVM.WindowHeight - 40); }
protected override void FloatTabExecuted(FloatEventArgs e) { var item = e.DataContext as TabModel; Children.Remove(item); var model = new WindowViewModel { IsRafted = true }; var group = new DocumentWellModel(); group.Children.Add(item); model.Content = new DocContainerModel(group); var wnd = new RaftedWindow { Model = model, Left = e.VisualBounds.X, Top = e.VisualBounds.Y, Width = e.VisualBounds.Width, Height = e.VisualBounds.Height }; model.Host = wnd; if (ParentViewModel != null && ParentViewModel.IsRafted && !ParentViewModel.AllTabs.Any()) { ShowOnClose(ParentViewModel.Host, wnd); } else { wnd.Show(); wnd.DragMove(); } }
public BuildingsPage(WindowViewModel vm) { InitializeComponent(); this.vm = vm; Buildings = vm.Buildings; DataContext = this; }
public FractionsPage(WindowViewModel vm, Predio p) { InitializeComponent(); this.vm = vm; this.p = p; List <Fracao> fractions = Fracao.get_All_Fractions(p.ID); int oc = 0; foreach (Fracao fraction in fractions) { _Items.Add(fraction); if (fraction.CurrentCondomino != null) { oc += 1; } } if (fractions.Count() != 0) { Ocupacao = (Math.Round(100 * oc / (double)fractions.Count(), 2)).ToString() + "% (" + oc + "/" + fractions.Count() + ")"; } else { Ocupacao = "0% (" + oc + "/" + fractions.Count() + ")"; } }
public AgendaPage(WindowViewModel vm, Predio p) { InitializeComponent(); this.vm = vm; this.p = p; Eventos = new ObservableCollection <Evento>(Evento.get_Next_Events(p.ID)); }
public ApplicationViewModelBuilder(Window wpfWindow) { var window = new WindowViewModel(wpfWindow); var routeSolver = RoutingConfiguration.Register(); var serviceLocatorBuilder = new DependencyInjectionConfiguration(); var serviceLocatorLazy = serviceLocatorBuilder.GetServiceLocator(); serviceLocatorBuilder.Register <IWindowViewModel>(window); var navigation = NavigationViewModel.Create(serviceLocatorLazy, routeSolver); serviceLocatorBuilder.Register <INavigator>(navigation); serviceLocatorBuilder.Register(navigation); ApplicationViewModel = new ApplicationViewModel(window, navigation); serviceLocatorBuilder.Register <IMessageBox>(ApplicationViewModel); serviceLocatorBuilder.Register <INotificationSender>(ApplicationViewModel); var serviceLocator = serviceLocatorLazy.Value; _LifeCycleEventsRegistror = RegisterLifeCycleEvents(serviceLocator); var reactiveTraderApi = serviceLocator.GetInstance <IReactiveTrader>(); var username = serviceLocator.GetInstance <IUserProvider>().Username; reactiveTraderApi.Initialize(username, serviceLocator.GetInstance <IConfigurationProvider>().Servers, serviceLocator.GetInstance <ILoggerFactory>()); }
public BuildingMainPage(WindowViewModel vm, Predio p) { InitializeComponent(); this.vm = vm; this.p = p; Map.Center = p.Location; IntervalTimer = Convert.ToInt32(ConfigurationManager.AppSettings["IntervalTime"]); strImagePath = ConfigurationManager.AppSettings["ImagePath"] + "/Predio_" + p.ID; ImageControls = new[] { myImage, myImage2 }; LoadImages(); timerImageChange = new DispatcherTimer(); timerImageChange.Interval = new TimeSpan(0, 0, IntervalTimer); timerImageChange.Tick += new EventHandler(timerImageChange_Tick); List <Fracao> fractions = Fracao.get_All_Fractions(p.ID); foreach (Fracao fraction in fractions) { Fractions.Add(fraction); if (fraction.CurrentCondomino != null) { ocupacao += 1; } } Eventos = new ObservableCollection <Evento>(Evento.get_Next_Events(p.ID)); showColumnChart(); }
//EXPERIMENT file: LOAD static public AppViewModel loadExperiment(WindowViewModel parentWindow, Dictionary <string, string> appDefinitions) { string fileDoc = null; OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Experiment | *." + XMLConfig.experimentExtension; ofd.InitialDirectory = Path.Combine(Path.GetDirectoryName(Directory.GetCurrentDirectory()), "experiments"); if (ofd.ShowDialog() == DialogResult.OK) { fileDoc = ofd.FileName; } else { return(null); } //open the config file to retrive the app's name before loading it XmlDocument configDocument = new XmlDocument(); configDocument.Load(fileDoc); XmlNode rootNode = configDocument.LastChild; AppViewModel newApp = new AppViewModel(parentWindow, appDefinitions[rootNode.Name], fileDoc); return(newApp); }
private void CreateModel() { var model = new WindowViewModel(); var item1 = new DocContainerModel(new DocumentWellModel() { IsActive = true }); for (int i = 0; i < 5; i++) { item1.Children[0].Children.Add(new TabModel { Header = $"Tab Item {i}", Content = new DocumentControl() }); } var content = new SplitViewModel(); content.Item1 = item1; content.Item2 = new SplitViewModel { Orientation = Orientation.Vertical, Item1 = GenerateToolGroup(Dock.Right), Item2 = GenerateToolGroup(Dock.Right) }; content.Item2Size = new GridLength(WindowViewModel.DefaultDockSize); model.Content = content; Model = model; }
private void btnOpenServer_Click(object sender, RoutedEventArgs e) { if (ListboxServers.SelectedIndex != -1) { selectedserver = (Server)ListboxServers.SelectedItem; serverId = selectedserver.id; // Find the frame. Frame pageFrame = null; DependencyObject currParent = VisualTreeHelper.GetParent(this); while (currParent != null && pageFrame == null) { pageFrame = currParent as Frame; currParent = VisualTreeHelper.GetParent(currParent); } //Change the page of the frame. if (pageFrame.DataContext != null) { WindowViewModel windowViewModel = pageFrame.DataContext as WindowViewModel; windowViewModel.CurrentPage = ApplicationPage.Settings; windowViewModel.ServerId = serverId; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Server ID: " + serverId + "\n"); } } }
/// <summary> /// Changes the current page of the main window. /// </summary> /// <param name="page">Redirect application to this page.</param> protected void ChangePage(ApplicationPage page) { WindowViewModel windowViewModel = ((WindowViewModel)((MainWindow)Application.Current.MainWindow).DataContext); windowViewModel.PreviousPage = windowViewModel.CurrentPage; windowViewModel.CurrentPage = page; }
public EditBuilding(WindowViewModel vm, Predio p) { InitializeComponent(); this.vm = vm; this.p = p; tbNome.Text = p.Nome; tbLatitude.Text = p.Latitude.ToString(); tbLongitude.Text = p.Longitude.ToString(); if (p.Area != -1) { tbArea.Text = p.Area.ToString(); } if (p.Cidade != null) { tbCidade.Text = p.Cidade.ToString(); } if (p.Morada != null) { tbMorada.Text = p.Morada; } if (p.Codigo_Postal != null) { tbCodigo_Postal.Text = p.Codigo_Postal.Split('-')[0]; tbCodigo_Postal2.Text = p.Codigo_Postal.Split('-')[1]; } photos = new ObservableCollection <Photo>(p.getImagesPhotos()); PropertyChanged(this, new PropertyChangedEventArgs(nameof(photos))); }
public MainWindow() { InitializeComponent(); windowViewModel = new WindowViewModel(this); DataContext = windowViewModel; windowViewModel.GoToLoginPage(); }
public SettingsWindow(AsyncPackage package) { WindowViewModel = new WindowViewModel(new NotificationHandler(package)); DataContext = WindowViewModel; InitializeComponent(); InteropHelper = new WindowInteropHelper(this); }
private static int ResetHistoryCyclePointer(WindowViewModel windowvm) { int previousLinePointer = windowvm.CycleHistoryLinePointer; windowvm.CycleHistoryLinePointer = 0; return(previousLinePointer); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); MainWindow = WindowViewModel.CreateWindow <MainWindow>(); MainWindow.Show(); }
//public PageViewModel MainViewModel; //public User thisUser; public MainWindow() { InitializeComponent(); WindowViewModel vm = new WindowViewModel(); DataContext = vm; //Instantiate Viewmodel //MainViewModel = viewModel; //DataContext = MainViewModel; //thisUser = user; //using(var context = new DbmejiaEntities()) //{ // try // { // context.Database.Connection.Open(); // context.Database.Connection.Close(); // } // catch(SqlException) // { // MessageBox.Show("Verifica tus servicios de base de datos"); // this.Close(); // } //} ////Pagina Inicial ////var PaginaEstadisticas = new Views.PageEstadisticas(); //ContentMain.Navigate(new Pages.HomePage()); }