月度归档: 2016 年 12 月

  • WPF对某个元素进行淡入淡出

    WPF对某个元素进行淡入淡出,例如对 ImagePage 元素进行淡入淡出,代码如下:

    淡入

    daV = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(1)));
    this.ImagePage.BeginAnimation(UIElement.OpacityProperty, daV);

    淡出

    DoubleAnimation daV = new DoubleAnimation(1, 0, new Duration(TimeSpan.FromSeconds(1)));
    this.ImagePage.BeginAnimation(UIElement.OpacityProperty, daV);
  • electron中使用jquery

    electron中使用jquery:

    <!-- Insert this line above script imports  -->
    <script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
    <!-- normal script imports etc  -->
    <script src="js/jquery.min.js"></script>       
    <!-- Insert this line after script imports -->
    <script>if (window.module) module = window.module;</script>
    
    <script>   
        $(function(){
            var winHeight = document.documentElement.clientHeight;
            var winWidth = document.documentElement.clientWidth;
            $('.wrapper').css('width', winWidth);
        });
    </script>


    见 https://segmentfault.com/q/1010000004703629

  • asp.net core上传文件

    asp.net core上传文件:

    public class BannerController : Controller
    {
    
            private ApplicationDbContext _db;
            private IHostingEnvironment _environment;   
            public BannerController(ApplicationDbContext db, IHostingEnvironment environment)
            {
                _db = db;
                _environment = environment;
            }
    
    
            [HttpPost]
            [ValidateAntiForgeryToken]
            public async Task<IActionResult> Create(BannerCreateViewModel viewModel)
            {
                if (ModelState.IsValid)
                {
                    var file = viewModel.PicFile;
                    var uploads = Path.Combine(_environment.WebRootPath, "uploads/images");
                    var ext = Path.GetExtension(file.FileName);//获得文件扩展名
                    var timeStamp = DateTimeOffset.Now.ToUnixTimeSeconds();
                    var saveName = $"{timeStamp}{ext}";//实际保存文件名
                    using (var fileStream = new FileStream(Path.Combine(uploads, saveName), FileMode.Create))
                    {
                        await file.CopyToAsync(fileStream);
                    }
                    viewModel.Pic = saveName;
                    var model = Mapper.Map<BannerCreateViewModel, Banner>(viewModel);
                    _db.Banner.Add(model);
                    _db.SaveChanges();
                    return RedirectToAction(nameof(Index));
                }
                else
                {
                    return View(viewModel);
                }
            }
    }

  • asp-action 等taghelper不高亮的解决办法

    asp-action 等 taghelper 不高亮的解决办法:

    在_ViewImports.cshtml中添加

    @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

    即可