Example #1
0
File: Shader.cs Project: stefv/GLow
 /// <summary>
 /// Default constructor.
 /// </summary>
 public Shader(Shader src)
 {
     Id = src.Id;
     ShadertoyID = src.ShadertoyID;
     Name = src.Name;
     Description = src.Description;
     Author = src.Author;
     LastUpdate = src.LastUpdate;
     ReadOnly = src.ReadOnly;
     Favorite = src.Favorite;
 }
Example #2
0
        /// <summary>
        /// Download the shaders.
        /// </summary>
        /// <param name="sender">Object sending this event.</param>
        /// <param name="e">Argument for this event.</param>
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            // Get the connection to the database before to retreive the data from Shadertoy
            SQLiteConnection db = Database.Instance.GetConnection();

            // Load the shader list
            List<string> shaderList = GetShadertoyList();
            if (shaderList == null) return;

            db.BeginTransaction();

            // Load the informations of each shader
            int index = 0;
            foreach (string shaderId in shaderList)
            {
                // If this shader exists already, read its the informations from the database
                Shader shader = (from s in db.Table<Shader>() where s.ShadertoyID.Equals(shaderId) select s).FirstOrDefault();
                if (shader == null)
                {
                    ShaderV1 shadertoy = GetShadertoyShader(shaderId);

                    // Sauvegarde la shader
                    shader = new Shader()
                    {
                        ShadertoyID = shaderId,
                        Name = shadertoy.Shader.info.name,
                        Description = shadertoy.Shader.info.description,
                        Author = shadertoy.Shader.info.username,
                        ReadOnly = true,
                        Favorite = false,
                        Type = "GLSL",
                        LastUpdate = DateTime.Now
                    };
                    db.Insert(shader);

                    // Source garde le source
                    ImageSource imageSource = new ImageSource()
                    {
                        Shader = shader.Id,
                        SourceCode = shadertoy.Shader.renderpass[0].code
                    };
                    db.Insert(imageSource);
                }

                _worker.ReportProgress(++index, new WorkerData() { NbShaders = shaderList.Count, ShaderInfo = shader });
                if (_worker.CancellationPending) break;
            }

            db.Commit();
        }
Example #3
0
        /// <summary>
        /// Show the source code of the given Shader.
        /// </summary>
        /// <param name="shader">The shader with the source code.</param>
        private void ShowSourceCode(Shader shader)
        {
            // Retrieve the source code
            SQLiteConnection db = Database.Instance.GetConnection();
            ImageSource source = (from s in db.Table<ImageSource>() where s.Id == shader.Id select s).FirstOrDefault();

            ShaderEditWindow editWindow = new ShaderEditWindow() { Owner = this };
            editWindow.Code = source.SourceCode;
            editWindow.IsReadOnly = true;
            editWindow.ShowDialog();
        }