public override bool IsApplied(BuildContext context, AbstractTypeBuilderList builders) { if (_interceptorType == null && _interceptType == 0) return false; foreach (var builder in builders) { var interceptor = builder as InterceptorAspectBuilder; if (interceptor != null) { if (interceptor._interceptorType == null && interceptor._interceptType == 0) return false; if (builder == this) break; } } if (context.IsMethodOrProperty) switch (context.Step) { case BuildStep.Begin: return true; case BuildStep.Before: return (_interceptType & InterceptType.BeforeCall) != 0; case BuildStep.After: return (_interceptType & InterceptType.AfterCall) != 0; case BuildStep.Catch: return (_interceptType & InterceptType.OnCatch) != 0; case BuildStep.Finally: return (_interceptType & InterceptType.OnFinally) != 0; case BuildStep.End: return true; } return false; }
/// <summary> /// Called before the project's help build starts. /// </summary> /// <param name="context">Provides information about the build process.</param> public override void BuildStarting(BuildContext context) { // Uncomment the following line to break into the debugger: // System.Diagnostics.Debugger.Break(); buildStart = DateTime.Now; }
public void PostBelongsToBlog() { InitKernel(); IRelationshipInferenceService relService = ObtainService(); TableDefinition blogTable; TableDefinition postTable; BuildBlogPostsStructure(out blogTable, out postTable); BuildContext context = new BuildContext(); ActiveRecordDescriptor arDesc = new ActiveRecordDescriptor(); ActiveRecordPropertyDescriptor[] descs = relService.InferRelations( arDesc, postTable, context ); Assert.IsNotNull(descs); Assert.AreEqual( 1, descs.Length ); ActiveRecordBelongsToDescriptor desc1 = descs[0] as ActiveRecordBelongsToDescriptor; Assert.IsNotNull(desc1); Assert.IsNotNull(desc1.TargetType); Assert.IsNull(desc1.PropertyType); Assert.AreEqual( "Blog", desc1.PropertyName ); Assert.AreEqual( "blog_id", desc1.ColumnName ); ActiveRecordDescriptor targetARDescriptor = context.GetNextPendent(); Assert.AreSame( blogTable, targetARDescriptor.Table ); }
public void SetStyle(BuildContext context) { context.Cell.SetRowHeight(18); //context.Cell.SetColumnWidth(15); context.Cell.CellStyle = this.CenterStyle; }
private static void EmbedVirtualFile(BuildContext context, string relativePath) { var file = new VirtualPackageFile( context.SourceFolder, context.SourcePath + relativePath, context.TargetPath + relativePath); context.Builder.Files.Add(file); }
/// <summary> /// /// </summary> /// <param name="sourceStream"></param> /// <param name="targetStream"></param> public override void Process ( AssetSource assetFile, BuildContext context ) { using ( var sourceStream = assetFile.OpenSourceStream() ) { using ( var targetStream = assetFile.OpenTargetStream() ) { sourceStream.CopyTo( targetStream ); } } }
private void BuildClass( DocumentMapping documentMapping, bool isRoot, string path, BuildContext context ) { IList<System.Type> hierarchy = new List<System.Type>(); System.Type currClass = documentMapping.MappedClass; do { hierarchy.Add(currClass); currClass = currClass.BaseType; // NB Java stops at null we stop at object otherwise we process the class twice // We also need a null test for things like ISet which have no base class/interface } while (currClass != null && currClass != typeof(object)); for (int index = hierarchy.Count - 1; index >= 0; index--) { currClass = hierarchy[index]; /** * Override the default analyzer for the properties if the class hold one * That's the reason we go down the hierarchy */ // NB Must cast here as we want to look at the type's metadata var localAnalyzer = GetAnalyzer(currClass); var analyzer = documentMapping.Analyzer ?? localAnalyzer; // Check for any ClassBridges var classBridgeAttributes = AttributeUtil.GetAttributes<ClassBridgeAttribute>(currClass); AttributeUtil.GetClassBridgeParameters(currClass, classBridgeAttributes); // Now we can process the class bridges foreach (var classBridgeAttribute in classBridgeAttributes) { var bridge = BuildClassBridge(classBridgeAttribute, analyzer); documentMapping.ClassBridges.Add(bridge); } // NB As we are walking the hierarchy only retrieve items at this level var propertyInfos = currClass.GetProperties( BindingFlags.DeclaredOnly | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance ); foreach (var propertyInfo in propertyInfos) { BuildProperty(documentMapping, propertyInfo, analyzer, isRoot, path, context); } var fields = currClass.GetFields( BindingFlags.DeclaredOnly | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance ); foreach (var fieldInfo in fields) { BuildProperty(documentMapping, fieldInfo, analyzer, isRoot, path, context); } } }
public override void Build ( BuildContext buildContext ) { var src = buildContext.Resolve( SourceFile ); var dst = buildContext.GetTempFileName( Hash, ".dds" ); RunNVCompress( buildContext, src, dst, NoMips, Fast, ToNormal, Color, Alpha, Normal, Compression ); using ( var target = buildContext.OpenTargetStream( this ) ) { buildContext.CopyTo( dst, target ); } }
/// <summary> /// /// </summary> /// <param name="sourceStream"></param> /// <param name="targetStream"></param> public override void Process ( AssetSource assetFile, BuildContext context ) { var src = assetFile.FullSourcePath; var dst = context.GetTempFileName( assetFile.KeyPath, ".dds" ); RunNVCompress( context, src, dst, NoMips, Fast, ToNormal, Color, Alpha, Normal, Compression ); using ( var target = assetFile.OpenTargetStream() ) { context.CopyFileTo( dst, target ); } }
public override void Compile(ICompileContext context, IProjectItem projectItem) { var item = projectItem as Item; Assert.Cast(item, nameof(item)); var fileName = item.GetValue<string>(LayoutPage)?.Trim() ?? string.Empty; if (string.IsNullOrEmpty(fileName)) { return; } var property = item.GetProperty<string>(LayoutPage); // find page html file var rendering = item.Project.Files.FirstOrDefault(i => string.Equals(i.FilePath, fileName, StringComparison.OrdinalIgnoreCase)); if (rendering == null) { context.Trace.TraceError(Msg.C1047, Texts.Rendering_reference_not_found, TraceHelper.GetTextNode(property), fileName); } // find MvcLayout var layoutItem = item.Project.ProjectItems.OfType<Item>().FirstOrDefault(i => i.ItemIdOrPath == "/sitecore/layout/Layouts/MvcLayout"); if (layoutItem == null) { context.Trace.TraceError(Msg.C1048, Texts.Layout_reference_not_found, TraceHelper.GetTextNode(property), "/sitecore/layout/Layouts/MvcLayout"); } if (rendering == null || layoutItem == null) { return; } var sourceFile = rendering.Snapshots.First().SourceFile; var writer = new StringWriter(); var output = new XmlTextWriter(writer); output.Formatting = Formatting.Indented; var buildContext = new BuildContext(context, sourceFile, output, item, layoutItem); var literalRendering = FindRendering(buildContext, "Literal", string.Empty, TextSpan.Empty); if (literalRendering == null) { return; } buildContext.Placeholder = layoutItem["Place Holders"]; buildContext.LiteralRendering = literalRendering; ParseHtml(buildContext); SetRenderingsField(buildContext, buildContext.Item, writer.ToString()); }
/// <summary> /// /// </summary> /// <param name="sourceStream"></param> /// <param name="targetStream"></param> public override void Process ( AssetSource assetFile, BuildContext context ) { string tempFileName = context.GetTempFileName( assetFile.KeyPath, ".fnt" ); string resolvedPath = assetFile.FullSourcePath; // Launch 'bmfont.com' with temporary output file : context.RunTool( @"bmfont.com", string.Format("-c \"{0}\" -o \"{1}\"", resolvedPath, tempFileName ) ); // load temporary output : SpriteFont.FontFile font; using ( var stream = File.OpenRead( tempFileName ) ) { font = SpriteFont.FontLoader.Load( stream ); } // perform some checks : if (font.Common.Pages!=1) { throw new BuildException("Only one page of font image is supported"); } // patch font description and add children (e.g. "secondary") content : using ( var stream = assetFile.OpenTargetStream() ) { using ( var sw = new BinaryWriter( stream ) ) { var xml = SpriteFont.FontLoader.SaveToString( font ); sw.Write( xml ); // write pages : foreach (var p in font.Pages) { var pageFile = Path.Combine( Path.GetDirectoryName( tempFileName ), p.File ); if ( Path.GetExtension( pageFile ).ToLower() == ".dds" ) { context.CopyFileTo( pageFile, sw ); } else { TextureProcessor.RunNVCompress( context, pageFile, pageFile + ".dds", true, false, false, true, true, false, TextureProcessor.TextureCompression.RGB ); context.CopyFileTo( pageFile + ".dds", sw ); } } } } }
/// <summary> /// /// </summary> /// <param name="sourceStream"></param> /// <param name="targetStream"></param> public override void Process ( AssetSource assetFile, BuildContext context ) { var mtrl = BaseIllum.ImportFromXml ( File.ReadAllText(assetFile.FullSourcePath) ); // get dependencies : var deps = mtrl.GetDependencies().ToArray(); var file = BaseIllum.ExportToXml(mtrl); using ( var target = assetFile.OpenTargetStream(deps) ) { using ( var bw = new BinaryWriter(target) ) { bw.Write(file); } } }
/// <summary> /// Builds asset /// </summary> /// <param name="buildContext"></param> public override void Build( BuildContext buildContext ) { string tempFileName = buildContext.GetTempFileName( AssetPath, ".fnt", false ); string tempFileNameR = buildContext.GetTempFileName( AssetPath, ".fnt", true ); string resolvedPath = buildContext.Resolve( SourcePath ); // Launch 'bmfont.com' with temporary output file : buildContext.RunTool( @"bmfont.com", string.Format("-c \"{0}\" -o \"{1}\"", resolvedPath, tempFileNameR ) ); // load temporary output : SpriteFont.FontFile font; using ( var stream = File.OpenRead( tempFileNameR ) ) { font = SpriteFont.FontLoader.Load( stream ); } // perform some checks : if (font.Common.Pages!=1) { throw new ContentException("Only one page of font image is supported"); } // patch font description and add children (e.g. "secondary") content : foreach (var p in font.Pages) { var newAssetPath = Path.Combine( AssetPath, "Page#" + p.ID.ToString() ); var newSrcPath = Path.Combine( Path.GetDirectoryName(tempFileName), p.File ); if ( Path.GetExtension( newSrcPath ).ToLower() == ".dds" ) { var asset = buildContext.AddAsset<RawFileAsset>( newAssetPath ); asset.SourceFile = newSrcPath; asset.BuildOrder = BuildOrder + 1; } else { var asset = buildContext.AddAsset<ImageFileTextureAsset>( newAssetPath ); asset.SourceFile = newSrcPath; asset.BuildOrder = BuildOrder + 1; } p.File = newAssetPath; } using ( var stream = buildContext.TargetStream( this ) ) { SpriteFont.FontLoader.Save( stream, font ); } }
public override Dictionary<string, FileOutput> Package( BuildContext buildContext, string projectId, Dictionary<string, ParseTree.Executable[]> finalCode, List<string> filesToCopyOver, ICollection<ParseTree.StructDefinition> structDefinitions, string inputFolder, SpriteSheetBuilder spriteSheet) { Dictionary<string, FileOutput> output = new Dictionary<string, FileOutput>(); List<string> concatenatedCode = new List<string>(); Dictionary<string, string> replacements = new Dictionary<string, string>() { { "PROJECT_ID", projectId }, }; concatenatedCode.Add(this.GetPyGameCode("Header.py", replacements)); concatenatedCode.Add(this.Translator.NL); concatenatedCode.Add(this.GetPyGameCode("AsyncHttpFetcher.py", replacements)); concatenatedCode.Add(this.Translator.NL); this.Translator.TranslateGlobals(concatenatedCode, finalCode); concatenatedCode.Add(this.Translator.NL); this.Translator.TranslateSwitchLookups(concatenatedCode, finalCode); concatenatedCode.Add(this.Translator.NL); this.Translator.TranslateFunctions(concatenatedCode, finalCode); concatenatedCode.Add(this.Translator.NL); concatenatedCode.Add(this.GetPyGameCode("Footer.py", replacements)); concatenatedCode.Add(this.Translator.NL); output["game.py"] = new FileOutput() { Type = FileOutputType.Text, TextContent = string.Join("", concatenatedCode) }; foreach (string file in filesToCopyOver) { output[file] = new FileOutput() { Type = FileOutputType.Copy, RelativeInputPath = file, }; } return output; }
/// <summary> /// /// </summary> /// <param name="buildContext"></param> /// <param name="src"></param> /// <param name="dst"></param> /// <param name="noMips"></param> /// <param name="fast"></param> /// <param name="toNormal"></param> /// <param name="color"></param> /// <param name="alpha"></param> /// <param name="normal"></param> /// <param name="compression"></param> internal static void RunNVCompress( BuildContext buildContext, string src, string dst, bool noMips, bool fast, bool toNormal, bool color, bool alpha, bool normal, TextureCompression compression ) { string commandLine = ""; if ( noMips ) commandLine += " -nomips" ; if ( fast ) commandLine += " -fast" ; if ( toNormal ) commandLine += " -tonormal"; if ( color ) commandLine += " -color" ; if ( alpha ) commandLine += " -alpha" ; if ( normal ) commandLine += " -normal" ; commandLine += ( " -" + compression.ToString().ToLower() ); commandLine += ( " \"" + src + "\"" ); commandLine += ( " \"" + dst + "\"" ); buildContext.RunTool( @"nvcompress.exe", commandLine );//*/ }
private static void EmbedFiles(BuildContext context) { var basePath = context.SourcePath; foreach (var virtualPath in context.SourceFolder.ListFiles(context.SourcePath, true)) { // skip ignores files if (IgnoreFile(virtualPath)) { continue; } // full virtual path given but we need the relative path so it can be put into // the package that way (the package itself is the logical base path). // Get it by stripping the basePath off including the slash. var relativePath = virtualPath.Replace(basePath, ""); EmbedVirtualFile(context, relativePath); } }
public override Dictionary<string, FileOutput> Package(BuildContext buildContext, string projectId, Dictionary<string, ParseTree.Executable[]> finalCode, List<string> filesToCopyOver, ICollection<ParseTree.StructDefinition> structDefinitions, string fileCopySourceRoot, SpriteSheetBuilder spriteSheet) { Dictionary<string, string> mainFile = new Dictionary<string, string>(); string nl = this.Translator.NL; List<string> structSection = new List<string>(); foreach (StructDefinition structDefinition in structDefinitions) { string name = structDefinition.Name.Value; structSection.Add("typedef struct " + name + " {"); for (int i = 0; i < structDefinition.Fields.Length; ++i) { string fieldName = structDefinition.FieldsByIndex[i]; Annotation type = structDefinition.Types[i]; string typeValue = ((StringConstant)type.Args[0]).Value; string typeString = this.GetTypeStringFromAnnotation(structDefinition.Fields[i], typeValue, false, false); structSection.Add("\t" + typeString + " " + fieldName + "; /* " + typeValue + " */"); } structSection.Add("} " + name + ";"); structSection.Add(""); } mainFile["structs"] = string.Join("\n", structSection); Dictionary<string, FileOutput> output = new Dictionary<string, FileOutput>(); List<string> mainC = new List<string>(); mainC.Add(Util.ReadFileInternally("Translator/COpenGL/Project/Header.c")); mainC.Add(mainFile["structs"]); mainC.Add(this.Translator.NL); this.Translator.TranslateGlobals(mainC, finalCode); mainC.Add(this.Translator.NL); this.Translator.TranslateFunctions(mainC, finalCode); mainC.Add(this.Translator.NL); mainC.Add(Util.ReadFileInternally("Translator/COpenGL/Project/Footer.c")); output["main.c"] = new FileOutput() { Type = FileOutputType.Text, TextContent = string.Join("", mainC) }; return output; }
public override void Build ( BuildContext buildContext ) { throw new NotImplementedException(); /* string tempFileName = Path.GetTempFileName(); var dir = Path.GetDirectoryName( item.ResolvedPath ); var names = File.ReadAllLines( item.ResolvedPath ); names = names.Select( n => Path.Combine( dir, n ) ).ToArray(); // Launch 'nvassemble.exe' with temporary output file : ContentProject.Instance.RunExternalTool( @"NVTT\nvassemble.exe", "-cube " + string.Join( " ", names ) ); File.Move( "output.dds", item.TargetPath ); */ }
/// <summary> /// Builds asset /// </summary> /// <param name="buildContext"></param> public override void Build ( BuildContext buildContext ) { var resolvedPath = buildContext.Resolve( SourceFile ); var destPath = buildContext.GetTempFileName( Hash, ".scene" ); var cmdLine = string.Format("\"{0}\" /out:\"{1}\" /merge:{2} {4} {5}", resolvedPath, destPath, MergeTolerance, null, ImportAnimation ? "/anim":"", ImportGeometry ? "/geom":"" ); buildContext.RunTool( "Native.Fbx.exe", cmdLine ); using ( var target = buildContext.OpenTargetStream( this ) ) { buildContext.CopyTo( destPath, target ); } }
public override bool IsCompatible(BuildContext context, IAbstractTypeBuilder typeBuilder) { if (context.IsBuildStep) return false; var list = new AbstractTypeBuilderList(2) { this, typeBuilder }; var step = context.Step; try { context.Step = BuildStep.Build; return typeBuilder.IsApplied(context, list); } finally { context.Step = step; } }
public DocumentMapping Build(Type type) { var documentMapping = new DocumentMapping(type) { Boost = GetBoost(type), IndexName = AttributeUtil.GetAttribute<IndexedAttribute>(type).Index }; var context = new BuildContext { Root = documentMapping, Processed = { type } }; BuildClass(documentMapping, true, string.Empty, context); BuildFilterDefinitions(documentMapping); return documentMapping; }
public void BlogActiveRecord() { InitKernel(); IActiveRecordDescriptorBuilder arbuilder = ObtainService(); TableDefinition blogTable; TableDefinition postTable; BuildBlogPostsStructure(out blogTable, out postTable); BuildContext context = new BuildContext(); ActiveRecordDescriptor desc = arbuilder.Build( blogTable, context ); Assert.IsNotNull(desc); Assert.AreEqual( "Blog", desc.ClassName ); Assert.AreEqual( 2, desc.Properties.Count ); Assert.AreEqual( 1, desc.PropertiesRelations.Count ); }
private Stream BuildPackage(ExtensionDescriptor extensionDescriptor) { var context = new BuildContext(); BeginPackage(context); try { EstablishPaths(context, _webSiteFolder, extensionDescriptor.Location, extensionDescriptor.Id, extensionDescriptor.ExtensionType); SetCoreProperties(context, extensionDescriptor); EmbedFiles(context); } finally { EndPackage(context); } if (context.Stream.CanSeek) { context.Stream.Seek(0, SeekOrigin.Begin); } return context.Stream; }
/// <summary> /// /// </summary> /// <param name="sourceStream"></param> /// <param name="targetStream"></param> public override void Process ( AssetSource assetFile, BuildContext context ) { var resolvedPath = assetFile.FullSourcePath; var destPath = context.GetTempFileName( assetFile.KeyPath, ".scene" ); var cmdLine = string.Format("\"{0}\" /out:\"{1}\" /base:\"{2}\" /merge:{3} {4} {5} {6} {7}", resolvedPath, destPath, assetFile.BaseDirectory, MergeTolerance, ImportAnimation ? "/anim":"", ImportGeometry ? "/geom":"", OutputReport ? "/report":"" , GenerateMissingMaterials ? "/genmtrl":"" ); context.RunTool( "FScene.exe", cmdLine ); using ( var target = assetFile.OpenTargetStream() ) { context.CopyFileTo( destPath, target ); } }
protected AxisDirection getDirection(BuildContext context) { return(LayoutUtils.getAxisDirectionFromAxisReverseAndDirectionality( context, this.scrollDirection, this.reverse)); }
protected abstract List <Widget> buildSlivers(BuildContext context);
public override bool IsCompatible(BuildContext context, IAbstractTypeBuilder typeBuilder) { return(true); }
public override Widget build(BuildContext context) { if (this.bloggerIds == null || this.userDict.isEmpty() || !this.userDict.ContainsKey(this.bloggerIds[0])) { return(new Container()); } Widget firstAvatar; if (this.bloggerIds.Count > 0) { var user = this.userDict[this.bloggerIds[0]]; firstAvatar = this._buildAvatar(user: user, "image/blogger-badge1", 88, true); } else { firstAvatar = new Container(); } Widget secondAvatar; if (this.bloggerIds.Count > 1) { var user = this.userDict[this.bloggerIds[1]]; secondAvatar = this._buildAvatar(user: user, "image/blogger-badge2"); } else { secondAvatar = new Container(); } Widget thirdAvatar; if (this.bloggerIds.Count > 2) { var user = this.userDict[this.bloggerIds[2]]; thirdAvatar = this._buildAvatar(user: user, "image/blogger-badge3"); } else { thirdAvatar = new Container(); } return(new Container( height: 286, padding: EdgeInsets.symmetric(horizontal: 16), child: new Row( children: new List <Widget> { new Expanded( flex: 11, child: new Column( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.center, children: new List <Widget> { new Container( margin: EdgeInsets.only(bottom: 24), child: secondAvatar ), Image.asset("image/leaderboard-podium-2") } ) ), new Expanded( flex: 12, child: new Column( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.center, children: new List <Widget> { new Container( margin: EdgeInsets.only(bottom: 24), child: firstAvatar ), Image.asset("image/leaderboard-podium-1") } ) ), new Expanded( flex: 11, child: new Column( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.center, children: new List <Widget> { new Container( margin: EdgeInsets.only(bottom: 24), child: thirdAvatar ), Image.asset("image/leaderboard-podium-3") } ) ) } ) )); }
public override Widget build(BuildContext context) { Color numColor = this.index + 1 <= 3 ? CColors.Error : CColors.TextBody5; var title = this.column.resetTitle.isNotEmpty() ? this.column.resetTitle : $"{this.user.fullName}的专栏"; var images = new List <string>(); this.userArticle.list.ForEach(article => { images.Add(item: article.thumbnail.url); }); return(new GestureDetector( onTap: this.onPress, child: new Container( padding: EdgeInsets.all(16), color: CColors.White, height: 112, child: new Row( crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Text( $"{this.index + 1}", style: new TextStyle( height: 1.27f, fontSize: 20, fontFamily: "Roboto-Bold", color: numColor ) ), new SizedBox(width: 16), new Expanded( child: new Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Text( data: title, maxLines: 2, overflow: TextOverflow.ellipsis, style: CTextStyle.PXLargeMediumBody ), new Row( children: new List <Widget> { new Flexible( child: new Text( $"{this.user.fullName}", style: CTextStyle.PSmallBody4, maxLines: 1, overflow: TextOverflow.ellipsis ) ), new Text( $" • 文章 {this.userArticle.total}", style: CTextStyle.PSmallBody4 ) } ) } ) ), new SizedBox(width: 16), new CoverImages( images: images, horizontalGap: 8, verticalGap: 0 ) } ) ) )); }
public CustomizerInfoImpl(BuildContext context) { Context = context; new NPath(WorkingDirectory).MakeAbsolute().EnsureDirectoryExists(); }
internal static Dictionary <object, _HeroState> _allHeroesFor( BuildContext context, bool isUserGestureTransition, NavigatorState navigator) { D.assert(context != null); D.assert(navigator != null); Dictionary <object, _HeroState> result = new Dictionary <object, _HeroState> { }; void inviteHero(StatefulElement hero, object tag) { D.assert(() => { if (result.ContainsKey(tag)) { throw new UIWidgetsError( new List <DiagnosticsNode>() { new ErrorSummary("There are multiple heroes that share the same tag within a subtree."), new ErrorDescription( "Within each subtree for which heroes are to be animated (i.e. a PageRoute subtree), " + "each Hero must have a unique non-null tag.\n" + $"In this case, multiple heroes had the following tag: {tag}\n" ), new DiagnosticsProperty <StatefulElement>("Here is the subtree for one of the offending heroes", hero, linePrefix: "# ", style: DiagnosticsTreeStyle.dense), }); } return(true); }); Hero heroWidget = hero.widget as Hero; _HeroState heroState = hero.state as _HeroState; if (!isUserGestureTransition || heroWidget.transitionOnUserGestures) { result[tag] = heroState; } else { heroState.ensurePlaceholderIsHidden(); } } void visitor(Element element) { Widget widget = element.widget; if (widget is Hero) { StatefulElement hero = element as StatefulElement; object tag = ((Hero)widget).tag; D.assert(tag != null); if (Navigator.of(hero) == navigator) { inviteHero(hero, tag); } else { ModalRoute heroRoute = ModalRoute.of(hero); if (heroRoute != null && heroRoute is PageRoute && heroRoute.isCurrent) { inviteHero(hero, tag); } } } element.visitChildren(visitor); } context.visitChildElements(visitor); return(result); }
/// <summary> /// Extracts pipeline states /// </summary> /// <param name="buildContext"></param> /// <param name="include"></param> /// <param name="shaderSource"></param> /// <param name="defines"></param> /// <returns></returns> KeyValuePair<string,string>[] ExtractPipelineStates ( BuildContext buildContext, Include include, string shaderSource, string sourceFile, string defines, string listing ) { defines = defines + " _UBERSHADER"; var defs = defines.Split(new[]{' ','\t'}, StringSplitOptions.RemoveEmptyEntries) .Select( entry => new SharpDX.Direct3D.ShaderMacro( entry, "1" ) ) .ToArray(); string errors = null; var preprocessed = FX.ShaderBytecode.Preprocess( shaderSource, defs, include, out errors, sourceFile ); var stateList = new List<KeyValuePair<string,string>>(); using ( var sr = new StringReader(preprocessed) ) { while (true) { var line = sr.ReadLine(); if (line==null) { break; } line = line.Trim(); if (line.StartsWith("$")) { var words = line.Split(new[]{' ','\t'}, StringSplitOptions.RemoveEmptyEntries ); if (words.Contains("ubershader")) { continue; } if (words.Length==2) { stateList.Add( new KeyValuePair<string,string>( words[1], "" ) ); } else if (words.Length==3) { stateList.Add( new KeyValuePair<string,string>( words[1], words[2] ) ); } else { Log.Warning("Bad ubershader $-statement: {0}", line); } } } } stateList = stateList .DistinctBy( s0 => s0.Key ) .ToList(); var html = "<pre>" + "<b>Pipeline States:</b>\r\n\r\n" + string.Join("\r\n", stateList.Select( s => string.Format("{0,-20} = <i>{1}</i>", s.Key, s.Value ) ) ) + "</pre>"; File.WriteAllText( listing, html ); return stateList.ToArray(); }
/// <summary> /// /// </summary> /// <param name="sourceFile"></param> /// <param name="profile"></param> /// <param name="entryPoint"></param> /// <param name="defines"></param> /// <returns></returns> byte[] RunFxc ( BuildContext buildContext, string sourceFile, string profile, string entryPoint, string defines, string output, string listing ) { StringBuilder sb = new StringBuilder(); sb.Append("/Cc" + " "); sb.Append("/T" + profile + " "); sb.Append("/E" + entryPoint + " "); sb.Append("/Fo\"" + output + "\" "); sb.Append("/Fc\"" + listing + "\" "); sb.Append("/nologo" + " "); sb.Append("/O" + OptimizationLevel.ToString() + " "); if ( DisableOptimization) sb.Append("/Od "); if ( PreferFlowControl) sb.Append("/Gfp "); if ( AvoidFlowControl) sb.Append("/Gfa "); if ( MatrixPacking==ShaderMatrixPacking.ColumnMajor ) sb.Append("/Zpc "); if ( MatrixPacking==ShaderMatrixPacking.RowMajor ) sb.Append("/Zpr "); foreach ( var def in defines.Split(new[]{' ','\t'}, StringSplitOptions.RemoveEmptyEntries) ) { sb.AppendFormat("/D{0}=1 ", def); } sb.Append("\"" + sourceFile + "\""); try { buildContext.RunTool("fxc_1.exe", sb.ToString()); } catch ( ToolException tx ) { /// entry point not fount - that is ok. if (tx.Message.Contains("error X3501")) { Log.Debug("No entry point '{0}'. That is ok.", entryPoint ); return new byte[0]; } throw; } return File.ReadAllBytes( output ); }
public override Widget build(BuildContext context) { return(new Icon(_getIconData(Theme.of(context).platform))); }
public override Widget build(BuildContext context) { var card = new Container( margin: EdgeInsets.only(right: 45), child: new Container( child: new Column( children: new List <Widget> { new Container( decoration: new BoxDecoration( color: CLColors.white, borderRadius: BorderRadius.only(topLeft: 3, topRight: 3) ), width: 200, height: 124, child: Image.network( this.imageSrc, fit: BoxFit.fill ) ), new Container( color: CLColors.white, width: 200, height: 86, padding: EdgeInsets.fromLTRB(14, 12, 14, 8), child: new Column( crossAxisAlignment: CrossAxisAlignment.baseline, children: new List <Widget> { new Container( height: 18, padding: EdgeInsets.only(top: 3), child: new Text(this.category, style: new TextStyle( fontSize: 11, color: CLColors.text5 ) ) ), new Container( height: 20, padding: EdgeInsets.only(top: 2), child: new Text(this.name, style: new TextStyle( fontSize: 14, color: CLColors.text6 ) ) ), new Container( height: 22, padding: EdgeInsets.only(top: 4), child: new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: new List <Widget> { new Container( child: new Row( children: new List <Widget> { new Container( margin: EdgeInsets.only(right: 10), child: new Text( "$" + this.price, style: new TextStyle( fontSize: 14, color: CLColors.text7, decoration: TextDecoration.lineThrough ) ) ), new Container( child: new Text( "$" + this.priceDiscount, style: new TextStyle( fontSize: 14, color: CLColors.text8 ) ) ) }) ), this.showBadge ? new Container( width: 80, height: 18, color: CLColors.black, child: new Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: new List <Widget> { new Text( "Plus/Pro", style: new TextStyle( fontSize: 11, color: CLColors.white ) ) } ) ) : new Container() } ) ) } ) ) } ) ) ); return(card); }
Widget _buildMiddleView(BuildContext context) { return(new Container( padding: EdgeInsets.symmetric(horizontal: 16), child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Container(height: 32), new Container( child: new Text( "邮箱", style: CTextStyle.PMediumBody4 ) ), new Container( height: 46, decoration: new BoxDecoration( CColors.Transparent, border: new Border( bottom: new BorderSide( this._isEmailFocus ? CColors.PrimaryBlue : CColors.Separator, this._isEmailFocus ? 2 : 1 ) ) ), alignment: Alignment.center, child: new InputField( focusNode: this._emailFocusNode, maxLines: 1, autofocus: true, enabled: !this.widget.viewModel.loginLoading, style: CTextStyle.PLargeBody, cursorColor: CColors.PrimaryBlue, clearButtonMode: InputFieldClearButtonMode.whileEditing, keyboardType: TextInputType.emailAddress, onChanged: text => this.widget.actionModel.changeEmail(text), onSubmitted: _ => { if (null == this._focusScopeNode) { this._focusScopeNode = FocusScope.of(context); } this._focusScopeNode.requestFocus(this._passwordFocusNode); } ) ), new Container(height: 16), new Container( child: new Text( "密码", style: CTextStyle.PMediumBody4 ) ), new Container( height: 46, decoration: new BoxDecoration( CColors.Transparent, border: new Border( bottom: new BorderSide( this._isPasswordFocus ? CColors.PrimaryBlue : CColors.Separator, this._isPasswordFocus ? 2 : 1 ) ) ), alignment: Alignment.center, child: new InputField( focusNode: this._passwordFocusNode, maxLines: 1, autofocus: false, obscureText: true, enabled: !this.widget.viewModel.loginLoading, style: CTextStyle.PLargeBody, cursorColor: CColors.PrimaryBlue, clearButtonMode: InputFieldClearButtonMode.whileEditing, onChanged: text => this.widget.actionModel.changePassword(text), onSubmitted: _ => this._login() ) ) } ) )); }
protected abstract Widget buildChildLayout(BuildContext context);
public override void Build(BuildContext context) { Context = context; if (string.IsNullOrEmpty(_methodName)) { FieldBuilder type = Context.CreatePrivateStaticField( "_type$ClearCacheAspect$" + ++_methodCounter, typeof(Type)); EmitHelper emit = Context.MethodBuilder.Emitter; Label checkType = emit.DefineLabel(); emit .ldsfld(type) .brtrue_s(checkType) .ldarg_0 .LoadType(_declaringType) .call(typeof(ClearCacheAspect), "GetType", typeof(object), typeof(Type)) .stsfld(type) .MarkLabel(checkType) .ldsfld(type) .call(typeof(CacheAspect), "ClearCache", typeof(Type)) ; } else { FieldBuilder methodInfo = Context.CreatePrivateStaticField( "_methodInfo$ClearCacheAspect$" + ++_methodCounter, typeof(MethodInfo)); EmitHelper emit = Context.MethodBuilder.Emitter; Label checkMethodInfo = emit.DefineLabel(); emit .ldsfld(methodInfo) .brtrue_s(checkMethodInfo) .ldarg_0 .LoadType(_declaringType) .ldstrEx(_methodName) ; if (_parameterTypes == null || _parameterTypes.Length == 0) { emit.ldnull.end(); } else { LocalBuilder field = emit.DeclareLocal(typeof(Type[])); emit .ldc_i4_(_parameterTypes.Length) .newarr(typeof(Type)) .stloc(field) ; for (int i = 0; i < _parameterTypes.Length; i++) { emit .ldloc(field) .ldc_i4(i) .LoadType(_parameterTypes[i]) .stelem_ref .end() ; } emit.ldloc(field); } emit .call(typeof(ClearCacheAspect), "GetMethodInfo", typeof(object), typeof(Type), typeof(string), typeof(Type[])) .stsfld(methodInfo) .MarkLabel(checkMethodInfo) .ldsfld(methodInfo) .call(typeof(CacheAspect), "ClearCache", typeof(MethodInfo)) ; } }
protected override List <Widget> buildSlivers(BuildContext context) { return(this.slivers); }
public override Widget build(BuildContext context) { List <MergeableMaterialItem> items = new List <MergeableMaterialItem>(); EdgeInsets kExpandedEdgeInsets = EdgeInsets.symmetric( vertical: ExpansionPanelUtils._kPanelHeaderExpandedHeight - ExpansionPanelUtils._kPanelHeaderCollapsedHeight); for (int index = 0; index < this.widget.children.Count; index++) { int expandIndex = index; if (this._isChildExpanded(index) && index != 0 && !this._isChildExpanded(index - 1)) { items.Add(new MaterialGap( key: new _SaltedKey <BuildContext, int>(context, index * 2 - 1))); } ExpansionPanel child = this.widget.children[index]; Row header = new Row( children: new List <Widget> { new Expanded( child: new AnimatedContainer( duration: this.widget.animationDuration, curve: Curves.fastOutSlowIn, margin: this._isChildExpanded(index) ? kExpandedEdgeInsets : EdgeInsets.zero, child: new ConstrainedBox( constraints: new BoxConstraints( minHeight: ExpansionPanelUtils._kPanelHeaderCollapsedHeight), child: child.headerBuilder( context, this._isChildExpanded(index)) ) ) ), new Container( margin: EdgeInsets.fromLTRB(0, 0, 8, 0), child: new ExpandIcon( isExpanded: this._isChildExpanded(index), padding: EdgeInsets.all(16.0f), onPressed: (bool isExpanded) => this._handlePressed(isExpanded, expandIndex) ) ) } ); items.Add(new MaterialSlice( key: new _SaltedKey <BuildContext, int>(context, index * 2), child: new Column( children: new List <Widget> { header, new AnimatedCrossFade( firstChild: new Container(height: 0.0f), secondChild: child.body, firstCurve: new Interval(0.0f, 0.6f, curve: Curves.fastOutSlowIn), secondCurve: new Interval(0.4f, 1.0f, curve: Curves.fastOutSlowIn), sizeCurve: Curves.fastOutSlowIn, crossFadeState: this._isChildExpanded(index) ? CrossFadeState.showSecond : CrossFadeState.showFirst, duration: this.widget.animationDuration ) } ) ) ); if (this._isChildExpanded(index) && index != this.widget.children.Count - 1) { items.Add(new MaterialGap( key: new _SaltedKey <BuildContext, int>(context, index * 2 + 1))); } } return(new MergeableMaterial( hasDividers: true, children: items)); }
public override Widget build(BuildContext buildContext) { var children = new List <Widget> { new Expanded( child: new Container( decoration: new BoxDecoration( border: new Border( left: new BorderSide( width: 2f, color: widget._level > 1 ? IconColor : NormalColor ) ) ), margin: EdgeInsets.only( left: 32f + 16f * widget._level ), padding: EdgeInsets.only( top: 8f, bottom: 8f ), child: new Container( margin: EdgeInsets.only(left: 14f), child: new Text( widget._bind.title, style: new TextStyle( fontSize: 16f, height: 1.5f.LineHeight(), color: new Color(0xff616161) ) ) ) ) ), }; if (widget._hasChildren) { children.Add(new GestureDetector( onTap: OnExpandTap, child: new Container( child: new Icon( Icons.MaterialExpandMore, color: IconColor, size: 24f ) ) ) ); } Color color; if (widget._active) { color = ActiveColor; } else if (_hover) { color = HoverColor; } else { color = NormalColor; } var self = new Listener( onPointerEnter: OnPointerEnter, onPointerExit: OnPointerExit, child: new GestureDetector( onTap: OnTap, child: new Container( color: color, padding: EdgeInsets.only(right: 16f), child: new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: children ) ) ) ); return(self); }
bool _onNotification(ScrollNotification notification, BuildContext context) { return(true); }
public override Widget build(BuildContext context) { return(this.widget.builder(context, this.latestValue, this.widget.store.dispatcher)); }
Widget _buildHeader(BuildContext context) { var container = new Container( padding: EdgeInsets.only(left: 16.0f, right: 8.0f), height: headerHeight, color: CLColors.header, child: new Row( mainAxisAlignment: MainAxisAlignment.center, children: new List <Widget> { new Container( child: new Text( "All Assets", style: new TextStyle( fontSize: 16, color: Color.fromARGB(100, 255, 255, 0) ) ) ), new CustomButton( padding: EdgeInsets.only(0.0f, 0.0f, 16.0f, 0.0f), child: new Icon( Icons.keyboard_arrow_down, size: 18.0f, color: CLColors.icon2 ) ), new Container( decoration: new BoxDecoration( color: CLColors.white, borderRadius: BorderRadius.all(3) ), width: 320, height: 36, padding: EdgeInsets.all(10.0f), margin: EdgeInsets.only(right: 4), child: new EditableText( maxLines: 1, selectionControls: MaterialUtils.materialTextSelectionControls, controller: new TextEditingController("Type here to search assets"), focusNode: new FocusNode(), style: new TextStyle( fontSize: 16 ), selectionColor: Color.fromARGB(255, 255, 0, 0), cursorColor: Color.fromARGB(255, 0, 0, 0) ) ), new Container( decoration: new BoxDecoration( color: CLColors.background4, borderRadius: BorderRadius.all(2) ), width: 36, height: 36, child: new Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: new List <Widget> { new CustomButton( padding: EdgeInsets.only(8.0f, 0.0f, 8.0f, 0.0f), child: new Icon( Icons.search, size: 18.0f, color: CLColors.white ) ) } ) ), new Container( margin: EdgeInsets.only(left: 16, right: 16), child: new Text( "Learn Game Development", style: new TextStyle( fontSize: 12, color: CLColors.white ) ) ), new Container( decoration: new BoxDecoration( border: Border.all( color: CLColors.white ) ), margin: EdgeInsets.only(right: 16), padding: EdgeInsets.all(4), child: new Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: new List <Widget> { new Text( "Plus/Pro", style: new TextStyle( fontSize: 11, color: CLColors.white ) ) } ) ), new Container( margin: EdgeInsets.only(right: 16), child: new Text( "Impressive New Assets", style: new TextStyle( fontSize: 12, color: CLColors.white ) ) ), new Container( child: new Text( "Shop On Old Store", style: new TextStyle( fontSize: 12, color: CLColors.white ) ) ), } ) ); return(container); }
public override Widget build(BuildContext context) { Widget titleWidget; if (this.blogger.title.isNotEmpty()) { titleWidget = new Text( data: this.blogger.title, maxLines: 1, overflow: TextOverflow.ellipsis, style: CTextStyle.PRegularBody4 ); } else { titleWidget = new Container(); } return(new GestureDetector( onTap: this.onPress, child: new Container( padding: EdgeInsets.all(16), color: CColors.White, height: 88, child: new Row( children: new List <Widget> { new Text( $"{this.index + 1}", style: new TextStyle( height: 1.27f, fontSize: 20, fontFamily: "Roboto-Bold", color: CColors.TextBody5 ) ), new Padding( padding: EdgeInsets.symmetric(horizontal: 16), child: Avatar.User(user: this.blogger, 56) ), new Expanded( child: new Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Text( data: this.blogger.fullName, maxLines: 1, overflow: TextOverflow.ellipsis, style: new TextStyle( height: 1.33f, fontSize: 16, fontFamily: "Roboto-Medium", color: CColors.TextBody ) ), titleWidget } ) ), new Padding( padding: EdgeInsets.only(16), child: new Text( $"文章 {this.blogger.articleCount ?? 0} • 赞 {this.blogger.likeCount ?? 0}", style: CTextStyle.PSmallBody4 ) ) } ) ) )); }
public override Widget build(BuildContext context) { base.build(context); // See AutomaticKeepAliveClientMixin. D.assert(!this._directionIsXAxis || WidgetsD.debugCheckHasDirectionality(context)); Widget background = this.widget.background; if (this.widget.secondaryBackground != null) { DismissDirection?direction = this._dismissDirection; if (direction == DismissDirection.endToStart || direction == DismissDirection.up) { background = this.widget.secondaryBackground; } } if (this._resizeAnimation != null) { // we've been dragged aside, and are now resizing. D.assert(() => { if (this._resizeAnimation.status != AnimationStatus.forward) { D.assert(this._resizeAnimation.status == AnimationStatus.completed); throw new UIWidgetsError( "A dismissed Dismissible widget is still part of the tree.\n" + "Make sure to implement the onDismissed handler and to immediately remove the Dismissible\n" + "widget from the application once that handler has fired." ); } return(true); }); return(new SizeTransition( sizeFactor: this._resizeAnimation, axis: this._directionIsXAxis ? Axis.vertical : Axis.horizontal, child: new SizedBox( width: this._sizePriorToCollapse.width, height: this._sizePriorToCollapse.height, child: background ) )); } Widget content = new SlideTransition( position: this._moveAnimation, child: this.widget.child ); if (background != null) { List <Widget> children = new List <Widget> { }; if (!this._moveAnimation.isDismissed) { children.Add(Positioned.fill( child: new ClipRect( clipper: new _DismissibleClipper( axis: this._directionIsXAxis ? Axis.horizontal : Axis.vertical, moveAnimation: this._moveAnimation ), child: background ) )); } children.Add(content); content = new Stack(children: children); } return(new GestureDetector( onHorizontalDragStart: this._directionIsXAxis ? (GestureDragStartCallback)this._handleDragStart : null, onHorizontalDragUpdate: this._directionIsXAxis ? (GestureDragUpdateCallback)this._handleDragUpdate : null, onHorizontalDragEnd: this._directionIsXAxis ? (GestureDragEndCallback)this._handleDragEnd : null, onVerticalDragStart: this._directionIsXAxis ? null : (GestureDragStartCallback)this._handleDragStart, onVerticalDragUpdate: this._directionIsXAxis ? null : (GestureDragUpdateCallback)this._handleDragUpdate, onVerticalDragEnd: this._directionIsXAxis ? null : (GestureDragEndCallback)this._handleDragEnd, behavior: HitTestBehavior.opaque, child: content, dragStartBehavior: this.widget.dragStartBehavior )); }
public static ResourceDatabase CreateResourceDatabase(BuildContext buildContext) { using (new PerformanceSection("ResourceDatabaseBuilder.CreateResourceDatabase")) { ResourceDatabase resDb = new ResourceDatabase(); foreach (FilePath sourceRoot in buildContext.SourceFolders) { string[] relativePaths = FileUtil.GetAllFilePathsRelativeToRoot(sourceRoot.AbsolutePath); // Everything is just a basic copy resource at first. foreach (string relativeFilePath in relativePaths) { string absolutePath = FileUtil.GetCanonicalizeUniversalPath(sourceRoot.AbsolutePath + "/" + relativeFilePath); string aliasedPath = sourceRoot.GetAliasedOrRelativePathh(absolutePath); string fileName = FileUtil.GetFileNameFromPath(absolutePath); string extension = FileUtil.GetCanonicalExtension(fileName) ?? ""; ResourceDatabase.FileCategory category; if (IGNORABLE_FILES.Contains(fileName.ToLowerInvariant())) { // Common system generated files that no one would ever want. category = ResourceDatabase.FileCategory.IGNORE_SILENT; } else if (ResourceDatabase.KNOWN_FILE_EXTENSIONS.ContainsKey(extension)) { category = ResourceDatabase.KNOWN_FILE_EXTENSIONS[extension]; } else { TODO.BuildFileShouldIndicateWhichResourcesAreTextVsBinary(); category = ResourceDatabase.FileCategory.TEXT; } switch (category) { case ResourceDatabase.FileCategory.IGNORE_SILENT: break; case ResourceDatabase.FileCategory.IGNORE_IMAGE: System.Console.WriteLine(aliasedPath + " is not a usable image type and is being ignored. Consider converting to PNG or JPEG."); break; case ResourceDatabase.FileCategory.IGNORE_AUDIO: System.Console.WriteLine(aliasedPath + " is not a usable audio format and is being ignored. Consider converting to OGG."); break; case ResourceDatabase.FileCategory.IGNORE_IMAGE_ASSET: System.Console.WriteLine(aliasedPath + " is an image asset container file type and is being ignored. Consider moving original assets outside of the source folder."); break; case ResourceDatabase.FileCategory.AUDIO: resDb.AudioResources.Add(new FileOutput() { Type = FileOutputType.Copy, RelativeInputPath = aliasedPath, OriginalPath = aliasedPath, AbsoluteInputPath = absolutePath, }); break; case ResourceDatabase.FileCategory.BINARY: resDb.AudioResources.Add(new FileOutput() { Type = FileOutputType.Copy, RelativeInputPath = aliasedPath, OriginalPath = aliasedPath, AbsoluteInputPath = absolutePath, }); break; case ResourceDatabase.FileCategory.TEXT: string content = FileUtil.ReadFileText(absolutePath); resDb.TextResources.Add(new FileOutput() { Type = FileOutputType.Text, TextContent = content, OriginalPath = aliasedPath, AbsoluteInputPath = absolutePath, }); break; case ResourceDatabase.FileCategory.IMAGE: TODO.GetImageDimensionsFromFirstFewBytesInsteadOfLoadingIntoMemory(); if (extension == "png") { // Re-encode PNGs into a common format/palette configuration since there are some issues // with obscure format PNGs on some platforms. Luckily the compiler is pretty good with // reading these. Besides, you're going to be opening most of these files anyway since // the user should be using image sheets. resDb.ImageResources.Add(new FileOutput() { Type = FileOutputType.Image, Bitmap = new SystemBitmap(absolutePath), OriginalPath = aliasedPath, AbsoluteInputPath = absolutePath, }); } else if (extension == "jpg" || extension == "jpeg") { resDb.ImageResources.Add(new FileOutput() { Type = FileOutputType.Image, Bitmap = new SystemBitmap(absolutePath), OriginalPath = aliasedPath, AbsoluteInputPath = absolutePath, IsLossy = true, }); } else { TODO.PutImageWidthAndHeightIntoFileOutputPropertiesSoThatBitmapDoesntNeedToBePersistedInMemory(); resDb.ImageResources.Add(new FileOutput() { Type = FileOutputType.Copy, Bitmap = new SystemBitmap(absolutePath), RelativeInputPath = aliasedPath, OriginalPath = aliasedPath, AbsoluteInputPath = absolutePath, }); } break; case ResourceDatabase.FileCategory.FONT: resDb.FontResources.Add(new FileOutput() { Type = FileOutputType.Copy, RelativeInputPath = aliasedPath, OriginalPath = aliasedPath, AbsoluteInputPath = absolutePath, }); break; default: throw new InvalidOperationException(); } } } return(resDb); } }
private static BuildResult RunBuildSteps(IReadOnlyList <BuildStep.IBuildStep> buildSteps, BuildContext context) { var result = true; var index = 1u; var timer = new Stopwatch(); var stats = new List <BuildStepStatistics>(); var startTime = DateTime.Now; for (var i = 0; i < buildSteps.Count && result; ++i) { var buildStep = buildSteps[i]; if (!buildStep.IsEnabled(context)) { continue; } context.ProgressBar.Update(buildStep.Description + "...", (float)i / buildSteps.Count); try { timer.Restart(); result = buildStep.Run(context); timer.Stop(); stats.Add(new BuildStepStatistics { Index = index++, Name = buildStep.Description, Duration = timer.Elapsed }); } catch (Exception exception) { Debug.LogError($"Build step '{buildStep.Description}' failed with exception: {exception}"); result = false; } } return(new BuildResult { Success = result, Target = context.TargetExeFile, Duration = DateTime.Now - startTime, Statistics = stats.AsReadOnly() }); }
public override Dictionary<string, FileOutput> Package( BuildContext buildContext, string projectId, Dictionary<string, ParseTree.Executable[]> finalCode, List<string> filesToCopyOver, ICollection<ParseTree.StructDefinition> structDefinitions, string inputFolder, SpriteSheetBuilder spriteSheet) { Dictionary<string, FileOutput> output = new Dictionary<string, FileOutput>(); string package = "com." + projectId.ToLowerInvariant() + ".app"; string pathToJavaCode = "app/src/main/java/" + package.Replace('.', '/'); Dictionary<string, string> replacements = new Dictionary<string, string>() { { "PROJECT_TITLE", projectId }, { "PROJECT_ID", projectId }, { "PACKAGE", package }, { "CURRENT_YEAR", DateTime.Now.Year.ToString() }, { "COPYRIGHT", "©" }, }; foreach (string simpleCopyText in new string[] { // Boilerplate Android project stuff "build.gradle|AndroidProject/Boilerplate/BuildGradle.txt", "gradle.properties|AndroidProject/Boilerplate/GradleProperties.txt", "gradlew|AndroidProject/Boilerplate/Gradlew.txt", "gradlew.bat|AndroidProject/Boilerplate/GradlewBat.txt", projectId + ".iml|AndroidProject/Boilerplate/ProjectIml.txt", "android.iml|AndroidProject/Boilerplate/AndroidIml.txt", "settings.gradle|AndroidProject/Boilerplate/SettingsGradle.txt", "gradle/wrapper/gradle-wrapper.jar|AndroidProject/Boilerplate/GradleWrapperJar", "gradle/wrapper/gradle-wrapper.properties|AndroidProject/Boilerplate/GradleWrapperProperties.txt", "app/app.iml|AndroidProject/Boilerplate/AppIml.txt", "app/build.gradle|AndroidProject/Boilerplate/AppBuildGradle.txt", "app/src/main/res/layout/activity_game.xml|AndroidProject/Boilerplate/ResLayoutActivityGameXml.txt", "app/src/main/res/values/attrs.xml|AndroidProject/Boilerplate/ResValuesAttrsXml.txt", "app/src/main/res/values/colors.xml|AndroidProject/Boilerplate/ResValuesColorsXml.txt", "app/src/main/res/values/strings.xml|AndroidProject/Boilerplate/ResValuesStringsXml.txt", "app/src/main/res/values/styles.xml|AndroidProject/Boilerplate/ResValuesStylesXml.txt", "app/src/main/res/values-v11/styles.xml|AndroidProject/Boilerplate/ResValuesV11StylesXml.txt", "app/src/main/res/drawable-hdpi/ic_launcher.png|AndroidProject/Boilerplate/ResDrawableHdpiIcLauncher.png", "app/src/main/res/drawable-mdpi/ic_launcher.png|AndroidProject/Boilerplate/ResDrawableMdpiIcLauncher.png", "app/src/main/res/drawable-xhdpi/ic_launcher.png|AndroidProject/Boilerplate/ResDrawableXhdpiIcLauncher.png", "app/src/main/res/drawable-xxhdpi/ic_launcher.png|AndroidProject/Boilerplate/ResDrawableXxhdpiIcLauncher.png", pathToJavaCode + "/util/SystemUiHider.java|AndroidProject/Boilerplate/JavaUtilSystemUiHider.txt", pathToJavaCode + "/util/SystemUiHiderBase.java|AndroidProject/Boilerplate/JavaUtilSystemUiHiderBase.txt", pathToJavaCode + "/util/SystemUiHiderHoneycomb.java|AndroidProject/Boilerplate/JavaUtilSystemUiHiderHoneycomb.txt", "app/src/main/AndroidManifest.xml|AndroidProject/Boilerplate/AndroidManifestXml.txt", "app/src/main/ic_launcher-web.png|AndroidProject/Boilerplate/IcLauncherWeb.png", ".idea/copyright/profiles_settings.xml|AndroidProject/Boilerplate/Idea/CopyrightProfilesSettingsXml.txt", ".idea/libraries/support_v4_18_0_0.xml|AndroidProject/Boilerplate/Idea/LibrariesSupportXml.txt", ".idea/scopes/scope_settings.xml|AndroidProject/Boilerplate/Idea/ScopeSettingsXml.txt", ".idea/.name|AndroidProject/Boilerplate/Idea/DotName.txt", ".idea/compiler.xml|AndroidProject/Boilerplate/Idea/CompilerXml.txt", ".idea/encodings.xml|AndroidProject/Boilerplate/Idea/EncodingsXml.txt", ".idea/gradle.xml|AndroidProject/Boilerplate/Idea/GradleXml.txt", ".idea/misc.xml|AndroidProject/Boilerplate/Idea/MiscXml.txt", ".idea/modules.xml|AndroidProject/Boilerplate/Idea/ModulesXml.txt", ".idea/vcs.xml|AndroidProject/Boilerplate/Idea/VcsXml.txt", ".idea/workspace.xml|AndroidProject/Boilerplate/Idea/WorkspaceXml.txt", // Crayon Android stuff pathToJavaCode + "/AndroidTranslationHelper.java|AndroidProject/AndroidTranslationHelper.txt", pathToJavaCode + "/GlUtil.java|AndroidProject/GlUtil.txt", pathToJavaCode + "/GameActivity.java|AndroidProject/GameActivity.txt", pathToJavaCode + "/OpenGlRenderer.java|AndroidProject/OpenGlRenderer.txt", pathToJavaCode + "/CrayonGlRenderer.java|AndroidProject/CrayonGlRenderer.txt", pathToJavaCode + "/CrayonGlSurfaceView.java|AndroidProject/CrayonGlSurfaceView.txt", // Generic Crayon Java stuff pathToJavaCode + "/AsyncMessageQueue.java|Project/AsyncMessageQueue.txt", pathToJavaCode + "/TranslationHelper.java|Project/TranslationHelper.txt", pathToJavaCode + "/Image.java|Project/Image.txt", pathToJavaCode + "/JsonParser.java|Project/JsonParser.txt", }) { string[] parts = simpleCopyText.Split('|'); string target = parts[0]; string source = parts[1]; bool isBinary = !source.EndsWith(".txt"); if (isBinary) { output[target] = new FileOutput() { Type = FileOutputType.Binary, BinaryContent = Util.ReadBytesInternally("Translator/Java/" + source) }; } else { string text = Util.ReadFileInternally("Translator/Java/" + source); output[target] = new FileOutput() { Type = FileOutputType.Text, TextContent = Constants.DoReplacements(text, replacements) }; } } foreach (string basicFile in new string[] { "AsyncMessageQueue", "TranslationHelper", //"Start", //"GameWindow", //"RenderEngine", "Image", "JsonParser" }) { output[pathToJavaCode + "/" + basicFile + ".java"] = new FileOutput() { Type = FileOutputType.Text, TextContent = Constants.DoReplacements( Util.ReadFileInternally("Translator/Java/Project/" + basicFile + ".txt"), replacements) }; } string[] items = finalCode.Keys.OrderBy<string, string>(s => s.ToLowerInvariant()).ToArray(); List<string> crayonWrapper = new List<string>(); crayonWrapper.Add(string.Join("\n", "package %%%PACKAGE%%%;", "", "import java.util.ArrayList;", "import java.util.HashMap;", "import java.util.Stack;", "", "final class CrayonWrapper {", " private CrayonWrapper() {}", "")); this.Translator.CurrentIndention++; foreach (string finalCodeKey in items) { this.Translator.Translate(crayonWrapper, finalCode[finalCodeKey]); } this.Translator.CurrentIndention--; crayonWrapper.Add(string.Join("\n", "}", "")); output[pathToJavaCode + "/CrayonWrapper.java"] = new FileOutput() { Type = FileOutputType.Text, TextContent = Constants.DoReplacements(string.Join("", crayonWrapper), replacements) }; string crayonHeader = string.Join(this.Translator.NL, new string[] { "package " + package + ";", "", "import java.util.ArrayList;", "import java.util.HashMap;", "import java.util.Stack;", "", "" }); string nl = this.Translator.NL; foreach (StructDefinition structDefinition in structDefinitions) { string structName = structDefinition.Name.Value; string filename = structName + ".java"; List<string> codeContents = new List<string>(); codeContents.Add("class " + structName + " {" + nl); codeContents.Add(" public " + structName + "("); List<string> types = new List<string>(); for (int i = 0; i < structDefinition.FieldsByIndex.Length; ++i) { string type; Annotation typeAnnotation = structDefinition.Types[i]; if (typeAnnotation == null) { throw new Exception("Are there any of these left?"); } else { type = this.GetTypeStringFromAnnotation(typeAnnotation.FirstToken, typeAnnotation.GetSingleArgAsString(null), false, false); } types.Add(type); if (i > 0) codeContents.Add(", "); codeContents.Add(type); codeContents.Add(" v_" + structDefinition.FieldsByIndex[i]); } codeContents.Add(") {" + nl); for (int i = 0; i < structDefinition.FieldsByIndex.Length; ++i) { codeContents.Add(" this." + structDefinition.FieldsByIndex[i] + " = v_" + structDefinition.FieldsByIndex[i] + ";" + nl); } codeContents.Add(" }" + nl + nl); for (int i = 0; i < structDefinition.FieldsByIndex.Length; ++i) { codeContents.Add(" public "); codeContents.Add(types[i]); codeContents.Add(" " + structDefinition.FieldsByIndex[i] + ";" + nl); } codeContents.Add("}" + nl); string fileContents = string.Join("", codeContents); string header = "package " + package + ";" + nl + nl; bool useList = fileContents.Contains("ArrayList<"); bool useHashMap = fileContents.Contains("HashMap<"); bool useStack = fileContents.Contains("Stack<"); if (useList || useHashMap || useStack) { if (useList) header += "import java.util.ArrayList;" + nl; if (useHashMap) header += "import java.util.HashMap;" + nl; if (useStack) header += "import java.util.Stack;" + nl; header += nl; } fileContents = header + fileContents; output[pathToJavaCode + "/" + filename] = new FileOutput() { Type = FileOutputType.Text, TextContent = fileContents }; output["app/src/main/res/bytecode/ByteCode.txt"] = new FileOutput() { Type = FileOutputType.Text, TextContent = this.Context.ByteCodeString }; } foreach (string file in filesToCopyOver) { System.Drawing.Bitmap bmpHack = null; if (file.ToLowerInvariant().EndsWith(".png")) { bmpHack = HackUtil.ReEncodePngImageForJava(System.IO.Path.Combine(inputFolder, file)); } if (bmpHack != null) { output["app/src/main/res/images/" + file] = new FileOutput() { Type = FileOutputType.Image, Bitmap = bmpHack }; } else { output["app/src/main/res/images/" + file] = new FileOutput() { Type = FileOutputType.Copy, RelativeInputPath = file }; } } output["app/src/main/res/raw/bytes.txt"] = new FileOutput() { Type = FileOutputType.Text, TextContent = this.Context.ByteCodeString }; return output; }
public override int GetPriority(BuildContext context) { return(TypeBuilderConsts.Priority.ClearCacheAspect); }
public override RenderObject createRenderObject(BuildContext context) { return(new RenderAnnotatedRegion <T>(value: value, sized: sized)); }
public override Widget build(BuildContext context) { return(this.widget.builder(context, this.latestValue)); }
protected override bool OnExecute(BuildContext context) { bool processResult = false; if (String.IsNullOrEmpty(this.Application) && String.IsNullOrEmpty(this.Arguments)) { if (String.IsNullOrEmpty(_projectFile) || File.Exists(_projectFile) == false) { return(processResult); } } BuildLogger logger = context.Logger; try { if (String.IsNullOrEmpty(_projectFile) || File.Exists(_projectFile) == false) { processResult = this.Run(logger); } else { HxComp hxsCompiler = new HxComp(); hxsCompiler.Initialize(); HxCompError compilerError = new HxCompError(logger, this.Verbosity); compilerError.Attach(hxsCompiler); hxsCompiler.Compile(_projectFile, Path.GetDirectoryName(_projectFile), null, 0); compilerError.Detach(hxsCompiler); hxsCompiler = null; processResult = compilerError.IsSuccess; } if (!processResult) { return(processResult); } } catch (ArgumentException) { // If the COM server compiler fails, run the command line version... processResult = this.Run(logger); if (!processResult) { return(processResult); } } catch (Exception ex) { if (logger != null) { logger.WriteLine(ex, BuildLoggerLevel.Error); } return(false); } // If the help is successfully compiled, then... // 1. Copy the compiled help files to the output folder... string workingDir = this.WorkingDirectory; if (!Directory.Exists(_helpDirectory)) { Directory.CreateDirectory(_helpDirectory); } // If we need to keep the help sources, then just copy everything to // the output folder... string helpOutput = Path.Combine(_helpDirectory, _helpFolder); if (_keepSources) { string compiledDir = Path.Combine(workingDir, _helpFolder); if (!Directory.Exists(compiledDir)) { return(processResult); } if (Directory.Exists(helpOutput)) { DirectoryUtils.DeleteDirectory(helpOutput, true); } Directory.Move(compiledDir, helpOutput); string destHelpPath = Path.Combine(helpOutput, _helpName + ".HxS"); context.AddOutput(BuildFormatType.HtmlHelp2, destHelpPath); } else //...otherwise, just copy the essentials... { if (!Directory.Exists(helpOutput)) { Directory.CreateDirectory(helpOutput); } string sourceHelpPath = Path.Combine(workingDir, String.Format(@"{0}\{1}.HxS", _helpFolder, _helpName)); string destHelpPath = Path.Combine(helpOutput, _helpName + ".HxS"); if (File.Exists(sourceHelpPath)) { File.Copy(sourceHelpPath, destHelpPath, true); File.SetAttributes(destHelpPath, FileAttributes.Normal); context.AddOutput(BuildFormatType.HtmlHelp2, destHelpPath); } // Copy the log file, if available... sourceHelpPath = Path.ChangeExtension(sourceHelpPath, ".log"); if (File.Exists(sourceHelpPath)) { destHelpPath = Path.ChangeExtension(destHelpPath, ".log"); File.Copy(sourceHelpPath, destHelpPath, true); File.SetAttributes(destHelpPath, FileAttributes.Normal); } // Copy the separated index file, if available... sourceHelpPath = Path.ChangeExtension(sourceHelpPath, ".HxI"); if (File.Exists(sourceHelpPath)) { destHelpPath = Path.ChangeExtension(destHelpPath, ".HxI"); File.Copy(sourceHelpPath, destHelpPath, true); File.SetAttributes(destHelpPath, FileAttributes.Normal); } } // 2. Create the help collection files for registration... processResult = CreateCollection(context); return(processResult); }
private bool CreateCollection(BuildContext context) { string workingDir = this.WorkingDirectory; if (String.IsNullOrEmpty(workingDir)) { throw new BuildException("A working directory is required."); } BuildTocContext tocContext = context.TocContext; string tocFile = tocContext.GetValue("$" + _buildFormat.Name); if (!String.IsNullOrEmpty(tocFile) && File.Exists(tocFile)) { _helpToc = Path.GetFileName(tocFile); } if (String.IsNullOrEmpty(_helpName) || String.IsNullOrEmpty(_helpToc)) { throw new BuildException("The required property values are set."); } bool buildResult = false; _settings = context.Settings; BuildFormatList formats = _settings.Formats; if (formats == null || formats.Count == 0) { return(buildResult); } FormatHxs hxsFormat = formats[BuildFormatType.HtmlHelp2] as FormatHxs; if (hxsFormat == null || hxsFormat.Enabled == false) { return(buildResult); } _buildFormat = hxsFormat; string helpTitleId = _helpTitleId; if (helpTitleId != null) { helpTitleId = helpTitleId.Trim(); } if (String.IsNullOrEmpty(helpTitleId)) { helpTitleId = _helpName; } _helpTitleId = helpTitleId; // We create a common XML Settings for all the writers... _xmlSettings = new XmlWriterSettings(); _xmlSettings.Encoding = Encoding.UTF8; _xmlSettings.Indent = true; _xmlSettings.IndentChars = "\t"; _xmlSettings.OmitXmlDeclaration = false; _xmlSettings.CloseOutput = true; try { if (_helpCulture != null) { _langId = _helpCulture.LCID; } // For these properties, we do not mind if set or there is error. string tmpText = _buildFormat["IndexAutoInclude"]; if (String.IsNullOrEmpty(tmpText) == false) { try { _indexAutoInclude = Convert.ToBoolean(tmpText); } catch { } } tmpText = _buildFormat["IndexSort"]; if (String.IsNullOrEmpty(tmpText) == false) { try { _indexSort = Convert.ToBoolean(tmpText); } catch { } } tmpText = _buildFormat["IndexMerge"]; if (String.IsNullOrEmpty(tmpText) == false) { try { _indexMerge = Convert.ToBoolean(tmpText); } catch { } } tmpText = _buildFormat["SampleInfo"]; if (String.IsNullOrEmpty(tmpText) == false) { try { _sampleInfo = Convert.ToBoolean(tmpText); } catch { } } tmpText = _buildFormat["CollectionPrefix"]; if (String.IsNullOrEmpty(tmpText) == false) { _collectionPrefix = tmpText; } if (String.IsNullOrEmpty(_helpDirectory)) { _helpOutputDir = Path.Combine(workingDir, _helpFolder); } else { _helpOutputDir = Path.Combine(_helpDirectory, _helpFolder); } if (Directory.Exists(_helpOutputDir) == false) { Directory.CreateDirectory(_helpOutputDir); } string langText = _langId.ToString(); bool lineOnAttribute = _xmlSettings.NewLineOnAttributes; _xmlSettings.NewLineOnAttributes = true; IList <string> listFiles = CreateCollectionIndex(context, langText); _xmlSettings.NewLineOnAttributes = lineOnAttribute; if (listFiles != null && listFiles.Count != 0) { if (CreateCollectionToc(context, langText)) { buildResult = CreateCollectionProject(context, listFiles, langText); } } return(buildResult); } catch (Exception ex) { if (_logger != null) { _logger.WriteLine(ex, BuildLoggerLevel.Error); } return(false); } }
public IncludeHandler ( BuildContext buildContext ) { this.buildContext = buildContext; }
private IList <string> CreateCollectionIndex(BuildContext context, string langText) { List <string> listFiles = new List <string>(6); // 1. For the A... string fileName = _collectionPrefix + _helpName + "_A.HxK"; listFiles.Add(fileName); string filePath = Path.Combine(_helpOutputDir, fileName); using (XmlWriter xmlWriter = XmlWriter.Create(filePath, _xmlSettings)) { xmlWriter.WriteDocType("HelpIndex", null, null, null); xmlWriter.WriteStartElement("HelpIndex"); xmlWriter.WriteAttributeString("Name", "A"); xmlWriter.WriteAttributeString("DTDVersion", "1.0"); xmlWriter.WriteAttributeString("Id", Path.GetFileNameWithoutExtension(fileName)); xmlWriter.WriteAttributeString("AutoInclude", _indexAutoInclude ? "Yes" : "No"); xmlWriter.WriteAttributeString("Merge", _indexMerge ? "Yes" : "No"); xmlWriter.WriteAttributeString("Sort", _indexSort ? "Yes" : "No"); xmlWriter.WriteAttributeString("Title", "HxLink Index"); xmlWriter.WriteAttributeString("Visible", "No"); xmlWriter.WriteAttributeString("LangId", langText); xmlWriter.WriteWhitespace(_xmlSettings.NewLineChars); // force a new line xmlWriter.WriteFullEndElement(); } // 2. For the B... fileName = _collectionPrefix + _helpName + "_B.HxK"; listFiles.Add(fileName); filePath = Path.Combine(_helpOutputDir, fileName); using (XmlWriter xmlWriter = XmlWriter.Create(filePath, _xmlSettings)) { xmlWriter.WriteDocType("HelpIndex", null, null, null); xmlWriter.WriteStartElement("HelpIndex"); xmlWriter.WriteAttributeString("Name", "B"); xmlWriter.WriteAttributeString("DTDVersion", "1.0"); xmlWriter.WriteAttributeString("Id", Path.GetFileNameWithoutExtension(fileName)); xmlWriter.WriteAttributeString("AutoInclude", _indexAutoInclude ? "Yes" : "No"); xmlWriter.WriteAttributeString("Merge", _indexMerge ? "Yes" : "No"); xmlWriter.WriteAttributeString("Sort", _indexSort ? "Yes" : "No"); xmlWriter.WriteAttributeString("Title", "Dynamic Link Index"); xmlWriter.WriteAttributeString("Visible", "No"); xmlWriter.WriteAttributeString("LangId", langText); xmlWriter.WriteWhitespace(_xmlSettings.NewLineChars); // force a new line xmlWriter.WriteFullEndElement(); } // 3. For the F... fileName = _collectionPrefix + _helpName + "_F.HxK"; listFiles.Add(fileName); filePath = Path.Combine(_helpOutputDir, fileName); using (XmlWriter xmlWriter = XmlWriter.Create(filePath, _xmlSettings)) { xmlWriter.WriteDocType("HelpIndex", null, null, null); xmlWriter.WriteStartElement("HelpIndex"); xmlWriter.WriteAttributeString("Name", "F"); xmlWriter.WriteAttributeString("DTDVersion", "1.0"); xmlWriter.WriteAttributeString("Id", Path.GetFileNameWithoutExtension(fileName)); xmlWriter.WriteAttributeString("AutoInclude", _indexAutoInclude ? "Yes" : "No"); xmlWriter.WriteAttributeString("Merge", _indexMerge ? "Yes" : "No"); xmlWriter.WriteAttributeString("Sort", _indexSort ? "Yes" : "No"); xmlWriter.WriteAttributeString("Title", "Dynamic Help and F1 Index"); xmlWriter.WriteAttributeString("Visible", "No"); xmlWriter.WriteAttributeString("LangId", langText); xmlWriter.WriteWhitespace(_xmlSettings.NewLineChars); // force a new line xmlWriter.WriteFullEndElement(); } // 4. For the K... fileName = _collectionPrefix + _helpName + "_K.HxK"; listFiles.Add(fileName); filePath = Path.Combine(_helpOutputDir, fileName); using (XmlWriter xmlWriter = XmlWriter.Create(filePath, _xmlSettings)) { xmlWriter.WriteDocType("HelpIndex", null, null, null); xmlWriter.WriteStartElement("HelpIndex"); xmlWriter.WriteAttributeString("Name", "K"); xmlWriter.WriteAttributeString("DTDVersion", "1.0"); xmlWriter.WriteAttributeString("FileVersion", _helpFileVersion.ToString()); xmlWriter.WriteAttributeString("Id", Path.GetFileNameWithoutExtension(fileName)); xmlWriter.WriteAttributeString("AutoInclude", _indexAutoInclude ? "Yes" : "No"); xmlWriter.WriteAttributeString("Merge", _indexMerge ? "Yes" : "No"); xmlWriter.WriteAttributeString("Sort", _indexSort ? "Yes" : "No"); xmlWriter.WriteAttributeString("Title", "Keyword Index"); xmlWriter.WriteAttributeString("Visible", "Yes"); xmlWriter.WriteAttributeString("LangId", langText); xmlWriter.WriteWhitespace(_xmlSettings.NewLineChars); // force a new line xmlWriter.WriteFullEndElement(); } // 5. For the S... fileName = _collectionPrefix + _helpName + "_S.HxK"; listFiles.Add(fileName); filePath = Path.Combine(_helpOutputDir, fileName); using (XmlWriter xmlWriter = XmlWriter.Create(filePath, _xmlSettings)) { xmlWriter.WriteDocType("HelpIndex", null, null, null); xmlWriter.WriteStartElement("HelpIndex"); xmlWriter.WriteAttributeString("Name", "S"); xmlWriter.WriteAttributeString("DTDVersion", "1.0"); xmlWriter.WriteAttributeString("Id", Path.GetFileNameWithoutExtension(fileName)); xmlWriter.WriteAttributeString("AutoInclude", _indexAutoInclude ? "Yes" : "No"); xmlWriter.WriteAttributeString("Merge", _indexMerge ? "Yes" : "No"); xmlWriter.WriteAttributeString("Sort", _indexSort ? "Yes" : "No"); xmlWriter.WriteAttributeString("Title", "Search Enhancement Index"); xmlWriter.WriteAttributeString("Visible", "No"); xmlWriter.WriteAttributeString("LangId", langText); xmlWriter.WriteWhitespace(_xmlSettings.NewLineChars); // force a new line xmlWriter.WriteFullEndElement(); } // 6. For the N... fileName = _collectionPrefix + _helpName + "_N.HxK"; listFiles.Add(fileName); filePath = Path.Combine(_helpOutputDir, fileName); using (XmlWriter xmlWriter = XmlWriter.Create(filePath, _xmlSettings)) { xmlWriter.WriteDocType("HelpIndex", null, null, null); xmlWriter.WriteStartElement("HelpIndex"); // start - HelpIndex xmlWriter.WriteAttributeString("Name", "NamedUrl"); xmlWriter.WriteAttributeString("DTDVersion", "1.0"); xmlWriter.WriteAttributeString("Id", Path.GetFileNameWithoutExtension(fileName)); xmlWriter.WriteAttributeString("AutoInclude", _indexAutoInclude ? "Yes" : "No"); xmlWriter.WriteAttributeString("Merge", _indexMerge ? "Yes" : "No"); xmlWriter.WriteAttributeString("Sort", _indexSort ? "Yes" : "No"); xmlWriter.WriteAttributeString("Title", "Named Url Index"); xmlWriter.WriteAttributeString("Visible", "No"); xmlWriter.WriteAttributeString("LangId", langText); xmlWriter.WriteWhitespace(_xmlSettings.NewLineChars); // force a new line xmlWriter.WriteFullEndElement(); // end - HelpIndex } return(listFiles); }
/// <summary> /// /// </summary> /// <param name="buildContext"></param> /// <param name="sourceFile"></param> /// <param name="profile"></param> /// <param name="entryPoint"></param> /// <param name="defines"></param> /// <param name="output"></param> /// <param name="listing"></param> /// <returns></returns> byte[] Compile ( BuildContext buildContext, Include include, string shaderSource, string sourceFile, string profile, string entryPoint, string defines, string output, string listing ) { Log.Debug("{0} {1} {2} {3}", sourceFile, profile, entryPoint, defines ); var flags = FX.ShaderFlags.None; if ( DisableOptimization) flags |= FX.ShaderFlags.OptimizationLevel0; // (!DisableOptimization) flags |= FX.ShaderFlags.OptimizationLevel3; if ( PreferFlowControl) flags |= FX.ShaderFlags.PreferFlowControl; if ( AvoidFlowControl) flags |= FX.ShaderFlags.AvoidFlowControl; if ( MatrixPacking==ShaderMatrixPacking.ColumnMajor ) flags |= FX.ShaderFlags.PackMatrixColumnMajor; if ( MatrixPacking==ShaderMatrixPacking.RowMajor ) flags |= FX.ShaderFlags.PackMatrixRowMajor; var defs = defines.Split(new[]{' ','\t'}, StringSplitOptions.RemoveEmptyEntries) .Select( entry => new SharpDX.Direct3D.ShaderMacro( entry, "1" ) ) .ToArray(); try { var sourceBytes = Encoding.UTF8.GetBytes(shaderSource); var result = FX.ShaderBytecode.Compile( sourceBytes, entryPoint, profile, flags, FX.EffectFlags.None, defs, include, sourceFile ); if ( result.Message!=null ) { Log.Warning( result.Message ); } File.WriteAllText( listing, result.Bytecode.Disassemble( FX.DisassemblyFlags.EnableColorCode, "" ) ); return result.Bytecode.Data; } catch ( Exception ex ) { if (ex.Message.Contains("error X3501")) { Log.Debug("No entry point '{0}'. It's ok", entryPoint ); return new byte[0]; } throw; } }
public override Widget buildPage(BuildContext context, Animation <float> animation, Animation <float> secondaryAnimation) { return(this.builder(context: context)); }
/// <summary> /// /// </summary> /// <param name="buildContext"></param> public override void Process ( AssetSource assetFile, BuildContext buildContext ) { // // Get combinations : // string shaderSource = File.ReadAllText( assetFile.FullSourcePath ); var ubershaderDecl = shaderSource.Split( new[]{Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries ) .Select( line0 => line0.Trim() ) .Where( line1 => line1.StartsWith("$ubershader") ) .ToList(); var defineList = new List<string>(); foreach ( var comb in ubershaderDecl ) { var ue = new UbershaderEnumerator( comb, "$ubershader" ); defineList.AddRange( ue.DefineList ); } // // Start listing builder : // ListingPath = buildContext.GetTempFileName( assetFile.KeyPath, ".html" ); var htmlBuilder = new StringBuilder(); htmlBuilder.AppendFormat("<pre>"); htmlBuilder.AppendLine("<b>Ubershader assembly listing</b>"); htmlBuilder.AppendLine(""); htmlBuilder.AppendLine("<b>Source:</b> <i>" + assetFile.KeyPath + "</i>" ); htmlBuilder.AppendLine(""); // insert includes here bit later: var includeInsert = htmlBuilder.Length; htmlBuilder.AppendLine("<b>Declarations:</b>"); foreach ( var comb in ubershaderDecl ) { htmlBuilder.AppendLine(" <i>" + comb + "</i>"); } htmlBuilder.AppendLine(""); var usdb = new List<UsdbEntry>(); var include = new IncludeHandler(buildContext); // // Build all : // foreach ( var defines in defineList ) { var id = defineList.IndexOf( defines ); var psbc = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".PS.dxbc" ); var vsbc = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".VS.dxbc" ); var gsbc = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".GS.dxbc" ); var hsbc = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".HS.dxbc" ); var dsbc = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".DS.dxbc" ); var csbc = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".CS.dxbc" ); var pshtm = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".PS.html" ); var vshtm = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".VS.html" ); var gshtm = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".GS.html" ); var hshtm = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".HS.html" ); var dshtm = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".DS.html" ); var cshtm = buildContext.GetTempFileName( assetFile.KeyPath, "." + id.ToString("D8") + ".CS.html" ); var ps = Compile( buildContext, include, shaderSource, assetFile.FullSourcePath, "ps_5_0", PSEntryPoint, defines, psbc, pshtm ); var vs = Compile( buildContext, include, shaderSource, assetFile.FullSourcePath, "vs_5_0", VSEntryPoint, defines, vsbc, vshtm ); var gs = Compile( buildContext, include, shaderSource, assetFile.FullSourcePath, "gs_5_0", GSEntryPoint, defines, gsbc, gshtm ); var hs = Compile( buildContext, include, shaderSource, assetFile.FullSourcePath, "hs_5_0", HSEntryPoint, defines, hsbc, hshtm ); var ds = Compile( buildContext, include, shaderSource, assetFile.FullSourcePath, "ds_5_0", DSEntryPoint, defines, dsbc, dshtm ); var cs = Compile( buildContext, include, shaderSource, assetFile.FullSourcePath, "cs_5_0", CSEntryPoint, defines, csbc, cshtm ); htmlBuilder.AppendFormat( (vs.Length==0) ? ".. " : "<a href=\"{0}\">vs</a> ", Path.GetFileName(vshtm) ); htmlBuilder.AppendFormat( (ps.Length==0) ? ".. " : "<a href=\"{0}\">ps</a> ", Path.GetFileName(pshtm) ); htmlBuilder.AppendFormat( (hs.Length==0) ? ".. " : "<a href=\"{0}\">hs</a> ", Path.GetFileName(hshtm) ); htmlBuilder.AppendFormat( (ds.Length==0) ? ".. " : "<a href=\"{0}\">ds</a> ", Path.GetFileName(dshtm) ); htmlBuilder.AppendFormat( (gs.Length==0) ? ".. " : "<a href=\"{0}\">gs</a> ", Path.GetFileName(gshtm) ); htmlBuilder.AppendFormat( (cs.Length==0) ? ".. " : "<a href=\"{0}\">cs</a> ", Path.GetFileName(cshtm) ); htmlBuilder.Append( "[" + defines + "]<br>" ); usdb.Add( new UsdbEntry( defines, ps, vs, gs, hs, ds, cs ) ); } htmlBuilder.Insert( includeInsert, "<b>Includes:</b>\r\n" + string.Join("", include.Includes.Select(s=>" <i>" + s + "</i>\r\n") ) + "\r\n"); File.WriteAllText( buildContext.GetTempFileName(assetFile.KeyPath, ".html"), htmlBuilder.ToString() ); // // Write ubershader : // using ( var fs = assetFile.OpenTargetStream(include.Includes) ) { using ( var bw = new BinaryWriter( fs ) ) { bw.WriteFourCC( Ubershader.UbershaderSignature ); // params : // bytecodes : bw.Write( usdb.Count ); foreach ( var entry in usdb ) { bw.Write( entry.Defines ); bw.WriteFourCC( Ubershader.PSBytecodeSignature ); bw.Write( entry.PSBytecode.Length ); bw.Write( entry.PSBytecode ); bw.WriteFourCC( Ubershader.VSBytecodeSignature ); bw.Write( entry.VSBytecode.Length ); bw.Write( entry.VSBytecode ); bw.WriteFourCC( Ubershader.GSBytecodeSignature ); bw.Write( entry.GSBytecode.Length ); bw.Write( entry.GSBytecode ); bw.WriteFourCC( Ubershader.HSBytecodeSignature ); bw.Write( entry.HSBytecode.Length ); bw.Write( entry.HSBytecode ); bw.WriteFourCC( Ubershader.DSBytecodeSignature ); bw.Write( entry.DSBytecode.Length ); bw.Write( entry.DSBytecode ); bw.WriteFourCC( Ubershader.CSBytecodeSignature ); bw.Write( entry.CSBytecode.Length ); bw.Write( entry.CSBytecode ); } } } }
public override Widget build(BuildContext context) { _rebuildOutgoingWidgetsIfNeeded(); return(widget.layoutBuilder(_currentEntry?.transition, _outgoingWidgets)); }