Ejemplo n.º 1
0
		public static IEnumerable<ResourcesHelper> IconsCss(this ResourcesHelper registrator)
		{
			var p = Register.IconsCssPath.Split(';');
			var r = new ResourcesHelper[p.Length];
			for (int i = 0; i < p.Length; ++i)
				r[i] = registrator.StyleSheet(p[i].ResolveUrlTokens());
			return r;
		}
Ejemplo n.º 2
0
        private void btnUpoad_Click(object sender, System.EventArgs e)
        {
            SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);

            if (this.fileUpload.HasFile)
            {
                try
                {
                    if (!string.IsNullOrEmpty(masterSettings.WeiXinCodeImageUrl))
                    {
                        ResourcesHelper.DeleteImage(masterSettings.WeiXinCodeImageUrl);
                    }
                    this.imgPic.ImageUrl      = (masterSettings.WeiXinCodeImageUrl = VShopHelper.UploadWeiXinCodeImage(this.fileUpload.PostedFile));
                    this.btnPicDelete.Visible = true;
                    SettingsManager.Save(masterSettings);
                }
                catch
                {
                    this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 添加or修改内容
        /// </summary>
        /// <returns></returns>
        private async Task AddOrModifyToDo()
        {
            try
            {
                if (EditedToDo != null)
                {
                    if (_addMode == AddMode.None)
                    {
                        return;
                    }

                    if (string.IsNullOrEmpty(EditedToDo.Content))
                    {
                        ToastService.SendToast(ResourcesHelper.GetResString("ContentEmpty"));
                        return;
                    }

                    ShowPaneOpen = false;

                    //显示进度条
                    IsLoading = Visibility.Visible;

                    //添加
                    if (_addMode == AddMode.Add)
                    {
                        await AddOrRestoreAndSyncNewToDo();
                    }
                    //修改
                    else if (_addMode == AddMode.Modify)
                    {
                        await ModifyAndSyncToDo();
                    }
                }
            }
            catch (Exception ex)
            {
                var task = Logger.LogAsync(ex);
            }
        }
Ejemplo n.º 4
0
        public EntitySearchDisplayInfo GetInfoFromEntity(int index)
        {
            var indexName = ResourcesHelper.GetEntityName(index);
            var rm        = ResourcesHelper.GetEntityResourceCollection();


            var info = new EntitySearchDisplayInfo
            {
                Title       = new ResourceManager(rm.Titles).GetString(indexName),
                Column      = rm.Columns == null ? null : new ResourceManager(rm.Columns).GetString(indexName),
                Description = new ResourceManager(rm.Descriptions).GetString(indexName),
                ShortName   = new ResourceManager(rm.ShortNames).GetString(indexName),
                PlaceHolder = new ResourceManager(rm.PlaceHolders)?.GetString(indexName) ?? "",
            };

            if (info.Title == null && info.Column == null && info.Description == null || info.ShortName == null)
            {
                return(null);
            }

            return(info);
        }
        public void ResourceLibraryDisposesNativeResources()
        {
            var disposable = MockRepository.GenerateMock <INativeResource>();

            disposable.Stub(f => f.Id).Return(Guid.NewGuid().ToString());
            var disposableUri = ResourcesHelper.NewTestResourceUri(disposable.Id);

            var nondisposable = MockRepository.GenerateMock <IResource>();

            nondisposable.Stub(f => f.Id).Return(Guid.NewGuid().ToString());
            var nondisposableUri = ResourcesHelper.NewTestResourceUri(nondisposable.Id);

            ResourcesHelper.GenerateResourceLoaderMock(true, disposable, nondisposable);

            using (var library = new ResourceLibrary())
            {
                Assert.IsNotNull(library.GetResourceByUri <IResource>(disposableUri));
                Assert.IsNotNull(library.GetResourceByUri <IResource>(nondisposableUri));
            }

            disposable.AssertWasCalled(f => f.Dispose());
        }
Ejemplo n.º 6
0
        private void BlurStyleButtonOnClicked(object sender, EventArgs e)
        {
            var selectedButton = (Button)sender;

            if (selectedButton == LightButton)
            {
                _blurStyle = Sharpnado.MaterialFrame.MaterialFrame.BlurStyle.Light;
            }
            else if (selectedButton == DarkButton)
            {
                _blurStyle = Sharpnado.MaterialFrame.MaterialFrame.BlurStyle.Dark;
            }
            else
            {
                _blurStyle = Sharpnado.MaterialFrame.MaterialFrame.BlurStyle.ExtraLight;
            }

            ResourcesHelper.SetBlurStyle(_blurStyle);

            selectedButton.TextColor = _blurStyle != Sharpnado.MaterialFrame.MaterialFrame.BlurStyle.ExtraLight
                                           ? ResourcesHelper.GetResourceColor("TextPrimaryColor")
                                           : ResourcesHelper.GetResourceColor("TextPrimaryDarkColor");

            selectedButton.BackgroundColor = ResourcesHelper.GetResourceColor(ResourcesHelper.DynamicPrimaryColor);

            foreach (var button in _blurStyleButtons)
            {
                if (button == selectedButton)
                {
                    continue;
                }

                button.TextColor = _blurStyle != Sharpnado.MaterialFrame.MaterialFrame.BlurStyle.ExtraLight
                                       ? ResourcesHelper.GetResourceColor("TextPrimaryDarkColor")
                                       : ResourcesHelper.GetResourceColor("TextPrimaryColor");
                button.BackgroundColor = Color.Transparent;
            }
        }
Ejemplo n.º 7
0
        public static async Task Main(string[] args)
        {
            var exportPath = AssemblyHelper.EntryAssemblyDirectory;

            if (args != null && args.Any())
            {
                exportPath = args.First();
            }

            var outputPath = Path.Combine(exportPath, "fa2cs-output");

            if (Directory.Exists(outputPath))
            {
                Directory.Delete(outputPath, true);
            }

            Directory.CreateDirectory(outputPath);

            var downloader = new FontAwesomeDownloader();
            var codeWriter = new CodeWriter();

            var icons = await downloader.DownloadIconCodes(Endpoint);

            var code = codeWriter.Write(icons);

            var codeFiles = new List <string>()
            {
                code,
                ResourcesHelper.ReadResourceContent("AssemblyInfoTemplate.txt"),
            };

            AssemblyEmitter.EmitAssembly(codeFiles, outputPath);

            File.WriteAllText(Path.Combine(outputPath, "readme.txt"), ResourcesHelper.ReadResourceContent("readme.txt"));
            File.WriteAllText(Path.Combine(exportPath, "FontAwesomeIcons.cs"), code);

            OpenFileHelper.OpenAndSelect(exportPath);
        }
Ejemplo n.º 8
0
        private void grdArticleCategories_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
        {
            int rowIndex               = ((System.Web.UI.WebControls.GridViewRow)((System.Web.UI.Control)e.CommandSource).NamingContainer).RowIndex;
            int categoryId             = (int)this.grdArticleCategories.DataKeys[rowIndex].Value;
            int displaySequence        = int.Parse((this.grdArticleCategories.Rows[rowIndex].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text);
            int num                    = 0;
            int replaceDisplaySequence = 0;

            if (e.CommandName == "Fall")
            {
                if (rowIndex < this.grdArticleCategories.Rows.Count - 1)
                {
                    num = (int)this.grdArticleCategories.DataKeys[rowIndex + 1].Value;
                    replaceDisplaySequence = int.Parse((this.grdArticleCategories.Rows[rowIndex + 1].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text);
                }
            }
            else
            {
                if (e.CommandName == "Rise" && rowIndex > 0)
                {
                    num = (int)this.grdArticleCategories.DataKeys[rowIndex - 1].Value;
                    replaceDisplaySequence = int.Parse((this.grdArticleCategories.Rows[rowIndex - 1].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text);
                }
            }
            if (num > 0)
            {
                ArticleHelper.SwapArticleCategorySequence(categoryId, num, displaySequence, replaceDisplaySequence);
            }
            if (e.CommandName == "Delete")
            {
                ArticleCategoryInfo articleCategory = ArticleHelper.GetArticleCategory(categoryId);
                if (ArticleHelper.DeleteArticleCategory(categoryId))
                {
                    ResourcesHelper.DeleteImage(articleCategory.IconUrl);
                }
            }
            base.Response.Redirect(System.Web.HttpContext.Current.Request.Url.ToString(), true);
        }
Ejemplo n.º 9
0
        public async Task Collection()
        {
            var registry = new CollectorRegistry();
            var factory  = new MetricFactory(registry);

            var histogram1 = CreateHistogram1(factory);

            var histogram2 = factory.CreateHistogram("hist2", "help2", new[] { -5.0, 0, 5.0, 10 });

            histogram2.Observe(-20);
            histogram2.Observe(-1);
            histogram2.Observe(0);
            histogram2.Observe(2.5);
            histogram2.Observe(5);
            histogram2.Observe(9);
            histogram2.Observe(11);

            string formattedText = null;

            using (var stream = new MemoryStream())
            {
                using (var writer = new MetricsTextWriter(stream))
                {
                    ((ICollector)histogram1).Collect(writer);
                    ((ICollector)histogram2).Collect(writer);
                    await writer.CloseWriterAsync();
                }

                stream.Seek(0, SeekOrigin.Begin);

                using (var streamReader = new StreamReader(stream))
                {
                    formattedText = streamReader.ReadToEnd();
                }
            }

            Assert.Equal(ResourcesHelper.GetFileContent("HistogramTests_Collection.txt"), formattedText);
        }
        static HumanEffortComputer()
        {
            ByHeartBeat = new EffortComputer(
                new List <EffortSpan>
            {
                new EffortSpan(0f, ResourcesHelper.GetResourceColor("ColorEffortUnknown"), AppResources.PaceUnknown),
                new EffortSpan(0.3f, ResourcesHelper.GetResourceColor("ColorEffortLightest"), AppResources.PaceVeryLight),
                new EffortSpan(0.6f, ResourcesHelper.GetResourceColor("ColorEffortLight"), AppResources.PaceLight),
                new EffortSpan(0.7f, ResourcesHelper.GetResourceColor("ColorEffortAerobic"), AppResources.PaceAerobic),
                new EffortSpan(0.8f, ResourcesHelper.GetResourceColor("ColorEffortAnaerobic"), AppResources.PaceAnaerobic),
                new EffortSpan(0.9f, ResourcesHelper.GetResourceColor("ColorEffortMax"), AppResources.PaceMax),
            },
                180);

            BySpeed = new EffortComputer(
                new List <EffortSpan>
            {
                new EffortSpan(0f, ResourcesHelper.GetResourceColor("ColorEffortSpeedMin"), AppResources.PaceVeryLight),
                new EffortSpan(0.7f, ResourcesHelper.GetResourceColor("ColorEffortAnaerobic"), AppResources.PaceAnaerobic),
                new EffortSpan(0.95f, ResourcesHelper.GetResourceColor("ColorEffortMax"), AppResources.PaceMax),
            },
                40);
        }
Ejemplo n.º 11
0
        public MovieNodeViewModel(IMovieListResult result)
        {
            if (result == null)
            {
                return;
            }

            var poster = result.Images.FirstOrDefault();

            if (poster != null)
            {
                Poster = poster.Thumbnail.Normal;
            }

            Id      = result.Id;
            Title   = result.Title.GetNormalString();
            Age     = result.AgeRestriction;
            Year    = result.Year;
            Country = result.Country;
            var format = ResourcesHelper.GetLocalizationString("MinutesStringFormat");

            RunningTime = string.Format(format, result.RunningTime);
        }
Ejemplo n.º 12
0
        public override void InitializeMenuOptions()
        {
            if (!this.MenuOptions.IsNullOrEmpty())
            {
                return;
            }

            this.MenuOptions.Add(new MenuOptionViewModel {
                Glyph = "", Label = ResourcesHelper.GetLocalizedString("HomeMainSettingsItemLabel"), Command = SettingsCommand
            });
            this.MenuOptions.Add(new MenuOptionViewModel {
                Glyph = "", Label = ResourcesHelper.GetLocalizedString("HomeMainScreenshotsItemLabel"), Command = ScreenshotsCommand
            });
            this.MenuOptions.Add(new MenuOptionViewModel {
                Glyph = "", Label = ResourcesHelper.GetLocalizedString("HomeMainWallpapersItemLabel"), Command = WallpapersCommand
            });
            this.MenuOptions.Add(new MenuOptionViewModel {
                Glyph = "", Label = ResourcesHelper.GetLocalizedString("HomeMainWatchfacesItemLabel"), Command = WatchfacesCommand
            });
            this.MenuOptions.Add(new MenuOptionViewModel {
                Glyph = "", Label = ResourcesHelper.GetLocalizedString("HomeMainTutorialsItemLabel"), Command = TutorialsCommand
            });
        }
Ejemplo n.º 13
0
        private async void OkBtn_Click(object sender, RoutedEventArgs e)
        {
            LoadingMaskGrid.Visibility = Visibility.Visible;
            OkBtn.IsEnabled            = false;
            if (await MainVM.CateVM.SaveCatesToModify())
            {
                if (PopupService.CurrentShownCPEX != null)
                {
                    PopupService.CurrentShownCPEX.Hide();
                }
                OkBtn.IsEnabled            = true;
                LoadingMaskGrid.Visibility = Visibility.Collapsed;

                OnClickOKBtn?.Invoke();
            }
            else
            {
                OkBtn.IsEnabled            = true;
                LoadingMaskGrid.Visibility = Visibility.Collapsed;

                ToastService.SendToast(ResourcesHelper.GetResString("RequestError"));
            }
        }
Ejemplo n.º 14
0
        public Assembly Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext)
        {
            string path;
            var    newAssemblyName = new AssemblyName(assemblyName.Name);

#if DNXCORE50
            newAssemblyName.CultureName = assemblyName.CultureName;
#elif DNX451
            // Assigning empty CultureInfo makes the new assembly culture as neutral which won't match the entries in _assemblies dictionary. Hence this check.
            if (assemblyName.CultureInfo != null && !ResourcesHelper.IsResourceNeutralCulture(assemblyName))
            {
                newAssemblyName.CultureInfo = assemblyName.CultureInfo;
            }
#else
#error Unhandled framework error
#endif
            if (_assemblies.TryGetValue(newAssemblyName, out path))
            {
                return(loadContext.LoadFile(path));
            }

            return(null);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 演示行为树用法,使用时可以删除
        /// </summary>
        private static void TestBehaviorTree()
        {
            // 全局共享变量用法
            Game.Scene.AddComponent <BehaviorTreeVariableComponent>().SetVariable("全局变量", 1);

            var runtimeBehaivorTree = UnityEngine.Object.Instantiate(ResourcesHelper.Load("Cube") as GameObject).GetComponent <BehaviorDesigner.Runtime.BehaviorTree>();

            if (runtimeBehaivorTree)
            {
                //建议在资源预加载时进行初始化,以免游戏对局中反序列化GC卡顿
                BehaviorTreeHelper.Init(runtimeBehaivorTree.gameObject);

                //动态加载外部行为树用法
                //UnityEngine.Object externalBehavior = 加载("外部行为树资源");
                //BehaviorTreeHelper.Init(externalBehavior);
                //runtimeBehaivorTree.Ensure<BehaviorTreeController>().SetExternalBehavior(externalBehavior);

                (GameObjectHelper.Ensure(runtimeBehaivorTree.gameObject, typeof(BehaviorTreeController)) as BehaviorTreeController).Init();
            }

            var behaviorTree = BehaviorTreeFactory.Create(Game.Scene, runtimeBehaivorTree);

            // 新增行为树共享变量用法
            var p1 = behaviorTree.GetComponent <BehaviorTreeVariableComponent>().GetVariable <int>("变量1");

            Log.Info($"行为树变量:{p1}");

            behaviorTree.GetComponent <BehaviorTreeVariableComponent>().SetVariable("变量1", 2);

            p1 = behaviorTree.GetComponent <BehaviorTreeVariableComponent>().GetVariable <int>("变量1");

            Log.Info($"行为树变量:{p1}");

            behaviorTree.GetComponent <BehaviorTreeVariableComponent>().SetVariable("变量2", "");
            behaviorTree.GetComponent <BehaviorTreeVariableComponent>().SetVariable("变量3", behaviorTree);
            behaviorTree.GetComponent <BehaviorTreeVariableComponent>().SetVariable("变量4", runtimeBehaivorTree);
        }
        protected override async Task LoadDetails(long id)
        {
            var rs = await _dataSource.GetNewsDetails(id);

            if (rs == null)
            {
                return;
            }

            LayoutHelper.InvokeFromUiThread(async() =>
            {
                Title       = rs.Title.GetNormalString();
                Description = rs.Description.GetNormalString();
                BodyText    = rs.BodyText.GetNormalString();
                Source      = new Uri(rs.SiteUrl);

                foreach (var image in rs.Images)
                {
                    _images.Add(image.Image);
                }

                //if (rs.Place != null)
                //{
                //    Place = rs.Place.Title.GetNormalString();
                //    Metro = rs.Place.Subway;
                //    Location = rs.Place.Coords;
                //}

                if (rs.PublicationDate.HasValue)
                {
                    var format = ResourcesHelper.GetLocalizationString("PublishedAtStringFormat");
                    Date       = string.Format(format, rs.PublicationDate.Value.ToString("g"));
                }

                await CommentsViewModel.Load();
            });
        }
Ejemplo n.º 17
0
        private void btnSubmitArticleCategory_Click(object sender, EventArgs e)
        {
            ArticleCategoryInfo articleCategory = ArticleHelper.GetArticleCategory(categoryId);

            if (articleCategory != null)
            {
                if (fileUpload.HasFile)
                {
                    try
                    {
                        ResourcesHelper.DeleteImage(articleCategory.IconUrl);
                        articleCategory.IconUrl = ArticleHelper.UploadArticleImage(fileUpload.PostedFile);
                    }
                    catch
                    {
                        ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false);
                        return;
                    }
                }
                articleCategory.Name        = txtArticleCategoryiesName.Text.Trim();
                articleCategory.Description = txtArticleCategoryiesDesc.Text.Trim();
                ValidationResults results = Hishop.Components.Validation.Validation.Validate <ArticleCategoryInfo>(articleCategory, new string[] { "ValArticleCategoryInfo" });
                string            msg     = string.Empty;
                if (results.IsValid)
                {
                    UpdateCategory(articleCategory);
                }
                else
                {
                    foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
                    {
                        msg = msg + Formatter.FormatErrorMessage(result.Message);
                    }
                    ShowMsg(msg, false);
                }
            }
        }
Ejemplo n.º 18
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     System.Web.HttpFileCollection files = base.Request.Files;
     if (files.Count > 0)
     {
         string str = System.Web.HttpContext.Current.Request.MapPath(Globals.ApplicationPath + "/Storage/master/flex");
         System.Web.HttpPostedFile httpPostedFile = files[0];
         string text = System.IO.Path.GetExtension(httpPostedFile.FileName).ToLower();
         if (text != ".jpg" && text != ".gif" && text != ".jpeg" && text != ".png" && text != ".bmp")
         {
             base.Response.Write("1");
             return;
         }
         string text2 = System.DateTime.Now.ToString("yyyyMMdd") + new System.Random().Next(10000, 99999).ToString(System.Globalization.CultureInfo.InvariantCulture);
         text2 += text;
         string filename = str + "/" + text2;
         try
         {
             if (!ResourcesHelper.CheckPostedFile(httpPostedFile, "image"))
             {
                 base.Response.Write("0");
             }
             else
             {
                 httpPostedFile.SaveAs(filename);
                 base.Response.Write(text2);
             }
             return;
         }
         catch
         {
             base.Response.Write("0");
             return;
         }
     }
     base.Response.Write("2");
 }
        public bool Validate()
        {
            var validHostIP   = IPAddress.TryParse(this.HostIP, out IPAddress ipAddress);
            var validUsername = !string.IsNullOrWhiteSpace(this.Username);
            var validPassword = true;

            var validForm = validHostIP && validUsername && validPassword;

            if (!validForm)
            {
                var stringBuilder = new StringBuilder();
                stringBuilder.AppendLine(ResourcesHelper.GetLocalizedString("ScpCredentialsDialogInvalidFieldsFirstSegmentMessage"));

                if (!validHostIP)
                {
                    stringBuilder.AppendLine("- Host / IP");
                }

                if (!validUsername)
                {
                    stringBuilder.AppendLine("- Username");
                }

                if (!validPassword)
                {
                    stringBuilder.AppendLine("- Password");
                }

                this.ValidationSummary = stringBuilder.ToString();
            }
            else
            {
                this.ValidationSummary = string.Empty;
            }

            return(validForm);
        }
Ejemplo n.º 20
0
        public List <T> LoadObjects(IDbConnection connection)
        {
            IDataReader reader = null;

            try
            {
                List <T>   list    = new List <T>();
                IDbCommand command = connection.CreateCommand();
                command.CommandText = ResourcesHelper.GetScriptFromResources(this._scriptName);
                if (connection.State != ConnectionState.Open)
                {
                    connection.Open();
                }
                using (reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        T sqlObject = GetObject(reader);
                        sqlObject.ParentDb = _db;
                        list.Add(sqlObject);
                    }
                }

                return(list);
            }
            catch (Exception ex)
            {
                throw new Exception("Loading is failed. Type: " + typeof(T).Name, ex);
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                {
                    reader.Close();
                }
            }
        }
Ejemplo n.º 21
0
        // GET: /Resource/Export
        public ActionResult Export()
        {
            IList <LanguageResourcesList> languages = Session["__Languages"] as IList <LanguageResourcesList>;

            if (languages == null)
            {
                return(RedirectToAction("Index"));
            }

            ResourcesHelper helper   = new ResourcesHelper();
            StringBuilder   sb       = new StringBuilder();
            string          filename = String.Concat(String.Join("_", languages.Select(x => x.CultureName)), ".csv");

            sb.Append("KEY\t");
            for (int i = 0; i < languages.Count; i++)
            {
                sb.AppendFormat("{0}\t", languages[i].CultureName.ToUpper());
            }
            sb.AppendLine();

            LanguageResourcesList.Resource translated = null;
            foreach (var r in languages[0].Resources)
            {
                sb.AppendFormat("{0}\t{1}\t", r.Key, helper.StripTabs(r.Value));
                for (int i = 1; i < languages.Count; i++)
                {
                    translated = languages[i].Resources.FirstOrDefault(x => x.Key == r.Key);
                    sb.AppendFormat("{0}\t", translated == null ? "" : helper.StripTabs(translated.Value));
                }
                sb.AppendLine();
            }

            Response.ClearHeaders();
            Response.AddHeader("Content-Disposition", $"attachment; filename={filename}");
            return(File(Encoding.UTF8.GetBytes(sb.ToString()), "text/csv"));
        }
Ejemplo n.º 22
0
        public IController Create(RequestContext requestContext, Type controllerType)
        {
            string culture = "en-US";

            if (requestContext.HttpContext.Request.Cookies["culture"] == null)
            {
                requestContext.HttpContext.Response.Cookies.Add(
                    new HttpCookie("culture", culture)
                {
                    Path = "/", Expires = DateTime.Now.AddDays(1)
                }
                    );
            }
            else
            {
                culture = requestContext.HttpContext.Request.Cookies["culture"].Value;
            }

            requestContext.HttpContext.Session["culture"] = culture;

            ResourcesHelper.SetCulutre(culture);

            return(DependencyResolver.Current.GetService(controllerType) as IController);
        }
        private async Task AnimateTabButton()
        {
            double sourceScale = TabButton.Scale;
            Color  sourceColor = TabButton.ButtonBackgroundColor;
            Color  targetColor = _currentTheme == Theme.Light
                ? ResourcesHelper.GetResourceColor("DarkSurface")
                : Color.White;

            await TabButton.ScaleTo(3);

            await TabButton.ScaleTo(sourceScale);

            TabButton.IconImageSource = null;

            var bigScaleTask    = TabButton.ScaleTo(30, length: 500);
            var colorChangeTask = TabButton.ColorTo(
                sourceColor,
                targetColor,
                callback: c => TabButton.ButtonBackgroundColor = c,
                length: 500);
            await Task.WhenAll(bigScaleTask, colorChangeTask);

            _currentTheme = _currentTheme == Theme.Light ? Theme.Dark : Theme.Light;
            ApplyTheme();

            var reverseBigScaleTask    = TabButton.ScaleTo(sourceScale, length: 500);
            var reverseColorChangeTask = TabButton.ColorTo(
                targetColor,
                sourceColor,
                c => TabButton.ButtonBackgroundColor = c,
                length: 500);

            await Task.WhenAll(reverseBigScaleTask, reverseColorChangeTask);

            TabButton.IconImageSource = "theme_96.png";
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 添加图层工具
        /// </summary>
        /// <param name="commandFactory"></param>
        /// <param name="map"></param>
        /// <param name="layerCollection"></param>
        /// <returns></returns>
        public static IBaseCommand GetAddLayersCommand(this ICommandFactory commandFactory, IMap map, ILayerCollection layerCollection)
        {
            IBaseCommand command = null;

            if (commandFactory != null && map != null)
            {
                string name = "addLayers";
                command = commandFactory.Commands?.FirstOrDefault(x => x.Name == name);
                if (command == null)
                {
                    command = new BaseCommand()
                    {
                        Header         = "添加",
                        Name           = name,
                        ExecuteCommand = (obj) => AddLayers(map, layerCollection),
                        Icon           = ResourcesHelper.GetBitmapImage("Add16.png"),
                        LargeIcon      = ResourcesHelper.GetBitmapImage("Add32.png"),
                        ToolTip        = "添加图层"
                    };
                    commandFactory.Commands.Add(command);
                }
            }
            return(command);
        }
Ejemplo n.º 25
0
        public static IBaseCommand GetZoomToMaxExtentCommand(this ICommandFactory commandFactory, IMap map)
        {
            IBaseCommand command = null;

            if (commandFactory != null && map != null)
            {
                string name = "zoomToMaxExtent";
                command = commandFactory.Commands?.FirstOrDefault(x => x.Name == name);
                if (command == null)
                {
                    command = new BaseCommand()
                    {
                        Header         = "全图",
                        Name           = name,
                        ExecuteCommand = (obj) => map?.ZoomToMaxExtent(),
                        Icon           = ResourcesHelper.GetBitmapImage("Global16.png"),
                        LargeIcon      = ResourcesHelper.GetBitmapImage("Global32.png"),
                        ToolTip        = "缩放至全图"
                    };
                    commandFactory.Commands.Add(command);
                }
            }
            return(command);
        }
Ejemplo n.º 26
0
        public string Write(IEnumerable<MaterialDesignIcon> icons)
        {
            Console.Write("Generating C# code...");

            var classTemplate = ResourcesHelper.ReadResourceContent("ClassTemplate.txt");
            var propertyTemplate = ResourcesHelper.ReadResourceContent("PropertyTemplate.txt");

            var properties = new List<string>();

            foreach (var icon in icons)
            {
                var property = propertyTemplate.Replace("$link$", icon.Url)
                                               .Replace("$name$", icon.Name)
                                               .Replace("$code$", icon.Unicode)
                                               .Replace("$dotnet_name$", icon.DotNetName);

                properties.Add(property);
            }

            var separator = Environment.NewLine + Environment.NewLine;
            var code = string.Join(separator, properties);

            return classTemplate.Replace("$properties$", code);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// 添加图层组工具
        /// </summary>
        /// <param name="commandFactory"></param>
        /// <param name="layers"></param>
        /// <returns></returns>
        public static IBaseCommand GetAddGroupCommand(this ICommandFactory commandFactory, ILayerCollection layers)
        {
            IBaseCommand command = null;

            if (commandFactory != null && layers != null)
            {
                string name = "addGroup";
                command = commandFactory.Commands?.FirstOrDefault(x => x.Name == name);
                if (command == null)
                {
                    command = new BaseCommand()
                    {
                        Header         = "添加分组",
                        Name           = name,
                        ExecuteCommand = (obj) => layers.AddGroup(),
                        Icon           = ResourcesHelper.GetBitmapImage("Group16.png"),
                        LargeIcon      = ResourcesHelper.GetBitmapImage("Group32.png"),
                        ToolTip        = "添加分组"
                    };
                    commandFactory.Commands.Add(command);
                }
            }
            return(command);
        }
Ejemplo n.º 28
0
        public static IBaseCommand GetRedoCommand(this ICommandFactory commandFactory, IMap map)
        {
            IBaseCommand command = null;

            if (commandFactory != null && map != null)
            {
                string name = "redo";
                command = commandFactory.Commands?.FirstOrDefault(x => x.Name == name);
                if (command == null)
                {
                    command = new BaseCommand()
                    {
                        Header         = "重做",
                        Name           = name,
                        ExecuteCommand = (obj) => Redo(map),
                        Icon           = ResourcesHelper.GetBitmapImage("Redo16.png"),
                        LargeIcon      = ResourcesHelper.GetBitmapImage("Redo32.png"),
                        ToolTip        = "重做"
                    };
                    commandFactory.Commands.Add(command);
                }
            }
            return(command);
        }
Ejemplo n.º 29
0
        public static IBaseCommand GetZoomToNextViewCommand(this ICommandFactory commandFactory, IMap map)
        {
            IBaseCommand command = null;

            if (commandFactory != null && map != null)
            {
                string name = "zoomToNextView";
                command = commandFactory.Commands?.FirstOrDefault(x => x.Name == name);
                if (command == null)
                {
                    command = new BaseCommand()
                    {
                        Header         = "前进",
                        Name           = name,
                        ExecuteCommand = (obj) => ZoomToNextView(map),
                        Icon           = ResourcesHelper.GetBitmapImage("Next16.png"),
                        LargeIcon      = ResourcesHelper.GetBitmapImage("Next32.png"),
                        ToolTip        = "前进至后一视图"
                    };
                    commandFactory.Commands.Add(command);
                }
            }
            return(command);
        }
Ejemplo n.º 30
0
        public static IBaseCommand GetActiveZoomOutToolCommand(this ICommandFactory commandFactory, IMap map)
        {
            IBaseCommand command = null;

            if (commandFactory != null && map != null)
            {
                string name = "activeZoomOutTool";
                command = commandFactory.Commands?.FirstOrDefault(x => x.Name == name);
                if (command == null)
                {
                    command = new BaseCommand()
                    {
                        Header         = "缩小",
                        Name           = name,
                        ExecuteCommand = (obj) => ActiveZoomOutTool(map),
                        Icon           = ResourcesHelper.GetBitmapImage("ZoomOut16.png"),
                        LargeIcon      = ResourcesHelper.GetBitmapImage("ZoomOut32.png"),
                        ToolTip        = "缩小工具"
                    };
                    commandFactory.Commands.Add(command);
                }
            }
            return(command);
        }
Ejemplo n.º 31
0
        public static IBaseCommand GetRemoveLayerCommand(this ICommandFactory commandFactory, ILayer layer)
        {
            IBaseCommand command = null;

            if (commandFactory != null && layer != null)
            {
                string name = "removeLayer";
                command = commandFactory.Commands?.FirstOrDefault(x => x.Name == name);
                if (command == null)
                {
                    command = new BaseCommand()
                    {
                        Header         = "移除",
                        Name           = name,
                        ExecuteCommand = (obj) => RemoveLayer(layer),
                        Icon           = ResourcesHelper.GetBitmapImage("Remove16.png"),
                        LargeIcon      = ResourcesHelper.GetBitmapImage("Remove32.png"),
                        ToolTip        = "移除图层"
                    };
                    commandFactory.Commands.Add(command);
                }
            }
            return(command);
        }