📄 activityinfodlg.cs
字号:
for (int y = 0; y < alpos.Count; y++)
{
/*
if (IsMax)
{
//逆序 因为插入的时候是反插的
if ((int)alpos[x] > (int)alpos[y])
{
int temp = (int)alpos[x];
alpos[x] = (int)alpos[y];
alpos[y] = temp;
}
}
else
{
//逆序 因为插入的时候是反插的
if ((int)alpos[x] > (int)alpos[y])
{
int temp = (int)alpos[x];
alpos[x] = (int)alpos[y];
alpos[y] = temp;
}
}*/
if ((int)alpos[x] > (int)alpos[y])
{
int temp = (int)alpos[x];
alpos[x] = (int)alpos[y];
alpos[y] = temp;
}
}
}
foreach (int tempos in alpos)
{
al.Add(this.listBoxSlectedAppInfo.Items[tempos]);
}
return pos;
}
private void SortTopButtom(int TargtIndex, ArrayList al, int pos, bool IsMoveUP)
{
ArrayList oldListItem = new ArrayList();
if (!IsMoveUP)
{
//保存原有的列表项
foreach (WfApplication drv in this.listBoxSlectedAppInfo.Items)
{
oldListItem.Add(drv);
}
}
//删除所有数据
foreach (WfApplication drv in al)
{
this.listBoxSlectedAppInfo.Items.Remove(drv);
}
int count = 0;
foreach (WfApplication drv in al)
{
//判断是上移 还是下移
if (IsMoveUP)
{
//如果上移如果移动的开始位置是第一个则在第一个插入即可
if (TargtIndex <= 0)
{
this.listBoxSlectedAppInfo.Items.Insert(0, drv);
}
else
{
if (count == 0)
TargtIndex = TargtIndex - pos;
this.listBoxSlectedAppInfo.Items.Insert(TargtIndex, drv);
}
}
else
{
//如果下移
if (TargtIndex >= this.listBoxSlectedAppInfo.Items.Count + al.Count - 1)
{
//drv要排正序
if (count == 0)
{
//得到最小的焦点 并且-pos
//得到目前的对象
//加入个加的项
this.listBoxSlectedAppInfo.Items.Add(drv);
//在前面插入项
this.listBoxSlectedAppInfo.Items.Insert(this.listBoxSlectedAppInfo.Items.Count - 1, drv);
//删除最后项
this.listBoxSlectedAppInfo.Items.RemoveAt(this.listBoxSlectedAppInfo.Items.Count - 1);
TargtIndex = this.listBoxSlectedAppInfo.Items.Count - 1;
}
else
{
this.listBoxSlectedAppInfo.Items.Insert(this.listBoxSlectedAppInfo.Items.Count - 1, drv);
}
}
else
{
if (count == 0)
{
//得到原来队列插的那个对象所在位置
TargtIndex = TargtIndex + pos;
//得到目前的对象
int temppos = this.listBoxSlectedAppInfo.Items.IndexOf(oldListItem[TargtIndex]);
TargtIndex = temppos + pos;
}
//drv要排逆序
this.listBoxSlectedAppInfo.Items.Insert(TargtIndex, drv);
}
}
count++;
}
}
private void SetListBoxFouces(ArrayList al)
{
foreach (WfApplication drv in al)
{
if (this.listBoxSlectedAppInfo.Items.Contains(drv))
{
this.listBoxSlectedAppInfo.SetSelected(this.listBoxSlectedAppInfo.Items.IndexOf(drv), true);
}
}
}
#endregion
#region 拖拽
private void listBoxSlectedAppInfo_DragDrop(object sender, DragEventArgs e)
{
//拖放完成
if (e.Data.GetDataPresent(typeof(WfApplication)))
{
WfApplication item = (WfApplication)e.Data.GetData(typeof(WfApplication));
if (e.Effect == DragDropEffects.Move)
{
System.Windows.Forms.ListBox lb = (ListBox)sender;
Point clientPoint = this.listBoxSlectedAppInfo.PointToClient(new Point(e.X, e.Y));
//Point mouseDownLocation = new Point(e.X, e.Y);
//新的位置
int index = lb.IndexFromPoint(clientPoint);
//原来的位置
int oldindex = lb.Items.IndexOf(item);
int temp = System.Math.Abs(oldindex - index);
//将选中的项位置上移一格
ArrayList al = new ArrayList();
if (index == -1)
{
temp = System.Math.Abs(oldindex - (this.listBoxSlectedAppInfo.Items.Count - 1));
//移到最后
//向下移
//得到选中的最大pos
int fistPos = GetMaxMinPos(out al, true);
//根据最大的排序
this.SortTopButtom(this.listBoxSlectedAppInfo.Items.Count - 1, al, temp, false);
}
else
{
if (oldindex > index)
{
//向上移
//得到选中的最大pos
int fistPos = GetMaxMinPos(out al, false);
//根据最大的排序
this.SortTopButtom(fistPos, al, temp, true);
}
else if (oldindex < index)
{
//向下移
//得到选中的最大pos
int fistPos = GetMaxMinPos(out al, true);
//根据最大的排序
//如果位置大于等于数组本身 那么就放到最后
if (index >= this.listBoxSlectedAppInfo.Items.Count - 1)
{
this.SortTopButtom(this.listBoxSlectedAppInfo.Items.Count - 1, al, temp, false);
}
else
{
this.SortTopButtom(fistPos, al, temp, false);
}
}
}
SetListBoxFouces(al);
//this.textBox1.Text = item["UserName"].ToString();
//触发交换位置
//MessageBox.Show(item["UserName"].ToString());
}
}
}
private void listBoxSlectedAppInfo_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
System.Windows.Forms.ListBox lb = (ListBox)sender;
Point mouseDownLocation = new Point(e.X, e.Y);
int index = lb.IndexFromPoint(mouseDownLocation);
//int indexofitemundermousetodrag = this.listBoxSlectedAppInfo.IndexFromPoint(e.X, e.Y);
if (index != ListBox.NoMatches)
{
lb.DoDragDrop(lb.Items[index], DragDropEffects.Move);
}
}
}
private void listBoxSlectedAppInfo_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(WfApplication)))
{
e.Effect = DragDropEffects.Move;
}
}
#endregion
#region 参数列表
private bool IsExistsParamInfo(String ParamName)
{
foreach (WfParam drv in this.listBoxSelectedParam.Items)
{
String Name = drv.Name;
if (Name == ParamName)
{
return true;
}
}
return false;
}
private void AddParamInfo()
{
foreach (WfParam drv in this.listBoxParam.SelectedItems)
{
String ParamName = drv.Name;
if (!IsExistsParamInfo(ParamName))
{
this.listBoxSelectedParam.Items.Add((object)drv);
}
}
}
private void AddAllParamInfo()
{
//this.listBoxAppInfo.Items.Clear();
foreach (WfParam drv in this.listBoxParam.Items)
{
String ParamName = drv.Name;
if (!IsExistsParamInfo(ParamName))
{
this.listBoxSelectedParam.Items.Add((object)drv);
}
}
}
private void DeleteAllSelectParamInfo()
{
ArrayList al = new ArrayList();
foreach (WfParam drv in listBoxSelectedParam.Items)
{
al.Add(drv);
}
foreach (WfParam drv in al)
{
listBoxSelectedParam.Items.Remove((object)drv);
}
}
private void DeleteSelectParamInfoBySelectParam()
{
ArrayList al = new ArrayList();
foreach (WfParam drv in listBoxSelectedParam.SelectedItems)
{
al.Add(drv);
}
foreach (WfParam drv in al)
{
listBoxSelectedParam.Items.Remove((object)drv);
}
//
//al.CopyTo(alTemp);
}
#endregion
#region 参数事件
private void buttonAddParam_Click(object sender, EventArgs e)
{
if (this.listBoxParam.SelectedItems.Count > 0)
{
this.AddParamInfo();
}
else
{
MessageBox.Show("没有参数信息可以添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
this.BindParamsInfo();
}
private void buttonDeleteParam_Click(object sender, EventArgs e)
{
if (this.listBoxSelectedParam.SelectedItems.Count > 0)
{
this.DeleteSelectParamInfoBySelectParam();
}
else
{
MessageBox.Show("请选择要删除的参数信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
BindParamsInfo();
}
private void buttonAddAllParam_Click(object sender, EventArgs e)
{
if (this.listBoxParam.Items.Count > 0)
{
this.AddAllParamInfo();
}
else
{
MessageBox.Show("没有参数信息可以添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
BindParamsInfo();
}
private void buttonDeleteAllParam_Click(object sender, EventArgs e)
{
if (this.listBoxSelectedParam.Items.Count > 0)
{
this.DeleteAllSelectParamInfo();
}
else
{
MessageBox.Show("请选择要删除的参数信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
BindParamsInfo();
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -