预览
代码
手机端效果
web端效果
demoTimer.cs
demoTimer.Designer.cs
web:demoTimer.cs
web:demoTimer.Designer.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Smobiler.Core;
using Smobiler.Core.Controls;
namespace Smobiler.Tutorials.Components
{
partial class demoTimer : Smobiler.Core.Controls.MobileForm
{
public demoTimer()
: base()
{
//This call is required by the SmobilerForm.
InitializeComponent();
}
private void title1_ImagePress(object sender, EventArgs e)
{
this.Close();
}
private int i = 0;
private void timer1_Tick(object sender, EventArgs e)
{
if (progress1.Value != 1)
progress1.Value += 0.1f;
else
progress1.Value = 0;
switch1.Checked = !switch1.Checked;
checkBox1.Checked = !checkBox1.Checked;
checkBox2.Checked = !checkBox2.Checked;
label1.Text = i++.ToString();
}
private void demoTimer_Load(object sender, EventArgs e)
{
timer1.Start();
}
private void btnstart_Press(object sender, EventArgs e)
{
timer1.Start();
}
private void btnstop_Press(object sender, EventArgs e)
{
timer1.Stop();
}
}
}
using System;
using Smobiler.Core;
namespace Smobiler.Tutorials.Components
{
partial class demoTimer : Smobiler.Core.Controls.MobileForm
{
#region "SmobilerForm generated code "
//SmobilerForm overrides dispose to clean up the component list.
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
}
//NOTE: The following procedure is required by the SmobilerForm
//It can be modified using the SmobilerForm.
//Do not modify it using the code editor.
[System.Diagnostics.DebuggerStepThrough()]
private void InitializeComponent()
{
this.title1 = new Smobiler.Core.Controls.Title();
this.panel10 = new Smobiler.Core.Controls.Panel();
this.panel1 = new Smobiler.Core.Controls.Panel();
this.labContent = new Smobiler.Core.Controls.Label();
this.labTitle = new Smobiler.Core.Controls.Label();
this.progress1 = new Smobiler.Core.Controls.Progress();
this.switch1 = new Smobiler.Core.Controls.Switch();
this.checkBox1 = new Smobiler.Core.Controls.CheckBox();
this.checkBox2 = new Smobiler.Core.Controls.CheckBox();
this.label1 = new Smobiler.Core.Controls.Label();
this.panel2 = new Smobiler.Core.Controls.Panel();
this.label5 = new Smobiler.Core.Controls.Label();
this.label6 = new Smobiler.Core.Controls.Label();
this.btnstart = new Smobiler.Core.Controls.Button();
this.btnstop = new Smobiler.Core.Controls.Button();
this.panel3 = new Smobiler.Core.Controls.Panel();
this.label13 = new Smobiler.Core.Controls.Label();
this.label14 = new Smobiler.Core.Controls.Label();
this.timer1 = new Smobiler.Core.Controls.Timer();
//
// title1
//
this.title1.ImageType = Smobiler.Core.Controls.ImageEx.ImageStyle.FontIcon;
this.title1.Name = "title1";
this.title1.ResourceID = "angle-left";
this.title1.Size = new System.Drawing.Size(300, 30);
this.title1.Text = "Timer";
this.title1.ImagePress += new System.EventHandler(this.title1_ImagePress);
//
// panel10
//
this.panel10.Controls.AddRange(new Smobiler.Core.Controls.MobileControl[] {
this.panel1,
this.panel2,
this.panel3});
this.panel10.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel10.Location = new System.Drawing.Point(0, 30);
this.panel10.Name = "panel10";
this.panel10.Scrollable = true;
this.panel10.Size = new System.Drawing.Size(300, 970);
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.White;
this.panel1.Border = new Smobiler.Core.Controls.Border(1F);
this.panel1.BorderColor = System.Drawing.Color.Silver;
this.panel1.BorderRadius = 5;
this.panel1.Controls.AddRange(new Smobiler.Core.Controls.MobileControl[] {
this.labContent,
this.labTitle,
this.progress1,
this.switch1,
this.checkBox1,
this.checkBox2,
this.label1});
this.panel1.Location = new System.Drawing.Point(5, 9);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(290, 179);
//
// labContent
//
this.labContent.BackColor = System.Drawing.Color.WhiteSmoke;
this.labContent.FontSize = 15F;
this.labContent.Location = new System.Drawing.Point(0, 26);
this.labContent.Name = "labContent";
this.labContent.Padding = new Smobiler.Core.Controls.Padding(5F);
this.labContent.Size = new System.Drawing.Size(290, 63);
this.labContent.Text = "计时器控件,基础控件,Interval属性控制触发Tick事件的间隔时间(s),Enabled属性指示计时器是否正在运行\r\n";
this.labContent.VerticalAlignment = Smobiler.Core.Controls.VerticalAlignment.Top;
//
// labTitle
//
this.labTitle.BackColor = System.Drawing.Color.WhiteSmoke;
this.labTitle.Border = new Smobiler.Core.Controls.Border(0F, 0F, 0F, 1F);
this.labTitle.BorderColor = System.Drawing.Color.DarkSeaGreen;
this.labTitle.FontSize = 16F;
this.labTitle.Name = "labTitle";
this.labTitle.Padding = new Smobiler.Core.Controls.Padding(5F);
this.labTitle.Size = new System.Drawing.Size(290, 26);
this.labTitle.Text = "不同样式的计时器控件";
//
// progress1
//
this.progress1.Location = new System.Drawing.Point(0, 101);
this.progress1.Name = "progress1";
this.progress1.Size = new System.Drawing.Size(280, 15);
//
// switch1
//
this.switch1.Location = new System.Drawing.Point(11, 129);
this.switch1.Name = "switch1";
this.switch1.Size = new System.Drawing.Size(70, 30);
//
// checkBox1
//
this.checkBox1.Checked = true;
this.checkBox1.Location = new System.Drawing.Point(101, 127);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(42, 32);
//
// checkBox2
//
this.checkBox2.Location = new System.Drawing.Point(163, 129);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(40, 30);
this.checkBox2.Style = Smobiler.Core.Controls.CheckBoxStyle.Circular;
this.checkBox2.TintColor = System.Drawing.Color.Red;
//
// label1
//
this.label1.HorizontalAlignment = Smobiler.Core.Controls.HorizontalAlignment.Center;
this.label1.Location = new System.Drawing.Point(224, 129);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 30);
//
// panel2
//
this.panel2.BackColor = System.Drawing.Color.White;
this.panel2.Border = new Smobiler.Core.Controls.Border(1F);
this.panel2.BorderColor = System.Drawing.Color.Silver;
this.panel2.BorderRadius = 5;
this.panel2.Controls.AddRange(new Smobiler.Core.Controls.MobileControl[] {
this.label5,
this.label6,
this.btnstart,
this.btnstop});
this.panel2.Location = new System.Drawing.Point(5, 203);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(290, 173);
//
// label5
//
this.label5.BackColor = System.Drawing.Color.WhiteSmoke;
this.label5.FontSize = 15F;
this.label5.Location = new System.Drawing.Point(0, 26);
this.label5.Name = "label5";
this.label5.Padding = new Smobiler.Core.Controls.Padding(5F);
this.label5.Size = new System.Drawing.Size(290, 54);
this.label5.Text = "start,stop设置计时器启动与停止";
//
// label6
//
this.label6.BackColor = System.Drawing.Color.WhiteSmoke;
this.label6.Border = new Smobiler.Core.Controls.Border(0F, 0F, 0F, 1F);
this.label6.BorderColor = System.Drawing.Color.DarkSeaGreen;
this.label6.FontSize = 16F;
this.label6.Name = "label6";
this.label6.Padding = new Smobiler.Core.Controls.Padding(5F);
this.label6.Size = new System.Drawing.Size(290, 26);
this.label6.Text = "计时器的方法";
//
// btnstart
//
this.btnstart.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(76)))), ((int)(((byte)(176)))), ((int)(((byte)(249)))));
this.btnstart.Location = new System.Drawing.Point(31, 105);
this.btnstart.Name = "btnstart";
this.btnstart.Size = new System.Drawing.Size(100, 30);
this.btnstart.Text = "启动";
this.btnstart.Press += new System.EventHandler(this.btnstart_Press);
//
// btnstop
//
this.btnstop.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(254)))), ((int)(((byte)(192)))), ((int)(((byte)(78)))));
this.btnstop.Location = new System.Drawing.Point(161, 105);
this.btnstop.Name = "btnstop";
this.btnstop.Size = new System.Drawing.Size(100, 30);
this.btnstop.Text = "停止";
this.btnstop.Press += new System.EventHandler(this.btnstop_Press);
//
// panel3
//
this.panel3.BackColor = System.Drawing.Color.White;
this.panel3.Border = new Smobiler.Core.Controls.Border(1F);
this.panel3.BorderColor = System.Drawing.Color.Silver;
this.panel3.BorderRadius = 5;
this.panel3.Controls.AddRange(new Smobiler.Core.Controls.MobileControl[] {
this.label13,
this.label14});
this.panel3.Location = new System.Drawing.Point(5, 391);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(290, 85);
//
// label13
//
this.label13.BackColor = System.Drawing.Color.WhiteSmoke;
this.label13.FontSize = 15F;
this.label13.Location = new System.Drawing.Point(0, 26);
this.label13.Name = "label13";
this.label13.Padding = new Smobiler.Core.Controls.Padding(5F);
this.label13.Size = new System.Drawing.Size(290, 58);
this.label13.Text = "Tick当指定的计时器间隔已过去而且计时器处于启用状态时发生";
//
// label14
//
this.label14.BackColor = System.Drawing.Color.WhiteSmoke;
this.label14.Border = new Smobiler.Core.Controls.Border(0F, 0F, 0F, 1F);
this.label14.BorderColor = System.Drawing.Color.DarkSeaGreen;
this.label14.FontSize = 16F;
this.label14.Name = "label14";
this.label14.Padding = new Smobiler.Core.Controls.Padding(5F);
this.label14.Size = new System.Drawing.Size(290, 26);
this.label14.Text = "计时器事件";
//
// timer1
//
this.timer1.Name = "timer1";
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// demoTimer
//
this.Components.AddRange(new Smobiler.Core.Controls.MobileComponent[] {
this.timer1});
this.Controls.AddRange(new Smobiler.Core.Controls.MobileControl[] {
this.title1,
this.panel10});
this.Size = new System.Drawing.Size(300, 1000);
this.Load += new System.EventHandler(this.demoTimer_Load);
this.Name = "demoTimer";
}
#endregion
private Core.Controls.Title title1;
private Core.Controls.Panel panel10;
private Core.Controls.Panel panel1;
private Core.Controls.Label labContent;
private Core.Controls.Label labTitle;
private Core.Controls.Panel panel2;
private Core.Controls.Label label5;
private Core.Controls.Label label6;
private Core.Controls.Panel panel3;
private Core.Controls.Label label13;
private Core.Controls.Label label14;
private Core.Controls.Timer timer1;
private Core.Controls.Progress progress1;
private Core.Controls.Switch switch1;
private Core.Controls.CheckBox checkBox1;
private Core.Controls.CheckBox checkBox2;
private Core.Controls.Button btnstart;
private Core.Controls.Button btnstop;
private Core.Controls.Label label1;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Smobiler.Core;
using Smobiler.Core.Controls;
namespace SmobilerTutorialsWeb.Components
{
////ToolboxItem用于控制是否添加自定义控件到工具箱,true添加,false不添加
//[System.ComponentModel.ToolboxItem(true)]
partial class demoTimer : Smobiler.Core.Controls.MobileForm
{
public demoTimer() : base()
{
//This call is required by the SmobilerUserControl.
InitializeComponent();
}
private void title1_ImagePress(object sender, EventArgs e)
{
this.Close();
}
private void btnstart_Press(object sender, EventArgs e)
{
timer1.Start();
}
private void btnstop_Press(object sender, EventArgs e)
{
timer1.Stop();
}
private int i = 0;
private void timer1_Tick(object sender, EventArgs e)
{
if (progress1.Value != 1)
progress1.Value += 0.1f;
else
progress1.Value = 0;
switch1.Checked = !switch1.Checked;
checkBox1.Checked = !checkBox1.Checked;
checkBox2.Checked = !checkBox2.Checked;
label1.Text = i++.ToString();
}
private void demoTimer_Load(object sender, EventArgs e)
{
timer1.Start();
}
}
}
using System;
using Smobiler.Core;
namespace SmobilerTutorialsWeb.Components
{
partial class demoTimer : Smobiler.Core.Controls.MobileForm
{
#region "SmobilerUserControl generated code "
//SmobilerUserControl overrides dispose to clean up the component list.
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
}
//NOTE: The following procedure is required by the SmobilerUserControl
//It can be modified using the SmobilerUserControl.
//Do not modify it using the code editor.
[System.Diagnostics.DebuggerStepThrough()]
private void InitializeComponent()
{
this.title1 = new Smobiler.Core.Controls.Title();
this.panel10 = new Smobiler.Core.Controls.Panel();
this.panel1 = new Smobiler.Core.Controls.Panel();
this.labContent = new Smobiler.Core.Controls.Label();
this.progress1 = new Smobiler.Core.Controls.Progress();
this.switch1 = new Smobiler.Core.Controls.Switch();
this.checkBox1 = new Smobiler.Core.Controls.CheckBox();
this.checkBox2 = new Smobiler.Core.Controls.CheckBox();
this.label1 = new Smobiler.Core.Controls.Label();
this.label5 = new Smobiler.Core.Controls.Label();
this.btnstart = new Smobiler.Core.Controls.Button();
this.btnstop = new Smobiler.Core.Controls.Button();
this.labTitle = new Smobiler.Core.Controls.Label();
this.timer1 = new Smobiler.Core.Controls.Timer();
//
// title1
//
this.title1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(246)))), ((int)(((byte)(246)))), ((int)(((byte)(246)))));
this.title1.ImageType = Smobiler.Core.Controls.ImageEx.ImageStyle.FontIcon;
this.title1.Name = "title1";
this.title1.ResourceID = "angle-left";
this.title1.Size = new System.Drawing.Size(0, 30);
this.title1.Text = "Timer";
this.title1.ImagePress += new System.EventHandler(this.title1_ImagePress);
//
// panel10
//
this.panel10.Controls.AddRange(new Smobiler.Core.Controls.MobileControl[] {
this.panel1,
this.labTitle});
this.panel10.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel10.Flex = 1;
this.panel10.Name = "panel10";
this.panel10.Scrollable = true;
this.panel10.Size = new System.Drawing.Size(0, 0);
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.White;
this.panel1.Border = new Smobiler.Core.Controls.Border(1F);
this.panel1.BorderColor = System.Drawing.Color.Silver;
this.panel1.BorderRadius = 5;
this.panel1.Controls.AddRange(new Smobiler.Core.Controls.MobileControl[] {
this.labContent,
this.progress1,
this.switch1,
this.checkBox1,
this.checkBox2,
this.label1,
this.label5,
this.btnstart,
this.btnstop});
this.panel1.Location = new System.Drawing.Point(300, 57);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(600, 315);
//
// labContent
//
this.labContent.BackColor = System.Drawing.Color.White;
this.labContent.BorderColor = System.Drawing.Color.White;
this.labContent.HorizontalAlignment = Smobiler.Core.Controls.HorizontalAlignment.Center;
this.labContent.Location = new System.Drawing.Point(0, 121);
this.labContent.Name = "labContent";
this.labContent.Padding = new Smobiler.Core.Controls.Padding(5F);
this.labContent.Size = new System.Drawing.Size(600, 54);
this.labContent.Text = "计时器控件,基础控件,Interval属性控制触发Tick事件的间隔时间(s),Enabled属性指示计时器是否正在运行,Tick事件当指定的计时器间隔已过去而且" +
"计时器处于启用状态时发生\r\n";
//
// progress1
//
this.progress1.Location = new System.Drawing.Point(150, 40);
this.progress1.Name = "progress1";
this.progress1.Size = new System.Drawing.Size(280, 15);
//
// switch1
//
this.switch1.Location = new System.Drawing.Point(150, 73);
this.switch1.Name = "switch1";
this.switch1.Size = new System.Drawing.Size(70, 30);
//
// checkBox1
//
this.checkBox1.Checked = true;
this.checkBox1.Location = new System.Drawing.Point(240, 71);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(42, 32);
this.checkBox1.TintColor = System.Drawing.Color.FromArgb(((int)(((byte)(76)))), ((int)(((byte)(176)))), ((int)(((byte)(249)))));
//
// checkBox2
//
this.checkBox2.Location = new System.Drawing.Point(302, 73);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(40, 30);
this.checkBox2.Style = Smobiler.Core.Controls.CheckBoxStyle.Circular;
this.checkBox2.TintColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(67)))), ((int)(((byte)(81)))));
//
// label1
//
this.label1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(102)))), ((int)(((byte)(102)))), ((int)(((byte)(102)))));
this.label1.HorizontalAlignment = Smobiler.Core.Controls.HorizontalAlignment.Center;
this.label1.Location = new System.Drawing.Point(363, 73);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(67, 30);
//
// label5
//
this.label5.BackColor = System.Drawing.Color.White;
this.label5.BorderColor = System.Drawing.Color.White;
this.label5.HorizontalAlignment = Smobiler.Core.Controls.HorizontalAlignment.Center;
this.label5.Location = new System.Drawing.Point(0, 238);
this.label5.Name = "label5";
this.label5.Padding = new Smobiler.Core.Controls.Padding(5F);
this.label5.Size = new System.Drawing.Size(600, 54);
this.label5.Text = "timer1.Start()启动计时器,timer1.Stop()停止计时器\r\n";
//
// btnstart
//
this.btnstart.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(76)))), ((int)(((byte)(176)))), ((int)(((byte)(249)))));
this.btnstart.Location = new System.Drawing.Point(150, 186);
this.btnstart.Name = "btnstart";
this.btnstart.Size = new System.Drawing.Size(100, 30);
this.btnstart.Text = "启动";
this.btnstart.Press += new System.EventHandler(this.btnstart_Press);
//
// btnstop
//
this.btnstop.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(76)))), ((int)(((byte)(176)))), ((int)(((byte)(249)))));
this.btnstop.Location = new System.Drawing.Point(330, 186);
this.btnstop.Name = "btnstop";
this.btnstop.Size = new System.Drawing.Size(100, 30);
this.btnstop.Text = "停止";
this.btnstop.Press += new System.EventHandler(this.btnstop_Press);
//
// labTitle
//
this.labTitle.BackColor = System.Drawing.Color.White;
this.labTitle.Bold = true;
this.labTitle.Border = new Smobiler.Core.Controls.Border(0F, 0F, 0F, 1F);
this.labTitle.BorderColor = System.Drawing.Color.White;
this.labTitle.FontSize = 16F;
this.labTitle.Location = new System.Drawing.Point(300, 30);
this.labTitle.Name = "labTitle";
this.labTitle.Size = new System.Drawing.Size(600, 26);
this.labTitle.Text = "通过timer改变其他控件值";
//
// timer1
//
this.timer1.Name = "timer1";
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// demoTimer
//
this.BackColor = System.Drawing.Color.White;
this.Components.AddRange(new Smobiler.Core.Controls.MobileComponent[] {
this.timer1});
this.Controls.AddRange(new Smobiler.Core.Controls.MobileControl[] {
this.title1,
this.panel10});
this.Layout = Smobiler.Core.Controls.LayoutPosition.Relative;
this.Size = new System.Drawing.Size(1200, 800);
this.Load += new System.EventHandler(this.demoTimer_Load);
this.Name = "demoTimer";
}
#endregion
private Smobiler.Core.Controls.Title title1;
private Smobiler.Core.Controls.Panel panel10;
private Smobiler.Core.Controls.Panel panel1;
private Smobiler.Core.Controls.Label labContent;
private Smobiler.Core.Controls.Progress progress1;
private Smobiler.Core.Controls.Switch switch1;
private Smobiler.Core.Controls.CheckBox checkBox1;
private Smobiler.Core.Controls.CheckBox checkBox2;
private Smobiler.Core.Controls.Label label1;
private Smobiler.Core.Controls.Label labTitle;
private Smobiler.Core.Controls.Timer timer1;
private Smobiler.Core.Controls.Label label5;
private Smobiler.Core.Controls.Button btnstart;
private Smobiler.Core.Controls.Button btnstop;
}
}