Exemple #1
0
        private TypeCount ToTypeCount(JToken instance)
        {
            TypeCount typeCount = new TypeCount
            {
                Type  = instance.Value <JObject>().Property("key").Value.ToString(),
                Count = Convert.ToInt32(instance.Value <JObject>().Property("doc_count").Value.ToString())
            };

            typeCount.ShortTypeName = typeCount.Type.GetShortTypeName();
            ContentType contentType = _contentTypeRepository.Load(typeCount.ShortTypeName);

            if (contentType != null)
            {
                typeCount.Name  = contentType.LocalizedName;
                typeCount.Group = contentType.LocalizedGroupName;
            }

            if (String.IsNullOrWhiteSpace(typeCount.Name))
            {
                typeCount.Name = typeCount.ShortTypeName;
            }

            if (String.IsNullOrWhiteSpace(typeCount.Group))
            {
                typeCount.Group = " " + LocalizationExtensions.TranslateWithPath("nocategory", "/epinovaelasticsearch/indexinspector/");
            }

            return(typeCount);
        }
Exemple #2
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            var validationResult = ValidationResult.Success;

            if (value == null)
            {
                return(validationResult);
            }

            var date = DateTime.Parse(value.ToString() ?? string.Empty);

            if (date.CompareTo(DateTime.Now) <= 0)
            {
                return(validationResult);
            }

            if (ErrorMessageResourceType != null && !string.IsNullOrEmpty(ErrorMessageResourceName))
            {
                validationResult = new ValidationResult(LocalizationExtensions.GetResourceString(ErrorMessageResourceType, ErrorMessageResourceName), new List <string> {
                    validationContext.DisplayName
                });
            }
            else
            {
                validationResult = new ValidationResult(CommonResources.Validation_Error);
            }

            return(validationResult);
        }
Exemple #3
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            var result = ValidationResult.Success;

            if (value == null)
            {
                return(result);
            }

            var guid = Guid.Parse(value.ToString());

            if (guid != Guid.Empty)
            {
                return(result);
            }

            if (ErrorMessageResourceType != null && !string.IsNullOrEmpty(ErrorMessageResourceName))
            {
                result = new ValidationResult(LocalizationExtensions.GetResourceString(ErrorMessageResourceType, ErrorMessageResourceName));
            }
            else
            {
                result = new ValidationResult(CommonResources.Validation_InvalidGuidString);
            }

            return(result);
        }
 public override void Uninstall()
 {
     this._settingService.DeleteSetting <ZarinpalSettings>();
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.Fields.RedirectionTip");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.Fields.MerchantId");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.Fields.MerchantId.Hint");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.Fields.PayementUrl");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.Fields.PayementUrl.Hint");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.PaymentMethodDescription");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.Payment.Description");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.Verify.SuccessMessage");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.Payment.FailureMessage");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-1");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-2");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-3");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-4");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-11");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-12");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-21");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-22");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-33");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-34");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-40");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-41");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-42");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-54");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.100");
     LocalizationExtensions.DeletePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.101");
     base.Uninstall();
 }
Exemple #5
0
 public override void Uninstall()
 {
     this._settingService.DeleteSetting <FacebookPixelSettings>();
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.Widgets.FacebookPixel.FacebookPixelScriptFirstPart");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.Widgets.FacebookPixel.FacebookPixelScriptFirstPart.Hint");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.Widgets.FacebookPixel.FacebookPixelScriptLastPart");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.Widgets.FacebookPixel.FacebookPixelScriptLastPart.Hint");
     base.Uninstall();
 }
 public virtual void Uninstall()
 {
     this._settingService.DeleteSetting <QQConnectExternalAuthSettings>();
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.ExternalAuth.QQConnect.Login");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.ExternalAuth.QQConnect.CallbackUrl");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.ExternalAuth.QQConnect.ClientKeyIdentifier");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.ExternalAuth.QQConnect.ClientKeyIdentifier.Hint");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.ExternalAuth.QQConnect.ClientSecret");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.ExternalAuth.QQConnect.ClientSecret.Hint");
     base.Uninstall();
 }
 public virtual void Install()
 {
     this._settingService.SaveSetting(new QQConnectExternalAuthSettings()
     {
         ClientKeyIdentifier = "",
         ClientSecret        = ""
     }, 0);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.ExternalAuth.QQConnect.Login", "Login using QQConnect account", null);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.ExternalAuth.QQConnect.CallbackUrl", "Callback Url", null);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.ExternalAuth.QQConnect.ClientKeyIdentifier", "App ID/API Key", null);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.ExternalAuth.QQConnect.ClientKeyIdentifier.Hint", "Enter your app ID/API key here. You can find it on your QQConnect application page.", null);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.ExternalAuth.QQConnect.ClientSecret", "App Secret", null);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.ExternalAuth.QQConnect.ClientSecret.Hint", "Enter your app secret here. You can find it on your QQConnect application page.", null);
     base.Install();
 }
Exemple #8
0
        public override void Install()
        {
            FacebookPixelSettings facebookPixelSetting = new FacebookPixelSettings()
            {
                FacebookPixelScriptFirstPart = "<!-- Facebook Pixel Code -->\r\n<script>\r\n    !function (f, b, e, v, n, t, s) {\r\n        if (f.fbq) return; n = f.fbq = function () {\r\n            n.callMethod ?\r\n            n.callMethod.apply(n, arguments) : n.queue.push(arguments)\r\n        }; if (!f._fbq) f._fbq = n;\r\n        n.push = n; n.loaded = !0; n.version = '2.0'; n.queue = []; t = b.createElement(e); t.async = !0;\r\n        t.src = v; s = b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t, s)\r\n    }(window,\r\n    document, 'script', '//connect.facebook.net/en_US/fbevents.js');\r\n\r\n    fbq('init', '1769980523222843')",
                FacebookPixelScriptLastPart  = "fbq('track', \"PageView\");</script>\r\n<noscript>\r\n    <img height=\"1\" width=\"1\" style=\"display:none\"\r\n         src=\"https://www.facebook.com/tr?id=1769980523222843&ev=PageView&noscript=1\" />\r\n</noscript>\r\n<!-- End Facebook Pixel Code -->"
            };

            this._settingService.SaveSetting <FacebookPixelSettings>(facebookPixelSetting, 0);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.Widgets.FacebookPixel.Configure.Description", "\r\n\r\n<ul>\r\n    <li>The Facebook Pixel code divided into two part </li>\r\n    <li>First parts start from &#60;&#33;&#45;&#45; Facebook Pixel Code &#45;&#45;&#62; and end fbq('init', '111111111111');</li>\r\n    <li>Second parts start from fbq('track', \"PageView\");  and end &#60;&#33;&#45;&#45; End Facebook Pixel Code &#45;&#45;&#62;;</li>\r\n    <li>Two script Part put into the two different text feld</li>\r\n    <li>Save</li>\r\n</ul>\r\n\r\n", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.Widgets.FacebookPixel.FacebookPixelScriptFirstPart", "FacebookPixel Script_First", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.Widgets.FacebookPixel.FacebookPixelScriptFirstPart.Hint", "Paste the FacebookPixel Script here, and replace hard coded values by tokens. http will be automatically replaced with https if necessary.", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.Widgets.FacebookPixel.FacebookPixelScriptLastPart", "FacebookPixel Script_Last", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.Widgets.FacebookPixel.FacebookPixelScriptLastPart.Hint", "Paste the FacebookPixel Script Last  here, and replace hard coded values by tokens. http will be automatically replaced with https if necessary.", null);
            base.Install();
        }
Exemple #9
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            var propertyFrom = validationContext.ObjectType.GetProperty(PropertyFrom);

            if (propertyFrom == null)
            {
                return(new ValidationResult(string.Format(CommonResources.Validation_UnknowPropery, PropertyFrom)));
            }

            // Тип поля из модели не поддерживает сравнения
            var fromValue = propertyFrom.GetValue(validationContext.ObjectInstance, null);

            if (!(fromValue is IComparable))
            {
                return(new ValidationResult(string.Format(CommonResources.Validation_NotIComparable, PropertyFrom)));
            }

            var propertyTo = validationContext.ObjectType.GetProperty(PropertyTo);

            if (propertyTo == null)
            {
                return(new ValidationResult(string.Format(CommonResources.Validation_UnknowPropery, PropertyTo)));
            }

            // Тип поля из модели не поддерживает сравнения
            var toValue = propertyTo.GetValue(validationContext.ObjectInstance, null);

            if (!(toValue is IComparable))
            {
                return(new ValidationResult(string.Format(CommonResources.Validation_NotIComparable, PropertyTo)));
            }

            // Приводим к типам поддерживающим сравнения int, datetime, float и прочее
            var tempFrom = fromValue as IComparable;
            var tempTo   = toValue as IComparable;

            // Сама проверка
            if (IsSinglePossible ? tempFrom.CompareTo(tempTo) > 0 : tempFrom.CompareTo(tempTo) >= 0)
            {
                return(new ValidationResult(string.Format(CommonResources.Validation_FromToInvalid,
                                                          LocalizationExtensions.GetPropertyDisplayLabel(propertyFrom),
                                                          LocalizationExtensions.GetPropertyDisplayLabel(propertyTo))));
            }

            return(ValidationResult.Success);
        }
        public override void Install()
        {
            ZarinpalSettings zarinpalPaymentSettings = new ZarinpalSettings
            {
                MerchantId    = "",
                PayementUrl   = "https://www.zarinpal.com/pg/StartPay/{0}",
                WebServiceUrl = "https://www.zarinpal.com/pg/services/WebGate/service",
                IsToman       = false
            };

            this._settingService.SaveSetting <ZarinpalSettings>(zarinpalPaymentSettings, 0);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.Fields.RedirectionTip", " به درگاه زرین‌پال متصل خواهید شد.", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.Fields.MerchantId", "کد درگاه پرداخت", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.Fields.MerchantId.Hint", "كدي يكتا و 36 كاراكتري است كه زرین‌پال به ازاي هر درخواست درگاه پرداخت به پذيرنده اختصاص می‌دهد.", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.Fields.PayementUrl", "آدرس درگاه پرداخت", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.Fields.PayementUrl.Hint", "آدرس اینترنتی‌ای که مشتری برای پرداخت مبلغ فاکتور به آن هدایت می‌شود.", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.Fields.WebServiceUrl", "آدرس وب سرویس", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.Fields.WebServiceUrl.Hint", "آدرس وب سرویس زرین‌پال برای ازتباط با درگاه پرداخت.", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.Fields.IsToman", "محاسبه بر اساس تومان", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.PaymentMethodDescription", "پرداخت توسط درگاه زرین‌پال", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.Verify.SuccessMessage", "صورتحساب با موفقیت پرداخت گردید.\r\nکد پیگیری : {0}", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.Verify.FailureMessage", "پردخت  ناموفق بود.\r\nشرح خطا : {0}", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.Payment.Description", "بابت خرید فاکتور شماه {0}", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.Payment.FailureMessage", "برقراری ارتباط با سرور زرین‌پال امکان پذیر نمی‌باشد.\r\nشرح خطا : {0}", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-1", "اطلاعات ارسالی ناقص است.", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-2", "آی‌پی و یا مرچنت کد،  صحیح نیست.", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-3", "با توجه به محدودیت‌های شاپرک امکان پرداخت با رقم درخواست شده میسر نمی‌باشد.", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-4", "سطح تایید پذیرنده پایین‌تر از سطح نقره‌ای است.", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-11", "درخواست مورد نظر یافت نشد.", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-12", "امکان ویرایش درخواست میسر نمی‌باشد.", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-21", "هیچ نوع عملیات مالی برای این تراکنش یافت نشد.", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-22", "تراکنش ناموفق می‌باشد.", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-33", "رقم تراکنش با رقم پرداخت شده مطابقت ندارد.", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-34", "سقف تقسیم تراکنش از لحاظ تعداد یا رقم، عبور نموده است.", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-40", "اجازه دسترسی به متد مربوطه وجود ندارد.", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-41", "اطلاعات ارسال شده مربوط به AdditionalData غیرمعتبر می‌باشد.", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-42", "مدت زمان معتبر طول عمر شناسه پرداخت باید بین  30 دقیه تا  45 روز می‌باشد.", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.-54", "درخواست مورد نظر آرشیو شده است.", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.100", "عملیات با موفقیت انجام گردیده است.", null);
            LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "NopFarsi.Zarinpal.StatusCode.101", "عملیات پرداخت موفق بوده و قبلاً PaymentVerification تراکنش انجام شده است.", null);
            base.Install();
        }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            if (value == null || string.IsNullOrEmpty(value.ToString()))
            {
                return(ValidationResult.Success);
            }

            var phoneNumber = value.ToString();
            var pattern     = new Regex(PhonePattern, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);

            if (phoneNumber.Length <= PhoneNumberMaxLength && phoneNumber.Length >= PhoneNumberMinLength && pattern.IsMatch(phoneNumber))
            {
                return(ValidationResult.Success);
            }

            if (ErrorMessageResourceType != null && !string.IsNullOrEmpty(ErrorMessageResourceName))
            {
                return(new ValidationResult(LocalizationExtensions.GetResourceString(ErrorMessageResourceType, ErrorMessageResourceName)));
            }

            return(new ValidationResult(CommonResources.Validation_Error));
        }
Exemple #12
0
 public override void Install()
 {
     this._context.Install();
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.Widgets.m2hweb.Store", "Select Store Name", null);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.Widgets.m2hweb.Store.Hint", "Select Store Name", null);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.Widgets.m2hweb.Heading", "Title Header", null);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.Widgets.m2hweb.Heading.Hint", "Title Header", null);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.Widgets.m2hweb.Position", "Position", null);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.Widgets.m2hweb.Position.Hint", "Select Widgets Position.", null);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.Widgets.m2hweb.CustomDivHTML", "Html Widget Content", null);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.Widgets.m2hweb.CustomDivHTML.Hint", "Enter Html Content.", null);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.Widgets.m2hweb.Customscript", "Custom Js Script", null);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.Widgets.m2hweb.Customscript.Hint", "Enter Custom Js Script, if any.", null);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.Widgets.m2hweb.Published", "Published", null);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.Widgets.m2hweb.Published.Hint", "Check to publish this Content.Uncheck to unpublish", null);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.Widgets.m2hweb.DisplayOrder", "Display Order", null);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Plugins.Widgets.m2hweb.DisplayOrder.Hint", "Set the Content display order. 1 represents top of the list", null);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "admin.contentmanagement.widgets.m2hweb", "Manage M2hweb Widget", null);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "widget.m2hweb", "List M2hweb Html Widget (for Nop Task)", null);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Add.Widgets.m2hweb.Details", "Add Html Widget", null);
     LocalizationExtensions.AddOrUpdatePluginLocaleResource(this, "Edit.Widgets.m2hweb.Details", "Edit Html Widget", null);
     base.Install();
 }
Exemple #13
0
 public override void Uninstall()
 {
     this._context.Uninstall();
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.Widgets.m2hweb.Store");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.Widgets.m2hweb.Store.Hint");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.Widgets.m2hweb.Heading");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.Widgets.m2hweb.Heading.Hint");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.Widgets.m2hweb.Position");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.Widgets.m2hweb.Position.Hint");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.Widgets.m2hweb.CustomDivHTML");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.Widgets.m2hweb.CustomDivHTML.Hint");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.Widgets.m2hweb.Customscript");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.Widgets.m2hweb.Customscript.Hint");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.Widgets.m2hweb.Published");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.Widgets.m2hweb.Published.Hint");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.Widgets.m2hweb.DisplayOrder");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Plugins.Widgets.m2hweb.DisplayOrder.Hint");
     LocalizationExtensions.DeletePluginLocaleResource(this, "admin.contentmanagement.widgets.m2hweb");
     LocalizationExtensions.DeletePluginLocaleResource(this, "widget.m2hweb");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Add.Widgets.m2hweb.Details");
     LocalizationExtensions.DeletePluginLocaleResource(this, "Edit.Widgets.m2hweb.Details");
     base.Uninstall();
 }
Exemple #14
0
 public override object EvaluateExpression(object target, BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
 {
     // ReSharper disable InvokeAsExtensionMethod
     return(LocalizationExtensions.Localize(entry.Expression.Trim()));
     // ReSharper restore InvokeAsExtensionMethod
 }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            var validationResult = ValidationResult.Success;

            if (value == null)
            {
                return(validationResult);
            }

            if (!string.IsNullOrEmpty(OtherProperty) && Period != default)
            {
                if (IsValidPlusPeriod(value) && IsValidOtherParameter(value, validationContext) == PropertyValidationStatus.Success)
                {
                    return(validationResult);
                }

                if (ErrorMessageResourceType != null && !string.IsNullOrEmpty(ErrorMessageResourceName))
                {
                    validationResult = new ValidationResult(
                        string.Format(LocalizationExtensions.GetResourceString(ErrorMessageResourceType, ErrorMessageResourceName), Period, OtherProperty));
                }
                else
                {
                    validationResult = new ValidationResult(CommonResources.Validation_Error);
                }
            }
            else if (!string.IsNullOrEmpty(OtherProperty))
            {
                switch (IsValidOtherParameter(value, validationContext))
                {
                case PropertyValidationStatus.FiledIsNull:
                    validationResult = new ValidationResult(string.Format(CommonResources.Validation_UnknowPropery, OtherProperty));
                    break;

                case PropertyValidationStatus.IsInvalid:
                    if (ErrorMessageResourceType != null && !string.IsNullOrEmpty(ErrorMessageResourceName))
                    {
                        validationResult = new ValidationResult(
                            string.Format(LocalizationExtensions.GetResourceString(ErrorMessageResourceType, ErrorMessageResourceName), OtherProperty));
                    }
                    else
                    {
                        validationResult = new ValidationResult(CommonResources.Validation_Error);
                    }
                    break;

                case PropertyValidationStatus.CommonError:
                    validationResult = new ValidationResult(CommonResources.Validation_InvalidDateTime);
                    break;
                }
            }
            else if (Period != default(int) && !IsValidPlusPeriod(value))
            {
                if (ErrorMessageResourceType != null && !string.IsNullOrEmpty(ErrorMessageResourceName))
                {
                    validationResult = new ValidationResult(string.Format(LocalizationExtensions.GetResourceString(ErrorMessageResourceType, ErrorMessageResourceName), Period));
                }
                else
                {
                    validationResult = new ValidationResult(CommonResources.Validation_Error);
                }
            }

            return(validationResult);
        }
        private SettingSection BuildDisplaySection()
        {
            var section = new SettingSection(SystemUtil.GetStringResource("SettingSection_Display"));

            section.Add(new ToggleSetting
            {
                SettingData = new AppSettingData <bool>()
                {
                    Title         = SystemUtil.GetStringResource("DisplayTakeImageButtonSetting"),
                    Guide         = SystemUtil.GetStringResource("Guide_DisplayTakeImageButtonSetting"),
                    StateProvider = () => ApplicationSettings.GetInstance().IsShootButtonDisplayed,
                    StateObserver = enabled => ApplicationSettings.GetInstance().IsShootButtonDisplayed = enabled
                }
            });

            section.Add(new ToggleSetting
            {
                SettingData = new AppSettingData <bool>()
                {
                    Title         = SystemUtil.GetStringResource("DisplayHistogram"),
                    Guide         = SystemUtil.GetStringResource("Guide_Histogram"),
                    StateProvider = () => ApplicationSettings.GetInstance().IsHistogramDisplayed,
                    StateObserver = enabled => ApplicationSettings.GetInstance().IsHistogramDisplayed = enabled
                }
            });

            var FocusFrameSetting = new AppSettingData <bool>()
            {
                Title         = SystemUtil.GetStringResource("FocusFrameDisplay"),
                Guide         = SystemUtil.GetStringResource("Guide_FocusFrameDisplay"),
                StateProvider = () => ApplicationSettings.GetInstance().RequestFocusFrameInfo,
                StateObserver = enabled =>
                {
                    ApplicationSettings.GetInstance().RequestFocusFrameInfo = enabled;
                    // todo: support to show focus frames
                    //await SetupFocusFrame(enabled);
                    //if (!enabled) { _FocusFrameSurface.ClearFrames(); }
                }
            };

            section.Add(new ToggleSetting {
                SettingData = FocusFrameSetting
            });

            section.Add(new ToggleSetting
            {
                SettingData = new AppSettingData <bool>()
                {
                    Title         = SystemUtil.GetStringResource("LiveviewRotation"),
                    Guide         = SystemUtil.GetStringResource("LiveviewRotation_guide"),
                    StateProvider = () => ApplicationSettings.GetInstance().LiveviewRotationEnabled,
                    StateObserver = enabled =>
                    {
                        ApplicationSettings.GetInstance().LiveviewRotationEnabled = enabled;
                        // todo: support to rotate liveview image
                        //if (enabled && target != null && target.Status != null)
                        //{
                        //    RotateLiveviewImage(target.Status.LiveviewOrientationAsDouble);
                        //}
                        //else
                        //{
                        //    RotateLiveviewImage(0);
                        //}
                    }
                }
            });

            section.Add(new ToggleSetting
            {
                SettingData = new AppSettingData <bool>()
                {
                    Title         = SystemUtil.GetStringResource("FramingGrids"),
                    Guide         = SystemUtil.GetStringResource("Guide_FramingGrids"),
                    StateProvider = () => ApplicationSettings.GetInstance().FramingGridEnabled,
                    StateObserver = enabled =>
                    {
                        ApplicationSettings.GetInstance().FramingGridEnabled = enabled;
                        // screen_view_data.FramingGridDisplayed = enabled;
                    }
                }
            });

            var gridTypePanel = new ComboBoxSetting(new AppSettingData <int>()
            {
                Title         = SystemUtil.GetStringResource("AssistPattern"),
                StateProvider = () => (int)ApplicationSettings.GetInstance().GridType - 1,
                StateObserver = setting =>
                {
                    if (setting < 0)
                    {
                        return;
                    }
                    ApplicationSettings.GetInstance().GridType = (FramingGridTypes)(setting + 1);
                },
                Candidates = SettingValueConverter.FromFramingGrid(EnumUtil <FramingGridTypes> .GetValueEnumerable())
            });

            gridTypePanel.SetBinding(VisibilityProperty, new Binding
            {
                Source    = ApplicationSettings.GetInstance(),
                Path      = new PropertyPath(nameof(ApplicationSettings.FramingGridEnabled)),
                Mode      = BindingMode.OneWay,
                Converter = new BoolToVisibilityConverter(),
            });
            section.Add(gridTypePanel);

            var gridColorPanel = new ComboBoxSetting(new AppSettingData <int>()
            {
                Title         = SystemUtil.GetStringResource("FramingGridColor"),
                StateProvider = () => (int)ApplicationSettings.GetInstance().GridColor,
                StateObserver = setting =>
                {
                    if (setting < 0)
                    {
                        return;
                    }
                    ApplicationSettings.GetInstance().GridColor = (FramingGridColors)setting;
                },
                Candidates = SettingValueConverter.FromFramingGridColor(EnumUtil <FramingGridColors> .GetValueEnumerable())
            });

            gridColorPanel.SetBinding(VisibilityProperty, new Binding
            {
                Source    = ApplicationSettings.GetInstance(),
                Path      = new PropertyPath(nameof(ApplicationSettings.FramingGridEnabled)),
                Mode      = BindingMode.OneWay,
                Converter = new BoolToVisibilityConverter(),
            });
            section.Add(gridColorPanel);

            var fibonacciOriginPanel = new ComboBoxSetting(new AppSettingData <int>()
            {
                Title         = SystemUtil.GetStringResource("FibonacciSpiralOrigin"),
                StateProvider = () => (int)ApplicationSettings.GetInstance().FibonacciLineOrigin,
                StateObserver = setting =>
                {
                    if (setting < 0)
                    {
                        return;
                    }
                    ApplicationSettings.GetInstance().FibonacciLineOrigin = (FibonacciLineOrigins)setting;
                },
                Candidates = SettingValueConverter.FromFibonacciLineOrigin(EnumUtil <FibonacciLineOrigins> .GetValueEnumerable())
            });

            fibonacciOriginPanel.SetBinding(VisibilityProperty, new Binding
            {
                Source    = ApplicationSettings.GetInstance(),
                Path      = new PropertyPath(nameof(ApplicationSettings.IsFibonacciSpiralEnabled)),
                Mode      = BindingMode.OneWay,
                Converter = new BoolToVisibilityConverter(),
            });
            section.Add(fibonacciOriginPanel);

            section.Add(new ToggleSetting
            {
                SettingData = new AppSettingData <bool>()
                {
                    Title         = SystemUtil.GetStringResource("ForcePhoneView"),
                    Guide         = SystemUtil.GetStringResource("ForcePhoneView_Guide"),
                    StateProvider = () => ApplicationSettings.GetInstance().ForcePhoneView,
                    StateObserver = enabled => ApplicationSettings.GetInstance().ForcePhoneView = enabled
                }
            });

            section.Add(new ToggleSetting
            {
                SettingData = new AppSettingData <bool>()
                {
                    Title         = SystemUtil.GetStringResource("ShowKeyCheatSheet"),
                    Guide         = SystemUtil.GetStringResource("ShowKeyCheatSheet_Guide"),
                    StateProvider = () => ApplicationSettings.GetInstance().ShowKeyCheatSheet,
                    StateObserver = enabled => ApplicationSettings.GetInstance().ShowKeyCheatSheet = enabled
                }
            });

            section.Add(new ComboBoxSetting(new AppSettingData <int>()
            {
                Title         = "🌏 " + SystemUtil.GetStringResource("LanguageSetting"),
                Guide         = SystemUtil.GetStringResource("LanguageSetting_Guide"),
                StateProvider = () => (int)LocalizationExtensions.FromLang(ApplicationSettings.GetInstance().LanguageOverride),
                StateObserver = async(index) =>
                {
                    if (index == -1)
                    {
                        return;
                    }
                    var lang = ((Localization)index).AsLang();
                    if (ApplicationSettings.GetInstance().LanguageOverride != lang)
                    {
                        ApplicationSettings.GetInstance().LanguageOverride = lang;

                        RestartDialog.DataContext = ExitConfirmationSource;
                        if (await RestartDialog.ShowAsync() == ContentDialogResult.Primary)
                        {
                            Application.Current.Exit();
                        }
                    }
                },
                Candidates = SettingValueConverter.FromLocalization(EnumUtil <Localization> .GetValueEnumerable())
            }
                                            ));

            return(section);
        }