我最近一直在教自己WinForms,但我现在已经切换到更现代的WPF,这是更好的SOOO!
我现在唯一困惑的是使用图像.现在在WinForms中,您将其作为资源导入,并且在/ bin/Debug文件夹中编译时图像仍然有效.
我无法弄清楚如何在WPF中使用它,当我运行应用程序时图像没有加载,因为图像被保存/Projects/AppName/images/,并且应用程序/Projects/AppName/bin/Debug在我在调试模式下运行时编译成.
我只需要复制我的Images文件夹并将其放在编译应用程序的位置吗?还是有另一种方式.这是我的代码,显示我的图像:
<Image Width="300">
<Image.Source>
<BitmapImage DecodePixelWidth="300" UriSource="/images/jamsnaps-dark.png" />
</Image.Source>
</Image>
Run Code Online (Sandbox Code Playgroud) 解决此问题的最佳方法是什么?显然,移动设备上的所有浏览器都在顶部有一个UI(地址栏等).这会为视口增加额外的高度,因此我使用100vh的网站缺少一个部分.
我假设不同的浏览器有不同大小的视口,因为这样,我可以简单地做一些类似height: calc(100vh - 50px)或高低的东西,但它在所有移动浏览器上都不匹配对吗?
试图创建一个缩略图,但我得到一些错误,我没有使用Imagick的经验.
这是我的PHP:
<?php
try {
$imagick = new Imagick();
$imagick->readImage('C:\xampp\htdocs\ppa\032.JPG');
$imagick->thumbnailImage(800, 800);
$imagick->writeImage('032(2).JPG');
}
catch(Exception $e) {
die('Error when creating a thumbnail: ' . $e->getMessage());
}
?>
Run Code Online (Sandbox Code Playgroud)
然后我得到这个错误代码:
创建缩略图时出错:NoDecodeDelegateForThisImageFormat`C:\ xampp\htdocs\ppa\032.JPG'@ error/composed.c/ReadImage/555
这是我用一些代码生成的一些信息,我再也找不到了......:/
Array
(
[GD Version] => bundled (2.1.0 compatible)
[FreeType Support] => 1
[FreeType Linkage] => with freetype
[T1Lib Support] =>
[GIF Read Support] => 1
[GIF Create Support] => 1
[JPEG Support] => 1
[PNG Support] => 1
[WBMP Support] => 1
[XPM Support] => 1
[XBM Support] …Run Code Online (Sandbox Code Playgroud) 我已将forEach polyfill添加到我的JavaScript文件的顶部,但Internet Explorer仍然说它不支持该功能.
我基本上想要遍历querySelector的结果,但是我在脚本中的其他一些数组对象上使用forEach.
这一切都适用于Chrome.
// Production steps of ECMA-262, Edition 5, 15.4.4.18
// Reference: http://es5.github.io/#x15.4.4.18
if (!Array.prototype.forEach) {
Array.prototype.forEach = function(callback/*, thisArg*/) {
var T, k;
if (this === null) {
throw new TypeError('this is null or not defined');
}
var O = Object(this);
var len = O.length >>> 0;
if (typeof callback !== 'function') {
throw new TypeError(callback + ' is not a function');
}
if (arguments.length > 1) {
T = arguments[1];
}
k = 0;
while …Run Code Online (Sandbox Code Playgroud) 我一直在关注Keith Clark的 CSS Parallax指南.他的概念是这样的:
HTML:
<div class="container”>
<div class="parallax-child”></div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.container {
width: 100%;
height: 100%;
overflow-x: hidden;
overflow-y: scroll;
perspective: 1px;
perspective-origin: 0 0;
}
.parallax-child {
transform-origin: 0 0;
transform: translateZ(-2px) scale(3);
}
Run Code Online (Sandbox Code Playgroud)
这在大多数情况下都是完美的,例如在我的开发网站上.但是我需要将这个效果添加到另一个我根本无法控制HTML结构的网站,下面是基本结构树,添加注释到我可以编辑的地方.
<html>
<body>
<div itemscope itemtype="http://schema.org/AutoDealer">
<div id="main-wrap">
<div class="row">
<div class="main twelvecol">
<!-- Editable -->
<div>
<div class="row-block finance parallax__group">
<div class="parallax__layer--back parallax__layer">
<p>Content in here scrolls slower than everything else</p>
</div>
<div class="wrapper">
<div class="container">
<div class="parallax__layer--base parallax__layer">
<p>This …Run Code Online (Sandbox Code Playgroud) 我有一个目前半工作的多层视差脚本.如果让我们说具有视差效果的元素放在网站的顶部,那么效果就会有效,因为当它滚出视图时你无法看到图层移出框架.
但是我希望能够在整个页面的多个元素上,在不同的位置使用此脚本.请参阅下面的示例,您可以看到效果正常,但如果您在该data-parallax="panel-1"部分添加一些边距,您将看到现在存在问题.
/**
* @author Martyn Lee Ball
* @desc Creates multi-layer Parallax effect
* @version 1.0
* @return {Array} Returns instances of classes as Array
*/
class Parallax {
constructor(node) {
const self = this;
// Settings and defaults
self.settings = {
container: node,
height: node.clientHeight,
name: node.dataset.parallax,
layers: [],
defaultDepth: 0.5,
offset: function(element) {
let top = 0;
do {
top += element.offsetTop || 0;
element = element.offsetParent;
} while(element);
return {
top: self.normalizeInt(top)
};
}.call(self, …Run Code Online (Sandbox Code Playgroud)我有一个 Vue 组件,我可以在其中放大图像,然后在容器周围移动它。缩放时还有一个小视口显示图像的哪些部分是可见的。但是,当围绕它移动图像时,它的移动速度比鼠标快,我猜这是由于使用了scale变换。
我也觉得当我在视口上单击并拖动时,我不应该两次反转值,但这似乎是让它用鼠标移动方块的唯一方法。
Vue.component('test', {
template: '#template',
data: function() {
return {
loading: true,
loop: true,
speed: 8,
speedController: 0,
zoomEnabled: true,
zoomLevels: [1, 1.5, 2, 2.5, 3],
zoomLevel: 1,
frame: 1,
images: [],
imagesPreloaded: 0,
reverse: false,
viewportScale: 0.3,
viewportEnabled: true,
viewportOpacity: 0.8,
lastX: 0,
lastY: 0,
startX: 0,
startY: 0,
translateX: 0,
translateY: 0,
isMoving: false,
isDragging: false,
};
},
mounted() {
window.addEventListener('mouseup', this.handleEnd);
window.addEventListener('touchend', this.handleEnd);
},
beforeDestroy() {
window.removeEventListener('mouseup', this.handleEnd);
window.removeEventListener('touchend', this.handleEnd);
},
methods: …Run Code Online (Sandbox Code Playgroud)我有一些图标我想在我的WPF应用程序使用,但是我需要他们几何对象,我将如何去的SVG转换为几何,还是几何不允许多个路径构成复杂的形状?
这是SVG数据,因此您可以看到我正在使用的内容:
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="438.529px" height="438.528px" viewBox="0 0 438.529 438.528" style="enable-background:new 0 0 438.529 438.528;"
xml:space="preserve">
<g>
<g>
<path d="M433.109,23.694c-3.614-3.612-7.898-5.424-12.848-5.424c-4.948,0-9.226,1.812-12.847,5.424l-37.113,36.835
c-20.365-19.226-43.684-34.123-69.948-44.684C274.091,5.283,247.056,0.003,219.266,0.003c-52.344,0-98.022,15.843-137.042,47.536
C43.203,79.228,17.509,120.574,5.137,171.587v1.997c0,2.474,0.903,4.617,2.712,6.423c1.809,1.809,3.949,2.712,6.423,2.712h56.814
c4.189,0,7.042-2.19,8.566-6.565c7.993-19.032,13.035-30.166,15.131-33.403c13.322-21.698,31.023-38.734,53.103-51.106
c22.082-12.371,45.873-18.559,71.376-18.559c38.261,0,71.473,13.039,99.645,39.115l-39.406,39.397
c-3.607,3.617-5.421,7.902-5.421,12.851c0,4.948,1.813,9.231,5.421,12.847c3.621,3.617,7.905,5.424,12.854,5.424h127.906
c4.949,0,9.233-1.807,12.848-5.424c3.613-3.616,5.42-7.898,5.42-12.847V36.542C438.529,31.593,436.733,27.312,433.109,23.694z"/>
<path d="M422.253,255.813h-54.816c-4.188,0-7.043,2.187-8.562,6.566c-7.99,19.034-13.038,30.163-15.129,33.4
c-13.326,21.693-31.028,38.735-53.102,51.106c-22.083,12.375-45.874,18.556-71.378,18.556c-18.461,0-36.259-3.423-53.387-10.273
c-17.13-6.858-32.454-16.567-45.966-29.13l39.115-39.112c3.615-3.613,5.424-7.901,5.424-12.847c0-4.948-1.809-9.236-5.424-12.847
c-3.617-3.62-7.898-5.431-12.847-5.431H18.274c-4.952,0-9.235,1.811-12.851,5.431C1.807,264.844,0,269.132,0,274.08v127.907
c0,4.945,1.807,9.232,5.424,12.847c3.619,3.61,7.902,5.428,12.851,5.428c4.948,0,9.229-1.817,12.847-5.428l36.829-36.833
c20.367,19.41,43.542,34.355,69.523,44.823c25.981,10.472,52.866,15.701,80.653,15.701c52.155,0,97.643-15.845,136.471-47.534
c38.828-31.688,64.333-73.042,76.52-124.05c0.191-0.38,0.281-1.047,0.281-1.995c0-2.478-0.907-4.612-2.715-6.427
C426.874,256.72,424.731,255.813,422.253,255.813z"/>
</g>
</g>
</svg>
Run Code Online (Sandbox Code Playgroud)
这是我目前正在使用的几何形状定义的示例:
<Geometry x:Key="RefreshIcon">
M19.85228,12.08996L12.093,19.849201 24.242323,31.997846 12.094,44.145998 19.852051,51.904958 32.001186,39.756277 44.150543,51.904958 51.909,44.145994 39.760246,31.997501 51.909,19.849201 44.15049,12.08996 32.001431,24.238849z M32,0C49.671021,3.1599484E-07 64,14.329407 64,31.998501 64,49.677606 49.671021,63.997003 32,63.997003 14.328003,63.997003 0,49.677606 0,31.998501 0,14.329407 14.328003,3.1599484E-07 32,0z
</Geometry>
Run Code Online (Sandbox Code Playgroud) 我试图从文件加载组件而不是在app.js.
因此,延迟加载的组件定义如下所示:
Vue.component(
'carousel',
() => import(
/* webpackChunkName: "carousel" */
'./components/carousel.vue'
)
);
Run Code Online (Sandbox Code Playgroud)
使用文件注册组件是这样的:
const files = require.context('./', true, /\.vue$/i);
files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default));
Run Code Online (Sandbox Code Playgroud)
我怎样才能结合这个?
我目前的尝试如下,但当然我错过了webpackChunkName不知道如何做到这一点:
const files = require.context('./', true, /\.vue$/i);
files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], () => import(files(key)) ));
Run Code Online (Sandbox Code Playgroud)
但是,这不起作用,我只是收到一条错误消息:
./resources/js/app.js 中的警告 9:11-29 关键依赖:依赖的请求是一个表达式 @ multi ./resources/js/app.js ./resources/sass/index.sass
我有一个开发数据库和一个实时数据库。我需要从实时数据库中返回一些结果,但仅针对此模型中的一种方法。
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class TableName extends Model
{
protected $table = 'table_name';
protected $connection = 'dev';
public $timestamps = false;
public static function live($index) {
$liveId = Settings::where('index', $index)->get()[0];
$live = new TableName;
$live->setConnection('live');
$data = $live::where('index', $liveId->live_index)->get();
dd($live);
return $data;
}
}
Run Code Online (Sandbox Code Playgroud)
如果我dd()在$live打完电话后变量setConnection然后它说,连接确实live。但是,只要我dd()在$data我从一开始的行开发数据库!