public ContactScreen() { InitializeComponent(); _mainVM = MainVM.Instance; this.DataContext = _mainVM; ChatResult.ContactChangeEvent += ChatResult_contactChangeEvent; //Open chat when Send Message menu item clicked MainWindow.OpenChatEvent += MenuItem_OpenChatEvent; //Disconnect menu item clicked MainWindow.ConnectionEvent += Menu_DisonnectionEvent; //Message list from contact recieved ChatResult.MessagesListRecievedEvent += ChatResult_MessagesListRecievedEvent; //Game request recieved ChatResult.GameRequestedEvent += ChatResult_GameRequestedEvent; //Game response recieved ChatResult.GameRespondEvent += ChatResult_GameRespondEvent;; //Play Backgammon menu item clicked MainWindow.PlayEvent += MenuItem_PlayEvent; //Game Ended recieved ChatResult.GameEndedEvent += ChatResult_GameEndedEvent; _openChatsList = new Dictionary <string, ChatWindow>(); _waitingForResponse = new Dictionary <string, Guid?>(); }
public MainPage() { InitializeComponent(); viewModel = new MainVM(); BindingContext = viewModel; }
protected override /*async*/ void OnStartup(StartupEventArgs e) { Bpr.BeepShort(); Current.DispatcherUnhandledException += UnhandledExceptionHndlr.OnCurrentDispatcherUnhandledException; Tracer.SetupTracingOptions("TypingWpf", AppTraceLevel_Warnng); base.OnStartup(e); #if _DEBUG await sw(); //MainVM.UpdateDoneTodo("Zoe", null); //DeadlockDemo.NoDeadlock(); //DeadlockDemo.Causes_A_Deadlock(); //Trace.WriteLine(LessonHelper.GetLesson(LessonType.Combinations, 1)); //LessonHelper.CodeGen(); //new xChartPoc().ShowDialog(); //IsoHelper.ListIsoFolders(); return; //new Vws.DbExplorer2().ShowDialog(); // new JsonToSqlMigrator().ShowDialog(); #else var mw = new MainWindow(); var vm = MainVM.Create(mw.cChart1); if (vm != null) { BindableBaseViewModel.ShowModalMvvmAsync(vm, mw); } else #endif Shutdown(); }
public WeatherForecastController() { var host = ConfigurationManager.AppSettings["host"]; if (!int.TryParse(ConfigurationManager.AppSettings["port"], out int port) || string.IsNullOrEmpty(host)) { return; } _apiClient = Ioc.Resolve <IApiClient>(); _apiClient.Open(host, port); MainVM = new MainVM(_apiClient); DataContext = MainVM; var wc = Ioc.Resolve <IVisual>().GetVisualComponent(); _wcInterface = wc; if (wc.IsWpfCompatible) { _weatherControl = (UIElement)wc.Control; } else { _weatherControl = new WindowsFormsHost() { Child = (System.Windows.Forms.Control)wc.Control }; } Body.Content = _weatherControl; }
async static Task <string> tr(string str, string srcCode, string dstCode) { var src = srcCode?.Split('_')[0]; var dst = dstCode?.Split('_'); return(await MainVM.TranslateText(str, src, dst[0], dst.Length > 1 && dst[1].StartsWith("lat", StringComparison.InvariantCultureIgnoreCase))); }
public void ThenIShouldSeeARootFolderNamed(string folderName) { MainVM mainVM = (MainVM)ScenarioContext.Current["MainVM"]; string expectedOrganisationName = (string)ScenarioContext.Current["OrganisationName"]; Assert.AreEqual(expectedOrganisationName, mainVM.ChildVM.Folders[0].Name); }
public Login(MainVM main) { _main = main; vmUserCode = ""; vmUserCodeDisplay = ""; // _main.SwitchToView(Model.SectionType.Report); }
private void ShowTable(object sender, RoutedEventArgs e) { double _a = Math.Abs(A); double left_border = -_a; double right_border = _a; if (db_left_border.Value.HasValue && db_right_border.Value.HasValue) { left_border = db_left_border.Value.Value; right_border = db_right_border.Value.Value; if (left_border < -_a) { left_border = -_a; } if (right_border > _a) { right_border = _a; } } List <TableValue> table = new List <TableValue>(); double step = db_step.Value.Value; for (double x = left_border; x <= right_border; x += step) { TableValue row = new TableValue(); row.X = Math.Round(x, 2); row.Y = Math.Round(MainVM.GetFunc(x, _a), 2); table.Add(row); } TableValueWindow Table = new TableValueWindow(table); Table.Show(); }
protected override void OnStartup(StartupEventArgs e) { mainvm = new MainVM(); actorSystem = ActorSystem.Create("sys"); appActor = actorSystem.ActorOf(Props.Create(() => new AppActor(mainvm)), "app"); base.OnStartup(e); }
private void WriteSettingsValue(object sender, RoutedEventArgs e) { string file_path = string.Empty; string file_name = string.Empty; using (SaveFileDialog saveFileDialog1 = new SaveFileDialog()) { saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; saveFileDialog1.FilterIndex = 1; saveFileDialog1.RestoreDirectory = true; if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (!string.IsNullOrEmpty(file_path = saveFileDialog1.FileName)) { file_name = Path.GetFileName(file_path); if (MainVM.WriteFile(new double[] { db_size.Value.Value, db_left_border.Value.Value, db_right_border.Value.Value, db_step.Value.Value }, file_path)) { MessageBox.Show($"Файл \"{file_name}\" успешно записан", file_name); } else { MessageBox.Show($"Файл \"{file_name}\" не удалось записать", file_name); } } } } }
public SelectLoggedPropertiesWindow(MainVM mainVM) { InitializeComponent(); MainVM = mainVM ?? throw new ArgumentNullException(nameof(mainVM)); TopContainer.DataContext = MainVM.LoggingOptions; }
// GET: Store/Shop public async Task <ActionResult> Index(int?page) { var pageNumber = page ?? 1; var model = new MainVM { ProductContents = await(from p in db.Products orderby p.Id descending select new ProductContentVM { Id = p.Id, ImageUrl = p.ImageUrl, Name = p.Name, Price = p.SellingPrice, IsOnSale = p.IsOnSale, DiscountedPrice = p.DiscountedPrice, DiscountedRate = p.IsOnSale ? p.DiscountedRate : 0, ProductLink = "/store/shop/product-details/" + p.Slug }).ToListAsync(), Categories = db.Categories.ToList() }; var onePageOfProducts = model.ProductContents.ToPagedList(pageNumber, 20); ViewBag.OnePageOfProducts = onePageOfProducts; return(View(model)); }
public MainWindow() { InitializeComponent(); _vm = this.AssertViewModel <MainVM>(); Title = ApplicationStateManager.Title; base.SizeChanged += new SizeChangedEventHandler(this.OnSizeChangedSave); Translations.LanguageChanged += (s, e) => WindowUtils.Translate(this); LoadingBar.Visibility = Visibility.Visible; Topmost = GUISettings.Instance.GUIWindowsAlwaysOnTop; CustomDialogManager.MainWindow = this; SetBurnCalledAction(); SetNoDeviceAction(); _timer.Interval = 1000 * 60 * 2; //2min _timer.Elapsed += CheckConnection; _timer.Start(); if (GUISettings.Instance.MainFormSize != System.Drawing.Size.Empty) { this.Width = GUISettings.Instance.MainFormSize.Width; this.Height = GUISettings.Instance.MainFormSize.Height; } }
public MainWindow() { InitializeComponent(); m = new MainVM(() => this.Close(), null, MyMapView, this); DataContext = m; var dpi = GetDpi(); }
public MainPage() { InitializeComponent(); viewModel = Resources["vm"] as MainVM; viewModel.Messages.CollectionChanged += Messages_CollectionChanged; }
public OperateOrderVM(MainVM parent) : base(parent) { this.View = new OperateOrderView(); this.Header = "並び替え"; this.OpenWinnerCommand = new DelegateCommand(OpenWinner, CanSelectedMedia); this.OpenOtherCommand = new DelegateCommand(OpenOther, CanSelectedMedia); this.OpenAnswer1Command = new DelegateCommand(OpenAnswer1, CanSelectedMedia); this.OpenAnswer2Command = new DelegateCommand(OpenAnswer2, CanSelectedMedia); this.OpenAnswerAllCommand = new DelegateCommand(OpenAnswerAll, CanSelectedMedia); this.ResetCommand = new DelegateCommand(Reset, CanSelectedMedia); this.adapter = new ViewModelsAdapter <TeamOrderVM, TeamData>(CreateTeamSortVM); this.playOtherView = new PlayOtherOrderView() { DataContext = this }; this.playWinnerView = new PlayWinnerOrderView() { DataContext = this }; this.PlayView = this.playWinnerView; }
internal static void Launch(Engine engine, bool isNewVersion) { Screen = new SplashScreen(); context = SynchronizationContext.Current; isLaunching = true; UserInterface.engine = engine; UserInterface.isNewVersion = isNewVersion; engine.ApprovalRequired += GetApproval; engine.Initialized += OnEngineInitialized; mainVM = new MainVM(engine); // Initial screen if (!ApplicationInfo.IsLicensed) { // Must sign agreement to continue Screen = new Agreement(); } else { OnLicenseAgreed(); } }
public MediaExplorerUC() { this.InitializeComponent(); _vm = MainVM.Instance; DataContext = _vm; }
//UserContext db; public MainWindow() { InitializeComponent(); DataContext = new MainVM(this); DBConnection.DBConnection.getInstance(); }
private void AboutProgram() { var result = MessageBox.Show(MainVM.AboutMessage() + Environment.NewLine + "Показывать это окно в дальнейшем?", "О программе", MessageBoxButtons.YesNo, MessageBoxIcon.Information); Properties.Settings.Default.AboutShow = result == System.Windows.Forms.DialogResult.Yes; Properties.Settings.Default.Save(); }
public MainWindow() { MainVM _vm = new MainVM(); this.DataContext = _vm; InitializeComponent(); }
public AudioPlayerUC() { this.InitializeComponent(); _vm = MainVM.Instance; DataContext = _vm; }
public MainWindow() { InitializeComponent(); new ConfigWindow().ShowDialog(); var vm = new MainVM(); DataContext = vm; vm.OutputUpdate += (s, a) => { console.Dispatcher.Invoke(() => { console.Text += "\n" + (string)s; }); }; vm.PropertyChanged += delegate { listView.Dispatcher.Invoke(() => { listView.ItemsSource = vm.ResultFiles; }); }; }
private void MyInitializeComponent() { DataContext = new MainVM(); ((INotifyCollectionChanged)lb_array.Items).CollectionChanged += (s, e) => { if (e.Action == NotifyCollectionChangedAction.Add) { nb_add_value.Clear(); } }; b_Add.Command = _baseArrayWorkerVM.AddCommand; b_Remove.Command = _baseArrayWorkerVM.RemoveCommand; lb_array.ItemsSource = _baseArrayWorkerVM.MVValues; lb_array_even.ItemsSource = _baseArrayWorkerVM.MVEvenValues; lb_array_odd.ItemsSource = _baseArrayWorkerVM.MVOddValues; if (ParamVM.ShowInfo) { g_аbout_program.Visibility = Visibility.Visible; g_program.Visibility = Visibility.Collapsed; } else { g_аbout_program.Visibility = Visibility.Collapsed; g_program.Visibility = Visibility.Visible; } System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer(); timer.Tick += new EventHandler(ButtonAnimation); timer.Interval = new TimeSpan(0, 0, 3); timer.Start(); }
public MainPage() { InitializeComponent(); NavigationPage.SetHasNavigationBar(this, false); viewModel = new MainVM(); BindingContext = viewModel; }
/// <summary> /// Initializes a new instance of the <see cref="MainView"/> class. /// </summary> /// <param name="loggedUser">User that is logged.</param> public MainView(User loggedUser) { InitializeComponent(); currentUser = loggedUser; DataContext = new MainVM(loggedUser); viewmodel = (MainVM)DataContext; }
public async Task <IActionResult> Index() { ApplicationUser applicationUser = await _userManager.GetUserAsync(HttpContext.User); List <string> roles = (List <string>) await _userManager.GetRolesAsync(applicationUser); UserProfile currentUser = await _repository.GetUserByIdAsync(new Guid(applicationUser.Id)); if (currentUser == null) { return(RedirectToAction("MakeNewProfile")); } List <Picture> pictures = await _repository.GetAllPicturesAsync(); ProfilePictureVM profilePictureVM = new ProfilePictureVM(currentUser.ProfilePicture); UserProfileVM userProfileVM = new UserProfileVM(currentUser); List <PictureVM> picturesToPresent = new List <PictureVM>(); foreach (var item in pictures) { picturesToPresent.Add(new PictureVM(item)); } // get all users List <UserProfileVM> userProfilesVM = await GetAllUsersVMAsync(currentUser.Id); //get following users List <UserProfileVM> followingUserProfilesVM = GetFollowingUsersVM(currentUser); MainVM indexViewModel = new MainVM("Newest Pictures", userProfileVM, picturesToPresent, userProfilesVM, followingUserProfilesVM); return(View("Index", indexViewModel)); }
public async Task <IActionResult> IndexRealtime_Codebehind(string UserType, LanguagePreference languagePreference) { if (HttpContext.Session.GetString("ControlNumber") == null) { return(RedirectToAction("Login", "ShareholderVoting")); } var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json"); IConfigurationRoot Configuration = builder.Build(); int refreshBlockchainDataInSeconds = Convert.ToInt32(Configuration["refreshBlockchainDataInSeconds"]); string contractNumber = _blockchainContext.ContractAddress; List <ContractBlockchainAddresses> contractBlockchainAddresses = Context.contractBlockchainAddresses.AsQueryable().ToList(); MainVM viewModel = new MainVM(); if (contractBlockchainAddresses.Any(bc => bc.contractNumber == contractNumber && Convert.ToDateTime(bc.lastModifiedDatetime).AddSeconds(refreshBlockchainDataInSeconds) > DateTime.Now)) { viewModel.refreshDataFromBlockchain = "false"; } else { viewModel.refreshDataFromBlockchain = "true"; } viewModel.contractNumber = contractNumber; ViewBag.UserType = UserType; return(await Task.Run <IActionResult>(() => { return View(viewModel); })); }
public Views.Game.Game LoadGame(MainVM vm, string fileName) { var ret = new Views.Game.Game(vm); ret.UpdateWithLogs(JsonConvert.DeserializeObject <GameEvent[]>(File.ReadAllText(fileName))); return(ret); }
public MainWindow() { InitializeComponent(); MainVM main = new MainVM(); this.DataContext = main; }
public void MainVM_Creates_ChildTreeview_withSingleNode() { var expectedFolders = new List<Folder> { new Folder { Name = "TestFolder", Id = 1, ParentId = -1 } }; var mockService = new Mock<IFolderService>(); mockService.Setup(f => f.GetFolders()).Returns(expectedFolders); MainVM mainVM= new MainVM(mockService.Object, "test"); Assert.AreEqual(mainVM.ChildVM.Folders.Count, expectedFolders.Count); }
public void FirstTimeTest() { // Arrange var resources = new TestStringResources(); var keyValueStore = new TestKeyValueStore(); // Act var underTest = new MainVM(resources, keyValueStore); // Assert Assert.AreEqual(resources.Welcome, underTest.Message); Assert.IsFalse(keyValueStore.GetValue("FirstTime", true)); }
protected override void OnActivated(EventArgs e) { base.OnActivated(e); if (MainWindow.DataContext == null) { var mainVM = new MainVM(); var mainBook = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), @"Settings\Core.savage-setting"); mainVM.CharacterGenerator.LoadSetting(new FileInfo(mainBook)); mainVM.CharacterGenerator.SelectedArchetype = mainVM.CharacterGenerator.Archetypes[0]; mainVM.CharacterGenerator.SelectedRace = mainVM.CharacterGenerator.Races[0]; mainVM.CharacterGenerator.SelectedRank = mainVM.CharacterGenerator.Ranks[0]; MainWindow.DataContext = mainVM; } }
public DatabaseExpItemVM(AccountExpItemVM parentAccount, DatabaseModel model, MainVM main) : base(main) { _model = model; this.Children.Add(new DummyExpItemVM(main)); this.ContextMenuItems.Add(new MenuItemVM() { Caption = "Refresh", Command = new LambdaCommand(async (o) => { await refresh(); }) }); this.ContextMenuItems.Add(new MenuItemVM() { Caption = "Create collection", Command = new LambdaCommand(async (o) => { var dlg = new NameSelector("New collection name"); if (dlg.ShowDialog() == true && dlg.Value.IsNotEmpty()) { var created = await _model.CreateCollection(dlg.Value); this.Children.Insert(0, new CollectionExpItemVM(this, created, main)); } }) }); this.ContextMenuItems.Add(new MenuItemVM() { Caption = "Delete database", Command = new LambdaCommand(async (o) => { MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure?", "Delete Confirmation", System.Windows.MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { await this._model.DeleteDabaseFormAccount(); parentAccount.Children.Remove(this); } }) }); }
public CollectionExpItemVM(DatabaseExpItemVM parentDatabaseExp, CollectionModel model, MainVM main, CollectionViewModel sourceView = null, CollectionExpItemVM viewSourceCollection = null) : base(main) { _parentDbExpItem = parentDatabaseExp; _model = model; if (sourceView != null) { this.View = sourceView; IsView = true; ViewSourceCollection = viewSourceCollection; } else { this.View = new CollectionViewModel(); IsView = false; } this.ContextMenuItems.Add(new MenuItemVM() { Caption = "Refresh", Command = new LambdaCommand((o) => _wrkspc?.Refresh()) }); if (sourceView == null) { var savedCollection = Config.Instance.GetCollection(model.AccountEndpoint, model.DatabaseName, model.Name); if (savedCollection != null) { this.IsExpanded = savedCollection.IsExpanded; if (savedCollection.Views != null) { foreach (var view in savedCollection.Views) { this.Children.Add(new CollectionExpItemVM(parentDatabaseExp, model, main, view, this)); } } } this.ContextMenuItems.Add(new MenuItemVM() { Caption = "Delete collection", Command = new LambdaCommand(async (o) => { MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure?", "Delete Confirmation", System.Windows.MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { await this._model.DeleteCollectionFromDatabase(); parentDatabaseExp.Children.Remove(this); } }) }); } else { this.ContextMenuItems.Add(new MenuItemVM() { Caption = "Delete view", Command = new LambdaCommand((o) => { MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure?", "Delete Confirmation", System.Windows.MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { this.ViewSourceCollection.Children.Remove(this); this.ViewSourceCollection.IsSelected = true; Config.Instance.RemoveCollectionView(_model.AccountEndpoint, _model.DatabaseName, this.View); } }) }); } }
public ViewRateApp() { InitializeComponent(); DataContext = new MainVM(); }
public DummyExpItemVM(MainVM main) : base(main) { }
public AccountExpItemVM(AccountModel model, MainVM main) : base(main) { IsBroken = false; _model = model; this.Children.Add(new DummyExpItemVM(main)); this.ContextMenuItems.Add(new MenuItemVM() { Caption = "Refresh", Command = new LambdaCommand(async (o) => { await this.LoadDatabases(); }) }); this.ContextMenuItems.Add(new MenuItemVM() { Caption = "Create database", Command = new LambdaCommand(async (o) => { if(IsBroken) { MessageBox.Show("Can't create database on a broken connect, check error message, try to reenter credentials."); return; } var dlg = new NameSelector("New database name"); if (dlg.ShowDialog() == true && dlg.Value.IsNotEmpty()) { var created = await _model.CreateDatabase(dlg.Value); this.Children.Insert(0,new DatabaseExpItemVM(this, created, this.Main)); } }) }); this.ContextMenuItems.Add(new MenuItemVM() { Caption = "Change access data", Command = new LambdaCommand((o) => { var oldEndpoint = _model.Endpoint; DocDbAccountCredentialsDlg.ShowDialog(_model.Credentials, async (creds) => { await performWithIsBrokenTest(async () => { this.Children.Clear(); await _model.RefreshCredentials(); foreach (var db in this._model.Databases) { this.Children.Add(new DatabaseExpItemVM(this, db, this.Main)); } Config.Instance.ChangeAccountCredentials(oldEndpoint, _model.Credentials); }); }); }) }); this.ContextMenuItems.Add(new MenuItemVM() { Caption = "Remove", Command = new LambdaCommand((o) => { MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure?", "Removal Confirmation", System.Windows.MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { main.Explorer.RootItems.Remove(this); Config.Instance.RemoveAccount(_model.Endpoint); } }) }); }
public MainPage() { InitializeComponent(); DataContext = new MainVM(new StringResources(), new LocalKeyValueStore()); }
public ExplorerItemBaseVM(MainVM main) { this.Main = main; this.Children = new ObservableCollection<ExplorerItemBaseVM>(); this.ContextMenuItems = new ObservableCollection<MenuItemVM>(); }