public IDocument Open(string path) { var editor = new EditorViewModel(); editor.Open(path); return(editor); }
public EditorWindow() { InitializeComponent(); _currentContext = (EditorViewModel)this.DataContext; _graphicsWindow = new GraphicsWindow(_currentContext); _graphicsWindow.Show(); }
public IDocument CreateNew(string name) { var editor = new EditorViewModel(); editor.New(name); return(editor); }
public ResultViewModel Post([FromBody] EditorViewModel model) { model.Validate(); if (model.Invalid) { return(new ResultViewModel { Success = false, Message = "Não foi possível cadastrar o todo", Data = model.Notifications }); } var todo = new TodoItem(); todo.Name = model.Name; todo.IsComplete = model.IsComplete; _repository.Save(todo); return(new ResultViewModel { Success = true, Message = "Todo cadastrado com sucesso", Data = todo }); }
public async Task <IActionResult> Export(int projectId, bool jsonExport = true) { EditorViewModel model = EditorBL.EditorData(_context, projectId, $"{_env.WebRootPath}"); model.Mode = EditorMode.Export; if (model.ProjectData == null) { return(RedirectToAction("Index", "Projects")); } string redirect = ""; if (jsonExport) { redirect = EditorBL.ExportProjectJson(_context, projectId, $"{_env.WebRootPath}"); } else { string htmlContent = await RenderPartialViewToString("Preview", model); redirect = EditorBL.ExportProjectHtml(projectId, $"{_env.WebRootPath}", htmlContent, model.EditorData.CustomCss); } ProjectsBL.SetProjectStatus(_context, projectId, Models.Enums.ProjectStatus.Exported, true); return(RedirectToAction("Index", "Projects", new { RedirectTo = redirect })); }
public MainWindow(EditorViewModel viewModel) { InitializeComponent(); ViewModel = viewModel; viewModel.RequestDelayedWork += (sender, e) => deferredActions.Add(e); DataContext = viewModel; viewModel.MoveFocusToFind += (sender, e) => FocusTextBox(FindBox); viewModel.GotoViewModel.MoveFocusToGoto += FocusGotoBox; viewModel.PropertyChanged += ViewModelPropertyChanged; GotoPanel.IsVisibleChanged += AnimateFocusToCorner; FindPanel.IsVisibleChanged += AnimateFocusToCorner; MessagePanel.IsVisibleChanged += AnimateFocusToCorner; ErrorPanel.IsVisibleChanged += AnimateFocusToCorner; viewModel.PropertyChanged += (sender, e) => { if (e.PropertyName == nameof(viewModel.InformationMessage) && MessagePanel.IsVisible && !string.IsNullOrEmpty(viewModel.InformationMessage) ) { AnimateFocusToCorner(MessagePanel, default); } }; Application.Current.DispatcherUnhandledException += (sender, e) => { File.AppendAllText("crash.log", e.Exception.Message + Environment.NewLine + e.Exception.StackTrace); FileSystem.ShowCustomMessageBox("An unhandled error occured. Please report it on Discord or open an issue on GitHub." + Environment.NewLine + "HexManiac might be in a bad state. You should close as soon as possible." + Environment.NewLine + "The error has been logged to crash.log", showYesNoCancel: false); e.Handled = true; }; FillQuickEditMenu(); }
public IDocument Create(string path) { var editor = new EditorViewModel(_propertyGrid, _extendedShell); editor.Open(path); return(editor); }
public nint GetHeight(EditorViewModel viewModel) { if (!(viewModel is PropertyGroupViewModel gvm)) { throw new ArgumentException("Invalid viewmodel type"); } Type propertyVmType = gvm.Properties[0].GetType(); IEditorView view; if (propertyVmType == ViewModel?.Properties[0].GetType()) { if (this.hostedEditor == null) { UpdateHosted(); } view = this.hostedEditor; } else { view = this.selector.GetEditor(this.hostResources, gvm.Properties[0]); } nint editorHeight = view.GetHeight(gvm.Properties[0]); return(((nint)this.table.RowHeight * gvm.Properties.Count) + editorHeight); }
public EditorView(EditorViewModel evm) { InitializeComponent(); _viewModel = evm; DataContext = evm; toolbox = new ToolBox(this); strokeMenu = new StrokeContextMenu(this); _undoStack = new Stack <KeyValuePair <Stroke, int> >(20); _redoStack = new Stack <KeyValuePair <Stroke, int> >(20); _highlighterStrokes = new BlockingCollection <Stroke>(); inkDispatcher = icCanvas.Dispatcher; InitializeHighlightManager(); // Bind inkcanvas stroke to activecanvas RebindStrokes(); Binding newBinding = new Binding(); newBinding = new Binding("allCanvasesView"); newBinding.Source = _viewModel; lvCanvasList.SetBinding(ListView.ItemsSourceProperty, newBinding); newBinding = new Binding("SelectedWSName"); newBinding.Source = _viewModel; cboWSNameSelector.SetBinding(ComboBox.SelectedItemProperty, newBinding); DBOperations.SetUpConnection(); dtKnowledge = new DataTable(); //UpdateListViewData(); TimerSetUp(); //cmdInfo.IsEnabled = false; }
private void UpdateThemeDictionary(EditorViewModel viewModel) { if (Resources.MergedDictionaries.Count == 0) { Resources.MergedDictionaries.Add(new ResourceDictionary()); } var sources = new List <string> { nameof(viewModel.Theme.Primary), nameof(viewModel.Theme.Secondary), nameof(viewModel.Theme.Background), nameof(viewModel.Theme.Backlight), nameof(viewModel.Theme.Error), nameof(viewModel.Theme.Text1), nameof(viewModel.Theme.Text2), nameof(viewModel.Theme.Data1), nameof(viewModel.Theme.Data2), nameof(viewModel.Theme.Accent), nameof(viewModel.Theme.Stream1), nameof(viewModel.Theme.Stream2), nameof(viewModel.Theme.EditBackground), }; var dict = new ResourceDictionary(); var theme = viewModel.Theme.GetType(); sources.ForEach(source => { var rawValue = (string)theme.GetProperty(source).GetValue(viewModel.Theme); dict.Add(source, Brush(rawValue)); dict.Add(source + "Color", ColorConverter.ConvertFromString(rawValue)); }); Resources.MergedDictionaries[0] = dict; }
public GameStudioWindow(EditorViewModel editor) { if (editor == null) { throw new ArgumentNullException(nameof(editor)); } if (editor.Session == null) { throw new ArgumentException($@"A valid session must exist before creating a {nameof(GameStudioWindow)}", nameof(editor)); } DataContext = editor; // Must be set before calling InitializeComponent dockingLayout = new DockingLayoutManager(this, editor.Session); assetEditorsManager = new AssetEditorsManager(dockingLayout, editor.Session); editor.ServiceProvider.Get <IEditorDialogService>().AssetEditorsManager = assetEditorsManager; OpenDebugWindowCommand = new AnonymousCommand(editor.ServiceProvider, OpenDebugWindow); CreateTestAssetCommand = new AnonymousCommand(editor.ServiceProvider, CreateTestAsset); CreateUnitTestAssetCommand = new AnonymousCommand(editor.ServiceProvider, CreateUnitTestAsset); BreakDebuggerCommand = new AnonymousCommand(editor.ServiceProvider, BreakDebugger); EditorSettings.ResetEditorLayout.Command = new AnonymousTaskCommand(editor.ServiceProvider, ResetAllLayouts); InitializeComponent(); Application.Current.Activated += (s, e) => editor.ServiceProvider.Get <IEditorDialogService>().ShowDelayedNotifications(); Loaded += GameStudioLoaded; OpenMetricsProjectSession(editor); }
public void WhenContentIsNotReadyTheProjectSelectionComboBoxIsDisabled() { var mockPlugins = GetEditorPluginLoaderMock(); var model = new EditorViewModel(mockPlugins, new MockSettings()); Assert.AreEqual(false, model.IsContentReady); }
public IActionResult Index() { //using (var scope = _noteSaverDbContext.Database.BeginTransaction()) //{ // var list = new List<int>() { 2 }; // var joinedList = list // .Join(_noteSaverDbContext.InnerContents, c => c, l => l.Id, (c, l) => new { c, l }) // .ToList(); // var joinedList2 = _noteSaverDbContext.InnerContents // .Join(list.Distinct(), c => c.Id, l => l, (c, l) => new { c, l }) // .ToList(); // scope.Commit(); //} var content = _noteSaverDbContext.InnerContents.FirstOrDefault(); var editor = new EditorViewModel() { Content = "" }; if (content != null) { editor.Content = content.InnerText; } return(View(editor)); }
public IActionResult Add() { var viewModel = new EditorViewModel(); SetupEditorViewModelSelectListItems(viewModel); return(View("Editor", viewModel)); }
public void ViewPortWarnsIfLoadedMatchedWordValueDoesNotMatch() { // Arrange var data = new byte[0x200]; var model = new PokemonModel(data); var change = new ModelDelta(); ArrayRun.TryParse(model, "[a:]8", 0x10, null, out var table); model.ObserveAnchorWritten(change, "table", table); change.AddMatchedWord(model, 0, "table"); model.ObserveRunWritten(change, new WordRun(0, "table")); fileSystem.MetadataFor = name => model.ExportMetadata().Serialize(); fileSystem.OpenFile = (name, extensions) => new LoadedFile(name, data); var editor = new EditorViewModel(fileSystem); // change the data so that the viewPort will notice something weird change.ChangeData(model, 0, 4); // Act editor.Open.Execute("text.gba"); // Assert Assert.True(editor.ShowMessage); }
public UserScreenViewModel() { Editor = new EditorViewModel <UserVM>(controller.Users.Select(u => CreateVM(u)), "Выберите пользователя:", () => { var ent = controller.CreateUser(); return(CreateVM(ent)); }); Buttons = new AddButtonsViewModel <UserVM>(OnAddRoles, "+ роли", OnAddAbilities, "+ возможности"); Editor.PropertyChanged += Editor_PropertyChanged; controller.UserRolesChanged += (s, e1) => { SetupUserRoles(); SetupRoleAbilities(); }; controller.UserAbilitiesChanged += (s, e1) => { SetupRoleAbilities(); }; // возможности в роли не меняются controller.DeprecatedChanged += (s, e1) => { if (e1.entity == CurrentEntity.user) { CurrentEntity.OnDeprecatedChangedByCode(); } }; AfterConstructed(); }
PropertyEditorControl GetEditor(EditorViewModel vm, NSOutlineView outlineView) { Type[] genericArgs = null; Type controlType; Type propertyType = vm.GetType(); if (!ViewModelTypes.TryGetValue(propertyType, out controlType)) { if (propertyType.IsConstructedGenericType) { genericArgs = propertyType.GetGenericArguments(); propertyType = propertyType.GetGenericTypeDefinition(); ViewModelTypes.TryGetValue(propertyType, out controlType); } } if (controlType == null) { return(null); } if (controlType.IsGenericTypeDefinition) { if (genericArgs == null) { genericArgs = propertyType.GetGenericArguments(); } controlType = controlType.MakeGenericType(genericArgs); } return(SetUpEditor(controlType, vm, outlineView)); }
public void OnHideSystemPropertiesChanged() { if (_queryResult != null) { EditorViewModel.SetText(_queryResult, HideSystemProperties); } }
public async Task <bool> StartDebug(EditorViewModel editor, ProjectViewModel currentProject, LoggerResult logger) { if (currentProject == null) { await editor.Session.Dialogs.MessageBox(Tr._p("Message", "An executable project must be set as current project in the session explorer in order to process build."), MessageBoxButton.OK, MessageBoxImage.Information); return(false); } try { var projectWatcher = new ProjectWatcher(currentProject.Session, false); await projectWatcher.Initialize(); var executableOutputPath = Path.GetDirectoryName(projectWatcher.CurrentGameExecutable.OutputFilePath); var debuggerProcess = await GetDebuggerProcess(editor); var projectCouldFirstCompile = new TaskCompletionSource <bool>(); Task.Run(() => StartDebugHost(executableOutputPath, projectWatcher, projectCouldFirstCompile, RecompilationDelay, debuggerProcess, logger)).Forget(); return(await projectCouldFirstCompile.Task); } catch { return(false); } }
private static void DebugLog(EditorViewModel editor, params string[] text) { if (editor.LogAppStartupProgress) { File.AppendAllLines("HexManiacAdvance.debug.txt", text); } }
public MainWindow(EditorViewModel viewModel) { InitializeComponent(); ViewModel = viewModel; viewModel.RequestDelayedWork += (sender, e) => deferredActions.Add(e); DataContext = viewModel; viewModel.MoveFocusToFind += (sender, e) => FocusTextBox(FindBox); viewModel.MoveFocusToHexConverter += (sender, e) => FocusTextBox(HexBox); viewModel.GotoViewModel.MoveFocusToGoto += FocusGotoBox; viewModel.PropertyChanged += ViewModelPropertyChanged; GotoPanel.IsVisibleChanged += AnimateFocusToCorner; FindPanel.IsVisibleChanged += AnimateFocusToCorner; HexConverter.IsVisibleChanged += AnimateFocusToCorner; HexBox.GotFocus += (sender, e) => HexBox.SelectAll(); DecBox.GotFocus += (sender, e) => DecBox.SelectAll(); MessagePanel.IsVisibleChanged += AnimateFocusToCorner; ErrorPanel.IsVisibleChanged += AnimateFocusToCorner; viewModel.PropertyChanged += (sender, e) => { if (e.PropertyName == nameof(viewModel.InformationMessage) && MessagePanel.IsVisible && !string.IsNullOrEmpty(viewModel.InformationMessage) ) { AnimateFocusToCorner(MessagePanel, default); } }; Application.Current.DispatcherUnhandledException += HandleException; Loaded += SetupDebugListener; FillQuickEditMenu(); }
private void InitializeEditor() { _vm = new EditorViewModel(); _vm.Editor = new SpiroEditor() { State = new EditorState(), Measure = new EditorMeasure(), Invalidate = () => _canvas.InvalidateVisual(), Drawing = SpiroDrawing.Create(600, 600), Data = new Dictionary <SpiroShape, string>(), Knots = new Dictionary <SpiroShape, IList <SpiroKnot> >() }; _vm.InvalidateCommand = Command.Create(_vm.Editor.Invalidate); _vm.NewCommand = Command.Create(New); _vm.OpenCommand = Command.Create(Open); _vm.SaveAsCommand = Command.Create(SaveAs); _vm.ExportCommand = Command.Create(Export); _vm.ExitCommand = Command.Create(Exit); _vm.DeleteCommand = Command.Create(_vm.Editor.Delete); _vm.IsStrokedCommand = Command.Create(_vm.Editor.ToggleIsStroked); _vm.IsFilledCommand = Command.Create(_vm.Editor.ToggleIsFilled); _vm.IsClosedCommand = Command.Create(_vm.Editor.ToggleIsClosed); _vm.IsTaggedCommand = Command.Create(_vm.Editor.ToggleIsTagged); _vm.ToolCommand = Command <string> .Create(_vm.Editor.ToggleTool); _vm.PointTypeCommand = Command <string> .Create(_vm.Editor.TogglePointType); _vm.ExecuteScriptCommand = Command <string> .Create(_vm.Editor.ExecuteScript); }
private static void OpenMetricsProjectSession(EditorViewModel editor) { var projectUid = editor.Session.CurrentPackage?.Id ?? Guid.Empty; var execProfiles = editor.Session.AllPackages.SelectMany(x => x.ExecutableProfiles); var sessionPlatforms = new HashSet <PlatformType>(); foreach (var execProfile in execProfiles) { if (execProfile.Platform != PlatformType.Shared) { sessionPlatforms.Add(execProfile.Platform); } } if (sessionPlatforms.Count > 0) { var metricData = new StringBuilder(); foreach (var sessionPlatform in sessionPlatforms) { metricData.Append($"#platform:{sessionPlatform}|"); } metricData.Remove(metricData.Length - 1, 1); XenkoGameStudio.MetricsClient?.OpenProjectSession($"#projectUid:{projectUid}|{metricData}"); } else { XenkoGameStudio.MetricsClient?.OpenProjectSession($"#projectUid:{projectUid}|#platform:None"); } }
public ActionResult Index(int id = 0) { Class classObj; if (!Utilities.GetClassObjFromId(db, id, out classObj)) { return(HttpNotFound()); } Instructor instructorObj; if (!Utilities.GetInstructorObjFromEmail(db, classObj.Instructor, out instructorObj)) { return(HttpNotFound()); } EditorViewModel editorViewData = new EditorViewModel(); //data editorViewData.classObj = classObj; editorViewData.instructorObj = instructorObj; editorViewData.announcements = V1.DeserializeAnnouncements(classObj.Announcements); editorViewData.assignments = V1.DeserializeAssignments(classObj.Assignments); editorViewData.subscribers = V1.DeserializeSubscribers(classObj.Subscribers); editorViewData.fullUrl = Utilities.GetFullUrl(classObj.Url); //labels editorViewData.AnnouncementsLbl = Constants.AnnouncementsLbl; editorViewData.AssignmentsLbl = Constants.AssignmentsLbl; editorViewData.InstructorLbl = Constants.InstructorLbl; return(View(editorViewData)); }
private EditorViewModel CreateViewModel() { EditorViewModel viewModel = new EditorViewModel(_lastUpdateTime, _camera.Position, _camera.CalcMatrix(), _world.UpdatedChunks, VoxelSize, _world.WorldSize, _materialID, _materialAmount, _raytraceVoxelPosition, _raytracedVoxel); _world.ResetUpdateList(); return(viewModel); }
/// <summary> /// Open the selected file and display it if you can do it /// </summary> private void SelectedItemChanged() { var s = Path.GetExtension(SelectedItemPath); if (SelectedItemIsFolder || s == null) { return; } var extension = s.ToLower(); switch (extension) //Only open these extensions { case ".html": case ".css": case ".js": case ".ws": break; default: return; } foreach (var doc in ProjectModel.Instance.Documents) { doc.IsSelected = false; } EditorViewModel myEditor = ProjectModel.Instance.SearchOrCreateDocument(SelectedItemPath); myEditor.IsSelected = true; }
public void DefaultProjectToLoginWithIsSelectedIfUserHasNotLoggedInYetOrLoggedOut() { var mockPlugins = GetEditorPluginLoaderMock(); var model = new EditorViewModel(mockPlugins, new MockSettings()); model.SelectedProject = new ProjectNameAndFontWeight("", FontWeights.Normal); Assert.AreEqual("GhostWars", model.SelectedProject); }
public EditorView() { InitializeComponent(); BindingContext = vm = new EditorViewModel(); vm.PropertyChanged += HandlePropertyChanged; }
private NSView GetEditor(string identifier, EditorViewModel vm, NSOutlineView outlineView) { var view = outlineView.MakeView(identifier, this); if (view != null) { return(view); } if (vm != null) { IEditorView editor = this.editorSelector.GetEditor(this.hostResources, vm); var editorControl = editor?.NativeView as PropertyEditorControl; if (editorControl != null) { editorControl.TableView = outlineView; } else if (editor?.NativeView != null) { editor.NativeView.Identifier = identifier; return(editor.NativeView); } return(new EditorContainer(this.hostResources, editor) { Identifier = identifier }); } else { return(new PanelHeaderEditorControl(this.hostResources)); } }
public MainViewModel() { VirtualMachine machine = new VirtualMachine(); EditorViewModel = new EditorViewModel(machine); StackViewModel = new StackViewModel(EditorViewModel); }
private static EditorViewModel GetViewModel(string fileName, int address, WindowsFileSystem fileSystem, bool[] options) { bool useMetadata = options[0]; bool showDevMenu = options[1]; if (fileName != string.Empty) { fileName = Path.GetFullPath(fileName); } SetInitialWorkingDirectory(); var editor = new EditorViewModel(fileSystem, fileSystem, allowLoadingMetadata: useMetadata) { ShowDeveloperMenu = showDevMenu }; DebugLog(editor, "------"); DebugLog(editor, fileName); CheckIsNewerVersionAvailable(editor); if (!File.Exists(fileName)) { return(editor); } DebugLog(editor, "File Exists"); TryOpenFile(editor, fileSystem, fileName, address); return(editor); }
public void ToggleMaximize(bool moveWindowToTop, EditorViewModel viewModel) { if (isMaximized) RestoreWindowLocation(moveWindowToTop); else MaximizeWindow(); viewModel.UpdateBorderThicknessOfChromeStyle(); }
public IntellisenseViewModel(EditorModel editor, EditorViewModel viewModel) { completionData = new List<CompletionDataViewModel>(); completionAssistant = new CompletionAssistantViewModel(this); editorViewModel = viewModel; this.editor = editor; isVisible = false; }
public void CreateEditorPluginEntryFromLoadedPlugins() { var mockPlugins = GetEditorPluginLoaderMock(); var model = new EditorViewModel(mockPlugins, new MockSettings()); model.AddAllPlugins(); Assert.AreEqual(1, model.EditorPlugins.Count); Assert.AreEqual("Mock Plugin", model.EditorPlugins[0].ShortName); Assert.AreEqual("Mock.png", model.EditorPlugins[0].Icon); Assert.AreEqual(typeof(MockEditorPluginView), model.EditorPlugins[0].GetType()); }
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e) { editor.EditorScrolled -= Editor_EditorScrolled; editor.CaretChangedByPointerClick -= Editor_CaretChangedByPointerClick; editor = null; editorViewModel = null; disposables.Dispose(); }
protected override void OnDetaching() { editorVm = null; if (editor != null) { editor.DataContextChanged -= Editor_DataContextChanged; editor = null; } base.OnDetaching(); }
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) { editor = this.Find<TextEditor.TextEditor>("editor"); editor.CaretChangedByPointerClick += Editor_CaretChangedByPointerClick; editor.EditorScrolled += Editor_EditorScrolled; editorViewModel = DataContext as EditorViewModel; if (editorViewModel != null && editor != null) { editorViewModel.Model.Editor = editor; editor.Focus(); } }
public void PopUpNotificationForUpdatedContentDoesNotShowUpInitially() { var mockPlugins = GetEditorPluginLoaderMock(); var model = new EditorViewModel(mockPlugins, new MockSettings()); Assert.IsTrue(string.IsNullOrEmpty(model.PopupText)); Assert.AreEqual(Visibility.Hidden, model.PopupVisibility); }
//Private private EditorViewModel GetEditor(ViewModelConfig viewModelConfig, PropertyInfo prop, Type type) { var detailViewAttr = prop.GetCustomAttribute<DetailViewAttribute>(); var systemPropertyAttr = prop.GetCustomAttribute<SystemPropertyAttribute>(); if (detailViewAttr == null && systemPropertyAttr != null) { detailViewAttr = new DetailViewAttribute() { Name = prop.Name, Visible = false }; } if (detailViewAttr != null) { var maxLengthAttr = prop.GetCustomAttribute<MaxLengthAttribute>(); var jsonIgnoreAttr = prop.GetCustomAttribute<JsonIgnoreAttribute>(); bool hideLabel = detailViewAttr.HideLabel; if (!hideLabel) hideLabel = String.IsNullOrEmpty(detailViewAttr.Name); var editor = new EditorViewModel { Mnemonic = detailViewAttr.Mnemonic, ParentViewModelConfig = viewModelConfig, Title = detailViewAttr.Name ?? prop.Name, Description = detailViewAttr.Description, PropertyName = prop.Name, PropertyType = prop.PropertyType, IsLabelVisible = !hideLabel, TabName = detailViewAttr.TabName ?? "[0]Основное", GroupName = detailViewAttr.GroupName ?? Guid.NewGuid().ToString("N"), IsReadOnly = !prop.CanWrite || detailViewAttr.ReadOnly, IsRequired = detailViewAttr.Required, Order = detailViewAttr.Order, MaxLength = maxLengthAttr != null ? (int?)maxLengthAttr.Length : null, DeferredLoading = detailViewAttr.DeferredLoading, Width = detailViewAttr.Width != 0 ? (int?)detailViewAttr.Width : null, Height = detailViewAttr.Height != 0 ? (int?)detailViewAttr.Height : null, JsonIgnore = jsonIgnoreAttr != null, IsSystemPropery = systemPropertyAttr != null, Visible = detailViewAttr.Visible, EditorType = prop.PropertyType.IsBaseCollection() ? prop.PropertyType.GetGenericType().GenericTypeArguments[0] : prop.PropertyType, Relationship = GetRelationship(prop.PropertyType, type), }; var dataTypeAttr = prop.GetCustomAttribute<PropertyDataTypeAttribute>(); if (dataTypeAttr == null) { if (editor.EditorType == typeof(string) && editor.MaxLength == null) editor.EditorTemplate = "MultilineText"; else if (editor.EditorType == typeof(int) || editor.EditorType == typeof(int?)) editor.EditorTemplate = "Integer"; else if (editor.EditorType == typeof(decimal) || editor.EditorType == typeof(decimal?)) editor.EditorTemplate = "Currency"; else if (editor.EditorType == typeof(double) || editor.EditorType == typeof(double?)) editor.EditorTemplate = "Double"; else if (editor.EditorType == typeof(DateTime) || editor.EditorType == typeof(DateTime?)) editor.EditorTemplate = "Date"; else if (editor.EditorType.IsEnum()) editor.EditorTemplate = "Enum"; else if (editor.EditorType == typeof(Period)) editor.EditorTemplate = "Period"; else if (editor.EditorType == typeof(Icon)) editor.EditorTemplate = "Icon"; else if (typeof(MultilanguageText).IsAssignableFrom(editor.EditorType)) editor.EditorTemplate = "Multilanguage"; else if (editor.EditorType == typeof(Url)) editor.EditorTemplate = "ComplexUrl"; else if (editor.EditorType == typeof(UrlMultilanguageText)) editor.EditorTemplate = "UrlMultilanguageText"; else if (editor.EditorType == typeof(LinkBaseObject)) editor.EditorTemplate = "LinkBaseObject"; else if (editor.EditorType == typeof(MultiEnum)) editor.EditorTemplate = "MultiEnum"; //else if (editor.EditorType == typeof(ValidationObjectBinding)) // editor.EditorTemplate = "ValidationObjectBinding"; else { Type easyCollectionEntry = prop.PropertyType.GetEntryOfUnboundedTypeOfCollection(typeof(EasyCollectionEntry<>)); if (easyCollectionEntry != null) { editor.EditorTemplate = "EasyCollection"; editor.ViewModelConfig = _viewModelConfigService.Get(easyCollectionEntry); } else { switch (editor.Relationship) { case Relationship.OneToMany: if (typeof(FileData).IsAssignableFrom(editor.EditorType)) editor.EditorTemplate = "Files"; else if (typeof(Base.LinkedObjects.Entities.Link).IsAssignableFrom(editor.EditorType)) editor.EditorTemplate = "ListLinkedОbjects"; else editor.EditorTemplate = "OneToMany"; break; case Relationship.ManyToMany: editor.EditorTemplate = "ManyToMany"; break; case Relationship.One: editor.EditorTemplate = "BaseObjectOne"; break; case Relationship.None: editor.EditorTemplate = editor.EditorType.Name; break; } } } } else { editor.EditorTemplate = dataTypeAttr.DataType != PropertyDataType.Custom ? dataTypeAttr.DataType.ToString() : dataTypeAttr.CustomDataType; editor.EditorTemplateParams = dataTypeAttr.Params; } var configEditor = viewModelConfig.DetailView.Editors.FirstOrDefault(m => m.PropertyName == editor.PropertyName); if (configEditor != null) { if (configEditor.Mnemonic != null) editor.Mnemonic = configEditor.Mnemonic; if (configEditor.Title != null) editor.Title = configEditor.Title; if (configEditor.IsLabelVisible != null) editor.IsLabelVisible = configEditor.IsLabelVisible.Value; if (configEditor.EditorTemplate != null) editor.EditorTemplate = configEditor.EditorTemplate; if (configEditor.TabName != null) editor.TabName = configEditor.TabName; if (configEditor.IsReadOnly != null) editor.IsReadOnly = configEditor.IsReadOnly.Value; if (configEditor.IsRequired != null) editor.IsRequired = configEditor.IsRequired.Value; if (configEditor.Order != null) editor.Order = configEditor.Order.Value; if (configEditor.Visible != null) editor.Visible = configEditor.Visible.Value; } if (editor.ViewModelConfig == null) { editor.ViewModelConfig = _viewModelConfigService.Get(editor.Mnemonic) ?? _viewModelConfigService.Get(editor.EditorType); if (editor.ViewModelConfig == null && prop.PropertyType.IsAssignableFromBase()) throw new Exception(String.Format("The configuration file is not configured for type \"{0}\"", editor.EditorType.Name)); } if (String.IsNullOrEmpty(editor.Mnemonic)) editor.Mnemonic = type.GetTypeName(); return editor; } return null; }
public void SaveAndLoadStartEditorFullscreenRegistryState() { MakeSureToDeleteStartMaximizedRegistryEntry(); var mockPlugins = GetEditorPluginLoaderMock(); var model = new EditorViewModel(mockPlugins, new MockSettings()); model.StartEditorMaximized = false; Assert.IsFalse(model.StartEditorMaximized); model.StartEditorMaximized = true; Assert.IsTrue(model.StartEditorMaximized); }
public StockAdministrationViewModel(ISession session, IProductService productService, IStockService stockService) { _session = session; _productService = productService; _stockService = stockService; #region Maintance - Products Actions.Add(new AdministrationActionViewModel() { Action = (p) => { IsBusy = true; Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate { View = new EditorView(_session); var _viewModel = new EditorViewModel<Product>(_session); _viewModel.ItemRemoved += (sender, e) => { _session.Delete<Data.Models.Stock>(s => s.ProductId == e.Item.Id); _session.CommitChanges(); }; _viewModel.NewItemSaved += (sender, e) => { _session.Add<Data.Models.Stock>(new Data.Models.Stock() { Id = Guid.NewGuid(), ProductId = e.Item.Id, Units = 0 }); _session.CommitChanges(); }; View.DataContext = _viewModel; IsBusy = false; }, DispatcherPriority.Background); }, Category = "Maintance", Title = "Products" }); #endregion #region Maintance - Tax Actions.Add(new AdministrationActionViewModel() { Action = (p) => { IsBusy = true; Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate { View = new EditorView(_session); View.DataContext = new EditorViewModel<Tax>(_session); IsBusy = false; }, DispatcherPriority.Background); }, Category = "Maintance", Title = "Tax" }); #endregion #region Maintance - Categories Actions.Add(new AdministrationActionViewModel() { Action = (p) => { IsBusy = true; Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate { View = new EditorView(_session); View.DataContext = new EditorViewModel<Category>(_session); IsBusy = false; }, DispatcherPriority.Background); }, Category = "Maintance", Title = "Categories" }); #endregion #region Maintance - Stock Maintance Actions.Add(new AdministrationActionViewModel() { Action = (p) => { IsBusy = true; Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate { View = new StockMaintanceView_Main(); View.DataContext = new StockMaintanceViewModel( _productService, _stockService); IsBusy = false; }, DispatcherPriority.Background); }, Category = "Maintance", Title = "Stock Maintance" }); #endregion #region Reports - Products Actions.Add(new AdministrationActionViewModel() { Action = (p) => { IsBusy = true; Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate { ReportDocument reportDocument = new ReportDocument(); StreamReader reader = new StreamReader( new FileStream( @"Templates\ProductsReport.xaml", FileMode.Open, FileAccess.Read)); reportDocument.XamlData = reader.ReadToEnd(); reportDocument.XamlImagePath = Path.Combine( Environment.CurrentDirectory, @"Templates\"); reader.Close(); ReportData reportData = new ReportData(); DataTable table = new DataTable("Products"); table.Columns.Add("Reference", typeof (string)); table.Columns.Add("Name", typeof (string)); table.Columns.Add("BuyPrice", typeof (double)); table.Columns.Add("SellPrice", typeof (double)); foreach ( var product in _productService.GetProducts()) { table.Rows.Add(new object[] { product.Reference, product.Name, product.BuyPrice, product.SellPrice }); } reportData.DataTables.Add(table); XpsDocument xps = reportDocument.CreateXpsDocument( reportData); View = new SimpleReportView(xps); IsBusy = false; }, DispatcherPriority.SystemIdle); }, Category = "Reports", Title = "Products" }); #endregion #region Reports - Current Inventory Actions.Add(new AdministrationActionViewModel() { Action = (p) => { IsBusy = true; Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate { ReportDocument reportDocument = new ReportDocument(); StreamReader reader = new StreamReader( new FileStream( @"Templates\CurrentInventoryReport.xaml", FileMode.Open, FileAccess.Read)); reportDocument.XamlData = reader.ReadToEnd(); reportDocument.XamlImagePath = Path.Combine( Environment.CurrentDirectory, @"Templates\"); reader.Close(); ReportData reportData = new ReportData(); DataTable table = new DataTable("Products"); table.Columns.Add("Reference", typeof (string)); table.Columns.Add("Name", typeof (string)); table.Columns.Add("Units", typeof (double)); foreach ( var product in _productService.GetProducts()) { Data.Models.Stock stock = _stockService.GetStockByProductId( product.Id); table.Rows.Add(new object[] { product.Reference, product.Name, stock.Units }); } reportData.DataTables.Add(table); XpsDocument xps = reportDocument.CreateXpsDocument( reportData); View = new SimpleReportView(xps); IsBusy = false; }, DispatcherPriority.SystemIdle); }, Category = "Reports", Title = "Current Inventory" }); #endregion }
public void Dispose() { editor = null; editorViewModel = null; }
private void Editor_DataContextChanged(object sender, EventArgs e) { editorVm = editor.DataContext as EditorViewModel; }
public async Task<IEditor> OpenDocument(ISourceFile file, int line, int column = 1, bool debugHighlight = false, bool selectLine = false) { var currentTab = DocumentTabs.Documents.OfType<EditorViewModel>().FirstOrDefault(t => t.Model.ProjectFile.FilePath == file.FilePath); var selectedDocumentTCS = new TaskCompletionSource<IDocumentTabViewModel>(); if (currentTab == null) { await Dispatcher.UIThread.InvokeTaskAsync(async () => { if (DocumentTabs.TemporaryDocument != null) { var documentToClose = DocumentTabs.TemporaryDocument; DocumentTabs.TemporaryDocument = null; await documentToClose.CloseCommand.ExecuteAsyncTask(null); SelectedDocument = null; } }); EditorViewModel newEditor = null; await Dispatcher.UIThread.InvokeTaskAsync(async () => { newEditor = new EditorViewModel(new EditorModel()); newEditor.Margins.Add(new BreakPointMargin(IoC.Get<IDebugManager>().BreakPointManager)); newEditor.Margins.Add(new LineNumberMargin()); await Dispatcher.UIThread.InvokeTaskAsync(() => { DocumentTabs.Documents.Add(newEditor); DocumentTabs.TemporaryDocument = newEditor; }); DocumentTabs.SelectedDocument = newEditor; await Dispatcher.UIThread.InvokeTaskAsync(() => { newEditor.Model.OpenFile(file, newEditor.Intellisense, newEditor.Intellisense.CompletionAssistant); }); selectedDocumentTCS.SetResult(DocumentTabs.SelectedDocument); }); } else { await Dispatcher.UIThread.InvokeTaskAsync(() => { DocumentTabs.SelectedDocument = currentTab; }); selectedDocumentTCS.SetResult(DocumentTabs.SelectedDocument); } await selectedDocumentTCS.Task; if (DocumentTabs.SelectedDocument is EditorViewModel) { if (debugHighlight) { (DocumentTabs.SelectedDocument as EditorViewModel).DebugLineHighlighter.Line = line; } if (selectLine || debugHighlight) { Dispatcher.UIThread.InvokeAsync(() => (DocumentTabs.SelectedDocument as EditorViewModel).Model.ScrollToLine(line)); (DocumentTabs.SelectedDocument as EditorViewModel).GotoPosition(line, column); } } return DocumentTabs.SelectedDocument as EditorViewModel; }
public void StartEditorFullscreenWhenNoRegistryKeyIsSetAndSaveStateInRegistry() { MakeSureToDeleteStartMaximizedRegistryEntry(); var mockPlugins = GetEditorPluginLoaderMock(); var model = new EditorViewModel(mockPlugins, new MockSettings()); Assert.IsTrue(model.StartEditorMaximized); }