private void SaveDraft(object o) { if (saveNeedless) { return; } if (IsDraft) { var doc = o as FlowDocument; if (doc == null) { return; } string bodyHtml = doc.ToHtmlString(); string bodyText = doc.GetText(); MainVm.SaveDraftChanges(new MailBase { ID = MailMessage.ID, Subject = MailMessage.Subject, ToAddresses = MailMessage.ToAddresses, BodyHtml = bodyHtml, BodyText = bodyText, Attachments = MailMessage.Attachments }); saveNeedless = true; } else { DiscardDraft(); } }
/// <inheritdoc/> public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { try { var app = commandData.Application.Application; var revitEvent = new RevitEvent(); var revitService = new RevitService(app, revitEvent); var mainVm = new MainVm(revitService); var renamerWindow = new RenamerWindow() { DataContext = mainVm }; renamerWindow.Show(); } catch (PluginException e) { message = e.Message; if (e.Elements.Count > 0) { foreach (var element in e.Elements) { elements.Insert(element); } } return(Result.Failed); } catch (Exception e) { message = e.Message; return(Result.Failed); } return(Result.Succeeded); }
private void DiscardDraft() { IsDraft = false; if (string.IsNullOrEmpty(MailMessage.ID)) { return; } string folder = DraftFolder.CombinePath(MailMessage.ID); var dirInfo = new DirectoryInfo(folder); if (dirInfo.Exists) { try { dirInfo.Delete(true); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); } } MainVm.RemoveDraft(MailMessage.ID); MailMessage.ID = null; Messenger.Default.Send(new DisplayMessage("Discard draft.", DisplayType.Toast)); Messenger.Default.Send(new NavigationMessage(), Tokens.Draft); }
public MainWindow() { InitializeComponent(); _app = (App)Application.Current; var fileValidator = new FileValidator(); var errorHandler = new ErrorHandlerView(); var librarySelector = new LibrarySelector(fileValidator, errorHandler, Dispatcher, _app.EventAggregator); _vm = new MainVm(new LibraryLocationDialog(), librarySelector, errorHandler, fileValidator, _app.AppSettings, _app.EventAggregator); DataContext = _vm; Instance = this; var positionData = _app.AppSettings.WindowPositions == null ? null : _app.AppSettings.WindowPositions .FirstOrDefault(w => w.WindowId == "MainWindow"); _windowPositionSettings = new WindowPositionSettings(positionData, 0.7); _windowPositionSettings.AttachWindow(this); if (positionData == null) { _windowPositionSettings.PositionData.WindowId = "MainWindow"; if (_app.AppSettings.WindowPositions == null) { _app.AppSettings.WindowPositions = new List <WindowPositionData>(); } _app.AppSettings.WindowPositions.Add(_windowPositionSettings.PositionData); } _app.MainWindow = this; }
private void DoFindVote() { var findVoteVm = GetVm <FindVoteViewModel>(); findVoteVm.SetResults(_questions, _answers); MainVm.ChangeView(EvotoView.FindVote); }
public void MessageHelloAfterClickt() { var result = new MainVm(); result.ClickCommand.Execute(null); Assert.AreEqual("Hello!", result.Message); }
public void DoBack() { MainVm.ChangeView(EvotoView.Results); var resultsVm = GetVm <ResultsViewModel>(); resultsVm.ReInit(); }
private void DoProceed() { var resultsVm = GetVm <ResultsViewModel>(); resultsVm.SelectVote(_blockchain); MainVm.ChangeView(EvotoView.Results); }
public MainWindow() { InitializeComponent(); var vm = new MainVm(); DataContext = vm; }
private void AddAttachment(object o) { //Validate basic info if (null == o) { return; } string[] filesPath = null; var filePath = o as string; if (null == filePath) { filesPath = o as string[]; if (null == filesPath) { return; } } else { filesPath = new string[] { filePath } }; //Validate id generated if (string.IsNullOrEmpty(MailMessage.ID)) { MailMessage.ID = MainVm.CreateId(); } //Ensure cache folder is generated string folder = EnsureDraftCacheFolder(MailMessage.ID); //Attach file string copyTarget = null; foreach (var path in filesPath) { FileInfo info = new FileInfo(path); if (!info.Exists) { return; } try { copyTarget = folder.CombinePath(info.Name); if (File.Exists(copyTarget)) { Messenger.Default.Send(new DisplayMessage("Exist file!", DisplayType.Toast)); } else { info.CopyTo(copyTarget); MailMessage.Attachments.Add(info.Name); } } catch (Exception e) { Messenger.Default.Send(new DisplayMessage(e.Message, DisplayType.Toast)); } } }
private void DoContinue() { MainVm.ChangeView(EvotoView.ResetPassword); if (!string.IsNullOrWhiteSpace(Email)) { var resetVm = ServiceLocator.Current.GetInstance <ResetPasswordViewModel>(); resetVm.SetEmail(Email, false); } }
public MainVmCommandBase(MainVm vm) { Vm = vm; Vm.CurrentBlobChanged += delegate { if (CanExecuteChanged != null) { CanExecuteChanged(this, null); } }; }
private void CreateWindowWithDataContext() { var window = new View.MainWindow(); var vm = new MainVm(); vms.Add(vm); window.DataContext = vm; window.Show(); }
/// <summary> /// Invoked when application execution is being suspended. Application state is saved /// without knowing whether the application will be terminated or resumed with the contents /// of memory still intact. /// </summary> /// <param name="sender">The source of the suspend request.</param> /// <param name="e">Details about the suspend request.</param> private async void OnSuspending(object sender, SuspendingEventArgs e) { var deferral = e.SuspendingOperation.GetDeferral(); await MainVm.Suspend(); await SuspensionManager.SaveAsync(); deferral.Complete(); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var mainVm = new MainVm(); new MainWindow { DataContext = mainVm }.Show(); }
private void DoForgotPassword() { ErrorMessage = ""; if (!string.IsNullOrWhiteSpace(Email)) { var forgotPasswordVM = ServiceLocator.Current.GetInstance <ForgotPasswordViewModel>(); forgotPasswordVM.SetEmail(Email); } MainVm.ChangeView(EvotoView.ForgotPassword); }
public MainWindow() { InitializeComponent(); MainVm mv = new MainVm(); DataContext = mv; mv.Initialize(); // GetCoinsAndCurrencies(); }
public MainWindow() { InitializeComponent(); MainVm = new MainVm { Config = ConfigurationManager.Read() }; DataContext = MainVm; WebsocketServer.Start(MainVm.Config.Port); }
public MainWindow() { jirnalCore_ = new JirnalCore(); mainVm_ = new MainVm(jirnalCore_); DataContext = mainVm_; Loaded += OnLoaded_; InitializeComponent(); MainMenuBar.Close += Close; WindowManager.Singleton.Initialize(jirnalCore_); mainVm_.StatusBar.SetSelectedLayout(); }
public void SetUp() { _eventAggregator = new UnitTestEventAggregator(); _fileValidator = new MockFileValidator(); _testDispatcher = new UnitTestDispatcher(); _locationDialog = new MockLibraryLocationDialog(); _errorHandlerView = new MockErrorHandlerView(); _librarySelector = new MockLibrarySelector(_testDispatcher.Dispatcher, null, _errorHandlerView.MockErrorHandler, _fileValidator, _eventAggregator); _settings = new ImbSettings(); _listener = new EventListener(); _eventAggregator.AddListener(_listener); _vm = new MainVm(_locationDialog, _librarySelector, _errorHandlerView, new MockFileValidator(), _settings, _eventAggregator); }
private void DoVote() { if (!MultiChainVm.Connected) { throw new Exception("Not connected"); } // Get userbar to temporarily disable logout var userBar = GetVm <UserBarViewModel>(); // Reset vote progress VoteProgress = new VoteProgressViewModel(); Ui(() => { userBar.LogoutDisabled = true; Voting = true; ErrorMessage = ""; }); Task.Run(async() => { try { var words = await MultiChainVm.Vote(Questions.ToList(), _currentDetails, VoteProgress.Progress); Ui(() => { Voting = false; VoteProgress = null; userBar.LogoutDisabled = false; var postVoteVm = GetVm <PostVoteViewModel>(); postVoteVm.Voted(_currentDetails, words); MainVm.ChangeView(EvotoView.PostVote); }); } catch (CouldNotVoteException) { Ui(() => { Voting = false; VoteProgress = null; userBar.LogoutDisabled = false; ErrorMessage = "An error occurred while voting. Please try again or contact a system administrator"; }); } }); }
public App() { Current = this; InitializeComponent(); Storage = new Storage(); MainPage = new MainView(); MainVm = (MainVm)MainPage.BindingContext; Init(); }
private void DoProceed() { if (SelectedVote == null) { return; } Loading = true; Task.Run(async() => { var showResults = true; if (SelectedVote.IsCurrent) { // Contact the Registrar to see if we have voted on this vote yet showResults = await _voteClient.HasVoted(SelectedVote.ChainString); } Ui(() => { Loading = false; ErrorMessage = ""; ShowErrorMessage = false; }); if (!showResults) { MainVm.ChangeView(EvotoView.Vote); var voteView = GetVm <VoteViewModel>(); voteView.SelectVote(SelectedVote.GetModel()); } else { if (!SelectedVote.Encrypted) { MainVm.ChangeView(EvotoView.Results); var resultsVm = GetVm <ResultsViewModel>(); resultsVm.SelectVote(SelectedVote.GetModel()); } else { Ui(() => { ErrorMessage = "This vote is encrypted and still active. Results cannot be viewed."; ShowErrorMessage = true; }); } } }); }
private void NewDatabase_OnClick(object sender, RoutedEventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog { Filter = "Library File (*.sqlite)|*.sqlite", InitialDirectory = DbHandler.DefaultDbDir }; if (saveFileDialog.ShowDialog() == true) { File.Create(saveFileDialog.FileName); MainVm.LoadDatabase(saveFileDialog.FileName); } }
private void LoadDatabase_OnClick(object sender, RoutedEventArgs e) { OpenFileDialog openDialog = new OpenFileDialog { Filter = "Library File (*.sqlite)|*.sqlite", Multiselect = false, InitialDirectory = DbHandler.DefaultDbDir, FilterIndex = 1 }; if (openDialog.ShowDialog() == true) { MainVm.LoadDatabase(openDialog.FileName); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var t = Type.GetType("Mono.Runtime"); IsMonoRuntime = (t != null); var session = new CommsSession(); //var session = new FakeCommsSession(); var mainVm = new MainVm(session); Application.Run(new mainForm(mainVm)); }
private void DoResetPassword(object parameter) { ResetPasswordModel resetPasswordModel; if (!IsFormValid(parameter, out resetPasswordModel)) { return; } Loading = true; ErrorMessage = ""; Task.Run(async() => { try { await _userClient.ResetPassword(resetPasswordModel); var userDetails = await _userClient.GetCurrentUserDetails(); MainVm.Login(this, userDetails); Ui(() => { Loading = false; ResetForm(parameter); }); } catch (BadRequestException e) { Ui(() => { ErrorMessage = e.Message; Loading = false; }); } catch (ApiException) { Ui(() => { ErrorMessage = "An Unknown Error Occurred"; Loading = false; }); } }); }
public async Task Configure() { foreach (string?recentDB in Settings.Default.RecentDBs) { if (recentDB != null) { MenuItem recentDBItem = new MenuItem { Header = recentDB }; recentDBItem.Click += (s, e) => MainVm.LoadDatabase(recentDB); FileMenuItem.Items.Add(recentDBItem); } } if (DataContext is MainVM mainVM) { await mainVM.LoadData().ConfigureAwait(false); } }
public ChildCOViewModel( TreeViewViewModel treeParent, CompoundObjectViewModel parentVm, MainViewModel mainVm, TStateProperties <ChildObjectStateProperties> childStateModelObject, bool enabled = true) : base(treeParent, parentVm, mainVm, childStateModelObject.Properties.CompObj) { ChildStateModelObject = childStateModelObject; // Below we need to find the top level behavior. Must get it from the MainViewModel! int i = MainVm.GetEditableCoBehaviourIndexOf(ChildStateModelObject.State); if (i < 0) { i = 0; } SelectedStateIndex = i; }
public IActionResult GetMainPageData(DateTime month) { using (ApplicationDbContext db = new ApplicationDbContext()) { ClaimsPrincipal currentUser = User; var returnData = new MainVm(); if (currentUser.Identity.Name != null) { var currentUserID = currentUser.FindFirst(ClaimTypes.NameIdentifier).Value; returnData.AggregateWeatherPredictions = db.AggregateWeatherPredictions.Where(y => y.Day.Year == month.Year && y.Day.Month == month.Month).ToList(); returnData.WeatherEntries = db.WeatherEntries.Where( y => y.ApplicationUser.Id == currentUserID && y.TargetDay.Year == month.Year && y.TargetDay.Month == month.Month).ToList(); returnData.ActualWeatherEntries = db.ActualWeatherEntries.Where(y => y.Day.Year == month.Year && y.Day.Month == month.Month) .ToList(); returnData.Cities = db.Cities.ToList(); } return(Json(returnData)); } }