public void OpenProject() { var file = StandaloneFileBrowser.OpenFilePanel("Load Editor File", "", "tse", false).SingleOrDefault(); if (!File.Exists(file)) { return; } CurrentFile = JsonConvert.DeserializeObject <EditorFile>(File.ReadAllText(file), new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto, Formatting = Formatting.Indented }); }
private void ListEntryOnRightUp(object sender, MouseButtonEventArgs e) { ListBoxItem target = sender as ListBoxItem; EditorFile entry = (EditorFile)target.DataContext; if (MessageBox.Show( "Do you want to remove \"" + entry.Path.Split('\\').Last() + "\" from the recently opened files?", "Remove from history", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { FileHistory.Remove(entry); } }
void OpenFile(string filename) { filepath = filename; IStorageGraph newgraph; bool isnewfile = false; if (string.IsNullOrEmpty(filename)) { newgraph = new MemoryStorageGraph(); isnewfile = true; } else { switch (Path.GetExtension(filename)) { case ".musicwriter": var stream = File.Open( path: filepath, mode: FileMode.OpenOrCreate, access: FileAccess.ReadWrite, share: FileShare.Read ); var archive = new ZipArchive( stream: stream, mode: ZipArchiveMode.Update | ZipArchiveMode.Read ); newgraph = new ZipStorageGraph(archive); break; case ".musicwriter-dir": throw new NotImplementedException(); default: throw new NotSupportedException(); } } tabScreens.Controls.Clear(); file = new EditorFile(newgraph, containerfactoryset, isnewfile); Setup(); RecentFiles.AddRecent(filepath); }
public void NewProject() { CurrentFile = new EditorFile(); State = EState.EditSM; ObjectPicker.LevelInstance.Pick(() => GetTypes <IStateMachineDefinition>(), t => { if (t == null) { NewProject(); } CurrentFile.StateMachineDefinition = (IStateMachineDefinition)Activator.CreateInstance(t); }); }
void SetupStatic() { InitInputSources(); InitContainers(); InitPorters(); inputcontroller = new InputController(commandcenter); file = new EditorFile( new MemoryStorageGraph(), containerfactoryset, isnewfile: true ); }
private void ListBoxItemOnMouseDoubleClick(object sender, MouseButtonEventArgs e) { ListBoxItem item = sender as ListBoxItem; EditorFile editorFile = item.DataContext as EditorFile; Type type = editorFile.GetEditorType(); if (!typeof(IEditorControl).IsAssignableFrom(type)) { if (MessageBox.Show("Invalid entry in history!\nDo you want to remove it from recently opened files?", "Invalid entry", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { FileHistory.Remove(editorFile); } return; } if (!File.Exists(editorFile.Path)) { if (MessageBox.Show("The file does not exist anymore!\nDo you want to remove it from recently opened files?", "Missing file", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { FileHistory.Remove(editorFile); } return; } // TODO Check if file type is supported by editor before calling this part /* * if (FileChecker.IsBinary(editorFile.Path)) * { * if (MessageBox.Show("Binary files are not supported at this time.\nDo you want to remove it from recently opened files?", "File is binary", MessageBoxButton.YesNo) == MessageBoxResult.Yes) * FileHistory.Remove(editorFile); * return; * } */ if (FileChecker.IsTooBig(editorFile.Path)) { if (MessageBox.Show("Files with a size over 10MB are not supported.\nOpen anyways? (Program may freeze or stop working)", "File too big", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel) { return; } } new MainWindow(editorFile.Path, type).Show(); Close(); }
public void TestCreateGraph() { graph = new MemoryStorageGraph(); var factoryset = new FactorySet <IContainer>(); factoryset .Factories .Add( PolylineContainer.CreateFactory( new FactorySet <PolylineData>( PolylineData.FactoryInstance ), new ViewerSet <PolylineData>() ) ); file = new EditorFile(graph, factoryset); obj1 = graph.CreateObject(); obj2 = graph.CreateObject(); }
void Start() { instance = this; }
/// <summary> /// Edits the specified object's value using the editor style indicated by the <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle"/> method. /// </summary> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"/> that can be used to gain additional context information.</param> /// <param name="provider">An <see cref="T:System.IServiceProvider"/> that this editor can use to obtain services.</param> /// <param name="value">The object to edit.</param> /// <returns> /// The new value of the object. If the value of the object has not changed, this should return the same object it was passed. /// </returns> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { var descriptor = (ContentTypeDescriptor)context.Instance; var document = (GorgonFontContent)descriptor.Content; FormBrushEditor brushEditor = null; try { EditorFile textureBrushFile = null; if (document.Brush.BrushType == GlyphBrushType.Texture) { Dependency dependency = document.Dependencies.SingleOrDefault(item => string.Equals(item.Type, GorgonFontContent.TextureBrushTextureType)); if (dependency != null) { textureBrushFile = dependency.EditorFile; } } brushEditor = new FormBrushEditor(document) { BrushType = document.Brush.BrushType }; switch (document.Brush.BrushType) { case GlyphBrushType.Texture: brushEditor.TextureBrush = (GorgonGlyphTextureBrush)document.Brush; brushEditor.TextureBrushFile = textureBrushFile; break; case GlyphBrushType.Hatched: brushEditor.PatternBrush = (GorgonGlyphHatchBrush)document.Brush; break; case GlyphBrushType.LinearGradient: brushEditor.GradientBrush = (GorgonGlyphLinearGradientBrush)document.Brush; break; case GlyphBrushType.Solid: brushEditor.SolidBrush = (GorgonGlyphSolidBrush)document.Brush; break; } GorgonGlyphBrush brush = document.Brush; if (brushEditor.ShowDialog() != DialogResult.OK) { return(brush); } // Destroy the previous brush. if (brush.BrushType == GlyphBrushType.Texture) { var textureBrush = (GorgonGlyphTextureBrush)document.Brush; if ((brushEditor.BrushType != GlyphBrushType.Texture) && (textureBrush.Texture != null)) { textureBrush.Texture.Dispose(); } // Remove the old texture brush dependency (if it existed). if (textureBrushFile != null) { if (document.Dependencies.Contains(textureBrushFile, GorgonFontContent.TextureBrushTextureType)) { document.Dependencies.Remove(textureBrushFile, GorgonFontContent.TextureBrushTextureType); } } } switch (brushEditor.BrushType) { case GlyphBrushType.Texture: brush = brushEditor.TextureBrush; // Add the updated texture brush dependency path. if (textureBrushFile != null) { document.Dependencies[brushEditor.TextureBrushFile, GorgonFontContent.TextureBrushTextureType] = new Dependency(brushEditor.TextureBrushFile, GorgonFontContent.TextureBrushTextureType); } break; case GlyphBrushType.Solid: brush = brushEditor.SolidBrush; break; case GlyphBrushType.LinearGradient: brush = brushEditor.GradientBrush; break; case GlyphBrushType.Hatched: brush = brushEditor.PatternBrush; break; } return(brush); } finally { if (brushEditor != null) { brushEditor.Dispose(); } } }