public ActionResult ProjectEdit(string guid = "") { var project = _projectFactory.GetProject(guid); ViewBag.customers = _customerFactory.GetAllCustomers() ?? new List <Customer>(); ViewBag.users = UserFactory.GetAllUsers() ?? new List <User>(); return(View(project ?? new Project())); }
public JsonResult GoToNextStep() { string guid = Request["guid"].ToString(); //DateTime estimatedDate = Convert.ToDateTime(Request["estimatedDate"]); DateTime actualDate = Convert.ToDateTime(Request["actualDate"]); var personInCharge = Request["personInCharge"].ToString(); var project = _projectFactory.GetProject(guid); project.GoToNextStep(actualDate, personInCharge); return(Json(new { result = 1 })); }
public void TestProjectLoad_AllMethodsReturnEquivalentResult() { FileInfo fileInfo = TestUtils.GetSampleProject(@"DotNetProjectParser.SampleProjects.NetCore.Console.csproj"); Project projectFromStaticFactory = ProjectFactory.GetProject(fileInfo); Project projectFromConstructMethod = Project.Construct(fileInfo); IProjectFactory factory = new ProjectFactory(); Project projectFromInstanceFactory = factory.GetProject(fileInfo); projectFromStaticFactory.Should().BeEquivalentTo(projectFromConstructMethod, options => options.IgnoringCyclicReferences()); projectFromStaticFactory.Should().BeEquivalentTo(projectFromInstanceFactory, options => options.IgnoringCyclicReferences()); }
public void TestLoad_StaticProperties_ReadOk() { var fileInfo = TestUtils.GetSampleProject(@"DotNetProjectParser.SampleProjects.NetCore.Library.csproj"); var project = ProjectFactory.GetProject(fileInfo); project.Should().NotBeNull(); project.ProjectXml.Should().NotBeNull(); project.Name.Should().Be("DotNetProjectParser.SampleProjects.NetCore.Library.csproj"); project.FullPath.Should().Be(fileInfo.FullName); project.DirectoryPath.Should().Be(fileInfo.Directory.FullName); project.AssemblyName.Should().Be("DotNetProjectParser.SampleProjects.NetCore.Library"); project.OutputType.Should().Be("Library"); project.TargetExtension.Should().Be(".dll"); project.TargetFramework.Should().Be("netcoreapp3.0"); }
private void OpenProject() { CloseProject(); OpenProjectFileDialog.Filter = "Traducciones|" + GetOpenProjectFilesFilter(); var result = OpenProjectFileDialog.ShowDialog(this); if (result == DialogResult.OK) { Project project = null; #if !DEBUG try { #endif Enabled = false; Cursor.Current = Cursors.WaitCursor; project = ProjectFactory.GetProject(OpenProjectFileDialog.FileName); project.LoadFiles(); project.LoadStrings(); Enabled = true; Cursor.Current = Cursors.Default; _openProject = project; LoadDataGrid(); Text = $"Translation Framework - {_openProject.Path}"; #if !DEBUG } catch (Exception e) { MessageBox.Show($"No se ha podido abrir el fichero.\r\n{e.GetType()}: {e.Message}", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); project?.Close(); Cursor.Current = Cursors.Default; Enabled = true; } #endif } }
private Project LoadProject(string uri) { Project prj; try { prj = ProjectFactory.GetProject(new FileInfo(uri)); this.logger.Debug($"Project loaded from [{uri}]"); } catch (Exception ex) { this.logger.Warn($"Error while loading project [{uri}] {ex.Message}. Details in DEBUG mode."); this.logger.Debug($"Error details:" + ex); return(null); } return(prj); }
private void CreateNewProject() { CloseProject(); SaveProjectFileDialog.Filter = GetSaveProjectFilesFilter(); var result = SaveProjectFileDialog.ShowDialog(this); if (result == DialogResult.OK) { Project project = null; #if !DEBUG try { #endif var i = 0; while (File.Exists(SaveProjectFileDialog.FileName) && i < 10) { try { File.Delete(SaveProjectFileDialog.FileName); } catch (Exception e) { i++; } } if (File.Exists(SaveProjectFileDialog.FileName)) { MessageBox.Show("No se ha podido sobreescribir el fichero", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } project = ProjectFactory.GetProject(SaveProjectFileDialog.FileName); if (AddFilesToProject(project)) { project.SaveStrings(); _openProject = project; LoadDataGrid(); Text = $"Translation Framework - {_openProject.Path}"; } #if !DEBUG } catch (Exception e) { MessageBox.Show($"No se ha podido crear el proyecto.\r\n{e.GetType()}: {e.Message}", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); project?.Close(); Cursor.Current = Cursors.Default; Enabled = true; } #endif } }
private void ImportTF(bool complete) { if (_openProject == null) { return; } ImportFileDialog.Filter = "Traducciones|" + GetOpenProjectFilesFilter(); var result = ImportFileDialog.ShowDialog(this); if (result == DialogResult.OK) { var strings = new Dictionary <string, string>(); Project project = null; #if !DEBUG try { #endif project = ProjectFactory.GetProject(ImportFileDialog.FileName); project.LoadFiles(); project.LoadStrings(); var files = project.Files.ToDictionary(file => file.Id, file => Path.GetFileName(file.Path)); foreach (var tfString in project.Strings) { string key; if (!complete) { key = tfString.Original; } else { key = files.ContainsKey(tfString.FileId) ? string.Concat(files[tfString.FileId], "|", tfString.Section, "|", tfString.Offset, "|", tfString.Original) : string.Empty; } var value = tfString.Translation; if (!string.IsNullOrEmpty(key)) { if (!strings.ContainsKey(key)) { strings.Add(key, value); } } } project.Close(); #if !DEBUG } catch (Exception e) { MessageBox.Show($"No se ha podido abrir el fichero.\r\n{e.GetType()}: {e.Message}", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); project?.Close(); return; } #endif var files2 = _openProject.Files.ToDictionary(file => file.Id, file => Path.GetFileName(file.Path)); foreach (var tfString in _openProject.Strings) { string key; if (!complete) { key = tfString.Original; } else { key = files2.ContainsKey(tfString.FileId) ? string.Concat(files2[tfString.FileId], "|", tfString.Section, "|", tfString.Offset, "|", tfString.Original) : string.Empty; } if (!string.IsNullOrEmpty(key)) { if (strings.ContainsKey(key)) { tfString.Translation = strings[key]; } } } StringsDataGrid.Rows.Clear(); LoadDataGrid(); } }
public void TestLoad_Items_ReadOk() { var fileInfo = TestUtils.GetSampleProject(@"DotNetProjectParser.SampleProjects.NetCore.Library.csproj"); Project project = ProjectFactory.GetProject(fileInfo); project.Should().NotBeNull(); Assert.IsFalse(project.Items.Any(x => x.ItemName == "I should not be visible.txt")); project.Items.Should().ContainEquivalentOf(new ProjectItem() { Include = "Class1.cs", ItemName = "Class1.cs", ResolvedIncludePath = Path.Combine(fileInfo.Directory.FullName, "Class1.cs"), ItemType = "Compile", CopyToOutputDirectory = null, Project = project }); project.Items.Should().ContainEquivalentOf(new ProjectItem() { Include = @"Subfolder\File2.cs", ItemName = @"File2.cs", ResolvedIncludePath = Path.Combine(fileInfo.Directory.FullName, "Subfolder\\File2.cs"), ItemType = "Compile", CopyToOutputDirectory = null, Project = project }); project.Items.Should().ContainEquivalentOf(new ProjectItem() { Include = @"File3.cs", ItemName = @"File3.cs", ResolvedIncludePath = Path.Combine(fileInfo.Directory.FullName, "File3.cs"), ItemType = "Resource", CopyToOutputDirectory = "PreserveNewest", Project = project }); project.Items.Should().ContainEquivalentOf(new ProjectItem() { Include = @".startWithDot", ItemName = @".startWithDot", ResolvedIncludePath = Path.Combine(fileInfo.Directory.FullName, ".startWithDot"), ItemType = "None", CopyToOutputDirectory = null, Project = project }); project.Items.Should().ContainEquivalentOf(new ProjectItem() { Include = @"NoneDoNotCopy.bmp", ItemName = @"NoneDoNotCopy.bmp", ResolvedIncludePath = Path.Combine(fileInfo.Directory.FullName, "NoneDoNotCopy.bmp"), ItemType = "None", CopyToOutputDirectory = null, Project = project }); project.Items.Should().ContainEquivalentOf(new ProjectItem() { Include = @"ResourceCopyAlways.bmp", ItemName = @"ResourceCopyAlways.bmp", ResolvedIncludePath = Path.Combine(fileInfo.Directory.FullName, "ResourceCopyAlways.bmp"), ItemType = "Resource", CopyToOutputDirectory = "Always", Project = project }); var compileItems = project.GetCompileItems(); Assert.AreEqual(2, compileItems.Count()); compileItems.Select(x => x.ItemName).Should().Contain(new[] { "Class1.cs", "File2.cs" }); }
/// <summary> /// Initializes static designer context. /// </summary> /// <param name="serviceProvider">The service provider.</param> public static void InitializeContext(IServiceProvider serviceProvider) { // Editor Editor = serviceProvider.GetService <ProjectEditor>(); // Recent Projects Editor.RecentProjects = Editor.RecentProjects.Add(RecentFile.Create("Test1", "Test1.project")); Editor.RecentProjects = Editor.RecentProjects.Add(RecentFile.Create("Test2", "Test2.project")); // New Project Editor.OnNewProject(); // Transform Transform = MatrixObject.Identity; // Data var db = Database.Create("Db"); var fields = new string[] { "Column0", "Column1" }; var columns = ImmutableArray.CreateRange(fields.Select(c => Column.Create(db, c))); db.Columns = columns; var values = Enumerable.Repeat("<empty>", db.Columns.Length).Select(c => Value.Create(c)); var record = Record.Create( db, ImmutableArray.CreateRange(values)); db.Records = db.Records.Add(record); db.CurrentRecord = record; Database = db; Data = Context.Create(record); Record = record; // Project IProjectFactory factory = new ProjectFactory(); Project = factory.GetProject(); Template = PageContainer.CreateTemplate(); Page = PageContainer.CreatePage(); var layer = Page.Layers.FirstOrDefault(); layer.Shapes = layer.Shapes.Add(LineShape.Create(0, 0, null, null)); Page.CurrentLayer = layer; Page.CurrentShape = layer.Shapes.FirstOrDefault(); Page.Template = Template; Document = DocumentContainer.Create(); Layer = LayerContainer.Create(); Options = Options.Create(); // State State = ShapeState.Create(); // Style ArgbColor = ArgbColor.Create(128, 255, 0, 0); ArrowStyle = ArrowStyle.Create(); FontStyle = FontStyle.Create(); LineFixedLength = LineFixedLength.Create(); LineStyle = LineStyle.Create(); Style = ShapeStyle.Create("Default"); TextStyle = TextStyle.Create(); // Shapes Arc = ArcShape.Create(0, 0, Style, null); CubicBezier = CubicBezierShape.Create(0, 0, Style, null); Ellipse = EllipseShape.Create(0, 0, Style, null); Group = GroupShape.Create(Constants.DefaulGroupName); Image = ImageShape.Create(0, 0, Style, null, "key"); Line = LineShape.Create(0, 0, Style, null); Path = PathShape.Create(Style, null); Point = PointShape.Create(); QuadraticBezier = QuadraticBezierShape.Create(0, 0, Style, null); Rectangle = RectangleShape.Create(0, 0, Style, null); Text = TextShape.Create(0, 0, Style, null, "Text"); // Path ArcSegment = ArcSegment.Create(PointShape.Create(), PathSize.Create(), 180, true, SweepDirection.Clockwise, true, true); CubicBezierSegment = CubicBezierSegment.Create(PointShape.Create(), PointShape.Create(), PointShape.Create(), true, true); LineSegment = LineSegment.Create(PointShape.Create(), true, true); PathFigure = PathFigure.Create(PointShape.Create(), false, true); PathGeometry = PathGeometry.Create(ImmutableArray.Create <PathFigure>(), FillRule.EvenOdd); PathSize = PathSize.Create(); PolyCubicBezierSegment = PolyCubicBezierSegment.Create(ImmutableArray.Create <PointShape>(), true, true); PolyLineSegment = PolyLineSegment.Create(ImmutableArray.Create <PointShape>(), true, true); PolyQuadraticBezierSegment = PolyQuadraticBezierSegment.Create(ImmutableArray.Create <PointShape>(), true, true); QuadraticBezierSegment = QuadraticBezierSegment.Create(PointShape.Create(), PointShape.Create(), true, true); }
/// <summary> /// Initializes static designer context. /// </summary> /// <param name="renderer">The design time renderer instance.</param> /// <param name="clipboard">The design time clipboard instance.</param> /// <param name="jsonSerializer">The design time Json serializer instance.</param> /// <param name="xamlSerializer">The design time Xaml serializer instance.</param> /// <returns>The new instance of the <see cref="DesignerContext"/> class.</returns> public static void InitializeContext(ShapeRenderer renderer, ITextClipboard clipboard, ITextSerializer jsonSerializer, ITextSerializer xamlSerializer) { // Editor Editor = new ProjectEditor() { CurrentTool = Tool.Selection, CurrentPathTool = PathTool.Line, CommandManager = new DesignerCommandManager(), Renderers = new ShapeRenderer[] { renderer }, ProjectFactory = new ProjectFactory(), TextClipboard = clipboard, JsonSerializer = jsonSerializer, XamlSerializer = xamlSerializer }.Defaults(); // Recent Projects Editor.RecentProjects = Editor.RecentProjects.Add(RecentFile.Create("Test1", "Test1.project")); Editor.RecentProjects = Editor.RecentProjects.Add(RecentFile.Create("Test2", "Test2.project")); // Commands Editor.InitializeCommands(); InitializeCommands(Editor); Editor.CommandManager.RegisterCommands(); // New Project Editor.OnNew(null); // Data var db = XDatabase.Create("Db"); var fields = new string[] { "Column0", "Column1" }; var columns = ImmutableArray.CreateRange(fields.Select(c => XColumn.Create(db, c))); db.Columns = columns; var values = Enumerable.Repeat("<empty>", db.Columns.Length).Select(c => XValue.Create(c)); var record = XRecord.Create( db, db.Columns, ImmutableArray.CreateRange(values)); db.Records = db.Records.Add(record); db.CurrentRecord = record; Database = db; Data = XContext.Create(record); Record = record; // Project IProjectFactory factory = new ProjectFactory(); Project = factory.GetProject(); Template = XContainer.CreateTemplate(); Page = XContainer.CreatePage(); var layer = Page.Layers.FirstOrDefault(); layer.Shapes = layer.Shapes.Add(XLine.Create(0, 0, null, null)); Page.CurrentLayer = layer; Page.CurrentShape = layer.Shapes.FirstOrDefault(); Page.Template = Template; Document = XDocument.Create(); Layer = XLayer.Create(); Options = XOptions.Create(); // State State = ShapeState.Create(); // Style ArgbColor = ArgbColor.Create(); ArrowStyle = ArrowStyle.Create(); FontStyle = FontStyle.Create(); LineFixedLength = LineFixedLength.Create(); LineStyle = LineStyle.Create(); Style = ShapeStyle.Create("Default"); TextStyle = TextStyle.Create(); // Shapes Arc = XArc.Create(0, 0, Style, null); CubicBezier = XCubicBezier.Create(0, 0, Style, null); Ellipse = XEllipse.Create(0, 0, Style, null); Group = XGroup.Create(Constants.DefaulGroupName); Image = XImage.Create(0, 0, Style, null, "key"); Line = XLine.Create(0, 0, Style, null); Path = XPath.Create("Path", Style, null); Point = XPoint.Create(); QuadraticBezier = XQuadraticBezier.Create(0, 0, Style, null); Rectangle = XRectangle.Create(0, 0, Style, null); Text = XText.Create(0, 0, Style, null, "Text"); // Path ArcSegment = XArcSegment.Create(XPoint.Create(), XPathSize.Create(), 180, true, XSweepDirection.Clockwise, true, true); CubicBezierSegment = XCubicBezierSegment.Create(XPoint.Create(), XPoint.Create(), XPoint.Create(), true, true); LineSegment = XLineSegment.Create(XPoint.Create(), true, true); PathFigure = XPathFigure.Create(XPoint.Create(), false, true); PathGeometry = XPathGeometry.Create(ImmutableArray.Create <XPathFigure>(), XFillRule.EvenOdd); PathSize = XPathSize.Create(); PolyCubicBezierSegment = XPolyCubicBezierSegment.Create(ImmutableArray.Create <XPoint>(), true, true); PolyLineSegment = XPolyLineSegment.Create(ImmutableArray.Create <XPoint>(), true, true); PolyQuadraticBezierSegment = XPolyQuadraticBezierSegment.Create(ImmutableArray.Create <XPoint>(), true, true); QuadraticBezierSegment = XQuadraticBezierSegment.Create(XPoint.Create(), XPoint.Create(), true, true); }