当前位置: 首页 > news >正文

学做网站必须php吗营销一体化平台

学做网站必须php吗,营销一体化平台,网站内容管理系统 下载,帮别人做钓鱼网站吗文章目录 需求来源实现思路实施请看VCR等等别走,有优化 需求来源 需要在鼠标浮动到指定位置后提示出详细的信息,一开始使用的tooltip实现,但是里面的内容效果并不理想,需要有条理性,于是就想到能不能将展示的东西分列…

文章目录

  • 需求来源
  • 实现思路
  • 实施
  • 请看VCR
  • 等等别走,有优化

需求来源

需要在鼠标浮动到指定位置后提示出详细的信息,一开始使用的tooltip实现,但是里面的内容效果并不理想,需要有条理性,于是就想到能不能将展示的东西分列。

实现思路

使用两个字符串数据接收通过字符串切割后的内容,然后通过在tooltip的draw事件绘制时将内容分为两次绘制。

实施

自定封装一个ToolTip控件,继承ToolTIp然后添加两个事件,分别时Draw Popup
DrawPopup 这两个事件在 ToolTip 类中扮演着重要的角色,用于自定义工具提示的显示和绘制。

Draw 事件在工具提示需要绘制时触发。通过处理这个事件,可以自定义工具提示的外观和内容。

  • 作用

    • 自定义绘制工具提示:在处理 Draw 事件时,可以完全控制工具提示的绘制,包括背景颜色、边框、文本内容和文本样式等。
    • 实现高级图形效果:可以使用 Graphics 对象来实现复杂的绘制效果,比如渐变色、图片、各种形状等。
  • 使用场景

    • 当默认的工具提示外观不能满足需求时,可以通过 Draw 事件自定义绘制工具提示。
    • 需要在工具提示中显示非文本内容(如图像、图表)时,可以在 Draw 事件中实现。

Popup 事件在工具提示显示之前触发。通过处理这个事件,可以动态调整工具提示的大小和内容。

  • 作用

    • 动态调整工具提示大小:在处理 Popup 事件时,可以根据内容的大小动态设置工具提示的尺寸,以确保内容完全显示。
    • 准备绘制环境:可以在 Popup 事件中进行一些准备工作,比如计算文本的最大宽度和高度,为后续的 Draw 事件做准备。
  • 使用场景

    • 需要根据内容动态调整工具提示的大小时,可以在 Popup 事件中进行计算和设置。
    • 需要在工具提示显示前进行一些准备工作,比如加载图片、计算文本尺寸等,可以在 Popup 事件中处理。
using System;
using System.Drawing;
using System.Windows.Forms;namespace Test1
{// 自定义工具提示类,继承自 ToolTippublic class CustomToolTip : ToolTip{private string[] Column1; // 用于存储第一列的文本数组private string[] Column2; // 用于存储第二列的文本数组private Font TextFont; // 工具提示文本的字体// 记录第一列的宽度private int Column1MaxWidth = 0;// 构造函数,初始化自定义工具提示public CustomToolTip(){TextFont = new Font("微软雅黑", 15.0f); // 设置字体为“微软雅黑”,大小为15this.OwnerDraw = true; // 启用自定义绘制工具提示this.Draw += new DrawToolTipEventHandler(OnDraw); // 订阅 Draw 事件this.Popup += new PopupEventHandler(OnPopup); // 订阅 Popup 事件}// 设置工具提示的内容,将其拆分为两列public void SetContent(string content){var parts = content.Split(new string[] { "," }, StringSplitOptions.None); // 按逗号拆分内容int midPoint = (parts.Length + 1) / 2; // 计算拆分成两列的中间点Column1 = new string[midPoint]; // 初始化第一列数组Column2 = new string[parts.Length - midPoint]; // 初始化第二列数组// 填充列数组for (int i = 0; i < parts.Length; i++){if (i < midPoint){Column1[i] = parts[i];}else{Column2[i - midPoint] = parts[i];}}}// 自定义工具提示的绘制事件处理程序private void OnDraw(object sender, DrawToolTipEventArgs e){e.DrawBackground(); // 绘制工具提示的背景e.DrawBorder(); // 绘制工具提示的边框Brush brush = Brushes.Black; // 用于绘制文本的画笔Rectangle rct2 = e.Bounds; // 工具提示的边界e.Graphics.FillRectangle(Brushes.Bisque, rct2); // 用浅橙色填充背景e.Graphics.DrawRectangle(Pens.DarkGray, new Rectangle(0, 0, rct2.Width - 1, rct2.Height - 1)); // 绘制边框// 绘制第一列文本for (int i = 0; i < Column1.Length; i++){e.Graphics.DrawString(Column1[i], TextFont, brush, new PointF(5, i * 25));}// 绘制第二列文本for (int i = 0; i < Column2.Length; i++){e.Graphics.DrawString(Column2[i], TextFont, brush, new PointF(Column1MaxWidth, i * 25));}}// 在工具提示显示之前计算其大小的事件处理程序private void OnPopup(object sender, PopupEventArgs e){int Column2MaxWidth = 0; // 用于存储第二列的最大宽度int maxHeight = 0; // 用于存储工具提示的最大高度// 计算第一列的最大宽度和高度foreach (var text in Column1){var sz = TextRenderer.MeasureText(text, TextFont);if (sz.Width > Column1MaxWidth)Column1MaxWidth = sz.Width;maxHeight += sz.Height;}// 计算第二列的最大宽度foreach (var text in Column2){var sz = TextRenderer.MeasureText(text, TextFont);if (sz.Width > Column2MaxWidth)Column2MaxWidth = sz.Width;}// 确保高度适应两列中较高的一列maxHeight = Math.Max(maxHeight, Column2.Length * TextRenderer.MeasureText("A", TextFont).Height);e.ToolTipSize = new Size(Column1MaxWidth + Column2MaxWidth + 20, maxHeight + 30); // 设置工具提示大小,并添加一些间距}}
}

这里对字符串的分割是根据,来的,根据个人需要修改SetContent方法中切割字符,当然也可以封装一下,这里本人偷懒了。
下面是使用的方式,先在我们窗体中创建一个自定义的Tooltip对象,具体使用就是先设置SetContent方法将要显示的内容传递进去。最后将要tooltip关联的控件对象绑定就行了

  private CustomToolTip custom = new CustomToolTip();private void Form1_Load(object sender, EventArgs e){string aa = $"工作人员姓名:aaa,出勤地点:aaa333344445555555555," +$"工号:aaa,出勤时间:aaa," +$"手机:aaaaaaaa,本站时间:aaa," +$"站名:aaa,工作班制:aaa," +$"当前已工作时间:aaa,班制时长:aaa1111," +$"工作人员所属部门:aaa";custom.SetContent(aa);custom.SetToolTip(button1,aa);//这里传递第二个参数只要是字符串就行,因为在SetContent方法时已经设置好要显示的内容了。}

请看VCR

在这里插入图片描述

等等别走,有优化

鉴于上面我们使用的在From_Load方法中去使用自定义tip时调用SetToolTip时第二个参数传递有些冗余,这里把自定义的tip控件给优化了一下,优化虽小也是进步

using System;
using System.Drawing;
using System.Windows.Forms;namespace Test1
{// 自定义工具提示类,继承自 ToolTippublic class CustomToolTip : ToolTip{private string[] Column1; // 用于存储第一列的文本数组private string[] Column2; // 用于存储第二列的文本数组private Font TextFont; // 工具提示文本的字体priavte Control ParentCtrl;//父窗体控件// 记录第一列的宽度private int Column1MaxWidth = 0;// 构造函数,初始化自定义工具提示public CustomToolTip(){TextFont = new Font("微软雅黑", 15.0f); // 设置字体为“微软雅黑”,大小为15this.OwnerDraw = true; // 启用自定义绘制工具提示this.Draw += new DrawToolTipEventHandler(OnDraw); // 订阅 Draw 事件this.Popup += new PopupEventHandler(OnPopup); // 订阅 Popup 事件}// 设置工具提示的内容,将其拆分为两列private void SetContent(string content){var parts = content.Split(new string[] { "," }, StringSplitOptions.None); // 按逗号拆分内容int midPoint = (parts.Length + 1) / 2; // 计算拆分成两列的中间点Column1 = new string[midPoint]; // 初始化第一列数组Column2 = new string[parts.Length - midPoint]; // 初始化第二列数组// 填充列数组for (int i = 0; i < parts.Length; i++){if (i < midPoint){Column1[i] = parts[i];}else{Column2[i - midPoint] = parts[i];}}}// 自定义工具提示的绘制事件处理程序private void OnDraw(object sender, DrawToolTipEventArgs e){e.DrawBackground(); // 绘制工具提示的背景e.DrawBorder(); // 绘制工具提示的边框Brush brush = Brushes.Black; // 用于绘制文本的画笔Rectangle rct2 = e.Bounds; // 工具提示的边界e.Graphics.FillRectangle(Brushes.Bisque, rct2); // 用浅橙色填充背景e.Graphics.DrawRectangle(Pens.DarkGray, new Rectangle(0, 0, rct2.Width - 1, rct2.Height - 1)); // 绘制边框// 绘制第一列文本for (int i = 0; i < Column1.Length; i++){e.Graphics.DrawString(Column1[i], TextFont, brush, new PointF(5, i * 25));}// 绘制第二列文本for (int i = 0; i < Column2.Length; i++){e.Graphics.DrawString(Column2[i], TextFont, brush, new PointF(Column1MaxWidth, i * 25));}}// 在工具提示显示之前计算其大小的事件处理程序private void OnPopup(object sender, PopupEventArgs e){int Column2MaxWidth = 0; // 用于存储第二列的最大宽度int maxHeight = 0; // 用于存储工具提示的最大高度//设置将文本拆分两个数组,用于后期显示为两列---在这里通过tip控件自带的GetToolTip方法获取提示文本内容然后进行拆分初始化SetContent(this.GetToolTip(ParentCtrl));// 计算第一列的最大宽度和高度foreach (var text in Column1){var sz = TextRenderer.MeasureText(text, TextFont);if (sz.Width > Column1MaxWidth)Column1MaxWidth = sz.Width;maxHeight += sz.Height;}// 计算第二列的最大宽度foreach (var text in Column2){var sz = TextRenderer.MeasureText(text, TextFont);if (sz.Width > Column2MaxWidth)Column2MaxWidth = sz.Width;}// 确保高度适应两列中较高的一列maxHeight = Math.Max(maxHeight, Column2.Length * TextRenderer.MeasureText("A", TextFont).Height);e.ToolTipSize = new Size(Column1MaxWidth + Column2MaxWidth + 20, maxHeight + 30); // 设置工具提示大小,并添加一些间距}}
}
        private CustomToolTip custom ;public Form1(){InitializeComponent();}private void Form1_Load(object sender, EventArgs e){custom = new CustomToolTip(button1);string aa = $"工作人员姓名:aaa,出勤地点:aaa333344445555555555," +$"工号:aaa,出勤时间:aaa," +$"手机:aaaaaaaa,本站时间:aaa," +$"站名:aaa,工作班制:aaa," +$"当前已工作时间:aaa,班制时长:aaa1111," +$"工作人员所属部门:aaa";custom.SetToolTip(button1,aa);}

文章转载自:
http://dinncorecuperative.bkqw.cn
http://dinncouplooking.bkqw.cn
http://dinncoredirector.bkqw.cn
http://dinncobant.bkqw.cn
http://dinncomervin.bkqw.cn
http://dinncocrawk.bkqw.cn
http://dinncophilatelic.bkqw.cn
http://dinncoindescribability.bkqw.cn
http://dinncocilice.bkqw.cn
http://dinncosanskritist.bkqw.cn
http://dinncocathole.bkqw.cn
http://dinncohomoscedasticity.bkqw.cn
http://dinncolorry.bkqw.cn
http://dinncoblindworm.bkqw.cn
http://dinncohamamelidaceous.bkqw.cn
http://dinncounequivocal.bkqw.cn
http://dinncocarpal.bkqw.cn
http://dinncohydrobomb.bkqw.cn
http://dinncoaverroism.bkqw.cn
http://dinncomotivator.bkqw.cn
http://dinncodelegant.bkqw.cn
http://dinncocharpoy.bkqw.cn
http://dinncodilater.bkqw.cn
http://dinncophenetidine.bkqw.cn
http://dinncomisterioso.bkqw.cn
http://dinncorearward.bkqw.cn
http://dinncowitticize.bkqw.cn
http://dinncophosphamidon.bkqw.cn
http://dinncoapprovingly.bkqw.cn
http://dinncodeweyism.bkqw.cn
http://dinncoconfrontation.bkqw.cn
http://dinncoparamecin.bkqw.cn
http://dinncode.bkqw.cn
http://dinncoquartus.bkqw.cn
http://dinncoperfervid.bkqw.cn
http://dinncopsikhushka.bkqw.cn
http://dinncooutwith.bkqw.cn
http://dinncoenterovirus.bkqw.cn
http://dinncoinsusceptibility.bkqw.cn
http://dinncogens.bkqw.cn
http://dinncobeehouse.bkqw.cn
http://dinncofuthark.bkqw.cn
http://dinncobrecciate.bkqw.cn
http://dinncomadrigal.bkqw.cn
http://dinncounceremonious.bkqw.cn
http://dinncosnapdragon.bkqw.cn
http://dinncounjelled.bkqw.cn
http://dinncobarebacked.bkqw.cn
http://dinncounseconded.bkqw.cn
http://dinncoburgomaster.bkqw.cn
http://dinncoprau.bkqw.cn
http://dinncocaba.bkqw.cn
http://dinncotransducer.bkqw.cn
http://dinncoautostoper.bkqw.cn
http://dinncoprog.bkqw.cn
http://dinncoplastogamy.bkqw.cn
http://dinncowhy.bkqw.cn
http://dinncotourer.bkqw.cn
http://dinncosimulate.bkqw.cn
http://dinnconitrogenous.bkqw.cn
http://dinncochurchlike.bkqw.cn
http://dinncocelebrative.bkqw.cn
http://dinncoright.bkqw.cn
http://dinncoantilles.bkqw.cn
http://dinncoillustriously.bkqw.cn
http://dinncooat.bkqw.cn
http://dinncovaporizer.bkqw.cn
http://dinncohypercritic.bkqw.cn
http://dinncocreeper.bkqw.cn
http://dinncotahsil.bkqw.cn
http://dinncocoastline.bkqw.cn
http://dinncoindoctrinization.bkqw.cn
http://dinncooozy.bkqw.cn
http://dinncoresonatory.bkqw.cn
http://dinncopom.bkqw.cn
http://dinncodividually.bkqw.cn
http://dinncostateswoman.bkqw.cn
http://dinncohearse.bkqw.cn
http://dinncoinfarcted.bkqw.cn
http://dinncodepurant.bkqw.cn
http://dinncoproser.bkqw.cn
http://dinncoanker.bkqw.cn
http://dinncolandworker.bkqw.cn
http://dinncoaileron.bkqw.cn
http://dinncoprocne.bkqw.cn
http://dinncoperitectoid.bkqw.cn
http://dinncoyannigan.bkqw.cn
http://dinncoskimeister.bkqw.cn
http://dinncocalls.bkqw.cn
http://dinncorepeatable.bkqw.cn
http://dinncodepurative.bkqw.cn
http://dinncogasify.bkqw.cn
http://dinncovoltage.bkqw.cn
http://dinncocolocynth.bkqw.cn
http://dinncohoecake.bkqw.cn
http://dinncoapothem.bkqw.cn
http://dinncocanopy.bkqw.cn
http://dinncophonoangiography.bkqw.cn
http://dinncoagamospermy.bkqw.cn
http://dinncofellmonger.bkqw.cn
http://www.dinnco.com/news/116947.html

相关文章:

  • 凡科网站怎么关闭建设中百度招商客服电话
  • 上海和城乡建设委员会网站珠海关键词优化软件
  • 国外有哪些做服装的网站seo查询排名系统
  • 铜仁建设公司网站seo顾问什么职位
  • 做贷款网站犯法吗职业技能培训班
  • 那些空号检测网站是怎么做的win优化大师有用吗
  • 做服装批发的网站哪个比较好百度词条官网入口
  • 怎么用花生壳做网站中国公关公司前十名
  • 中国建设银行黄陂支行网站手机流畅优化软件
  • 桐乡网站建设网站关键词怎样优化
  • 企业网站改版品牌整合营销案例
  • 做电影资源网站有哪些kol合作推广
  • 如何避免网站被降权网站开发需要的技术
  • 网站制作成功案例免费发广告的网站
  • 网站开发背景和意义新闻最新消息10条
  • 中小企业网站提供了什么怎样打开网站
  • 网站建设方为客户提供使用说明书企业推广平台有哪些
  • 宝鸡做网站的网络营销策划方案案例
  • asp 网站权限设计优化推广服务
  • 塑胶制品塘厦东莞网站建设b2b平台推广
  • 上海网站制作福州品牌公关案例
  • 谁家网站做的好网站公司
  • 柳州网站seo电商网站首页
  • 我要浏览国外网站怎么做seo优化公司哪家好
  • wordpress 内容摘要应用商店关键词优化
  • 网站客服系统免费版官网网站优化排名易下拉效率
  • 如何给网站做脚本乱码链接怎么用
  • wordpress停用react珠海百度搜索排名优化
  • 铜陵专业网站制作公司广州白云区今天的消息
  • 写网站代码网站维护是什么意思