Esempio n. 1
0
        protected virtual void InitializeShader()
        {
            try
            {
                string shaderSource = EmbeddedResourceReader.ReadTextResource("MacomberMapClient.Effects.VertexColorShader.fx", Assembly.GetExecutingAssembly());
                // load our default shader

                var vertexShaderByteCode = ShaderBytecode.Compile(shaderSource, "VS", "vs_4_0", ShaderFlags.None, EffectFlags.None);
                _vertexShader = new VertexShader(_surface.Device, vertexShaderByteCode);

                var pixelShaderByteCode = ShaderBytecode.Compile(shaderSource, "PS", "ps_4_0", ShaderFlags.None, EffectFlags.None);
                _pixelShader = new PixelShader(_surface.Device, pixelShaderByteCode);

                // Layout from VertexShader input signature
                _inputLayout = new InputLayout(
                    _surface.Device,
                    ShaderSignature.GetInputSignature(vertexShaderByteCode),
                    new[]
                {
                    new SharpDX.Direct3D11.InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0),
                    new SharpDX.Direct3D11.InputElement("COLOR", 0, Format.R32G32B32A32_Float, 16, 0),
                    new SharpDX.Direct3D11.InputElement("NORMAL", 0, Format.R32G32B32_Float, 32, 0),
                });

                // Instantiate Vertex buiffer from vertex data
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 2
0
        static FishGenerator()
        {
            string rawNames = EmbeddedResourceReader.ReadTextResource("Names.txt");

            foreach (string name in rawNames.Split('\n'))
            {
                if (string.IsNullOrWhiteSpace(name))
                {
                    continue;
                }

                string[] parts = name.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                Names.Add(char.ToUpper(parts[0][0]) + parts[0].Substring(1).ToLower());
            }
        }
        protected FlowStepComponent(
            string viewName,
            IPlatformSettings platformSettings,
            string customLoadingViewName          = null,
            [CallerFilePath] string componentPath = null)
            : this($"~{GetCustomViewPath(componentPath, viewName, "cshtml")}")
        {
            PlatformSettings = platformSettings;

            UpdateCachedLoaderView();
            SetComponentId();

            _loadingViewContent = new Lazy <string>(() =>
            {
                string customLoadingViewFullPath = null;
                if (customLoadingViewName != null)
                {
                    customLoadingViewFullPath = GetCustomViewPath(componentPath, customLoadingViewName).TrimStart('~', '/');
                }

                return(customLoadingViewFullPath != null
                                        ? ResolveView(customLoadingViewFullPath)
                                        : string.Empty);
            });

            void SetComponentId()
            {
                var componentPrefix = ViewName.Replace(".cshtml", string.Empty, StringComparison.InvariantCultureIgnoreCase)
                                      .Replace('\\', '_')
                                      .Replace('/', '_')
                                      .Replace('~', '_')
                                      .Replace('.', '_')
                                      .TrimStart('_');

                ComponentId = $"{componentPrefix}_{Guid.NewGuid()}";
            }

            string ResolveView(string customLoadingViewFullPath)
            {
#if DEBUG || FRAMEWORKDEVELOPMENT
                //so it can be changed in the same debugging session
                return(DoResolve());
#else
                return(LoadingViewsCache.GetOrAdd(customLoadingViewFullPath, k => DoResolve()));
#endif
                string DoResolve()
                {
                    var path = Path.Combine(HttpContext.Resolve <IWebHostEnvironment>().ContentRootPath,
                                            customLoadingViewFullPath);

                    if (!File.Exists(path))
                    {
                        Logger.Error(() => $"Could not find loading view at :{path}");
                        return(string.Empty);
                    }
                    return(File.ReadAllText(path).Replace("\"~/", $"\"{HttpContext.GetBaseUrl()}"));
                }
            }

            void UpdateCachedLoaderView()
            {
                if (platformSettings.DeferredComponentLoaderViewEmbeddedResourceName != null &&
                    Template.Key != platformSettings.DeferredComponentLoaderViewEmbeddedResourceName)
                {
                    var textResource = EmbeddedResourceReader.ReadTextResource(
                        platformSettings.DeferredComponentLoaderViewEmbeddedResourceName,
                        GetType().Assembly);
                    Template = new KeyValuePair <string, string>(
                        platformSettings.DeferredComponentLoaderViewEmbeddedResourceName,
                        textResource);
                }
            }
        }