153 lines
5.1 KiB
C#
153 lines
5.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace AyaNova.Plugin.QuickNotification
|
|
{
|
|
public partial class QuickNotificationCompose : Form
|
|
{
|
|
private QuickNotification mqn;
|
|
|
|
public QuickNotificationCompose(QuickNotification QN)
|
|
{
|
|
mqn = QN;
|
|
InitializeComponent();
|
|
this.btnSend.Image = (System.Drawing.Image)mqn.AyaNovaResourceManager.GetObject("OK24");
|
|
this.btnCancel.Image = (System.Drawing.Image)mqn.AyaNovaResourceManager.GetObject("Cancel24");
|
|
|
|
|
|
}
|
|
|
|
private void QuickNotificationCompose_Load(object sender, EventArgs e)
|
|
{
|
|
ckAll.Focus();
|
|
Win32Utility.SetCueText(tbSubject, "Subject");
|
|
Win32Utility.SetCueText(tbMsg, "Message");
|
|
this.Icon = Resource.QuickNotification ;
|
|
grid.DataSource=mqn.NotifyList;
|
|
grid.Columns["Category"].ReadOnly = true;
|
|
grid.Columns["Source"].ReadOnly = true;
|
|
grid.Columns["UserName"].ReadOnly = true;
|
|
|
|
//iterate rows, users not subscribed get red
|
|
int x=0;
|
|
foreach (NotifyItem ni in mqn.NotifyList)
|
|
{
|
|
DataGridViewRow row = grid.Rows[x];
|
|
if (!mqn.Subscribers.Contains(ni.UserID))
|
|
{
|
|
row.ReadOnly = true;
|
|
foreach (DataGridViewCell c in row.Cells)
|
|
{
|
|
c.Style.Font = new Font(grid.DefaultCellStyle.Font, FontStyle.Strikeout);
|
|
//c.Style.BackColor = System.Drawing.Color.WhiteSmoke;
|
|
//c.Style.ForeColor = System.Drawing.Color.Gray;
|
|
c.ToolTipText = ni.UserName + " is not subscribed to QuickNotification event";
|
|
}
|
|
}
|
|
|
|
x++;
|
|
}
|
|
|
|
Application.Idle += new EventHandler(Application_Idle);
|
|
}
|
|
|
|
private void QuickNotificationCompose_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
Application.Idle -= new EventHandler(Application_Idle);
|
|
}
|
|
|
|
private void Application_Idle(object sender, EventArgs e)
|
|
{
|
|
btnSend.Enabled = (mqn.HasSelectedUsers && HasSomethingToSend);
|
|
}
|
|
bool bIgnoreCheckChange = false;
|
|
|
|
private void grid_CurrentCellDirtyStateChanged(object sender, EventArgs e)
|
|
{
|
|
if (grid.IsCurrentCellDirty)
|
|
{
|
|
grid.CommitEdit(DataGridViewDataErrorContexts.Commit);
|
|
}
|
|
}
|
|
|
|
private void grid_CellValueChanged(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
if (!bIgnoreCheckChange && grid.Columns[e.ColumnIndex].Name == "Send")
|
|
{
|
|
|
|
DataGridViewCheckBoxCell checkCell =
|
|
(DataGridViewCheckBoxCell)grid.
|
|
Rows[e.RowIndex].Cells["Send"];
|
|
bool bWasChecked = !(Boolean)checkCell.Value;
|
|
Guid SelectedUserID=mqn.NotifyList[e.RowIndex].UserID;
|
|
bIgnoreCheckChange = true;
|
|
mqn.CheckAllForUser(!bWasChecked, SelectedUserID);
|
|
bIgnoreCheckChange = false;
|
|
grid.Invalidate();
|
|
}
|
|
}
|
|
|
|
public string MesageToSend
|
|
{
|
|
get
|
|
{
|
|
//case 1375
|
|
if (!string.IsNullOrEmpty(tbSubject.Text))
|
|
{
|
|
return "<SUBJECT>" + tbSubject.Text.Trim() + "</SUBJECT>" + tbMsg.Text.Trim().TrimEnd('\r','\n');
|
|
}
|
|
else
|
|
return tbMsg.Text;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//case 1375
|
|
public bool HasSomethingToSend
|
|
{
|
|
get
|
|
{//can send on either a subject or message alone
|
|
return ((!string.IsNullOrEmpty(tbSubject.Text)) || (!string.IsNullOrEmpty(tbMsg.Text)));
|
|
}
|
|
}
|
|
|
|
private void btnSend_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void grid_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
|
|
{
|
|
if (grid.Columns[e.ColumnIndex].Name == "Send")
|
|
{
|
|
//check uncheck all based on first column
|
|
ckAll.Checked = !ckAll.Checked;
|
|
|
|
}
|
|
}
|
|
|
|
private void ckAll_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
mqn.CheckAll(ckAll.Checked);
|
|
grid.Invalidate();
|
|
}
|
|
|
|
private void grid_CellClick(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
if (grid.Rows[e.RowIndex].ReadOnly)
|
|
{
|
|
MessageBox.Show(grid.Rows[e.RowIndex].Cells["UserName"].FormattedValue.ToString() + " is not subscribed to QuickNotification event");
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|