Skip to content

Instantly share code, notes, and snippets.

@noqisofon
Created November 19, 2010 02:33
Show Gist options
  • Save noqisofon/706055 to your computer and use it in GitHub Desktop.
Save noqisofon/706055 to your computer and use it in GitHub Desktop.
フローティングウィンドウクラス。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace groan.app.widgets {
using util;
/// <summary>
///
/// </summary>
public partial class Stick : Form {
/// <summary>
///
/// </summary>
public Stick() {
InitializeComponent();
}
/// <summary>
///
/// </summary>
public void update() {
StickInfo tag = (StickInfo)this.Tag;
int padding = 10;
int start_x = Screen.PrimaryScreen.Bounds.Width - tag.width;
int start_y = 0;
lblTitle.Text = tag.title;
lblFullText.Text = tag.fulltext;
this.Location = new Point( ( start_x - ( tag.width * tag.x ) ) - padding * tag.x,
start_y + ( tag.height * tag.y ) + ( padding * tag.y )
);
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="ergs"></param>
private void PopupForm_Load(object sender, EventArgs ergs) {
update();
timer.Start();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="wcergs"></param>
private void PopupForm_FormClosing(object sender, FormClosingEventArgs wcergs) {
GroanForm f =(GroanForm)this.Owner;
f.raiseStickClosed();
timer.Stop();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="ergs"></param>
private void timer_Tick(object sender, EventArgs ergs) {
// 100 以上になったらこの窓を閉じます。
if ( this.count_ > 100 )
this.Close();
this.Opacity = ( 100 - this.count_ ) / 100.0;
//lblTitle.Text = string.Format( "{0:F}", this.Opacity );
++this.count_;
}
private int count_ = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment