public UnityInspectorCodeInsightsHighlighting(DocumentRange range, [NotNull] string lenText, string tooltipText, [NotNull] string moreText,
                                               [NotNull] ICodeInsightsProvider provider, IDeclaredElement element,
                                               [CanBeNull] IconModel icon, UnityCodeInsightFieldUsageProvider.UnityPresentationType unityPresentationType)
     : base(range, lenText, tooltipText, moreText, provider, element, icon)
 {
     UnityPresentationType = unityPresentationType;
 }
コード例 #2
0
ファイル: IconService.cs プロジェクト: vchedi/Umbraco-CMS
        /// <summary>
        /// Gets an IconModel containing the icon name and SvgString
        /// </summary>
        /// <param name="iconName"></param>
        /// <param name="iconPath"></param>
        /// <returns><see cref="IconModel"/></returns>
        private static IconModel CreateIconModel(string iconName, string iconPath)
        {
            if (string.IsNullOrWhiteSpace(iconPath))
            {
                return(null);
            }

            try
            {
                var sanitizer = new HtmlSanitizer();
                sanitizer.AllowedAttributes.UnionWith(Constants.SvgSanitizer.Attributes);
                sanitizer.AllowedCssProperties.UnionWith(Constants.SvgSanitizer.Attributes);
                sanitizer.AllowedTags.UnionWith(Constants.SvgSanitizer.Tags);

                var svgContent      = System.IO.File.ReadAllText(iconPath);
                var sanitizedString = sanitizer.Sanitize(svgContent);

                var svg = new IconModel
                {
                    Name      = iconName,
                    SvgString = sanitizedString
                };

                return(svg);
            }
            catch
            {
                return(null);
            }
        }
コード例 #3
0
 public void AddHighlighting(IHighlightingConsumer consumer, IDeclaration declaration,
                             IDeclaredElement declaredElement, int count, string tooltipText, string moreText, bool estimatedResult,
                             IconModel iconModel)
 {
     consumer.AddHighlighting(new CodeInsightsHighlighting(declaration.GetNameDocumentRange(),
                                                           GetText(count, estimatedResult), tooltipText, moreText, this, declaredElement, iconModel));
 }
コード例 #4
0
        /// <summary>
        /// Gets an IconModel containing the icon name and SvgString
        /// </summary>
        /// <param name="iconName"></param>
        /// <param name="iconPath"></param>
        /// <returns></returns>
        private IconModel CreateIconModel(string iconName, string iconPath)
        {
            var sanitizer = new HtmlSanitizer();

            sanitizer.AllowedAttributes.UnionWith(Core.Constants.SvgSanitizer.Attributes);
            sanitizer.AllowedCssProperties.UnionWith(Core.Constants.SvgSanitizer.Attributes);
            sanitizer.AllowedTags.UnionWith(Core.Constants.SvgSanitizer.Tags);

            try
            {
                var svgContent      = File.ReadAllText(iconPath);
                var sanitizedString = sanitizer.Sanitize(svgContent);

                var svg = new IconModel
                {
                    Name      = iconName,
                    SvgString = sanitizedString
                };

                return(svg);
            }
            catch
            {
                return(null);
            }
        }
コード例 #5
0
 private async Task IconDblClickInternal(IconModel icon)
 {
     if (icon.Type == FileTypes.mp3)
     {
         await jsRuntime.InvokeAsync <string>("PlayFile", "../assets/win31.mp3");
     }
 }
コード例 #6
0
ファイル: IconModelParser.cs プロジェクト: iomeone/FoBOFD
 public IconModel ParseIconModel(IconModel iconModel, string sourePath)
 {
     iconModel.ActiveImageSource = ConvertIconToImageSource(this.ShellIcon.GetSmallIcon(sourePath));
     iconModel.SmallImageSource  = iconModel.ActiveImageSource;
     iconModel.LargeImageSource  = ConvertIconToImageSource(this.ShellIcon.GetLargeIcon(sourePath));
     return(iconModel);
 }
コード例 #7
0
 public UnityCodeInsightsHighlighting(DocumentRange range, [NotNull] string lenText, [NotNull] string moreText,
                                      [NotNull] ICodeInsightsProvider provider, IDeclaredElement element,
                                      [CanBeNull] IconModel icon, IEnumerable <BulbMenuItem> menuItems,
                                      List <CodeLensEntryExtraActionModel> extraActions = null)
     : base(range, lenText, moreText, provider, element, icon, extraActions)
 {
     MenuItems = menuItems.ToList();
 }
コード例 #8
0
 internal IconViewModel(IconModel iconModel, IExplorerTreeItemIconConfiguration iconConfiguration)
 {
     this.LargeImageSource  = iconModel.LargeImageSource;
     this.SmallImageSource  = iconModel.SmallImageSource;
     this.IconConfiguration = iconConfiguration;
     this.IconModel         = iconModel;
     this.InitActiveImageSource(iconConfiguration.ActiveIconState);
 }
コード例 #9
0
 public IconViewModel(IconModel model)
     : this()
 {
     Pinned    = true;
     Path      = model.Path;
     ImagePath = model.ImagePath;
     Name      = model.Name;
     Text      = StringUtils.LimitCharacters(model.Name, 40, 50);
 }
コード例 #10
0
        public async Task <IActionResult> UploadAlbum([FromBody] IconModel icon)
        {
            var mapping = new Func <ProductSpec, Task <ProductSpec> >(async(spec) =>
            {
                var albumIds = string.IsNullOrWhiteSpace(spec.Album) ? new List <string>() : spec.Album.Split(',', StringSplitOptions.RemoveEmptyEntries).ToList();
                albumIds.Add(icon.AssetId);
                spec.Album = string.Join(",", albumIds);
                return(await Task.FromResult(spec));
            });

            return(await _PutRequest(icon.ObjId, mapping));
        }
コード例 #11
0
        private void AddEventsHighlighting([NotNull] IHighlightingConsumer consumer,
                                           [NotNull] IDeclaration element,
                                           [NotNull] IconModel iconModel)
        {
            var declaredElement           = element.DeclaredElement;
            var eventsCount               = UnityEventsElementContainer.GetAssetUsagesCount(declaredElement, out var unityEventsEstimatedResult);
            var animationEventUsagesCount = myAnimationEventUsagesContainer
                                            .GetEventUsagesCountFor(declaredElement, out var animationEventsEstimatedResult);

            myUsagesCodeVisionProvider.AddHighlighting(consumer, element, declaredElement,
                                                       animationEventUsagesCount + eventsCount, "Click to view usages in assets", "Assets usages",
                                                       unityEventsEstimatedResult || animationEventsEstimatedResult, iconModel);
        }
コード例 #12
0
        private void AddScriptUsagesHighlighting([NotNull] IHighlightingConsumer consumer,
                                                 [NotNull] IClassLikeDeclaration declaration,
                                                 [NotNull] IconModel iconModel)
        {
            var count           = 0;
            var estimatedResult = false;

            foreach (var scriptUsagesContainer in myScriptsUsagesElementContainers)
            {
                count          += scriptUsagesContainer.GetScriptUsagesCount(declaration, out var result);
                estimatedResult = estimatedResult || result;
            }
            myUsagesCodeVisionProvider.AddHighlighting(consumer, declaration, declaration.DeclaredElement, count,
                                                       "Click to view usages in assets", "Assets usages", estimatedResult, iconModel);
        }
コード例 #13
0
ファイル: IconService.cs プロジェクト: robertjf/Umbraco-CMS
    /// <summary>
    ///     Gets an IconModel containing the icon name and SvgString
    /// </summary>
    /// <param name="iconName"></param>
    /// <param name="iconPath"></param>
    /// <returns></returns>
    private IconModel?CreateIconModel(string iconName, string iconPath)
    {
        try
        {
            var svgContent = File.ReadAllText(iconPath);

            var svg = new IconModel {
                Name = iconName, SvgString = svgContent
            };

            return(svg);
        }
        catch
        {
            return(null);
        }
    }
コード例 #14
0
        public async Task <IActionResult> DeleteAlbum([FromBody] IconModel icon)
        {
            var mapping = new Func <ProductSpec, Task <ProductSpec> >(async(spec) =>
            {
                var albumIds = string.IsNullOrWhiteSpace(spec.Album) ? new List <string>() : spec.Album.Split(',', StringSplitOptions.RemoveEmptyEntries).ToList();
                for (int idx = albumIds.Count - 1; idx >= 0; idx--)
                {
                    if (albumIds[idx] == icon.AssetId)
                    {
                        albumIds.RemoveAt(idx);
                    }
                }
                spec.Album = string.Join(",", albumIds);
                return(await Task.FromResult(spec));
            });

            return(await _PutRequest(icon.ObjId, mapping));
        }
コード例 #15
0
        protected override void AddHighlighting(IHighlightingConsumer consumer, ICSharpDeclaration element, string text, string tooltip,
                                                DaemonProcessKind kind)
        {
            var iconId = element.HasHotIcon(CallGraphSwaExtensionProvider, SettingsStore.BoundSettingsStore,
                                            MarksProvider, kind, ElementIdProvider)
                ? InsightUnityIcons.InsightHot.Id
                : InsightUnityIcons.InsightUnity.Id;

            if (RiderIconProviderUtil.IsCodeVisionEnabled(SettingsStore.BoundSettingsStore, myCodeInsightProvider.ProviderId,
                                                          () => { base.AddHighlighting(consumer, element, text, tooltip, kind); }, out var useFallback))
            {
                if (!useFallback)
                {
                    consumer.AddImplicitConfigurableHighlighting(element);
                }

                IconModel iconModel = myIconHost.Transform(iconId);
                if (myAssetIndexingSupport.IsEnabled.Value && myAssetSerializationMode.IsForceText)
                {
                    if (myDeferredCacheController.IsProcessingFiles())
                    {
                        iconModel = myIconHost.Transform(CodeInsightsThemedIcons.InsightWait.Id);
                    }

                    if (!myDeferredCacheController.CompletedOnce.Value)
                    {
                        tooltip = "Usages in assets are not available during asset indexing";
                    }
                }

                if (!myAssetIndexingSupport.IsEnabled.Value || !myDeferredCacheController.CompletedOnce.Value || !myAssetSerializationMode.IsForceText)
                {
                    myCodeInsightProvider.AddHighlighting(consumer, element, element.DeclaredElement, text,
                                                          tooltip, text, iconModel, GetActions(element),
                                                          RiderIconProviderUtil.GetExtraActions(mySolutionTracker, myBackendUnityHost));
                }
                else
                {
                    var count = UnityEventsElementContainer.GetAssetUsagesCount(element.DeclaredElement, out var estimate);
                    myUsagesCodeVisionProvider.AddHighlighting(consumer, element, element.DeclaredElement, count,
                                                               "Click to view usages in assets", "Assets usages", estimate, iconModel);
                }
            }
        }
コード例 #16
0
        public async Task <IActionResult> ChangeICon([FromBody] IconModel icon)
        {
            var mapping = new Func <T, Task <T> >(async(spec) =>
            {
                spec.Icon = icon.AssetId;
                return(await Task.FromResult(spec));
            });

            var handle = new Func <T, DTO, Task <IActionResult> >(async(entity, dto) =>
            {
                var new_dto  = new DTO();
                new_dto.Id   = entity.Id;
                new_dto.Name = entity.Name;
                new_dto.Icon = dto.Icon;
                return(await Task.FromResult(Ok(new_dto)));
            });

            return(await _PutRequest(icon.ObjId, mapping, handle));
        }
コード例 #17
0
ファイル: IconService.cs プロジェクト: waldvmar/Umbraco-CMS
        /// <summary>
        /// Gets an IconModel containing the icon name and SvgString
        /// </summary>
        /// <param name="iconName"></param>
        /// <param name="iconPath"></param>
        /// <returns></returns>
        private IconModel CreateIconModel(string iconName, string iconPath)
        {
            try
            {
                var svgContent      = System.IO.File.ReadAllText(iconPath);
                var sanitizedString = _htmlSanitizer.Sanitize(svgContent);

                var svg = new IconModel
                {
                    Name      = iconName,
                    SvgString = sanitizedString
                };

                return(svg);
            }
            catch
            {
                return(null);
            }
        }
コード例 #18
0
ファイル: HomeController.cs プロジェクト: DevMammadov/Gunicon
        public async Task <IActionResult> addIcon(string name, string tags, string type, IFormFile file)
        {
            string uniqFileName = (string.IsNullOrEmpty(name)) ? file.FileName : name;
            string uploadTo     = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\icons", uniqFileName);

            using (var fileSteam = new FileStream(uploadTo, FileMode.Create))
            {
                await file.CopyToAsync(fileSteam);
            }

            IconModel newIcon = new IconModel()
            {
                id   = Guid.NewGuid().ToString(),
                name = name,
                tags = string.IsNullOrEmpty(tags) ? new List <string>() : tags.Split(",").ToList(),
                type = type,
                date = DateTime.Now
            };
            string fromTxt = System.IO.File.ReadAllText("DB\\icons.txt");

            if (string.IsNullOrEmpty(fromTxt))
            {
                List <IconModel> singleList = new List <IconModel>();
                singleList.Add(newIcon);
                var serializedIcon = JsonConvert.SerializeObject(singleList);
                System.IO.File.WriteAllText("DB\\icons.txt", serializedIcon);
            }
            else
            {
                List <IconModel> iconList = JsonConvert.DeserializeObject <List <IconModel> >(fromTxt);
                iconList.Add(newIcon);
                var serializedList = JsonConvert.SerializeObject(iconList);
                System.IO.File.WriteAllText("DB\\icons.txt", string.Empty);
                System.IO.File.WriteAllText("DB\\icons.txt", serializedList);
            }

            string fromFile = System.IO.File.ReadAllText("DB\\icons.txt");

            return(Ok(fromFile));
        }
コード例 #19
0
ファイル: HomeController.cs プロジェクト: DevMammadov/Gunicon
        public IActionResult DeleteIcon(string id)
        {
            string           fromTxt      = System.IO.File.ReadAllText("DB\\icons.txt");
            List <IconModel> iconList     = JsonConvert.DeserializeObject <List <IconModel> >(fromTxt);
            IconModel        iconToRemove = iconList.FirstOrDefault(i => i.id == id);

            iconList.Remove(iconToRemove);
            var serializedList = JsonConvert.SerializeObject(iconList);

            System.IO.File.WriteAllText("DB\\icons.txt", string.Empty);
            System.IO.File.WriteAllText("DB\\icons.txt", serializedList);

            // remove file from folder
            if (System.IO.File.Exists(Path.Combine("wwwroot\\icons", iconToRemove.name)))
            {
                System.IO.File.Delete(Path.Combine("wwwroot\\icons", iconToRemove.name));
            }

            string fromFile = System.IO.File.ReadAllText("DB\\icons.txt");

            return(Ok(fromFile));
        }
コード例 #20
0
        protected override void AddMonoBehaviourHighlighting(IHighlightingConsumer consumer, IClassLikeDeclaration declaration, string text,
                                                             string tooltip, DaemonProcessKind kind)
        {
            if (RiderIconProviderUtil.IsCodeVisionEnabled(SettingsStore.BoundSettingsStore, myCodeInsightProvider.ProviderId,
                                                          () => { base.AddHighlighting(consumer, declaration, text, tooltip, kind); }, out var useFallback))
            {
                if (!useFallback)
                {
                    consumer.AddImplicitConfigurableHighlighting(declaration);
                }

                IconModel iconModel = myIconHost.Transform(InsightUnityIcons.InsightUnity.Id);
                if (myAssetIndexingSupport.IsEnabled.Value && myAssetSerializationMode.IsForceText)
                {
                    if (myDeferredCacheController.IsProcessingFiles())
                    {
                        iconModel = myIconHost.Transform(CodeInsightsThemedIcons.InsightWait.Id);
                    }

                    if (!myDeferredCacheController.CompletedOnce.Value)
                    {
                        tooltip = "Usages in assets are not available during asset indexing";
                    }
                }

                if (!myAssetIndexingSupport.IsEnabled.Value || !myDeferredCacheController.CompletedOnce.Value || !myAssetSerializationMode.IsForceText)
                {
                    myCodeInsightProvider.AddHighlighting(consumer, declaration, declaration.DeclaredElement, text,
                                                          tooltip, text, iconModel, GetActions(declaration),
                                                          RiderIconProviderUtil.GetExtraActions(mySolutionTracker, myBackendUnityHost));
                }
                else
                {
                    var count = myAssetScriptUsagesElementContainer.GetUsagesCount(declaration, out var estimatedResult);
                    myUsagesCodeVisionProvider.AddHighlighting(consumer, declaration, declaration.DeclaredElement, count,
                                                               "Click to view usages in assets", "Assets usages", estimatedResult, iconModel);
                }
            }
        }
コード例 #21
0
        public void AddInspectorHighlighting(IHighlightingConsumer consumer, ICSharpDeclaration element,
                                             IDeclaredElement declaredElement, string baseDisplayName, string baseTooltip, string moreText, IconModel iconModel,
                                             IEnumerable <BulbMenuItem> items, List <CodeLensEntryExtraActionModel> extraActions)
        {
            string displayName = null;
            string tooltip     = "Values from Unity Editor Inspector";

            var solution = element.GetSolution();

            Assertion.Assert(solution.Locks.IsReadAccessAllowed(), "ReadLock required");

            var field          = (declaredElement as IField).NotNull();
            var type           = field.Type;
            var containingType = field.GetContainingType();

            if (containingType == null)
            {
                return;
            }

            var(guid, propertyNames) = GetAssetGuidAndPropertyName(solution, field);
            if (guid == null || propertyNames == null || propertyNames.Length == 0)
            {
                return;
            }

            var presentationType = GetUnityPresentationType(type);

            if (!myDeferredCacheController.CompletedOnce.Value || ShouldShowUnknownPresentation(presentationType))
            {
                base.AddHighlighting(consumer, element, field, baseDisplayName, baseTooltip, moreText, iconModel, items, extraActions);
                return;
            }

            var initializer = (element as IFieldDeclaration).NotNull("element as IFieldDeclaration != null").Initial;
            var initValue   = (initializer as IExpressionInitializer)?.Value?.ConstantValue.Value;

            var initValueUnityPresentation = GetUnitySerializedPresentation(presentationType, initValue);

            if (myInspectorValuesContainer.IsIndexResultEstimated(guid, containingType, propertyNames))
            {
                var count = myInspectorValuesContainer.GetAffectedFiles(guid, propertyNames) - myInspectorValuesContainer.GetAffectedFilesWithSpecificValue(guid, propertyNames, initValueUnityPresentation);
                displayName = $"{count}+ changes";
            }
            else
            {
                var initValueCount =
                    myInspectorValuesContainer.GetValueCount(guid, propertyNames, initValueUnityPresentation);

                if (initValueCount == 0 && myInspectorValuesContainer.GetUniqueValuesCount(guid, propertyNames) == 1
                    ) // only modified value
                {
                    var values = myInspectorValuesContainer.GetUniqueValues(guid, propertyNames).ToArray();
                    Assertion.Assert(values.Length == 1, "valueWithLocations.Length == 1"); //performance assertion
                    var value = values[0];
                    displayName = value.GetPresentation(solution, field, false);
                }
                else if (initValueCount > 0 &&
                         myInspectorValuesContainer.GetUniqueValuesCount(guid, propertyNames) == 2)
                {
                    // original value & only one modified value
                    var values = myInspectorValuesContainer.GetUniqueValues(guid, propertyNames).ToArray();
                    Assertion.Assert(values.Length == 2, "values.Length == 2"); //performance assertion

                    var anotherValueWithLocation = values.FirstOrDefault(t => !t.Equals(initValueUnityPresentation));
                    displayName = anotherValueWithLocation?.GetPresentation(solution, field, false);
                }

                if (displayName == null || displayName.Equals("..."))
                {
                    var count = myInspectorValuesContainer.GetAffectedFiles(guid, propertyNames) -
                                myInspectorValuesContainer.GetAffectedFilesWithSpecificValue(guid, propertyNames,
                                                                                             initValueUnityPresentation);
                    if (count == 0)
                    {
                        displayName = "Unchanged";
                    }
                    else
                    {
                        var word = count == 1 ? "asset" : "assets";
                        displayName = $"Changed in {count} {word}";
                    }
                }
            }

            consumer.AddHighlighting(new CodeInsightsHighlighting(element.GetNameDocumentRange(),
                                                                  displayName, tooltip, "Property Inspector values", this,
                                                                  declaredElement, iconModel));
        }
コード例 #22
0
ファイル: IconViewModelTest.cs プロジェクト: iomeone/FoBOFD
 private IconViewModel CreateIconVM(IconModel iconModel, IExplorerTreeItemIconConfiguration iconConfiguration)
 {
     return(new IconViewModel(iconModel, iconConfiguration));
 }
コード例 #23
0
 public virtual void AddHighlighting(IHighlightingConsumer consumer, ICSharpDeclaration element,
                                     IDeclaredElement declaredElement, string displayName, string tooltip, string moreText, IconModel iconModel,
                                     IEnumerable <BulbMenuItem> items, List <CodeLensEntryExtraActionModel> extraActions)
 {
     consumer.AddHighlighting(new UnityCodeInsightsHighlighting(element.GetNameDocumentRange(),
                                                                displayName, tooltip, moreText, this, declaredElement, iconModel, items,
                                                                extraActions));
 }
コード例 #24
0
        public JsonResult AddUpdateClaims(SystemClaims systemClaims, int clickType)
        {
            JsonResult result = null;

            try
            {
                Type           type       = systemClaims.GetType();
                PropertyInfo[] properties = type.GetProperties(BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.GetProperty);
                foreach (var item in properties)
                {
                    if (item.PropertyType == typeof(string) && item.GetValue(systemClaims, null) == null)
                    {
                        item.SetValue(systemClaims, "", null);
                    }
                }
                //操作数据之前  对的补齐和正确性的验证
                //审核通过之类的该状态的调用存储过程 暂时未处理
                //......

                if (clickType == 1)//审核未通过
                {
                    systemClaims.IsApproved       = false;
                    systemClaims.ApproverUserName = this.UserInfo.RealName;
                    systemClaims.ApproverTime     = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }
                else if (clickType == 2)//审核通过
                {
                    systemClaims.IsApproved       = true;
                    systemClaims.ApproverUserName = this.UserInfo.RealName;
                    systemClaims.ApproverTime     = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }

                systemClaims.DetailsImages1 = HttpUtility.UrlDecode(systemClaims.DetailsImages1);
                systemClaims.DetailsImages2 = HttpUtility.UrlDecode(systemClaims.DetailsImages2);
                systemClaims.DetailsImages3 = HttpUtility.UrlDecode(systemClaims.DetailsImages3);
                systemClaims.DetailsImages4 = HttpUtility.UrlDecode(systemClaims.DetailsImages4);
                systemClaims.DetailsImages5 = HttpUtility.UrlDecode(systemClaims.DetailsImages5);

                DataFornat dataformat = new DataFornat();
                systemClaims.TitleImagePath = dataformat.ReplaceDomain(systemClaims.TitleImagePath, AppConfigHelper.MainSiteUrl);
                systemClaims.DetailsImages1 = dataformat.ReplaceImageSrc(systemClaims.DetailsImages1, AppConfigHelper.MainSiteUrl);
                systemClaims.DetailsImages2 = dataformat.ReplaceImageSrc(systemClaims.DetailsImages2, AppConfigHelper.MainSiteUrl);
                systemClaims.DetailsImages3 = dataformat.ReplaceImageSrc(systemClaims.DetailsImages3, AppConfigHelper.MainSiteUrl);
                systemClaims.DetailsImages4 = dataformat.ReplaceImageSrc(systemClaims.DetailsImages4, AppConfigHelper.MainSiteUrl);
                systemClaims.DetailsImages5 = dataformat.ReplaceImageSrc(systemClaims.DetailsImages5, AppConfigHelper.MainSiteUrl);



                string           strIcons      = HttpUtility.UrlDecode(systemClaims.Icons);
                List <IconModel> IconModelList = new List <IconModel>();
                string[]         strArr        = strIcons.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var item in strArr)
                {
                    IconModel model   = new IconModel();
                    string[]  strItem = item.Split('^');
                    if (strItem.Length >= 3)
                    {
                        model.IconType    = strItem[0];
                        model.Title       = strItem[1];
                        model.Description = strItem[2];
                        model.StyleName   = strItem[3];
                    }
                    if (strItem.Length >= 4)
                    {
                        model.AtrrCode = strItem[4];
                    }
                    IconModelList.Add(model);
                }
                systemClaims.Icons = IconModelList.ToJsonString <List <IconModel> >();

                //添加或者修改
                BaseResultDto <string> resultDto = new BaseResultDto <string>();
                string message = string.Empty;
                if (systemClaims.ID > 0)
                {
                    #region 修改
                    RQUpdate <SystemClaims> model = new RQUpdate <SystemClaims>();
                    model.Tag = systemClaims;
                    bool rs = false;
                    if (clickType == 0 || clickType == 2)//修改资料
                    {
                        //更新修改的字段数据
                        model.UpdateFileds.AddRange(new string[] {
                            "Title", "TitleImagePath", "LoanAmount", "APR", "LoanPeriod", "SingleAmount",
                            "GuaranteeWay", "RepaymentWat", "InvestmentEndTime", "EarningsStartTime", "PawnSpec",
                            "Icons", "DetailsImages1", "DetailsImages2", "DetailsImages3", "DetailsImages4", "DetailsImages5"
                        });
                        rs = HttpHelper.CreatHelper().DoPostObject <bool>(string.Format("{0}Claims/UpdatePartal", this.WebApiUrl), model);
                    }
                    if (clickType == 2 && rs)
                    {
                        //更新审核字段数据
                        RQAduitApplay aduitApplay = new RQAduitApplay();
                        aduitApplay.ApplyID          = systemClaims.ClaimsApplayID;
                        aduitApplay.ClaimsID         = systemClaims.ID;
                        aduitApplay.ApproverUserName = systemClaims.ApproverUserName;
                        aduitApplay.OperatorUserId   = this.UserInfo.ID;
                        aduitApplay.Succeed          = systemClaims.IsApproved;
                        aduitApplay.IP = this.RequestIP;
                        aduitApplay.OperatorContent = (clickType == 1 ? "审核未通过" : "审核通过");
                        rs = HttpHelper.CreatHelper().DoPostObject <bool>(string.Format("{0}ClaimsApplay/AduitApplayClaims", this.WebApiUrl), aduitApplay);
                    }
                    //修改
                    if (rs)
                    {
                        resultDto.ErrorCode = 1;
                        resultDto.ErrorMsg  = "成功";
                    }
                    else
                    {
                        resultDto.ErrorMsg = "失败";
                    }
                    #endregion
                }
                else
                {
                    systemClaims.PublishTime = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    systemClaims.Publisher   = this.UserInfo.RealName;
                    int rs = HttpHelper.CreatHelper().DoPostObject <int>(string.Format("{0}Claims/Add", this.WebApiUrl), systemClaims);
                    //添加
                    if (rs > 0)
                    {
                        resultDto.ErrorCode = 1;
                        resultDto.ErrorMsg  = "成功";
                    }
                    else
                    {
                        resultDto.ErrorMsg = "失败";
                    }
                }
                result = Json(new { status = resultDto.ErrorCode, message = resultDto.ErrorMsg }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                result = Json(new { status = -1, message = ex.Message }, JsonRequestBehavior.AllowGet);
            }
            return(result);
        }
コード例 #25
0
        public void SaveBoards(List <IconReference> icons, List <StoredIconReference> storedIcons, bool inSingleMode)
        {
            Device.BeginInvokeOnMainThread(() =>
            {
                List <IconModel> mJsonIconArray             = new List <IconModel>();
                List <FolderModel> mJsonFolderArray         = new List <FolderModel>();
                List <StoredIconModel> mJsonStoredIconArray = new List <StoredIconModel>();

                foreach (IconReference iconRef in icons)
                {
                    if (iconRef.Sprite.Tag == SpriteTypes.IconTag)
                    {
                        var mModel = new IconModel("", "", 0, 0, -1, iconRef.Sprite.ScaleX);

                        var spriteLabel = iconRef.Sprite.GetChildByTag(SpriteTypes.ContentTag) as CCLabel;

                        if (spriteLabel != null)
                        {
                            mModel.Text = spriteLabel.Text;
                        }

                        mModel.Base64      = iconRef.Base64;
                        mModel.X           = (int)iconRef.Sprite.PositionX;
                        mModel.Y           = (int)iconRef.Sprite.PositionY;
                        mModel.Tag         = iconRef.Sprite.Tag;
                        mModel.TextScale   = spriteLabel.ScaleX;
                        mModel.TextVisible = spriteLabel.Visible;

                        mJsonIconArray.Add(mModel);
                    }
                    else if (iconRef.Sprite.Tag == SpriteTypes.FolderTag)
                    {
                        var mModel = new FolderModel("", "", 0, 0, -1, iconRef.Sprite.ScaleX);

                        var spriteLabel = iconRef.Sprite.GetChildByTag(SpriteTypes.ContentTag) as CCLabel;

                        if (spriteLabel != null)
                        {
                            mModel.Text = spriteLabel.Text;
                        }

                        mModel.AssetName   = iconRef.Base64;
                        mModel.X           = (int)iconRef.Sprite.PositionX;
                        mModel.Y           = (int)iconRef.Sprite.PositionY;
                        mModel.Tag         = iconRef.Sprite.Tag;
                        mModel.TextScale   = spriteLabel.ScaleX;
                        mModel.TextVisible = spriteLabel.Visible;

                        mJsonFolderArray.Add(mModel);
                    }
                }

                foreach (StoredIconReference mStoredRef in storedIcons)
                {
                    var mModel = new StoredIconModel("", "", 0, 0, -1, mStoredRef.Base64, mStoredRef.Sprite.ScaleX);

                    var spriteLabel = mStoredRef.Sprite.GetChildByTag(SpriteTypes.ContentTag) as CCLabel;

                    if (spriteLabel != null)
                    {
                        mModel.Text = spriteLabel.Text;
                    }

                    mModel.Base64      = mStoredRef.Base64;
                    mModel.Folder      = mStoredRef.FolderName;
                    mModel.X           = (int)mStoredRef.Sprite.PositionX;
                    mModel.Y           = (int)mStoredRef.Sprite.PositionY;
                    mModel.Tag         = mStoredRef.Sprite.Tag;
                    mModel.TextScale   = spriteLabel.ScaleX;
                    mModel.TextVisible = spriteLabel.Visible;

                    mJsonStoredIconArray.Add(mModel);
                }

                var mIconStorage         = new IconStorageObject();
                mIconStorage.Icons       = mJsonIconArray;
                mIconStorage.Folders     = mJsonFolderArray;
                mIconStorage.StoredIcons = mJsonStoredIconArray;
                mIconStorage.SingleMode  = inSingleMode;

                var mJsonString = JsonConvert.SerializeObject(mIconStorage);

                Console.WriteLine("saved!");

                DependencyService.Get <ISaveAndLoad>().SaveJSON("IconBoard", mJsonString);
            });
        }
コード例 #26
0
        public void AddInspectorHighlighting(IHighlightingConsumer consumer, ICSharpDeclaration element,
                                             IDeclaredElement declaredElement, string baseDisplayName, string baseTooltip, string moreText, IconModel iconModel,
                                             IEnumerable <BulbMenuItem> items, List <CodeLensEntryExtraActionModel> extraActions)
        {
            string displayName = null;

            var solution = element.GetSolution();

            Assertion.Assert(solution.Locks.IsReadAccessAllowed(), "ReadLock required");

            var field          = (declaredElement as IField).NotNull();
            var type           = field.Type;
            var containingType = field.GetContainingType();

            if (containingType == null)
            {
                base.AddHighlighting(consumer, element, field, baseDisplayName, baseTooltip, moreText, iconModel, items, extraActions);
                return;
            }

            var(guidN, propertyNames) = GetAssetGuidAndPropertyName(solution, field);
            if (guidN == null || propertyNames.Length == 0)
            {
                base.AddHighlighting(consumer, element, field, baseDisplayName, baseTooltip, moreText, iconModel, items, extraActions);
                return;
            }

            var guid = guidN.Value;

            var presentationType = GetUnityPresentationType(type);

            if (!myDeferredCacheController.CompletedOnce.Value || ShouldShowUnknownPresentation(presentationType))
            {
                base.AddHighlighting(consumer, element, field, baseDisplayName, baseTooltip, moreText, iconModel, items, extraActions);
                return;
            }

            if (presentationType == UnityPresentationType.UnityEvent)
            {
                var count = myUnityEventsElementContainer.GetUsageCountForEvent(field, out var estimated);
                var sb    = new StringBuilder();
                if (count == 0 && !estimated)
                {
                    sb.Append("No methods");
                }
                else
                {
                    sb.Append(count);
                    if (estimated)
                    {
                        sb.Append('+');
                    }
                    sb.Append(" ");
                    sb.Append("method");
                    if (estimated || count > 1)
                    {
                        sb.Append("s");
                    }
                }

                consumer.AddHighlighting(new UnityInspectorCodeInsightsHighlighting(element.GetNameDocumentRange(),
                                                                                    sb.ToString(), GetTooltip(count, estimated, false), "Methods", this,
                                                                                    declaredElement, iconModel, presentationType));
                return;
            }


            var initializer = (element as IFieldDeclaration).NotNull("element as IFieldDeclaration != null").Initial;
            var initValue   = (initializer as IExpressionInitializer)?.Value?.ConstantValue.Value;

            var initValueUnityPresentation = GetUnitySerializedPresentation(presentationType, initValue);

            int  changesCount;
            bool isEstimated    = false;
            bool isUniqueChange = false;

            if (myInspectorValuesContainer.IsIndexResultEstimated(guid, containingType, propertyNames))
            {
                changesCount = myInspectorValuesContainer.GetAffectedFiles(guid, propertyNames) - myInspectorValuesContainer.GetAffectedFilesWithSpecificValue(guid, propertyNames, initValueUnityPresentation);
                displayName  = $"Changed in {changesCount}+ assets";
                isEstimated  = true;
            }
            else
            {
                changesCount = 0;
                var initValueCount = myInspectorValuesContainer.GetValueCount(guid, propertyNames, initValueUnityPresentation);

                if (initValueCount == 0 && myInspectorValuesContainer.GetUniqueValuesCount(guid, propertyNames) == 1) // only modified value
                {
                    isUniqueChange = true;
                    var value = myInspectorValuesContainer.GetUniqueValueDifferTo(guid, propertyNames, null);
                    displayName = value.GetPresentation(solution, field, false);
                }
                else if (initValueCount > 0 && myInspectorValuesContainer.GetUniqueValuesCount(guid, propertyNames) == 2)
                {
                    isUniqueChange = true;
                    // original value & only one modified value
                    var anotherValueWithLocation = myInspectorValuesContainer.GetUniqueValueDifferTo(guid, propertyNames, initValueUnityPresentation);
                    displayName = anotherValueWithLocation.GetPresentation(solution, field, false);
                }

                if (displayName == null || displayName.Equals("..."))
                {
                    changesCount = myInspectorValuesContainer.GetAffectedFiles(guid, propertyNames) -
                                   myInspectorValuesContainer.GetAffectedFilesWithSpecificValue(guid, propertyNames,
                                                                                                initValueUnityPresentation);
                    if (changesCount == 0)
                    {
                        displayName = "Unchanged";
                    }
                    else
                    {
                        var word = NounUtil.ToPluralOrSingularQuick(changesCount, "asset", "assets");
                        displayName = $"Changed in {changesCount} {word}";
                    }
                }
            }

            consumer.AddHighlighting(new UnityInspectorCodeInsightsHighlighting(element.GetNameDocumentRange(),
                                                                                displayName, GetTooltip(changesCount, isEstimated, isUniqueChange), "Property Inspector values", this,
                                                                                declaredElement, iconModel, presentationType));
        }
コード例 #27
0
        public CarouselModel Create()
        {
            #region carousel

            CarouselModel carouselModel = new CarouselModel();

            List <BubbleModel> carouselContentList = new List <BubbleModel>();

            #region body_bubble_1

            BubbleModel bubbleModel = new BubbleModel();

            #region box_1

            BoxModel mainBoxModel = new BoxModel()
            {
                layout     = FlexLayout.vertical,
                paddingAll = "0px"
            };
            List <FlexComponentModel> mainboxModelList = new List <FlexComponentModel>();

            #region box_1_content_1

            ImageModel contentModel1 = new ImageModel()
            {
                url         = "https://scdn.line-apps.com/n/channel_devcenter/img/flexsnapshot/clip/clip1.jpg",
                size        = ImageSize.full,
                aspectMode  = ImageAspectMode.cover,
                aspectRatio = ImageAspectRatio.R2To3,
                gravity     = FlexGravity.top
            };
            mainboxModelList.Add(contentModel1);

            #endregion

            #region box_1_content_2

            BoxModel contentModel2 = new BoxModel()
            {
                layout          = FlexLayout.vertical,
                spacing         = FlexMarginSize.lg,
                position        = FlexPosition.absolute,
                backgroundColor = "#03303Acc",
                paddingAll      = "20px",
                paddingTop      = "18px",
                offsetBottom    = "0px",
                offsetStart     = "0px",
                offsetEnd       = "0px"
            };
            List <FlexComponentModel> contentModel2List = new List <FlexComponentModel>();

            #region box_1_content_2_content_1

            BoxModel contentModel2To1 = new BoxModel();
            contentModel2To1.layout = FlexLayout.vertical;
            List <FlexComponentModel> contentModel2To1List = new List <FlexComponentModel>();

            #region box_1_content_2_content_1_content1

            TextModel contentModel2To1To1 = new TextModel()
            {
                text   = "Brown's T-shirts",
                size   = FlexFontSize.xl,
                color  = "#ffffff",
                weight = TextWeight.bold
            };
            contentModel2To1List.Add(contentModel2To1To1);

            #endregion

            #endregion

            contentModel2To1.contents = contentModel2To1List;
            contentModel2List.Add(contentModel2To1);

            #region box_1_content_2_content_2

            BoxModel contentModel2To2 = new BoxModel()
            {
                layout  = FlexLayout.baseline,
                spacing = FlexMarginSize.lg,
            };
            List <FlexComponentModel> contentModel2To2List = new List <FlexComponentModel>();

            #region box_1_content_2_content_2_content1

            TextModel contentModel2To2To1 = new TextModel()
            {
                text  = "¥35,800",
                color = "#ebebeb",
                size  = FlexFontSize.sm,
                flex  = 0
            };
            contentModel2To2List.Add(contentModel2To2To1);

            #endregion

            #region box_1_content_2_content_2_content2

            TextModel contentModel2To2To2 = new TextModel()
            {
                text       = "¥75,000",
                color      = "#ffffffcc",
                decoration = TextDecoration.line_through,
                gravity    = FlexGravity.bottom,
                flex       = 0,
                size       = FlexFontSize.sm
            };
            contentModel2To2List.Add(contentModel2To2To2);

            #endregion

            #endregion

            contentModel2To2.contents = contentModel2To2List;
            contentModel2List.Add(contentModel2To2);

            #region box_1_content_2_content_3

            BoxModel contentModel2To3 = new BoxModel()
            {
                layout       = FlexLayout.vertical,
                borderWidth  = "1px",
                cornerRadius = "4px",
                spacing      = FlexMarginSize.sm,
                borderColor  = "#ffffff",
                margin       = FlexMarginSize.xxl,
                height       = "40px"
            };
            List <FlexComponentModel> contentModel2To3List = new List <FlexComponentModel>();

            #region box_1_content_2_content_3_content_1

            FillerModel contentModel2To3To1 = new FillerModel();
            contentModel2To3List.Add(contentModel2To3To1);

            #endregion

            #region box_1_content_2_content_3_content_2

            BoxModel contentModel2To3To2 = new BoxModel()
            {
                layout  = FlexLayout.baseline,
                spacing = FlexMarginSize.sm
            };
            List <FlexComponentModel> contentModel2To3To2List = new List <FlexComponentModel>();

            #region box_1_content_2_content_3_content_2_content1

            FillerModel contentModel2To3To2To1 = new FillerModel();
            contentModel2To3To2List.Add(contentModel2To3To2To1);

            #endregion

            #region box_1_content_2_content_3_content_2_content2

            IconModel contentModel2To3To2To2 = new IconModel()
            {
                url = "https://scdn.line-apps.com/n/channel_devcenter/img/flexsnapshot/clip/clip14.png"
            };
            contentModel2To3To2List.Add(contentModel2To3To2To2);

            #endregion

            #region box_1_content_2_content_3_content_2_content3

            TextModel contentModel2To3To2To3 = new TextModel()
            {
                text      = "Add to cart",
                color     = "#ffffff",
                flex      = 0,
                offsetTop = "-2px"
            };
            contentModel2To3To2List.Add(contentModel2To3To2To3);

            #endregion

            #region box_1_content_2_content_3_content_2_content4

            FillerModel contentModel2To3To2To4 = new FillerModel();
            contentModel2To3To2List.Add(contentModel2To3To2To4);

            #endregion

            #endregion

            contentModel2To3To2.contents = contentModel2To3To2List;
            contentModel2To3List.Add(contentModel2To3To2);

            #region box_1_content_2_content_3_content_3

            FillerModel contentModel2To3To3 = new FillerModel();
            contentModel2To3List.Add(contentModel2To3To3);
            #endregion

            #endregion

            contentModel2To3.contents = contentModel2To3List;
            contentModel2List.Add(contentModel2To3);

            #endregion

            contentModel2.contents = contentModel2List;
            mainboxModelList.Add(contentModel2);

            #region box_1_content_3

            BoxModel contentModel3 = new BoxModel()
            {
                layout          = FlexLayout.vertical,
                position        = FlexPosition.absolute,
                cornerRadius    = "20px",
                offsetTop       = "18px",
                backgroundColor = "#ff334b",
                offsetStart     = "18px",
                height          = "25px",
                width           = "52px"
            };
            List <FlexComponentModel> contentModel3List = new List <FlexComponentModel>();

            #region box_1_content_3_content1

            TextModel contentModel3To1 = new TextModel()
            {
                text      = "SALE",
                color     = "#ffffff",
                align     = FlexAlign.center,
                size      = FlexFontSize.xs,
                offsetTop = "3px"
            };
            contentModel3List.Add(contentModel3To1);

            #endregion

            #endregion

            contentModel3.contents = contentModel3List;
            mainboxModelList.Add(contentModel3);

            #endregion

            mainBoxModel.contents = mainboxModelList;

            #endregion

            bubbleModel.body = mainBoxModel;
            carouselContentList.Add(bubbleModel);

            #endregion

            carouselModel.contents = carouselContentList;

            return(carouselModel);
        }
コード例 #28
0
        public void AddInspectorHighlighting(IHighlightingConsumer consumer, ICSharpDeclaration element,
                                             IDeclaredElement declaredElement, string baseDisplayName, string baseTooltip, string moreText, IconModel iconModel,
                                             IEnumerable <BulbMenuItem> items, List <CodeLensEntryExtraActionModel> extraActions)
        {
            string displayName = null;
            string tooltip     = "Values from Unity Editor Inspector";

            var solution = element.GetSolution();

            Assertion.Assert(solution.Locks.IsReadAccessAllowed(), "ReadLock required");

            var result = GetAssetGuidAndPropertyName(solution, declaredElement);

            if (!result.HasValue)
            {
                return;
            }

            var guid         = result.Value.guid;
            var propertyName = result.Value.propertyName;

            var cache = solution.GetComponent <UnitySceneDataLocalCache>();

            var field            = (declaredElement as IField).NotNull();
            var type             = field.Type;
            var presentationType = GetUnityPresentationType(type);

            if (ShouldShowUnknownPresentation(presentationType))
            {
                base.AddHighlighting(consumer, element, field, baseDisplayName, baseTooltip, moreText, iconModel, items, extraActions);
                return;
            }

            var initializer = (element as IFieldDeclaration).NotNull("element as IFieldDeclaration != null").Initial;
            var initValue   = (initializer as IExpressionInitializer)?.Value?.ConstantValue.Value;

            var initValueUnityPresentation = GetUnitySerializedPresentation(presentationType, initValue);
            var initValueCount             = cache.GetValueCount(guid, propertyName, initValueUnityPresentation);

            if (initValueCount == 0 && cache.GetPropertyUniqueValuesCount(guid, propertyName) == 1) // only modified value
            {
                var valueWithLocations = cache.GetUniqueValuesWithLocation(guid, propertyName).ToArray();
                Assertion.Assert(valueWithLocations.Length == 1, "valueWithLocations.Length == 1"); //performance assertion
                displayName = GetPresentation(valueWithLocations[0], presentationType, type, solution, element.GetPsiModule(), false);
            }
            else if (initValueCount > 0 && cache.GetPropertyUniqueValuesCount(guid, propertyName) == 2)
            {
                // original value & only one modified value
                var values = cache.GetUniqueValuesWithLocation(guid, propertyName).ToArray();
                Assertion.Assert(values.Length == 2, "values.Length == 2"); //performance assertion

                var anotherValueWithLocation = values[0].Value.Value.Equals(initValueUnityPresentation) ? values[1] : values[0];
                displayName = GetPresentation(anotherValueWithLocation, presentationType, type, solution, element.GetPsiModule(), false);
            }

            if (displayName == null)
            {
                var count = cache.GetFilesWithPropertyCount(guid, propertyName) - cache.GetFilesCountWithoutChanges(guid, propertyName, initValueUnityPresentation);
                if (count == 0)
                {
                    displayName = "Unchanged";
                }
                else
                {
                    var word = count == 1 ? "asset" : "assets";
                    displayName = $"Changed in {count} {word}";
                }
            }


            consumer.AddHighlighting(new UnityInspectorCodeInsightsHighlighting(element.GetNameDocumentRange(),
                                                                                displayName, tooltip, "Property Inspector values", this,
                                                                                declaredElement, iconModel, presentationType, initValue));
        }
コード例 #29
0
 private void DragStartInternal(int id)
 {
     selectedIcon = Icons.First(i => i.Id == id);
 }