使用Apexcharts.js中的brush类型图表,上面的折线图无法刷新,求教问题在哪? 10C

Apexcharts.js中的brush类型图表无法刷新数据

求教各路大神,本人最近在做一个前端开发项目,需要用一张图来展现100个数据,这100个数据是从通过ajax请求从后端接收的,每10秒轮询一次,更新100个数据。

网上找到了开源库apexcharts.js,瞬间被高大上的brush类型图所吸引,引入到我在开发的程序中(网上demo图如下):

图片说明

但是出现了下面柱状图数据刷新正常,而上面折线图无法刷新的问题,如下图所示,详细问题描述和代码也在下方,谢谢各位。

图片说明

我根据示例代码和官方网站上的doc进行了修改,并移植到开发的程序中。大致原理是:打开网页——前端按10秒钟轮询方式通过ajax发送请求到后端——后端python程序生成100个数据,通过json格式返回前端——前端更新数据并刷新图表

前端跟后端交互的代码如下

    var storm_data_s6a = "";
    var strom_time_s6a = "";
    $(document).ready(function(){
       setInterval(function(){$.ajax({ 
            type:"POST", 
            url:"/sigStorm/", 
            dataType:"json",      
            contentType:"application/json",               
            data:JSON.stringify({"S6a_storm":true,"Cx_storm":true,"Rejcall":true}), 
            success:function(res){ 
                storm_data_s6a = res.S6a_storm;
                storm_time_s6a = res.storm_time;
                //alert(storm_data_s6a[15]);
                stormFigure()
            }
     })

       },100000);
      });

为了实现图表实时刷新的目的,防止重复新建插入图表,我在处理图表呈现时采用了“清空元素内容”,再“重新创建图表”的办法,代码如下:

function stormFigure()
{
    var time1 = new Date(storm_time_s6a).getTime()
    var time2 = time1 - 1200000
    var time3 = time1 - 5940000
    var data1 = generateDayWiseTimeSeries(new Date(time3).getTime(), 100, {
      min: 30,
      max: 90
    });
    var options1 = {
      chart: {
        id: "chart2",
        type: "area",
        height: 230,
        foreColor: "#ccc",
        toolbar: {
          autoSelected: "pan",
          show: false
        }
      },
      colors: ["#00BAEC"],
      stroke: {
        width: 3
      },
      grid: {
        borderColor: "#555",
        yaxis: {
          lines: {
            show: false
          }
        }
      },
      dataLabels: {
        enabled: true
      },
      fill: {
        gradient: {
          enabled: true,
          opacityFrom: 0.55,
          opacityTo: 0
        }
      },
      markers: {
        size: 5,
        colors: ["#000524"],
        strokeColor: "#00BAEC",
        strokeWidth: 3
      },
      series: [
        {
          name: "S6a_flow",
          data: data1
        }
      ],
      tooltip: {
        x:{
          show: true,
          format: 'HH:mm'
        },
        theme: "dark"
      },
      xaxis: {
        type: "datetime",
      },
      yaxis: {
        tickAmount: 10,
        min: 0,
        max: 250,
      }
    };

    $("#chart-area").empty();


    var chart1 = new ApexCharts(document.querySelector("#chart-area"), options1);

        chart1.render();



    //chart1.updateSeries([{ data: data1 }]);



    //chart1.updateOptions(null,false,false,false);



    var options2 = {
      chart: {
        id: "chart1",
        height: 130,
        type: "bar",
        foreColor: "#ccc",
        brush: {
          target: "chart2",
          enabled: true
        },
        selection: {
          fill: {
            color: "#fff",
            opacity: 0.4
          },
          xaxis: {
            min: time2,
            max: time1
          }
        }
      },
      colors: ["#FF0080"],
      series: [
        {
          name: "S6a_flow",
          data: data1
        }
      ],
      stroke: {
        width: 2
      },
      grid: {
        borderColor: "#444"
      },
      markers: {
        size: 0
      },
      xaxis: {
        type: "datetime",
        tooltip: {
          enabled: false
        }
      },
      yaxis: {
        tickAmount: 2,
        min: 0,
        max: 200
      }
    };

    $("#chart-bar").empty();

    var chart2 = new ApexCharts(document.querySelector("#chart-bar"), options2);

    chart2.render();


  }

但是在程序运行后,就出现了上面的折线图不能刷新的情况(重新打开网页可以)。下面的柱状图刷新没有问题。

可以确认的是,数据是没有问题的,我把chart2 options2中的brush.enable置为false后,折线图也可以实时刷新。但是我翻遍了官网,也未能得到brush设置的有效指导。

此问题已困扰我几天,求教各位大神和曾经使用过ApexCharts工具的大神给予指导,不胜感激~

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
web前端动态图表无法刷新数据,请教问题在哪?

# Apexcharts.js中的brush类型图表无法刷新数据 求教各路大神,本人最近在做一个前端开发项目,需要用一张图来展现100个数据,这100个数据是从通过ajax请求从后端接收的,每10秒轮询一次,更新100个数据。 网上找到了开源库apexcharts.js,瞬间被高大上的brush类型图所吸引,引入到我在开发的程序中(网上demo图如下): ![图片说明](https://img-ask.csdn.net/upload/201907/06/1562392234_131426.jpg) 但是出现了下面柱状图数据刷新正常,而上面折线图无法刷新的问题,如下图所示,详细问题描述和代码也在下方,谢谢各位。 ![图片说明](https://img-ask.csdn.net/upload/201907/06/1562393740_668680.png) 我根据示例代码和官方网站上的doc进行了修改,并移植到开发的程序中。大致原理是:打开网页——前端按10秒钟轮询方式通过ajax发送请求到后端——后端python程序生成100个数据,通过json格式返回前端——前端更新数据并刷新图表 前端跟后端交互的代码如下 ``` var storm_data_s6a = ""; var strom_time_s6a = ""; $(document).ready(function(){ setInterval(function(){$.ajax({ type:"POST", url:"/sigStorm/", dataType:"json", contentType:"application/json", data:JSON.stringify({"S6a_storm":true,"Cx_storm":true,"Rejcall":true}), success:function(res){ storm_data_s6a = res.S6a_storm; storm_time_s6a = res.storm_time; //alert(storm_data_s6a[15]); stormFigure() } }) },100000); }); ``` 为了实现图表实时刷新的目的,防止重复新建插入图表,我在处理图表呈现时采用了“清空元素内容”,再“重新创建图表”的办法,代码如下: ``` function stormFigure() { var time1 = new Date(storm_time_s6a).getTime() var time2 = time1 - 1200000 var time3 = time1 - 5940000 var data1 = generateDayWiseTimeSeries(new Date(time3).getTime(), 100, { min: 30, max: 90 }); var options1 = { chart: { id: "chart2", type: "area", height: 230, foreColor: "#ccc", toolbar: { autoSelected: "pan", show: false } }, colors: ["#00BAEC"], stroke: { width: 3 }, grid: { borderColor: "#555", yaxis: { lines: { show: false } } }, dataLabels: { enabled: true }, fill: { gradient: { enabled: true, opacityFrom: 0.55, opacityTo: 0 } }, markers: { size: 5, colors: ["#000524"], strokeColor: "#00BAEC", strokeWidth: 3 }, series: [ { name: "S6a_flow", data: data1 } ], tooltip: { x:{ show: true, format: 'HH:mm' }, theme: "dark" }, xaxis: { type: "datetime", }, yaxis: { tickAmount: 10, min: 0, max: 250, } }; $("#chart-area").empty(); var chart1 = new ApexCharts(document.querySelector("#chart-area"), options1); chart1.render(); //chart1.updateSeries([{ data: data1 }]); //chart1.updateOptions(null,false,false,false); var options2 = { chart: { id: "chart1", height: 130, type: "bar", foreColor: "#ccc", brush: { target: "chart2", enabled: true }, selection: { fill: { color: "#fff", opacity: 0.4 }, xaxis: { min: time2, max: time1 } } }, colors: ["#FF0080"], series: [ { name: "S6a_flow", data: data1 } ], stroke: { width: 2 }, grid: { borderColor: "#444" }, markers: { size: 0 }, xaxis: { type: "datetime", tooltip: { enabled: false } }, yaxis: { tickAmount: 2, min: 0, max: 200 } }; $("#chart-bar").empty(); var chart2 = new ApexCharts(document.querySelector("#chart-bar"), options2); chart2.render(); } ``` 但是在程序运行后,就出现了上面的折线图不能刷新的情况(重新打开网页可以)。下面的柱状图刷新没有问题。 可以确认的是,数据是没有问题的,我把chart2 options2中的brush.enable置为false后,折线图也可以实时刷新。但是我翻遍了官网,也未能得到brush设置的有效指导。 此问题已困扰我几天,求教各位大神和曾经使用过ApexCharts工具的大神给予指导,不胜感激~

未处理InvalidaOperationException

Object is Current in use elsewhere. 排错提示:如果在使用GetHdc方法后使用Graphic对象,请调用ReleaseHdc方法。获取此异常的常规帮助。 自己写了一个PictureButton的控件,在e.Graphics.DrawImage出的异常 protected override void OnPaint(PaintEventArgs e) { if (image != null) // && (this.Enabled) { lock(image) { e.Graphics.DrawImage(image, this.ClientRectangle, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imgAttr); } } if (string.IsNullOrEmpty(this.Text)) { if (string.IsNullOrEmpty(this.txtBottom)) { e.Graphics.DrawString(txtTop, this.Font, brush, this.rectTxt, strFmtTxt); } else { e.Graphics.DrawString(txtTop, this.Font, brush, this.rectTop, strFmtTop); e.Graphics.DrawString(txtBottom, this.Font, brush, this.rectBottom, strFmtBottom); } } else { e.Graphics.DrawString(this.Text, this.Font, brush, this.rectTxt, strFmtTxt); } base.OnPaint(e); } 已尝试两种方法 均无效:1.跨线程访问的问题,加了InvokeRequre;2.加了GetHdc ReleaseHdc; VS2005 C# 求助,谢谢!!!

SysInfoStrings的用法

protected override void OnPaint(PaintEventArgs pea) { Graphics grfx = pea.Graphics; Brush brush = new SolidBrush(ForeColor); int iCount = SysInfoStrings.Count; string[] astrLabels = SysInfoStrings.Labels; string[] astrValues = SysInfoStrings.Values; for (int i = 0; i < iCount; i++) { grfx.DrawString(astrLabels[i], Font, brush, 0, i * cySpace); grfx.DrawString(astrValues[i], Font, brush, cxCol, i * cySpace); }

不知道是不是笛卡尔心形函数C语言的编程,,

private void Form4_Load(object sender, EventArgs e) { this.BackColor = Color.Black; this.Size = new Size(400, 400); Panel panel = new Panel(); panel.Size = new Size(350, 350); panel.Paint += new PaintEventHandler(panel_Paint); panel.Location = new Point((this.ClientRectangle.Width - panel.Width) / 2, (this.ClientRectangle.Height - panel.Height) / 2); this.Controls.Add(panel); } void panel_Paint(object sender, PaintEventArgs e) { e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; double x, y, r; int w = e.ClipRectangle.Width; int h = e.ClipRectangle.Height; for (int i = 0; i <= 90; i++) { for (int j = 0; j <= 90; j++) { //转换为直角坐标系,设置偏移量,使图像居中 r = Math.PI / 45 * i * (1 - Math.Sin(Math.PI / 45 * j)) * 19; x = r * Math.Cos(Math.PI / 45 * j) * Math.Sin(Math.PI / 45 * i) + w / 2; y = -r * Math.Sin(Math.PI / 45 * j) + h / 4; using (Brush brush = new SolidBrush(Color.Red)) { e.Graphics.FillEllipse(brush, (float)x, (float)y, 2f, 2f); e.Graphics.FillEllipse(brush, (float)x, (float)y, 1f, 1f); } } } }

c# GDI绘图 winform程序

![图片说明](https://img-ask.csdn.net/upload/201510/12/1444648505_807874.png) 如图 分为两个区域 除上述蓝色背景区域外,下面的黑色整个部分我想换个颜色,以下是代码,请问最后的零的位置如何修改 (也就是修改下面的部分的高度) private void DrawTrainGraph(Graphics g) { //先绘制一个矩形区,作为列车区的底图 using (Brush brush = new SolidBrush(TraGraphBKColor)) { g.FillRectangle(brush, -orgView.X / ScaleX, -orgView.Y / ScaleX, Width / ScaleX, 0 / ScaleY); }

Silverlight中依赖属性设置出错

环境:Visual Studio 2010 Silverlight应用程序 实现类似微软人立方的人物关系图效果 但是出现如下错误: **未在类型“Button”中找到属性“CircleButtonWidth1” 。** 求大神给看一下,这个怎么改才可以?(附MainPage.xaml和MainPage.xaml.cs如下:) 首先是MailPage.xaml: **<UserControl x:Class="SilverlightApplication4.MainPage" 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:SilverlightApplication4" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> <UserControl.Resources> <Style x:Key="CircleButton" TargetType="Button"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <Grid Height="auto" HorizontalAlignment="Center" VerticalAlignment="Center" Width="auto" IsHitTestVisible="True" Background="{x:Null}"> <Ellipse Margin="0,0,0,0" Stroke="{x:Null}" HorizontalAlignment="Center" VerticalAlignment="Center" Width="{TemplateBinding CircleButtonWidth1}" Height="{TemplateBinding CircleButtonHeight1}" IsHitTestVisible="False" x:Name="ellipse1" Fill="{TemplateBinding Ellipse1Fill}"> </Ellipse> <Grid Margin="0,0,0,0" HorizontalAlignment="Center" Width="1024" Height="1024" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5" x:Name="grid" Opacity="1" Background="{x:Null}" IsHitTestVisible="True"> <Ellipse Fill="{TemplateBinding Ellipse2Fill}" Stroke="{TemplateBinding Ellipse2Stroke}" Margin="0,0,0,0" Width="{TemplateBinding CircleButtonWidth2}" Height="{TemplateBinding CircleButtonHeight2}" x:Name="ellipse2" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Center" VerticalAlignment="Center"> </Ellipse> <Ellipse Margin="2,2,2,2" Fill="{TemplateBinding Ellipse3Fill}" Width="{TemplateBinding CircleButtonWidth3}" Height="{TemplateBinding CircleButtonHeight3}" x:Name="ellipse3" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Center" VerticalAlignment="Center"> </Ellipse> <TextBlock Margin="0,0,0,0" FontFamily="Microsoft YaHei" FontSize="{TemplateBinding FontSize}" Foreground="#FFFFFFFF" HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="textBlock" Text="{TemplateBinding Content}" RenderTransformOrigin="0.5,0.5" IsHitTestVisible="False"> </TextBlock> </Grid> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </UserControl.Resources> <Grid x:Name="LayoutRoot" Background="White"> <Button Style="{StaticResource CircleButton}" Name="myButton" Content="Click me!!!" Click="myButton_Click_1" > </Button> </Grid> </UserControl>** 下面是MainPage.xaml.cs文件: using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using System.Reflection; namespace SilverlightApplication4 { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } private void myButton_Click(object sender, RoutedEventArgs e) { } public partial class CircleButton : UserControl { static CircleButton() { Ellipse1FillProperty = DependencyProperty.Register("myEllipse1Fill", typeof(Brush), typeof(CircleButton), new PropertyMetadata("默认属性值", new PropertyChangedCallback(CircleButton.OnEllipse1FillPropertyChanged)));//Ellipse1FillProperty.OnEllipse1FillPropertyChanged Ellipse2FillProperty = DependencyProperty.Register("myEllipse2Fill", typeof(Brush), typeof(CircleButton), new PropertyMetadata("默认属性值", new PropertyChangedCallback(CircleButton.OnEllipse2FillPropertyChanged))); Ellipse3FillProperty = DependencyProperty.Register("myEllipse3Fill", typeof(Brush), typeof(CircleButton), new PropertyMetadata("默认属性值", new PropertyChangedCallback(CircleButton.OnEllipse3FillPropertyChanged))); CircleButtonWidth1Property = DependencyProperty.Register("myCircleButtonWidth1", typeof(Double), typeof(CircleButton), new PropertyMetadata("默认属性值", new PropertyChangedCallback(CircleButton.OnCircleButtonWidth1PropertyChanged))); CircleButtonWidth2Property = DependencyProperty.Register("myCircleButtonWidth2", typeof(Double), typeof(CircleButton), new PropertyMetadata("默认属性值", new PropertyChangedCallback(CircleButton.OnCircleButtonWidth2PropertyChanged))); CircleButtonWidth3Property = DependencyProperty.Register("myCircleButtonWidth3", typeof(Double), typeof(CircleButton), new PropertyMetadata("默认属性值", new PropertyChangedCallback(CircleButton.OnCircleButtonWidth3PropertyChanged))); } private static void OnEllipse1FillPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { (d as CircleButton).OnEllipse1FillPropertyChanged(e); } private static void OnEllipse2FillPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { (d as CircleButton).OnEllipse2FillPropertyChanged(e); } private static void OnEllipse3FillPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { (d as CircleButton).OnEllipse3FillPropertyChanged(e); } private static void OnCircleButtonWidth1PropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { (d as CircleButton).OnCircleButtonWidth1PropertyChanged(e); } private static void OnCircleButtonWidth2PropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { (d as CircleButton).OnCircleButtonWidth2PropertyChanged(e); } private static void OnCircleButtonWidth3PropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { (d as CircleButton).OnCircleButtonWidth3PropertyChanged(e); } public event DependencyPropertyChangedEventHandler Ellipse1FillPropertyChanged; public event DependencyPropertyChangedEventHandler Ellipse2FillPropertyChanged; public event DependencyPropertyChangedEventHandler Ellipse3FillPropertyChanged; public event DependencyPropertyChangedEventHandler CircleButtonWidth1PropertyChanged; public event DependencyPropertyChangedEventHandler CircleButtonWidth2PropertyChanged; public event DependencyPropertyChangedEventHandler CircleButtonWidth3PropertyChanged; void OnEllipse1FillPropertyChanged(DependencyPropertyChangedEventArgs e) { try { // Ellipse BgTextBlock = this.GetTemplateChild("ButtonCaption") as Ellipse; //BgTextBlock.Fill = e.NewValue as Brush; if (Ellipse1FillPropertyChanged != null) { Ellipse1FillPropertyChanged(null, e); } } catch (Exception ex) { string ks = ex.ToString(); } } void OnEllipse2FillPropertyChanged(DependencyPropertyChangedEventArgs e) { try { // Ellipse BgTextBlock = this.GetTemplateChild("ButtonCaption") as Ellipse; //BgTextBlock.Fill = e.NewValue as Brush; if (Ellipse2FillPropertyChanged != null) { Ellipse2FillPropertyChanged(null, e); } } catch (Exception ex) { string ks = ex.ToString(); } } void OnEllipse3FillPropertyChanged(DependencyPropertyChangedEventArgs e) { try { // Ellipse BgTextBlock = this.GetTemplateChild("ButtonCaption") as Ellipse; //BgTextBlock.Fill = e.NewValue as Brush; if (Ellipse3FillPropertyChanged != null) { Ellipse3FillPropertyChanged(null, e); } } catch (Exception ex) { string ks = ex.ToString(); } } void OnCircleButtonWidth1PropertyChanged(DependencyPropertyChangedEventArgs e) { try { // Ellipse BgTextBlock = this.GetTemplateChild("ButtonCaption") as Ellipse; //BgTextBlock.Fill = e.NewValue as Brush; if (CircleButtonWidth1PropertyChanged != null) { CircleButtonWidth1PropertyChanged(null, e); } } catch (Exception ex) { string ks = ex.ToString(); } } void OnCircleButtonWidth2PropertyChanged(DependencyPropertyChangedEventArgs e) { try { // Ellipse BgTextBlock = this.GetTemplateChild("ButtonCaption") as Ellipse; //BgTextBlock.Fill = e.NewValue as Brush; if (CircleButtonWidth2PropertyChanged != null) { CircleButtonWidth2PropertyChanged(null, e); } } catch (Exception ex) { string ks = ex.ToString(); } } void OnCircleButtonWidth3PropertyChanged(DependencyPropertyChangedEventArgs e) { try { // Ellipse BgTextBlock = this.GetTemplateChild("ButtonCaption") as Ellipse; //BgTextBlock.Fill = e.NewValue as Brush; if (CircleButtonWidth3PropertyChanged != null) { CircleButtonWidth3PropertyChanged(null, e); } } catch (Exception ex) { string ks = ex.ToString(); } } //有些时候,我们希望在模板生效的时候就对某些模板成员进行操作,如绑定事件, //调整属性等,就需要一个事件OnApplyTemplate,我们只能通过override父类的OnApplyTemplate来响应模板生效 public override void OnApplyTemplate() { base.OnApplyTemplate(); try { var tb = GetTemplateChild("ButtonCaption") as Ellipse; //(GetTemplateChild("ButtonCaption") as Ellipse).Fill= this.Ellipse1Fill; tb.Fill= this.Ellipse1Fill; var tb2 = GetTemplateChild("ButtonCaption") as Ellipse; (GetTemplateChild("ButtonCaption") as Ellipse).Fill = this.Ellipse2Fill; var tb3 = GetTemplateChild("ButtonCaption") as Ellipse; (GetTemplateChild("ButtonCaption") as Ellipse).Fill = this.Ellipse3Fill; var we1 = GetTemplateChild("ButtonCaption") as Ellipse; we1.Width = this.CircleButtonWidth1; var we2 = GetTemplateChild("ButtonCaption") as Ellipse; we1.Width = this.CircleButtonWidth2; var we3 = GetTemplateChild("ButtonCaption") as Ellipse; we1.Width = this.CircleButtonWidth3; var w1 = GetTemplateChild("ButtonCaption") as Ellipse; we1.Width = this.CircleButtonHeight1; var w2 = GetTemplateChild("ButtonCaption") as Ellipse; we1.Width = this.CircleButtonHeight2; var w3 = GetTemplateChild("ButtonCaption") as Ellipse; we1.Width = this.CircleButtonHeight3; } catch (Exception ex) { string ke = ex.ToString(); } } public Brush Ellipse1Fill { get { return (Brush)base.GetValue(Ellipse1FillProperty); } set { base.SetValue(Ellipse1FillProperty, value); } } public Brush Ellipse2Fill { get { return (Brush)base.GetValue(Ellipse2FillProperty); } set { base.SetValue(Ellipse2FillProperty, value); } } public Brush Ellipse3Fill { get { return (Brush)base.GetValue(Ellipse3FillProperty); } set { base.SetValue(Ellipse3FillProperty, value); } } public double CircleButtonWidth1 { get { return (double)base.GetValue(CircleButtonWidth1Property); } set { base.SetValue(CircleButtonWidth1Property, value); } } public double CircleButtonWidth2 { get { return (double)base.GetValue(CircleButtonWidth2Property); } set { base.SetValue(CircleButtonWidth2Property, value); } } public double CircleButtonWidth3 { get { return (double)base.GetValue(CircleButtonWidth3Property); } set { base.SetValue(CircleButtonWidth3Property, value); } } public double CircleButtonHeight1 { get { return (double)base.GetValue(CircleButtonHeight1Property); } set { base.SetValue(CircleButtonHeight1Property, value); } } public double CircleButtonHeight2 { get { return (double)base.GetValue(CircleButtonHeight2Property); } set { base.SetValue(CircleButtonHeight2Property, value); } } public double CircleButtonHeight3 { get { return (double)base.GetValue(CircleButtonHeight3Property); } set { base.SetValue(CircleButtonHeight3Property, value); } } ///<summary> /// /// Register property. ///</summary> public static readonly DependencyProperty Ellipse1FillProperty = DependencyProperty.Register("Ellipse1Fill", typeof(Brush), typeof(CircleButton), null); public static readonly DependencyProperty Ellipse2FillProperty = DependencyProperty.Register("Ellipse2Fill", typeof(Brush), typeof(CircleButton), null); public static readonly DependencyProperty Ellipse3FillProperty = DependencyProperty.Register("Ellipse3Fill", typeof(Brush), typeof(CircleButton), null); public static readonly DependencyProperty CircleButtonWidth1Property = DependencyProperty.Register("CircleButtonWidth1", typeof(double), typeof(CircleButton), null); public static readonly DependencyProperty CircleButtonWidth2Property = DependencyProperty.Register("CircleButtonWidth2", typeof(double), typeof(CircleButton), null); public static readonly DependencyProperty CircleButtonWidth3Property = DependencyProperty.Register("CircleButtonWidth3", typeof(double), typeof(CircleButton), null); public static readonly DependencyProperty CircleButtonHeight1Property = DependencyProperty.Register("CircleButtonHeight1", typeof(double), typeof(CircleButton), null); public static readonly DependencyProperty CircleButtonHeight2Property = DependencyProperty.Register("CircleButtonHeight2", typeof(double), typeof(CircleButton), null); public static readonly DependencyProperty CircleButtonHeight3Property = DependencyProperty.Register("CircleButtonHeight3", typeof(double), typeof(CircleButton), null); } private void myButton_Click_1(object sender, RoutedEventArgs e) { } } }

vs的opencv用ellipse函数画出来的椭圆是实心的

![图片说明](https://img-ask.csdn.net/upload/201606/10/1465548016_525925.png) 代码是 CBrush *brush = CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH)); pDC->SelectObject(brush); memDC.Ellipse(ell.p1.x, ell.p1.y, ell.p2.x, ell.p2.y); 我也加过 pDC->SelectObject(brush); 没用

用qt写的五子棋界面,请问为什么第一行和第一列 不能落棋子? 大佬 bai'tuo

# ![图片说明](https://img-ask.csdn.net/upload/201903/10/1552210863_538638.jpg) ChessWidget::ChessWidget(QWidget *parent) : QWidget(parent) { ui.setupUi(this); this->setFixedSize(800, 660); this->setAutoFillBackground(true); QPalette palette; palette.setColor(QPalette::Window, QColor("#B1723C")); this->setPalette(palette); for (int i = 0; i < 15; ++i) { for (int j = 0; j < 15; ++j) { chess[i][j] = empyt; } } } ChessWidget::~ChessWidget() { } void ChessWidget::paintEvent(QPaintEvent *) { QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing, true);//反走样 QPen pen; pen.setColor(QColor("#8D5822")); pen.setWidth(7); painter.setPen(pen); QBrush brush; brush.setColor(QColor("#EEC085")); brush.setStyle(Qt::SolidPattern); painter.setBrush(brush); painter.drawRect(10, 10, 620, 620); QPainter painters(this); painters.setRenderHint(QPainter::Antialiasing, true); int i, j; for (i = 0; i <= 15; ++i) { painters.drawLine(20, 20 + i * 40, 620, 20 + i * 40); painters.drawLine(20 + i * 40, 20, 20 + i * 40, 620); } brush.setStyle(Qt::SolidPattern); for (i = 0; i < 15; ++i) { for (j = 0; j < 15; ++j) { if (chess[i][j] == BLACK) { brush.setColor(Qt::black); painters.setBrush(brush); painters.drawEllipse(QPoint((i) * 40 + 20, (j ) * 40 + 20), 20, 20); } else if (chess[i][j] == WHITE) { brush.setColor(Qt::white); painters.setBrush(brush); painters.drawEllipse(QPoint((i) * 40 + 20, (j) * 40 + 20), 20, 20); } } } } void ChessWidget::mousePressEvent(QMouseEvent *e) { int x, y; if (e->x() >= 20 || e->x() <= 620 || e->y() >= 20 || e->y() <= 620) { x = (e->x()-20)/40; y = (e->y()-20)/40; if (chess[x][y]==empyt) { chess[x][y] = player++ % 2 + 1; } } update(); } ``` ``` ``` ``` ``` ```

Delphi 在图片上画矩形

在image加载的图片上画矩形,会将图片覆盖,代码如下: unit Unit3; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls; type TForm3 = class(TForm) img1: TImage; dlgOpen1: TOpenDialog; procedure FormCreate(Sender: TObject); procedure img1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure img1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure img1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); private { Private declarations } public { Public declarations } end; var Form3: TForm3; implementation {$R *.dfm} var cx, cy: Integer; md: Boolean; procedure TForm3.FormCreate(Sender: TObject); var openPath: string; begin dlgOpen1.Title := '打开图片'; dlgOpen1.Filter := '全部 (*.jpg;*.jpeg;*.bmp;)'; if dlgOpen1.Execute then begin openPath := dlgOpen1.FileName; img1.Picture.LoadFromFile(openPath); img1.AutoSize := False; img1.Stretch := True; end; Form3.DoubleBuffered := true; md := False; end; procedure TForm3.img1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin md := True; cx := x; cy := y; end; procedure TForm3.img1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if md then begin // img1.Canvas.Brush.Color := clWhite; //画笔颜色设置为白色 // img1.Canvas.Brush.Style := bsclear; //img1.Canvas.FillRect(img1.ClientRect); //把画布背景填充为白色 img1.Canvas.Pen.Color := clRed; img1.Canvas.Rectangle(cx, cy, X, Y); end; end; procedure TForm3.img1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin md := False; end; end.

WPF中Graphics g = this.CreateGraphics();报错

``` using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Timers; using System.Windows.Threading; using System.Drawing; using System.Drawing.Imaging; namespace _2_3 { /// <summary> /// MainWindow.xaml 的交互逻辑 /// </summary> public partial class MainWindow : Window { private DispatcherTimer dispatcherTimer = null; int hh, mm, ss; public MainWindow() { InitializeComponent(); dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += new EventHandler(OnTimedEvent); dispatcherTimer.Interval = new TimeSpan(0, 0, 1); dispatcherTimer.Start(); } private void OnTimedEvent(object sender, EventArgs e) { timelabel.Content = DateTime.Now.ToLongTimeString(); hh = DateTime.Now.Hour; mm = DateTime.Now.Minute; ss = DateTime.Now.Second; MyDrawClock(hh, mm, ss); } private void MyDrawClock(int h, int m, int s) { Graphics g = this.CreateGraphics(); g.Clear(System.Drawing.Color.White); Font font = new Font("黑体", 20, System.Drawing.FontStyle.Bold); System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Black,1); SolidBrush Brush = new SolidBrush(System.Drawing.Color.Black); g.DrawString("12", font, Brush, 40, 60); g.DrawString("9", font, Brush, 20, 45); g.DrawString("3", font, Brush, 60, 45); g.DrawString("6", font, Brush, 40, 30); System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Black,1); System.Drawing.Point centerPoint = new System.Drawing.Point();//表的中心点 //计算出秒针,时针,分针的另外一个点 System.Drawing.Point secPoint = new System.Drawing.Point((int)(centerPoint.X + (Math.Sin(s * Math.PI / 30) * 140)), (int)(centerPoint.Y - (Math.Cos(s * Math.PI / 30) * 140))); System.Drawing.Point minPoint = new System.Drawing.Point((int)(centerPoint.X + (Math.Sin(m * Math.PI / 30) * 130)), (int)(centerPoint.Y - (Math.Cos(m * Math.PI / 30) * 130))); System.Drawing.Point hourPoint = new System.Drawing.Point((int)(centerPoint.X + (Math.Sin(h * Math.PI / 6) * 120) - m * Math.PI / 360), (int)(centerPoint.Y - (Math.Cos(h * Math.PI / 6) * 120) - m * Math.PI / 360)); //以不同颜色和宽度绘制表针 myPen = new System.Drawing.Pen(System.Drawing.Color.Red,1); g.DrawLine(myPen, centerPoint, secPoint); myPen = new System.Drawing.Pen(System.Drawing.Color.Green,2); g.DrawLine(myPen, centerPoint, minPoint); myPen = new System.Drawing.Pen(System.Drawing.Color.Orange, 1); g.DrawLine(myPen, centerPoint, hourPoint); } } } ``` 报错信息:错误 1 “_2_3.MainWindow”不包含“CreateGraphics”的定义,并且找不到可接受类型为“_2_3.MainWindow”的第一个参数的扩展方法“CreateGraphics”(是否缺少 using 指令或程序集引用 折腾了半天也没搞好,要崩溃了

C# DrawString往一张图片写入文字的时候,出现了“参数无效”的错误

测试代码如下,第一次运行没有问题,第二次就会提示报错,重启iis后又是这个情况。 ``` public void ProcessRequest(HttpContext context) { Bitmap nbitmap = new Bitmap(1000, 1000); Graphics g = Graphics.FromImage(nbitmap); Font font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Italic); Brush brush = Brushes.Black; g.DrawString("测试字符串", font, brush, 10, 10);/////运行到这句报参数无效 g.Dispose(); font.Dispose(); brush.Dispose(); nbitmap.Save(context.Server.MapPath("~/upload/cert" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".jpg")); nbitmap.Dispose(); } ``` ![](http://www.w3dev.cn/imgblog/20130828/1413334375.jpg)

golang中使用walk展示二维码图片

![图片说明](https://img-ask.csdn.net/upload/201912/17/1576568318_853567.png) **我的需求是点击生成二维码 在下面展示二维码。 **部分代码如下,初学golang 请教各位大佬** ``` type MyMainWindow struct { *walk.MainWindow hcName *walk.Label userIdName *walk.Label startTime *walk.DateEdit endTime *walk.DateEdit hc, userId *walk.LineEdit imageView *walk.ImageView imageComposite *walk.Composite qrCount int } func (mw *MyMainWindow) ShowQRcode() { if mw.imageComposite != nil { mw.imageComposite.Dispose() } mw.getQRcode() widgets := []Widget{} for i:=1;i<=mw.qrCount;i++ { bitmap, err := walk.NewBitmapFromFile("qrcode/qr_"+strconv.Itoa(i)+".jpg") log.Println("qrcode/qr_"+strconv.Itoa(i)+".jpg") if err != nil { walk.MsgBox(mw, mw.Title(), err.Error(), walk.MsgBoxIconError) break } widget := ImageView{ Image: bitmap, Mode: ImageViewModeZoom, } widgets = append(widgets, widget) } imageComposite := Composite{ AssignTo: &mw.imageComposite, Layout: HBox{}, Children: widgets, } if err := imageComposite.Create(NewBuilder(mw)); err != nil { log.Println(err) } } func openWindow(){ mw := &MyMainWindow{} _, _ = MainWindow{ Title: "梅清打印量上报", MinSize: Size{600, 400}, Size:Size{1200,800}, Layout: VBox{MarginsZero: true}, Children: []Widget{ Composite{ Layout:HBox{}, Children: []Widget{ Label{AssignTo: &mw.hcName,Text: "医院编号"}, LineEdit{AssignTo: &mw.hc,}, Label{AssignTo: &mw.userIdName,Text: "工程师编号"}, LineEdit{AssignTo: &mw.userId,}, DateEdit{AssignTo:&mw.startTime, Format:"yyyy-MM-dd",}, DateEdit{AssignTo:&mw.endTime, Format:"yyyy-MM-dd",}, PushButton{ Text: "生成二维码", OnClicked: func(){ if len(mw.hc.Text()) == 0 { walk.MsgBox(mw, mw.Title(), "请输入医院编号", walk.MsgBoxIconError) log.Println("请输入医院编号") return } if len(mw.userId.Text()) == 0 { walk.MsgBox(mw, mw.Title(), "请输入工程师编号", walk.MsgBoxIconError) log.Println("请输入工程师编号") return } mw.ShowQRcode() }, }, }, }, Composite{ AssignTo:&mw.imageComposite, Layout:HBox{}, }, }, }.Run() } ``` 这是报错信息 ![图片说明](https://img-ask.csdn.net/upload/201912/24/1577177949_302636.png)

新手请教Graphics画圆重绘、重置问题,各位大哥、大姐、大神帮帮忙~!谢谢~!!!

![图片说明](https://img-ask.csdn.net/upload/201612/18/1482072443_744997.jpg) 如图 当接受到数据包时,请看以下代码: int bag = U16(message, 17, 18);//包长 U16(message, message.Length - 4, message.Length - 3); for (int i = 0; i < bag - 4; i += 8) { int domain = U16(message, i + 19, i + 20);//设备ID uint xAxis = U24(message, i + 21, i + 22, i + 23);//设备X轴坐标 uint yAxis = U24(message, i + 24, i + 25, i + 26);//设备Y轴坐标 x = xAxis; y = yAxis; mayX = x - 5; mayY = y - 5; this.Invoke((EventHandler)(delegate { lstRecvData.Items.Add("收到的数据:" + domain + " " + "X: " + xAxis + " " + "Y: " + yAxis); })); } } graphics = ptbMap.CreateGraphics(); Brush brush = new SolidBrush(Color.Blue); graphics.FillEllipse(brush, mayX, mayY, 10, 10); 会自动生成一个圆 在图片中,我要如何 才能 再接收新的数据包时 可以让先前所生成的圆消失,产生新的圆,或者是删除之前所生成的圆 然后产生新的圆~!?

windows程序设计(第五版)第22章的drum.c中的问题?

windows程序设计(第五版)第22章的drum.c中的这段,没弄明白作者的想法, “ if (x >= 0 && x < 32 && y >= 0 && y < NUM_PERC) { if (message == WM_LBUTTONDOWN) drum.dwSeqPerc[y] ^= (1 << x) ;//这里不明白,作者为什么这样写 else drum.dwSeqPian[y] ^= (1 << x) ;//这里不明白,作者为什么这样写 DrawRectangle (hdc, x, y, drum.dwSeqPerc, drum.dwSeqPian) ; bNeedSave = TRUE ; }” 在这里是这样的 “void DrawRectangle (HDC hdc, int x, int y, DWORD * dwSeqPerc, DWORD * dwSeqPian) { int iBrush ; if (dwSeqPerc [y] & dwSeqPian [y] & (1L << x));//在这里是这样响应的 iBrush = BLACK_BRUSH ; else if (dwSeqPerc [y] & (1L << x)) //在这里是这样响应的 iBrush = DKGRAY_BRUSH ; else if (dwSeqPian [y] & (1L << x)) //在这里是这样响应的 iBrush = LTGRAY_BRUSH ; else iBrush = WHITE_BRUSH ; SelectObject (hdc, GetStockObject (iBrush)) ; Rectangle (hdc, (x + 40) * cxChar , (2 * y + 4) * cyChar / 4, (x + 41) * cxChar + 1, (2 * y + 6) * cyChar / 4 + 1) ; }” 作者的思路是什么呢?请教大神来给解释一下啊!

关于DC FillRect的问题

代码如下: CRect rc; CWnd *pWnd = GetDlgItem(IDC_STATIC); pWnd->GetClientRect(&rc);//rc为控件的大小。 CDC *pDC = GetDlgItem(IDC_STATIC)->GetDC();; HDC hDC =pDC ->GetSafeHdc(); CBrush brush; brush.CreateSolidBrush(RGB(255, 123, 123)); pDC->FillRect(rc,&brush); 运行结果为:在控件中没有显示。请问是什么问题啊。菜鸟新手求教啊

简单的一个画图程序,一画图就报错

namespace WindowsFormsApplication1 { public partial class Form1 : Form { Bitmap bmpOrigin; Pen pen; Brush brush; Point ptOld; Font ftString; ArrayList arrCurvePoint = new ArrayList();//画曲线 ArrayList arrPolygonPoint = new ArrayList();//画多边形 public Form1() { InitializeComponent(); } private void Form1_Load_1(object sender, EventArgs e) { } private void picBox_MouseDown(object sender, MouseEventArgs e) { pen = new Pen(pnlForeColor.BackColor, (float)udLineSize.Value); switch (cmbLineShape.SelectedIndex)//处理画笔 { case 0: pen.DashStyle = DashStyle.Solid; break;//实线 case 1: pen.DashStyle = DashStyle.Dash; break;//虚线 case 2: pen.DashStyle = DashStyle.Dot; break;//点线 case 3: pen.DashStyle = DashStyle.DashDot; break;//点划线 case 4: pen.DashStyle = DashStyle.DashDotDot; break;//双点划线 } switch (cmbFillDesign.SelectedIndex)//处理笔刷 { case 0: brush = null; break; case 1: brush = new SolidBrush(pnlBackColor.BackColor); break; } if (rdbCurve.Checked || rdbErase.Checked) { arrCurvePoint.Clear();//清除里面的点 arrCurvePoint.Add(e.Location);//把鼠标当前位置作为第一个点 } //多边形 if (rdbPolygon.Checked && arrPolygonPoint.Count == 0) { arrPolygonPoint.Add(e.Location); } ptOld = e.Location; } private void ControlResize(MouseEventArgs mouse)//自定义函数用来改变画幅的大小 { if (mouse.Button != MouseButtons.Left)//不是单击左键 { if (mouse.X >= picBox.Width - 4) picBox.Cursor = Cursors.VSplit; else if (mouse.Y >= picBox.Height - 4) picBox.Cursor = Cursors.HSplit; else picBox.Cursor = Cursors.Cross; } else//按了左键并移动 { if (picBox.Cursor == Cursors.VSplit && mouse.X > 20)//超出范围改变画框 { picBox.Width = mouse.X; } if (picBox.Cursor == Cursors.HSplit && mouse.Y > 20) { picBox.Height = mouse.Y; } if (picBox.Cursor != Cursors.Cross && picBox.Image != null)//这一系列操作完成了改变图片框的尺寸,并同步bmpOrigin的大小,并把picBox的图片重新画到bmpOrigin里。 { bmpOrigin = new Bitmap(picBox.Width, picBox.Height); if (picBox.Image != null) { Graphics gOrigin = Graphics.FromImage(bmpOrigin); gOrigin.DrawImage(picBox.Image, 0, 0); } picBox.Image = bmpOrigin; } } } private void picBox_MouseMove(object sender, MouseEventArgs e) { ControlResize(e); if (e.Button == MouseButtons.Left && picBox.Cursor == Cursors.Cross) { Bitmap bmpTemp = (Bitmap)bmpOrigin.Clone(); Graphics gTemp = Graphics.FromImage(bmpTemp); if (rdbLine.Checked)//画直线 { gTemp.DrawLine(pen, ptOld, e.Location); } else if (rdbRectangl.Checked)//画矩形 { float x = (ptOld.X < e.X) ? ptOld.X : e.X;//三目运算符,如果当前鼠标位置>起始点 float y = (ptOld.Y < e.Y) ? ptOld.Y : e.Y; gTemp.DrawRectangle(pen, x, y, Math.Abs(e.X - ptOld.X), Math.Abs(e.Y - ptOld.Y)); if (brush != null) gTemp.FillRectangle(brush, x, y, Math.Abs(e.X - ptOld.X), Math.Abs(e.Y - ptOld.Y)); } else if (rdbEllipse.Checked)//画椭圆 { float x = (ptOld.X < e.X) ? ptOld.X : e.X;//三目运算符,如果当前鼠标位置>起始点 float y = (ptOld.Y < e.Y) ? ptOld.Y : e.Y; gTemp.DrawEllipse(pen, x, y, Math.Abs(e.X - ptOld.X), Math.Abs(e.Y - ptOld.Y)); if (brush != null) gTemp.FillEllipse(brush, x, y, Math.Abs(e.X - ptOld.X), Math.Abs(e.Y - ptOld.Y)); } else if (rdbCurve.Checked)//画曲线 { Graphics gOrigin = Graphics.FromImage(bmpOrigin); arrCurvePoint.Add(e.Location); Point[] p = new Point[arrCurvePoint.Count]; arrCurvePoint.CopyTo(p); gOrigin.DrawCurve(pen, p); picBox.Image = bmpOrigin; } else if (rdbErase.Checked)//橡皮擦 { Graphics gOrigin = Graphics.FromImage(bmpOrigin); arrCurvePoint.Add(e.Location); Point[] p = new Point[arrCurvePoint.Count]; arrCurvePoint.CopyTo(p); gOrigin.DrawCurve(new Pen(pnlBackColor.BackColor, (float)udLineSize.Value), p); picBox.Image = bmpOrigin; } else if (rdbPolygon.Checked && arrPolygonPoint.Count > 0)//多边形(一定要结合mouseup代码结合起来看 { gTemp.DrawLine(pen, (Point)arrPolygonPoint[arrPolygonPoint.Count - 1], e.Location); } else if (rdbText.Checked)//处理文本要看三个地方:1.mouseDown事件里确定第一个点的位置 2.from_load里有 ftString实例化操作 3.就是下面的代码确定文本框的大小 { txtString.Width = e.X - ptOld.X; txtString.Height = e.Y - ptOld.Y; txtString.Focus(); } picBox.Image = bmpTemp; } } private void picBox_MouseUp(object sender, MouseEventArgs e) { if (picBox.Image != null) { Graphics gp = Graphics.FromImage(bmpOrigin); gp.DrawImage(picBox.Image, 0, 0); } //画多边形时除将第1个点外的所有点添加到arrPolygonPoin数组中 if (arrPolygonPoint.Count > 0) arrPolygonPoint.Add(e.Location); } private void picBox_MouseDoubleClick(object sender, MouseEventArgs e) { if (rdbPolygon.Checked) { Graphics gOrigin = Graphics.FromImage(bmpOrigin); Point[] p = new Point[arrPolygonPoint.Count]; arrPolygonPoint.CopyTo(p); gOrigin.DrawPolygon(pen, p); arrPolygonPoint.Clear(); if (brush != null) { gOrigin.FillPolygon(brush, p); } gOrigin.Dispose(); picBox.Image = bmpOrigin; } } private void pnlForeColor_Paint(object sender, PaintEventArgs e) { ColorDialog cd = new ColorDialog(); cd.Color = pnlForeColor.BackColor; DialogResult dr = cd.ShowDialog(); if (dr == DialogResult.OK) pnlForeColor.BackColor = cd.Color; } private void pnlBackColor_Paint(object sender, PaintEventArgs e) { ColorDialog cd = new ColorDialog(); cd.Color = pnlBackColor.BackColor; DialogResult dr = cd.ShowDialog(); if (dr == DialogResult.OK) pnlBackColor.BackColor = cd.Color; } private void picBox_MouseClick(object sender, MouseEventArgs e) { if (rdbGetColor.Checked) { if (bmpOrigin.GetPixel(e.X, e.Y).ToArgb() != 0) { if (e.Button == MouseButtons.Left) { pnlForeColor.BackColor = bmpOrigin.GetPixel(e.X, e.Y); } else { pnlBackColor.BackColor = bmpOrigin.GetPixel(e.X, e.Y); } } else { if (e.Button == MouseButtons.Left) { pnlForeColor.BackColor = picBox.BackColor; } else { pnlBackColor.BackColor = picBox.BackColor; } } } } } } ![图片说明](https://img-ask.csdn.net/upload/201701/10/1484047001_659879.png)

PHP代理jQuery部分到javascript

<div class="post-text" itemprop="text"> <p>Here is code that is done in jQuery and the aim is to change it to javascript. The original code is from here: <a href="http://benalman.com/code/projects/php-simple-proxy/examples/simple/" rel="nofollow">php proxy</a></p> <p>Here is the jQuery to change to javascript:</p> <pre><code>$(function(){ // Handle form submit. $('#params').submit(function(){ var proxy = 'ba-simple-proxy.php', url = proxy + '?' + $('#params').serialize(); // Make GET request. $.get( url, function(data){ $('#response') .html( '&lt;pre class="brush:xml"/&gt;' ) .find( 'pre' ) // To make the lines proper and to frame the text. .text( data ); }); // Prevent default form submit action. return false; }); }); </code></pre> <p>And below is the same code in javascript, which is not ready yet. The problem is that it is not logical at the moment.</p> <p>The form bit of html which is not included here calls ajaxcontent(). ajaxcontent() creates the ".html" and ".text" part of the jQuery. JQuery ".find" can be ignored at the moment.</p> <p>In ajaxcontent() the "pre" tag is created first, then added class "brush:xml" in it. Then "createTextNode" adds the source coude from the page that is asked. This is the "( data )" in jQuery. Here the code fails, since ajax wants to place the information to id="response", but ajaxcontent() still needs to do this line "xelement.appendChild(xtext);" to attach the text to "xelement".</p> <pre><code>function loadajax() { var xmlhttp; if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) { document.getElementById("response").innerHTML=xmlhttp.responseText; } } var urlvar=(document.getElementById("url").value) xmlhttp.open("GET","ba-simple-proxy.php&amp;url="+urlvar,true); xmlhttp.send(); } function ajaxcontent() { var xelement=document.createElement("pre"); xelement.className="brush:xml"; var xtext=document.createTextNode( loadajax() ); xelement.appendChild(xtext); } </code></pre> <p>Any suggestions how to make this work? The jQuery part is a working example but the javascript part is not yet.</p> </div>

各位大侠帮帮忙,用VFP在一张图片中写字,字体怎么旋转呢?如图“光盘编号”、”盛世天明”

![图片说明](https://img-ask.csdn.net/upload/202001/01/1577866388_317829.jpg) Erase test.png Declare Integer GdipDrawString In GDIPlus.Dll Long graphics,String Str,Long Length,Long thefont,String @layoutRect,Long StringFormat,Long brush Declare Integer GdipCreateStringFormat In GDIPlus.Dll Integer formatAttributes,Integer Language,Integer @nFormat Declare Integer GdipDeleteStringFormat In GDIPlus.Dll Long nFormat Declare Integer GdipCreateFont In GDIPlus.Dll Integer fontFamily,Single emSize,Integer fntstyle,Integer unit,Integer @fnt Declare Integer GdipDeleteFont In GDIPlus.Dll Integer fnt Declare Integer GdipCreateSolidFill In GDIPlus.Dll Integer ARGBcolor,Integer @brush Declare Integer GdipDeleteGraphics In GDIPlus.Dll Integer graphics Declare Integer GdipDeleteBrush In GDIPlus.Dll Integer brush Declare Integer GdipCreateFontFamilyFromName In GDIPlus.Dll String familyname,Integer FontCollection,Integer @FontFamily Declare Integer GdipDeleteFontFamily In GDIPlus.Dll Integer FontFamily Declare Integer GdipCreateFromHWND In GDIPlus.Dll Integer hWind,Integer @graphics Declare Integer MultiByteToWideChar In kernel32 Long iCodePage,Long dwFlags,String @ lpStr,Long iMultiByte,String @ lpWideStr,Long iWideChar Declare Integer GdipLoadImageFromFile In GDIPlus.Dll String wFilename,Integer @nImage Declare Integer GdipSaveImageToFile In GDIPlus.Dll Integer nImage,String wFilename,String qEncoder,Integer nEncoderParamsPtr Declare Integer GdipGetImageGraphicsContext In GDIPlus.Dll Integer nImage,Integer @ nGraphics Declare Integer GdipCreateHatchBrush In GDIPlus.Dll Integer hatchstyle,Integer ForeCol,Integer BackCol,Integer @brush Declare Integer GdipGetImageHeight In GDIPlus Integer img,Integer @ imgheight Declare Integer GdipGetImageWidth In GDIPlus Integer img,Integer @ imgwidth Declare Integer GdipDisposeImage In GDIPlus.Dll Long nativeImage graphics=0 nimage=0 File_Name='c:\D.PNG' &&原图(此处可以是BMP,JPG,GIF,TIF,PNG,ICO格式的文件) GdipLoadImageFromFile(Strconv(File_Name + Chr(0),5),@nimage) *********开始写绿色的100********** lcText='100' lnLen = 2 * (Len(lcText) + 1) lcWideStr = Replicate(Chr(0),lnLen) MultiByteToWideChar(0,0,@lcText,Len(lcText),@lcWideStr,lnLen) tcText=lcWideStr lcFontName='黑体'&&字体名称,必须是已注册的字体 lcFontName=Strconv(lcFontName+Chr(0),5) lnFontFamily=0 GdipCreateFontFamilyFromName(lcFontName,0,@lnFontFamily) lnFont=0 lnFontStyle=1&&字体类型,0默认,1加粗,2倾斜3=1+2加粗倾斜 4U 8 S tnSize=10&&字体大小 GdipCreateFont(lnFontFamily,tnSize,lnFontStyle,3,@lnFont) lnFormatHandle = 0 thAlignment=0&&对其格式 居左 GdipCreateStringFormat(0,0,@lnFormatHandle ) nAlign = lnFormatHandle brush=0 ucolor1=Rgb(0,255,0)&&字体颜色 aphpi=255&&透明度 lnColor1 = CToBin(Chr(aphpi)+Left(BinToC(uColor1,'4rs'),3),'4s') ucolor2=Rgb(0,255,0)&&字体颜色 aphpi=255&&透明度 lnColor2 = CToBin(Chr(aphpi)+Left(BinToC(uColor2,'4rs'),3),'4s') GdipCreateHatchBrush(11,lnColor1,lnColor2,@brush)&&建立纹理刷子 x=17&&绘制文字的左上角坐标 Y=28 w=0 h=0 GdipGetImageWidth(nImage,@w) GdipGetImageHeight(nImage,@h) lcRectangleF=BinToC(x,'F')+BinToC(Y,'F')+BinToC(w,'F')+BinToC(h,'F') GdipGetImageGraphicsContext (nImage,@Graphics) GdipDrawString(Graphics,tcText,Len(lcText),lnFont,@lcRectangleF,0,brush) *********写绿色的100结束********** GdipDeleteFontFamily(lnFontFamily) GdipDeleteFont(lnFont) GdipDeleteBrush(brush) GdipDeleteGraphics(Graphics) GdipDeleteStringFormat(lnFormatHandle) *********开始写红色的200********** lcText='200' lnLen = 2 * (Len(lcText) + 1) lcWideStr = Replicate(Chr(0),lnLen) MultiByteToWideChar(0,0,@lcText,Len(lcText),@lcWideStr,lnLen) tcText=lcWideStr lcFontName='黑体'&&字体名称,必须是已注册的字体 lcFontName=Strconv(lcFontName+Chr(0),5) lnFontFamily=0 GdipCreateFontFamilyFromName(lcFontName,0,@lnFontFamily) lnFont=0 lnFontStyle=1&&字体类型,0默认,1加粗,2倾斜3=1+2加粗倾斜 4U 8 S tnSize=10&&字体大小 GdipCreateFont(lnFontFamily,tnSize,lnFontStyle,3,@lnFont) lnFormatHandle = 0 thAlignment=0&&对其格式 居左 GdipCreateStringFormat(0,0,@lnFormatHandle ) nAlign = lnFormatHandle brush=0 ucolor1=Rgb(255,0,0)&&字体颜色 aphpi=255&&透明度 lnColor1 = CToBin(Chr(aphpi)+Left(BinToC(uColor1,'4rs'),3),'4s') ucolor2=Rgb(255,0,0)&&字体颜色 aphpi=255&&透明度 lnColor2 = CToBin(Chr(aphpi)+Left(BinToC(uColor2,'4rs'),3),'4s') GdipCreateHatchBrush(11,lnColor1,lnColor2,@brush)&&建立纹理刷子 x=17&&绘制文字的左上角坐标 Y=45 w=0 h=0 GdipGetImageWidth(nImage,@w) GdipGetImageHeight(nImage,@h) lcRectangleF=BinToC(x,'F')+BinToC(Y,'F')+BinToC(w,'F')+BinToC(h,'F') GdipGetImageGraphicsContext (nImage,@Graphics) GdipDrawString(Graphics,tcText,Len(lcText),lnFont,@lcRectangleF,0,brush) *********写红色的200结束********** lcEncoder=0h06F47C55041AD3119A730000F81EF32E &&PNG *lcEncoder=0h00F47C55041AD3119A730000F81EF32E &&BMP *lcEncoder=0h01F47C55041AD3119A730000F81EF32E &&JPG *lcEncoder=0h02F47C55041AD3119A730000F81EF32E &&GIF *lcEncoder=0h05F47C55041AD3119A730000F81EF32E &&TIF *lcEncoder=0h06F47C55041AD3119A730000F81EF32E &&PNG GdipSaveImageToFile (nImage,Strconv("c:\test.png",5) + Chr(0),lcEncoder,0) GdipDeleteFontFamily(lnFontFamily) GdipDeleteFont(lnFont) GdipDisposeImage(nImage) GdipDeleteBrush(brush) GdipDeleteGraphics(Graphics) GdipDeleteStringFormat(lnFormatHandle)

vs2010 使用CDC在picture控件上绘图,如何设备picture背景色

如标题所示,我现在的处理是 void CpictureCTL_test01Dlg::OnPaint() { CWnd* pWnd1; pWnd1 = GetDlgItem(IDC_LED); CPaintDC dc(pWnd1); // 用于绘制的设备上下文 CPaintDC dc.SetBkColor(RGB(0,0,0)); //picture背景色成黑色 CBrush brush(RGB(0,125,0));//画刷 CMyMemDC dcMem(&dc); dcMem.SelectObject(&brush); if(dd == 1) DrawLine(dcMem); else DrawRect(dcMem); 现在的结果是整个窗口都变成了黑色

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

String s = new String(" a ") 到底产生几个对象?

老生常谈的一个梗,到2020了还在争论,你们一天天的,哎哎哎,我不是针对你一个,我是说在座的各位都是人才! 上图红色的这3个箭头,对于通过new产生一个字符串(”宜春”)时,会先去常量池中查找是否已经有了”宜春”对象,如果没有则在常量池中创建一个此字符串对象,然后堆中再创建一个常量池中此”宜春”对象的拷贝对象。 也就是说准确答案是产生了一个或两个对象,如果常量池中原来没有 ”宜春” ,就是两个。...

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

Linux面试题(2020最新版)

文章目录Linux 概述什么是LinuxUnix和Linux有什么区别?什么是 Linux 内核?Linux的基本组件是什么?Linux 的体系结构BASH和DOS之间的基本区别是什么?Linux 开机启动过程?Linux系统缺省的运行级别?Linux 使用的进程间通信方式?Linux 有哪些系统日志文件?Linux系统安装多个桌面环境有帮助吗?什么是交换空间?什么是root帐户什么是LILO?什...

Linux命令学习神器!命令看不懂直接给你解释!

大家都知道,Linux 系统有非常多的命令,而且每个命令又有非常多的用法,想要全部记住所有命令的所有用法,恐怕是一件不可能完成的任务。 一般情况下,我们学习一个命令时,要么直接百度去搜索它的用法,要么就直接用 man 命令去查看守冗长的帮助手册。这两个都可以实现我们的目标,但有没有更简便的方式呢? 答案是必须有的!今天给大家推荐一款有趣而实用学习神器 — kmdr,让你解锁 Linux 学习新姿势...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

史上最全的 python 基础知识汇总篇,没有比这再全面的了,建议收藏

网友们有福了,小编终于把基础篇的内容全部涉略了一遍,这是一篇关于基础知识的汇总的文章,请朋友们收下,不用客气,不过文章篇幅肯能会有点长,耐心阅读吧爬虫(七十)多进程multiproces...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

85后蒋凡:28岁实现财务自由、34岁成为阿里万亿电商帝国双掌门,他的人生底层逻辑是什么?...

蒋凡是何许人也? 2017年12月27日,在入职4年时间里,蒋凡开挂般坐上了淘宝总裁位置。 为此,时任阿里CEO张勇在任命书中力赞: 蒋凡加入阿里,始终保持创业者的冲劲,有敏锐的...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

新一代神器STM32CubeMonitor介绍、下载、安装和使用教程

关注、星标公众号,不错过精彩内容作者:黄工公众号:strongerHuang最近ST官网悄悄新上线了一款比较强大的工具:STM32CubeMonitor V1.0.0。经过我研究和使用之...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

大学一路走来,学习互联网全靠这几个网站,最终拿下了一把offer

大佬原来都是这样炼成的

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

什么时候跳槽,为什么离职,你想好了么?

都是出来打工的,多为自己着想

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

你期望月薪4万,出门右拐,不送,这几个点,你也就是个初级的水平

先来看几个问题通过注解的方式注入依赖对象,介绍一下你知道的几种方式@Autowired和@Resource有何区别说一下@Autowired查找候选者的...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

立即提问
相关内容推荐