public RallyViewModel(INavigationService navigator, SetViewModel setViewModel) : this(navigator) { HomeTeam = setViewModel.MatchViewModel.HomeTeam; AwayTeam = setViewModel.MatchViewModel.AwayTeam; _navigator.OpenModal(this, "VolleyballApp.Views.Rallies.SelectTeamView"); }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { string idString; long setID; if (!NavigationContext.QueryString.TryGetValue("id", out idString)) { MessageBox.Show("Can't group the password for this group because the group ID was not specified."); NavigationService.GoBack(); return; } if (!long.TryParse(idString, out setID)) { MessageBox.Show("Can't submit a password for this group because the group ID is invalid."); NavigationService.GoBack(); return; } set = App.ViewModel.GetSet(setID, false); if (set == null) { MessageBox.Show("Can't submit a password for this group because it is unknown to this application."); NavigationService.GoBack(); } }
public ActionResult CompleteSet([FromForm] SetViewModel setViewModel) { WorkoutSetResult workoutSetResult = new WorkoutSetResult(); workoutSetResult.DateCreated = DateTime.Now; workoutSetResult.Difficulty = (int)setViewModel.Difficulty; workoutSetResult.Notes = setViewModel.Notes; workoutSetResult.RepsCompleted = setViewModel.RepsCompleted; workoutSetResult.Weight = setViewModel.Weight; workoutSetResult.WorkoutSetId = setViewModel.WorkoutSet.WorkoutSetId; workoutSetResult.WorkoutSessionId = setViewModel.WorkoutSessionId; workoutSetResult.Skipped = setViewModel.Skipped; if (workoutSetResult.Skipped) { workoutSetResult.Difficulty = 0; workoutSetResult.RepsCompleted = 0; workoutSetResult.Weight = 0; } _context.WorkoutSetResult.Add(workoutSetResult); _context.SaveChanges(); return(RedirectToAction("StartSet", new { workoutId = setViewModel.WorkoutId, workoutSetId = setViewModel.WorkoutSet.WorkoutSetId, lastSet = setViewModel.IsLastSet, currentExerciseId = setViewModel.Exercise.ExerciseId, workoutSessionId = setViewModel.WorkoutSessionId })); }
public async Task <IActionResult> SetToks(string id) { SetViewModel viewModel = new SetViewModel(); if (User != null) { var item = await _setService.GetSetAsync(id); if (item == null) { viewModel.CurrentSet = new Set() { Name = "Set not found", Description = "Please try a different set id", TokIds = new List <string>() }; } else { viewModel.CurrentSet = item; } } else { return(RedirectToAction("Index")); } return(View(viewModel)); }
public StatisticsViewModel(SetViewModel Set) { this.Set = Set; this.canvasDyn = new Canvas(); this.canvasStat = new Canvas(); int sum = 1; int[] count = new int[5]; var arSet = Set.ToList(); for (int k = 0; k < arSet.Count(); k++) { for (int i = 0; i < arSet[k].Collections.Length; i++) { for (int j = 0; j < arSet[k].Collections[i].cards.Count; j++) { CardInfo info = arSet[k].Collections[i].cards[j].Info; count[i]++; sum++; } } } drawCanvas(this.canvasStat, count, sum); }
public SetViewModel GetSetsNames(string keyWords, int setsCountOnPage, int pageNumber) { Repository <SetEntity> setEntityRepository = new Repository <SetEntity>(); SetViewModel setViewModel = new SetViewModel(); if (keyWords == null || keyWords == String.Empty) { var allSets = setEntityRepository.GetList(); List <SetBriefInfo> sets = allSets.OrderByDescending(set => set.AddingTime).Skip((pageNumber - 1) * setsCountOnPage). Take(setsCountOnPage).Select(set => new SetBriefInfo { setName = set.Name, mainImageName = set.MainImageName }).ToList(); return(new SetViewModel { sets = sets, setsCount = allSets.Count() }); } else { List <string> words = keyWords.Trim().Split(' ').ToList(); var allSets = setEntityRepository.GetList().Where(set => CommonMethods.TagsContainWords(set, words)); List <SetBriefInfo> sets = allSets.OrderByDescending(set => set.AddingTime).Skip((pageNumber - 1) * setsCountOnPage). Take(setsCountOnPage).Select(set => new SetBriefInfo { setName = set.Name, mainImageName = set.MainImageName }).ToList(); return(new SetViewModel { sets = sets, setsCount = allSets.Count() }); } }
public EditCardViewModel(SetViewModel set) { this.set = set; this.QuestionVisibility = "Visible"; this.AnswerVisibility = "Hidden"; checkEditedCard = ""; this.newKeyword = "Neues Wort"; selectedStack = ""; //stacks this.stacks = new ObservableCollection <String>(); this.stacks.Add("Erster Stapel"); this.stacks.Add("Zweiter Stapel"); this.stacks.Add("Dritter Stapel"); this.stacks.Add("Vierter Stapel"); this.stacks.Add("Fünfter Stapel"); //relayCommand editedCardCommand = new RelayCommand(this.editedCard, this.ReturnTrue); addQuestionImgCommand = new RelayCommand(this.addQuestionImg, this.ReturnTrue); addAnswerImgCommand = new RelayCommand(this.addAnswerImg, this.ReturnTrue); addNewKeywordCommand = new RelayCommand(this.addNewKeyword, this.ReturnTrue); removeKeywordCommand = new RelayCommand(this.removeKeyword, this.ReturnTrue); moveCardCommand = new RelayCommand(this.moveCard, this.ReturnTrue); flipCardCommand = new RelayCommand(this.flipCard, this.ReturnTrue); }
public ActionResult ValidateTrayNO(SetViewModel model) { //tStore 表返回 门店编码 和名称 集货道口编码 GetLoginInfo(); if (Login_Info == null) { return(Content("<script>location.href='/Home'</script>")); } service = new SetService(Login_Info.User_ID, Login_Info.User_Name, Login_Info.Token); try { service.SetParameter("TrayNO", model.TrayNO); service.ExecuteBusinessCheck("RF_Set", "TrayNO"); DataTable dt = service.QueryStore(); if (dt == null || dt.Rows.Count <= 0) { return(Content("出库箱异常,请检查!")); } else { return(Content(JsonHelper.ToJson(dt))); } //return Content(""); } catch (Exception ex) { Loger.Error(ex); return(Content(ex.Message)); } }
public Set CreateSet(SetViewModel vm) { return(new Set { Exercise = _context.Set <Exercise>().Find(vm.ExerciseId), Routine = _context.Set <Routine>().Find(vm.RoutineId) }); }
public InsertCSVView(SetViewModel v) { InitializeComponent(); vm = v; DataContext = vm; // isValidPath = false; // isFirstChange = true; }
public CreateCategoryViewModel(SetViewModel set) { this.set = set; Category = new CategoryViewModel(); this.categoryName = "Kategorienname eingeben"; //relayCommand createCategoryCommand = new RelayCommand(this.CreateCategory, this.ReturnTrue); }
public SetPage(SetViewModel v, Window w) { vm = v; // hostWindow = w; DataContext = vm; isValidPath = false; InitializeComponent(); }
public SetView(SetViewModel s) { InitializeComponent(); vm = s; DataContext = vm; isValidPath = false; isFirstChange = true; }
// constructor public SetView() { InitializeComponent(); vm = new SetViewModel(new SetModel()); DataContext = vm; isValidPath = false; isFirstChange = true; }
public IActionResult Index(SetViewModel model) { try { var setCode = model.Set.code; var cards = new List <Card>(); if (setCode == "KLD" || setCode == "kld") { using (StreamReader r = System.IO.File.OpenText(@"wwwroot/js/KLD.json")) { string json = r.ReadToEnd(); var cardDTO = JsonConvert.DeserializeObject <CardDTO>(json); cards = cardDTO.Cards; } } else { cards = MTGAPI.GetCardsBySetCode(setCode); } var rarityFilter = model.RarityFilter; var colorFilter = model.ColorFilter; var rarityPredicate = GetRarityFilter(rarityFilter); var colorPredicate = GetColorFilter(colorFilter); cards = cards .Where(c => !c.type.Contains("Basic Land")) .Where(rarityPredicate) .Where(colorPredicate) .OrderBy(c => c.number, new CardComparer()) .ToList(); var userGrades = new CardListViewModel(); foreach (var card in cards) { var cvm = new CardViewModel() { Card = card, Grade = new Grade() { CardName = card.name, MultiverseID = card.multiverseid ?? -1, Value = GradeEnum.None } }; userGrades.CardViewModels.Add(cvm); } return(PartialView("EditorTemplates/CardListViewModel", userGrades)); } catch (Exception ex) { return(RedirectToAction("Index", model.Set.code)); } }
private SetViewModel CreateSetViewModelForInvisalign(string entityId) { var setViewModel = new SetViewModel(); setViewModel.Pwid = entityId; setViewModel.Name = "Invisalign-Auto"; setViewModel.ModifiedBy = "Automator"; setViewModel.MediaType = PaidPremiumAdmin.Model.Enums.MediaTypeEnum.Badges; return(setViewModel); }
private SetViewModel MapSet(Set model) { var viewModel = new SetViewModel { Id = model.Id, Repetitions = Convert.ToString(model.Repetitions), Weight = String.Format("{0:0.##}", Math.Round(model.Weight, 2)) }; return(viewModel); }
SetViewModel ConvertSetVM(Set set) { SetViewModel setViewModel = new SetViewModel { Weight = set.Weight, SetID = set.SetID, SetOrder = set.SetOrder }; return(setViewModel); }
public ViewCategoryViewModel(SetViewModel setViewModel) { this.setViewModel = setViewModel; OpenCreateCardWindowCommand = new RelayCommand(() => OpenWindow(new OpenCreateCardWindow())); OpenEditCardWindowCommand = new RelayCommand(() => OpenOpenEditCardWindowFunction(new OpenEditCardWindow())); RemoveCardCommand = new RelayCommand(this.RemoveCardFunction, this.getBoolean); this.ComboboxItemslist = new String[2]; this.ComboboxItemslist[0] = "Name"; this.ComboboxItemslist[1] = "Datum"; }
private void fillInSongsMetaData(SetViewModel model) { var settings = model.Settings; foreach (var song in model.Set.songList) { song.SongMetaDataLayoutTop = completeTemplate(song, settings.SongMetaDataLayoutTop); song.SongMetaDataLayoutMiddle = completeTemplate(song, settings.SongMetaDataLayoutMiddle); song.SongMetaDataLayoutBottom = completeTemplate(song, settings.SongMetaDataLayoutBottom); } }
private Set MapSetViewModel(SetViewModel model) { var set = new Set { Id = model.Id, Repetitions = Convert.ToInt32(model.Repetitions), Weight = Convert.ToDouble(model.Weight) }; return(set); }
public ViewMarkedCardsViewModel(SetViewModel set) { this.Info = ""; this.UiVisable = "Hidden"; this.Set = set; this.markedCards = new ObservableCollection <CardViewModel>(); this.CurrentCardIndex = 0; this.nextCard = new RelayCommand(this.GetNextCard, this.ReturnTrue); this.prevCard = new RelayCommand(this.GetPrevCard, this.ReturnTrue); this.remove = new RelayCommand(this.RemoveMarker, this.ReturnTrue); }
private SetViewModel ConvertSetDTO(SetDTO setDTO) { SetViewModel setViewModel = new SetViewModel { RoundID = setDTO.RoundID, SetID = setDTO.SetID, SetOrder = setDTO.SetOrder, Weight = setDTO.Weight }; return(setViewModel); }
public IActionResult Put([FromBody] SetViewModel body) { try { _repo.Update(body); return(Ok(new { message = "Set Updated!", hypermedia = new HyperMediaResponse <Set>(body.Id) })); } catch (Exception e) { return(BadRequest(new { e.Message })); } }
private void Application_Startup(object sender, StartupEventArgs e) { //Program.OperateDLL("C:/Users/NicoleS/source/repos/FlightSimulator/plugins/CircularDetect.dll"); ISetModel setModel = new SetModel(); SetViewModel setVM = new SetViewModel(setModel); IFlightSimulatorModel simModel = new FlightSimulatorModel(setModel); FlightSimulatorViewModel flightSimVM = new FlightSimulatorViewModel(simModel); // does main window run simultanasle? MainWindow window = new MainWindow(setVM, flightSimVM); window.ShowDialog(); }
public LearnModeViewModel(SetViewModel set) { this.Set = set; submitAnswerCommand = new RelayCommand(this.SubmitAnswer, this.ReturnTrue); nextCardCommand = new RelayCommand(this.NextCard, this.ReturnTrue); markCardCommand = new RelayCommand(this.MarkCard, this.ReturnTrue); requestHelpCommand = new RelayCommand(this.RequestHelp, this.ReturnTrue); startLearningCommand = new RelayCommand(this.StartLearning, this.ReturnTrue); stopLearningCommand = new RelayCommand(this.StopLearning, this.ReturnTrue); this.FinishedCards = new ObservableCollection <CardViewModel>(); Console.WriteLine("tes2wt"); }
public async Task Save() { Directory.CreateDirectory("Data"); await SetViewModel.Save(); await PokemonsViewModel.Save(); await energyCardsViewModel.Save(); await trainerCardsViewModel.Save(); await formatViewModel.Save(); }
/// <summary> /// Creates a new deck (a streamloots "set") with the specified name, and returns the setId for that deck. /// </summary> /// <param name="deckName">The name of the deck to create.</param> /// <returns>The setId of the new deck (streamloots "set")</returns> async Task <string> AddDeck(string deckName) { CreateSetViewModel setData = new CreateSetViewModel(); setData.name = deckName; setData.slug = STR_DragonHumpersSlug; setData.craftableCards = true; setData.@default = false; setData.imageUrl = "https://static.streamloots.com/b355d1ef-d931-4c16-a48f-8bed0076401b/collections/collection_icon_001.png"; SetViewModel setCardViewModel = await CreateSet(setData); return(setCardViewModel._id); }
public ActionResult Create(SetViewModel set, HttpPostedFileBase[] files) { //Find logged in user User user = db.Users.Single(s => s.email.Trim().ToLower() == System.Web.HttpContext.Current.User.Identity.Name.Trim().ToLower()); int userID = user.id; if (ModelState.IsValid) { SquaresEntities db = new SquaresEntities(); List <string> pieces = new List <string>(); var squareSet = new Set { name = set.name, userId = userID, description = set.description, creationDate = DateTime.Now, //likes = , //sizeData = , combinationData = "666", }; //Create folders for set string relativePath = "/Images/" + userID + "/" + set.name; string path = Server.MapPath(relativePath); Directory.CreateDirectory(path); //Lopp through pieces, save, and save path foreach (HttpPostedFileBase file in files) { if (file != null) { string p = string.Empty; p = Server.MapPath(relativePath + "/"); // make a new path to save images pieces.Add(relativePath + "/" + file.FileName); // the path in database file.SaveAs(p + file.FileName); } } db.Sets.Add(squareSet); db.SaveChanges(); int setID = squareSet.id; CreateSet(setID, pieces); return(RedirectToAction("Details", new { id = squareSet.id })); } //redirect return(View(set)); }
public string GenerateHtml(bool enableAutoRefresh = false) { SetViewModel model = new SetViewModel() { Settings = _settings, Set = _set, EnableAutoRefresh = enableAutoRefresh, Title = Title }; var result = Engine.Razor.RunCompile(HtmlResources.BaseSongHtml, "BaseSongHtml", typeof(SetViewModel), model); return(result); }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { string idString; long setID; if (!NavigationContext.QueryString.TryGetValue("id", out idString)) { MessageBox.Show("Can't group the password for this group because the group ID was not specified."); NavigationService.GoBack(); return; } if (!long.TryParse(idString, out setID)) { MessageBox.Show("Can't submit a password for this group because the group ID is invalid."); NavigationService.GoBack(); return; } set = App.ViewModel.GetSet(setID, false); if (set == null) { MessageBox.Show("Can't submit a password for this group because it is unknown to this application."); NavigationService.GoBack(); } }
public static string GetExcelDocumentSet(SetViewModel obj, string filePath, int setType) { Excel.Application ExcelApp; Excel.Worksheet ExcelSheet; Excel.Workbook ExcelWorkbook; Excel.Workbooks ExcelWorkbooks; Excel.Range ExcelRange; int rowsCount; int columnsCount; dynamic data; ExcelApp = CreateExcelObj(); ExcelWorkbooks = ExcelApp.Workbooks; ExcelApp.ScreenUpdating = false; ExcelApp.DisplayAlerts = false; ExcelWorkbook = ExcelWorkbooks.Add(); try { if (String.IsNullOrEmpty(filePath)) { filePath = Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)).FullName; //if (Environment.OSVersion.Version.Major >= 6) //{ // filePath = Directory.GetParent(filePath).FullName; //} } filename = obj.Set.First().Project + " - Сет " + obj.Set.First().Set + " - " + obj.Set.First().TestMethod + ".xlsx"; switch (setType) { case 1: foreach (var itemSet in obj.Set) { ExcelSheet = ExcelWorkbook.Sheets.Add(); rowsCount = itemSet.MOList.Count + 8 + itemSet.ControlMOList.Count + 1; columnsCount = itemSet.MICList.Count + 5; ExcelRange = ExcelSheet.Range[ExcelSheet.Cells[1, 1], ExcelSheet.Cells[rowsCount, columnsCount]]; if ( itemSet.AB.Length > 30) { ExcelSheet.Name = itemSet.AB.Substring(0, 30).Replace("/","|").Replace("\\","|"); } else { ExcelSheet.Name = itemSet.AB.Replace("/", "|").Replace("\\", "|"); } data = PrepareListForSet1(itemSet); ExcelRange.Value = data; FormatSheetForSet1(ExcelSheet, itemSet); Marshal.ReleaseComObject(ExcelRange); Marshal.ReleaseComObject(ExcelSheet); } break; case 2: ExcelSheet = ExcelWorkbook.Sheets.Add(); rowsCount = obj.Set.First().MOList.Count + obj.Set.First().ControlMOList.Count + 3; columnsCount = obj.Set.Count + 3; ExcelRange = ExcelSheet.Range[ExcelSheet.Cells[1, 1], ExcelSheet.Cells[rowsCount, columnsCount]]; ExcelSheet.Name = obj.Set.First().Project + " - Сет № " + obj.Set.First().Set; data = PrepareListForSet2(obj); ExcelRange.Value = data; FormatSheetForSet2(ExcelSheet, obj); Marshal.ReleaseComObject(ExcelRange); Marshal.ReleaseComObject(ExcelSheet); break; default: break; } ExcelWorkbook.SaveAs(); ExcelWorkbook.SaveAs(filePath + "\\" + filename, Excel.XlFileFormat.xlWorkbookDefault, Type.Missing, Type.Missing, false, false, Excel.XlSaveAsAccessMode.xlNoChange, Excel.XlSaveConflictResolution.xlLocalSessionChanges, Type.Missing, Type.Missing); //while (Marshal.ReleaseComObject(ExcelWorkbook) > 0) //{ } //while (Marshal.ReleaseComObject(ExcelWorkbooks) > 0) //{ } //ExcelApp.Quit(); //while (Marshal.ReleaseComObject(ExcelApp) > 0) //{ } return filePath + "\\" + filename; } catch (Exception ex) { throw ex; } finally { while (Marshal.ReleaseComObject(ExcelWorkbook) > 0) { } while (Marshal.ReleaseComObject(ExcelWorkbooks) > 0) { } ExcelApp.Quit(); while (Marshal.ReleaseComObject(ExcelApp) > 0) { } GC.Collect(); } }
private Set MapSetViewModel(SetViewModel model) { var set = new Set { Id = model.Id, Repetitions = Convert.ToInt32(model.Repetitions), Weight = Convert.ToDouble(model.Weight) }; return set; }
private SetViewModel MapSet(Set model) { var viewModel = new SetViewModel { Id = model.Id, Repetitions = Convert.ToString(model.Repetitions), Weight = String.Format("{0:0.##}", Math.Round(model.Weight, 2)) }; return viewModel; }
private static void FormatSheetForSet2(Excel.Worksheet sheet, SetViewModel obj) { // formatting All sheet sheet.PageSetup.PrintGridlines = false; sheet.PageSetup.Orientation = Excel.XlPageOrientation.xlLandscape; sheet.PageSetup.PaperSize = Excel.XlPaperSize.xlPaperA4; sheet.PageSetup.RightFooter = "Дата: &DD Стр &PP из &NN"; sheet.PageSetup.RightHeader = "Исследование " + obj.Set.First().Project + ", сет № " + obj.Set.First().Set + " - " + obj.Set.First().TestMethod + " - " + obj.Set.First().AB; sheet.PageSetup.Zoom = false; sheet.PageSetup.LeftHeader = "НИИ Антимикробной химиотерапии"; sheet.PageSetup.TopMargin = 50; sheet.PageSetup.BottomMargin = 50; sheet.PageSetup.HeaderMargin = 20; sheet.PageSetup.FooterMargin = 20; sheet.PageSetup.RightMargin = 10; sheet.PageSetup.LeftMargin = 50; sheet.PageSetup.Order = Excel.XlOrder.xlOverThenDown; // Formatting Set Number sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, 3]].Merge(); FormatHeaderText1(sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, 3]]); // Formatting Footer cell sheet.Range[sheet.Cells[3 + obj.Set.First().MOList.Count + obj.Set.First().ControlMOList.Count, 1], sheet.Cells[3 + obj.Set.First().MOList.Count + obj.Set.First().ControlMOList.Count, 3]].Merge(); FormatHeaderText1(sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, 3]]); //Formatting table with MO FormatTableCells2(sheet.Range[sheet.Cells[1, 1], sheet.Cells[3 + obj.Set.First().MOList.Count + obj.Set.First().ControlMOList.Count, obj.Set.Count + 3]]); //Formatting AB Header sheet.Range[sheet.Cells[1, 1], sheet.Cells[1, obj.Set.Count() + 3]].RowHeight = 18; sheet.Range[sheet.Cells[2, 1], sheet.Cells[2, obj.Set.Count() + 3]].RowHeight = 80; sheet.Range[sheet.Cells[2, 4], sheet.Cells[2, obj.Set.Count() + 3]].Orientation = 90; sheet.Range[sheet.Cells[obj.Set.First().MOList.Count + obj.Set.First().ControlMOList.Count + 3 , 4], sheet.Cells[obj.Set.First().MOList.Count + obj.Set.First().ControlMOList.Count + 3, obj.Set.Count() + 3]].RowHeight = 80; sheet.Range[sheet.Cells[obj.Set.First().MOList.Count + obj.Set.First().ControlMOList.Count + 3 , 4], sheet.Cells[obj.Set.First().MOList.Count + obj.Set.First().ControlMOList.Count + 3, obj.Set.Count() + 3]].Orientation = 90; sheet.Range[sheet.Cells[2, 1], sheet.Cells[obj.Set.First().MOList.Count + obj.Set.First().ControlMOList.Count + 3, 1]].ColumnWidth = 5; sheet.Range[sheet.Cells[2, 2], sheet.Cells[obj.Set.First().MOList.Count + obj.Set.First().ControlMOList.Count + 3, 2]].ColumnWidth = 9; sheet.Range[sheet.Cells[2, 3], sheet.Cells[obj.Set.First().MOList.Count + obj.Set.First().ControlMOList.Count + 3, 3]].ColumnWidth = 15; FormatHeaderControlMOText2(sheet.Range[sheet.Cells[obj.Set.First().MOList.Count + 3, 1], sheet.Cells[obj.Set.First().MOList.Count + obj.Set.First().ControlMOList.Count + 3, 3 + obj.Set.Count]]); sheet.Cells[obj.Set.First().MOList.Count + obj.Set.First().ControlMOList.Count + 7, 2] = "Проверил:"; }
private static object[,] PrepareListForSet2(SetViewModel obj) { var rowsCount = obj.Set.First().MOList.Count + obj.Set.First().ControlMOList.Count + 3; var columnsCount = obj.Set.Count + 3; object[,] data = new object[rowsCount, columnsCount]; data[0, 0] = "Сет № " + obj.Set.First().Set; data[1, 0] = "№"; data[1, 1] = "Муз. №"; data[1, 2] = "МО"; for (int i = 0; i < obj.Set.Count; i++) { data[0, 3 + i] = obj.Set[i].AB; data[1, 3 + i] = obj.Set[i].MICList.First().ToString() + " - " + obj.Set[i].MICList.Last().ToString(); data[obj.Set.First().MOList.Count + obj.Set.First().ControlMOList.Count + 2, 3 + i] = obj.Set.First().ControlMICList.First().ToString() + " - " + obj.Set[i].ControlMICList.Last().ToString(); } for (int i = 0; i < obj.Set.First().MOList.Count; i++) { data[i + 2, 0] = obj.Set.First().MOList[i].Number; data[i + 2, 1] = obj.Set.First().MOList[i].MuseumNumber; data[i + 2, 2] = obj.Set.First().MOList[i].MO; } for (int i = 0; i < obj.Set.First().ControlMOList.Count; i++) { data[i + 2 + obj.Set.First().MOList.Count, 0] = obj.Set.First().ControlMOList[i].Number; data[i + 2 + obj.Set.First().MOList.Count, 1] = obj.Set.First().ControlMOList[i].MuseumNumber; data[i + 2 + obj.Set.First().MOList.Count, 2] = obj.Set.First().ControlMOList[i].MO; } return data; }
public void Delete(SetViewModel set, Action success, Action<Exception> errorHandler) { Action completion = delegate { MySets.Remove(s => s.ID == set.ID); FavouriteSets.Remove(s => s.ID == set.ID); foreach (var g in Groups) g.Sets.Remove(s => s.ID == set.ID); cache.RemoveSet(set.ID); success(); }; api.DeleteSet( set.ID, completion, err => { if (err is ItemDeletedException) completion(); // This case can hardly be considered an error. else errorHandler(err); }, new CancellationToken()); }
public void AddRecentSet(SetViewModel set) { if (RecentSets == null) RecentSets = new ObservableCollection<SetViewModel>(); RecentSets.Remove(s => s.ID == set.ID); while (RecentSets.Count >= 8) RecentSets.RemoveAt(7); RecentSets.Insert(0, set); cache.MakeSetRecent(set.ID); }
public void SetStarred(SetViewModel set, bool starred, Action completed, Action<Exception> errorHandler) { if (starred == set.Starred) return; api.SetStarred( set.ID, starred, delegate { cache.SetStarred(set.ID, starred); if (starred) FavouriteSets.Add(set); else FavouriteSets.Remove(set); set.Starred = starred; completed(); }, errorHandler, new CancellationToken()); }
public void RegisterSetInfo(SetViewModel set) { if (cache == null) return; cache.AddSetInfo(set.ToSetInfo()); }
public void LoadTerms(SetViewModel set) { var si = cache.GetSet(set.ID, true); if (si == null) return; set.Update(si.Value); }
public void FetchSetTerms(SetViewModel setViewModel, Action completed, Action<Exception> errorHandler) { api.FetchSet( setViewModel.ID, si => { cache.Update(si); setViewModel.Update(si); completed(); }, errorHandler, new CancellationToken() ); }
private PracticeItem MakePracticeItem(string promptLanguage, SetViewModel set, TermViewModel term) { if (set.DefinitionLanguageCode == promptLanguage || promptLanguage == "$definition") return new PracticeItem(term.Definition, term.Term); else if (set.TermLanguageCode == promptLanguage || promptLanguage == "$term" || promptLanguage == null) return new PracticeItem(term.Term, term.Definition); return null; }
void OnLoaded(object sender, RoutedEventArgs routedEventArgs) { if (set != null) return; if (!setID.HasValue) return; Metrics.Measure("MainViewModel.GetSet", delegate { set = App.ViewModel.GetSet(setID.Value, true); }); Metrics.Measure("Set.xaml: Set DataContext", delegate { DataContext = set; }); if (set == null) { MessageBox.Show("There was an error navigating to this group."); NavigationService.GoBack(); return; } App.ViewModel.AddRecentSet(set); SetBinding(StarredInUIProperty, new Binding("Starred") { Source = set }); bool shouldFetch = false; if (!set.TermsLoaded) { shouldFetch = true; } else if (NavigationContext.QueryString.ContainsKey("modifiedDate")) { string modifiedDate = NavigationContext.QueryString["modifiedDate"]; long ticks; if (modifiedDate != null && long.TryParse(modifiedDate, out ticks) && set.Modified.Ticks < ticks) // We have the group cached, but it has been updated since then. // Show the cached version but load the new one in the background. shouldFetch = true; } if (shouldFetch) set.FetchTerms( delegate { progressBar.Visibility = Visibility.Collapsed; }, err => { progressBar.Visibility = Visibility.Collapsed; MessageBox.Show(err.Message, "Unable to retrieve terms", MessageBoxButton.OK); }); ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = set.IsEditable; ApplicationBar.IsMenuEnabled = set.Author == App.ViewModel.UserName; //((ApplicationBarIconButton)ApplicationBar.MenuItems[0]).IsEnabled = group.Author == App.ViewModel.UserName; if (set.TermsLoaded) progressBar.Visibility = Visibility.Collapsed; }
public void CommitEdits(SetViewModel setViewModel, string newPassword, SetVisibility? newVisibility, SetEditPermissions? newPermissions, IEnumerable<long> groupIDs, Action completed, Action<Exception> errorHandler) { string editable = newPermissions.HasValue ? newPermissions.Value.ToApiString() : null; string visibility = newVisibility.HasValue ? newVisibility.Value.ToApiString() : null; api.EditSet(setViewModel.ToSetInfo(), newPassword, visibility, editable, groupIDs, completed, errorHandler, new CancellationToken()); }
public void CreateSet(SetViewModel setViewModel, string password, IEnumerable<long> groupIDs, Action completed, Action<Exception> errorHandler) { setViewModel.Author = UserName; var si = setViewModel.ToSetInfo(); api.CreateSet( si, password, groupIDs, (id, uri) => { si.ID = setViewModel.ID = id; si.Uri = setViewModel.Uri = uri; cache.AddSetInfo(si); MySets.Insert(0, setViewModel); completed(); }, errorHandler, new CancellationToken()); }