我有一个像这样的 C# 元组列表:
List<(int, (double, double))> lightStabilizers;
列表项必须通过键盘输入Console.ReadLine().Split()。结果数组需要以某种方式转换为元组并添加到列表中。
如何将数组转换为元组?我正在尝试通过方法来做到这一点System.Linq,但我不知道在哪里看
我有一个像这样的 C# 元组列表:
List<(int, (double, double))> lightStabilizers;
列表项必须通过键盘输入Console.ReadLine().Split()。结果数组需要以某种方式转换为元组并添加到列表中。
如何将数组转换为元组?我正在尝试通过方法来做到这一点System.Linq,但我不知道在哪里看
我在我的网站上安装了新版本的 FontAwesome 图标字体。想要使用“Web 字体和 CSS”选项。我按照说明做所有事情:我在文件夹中添加样式css和在文件夹中添加字体webfonts,但图标没有顽固地显示。
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="css/fontawesome-all.min.css" rel="stylesheet">
<title>Hello, world!</title>
</head>
<body>
<i class="fas fa-pencil"></i>
<body>
顺便说一句,它们没有显示在使用 CDN 的此代码段中。
<head>
<link href="https://use.fontawesome.com/releases/v5.0.8/css/all.css" rel="stylesheet">
</head>
<body>
<i class="fas fa-pencil"></i>
</body>
如何解决?
有一个程序可以从文件中读取数据并将其添加到数组中:
#!/usr/bin/perl
use strict;
use utf8;
use warnings FATAL => 'all';
use Switch;
open(FILE, "+<prodazhi.txt");
binmode FILE, ":utf8";
binmode STDOUT, ":utf8";
# здесь функции, работающие с массивом
while (<FILE>) {
chomp;
($id, $name, $serial, $delivery, $amount, $cost, $date) = split '\t';
add_new($id, $name, $serial, $delivery, $amount, $cost, $date);
}
print 'Выберите действие';
$_ = <STDIN>;
print $_;
(函数add_new将数据添加到数组中)
有必要在“选择一个动作”行的输出之后,我可以输入动作的编号来对数组执行某个动作。但是,在我输入之前不会输出该行。那些。我输入数字“1”,然后它才输出“Enter action1”。在那之前,输出流似乎被阻塞了。
告诉我如何解决这个问题?
我正在尝试为 Codeigniter 设置重定向,以便 URL 像localhost/codeigniter/class, 所以 localhost/codeigniter/class. Drupal 8 中也使用了这种类型的 URL,所以我决定使用 regexp 进行重定向:
location ~ /(drupal|codeigniter)/ {
try_files $uri $uri/ @rewrite8;
}
location @rewrite8 {
rewrite ^/(drupal|codeigniter) /$1/index.php;
}
但是,当我转到该页面时,系统会提示我下载文件(在响应标头中,MIME 类型看起来像octet-stream)。
如果您不使用正则表达式:
location /codeigniter/ {
try_files $uri $uri/ @rewrite8;
}
然后一切正常并给出text/html。
什么可能导致这种情况以及如何进行正确的重定向?
UPD。完整配置:
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html index.php;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location /codeigniter/ {
try_files $uri $uri/ @rewrite8;
}
location /drupal7/ {
try_files $uri $uri/ @rewrite7;
}
location @rewrite7 {
rewrite ^/drupal7/(.*)$ /drupal7/index.php?q=$1;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php-fastcgi/php-fastcgi.socket;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
}
location @rewrite8 {
rewrite ^/(drupal|codeigniter) /$1/index.php;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
有这棵树:
var li = $('li');
li.click(function () {
var children = $(this).children('ul');
if (children.is(':hidden')) children.show();
else children.hide();
})
li > ul {
margin-left: 20px;
display: none;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="container">
<div class="row">
<div class="col-sm-4">
<ul class="nav nav-pills nav-stacked">
<li role="presentation"><a href="#">животные</a>
<ul class="nav nav-pills nav-stacked">
<li role="presentation"><a href="#">хищники</a>
<ul class="nav nav-pills nav-stacked"><li role="presentation"><a href="#">волк</a></li>
<li role="presentation"><a href="#">тигр</a></li>
<li role="presentation"><a href="#">лев</a></li>
</ul>
</li>
<li role="presentation"><a href="#">травоядные</a>
<ul class="nav nav-pills nav-stacked"><li role="presentation"><a href="#">слон</a></li>
<li role="presentation"><a href="#">заяц</a></li>
<li role="presentation"><a href="#">лама</a></li>
<li role="presentation"><a href="#">зебра</a></li>
</ul>
</li>
</ul>
</li>
<li role="presentation"><a href="#">растения</a>
<ul class="nav nav-pills nav-stacked">
</ul>
</li>
</ul>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
折叠子项时如何使父项不折叠?
有这样的块布局:
* {
width:576px;
}
.item {
border: 1px #dededc solid;
height: 232px;
}
#four-blocks {
overflow: hidden;
}
#four-blocks .item {
width: 280px;
float: left;
margin-bottom: 10px;
}
#four-blocks .item:nth-child(1), .item:nth-child(3){
margin-right: 11px;
/*box-shadow: 0 3px 0 3px coral;*/
}
<div id="four-blocks">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
有必要在水平和垂直方向上用一条线分隔块,如下所示:
怎么做?我不是在想象什么。
您需要使用纯 CSS 来设置 select 标签的样式。我尝试这样做,但是当您单击向下箭头时,列表不会打开,您需要单击该字段本身。
* {font-family: Arial}
#search {
height: 270px;
width: 310px;
/*background: #fff65f;*/
overflow: hidden;
}
#search-form {
background: #8bab40;
color: #ffffff;
padding-left: 40px;
padding-top: 14px;
}
#search-form input[type="text"], select {
width: 230px;
background: #afc968;
margin-top: 5px;
margin-bottom: 5px;
font-family: Arial;
color: #557013;
}
#search-form input[type="text"]{
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.select span{
position: relative;
top: 2px;
right: -3px;
}
.select-button {
float: right;
width: 18px;
height: 18px;
position: relative;
/*z-index: -9999;*/
top: 7px;
right: 42px;
background: #77993a linear-gradient(rgba(255, 255, 255, .5), rgba(255, 255, 255, 0));
border: #70902b 1px solid;
}
.caret {
display: inline-block;
width: 0;
height: 0;
margin-left: 2px;
vertical-align: middle;
border-top: 4px solid;
border-right: 4px solid transparent;
border-left: 4px solid transparent;
}
#search-form select {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
<div id="search">
<div id="search-form">
<form>
<label>Keyword(s)</label><br>
<input type="text">
<label>Category</label><br>
<div class="select">
<select>
<option>--select--</option>
</select>
<div class="select-button"><span class="caret"></span></div>
</div>
</form>
</div>
</div>
这里还需要做什么?
表单代码:
div {
font-size: 12px;
font-family: Arial, sans-serif;
}
#block-search {
float: right;
margin: 7px 10px;
}
#block-search input[type="text"] {
background: #f4f4ec;
border: #dfdfdf 1px solid;
}
#block-search input[type="submit"] {
background: #ce3c00;
color: #ffffff;
text-transform: uppercase;
font-size: 12px;
font-family: Arial, sans-serif;
border: #ba4f23 1px solid;
height: 21px;
}
<div id="block-search">
<form>
Search:
<input type="text" size="10">
<input type="submit" value="search">
</form>
</div>
我需要按钮与输入字段位于同一行。尝试了各种组合margin,padding但没有任何效果。如果使用 flex,则元素之间的所有水平缩进都将丢失。
从一种形式,使用类似的代码(实际上是标准代码)启动另一种形式:
private void Show_Click(object sender, EventArgs e)
{
Child form1 = new Child();
form1.ShowDialog();
}
如何找出启动的表单类型Child?基于此,应确定表格的内容Child。
我正在尝试DataGridView使用列表中的值填写表格:
public partial class TeachDisciplines : Form
{
public class Discipline
{
public int Number { get; set; }
public string Name { get; set; }
public Discipline(int v1, string v2)
{
Number = v1;
Name = v2;
}
}
List<Discipline> disc = new List<Discipline>();
public TeachDisciplines()
{
InitializeComponent();
//DiscList.AutoGenerateColumns = true;
disc.Add(new Discipline(1, "Программная инженерия"));
disc.Add(new Discipline(2, "Математический анализ"));
DiscList.DataSource = disc;
}
}
该表充满了空行。该列表似乎不是空的。列表元素属性也是公共的。他还缺少什么?
使用循环结构编写了一个带有汇编程序插入的简单程序:
// laba4.cpp: определяет точку входа для консольного приложения.
//
#include "stdafx.h"
int main()
{
int a, b, n;
cin >> n;
_asm {
mov ebx, 1;
mov ecx, n;
dec ecx;
mov ebp, 1;
mov esi, 1;
mov edi, -1;
loop_1:
mov eax, edi;
imul ebp;
mov esp, eax;
inc esi;
mov eax, ebx;
mul esi;
mov ebx, eax;
mov eax, ebp;
mul esi;
mov ebp, eax;
add ebx, esp;
neg edi;
loop loop_1;
mov a, ebx;
mov b, ebp;
}
cout << a << "/" << b;
return 0;
}
所以,当从寄存器写入变量的值时(mov a, ...; mov b, ...发生“违反写访问”错误。这里有什么问题?
我已经在西里尔文编号阶段打滑了:
\makeatletter
\renewcommand\appendix{\par
\setcounter{section}{0}%
\setcounter{subsection}{0}%
\gdef\thesection{\@Asbuk\c@section}}
\makeatother
不给出任何结果并不断输出pdfTeX warning (ext4): destination with the same identifier (name{section.1}) has been already used, duplicate ignored。使用 instead \@Asbukof other character sets 可以工作(但是,会形成不正确的链接)。
该文档具有类extarticle.
也许有一些现成的食谱?如果没有,请告诉我需要做什么。
我正在为基于 bootstrap 的 Drupal 7 设计一个主题。我不使用特殊的基本主题,我手动完成所有操作。
您需要确保菜单中指向主页的链接看起来像一个字形的房子:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<a href="#"><span class="glyphicon glyphicon-home"></span></a>
我正在尝试像这样实现它:
function imit_menu_link__main_menu ($variables) {
$element = $variables['element'];
$sub_menu = '';
if ($element['#below']) {
$sub_menu = drupal_render($element['#below']);
}
if ($element['#href'] == '<front>') {
$element['#title'] = '<span class="glyphicon glyphicon-home"></span>';
}
$output = l($element['#title'], $element['#href']);
return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}
但最后,标签span显示为纯文本。如何强制将其呈现为 HTML 元素?
需要使活动菜单项在 Drupal 7 主题中突出显示,为此您需要设置active标签类<li>而不是<a>. 出于某种原因,我无法更改 CSS。我正在尝试这样做theme_preprocess_menu_link():
function mytheme_preprocess_menu_link (&$variables) {
$element = $variables['element'];
$attributes = $element['#attributes'];
$attributes['class'] = array_unique($attributes['class']);
$classes = $attributes['class'];
if (in_array('active-trail', $classes) || ($element['#href'] == '<front>' && drupal_is_front_page())) {
$element['#attributes']['class'][] = 'active';
}
}
function mytheme_menu_link__main_menu ($variables) {
$element = $variables['element'];
$sub_menu = '';
if ($element['#below']) {
$sub_menu = drupal_render($element['#below']);
}
$output = l($element['#title'], $element['#href']);
return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}
没有结果 - 和以前一样,此类仅设置为标签a。请告诉我如何正确添加课程。
我正在引导程序上建立一个网站。有必要确保右栏中大屏幕上显示的信息在内容部分的顶部显示在移动设备上。但是,默认情况下,右列会下降。如何布局页面以使右栏上升?
HTML 代码:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<main>
<div class="container">
<div class="row">
<div class="col-sm-9">
<div class="content">
<div class="info">
<h2>Информация</h2>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam sed massa sollicitudin, accumsan
diam et, luctus elit. Praesent odio est, faucibus a est at, dictum facilisis mi. Vestibulum a
libero odio. Sed nec ullamcorper nulla, ac lobortis odio. Donec egestas vel risus ac gravida.
Curabitur consectetur lobortis auctor. Fusce cursus semper lorem, ac auctor nunc fermentum sit
amet. Pellentesque nec lacus in magna consectetur viverra. Proin quis turpis laoreet, aliquam
est ac, lacinia nibh. Aliquam erat volutpat. Curabitur placerat consectetur maximus.
Mauris accumsan leo non lacus vehicula efficitur.
</div>
<div class="galerry">
<h2>Фотогалерея</h2>
Место для фотогалереи
</div>
<div class="news">
<h2>Новости</h2>
Место для новостей
</div>
</div>
</div>
<div class="col-sm-3">
<div class="search">
<h4>Поиск</h4>
<div class="input-group">
<input class="form-control" type="text">
<span class="input-group-btn">
<button class="btn btn-default"><span class="glyphicon glyphicon-search"></span> </button>
</span>
</div>
</div>
<div class="newspaper">
<h3>Газета</h3>
<div class="last">Содержимое блока</div>
</div>
<div class="contacts">
<h3>Контакты</h3>
<div class="contact">
<h5 class="small">jjj</h5>
</div>
</div>
</div>
</div>
</div>
</main>
我正在使用 3d 图形制作 WPF 程序。该程序的目的是创建一个通过拖动鼠标进行旋转的立方体。
模型本身已经准备就绪,事件处理程序也已实现。然而,有一个麻烦:在大角度旋转时,立方体某处的面片会消失。它看起来像这样:
如何解决?
XAML 中的表单代码:
<Window x:Class="laba10.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:laba10"
mc:Ignorable="d"
Title="RotateCube" Height="350" Width="525"
MouseDown="Window_MouseDown" MouseMove="Window_MouseMove" MouseUp="Window_MouseUp">
<Grid>
<Viewport3D>
<Viewport3D.Camera>
<PerspectiveCamera Position="1.5,0,1" LookDirection="0,0,-2" FieldOfView="105" />
</Viewport3D.Camera>
<ModelVisual3D>
<ModelVisual3D.Content>
<DirectionalLight x:Name="light" Color="#FFFFFF" Direction="-1,-1,-2" />
</ModelVisual3D.Content>
<ModelVisual3D.Transform>
<RotateTransform3D>
<RotateTransform3D.Rotation>
<AxisAngleRotation3D x:Name="rotatel" Axis="0 1 0"/>
</RotateTransform3D.Rotation>
</RotateTransform3D>
</ModelVisual3D.Transform>
</ModelVisual3D>
<!--wire model-->
<ModelVisual3D>
<ModelVisual3D.Content>
<GeometryModel3D>
<GeometryModel3D.Geometry>
<MeshGeometry3D
Positions="-1 -1 0 1 -1 0 -1 1 0 1 1 0 -1 -1 2 1 -1 2 -1 1 2 1 1 2
-1 -0.99 0 1 -0.99 0 0.99 -1 0 0.99 1 0 -1 0.99 0 1 0.99 0 -0.99 1 0 -0.99 -1 0
-1 -0.99 2 1 -0.99 2 0.99 -1 2 0.99 1 2 -1 0.99 2 1 0.99 2 -0.99 1 2 -0.99 -1 2"
TriangleIndices="0 1 8 1 9 8 10 1 11 1 3 11 2 12 13 13 3 2 0 15 2 15 14 2 0 4 8
4 16 8 4 23 6 23 22 6 2 14 22 22 6 2 4 5 16 5 17 16 18 5 19 5 7 19 6 20 21 20 21 7
9 1 17 17 1 5 11 3 19 19 3 7"/>
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<SolidColorBrush Color="Black" Opacity="1" />
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
<GeometryModel3D.Transform>
<TranslateTransform3D
OffsetX="1.5" OffsetY="0." OffsetZ="-3" >
</TranslateTransform3D>
</GeometryModel3D.Transform>
</GeometryModel3D>
</ModelVisual3D.Content>
<ModelVisual3D.Transform>
<RotateTransform3D CenterX="1.5" CenterY="0." CenterZ="-3">
<RotateTransform3D.Rotation>
<AxisAngleRotation3D x:Name="rotatew" Axis="0 1 0"/>
</RotateTransform3D.Rotation>
</RotateTransform3D>
</ModelVisual3D.Transform>
</ModelVisual3D>
<!--solid model-->
<ModelVisual3D>
<ModelVisual3D.Content>
<GeometryModel3D>
<GeometryModel3D.Geometry>
<MeshGeometry3D
Positions="-1 -1 0 1 -1 0 -1 1 0 1 1 0 -1 -1 2 1 -1 2 -1 1 2 1 1 2"
Normals="0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1"
TriangleIndices="0 1 2 1 3 2 0 4 2 4 6 2 1 5 3
5 7 3 4 5 6 5 7 6 0 1 4 1 5 4
2 3 6 3 6 7" />
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<SolidColorBrush Color="Cyan" Opacity="0.5"/>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
<!-- Translate the plane. -->
<GeometryModel3D.Transform>
<TranslateTransform3D
OffsetX="1.5" OffsetY="0" OffsetZ="-3" >
</TranslateTransform3D>
</GeometryModel3D.Transform>
</GeometryModel3D>
</ModelVisual3D.Content>
<ModelVisual3D.Transform>
<RotateTransform3D
CenterX="1.5" CenterY="0." CenterZ="-3">
<RotateTransform3D.Rotation>
<AxisAngleRotation3D x:Name="rotates" Axis="0 1 0"/>
</RotateTransform3D.Rotation>
</RotateTransform3D>
</ModelVisual3D.Transform>
</ModelVisual3D>
</Viewport3D>
</Grid>
</Window>
安装在 Ubuntu PhpStorm 上。有一条关于次要更新的消息。我点了“更新”,下载了更新文件,重启了IDE……版本还是一样。PhpStorm 以 root 身份运行。
我查看了日志,没有发现任何表明更新有任何错误的行。
我怎么还能更新?
您希望移动控件使其不超出窗体的边界。使用左边框,跟踪边框很容易:
if (PointToClient(p).X >= 0){/*код*/ }
但是当我尝试这样做时:
int w = ActiveForm.Size.Width;
if (PointToClient(p).X <= w){/*код*/ }
该元素仍然超出了右边界。也就是说Size.Width,它不是窗体的右边框。
对此,问题是:如何确定正确的边界?