Beispiel #1
0
        public static string GetNodeParamTooltip(NodeType type, ParamId paramId)
        {
            try
            {
                using (SQLiteCommand query = new SQLiteCommand(sqliteConnection))
                {
                    string field = $"param{ ((int)paramId + 1).ToString()}";
                    query.CommandText = $"SELECT {field} FROM node_tooltips WHERE Type LIKE '{type}';";
                    using (DbDataReader dataReader = query.ExecuteReader())
                    {
                        if (dataReader.Read())
                        {
                            if(dataReader[field].ToString() != "")
                                return dataReader[field].ToString();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Database Error!\nError: " + e.Message);
            }

            return null;
        }
Beispiel #2
0
 public static ParamId GetSampler(ParamId texture)
 {
     return(texture switch
     {
         ParamId.Texture0 => ParamId.Sampler0,
         ParamId.Texture1 => ParamId.Sampler1,
         ParamId.Texture2 => ParamId.Sampler2,
         ParamId.Texture3 => ParamId.Sampler3,
         ParamId.Texture4 => ParamId.Sampler4,
         ParamId.Texture5 => ParamId.Sampler5,
         ParamId.Texture6 => ParamId.Sampler6,
         ParamId.Texture7 => ParamId.Sampler7,
         ParamId.Texture8 => ParamId.Sampler8,
         ParamId.Texture9 => ParamId.Sampler9,
         ParamId.Texture10 => ParamId.Sampler10,
         ParamId.Texture11 => ParamId.Sampler11,
         ParamId.Texture12 => ParamId.Sampler12,
         ParamId.Texture13 => ParamId.Sampler13,
         ParamId.Texture14 => ParamId.Sampler14,
         ParamId.Texture15 => ParamId.Sampler15,
         ParamId.Texture16 => ParamId.Sampler16,
         ParamId.Texture17 => ParamId.Sampler17,
         ParamId.Texture18 => ParamId.Sampler18,
         ParamId.Texture19 => ParamId.Sampler19,
         _ => throw new ArgumentOutOfRangeException(nameof(texture), $"{texture} has no associated sampler")
     });
Beispiel #3
0
 public Parameter(ParamId id, string label, bool isRequired, bool isSection)
 {
     this.id         = id;
     this.label      = label;
     this.isRequired = isRequired;
     this.isSection  = isSection;
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ProductField toSave = new ProductField();

            if (!toSave.LoadByPrimaryKey(ParamId.GetValueOrDefault(-1)))
            {
                // NEW field
                toSave           = new ProductField();
                toSave.ProductId = ParamProductId.Value;
                ProductFieldWidgetType widgetType;
                if (!WA.Enum <ProductFieldWidgetType> .TryParse(ddlWidgetType.SelectedValue, out widgetType))
                {
                    throw new ArgumentException("Unable to determine WidgetType");
                }
                toSave.WidgetType = ddlWidgetType.SelectedValue;
                toSave.SortOrder  = 99;
                toSave.Slug       = txtName.Text.CreateSpecialSlug(true, 100);
                if (ProductField.SlugExistsForProductField(toSave.ProductId.Value, toSave.Slug))
                {
                    toSave.Slug = ProductField.GetNextAvailableSlug(toSave.ProductId.Value, toSave.Slug);
                }
            }

            toSave.Name       = txtName.Text;
            toSave.IsRequired = chkIsRequired.Checked;

            switch (toSave.WidgetTypeName)
            {
            case ProductFieldWidgetType.Textbox:
            case ProductFieldWidgetType.Textarea:
            case ProductFieldWidgetType.Checkbox:
                toSave.PriceAdjustment  = WA.Parser.ToDecimal(txtPriceAdjustment.Text);
                toSave.WeightAdjustment = WA.Parser.ToDecimal(txtWeightAdjustment.Text);

                // no 'choices' for these types
                toSave.ProductFieldChoiceCollectionByProductFieldId.MarkAllAsDeleted();
                break;

            default:
                // no field-level adjustments for these types (adjustments are done at the choice-level)
                toSave.PriceAdjustment  = null;
                toSave.WeightAdjustment = null;

                // save/update the 'choices'
                List <string> optionNames         = WA.Web.WebHelper.GetFormValuesByName("optionName", Request);
                List <string> optionValues        = WA.Web.WebHelper.GetFormValuesByName("optionValue", Request);
                List <string> optionPriceAdjusts  = WA.Web.WebHelper.GetFormValuesByName("optionPriceAdjust", Request);
                List <string> optionWeightAdjusts = WA.Web.WebHelper.GetFormValuesByName("optionWeightAdjust", Request);
                if (optionNames.Count == optionPriceAdjusts.Count && optionNames.Count == optionWeightAdjusts.Count)
                {
                    toSave.ProductFieldChoiceCollectionByProductFieldId.MarkAllAsDeleted();

                    for (int i = 0; i < optionNames.Count; i++)
                    {
                        if (!string.IsNullOrEmpty(optionNames[i]))
                        {
                            ProductFieldChoice newChoice = toSave.ProductFieldChoiceCollectionByProductFieldId.AddNew();
                            newChoice.Name             = optionNames[i];
                            newChoice.Value            = string.IsNullOrEmpty(optionValues[i]) ? optionNames[i] : optionValues[i];
                            newChoice.PriceAdjustment  = WA.Parser.ToDecimal(optionPriceAdjusts[i]);
                            newChoice.WeightAdjustment = WA.Parser.ToDecimal(optionWeightAdjusts[i]);
                            newChoice.SortOrder        = (short)i;
                        }
                    }
                }
                else
                {
                    throw new ArgumentException(
                              "Unable to parse/determine values for Product Choice Names and Adjustments");
                }
                break;
            }
            toSave.Save();


            // redirect back to Edit Product Url
            Response.Redirect(StoreUrls.AdminEditProduct(toSave.ProductId.Value, "Product variant/attribute saved"));
        }