每当我的C#项目中需要新的应用程序设置时,我都会通过PROJECT - > Properties - > Settings添加它.目前我的C#项目中有大约20个应用程序设置,但是它们不正常.
为了能够在运行时更改设置,我通过迭代设置创建了一个简单的设置面板.
foreach (System.Configuration.SettingsProperty prop in Properties.Settings.Default.Properties)
{
Label caption = new Label();
caption.Text = prop.Name;
caption.Location = new Point(10, this.Height - 70);
caption.Size = new Size(100, 13);
caption.Anchor = AnchorStyles.Left | AnchorStyles.Top;
TextBox textbox = new TextBox();
textbox.Name = prop.Name;
textbox.Text = Properties.Settings.Default[prop.Name].ToString();
textbox.Location = new Point(120, this.Height - 70);
textbox.Size = new Size(this.Width - 140, 23);
textbox.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
if (prop.IsReadOnly)
textbox.ReadOnly = true;
this.Height += …Run Code Online (Sandbox Code Playgroud) 是否有onClick锚标记的事件?我有以下代码行:
<li><a href="#" runat="server">Logout</a></li>
Run Code Online (Sandbox Code Playgroud)
当用户单击注销文本时,我希望它触发一些代码,这些代码将在以下方法中:
protected void btnLogout_Click(object sender, EventArgs e)
{
Session.RemoveAll();
Session.Abandon();
}
Run Code Online (Sandbox Code Playgroud)
在锚标记中执行此操作的最佳做法是什么?
我在includes/parser/Parser.phpMediaWiki PHP源代码中发现了这个:
public function replaceInternalLinks2( &$s ) {
global $wgExtraInterlanguageLinkPrefixes;
static $tc = false, $e1, $e1_img;
//...
}
Run Code Online (Sandbox Code Playgroud)
这个以逗号分隔的列表是什么?有什么价值$tc?
例如 - 表名= TABLE
StudentID | SubCode | SubName
-----------------------------
1 M1 Math
1 S1 Science
1 E1 English
2 H1 History
3 G2 Geography
4 M1 Math
Run Code Online (Sandbox Code Playgroud)
我们可以这样显示答案吗?
studentid | SubCode | SubName
---------------------------------
1 M1 Math
1 S1 Science
1 E1 English
Run Code Online (Sandbox Code Playgroud) 我目前有两种方法可以检查一个数字是否为素数,另一种方法是计算所需的时间.
IsPrime1:
bool IsPrime1(int i)
{
if (i == 2 || i == 3 || i == 5 || i == 7) return true;
return i % 2 != 0 && i % 3 != 0 && i % 5 != 0 && i % 7 != 0;
}
Run Code Online (Sandbox Code Playgroud)
IsPrime2:
bool IsPrime2(int i)
{
if (i == 2 || i == 3 || i == 5 || i == 7) return true;
if (i % 2 == 0) return false; …Run Code Online (Sandbox Code Playgroud) 我从维基百科生成了两个文本文件和jpeg文件.现在我想以json格式序列化所有这个文件.第一个我生成了一个短文本文件,第二个我生成了该位置的纬度和经度,第三个是图像文件作为哈希码.图像和短文文件工作正常.但我有纬度和经度文件的问题.我的文本文件看起来像是新行
Lat:54.33333333
Lon:10.13333333
Run Code Online (Sandbox Code Playgroud)
我想把它放在一个数组中.现在我用于为所有对象创建json的json类是 -
public class GeoCoordinates
{
public double Longitude { get; set; }
public double Latitude { get; set; }
}
public class POIData
{
public string ShortText { get; set; }
public GeoCoordinates GeoCoordinates { get; set; }
public List<string> Images { get; set; }
public string ToJson()
{
string json = JsonConvert.SerializeObject(this, Formatting.Indented);
return json;
}
public void FromJson(string json)
{
dynamic poi = JsonConvert.DeserializeObject<POIData>(json);
ShortText = poi.ShortText;
Images = poi.Images;
GeoCoordinates = poi.GeoCordinates;
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试安装 bluepy 1.0.5。但是,我收到下面的错误。知道如何解决吗?(我使用的是 Mac OS X El Capitan)
40:449:执行错误:目录“/Users/isozyesil/Library/Caches/pip/http”或其父目录不属于当前用户所有,并且缓存已被禁用。请检查该目录的权限和所有者。如果使用 sudo 执行 pip,您可能需要 sudo 的 -H 标志。
目录“/Users/isozyesil/Library/Caches/pip”或其父目录不属于当前用户,并且缓存轮已被禁用。检查该目录的权限和所有者。如果使用 sudo 执行 pip,您可能需要 sudo 的 -H 标志。
命令/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/95/f900ttf95g1b7h02y2_rtk400000gn/T/pycharm-packaging669/bluepy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/95/f900ttf95g1b7h02y2_rtk400000gn/T/pip-djih0T-record/install-record.txt --single-version-externally-managed --compile
失败,错误代码为 1 /private/var/folders/95/f900ttf95g1b7h02y2_rtk400000gn/T/pycharm-packaging669/bluepy/ (1)
我在网站上有一个用户图库,访问者可以上传一些图片.上传后,图像应调整为一些预定义的预设.另外原始图像也应该保存.所有工作正常png和bmp图像格式.但是,如果我上传gif格式或jpeg以一种颜色占优势上传的原始图像似乎被压缩.
例如:
原版的:

上传时间:
我在谷歌搜索过,并找到了一些如何正确上传图片的例子.最后我写了下一个方法:
void UploadImagePreset(Image image, ImageFormat imgFormat, string imgPath)
{
using (var uploadStream = imageUploader.CreateUploadStream(imagePath))
{
var newWidth = image.Width;
var newHeight = image.Height;
using (var outBitmap = new Bitmap(newWidth, newHeight))
{
using (var outGraph = Graphics.FromImage(outBitmap))
{
outGraph.CompositingQuality = CompositingQuality.HighQuality;
outGraph.SmoothingMode = SmoothingMode.HighQuality;
outGraph.PixelOffsetMode = PixelOffsetMode.HighQuality;
outGraph.InterpolationMode = InterpolationMode.HighQualityBicubic;
var imageRect = new Rectangle(0, 0, newWidth, newHeight);
outGraph.DrawImage(image, imageRect);
outBitmap.Save(uploadStream, imgFormat);
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
但它没有帮助.上载的图像与上述相同.我试图像这样指定结果图像的qaulity:
var encoderParameters …Run Code Online (Sandbox Code Playgroud) 我认识到,当我想在c#中为多个对象/控件(这里是标签)设置相同的属性时,我必须经常输入相同的代码.这通常看起来像这样:
string s = "one attribute";
label1.Text = s;
label2.Text = s;
label3.Text = s;
label4.Text = s;
label5.Text = s;
Run Code Online (Sandbox Code Playgroud)
有没有办法更快地用更少的代码来做这件事?我想像这样的东西:
string s = "one attribute";
(label1 && label2 && label3 && label4 && label5).Text = s;
Run Code Online (Sandbox Code Playgroud)
回答:
string s = "one attribute";
label1.Text =
label2.Text =
label3.Text =
label4.Text =
label5.Text = s;
Run Code Online (Sandbox Code Playgroud) 我一直试图将位图设置为MP3的封面艺术,但我似乎无法让它工作.它没有抛出任何错误,但是当我播放MP3时,位图没有显示.
这就是我目前拥有的:
TagLib.File f = TagLib.File.Create("song.mp3");
Image currentImage = getAlbumArt(result.passedAlbumID);
Picture pic = new Picture();
pic.Type = PictureType.FrontCover;
pic.MimeType = System.Net.Mime.MediaTypeNames.Image.Jpeg;
pic.Description = "Cover";
MemoryStream ms = new MemoryStream();
currentImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
ms.Position = 0;
pic.Data = ByteVector.FromStream(ms);
f.Tag.Pictures = new IPicture[1] { pic };
pictureBox1.Image = currentImage; //testing the image is correct
f.Save();
ms.Close();
Run Code Online (Sandbox Code Playgroud) 我正在 Laravel 5.5 中构建一个 GraphQL API,我收到一个错误消息User::create(),说我没有为“密码”列提供值,即使我确实提供了。这是来自User::create():的完整消息:
SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column \"password\" violates not-null constraint
DETAIL: Failing row contains (507, null, null, 2017-09-23 14:12:11, 2017-09-23 14:12:11, 658495, 56854685, Joe, Appleseed, royal, 1970-01-01, +31684736248, null, Poplar St, 14a, 1012AB, London, null, joe.appleseed@overwatch.com, joe.appleseed@mindef.nl, null). (SQL: insert into \"users\" (\"wid\", \"unumber\", \"first_name\", \"last_name\", \"civil_status\", \"birthdate\", \"phone_number\", \"street\", \"street_number\", \"postal_code\", \"city\", \"email_address_overwatch\", \"email_address_mindef\", \"updated_at\", \"created_at\") values (658495, 56854685, Joe, Appleseed, royal, 1970-01-01, +31684736248, Poplar …Run Code Online (Sandbox Code Playgroud) c# ×7
.net ×2
asp.net ×2
php ×2
arrays ×1
bitmap ×1
eloquent ×1
if-statement ×1
json ×1
laravel ×1
linq ×1
mysql ×1
performance ×1
postgresql ×1
primes ×1
properties ×1
pycharm ×1
python ×1
serial-port ×1
signals ×1
sql ×1
syntax ×1
taglib-sharp ×1
winforms ×1