protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); FrameView window = new FrameView(); // Create the ViewModel to which // the main window binds. //string path = "Data/customers.xml"; var viewModel = new FrameViewModel(); // When the ViewModel asks to be closed, // close the window. //EventHandler handler = null; //handler = delegate //{ // viewModel.RequestClose -= handler; // window.Close(); //}; //viewModel.RequestClose += handler; // Allow all controls in the window to // bind to the ViewModel by setting the // DataContext, which propagates down // the element tree. window.DataContext = viewModel; window.Show(); }
private void Swap(int firstIndex, int secondIndex) { var a = FrameViewModel.Models[firstIndex].Text; FrameViewModel.Models[firstIndex].Text = FrameViewModel.Models[secondIndex].Text; FrameViewModel.Models[secondIndex].Text = a; FrameViewModel.DisableAllAsync(); }
public FrameSourceViewModel(IHostTransformation hostTransformation, IFactory <IFrameable> frameFactory, IFrameSaver frameSaver) { FrameFactory = frameFactory; FrameSaver = frameSaver; HostTransformation = hostTransformation; OpenFileContainer = new OpenFileContainerViewModel(this, frameFactory.GetType()); Frame = new FrameViewModel(new NullFramable(), HostTransformation, null); }
public TestPageViewModel(string id, TimerViewModel testTimeViewModel, string time, ISettings settings, int index) { _settings = settings; _settingsViewModel = new SettingsViewModel(); _frameViewModel = new FrameViewModel(); Timer = testTimeViewModel ?? new TimerViewModel(TimeSpan.Parse(time), index); InitializeAsync(testTimeViewModel, id); }
private bool CheckModel() { var isRight = _viewModelTest.GetFrameModel[0].Text == _viewModelTest.GetFrameModel[0].MainText; _viewModelTest.GetFrameModel[0].BorderColor = FrameViewModel.GetColorOnCheck(isRight); return(isRight); }
public MenuCreatorViewModel(Page page, string testId = null) { _frameViewModel = new FrameViewModel(); _settingsViewModel = new SettingsViewModel(); TestId = testId; _page = page; InitializeAsync(testId); }
public async void TapEvent(int index) { if (IsChickAble) { await Task.Run(() => { FrameViewModel.SelectItem(index, false); TrySwap(index); }); } }
public IActionResult DeleteFrame(string frameId) { string framePath = framesService.GetFramePathById(frameId); var model = new FrameViewModel { FilePath = framePath, FrameId = frameId }; return(View(model)); }
string GetPayloadString(FrameViewModel model) { var exception = model.AccociatedFrameProcessorException; if (exception != null) { return(exception.ToString()); } var transfer = model.AssociatedTransfer; if (transfer == null) { return(null); } DsdlType scheme; switch (transfer.TransferType) { case UavcanTransferType.Broadcast: scheme = model.DataType as MessageType; break; case UavcanTransferType.Request: scheme = (model.DataType as ServiceType)?.Request; break; case UavcanTransferType.Response: scheme = (model.DataType as ServiceType)?.Response; break; default: throw new InvalidOperationException(); } if (scheme == null) { return(null); } var bytes = transfer.Payload; var obj = _serializer.Deserialize(bytes, scheme); try { return(ObjectPrinter.PrintToString(obj, scheme)); } catch (Exception ex) { return(ex.ToString()); } }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); MainWindow window = new MainWindow(); // nézet létrehozása FrameViewModel viewModel = new FrameViewModel(); // nézetmodell létrehozása window.DataContext = viewModel; // nézetmodell és modell társítása window.Show(); }
public void LoadFile(string fileName) { if (fileName == null) { Frame = new FrameViewModel(new NullFramable(), HostTransformation, null); return; } var frameable = FrameFactory.Create(fileName); Frame = new FrameViewModel(frameable, HostTransformation, FrameSaver); }
private bool CheckModel() { var pageIsRight = true; foreach (var model in FrameViewModel.Models) { var isRight = model.MainText == model.Text; model.BorderColor = FrameViewModel.GetColorOnCheck(isRight); pageIsRight = pageIsRight && isRight; } return(pageIsRight); }
public TestCreatorViewModel(Repository.Type type, string questionId, string testId = null) { _testId = testId; _questionId = questionId; _questionType = type; _settingsViewModel = new SettingsViewModel(); FrameViewModel = new FrameViewModel(); if (string.IsNullOrEmpty(questionId)) { InitializeNew(); } else { InitializeExisting(questionId); } }
private bool CheckPageAsync() { var pageIsRight = true; foreach (var model in _viewModelTest.GetFrameModel) { var isRight = model.BorderColor == (Color)Application.Current.Resources["ColorMaterialBlue"] == model.IsRight; model.BorderColor = FrameViewModel.GetColorOnCheck(isRight); pageIsRight = pageIsRight && isRight; } return(pageIsRight); }
public IActionResult Create(FrameViewModel frameViewModel) { string stringFileName = UploadFile(frameViewModel); var frame = new Frame { Name = frameViewModel.Name, ImageUrl = stringFileName, CategoryId = frameViewModel.Category.CategoryId }; _context.Frame.Add(frame); _context.SaveChanges(); return(RedirectToAction("List")); }
private string UploadFile(FrameViewModel frameViewModel) { string fileName = null; if (frameViewModel.ImageUrl != null) { string uploadDir = Path.Combine(_hostEnvironment.WebRootPath, "FrameImages"); fileName = Guid.NewGuid().ToString() + '-' + frameViewModel.ImageUrl.FileName; string filePath = Path.Combine(uploadDir, fileName); using (var fileStream = new FileStream(filePath, FileMode.Create)) { frameViewModel.ImageUrl.CopyTo(fileStream); } } return(fileName); }
private static void ExportDds(AnimViewModel parent) { FrameViewModel view = parent.GetSelectedFrame(); var dialog = new SaveFileDialog { AddExtension = true, CheckPathExists = true, DefaultExt = ".dds", Filter = "DDS File(*.dds)|*.dds" }; if ((bool)dialog.ShowDialog()) { using (FileStream f = File.Create(dialog.FileName)) { byte[] buffer = view.Frame.AsBytes; f.Write(buffer, 0, buffer.Length); } } }
private static void ImportDds(AnimViewModel parent) { FrameViewModel view = parent.GetSelectedFrame(); var dialog = new OpenFileDialog { AddExtension = true, CheckFileExists = true, CheckPathExists = true, DefaultExt = ".dds", Filter = "DDS File(*.dds)|*.dds" }; if ((bool)dialog.ShowDialog()) { using (FileStream f = File.OpenRead(dialog.FileName)) { var buffer = new byte[f.Length]; f.Read(buffer, 0, buffer.Length); view.Data = buffer; } } }
private async void Initialize(string questionId, TimerViewModel testTimeViewModel) { await Task.Run(() => { FrameViewModel = new FrameViewModel(); SettingsViewModel = new SettingsViewModel(); using (var realm = Realm.GetInstance()) { var question = realm.Find <Question>(questionId); SettingsViewModel.SetSettingsModel(question.QuestionText, question.Price, question.Time); Timer = testTimeViewModel ?? new TimerViewModel(TimeSpan.Parse(question.Time), Index); FillFramesAsync(question.Contents); } }); }
public WindowFrames(AnimationData animationData, string basePath) { InitializeComponent(); DataContext = new FrameViewModel(animationData, basePath); }
private void SaveContent(Realm realm, Question question, INavigation navigation, FrameViewModel viewModel) { SaveFrameContent(realm, question, viewModel.Models); Repository.RemoveQuestionContent(realm, question, viewModel.GetContentsToDelete); Device.BeginInvokeOnMainThread(async () => { await PopupNavigation.Instance.PushAsync(new SavePopup()); await navigation.PopAsync(true); }); }
public Frame() { InitializeComponent(); M = new FrameViewModel(); DataContext = M; }
private async void FillFramesAsync(IEnumerable <QuestionContent> contents) { FrameViewModel.FillTestFrames(contents, out var textList); textList.ShuffleAsync(); await Task.WhenAny(GetTask(textList)); }