C# winform自定义翻页控件详解

C#  winform中自定义的翻页控件,自己设计,供大家参考,具体内容如下

1.主要是使用控件绑定点击事件  

用到的控件分别为picturebox   lable  上一页pbPage_Prev    下一页 pbPage_Next  首页 pbPage_Begin   尾页pbPage_End  是picturebox控件加背景图

“第  页/ 共  页” 是一个lable “labPageInfo”    在lable上面加了一个隐藏的textbox 控件 “txtPageInfo”

2.将这个翻页的功能单独写在用户控件 ucPageTurn 里面  然后在每个页面直接应用就可以了

下面只是把ucPageTurn写了出来

还需要在winform页面上应用上

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Demo
{
 public partial class ucPageTurn : UserControl, IMessageFilter
 {
  private const int SIZE_HEIGHT = 40;
  private const int SIZE_MINWIDTH = 84;
  private const int SIZE_INFO_MINWIDTH = 188;

  public ucPageTurn()
  {
   Application.AddMessageFilter(this); 

   InitializeComponent();
   this.BorderStyle = System.Windows.Forms.BorderStyle.None;
   this.MinimumSize = new Size(SIZE_MINWIDTH, 0);
   this.Disposed += new EventHandler(ucPages_Disposed);

   //this.MouseClick += new MouseEventHandler(ucKeyboard_Close);

   PageChanged += new PageChangedHandle(new PageChangedHandle((oldPage, newPage, e) => { }));
   InputGotFocus += new InputFocusHandle(new InputFocusHandle((sender, e) => { }));
   //InputLostFocus += new InputFocusHandle(new InputFocusHandle((sender, e) => { }));

   InputGotFocus += new InputFocusHandle(new InputFocusHandle((sender, e) => { }));
   InputLostFocus += new InputFocusHandle(new InputFocusHandle((sender, e) => { }));

   InputMouseDown += new InputMouseHandle(new InputMouseHandle((sender, e) => { }));
   InputMouseUp += new InputMouseHandle(new InputMouseHandle((sender, e) => { }));
   InputTextClick += new EventHandler(new EventHandler((sender, e) => { }));
   InputKeyDown += new InputKeyHandle(new InputKeyHandle((sender, e) => { }));
   InputKeyUp += new InputKeyHandle(new InputKeyHandle((sender, e) => { }));
   InputKeyPress += new InputKeyPressHandle(new InputKeyPressHandle((sender, e) => { }));
   InputTextChanged += new EventHandler(new EventHandler((sender, e) => { }));

   this.BackColor = Color.White;
   labPageInfo.BackColor = this.BackColor;

   this.Resize += new EventHandler(ucPages_Resize);

   //labPageInfo.MouseDoubleClick += new MouseEventHandler(labPageInfo_MouseDoubleClick);

   pbPage_Prev.MouseDown += new MouseEventHandler(pbPage_Prev_MouseDown);
   pbPage_Prev.MouseUp += new MouseEventHandler(pbPage_Prev_MouseUp);

   pbPage_Next.MouseDown += new MouseEventHandler(pbPage_Next_MouseDown);
   pbPage_Next.MouseUp += new MouseEventHandler(pbPage_Next_MouseUp);

   pbPage_Begin.MouseDown += new MouseEventHandler(pbPage_Begin_MouseDown);
   pbPage_Begin.MouseUp += new MouseEventHandler(pbPage_Begin_MouseUp);

   pbPage_End.MouseDown += new MouseEventHandler(pbPage_End_MouseDown);
   pbPage_End.MouseUp += new MouseEventHandler(pbPage_End_MouseUp);

   txtPageInfo.TextChanged += new EventHandler(txtPageInfo_TextChanged);
   txtPageInfo.GotFocus += new EventHandler(txtPageInfo_GotFocus);
   txtPageInfo.Click += new EventHandler(txtPageInfo_Click);
   txtPageInfo.Text = m_strText;
   txtPageInfo.Visible = m_blnShowTxtPageInfo;

   m_blnIsAutoJump = false;
   m_timerAutoPage.Enabled = false;
   m_timerAutoPage.Interval = WAIT_FOR_AUTOJUMP;
   m_timerAutoPage.Tick += new EventHandler(timerAutoPage_Tick);
  }

  private void ucPages_Load(object sender, EventArgs e)
  {
   setStatus();
  }

  private void ucPages_Disposed(object sender, EventArgs e)
  {
   Application.RemoveMessageFilter(this);
  }

  public bool PreFilterMessage(ref System.Windows.Forms.Message MyMessage)
  {
   if (MyMessage.Msg == 0x204 || MyMessage.Msg == 0x205)
   {
    return true;
   }
   return false;
  }

  //设置控件的自适应大小
  private void ucPages_Resize(object sender, EventArgs e)
  {
   this.Height = SIZE_HEIGHT;

   pbPage_Begin.Location = new Point(0, 0);
   pbPage_Begin.Size = new Size(SIZE_HEIGHT, SIZE_HEIGHT);

   pbPage_Prev.Location = new Point(pbPage_Begin.Width + 2, pbPage_Begin.Top);
   pbPage_Prev.Size = pbPage_Begin.Size;

   pbPage_End.Location = new Point(this.Width - pbPage_End.Width, pbPage_Begin.Top);
   pbPage_End.Size = pbPage_Begin.Size;

   pbPage_Next.Location = new Point(this.Width - pbPage_Next.Width - pbPage_End.Width - 2, pbPage_Begin.Top);
   pbPage_Next.Size = pbPage_Begin.Size;

   if (this.Width < SIZE_INFO_MINWIDTH)
   {
    labPageInfo.Visible = false;
    txtPageInfo.Visible = false;
   }
   else
   {
    labPageInfo.Location = new Point(pbPage_Prev.Width + pbPage_Prev.Width + 3, 2);
    labPageInfo.Size = new Size(pbPage_Next.Left - labPageInfo.Left - 3, pbPage_Prev.Height);

    txtPageInfo.Location = new Point(pbPage_Prev.Left + pbPage_Prev.Width + 5, 11);
    //txtPageInfo.Size = new Size(pbPage_Next.Left - labPageInfo.Left , 15);

    if (m_blnShowLabel && !labPageInfo.Visible) labPageInfo.Visible = true;
    if (m_blnShowLabel && !txtPageInfo.Visible) txtPageInfo.Visible = true;
   }

   if (m_blnShowTxtPageInfo)
   {
    txtPageInfo.Size = new Size(79, labPageInfo.Height);
   }
   else
   {
    txtPageInfo.Size = new Size(0, labPageInfo.Height);
   }
  }

  //点击lablelabPageInfo 显示txtPageInfo
  private void labPageInfo_Click(object sender, EventArgs e)
  {
   if (!txtPageInfo.Visible)
   {
    showJumpPageStatus(true);
    InputTextClick(txtPageInfo, new EventArgs());
   }
   else {
    showJumpPageStatus(false);
   }
  }

  public void showJumpPageStatus(Boolean isShow)
  {
   if (isShow)
   {
    txtPageInfo.Visible = true;
    txtPageInfo.Text = string.Empty;
    txtPageInfo.Focus();
   }
   else
   {
    txtPageInfo.Visible = false;
   }
  }

  //上一页
  private void pbPage_Prev_MouseDown(object sender, MouseEventArgs e)
  {
   pbPage_Prev.Image = global::Pku.CFM.Controls.Properties.Resources.Page_Prev_D;
   m_blnIsPrevDown = true;

   m_timerAutoPage.Enabled = true;
  }

  private void pbPage_Prev_MouseUp(object sender, MouseEventArgs e)
  {
   pbPage_Prev.Image = global::Pku.CFM.Controls.Properties.Resources.Page_Prev_N;
   m_blnIsPrevDown = false;

   if (m_blnIsAutoJump)
   {
    leaveAutoJumpMode();
    return;
   }
   m_timerAutoPage.Enabled = false;

   if (1 == m_intCurPageIndex) return;
   int intOldPage = m_intCurPageIndex;
   m_intCurPageIndex--;
   setStatus();
   PageChanged(intOldPage, m_intCurPageIndex, new EventArgs());
  }

  //下一页
  private void pbPage_Next_MouseDown(object sender, MouseEventArgs e)
  {

   pbPage_Next.Image = global::Pku.CFM.Controls.Properties.Resources.Page_Next_D;
   m_blnIsNextDown = true;

   m_timerAutoPage.Enabled = true;
  }

  private void pbPage_Next_MouseUp(object sender, MouseEventArgs e)
  {
   pbPage_Next.Image = global::Pku.CFM.Controls.Properties.Resources.Page_Next_N;
   m_blnIsNextDown = false;

   if (m_blnIsAutoJump)
   {
    leaveAutoJumpMode();
    return;
   }
   m_timerAutoPage.Enabled = false;

   if (m_intPageCount == m_intCurPageIndex) return;
   int intOldPage = m_intCurPageIndex;
   m_intCurPageIndex++;
   setStatus();
   PageChanged(intOldPage, m_intCurPageIndex, new EventArgs());
  }

  //首页
  private void pbPage_Begin_MouseDown(object sender, MouseEventArgs e)
  {

   pbPage_Begin.Image = global::Pku.CFM.Controls.Properties.Resources.PageView_Begin_D;
   m_blnIsBeginDown = false;
   m_timerAutoPage.Enabled = true;
  }

  private void pbPage_Begin_MouseUp(object sender, MouseEventArgs e)
  {
   pbPage_Begin.Image = global::Pku.CFM.Controls.Properties.Resources.PageView_Begin_N;
   m_blnIsBeginDown = false;

   int intOldPage = m_intCurPageIndex;

   if (1 == m_intCurPageIndex) return;
   m_intCurPageIndex = 1;

   setStatus();
   PageChanged(intOldPage, m_intCurPageIndex, new EventArgs());

   m_blnIsAutoJump = false;
   m_timerAutoPage.Stop();
  }

  //尾页
  private void pbPage_End_MouseDown(object sender, MouseEventArgs e)
  {

   pbPage_End.Image = global::Pku.CFM.Controls.Properties.Resources.PageView_End_N;
   m_blnIsEndDown = true;

   m_timerAutoPage.Enabled = true;
  }

  private void pbPage_End_MouseUp(object sender, MouseEventArgs e)
  {
   pbPage_End.Image = global::Pku.CFM.Controls.Properties.Resources.PageView_End_D;
   m_blnIsEndDown = false;

   int intOldPage = m_intCurPageIndex;

   if (m_intCurPageIndex == m_intPageCount)return;
   m_intCurPageIndex = m_intPageCount;

   setStatus();
   PageChanged(intOldPage, m_intCurPageIndex, new EventArgs());

   m_blnIsAutoJump = false;
   m_timerAutoPage.Stop();

  }

  //翻页按钮的状态
  private void setStatus()
  {
   //如果页数为0,翻页的按钮全部不显示
   if (m_intPageCount <= 0)
   {
    labPageInfo.Text = "";
    pbPage_Prev.Visible = false;
    pbPage_Next.Visible = false;
    pbPage_Begin.Visible = false;
    pbPage_End.Visible = false;
    txtPageInfo.Visible = false;
   }
   else
   {
    //如果页数为1,翻页的按钮不显示
    if (1 == m_intPageCount)
    {
     labPageInfo.Text = "";
     pbPage_Prev.Visible = false;
     pbPage_Next.Visible = false;
     pbPage_Begin.Visible = false;
     pbPage_End.Visible = false;
     txtPageInfo.Visible = false;
    }
    else
    {
     //只显示下一页和最后一页的按钮
     if (m_intCurPageIndex <= 1)
     {
      m_intCurPageIndex = 1;

      pbPage_Prev.Visible = false;
      pbPage_Next.Visible = true;
      pbPage_Begin.Visible = false;
      pbPage_End.Visible = true;
      txtPageInfo.Visible = false;

     }
     //只显示上一页和首页的按钮
     else if (m_intCurPageIndex >= m_intPageCount)
     {
      m_intCurPageIndex = m_intPageCount;

      pbPage_Prev.Visible = true;
      pbPage_Next.Visible = false;
      pbPage_Begin.Visible = true ;
      pbPage_End.Visible = false;
      txtPageInfo.Visible = false;

     }
      //否则按钮全部显示
     else
     {
      pbPage_Prev.Visible = true;
      pbPage_Next.Visible = true;
      pbPage_Begin.Visible = true;
      pbPage_End.Visible = true;
      txtPageInfo.Visible = false;
     }

     labPageInfo.Text = String.Format("第{0}页 /共{1}页", m_intCurPageIndex, m_intPageCount);
     txtPageInfo.Text = String.Format("{0}", m_intCurPageIndex);
    }
   }
  }

  private void timerAutoPage_Tick(object sender, EventArgs e)
  {
   if ((m_blnIsNextDown && m_intCurPageIndex >= m_intPageCount) || (m_blnIsPrevDown && m_intCurPageIndex <= 1) || (m_blnIsEndDown && m_intCurPageIndex >=m_intPageCount) || (m_blnIsBeginDown && m_intCurPageIndex<=1))
   {
    leaveAutoJumpMode();
    return;
   }

   if (!m_blnIsAutoJump) m_timerAutoPage.Interval = AUTOJUMP_INV;

   int intOldPage = m_intCurPageIndex;

   if (m_blnIsNextDown) m_intCurPageIndex++;
   if (m_blnIsPrevDown) m_intCurPageIndex--;

   setStatus();

   PageChanged(intOldPage, m_intCurPageIndex, new EventArgs());

   if ((m_blnIsNextDown && m_intCurPageIndex >= m_intPageCount) || (m_blnIsPrevDown && m_intCurPageIndex <= 1)||(m_blnIsEndDown && m_intCurPageIndex >= m_intPageCount) || (m_blnIsBeginDown && m_intCurPageIndex <= 1))
   {
    leaveAutoJumpMode();
   }
   else
   {
    m_blnIsAutoJump = true;
   }
  }

  private void leaveAutoJumpMode()
  {
   m_blnIsAutoJump = false;
   m_timerAutoPage.Stop();
   m_timerAutoPage.Enabled = false;
   m_timerAutoPage.Interval = WAIT_FOR_AUTOJUMP;
  }

  private int m_intCurPageIndex = 0;

  //当前页面
  public int CurPageIndex
  {
   get { return m_intCurPageIndex; }
   set
   {
    if (value < 0 || (m_intPageCount> 0 && value > m_intPageCount)) return;

    int intOldPage = m_intCurPageIndex;
    m_intCurPageIndex = value;

    setStatus();
    if (!m_blnIgnoreChange) PageChanged(intOldPage, m_intCurPageIndex, new EventArgs());

    m_blnIsAutoJump = false;
    m_timerAutoPage.Stop();
    m_timerAutoPage.Enabled = false;
   }
  }

  //计算总页数
  public int PageCount
  {
   get { return m_intPageCount; }
   set
   {
    m_intPageCount = value;

    if (m_intPageCount > 0)
    {
     if (m_intCurPageIndex <= 0) m_intCurPageIndex = 0;

     if (m_intCurPageIndex > m_intPageCount)
     {
      m_intCurPageIndex = m_intPageCount;
     }
    }
    else
    {
     m_intCurPageIndex = 0;
    }

    setStatus();
   }
  }

  private Boolean m_blnIgnoreChange = false;
  public Boolean IgnoreChange
  {
   get { return m_blnIgnoreChange; }
   set { m_blnIgnoreChange = value; }
  }

  private Boolean m_blnShowLabel = true;
  public Boolean ShowLabel
  {
   get { return m_blnShowLabel; }
   set { m_blnShowLabel = value; labPageInfo.Visible = value; }
  }

  private void txtPageInfo_TextChanged(object sender, EventArgs e)
  {
   if (m_blnIgnTextChange) return;
   m_blnIgnTextChange = true;
   InputTextChanged(sender, e);
  }

  private void txtPageInfo_GotFocus(object sender, EventArgs e)
  {
   InputGotFocus(this, e);
  }

  private void txtPageInfo_LostFocus(object sender, EventArgs e)
  {
   InputLostFocus(this, e);
  }

  private void txtPageInfo_MouseDown(object sender, MouseEventArgs e)
  {
   InputMouseDown(sender, e);
  }

  private void txtPageInfo_MouseUp(object sender, MouseEventArgs e)
  {
   InputMouseUp(sender, e);
  }

  private void txtPageInfo_Click(object sender, EventArgs e)
  {
   InputTextClick(sender, e);
  }

  private void txtPageInfo_KeyDown(object sender, KeyEventArgs e)
  {
   InputKeyDown(sender, e);
  }

  private void txtPageInfo_KeyUp(object sender, KeyEventArgs e)
  {
   InputKeyUp(sender, e);
  }

  private void txtPageInfo_KeyPress(object sender, KeyPressEventArgs e)
  {
   InputKeyPress(sender, e);
  }

  private string m_strText = "";
  public String Text
  {
   get { return m_strText; }
   set { m_strText = value; }
  }

  private System.Windows.Forms.Timer m_timerAutoPage = new Timer();
  private bool m_blnIsPrevDown = false;
  private bool m_blnIsNextDown = false;

  private bool m_blnIsBeginDown = false;
  private bool m_blnIsEndDown = false;

  private bool m_blnIsAutoJump = false;
  public delegate void PageChangedHandle(int oldPage, int newPage, EventArgs e);
  public event PageChangedHandle PageChanged;

  private const int WAIT_FOR_AUTOJUMP = 500;
  private const int AUTOJUMP_INV = 500;

  private int m_intPageCount = 0;
  protected String m_strErrorText = "";
  public String ErrorText
  {
   get { return m_strErrorText; }
   set { m_strErrorText = value; }
  }

  /// <summary>
  /// 键盘控件的父对象
  /// </summary>
  private Control m_keyboardParent = null;
  public Control KeyboardParent
  {
   get { return m_keyboardParent; }
   set { m_keyboardParent = value; }
  }

  /// <summary>
  /// 是否显示输入翻页框按钮
  /// </summary>
  private Boolean m_blnShowTxtPageInfo = true;
  public Boolean ShowTxtPageInfo
  {
   get { return m_blnShowTxtPageInfo; }
   set { m_blnShowTxtPageInfo = value; txtPageInfo.Visible = value; }
  }

  //public bool IsPages { get; set; }

  private bool m_blnIgnTextChange = false;
  private Boolean m_blnIsInputFocus = false;

  //public event EventHandler InputEnterPressed;
  //public event EventHandler InputClearPressed;

  public delegate void InputFocusHandle(object sender, EventArgs e);
  public event InputFocusHandle InputGotFocus;
  public event InputFocusHandle InputLostFocus;

  public delegate void InputMouseHandle(object sender, MouseEventArgs e);
  public event InputMouseHandle InputMouseDown;
  public event InputMouseHandle InputMouseUp;

  public event EventHandler InputTextClick;

  public delegate void InputKeyHandle(object sender, KeyEventArgs e);
  public event InputKeyHandle InputKeyDown;
  public event InputKeyHandle InputKeyUp;
  //public event InputKeyHandle InputTextKeyBoardEnter;

  public delegate void InputKeyPressHandle(object sender, KeyPressEventArgs e);
  public event InputKeyPressHandle InputKeyPress;

  public event EventHandler InputTextChanged;

  public TextBox InputTextBox
  {
   set { txtPageInfo=value; }
   get { return txtPageInfo; }
  }

  public String InputText
  {
   get
   {
    if (m_strText == txtPageInfo.Text || String.IsNullOrWhiteSpace(txtPageInfo.Text))
    {
     return String.Empty;
    }
    else
    {
     return txtPageInfo.Text;
    }
   }
   set
   {
    if (m_blnIsInputFocus)
    {
     txtPageInfo.Text = value;
    }
    else
    {
     if (String.IsNullOrWhiteSpace(value))
     {
      m_blnIgnTextChange = true;
      txtPageInfo.Text = m_strText;
      m_blnIgnTextChange = false;
     }
    }
   }
  }

  public void setInputText(String text)
  {
   txtPageInfo.Text = text;
  }
 }
}

3. 你在资源管文件里面创建的control 文件夹里面,创建了一个用户控件ucPageTurn ,那么在工具栏里面会自动显示你刚刚写的ucPageTurn组件,把它拖到页面上 ,将这个组件的名字叫做ucPages,这样ucpageturn里面的控件就可以进行编辑

//在initControls里面添加textbox输入框的事件
 private void initControls()

 {
  ucPages.InputTextBox.KeyPress +=new KeyPressEventHandler(ucPages_KeyPress);
   ucPages.PageChanged += new Pku.CFM.Controls.ucPageTurn.PageChangedHandle(ucPages_PageChanged);
}

 private void ucPages_KeyPress(object sender, KeyPressEventArgs e)
  {
   if (13 == e.KeyChar)
   {
    int intReturn = SysDefine.NOTHING;
    String strInputText = ucPages.Text.ToUpper();
    if (SysDefine.FAILED == intReturn)
    {
     MessageBox.Show(this.ErrorText, "信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
    }

    String pageInputText = ucPages.InputText;
    int page = 0;
    try
    {
     page = int.Parse(pageInputText);
    }
    catch
    {
     page = 1;
    }
    ucPages.CurPageIndex = page;
    if (SysDefine.FAILED == refreshList(page, strInputText))
    {
     MessageBox.Show(this.ErrorText, "信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
    }
   }
  }

 private void ucPages_PageChanged(int oldPage, int newPage, EventArgs e)
  {
   int intReturn = SysDefine.NOTHING;

   String strInputText = ucPages.Text.ToUpper();
   intReturn = refreshList(newPage, strInputText);
   if (SysDefine.FAILED == intReturn)
   {
    MessageBox.Show(this.ErrorText, "信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
    return;
   }
  }

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。

(0)

相关推荐

  • C#使用WebService结合jQuery实现无刷新翻页的方法

    本文实例讲述了C#使用WebService结合jQuery实现无刷新翻页的方法.分享给大家供大家参考.具体如下: 1. 首先创建数据库.表Article,字段ArticleId,Title 前台代码 <%@ Page Language="C#" AutoEventWireup="true" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &quo

  • C# winform自定义翻页控件详解

    C#  winform中自定义的翻页控件,自己设计,供大家参考,具体内容如下 1.主要是使用控件绑定点击事件   用到的控件分别为picturebox   lable  上一页pbPage_Prev    下一页 pbPage_Next  首页 pbPage_Begin   尾页pbPage_End  是picturebox控件加背景图 "第  页/ 共  页" 是一个lable "labPageInfo"    在lable上面加了一个隐藏的textbox 控件

  • WPF自定义选择年月控件详解

    本文实例为大家分享了WPF自定义选择年月控件的具体代码,供大家参考,具体内容如下 封装了一个选择年月的控件,XAML代码: <UserControl x:Class="SunCreate.CombatPlatform.Client.DateMonthPicker" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.micr

  • Android自定义view实现滚动选择控件详解

    目录 前言 需求 编写代码 主要问题 前言 上篇文章通过一个有header和footer的滚动控件(Viewgroup)学了下MeasureSpec.onMeasure以及onLayout,接下来就用一个滚动选择的控件(View)来学一下onDraw的使用,并且了解下在XML自定义控件参数. 需求 这里就是一个滚动选择文字的控件,还是挺常见的,之前用别人的,现在选择手撕一个,核心思想如下: 1.有三层不同大小及透明度的选项,选中项放在中间 2.接受一个列表的数据,静态时显示三个值,滚动时显示四个

  • Android ToolBar控件详解及实例

    ToolBar控件详解 在Activity中添加ToolBar 1.添加库 dependencies { ... compile "com.android.support:appcompat-v7:18.0.+" } 2.Activity要继承AppCompatActivity 3.设置主题 使用ToolBar,要将系统默认的ActionBar隐藏掉 <application android:theme="@style/Theme.AppCompat.Light.NoA

  • ios电子书翻页效果代码详解

    近实现了一个完整的电子书阅读器,支持txt和epub格式的电子书阅读,其中epub支持图文混排的方式展示.本文主要谈谈其中两种翻页效果的实现,分别为仿真翻页和水平滑动翻页. 仿真翻页 最合适的方案就是使用系统提供的UIPageviewcontroller了,不过默认的UIpageviewcontroller翻页时背面是白色的,而阅读器通常都会有背景色或背景图片,翻页时用户体验就很糟糕,比如就像下面这样 所以接下来主要说说如何修改背面颜色以达到美观的翻页效果. UIpageviewcontroll

  • Android Tab 控件详解及实例

    Android Tab 控件详解及实例 在桌面应用中Tab控件使用得非常普遍,那么我们经常在Android中也见到以Tab进行布局的客户端.那么Android中的Tab是如何使用的呢? 1.Activity package com.wicresoft.activity; import com.wicresoft.myandroid.R; import android.app.TabActivity; import android.os.Bundle; import android.util.Lo

  • MAUI使用Maui.Graphics.Controls绘制控件详解

    目录 简介 Microsoft.Maui.Graphics.Controls 使用Microsoft.Maui.Graphics.Controls 绘制控件 总结 简介 Microsoft.Maui.Graphics是一个完全采用C#的iOS,Android,Windows,macOS,Tizen和Linux的跨平台图形库. 对于MAUI项目当中绘制的方案是使用不同平台的控件来而非自绘. 当然MAUI当中也使用了Microsoft.Maui.Graphics, MAUI Preview9更新中,

  • Android实现自定义轮播图片控件详解

    首先上效果图 实现原理 要完成一个轮播图片,首先想到的应该是使用ViewPager来实现.ViewPager已经有了滑动的功能,我们只要让它自己滚动.再加上下方的小圆点就行了.所以我们本次的自定义控件就是由ViewPager和LinearLayout叠加起来组成的. 一.创建一个自定义的ViewPager 先上完整的代码 package com.kcode.autoscrollviewpager.view; import android.content.Context; import andro

  • Android使用属性动画如何自定义倒计时控件详解

    为什么要引入属性动画? Android之前的补间动画机制其实还算是比较健全的,在android.view.animation包下面有好多的类可以供我们操作,来完成一系列的动画效果,比如说对View进行移动.缩放.旋转和淡入淡出,并且我们还可以借助AnimationSet来将这些动画效果组合起来使用,除此之外还可以通过配置Interpolator来控制动画的播放速度等等等等.那么这里大家可能要产生疑问了,既然之前的动画机制已经这么健全了,为什么还要引入属性动画呢? 其实上面所谓的健全都是相对的,如

  • bootstrap daterangepicker双日历时间段选择控件详解

    双日历时间段选择插件 - daterangepicker是bootstrap框架后期的一个时间控件,可以设定多个时间段选项,也可以自定义时间段,由用户自己选择起始时间和终止时间,时间段的最大跨度可以在程序里设定.我们项目里用到的Bootstrap版本是2.3.1,所以我把daterangepicker与Bootstrap-2.3.1进行了整合. 一.需要引入的css与js  <link href="bootstrap.min.css" rel="stylesheet&q

随机推荐