我使用以下内容:
$chartImage->autoOutput('/statistics/'.$image.'.png');
Run Code Online (Sandbox Code Playgroud)
问题是此代码将图像输出到浏览器.如果它将图像保存到我指定的目录和名称的文件中,我更喜欢它.我该怎么做呢?我正在查看pChart wiki,它对所有这些pCache的东西非常困惑.我不需要任何缓存或类似的东西......我只是想保存图像.
所以我在WinForms .NET 3.5中这样做...我现在正在使用WPF .NET 4.0 ......我无法弄清楚如何做到这一点.
这就是我在Windows .NET 3.5中所做的
using (Bitmap eventImg = new Bitmap("input.png"))
{
Graphics eventGfx = Graphics.FromImage(eventImg);
buildText(eventGfx, this.event1.Text);
eventImg.Save("output.png", ImageFormat.Png);
eventGfx.Dispose();
}
Run Code Online (Sandbox Code Playgroud)
上面的代码将现有图像带到"input.png",从中创建一个新图像,从中写入文本,然后将新图像保存在"output.png".使用以下函数编写文本:
private void buildText(Graphics graphic, string text)
{
if (text.Length == 0) { return; }
FontStyle weight = FontStyle.Regular;
switch (this.font_style)
{
case "regular": weight = FontStyle.Regular; break;
case "bold": weight = FontStyle.Bold; break;
case "italic": weight = FontStyle.Italic; break;
case "underline": weight = FontStyle.Underline; break;
case "strikeout": weight = FontStyle.Strikeout; break;
}
using …Run Code Online (Sandbox Code Playgroud) 所以我使用以下代码从输入表单中获取现有图像,文本,然后将输入表单中的文本放到现有图像上并将其另存为新图像:
using (FileStream output = new FileStream(match_outputFile, FileMode.Create))
{
BitmapImage bitmap = new BitmapImage(new Uri(match_sourceFile, UriKind.Relative));
DrawingVisual visual = new DrawingVisual();
using (DrawingContext image = visual.RenderOpen())
{
image.DrawImage(bitmap, new Rect(0, 0, bitmap.PixelWidth, bitmap.PixelHeight));
buildText(image, "text1", this.text1.Text);
buildText(image, "text2", this.text2.Text);
buildText(image, "text3", this.text3.Text);
}
RenderTargetBitmap target = new RenderTargetBitmap(bitmap.PixelWidth, bitmap.PixelHeight, bitmap.DpiX, bitmap.DpiY, PixelFormats.Default);
target.Render(visual);
BitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(target));
encoder.Save(output);
}
Run Code Online (Sandbox Code Playgroud)
如您所见,它调用以下函数来绘制文本:
private void buildText(DrawingContext image, string settings, string input)
{
string[] setting = (Properties.Settings.Default[settings].ToString()).Split(',');
FormattedText text = new FormattedText( …Run Code Online (Sandbox Code Playgroud) 好的,我在Visual Studio 2010 Express中编写了一个WinForms C#程序.该程序有两种形式,主要形式称为"MainForm",以及一种名为"ConfigForm"的辅助形式.MainForm上有一个按钮,弹出ConfigForm.
private void buttonConfig_Click(object sender, EventArgs e)
{
new ConfigForm().Show();
}
Run Code Online (Sandbox Code Playgroud)
现在,当您单击按钮时,ConfigForm会弹出任何感觉.它不一定会弹出MainForm.如何在主窗体上弹出它?我已经尝试将ConfigForm的StartPosition设置为CenterParent,但这似乎没有做任何事情.
就此而言,如何在ConfigForm打开时"锁定"程序.当ConfigForm打开时,如果用户无法导航回MainForm,我更愿意.
因此,我使用 DrawingContext 和 DrawingVisual 生成透明 PNG。
在 DrawingContext 中,我画了一个矩形。
我现在想在矩形内“切出”一个圆。我该怎么做呢?我没有找到任何绘制上下文来清除区域的函数。
好的,这个问题有点数学,有点CSS帮助...让我说我有一个多边形:
:root {
--poly-height: 100px;
--poly-width: 300px;
}
.poly1 {
background-color: black;
height: var(--poly-height);
width: var(--poly-width);
-webkit-clip-path: polygon(
0 0,
30px 100%,
100% 100%,
calc(100% - 20px) 50%,
100% 0
);
}Run Code Online (Sandbox Code Playgroud)
<div class="poly1"> </div>Run Code Online (Sandbox Code Playgroud)
这个多边形有五个点,让我们调用它们A B C D E.
如果我们看点B,你可以看到x,y位置30px 100%.这导致了一个倾斜,我不知道多少度...
现在让我们说,在将来的某个时候,我想改变.poly1元素的高度.但是,更改元素的高度也会改变倾斜度,因为30px插入是固定的.
我想知道的是,如果有一种方法来计算插入的值,知道元素的高度,起点0,0和所需的倾斜程度,可以说20deg ......这可以在CSS calc中完成?
因此,从点开始A的0,0,我想获得的x点值B,渴望一个20deg倾斜,并且知道什么的价值y将是.在上面的例子中,它被设置为100px;
在线搜索,我发现这个数学计算是:
y = height * tan(20 degrees)
Run Code Online (Sandbox Code Playgroud)
现在......是否可以在CSS3计算中执行此操作?
好的,所以我有一个使用WinForms在Visual Studio 2013 C#中编写的应用程序.在应用程序将是3个按钮.
Add Tab Type A
Add Tab Type B
Add Tab Type C
Run Code Online (Sandbox Code Playgroud)
在这3个按钮下面将是一个空的TabControl.当有人点击上述3个按钮之一时,我需要程序使用预定义的布局向TabControl添加新的Tab.3个按钮中的每个按钮都将生成一个新选项卡,其中包含与其他2个按钮不同的布局.
WinForms似乎没有内置的方法来做到这一点.有没有人有任何想法?
好吧,我想说我有一个字符串:
string text = "one|two|three";
Run Code Online (Sandbox Code Playgroud)
如果我这样做,string[] texts = text.Split('|');我将得到一个包含三个对象的字符串数组.但是,这不是我想要的.我真正想要的是只将字符串拆分一次......所以这两个数组我可以这样:
one
two|three
Run Code Online (Sandbox Code Playgroud)
另外,有没有办法在字符串中最后一次出现单个拆分?所以我得到:
one|two
three
Run Code Online (Sandbox Code Playgroud)
同样,有没有办法用字符串而不是字符分割?所以我能做到Split("||")
所以我有一个复杂的上下文菜单。它不仅仅是菜单项。它也有单选按钮,底部有一个 stackpanel,里面有一个 integerupdown 框。

<Button.ContextMenu>
<ContextMenu>
<RadioButton Tag="30" Content="30 seconds" GroupName="adLength" Checked="adLength_Checked" IsChecked="True"/>
<RadioButton Tag="60" Content="1 minutes" GroupName="adLength" Checked="adLength_Checked"/>
<RadioButton Tag="90" Content="1 min 30 sec" GroupName="adLength" Checked="adLength_Checked"/>
<RadioButton Tag="120" Content="2 minutes" GroupName="adLength" Checked="adLength_Checked"/>
<RadioButton Tag="150" Content="2 min 30 sec" GroupName="adLength" Checked="adLength_Checked"/>
<RadioButton Tag="180" Content="3 minutes" GroupName="adLength" Checked="adLength_Checked"/>
<Separator/>
<MenuItem x:Name="advert_Auto" Header="Run Automatically" IsCheckable="true" StaysOpenOnClick="True"/>
<StackPanel Orientation="Horizontal">
<TextBlock>every</TextBlock>
<xctk:IntegerUpDown x:Name="advert_Time" Value="30" Minimum="15" Width="50" Margin="5,0" />
<TextBlock>min</TextBlock>
</StackPanel>
</ContextMenu>
</Button.ContextMenu>
Run Code Online (Sandbox Code Playgroud)
该<MenuItem>对象可以选择staysopenonclick; 当有人单击该项目时,上下文菜单保持打开状态。该<RadioButton>对象没有这个选项,但他们保持开放反正。
我遇到的问题是最后一项,<StackPanel>. 当用户单击 …
我有一个记分牌...这个记分牌是一系列内联块div,以保持水平:
<div class="top">
<div class="score1 color0 inline slow">
<div class="inner color3 slow">
<div class="title">0</div>
</div>
</div>
<div class="player1 color0 inline slow">
<div class="inner color2 slow">
<div class="title">KDZaster</div>
</div>
</div>
<div class="round color0 inline slow">
<div class="inner color1 slow">
<div class="title">Grand Finals</div>
</div>
</div>
<div class="player2 color0 inline slow">
<div class="inner color2 slow">
<div class="title">DarthArma</div>
</div>
</div>
<div class="score2 color0 inline slow">
<div class="inner color3 slow">
<div class="title">0</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我已经包含了一个jsFiddle:https://jsfiddle.net/Lsxhmky7/
这个页面有一大堆动画,我正在用CSS和jQuery(jsFiddle中没有包含)...我已经让所有的动画工作,除了一个.
我想做的其中一件事是,左右两侧的两个刻度箭头从屏幕边缘滑入.
我知道我可以通过绝对定位来做到这一点,但是这个网格在绝对位置上没有任何其他东西,我不希望它.我希望它是内联的,这样如果某些元素的宽度必须改变,页面就随之移动.
有没有一种方法可以动画从屏幕外移动这两个元素,同时保持所有其他块的内联定位?
c# ×5
wpf ×4
css ×2
winforms ×2
.net ×1
animation ×1
contextmenu ×1
html ×1
javascript ×1
pchart ×1
php ×1
string ×1
string-split ×1
tabcontrol ×1
trigonometry ×1