Beispiel #1
0
        static bool CultureCheck2(DCParameter parameter, string culture)
        {
            if (culture == null)
            {
                culture = "";
            }
            if (parameter.Culture == null)
            {
                parameter.Culture = culture;
            }
            bool isCurrentCulture = appUsedCultureName.Equals(culture, StringComparison.CurrentCultureIgnoreCase);
            bool inCurrentCulture = appUsedCultureName.Equals(parameter.Culture, StringComparison.CurrentCultureIgnoreCase);
            bool isSubstitute     = culture.Equals(parameter.Culture, StringComparison.CurrentCultureIgnoreCase);

            if (isCurrentCulture ||
                isSubstitute ||
                (string.IsNullOrEmpty(culture) && !inCurrentCulture))
            {
                parameter.Culture = culture;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
 private Brush(ComputeShader cBegin, ComputeShader cDoing, ComputeShader cEnd, bool isSelectionBrush)
 {
     this.cBegin = cBegin;
     this.cDoing = cDoing;
     this.cEnd   = cEnd;
     for (int i = 0; i < c_parameterCount; i++)
     {
         Parameters[i] = new DCParameter();
     }
 }
Beispiel #3
0
        public static IAsyncOperation <BlendMode> LoadFromFileAsync(DeviceResources deviceResources, StorageFile file)
        {
            return(Task.Run(async() =>
            {
                Stream stream = (await file.OpenAsync(FileAccessMode.Read)).AsStream();
                XmlReaderSettings setting1 = new XmlReaderSettings();
                setting1.IgnoreComments = true;
                XmlReader xmlReader = XmlReader.Create(stream, setting1);
                string code = null;
                string name = "";
                string description = "";
                string imagePath = "";
                Guid guid = Guid.Empty;
                DCParameter[] dcParameters = new DCParameter[c_parameterCount];
                for (int i = 0; i < c_parameterCount; i++)
                {
                    dcParameters[i] = new DCParameter();
                }
                while (xmlReader.Read())
                {
                    if (xmlReader.NodeType == XmlNodeType.Element)
                    {
                        switch (xmlReader.Name)
                        {
                        case "BlendMode":
                            guid = Guid.Parse(xmlReader.GetAttribute("Guid"));
                            imagePath = xmlReader.GetAttribute("Image");
                            break;

                        case "Code":
                            code = xmlReader.ReadElementContentAsString();
                            break;

                        case "Parameter":
                            int.TryParse(xmlReader.GetAttribute("Index"), out int index);
                            dcParameters[index].Type = xmlReader.GetAttribute("Type");
                            if (string.IsNullOrEmpty(dcParameters[index].Type))
                            {
                                dcParameters[index].Type = "TextBox";
                            }
                            if (int.TryParse(xmlReader.GetAttribute("MaxValue"), out int maxValue))
                            {
                                dcParameters[index].MaxValue = maxValue;
                            }
                            else
                            {
                                dcParameters[index].MaxValue = int.MaxValue;
                            }
                            if (int.TryParse(xmlReader.GetAttribute("MinValue"), out int minValue))
                            {
                                dcParameters[index].MinValue = minValue;
                            }
                            else
                            {
                                dcParameters[index].MinValue = int.MinValue;
                            }
                            while (xmlReader.Read())
                            {
                                if (xmlReader.NodeType == XmlNodeType.Element)
                                {
                                    switch (xmlReader.Name)
                                    {
                                    case "Name":
                                        if (CultureCheck2(dcParameters[index], xmlReader.GetAttribute("Culture")))
                                        {
                                            dcParameters[index].Name = xmlReader.ReadElementContentAsString();
                                        }
                                        continue;

                                    case "Description":
                                        if (CultureCheck2(dcParameters[index], xmlReader.GetAttribute("Culture")))
                                        {
                                            dcParameters[index].Description = xmlReader.ReadElementContentAsString();
                                        }
                                        continue;
                                    }
                                    xmlReader.Skip();
                                }
                                else if (xmlReader.NodeType == XmlNodeType.EndElement && xmlReader.Name == "Parameter")
                                {
                                    break;
                                }
                            }
                            break;

                        case "Name":
                            name = xmlReader.ReadElementContentAsString();
                            break;

                        case "Description":
                            description = xmlReader.ReadElementContentAsString();
                            break;
                        }
                    }
                }
                byte[][] codesGroup = new byte[c_csBlendCount][];
                ComputeShader[] shaders = new ComputeShader[c_csBlendCount];
                for (int i = 0; i < c_csBlendCount; i++)
                {
                    codesGroup[i] = Encoding.UTF8.GetBytes(componentCode[i].Replace("#define codehere", code));
                    shaders[i] = ComputeShader.CompileAndCreate(deviceResources, codesGroup[i]);
                }
                BlendMode blendMode = new BlendMode(shaders);
                blendMode.Name = name;
                blendMode.Guid = guid;
                blendMode.Description = description;
                for (int j = 0; j < c_parameterCount; j++)
                {
                    blendMode.Parameters[j] = new DCParameter();
                    blendMode.Parameters[j].Name = dcParameters[j].Name;
                    blendMode.Parameters[j].Description = dcParameters[j].Description;
                    blendMode.Parameters[j].Type = dcParameters[j].Type;
                    blendMode.Parameters[j].MaxValue = dcParameters[j].MaxValue;
                    blendMode.Parameters[j].MinValue = dcParameters[j].MinValue;
                    blendMode.Parameters[j].Value = 0;
                }
                return blendMode;
            }).AsAsyncOperation());
        }