123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746 |
-
- using Cksoft.Unity;
- using DllEapEntity;
- using DllHsms;
- using DllPubInfo;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace DllXqManager
- {
- public partial class LayoutMstBaseFor : Form
- {
- private LayoutMst CurrEntity = null;
- private List<LayoutDetail> CurrDs = null;
- //private List<MoveControl> CurrMoveControl = new List<MoveControl>();
- private MachineQuery CurrMachineQuery = null;
- private const int LocX = 20;
- private const int LocY = 20;
- private LayoutDetailBase CurrLayoutDetailBase = null;
- private DataSet ds = null;
- public LayoutMstBaseFor(LayoutMst id)
- {
- InitializeComponent();
- CurrEntity = id;
- //SetCurrID(id);
- ds = GetPcode();
- }
- public void SetCurrID(LayoutMst id)
- {
- //CurrEntity = id;
- InitForm(id);
- }
- private void InitForm(LayoutMst id)
- {
- //foreach (Control item in panel2.Controls)
- //{
- // panel2.Controls.Remove(item);
- // item.Dispose();
- //}
- //panel2.Controls.Clear();
- //panel2.Refresh();
- CurrEntity = id;
- if (CurrEntity == null)
- {
- CurrEntity = new LayoutMst();
- }
- //用实体的值去赋值界面控件显示的值
- string errorinfo = "";
- int result = DllPubInfo.PubInfo.InitFormControl<LayoutMst>(panel1, CurrEntity, null, ref errorinfo);
- if (result < 0)
- MessageBox.Show(errorinfo);
- Filldgvmain(" and a.preid=" + CurrEntity.ID);
- MoveControl.CurrParent = panel2;
- ShowAllEntity();
- Rectory = new SetControlRectangle(panel2);
- Rectory.SetRectangel += new SetControlRectangle.SelectRectangel(Rectory_SetRectangel);
- PubInfo.DefaultLayout = editFCode.Text.Trim();
- }
- private DataSet GetPcode()
- {
- string strsql = $@"SELECT a.FCode FCode,s.FName regionNmae
- from Machine a
- left outer join staff b on a.RecCode =b.FCode
- left outer join staff c on a.ModCode =c.FCode
- left outer join macmodel d on a.MModeID =d.id
- left outer join supplier e on d.SupplierID =e.id
- left outer join mactprocess f on a.id =f.macid
- left outer join tprocess g on f.PCode =g.FCode
- left outer join constitem h on a.CallPMode =h.subid and h.preid=14
- left outer join factoryregion i on a.factoryid =i.id
- left outer join macstatus01 j on a.FCode =j.MacCode
- LEFT JOIN factoryregion s on a.regionid =s.id";
- string error = "";
- DataSet ds = PubInfo.Select(strsql, "layoutmst", ref error);
- return ds;
- }
- private void ShowAllEntity()
- {
- if (CurrDs == null)
- return;
- MoveControl.ClearAllControl();
- //显示实体
- foreach (var temprow in CurrDs)
- ShowSingleEntity(temprow);
- MoveControl.AddFrameControl();
- }
- private void Filldgvmain(string condition)
- {
- try
- {
- Cursor = Cursors.WaitCursor;
- string errorinfo = "";
- CurrDs = PubInfo.SelectForCondition<LayoutDetail>(condition, ref errorinfo).ToList();
- if (CurrDs == null)
- {
- MessageBox.Show(errorinfo);
- return;
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show("操作发生错误,错误信息为:" + ex.Message.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- finally
- {
- Cursor = Cursors.Default;
- }
- //dgvmain.Columns["选择"].ReadOnly = false;
- }
- //将实体显示在面板上
- private int ShowSingleEntity(LayoutDetail row)
- {
- //先查找是否已经显示
- foreach (Control tempcontrol in panel2.Controls)
- {
- if (!(tempcontrol is TEntityControl))
- continue;
- LayoutDetail temprow = (tempcontrol as TEntityControl).CurrEntity;
- if (temprow.ID == row.ID)
- return 1;
- }
- //row["报警代码"] = "AlarmCode";
- //row["status"] = "100";
- if (ds != null)
- {
- //var ds = dsp.Tables[0].AsEnumerable().Where(l => l.Field<string>("FCode")==maccode).Select(l=>l.Field<string>("PCode")).FirstOrDefault();// PubInfo.Select(pcondition, "MacTProcess", ref errorinfo);
- DataRow[] temprows = ds.Tables[0].Select($"FCode='{row.FCode}'", "");
- if (temprows.Length > 0)
- {
- row.FName = temprows[0]["regionNmae"].ToString().Trim();
- }
- }
- TEntityControl control = new TEntityControl(row);
-
- //计算坐标和大小
- int w = (int)(panel2.Width * decimal.Parse(row.SizeW.ToString()));
- int h = (int)(panel2.Height * decimal.Parse(row.SizeH.ToString()));
- int x = (int)(panel2.Width * decimal.Parse(row.LocX.ToString()));
- int y = (int)(panel2.Height * decimal.Parse(row.LocY.ToString()));
- control.Size = new Size(w, h);
- control.Location = new Point(x, y);
- control.BackColor = Color.Gray;
- // control.SetFontColor(Color.Black);
- control.DoubleClick += Control_DoubleClick;
- panel2.Controls.Add(control);
- MoveControl movecontrol = new MoveControl(control, cms);
- return 1;
- }
- private void ShowLayoutDetailBase(LayoutDetail row)
- {
- if (CurrLayoutDetailBase == null)
- {
- CurrLayoutDetailBase = new LayoutDetailBase(row);
- CurrLayoutDetailBase.Owner = this;
- CurrLayoutDetailBase.eventcloseForm += CurrLayoutDetailBase_eventcloseForm;
- CurrLayoutDetailBase.eventModifyEntity += CurrLayoutDetailBase_eventModifyEntity;
- CurrLayoutDetailBase.Show();
- }
- else
- {
- CurrLayoutDetailBase.SetCurrID(row);
- }
- }
- private void CurrLayoutDetailBase_eventModifyEntity(LayoutDetail entity)
- {
- //throw new NotImplementedException();
- foreach (var item in panel2.Controls)
- {
- if (!(item is TEntityControl))
- continue;
- TEntityControl temp = item as TEntityControl;
- if (temp.CurrEntity.ID == entity.ID)
- {
- temp.CurrEntity.ModifyEntity();
- temp.Refresh();
- return;
- }
- }
- }
- private void CurrLayoutDetailBase_eventcloseForm()
- {
- CurrLayoutDetailBase = null;
- }
- private void Control_DoubleClick(object sender, EventArgs e)
- {
- //throw new NotImplementedException();
- TEntityControl control = sender as TEntityControl;
- ShowLayoutDetailBase(control.CurrEntity);
- }
- //将实体显示在面板上
- private int ShowSingleEntityFor(LayoutDetail row, Point pt)
- {
- //先查找是否已经显示
- foreach (Control tempcontrol in panel2.Controls)
- {
- if (!(tempcontrol is TEntityControl))
- continue;
- if (row.EntityTypeID != EntityType.Machine)
- continue;
- LayoutDetail temprow = (tempcontrol as TEntityControl).CurrEntity;
- if (temprow.EntityID == row.EntityID)
- return 1;
- }
- TEntityControl control = new TEntityControl(row);
- //计算坐标和大小
- int w = (int)(panel2.Width * decimal.Parse(row.SizeW.ToString()));
- int h = (int)(panel2.Height * decimal.Parse(row.SizeH.ToString()));
- //int x = (int)(panel2.Width * decimal.Parse(row.LocX.ToString()));
- //int y = (int)(panel2.Height * decimal.Parse(row.LocY.ToString()));
- control.Size = new Size(w, h);
- control.Location = pt;
- control.BackColor = Color.White;
- control.DoubleClick += Control_DoubleClick;
- panel2.Controls.Add(control);
- //将move实例添加到列表,以便以后操作
- MoveControl movecontrol = new MoveControl(control, cms);
- return 1;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- InitForm(null);
- }
- private void button2_Click(object sender, EventArgs e)
- {
- //if(edit代码.Text.Trim()=="")
- //{
- // MessageBox.Show("代码不能为空,请填写!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- // edit代码.Focus();
- // return;
- //}
- if (editFName.Text.Trim() == "")
- {
- MessageBox.Show("名称不能为空,请填写!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- editFName.Focus();
- return;
- }
- string errorinfo = "";
- int result = PubInfo.UpdateRowFormControl(panel1, CurrEntity, ref errorinfo);
- if (result < 0)
- {
- MessageBox.Show("更新数据发生错误:" + errorinfo);
- return;
- }
- UpdateRow();
- List<LayoutDetail> changes = EntityHelper.GetEntityChange<LayoutDetail>(CurrDs);
- LayoutMst resultentity = CallFunction.CallIULayoutMst(CurrEntity, changes);
- if (resultentity != null)
- {
- MessageBox.Show("操作成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- InitForm(resultentity);
- }
- }
- //更新所有实体参数
- private int UpdateRow()
- {
- foreach (Control tempcontrol in panel2.Controls)
- {
- if (!(tempcontrol is TEntityControl))
- continue;
- LayoutDetail row = (tempcontrol as TEntityControl).CurrEntity;
- double w = (double)tempcontrol.Width / (double)panel2.Width;
- double h = (double)tempcontrol.Height / (double)panel2.Height;
- double x = (double)tempcontrol.Left / (double)panel2.Width;
- double y = (double)tempcontrol.Top / (double)panel2.Height;
- row.SizeW = w;
- row.SizeH = h;
- row.LocX = x;
- row.LocY = y;
- row.ModifyEntity();
- }
- return 1;
- }
- private void button3_Click(object sender, EventArgs e)
- {
- //if (CurrDs == null)
- //{
- // InitForm(0);
- // return;
- //}
- //CurrID = 0;
- //CurrDs.Tables[0].Rows[0]["id"] = 0;
- editFCode.Text = "";
- CurrEntity = new LayoutMst();
- }
- private void button4_Click(object sender, EventArgs e)
- {
- //TEntityQuery temp = new TEntityQuery("");
- //temp.eventSelRow += Temp_eventSelRow;
- //temp.ShowDialog();
- if (CurrMachineQuery != null)
- return;
- CurrMachineQuery = new MachineQuery(CurrDs);
- //temp.eventSelRow += Temp_eventSelRow;
- CurrMachineQuery.eventCloseForm += CurrMachineQuery_eventCloseForm;
- CurrMachineQuery.Owner = this;
- CurrMachineQuery.Show();
- }
- private void CurrMachineQuery_eventCloseForm()
- {
- CurrMachineQuery = null;
- }
- private void Temp_eventSelRow(List<TEntity> rows, int seltype)
- {
- double x = 0;
- double y = 0;
- foreach (var temprow in rows)
- {
- List<LayoutDetail> templist = CurrDs.Where(t => t.EntityID == temprow.ID).ToList();
- if (templist.Count > 0)
- continue;
- x += 0.01;
- y += 0.01;
- LayoutDetail addrow = AddDetail(temprow);
- addrow.LocX = x;
- addrow.LocY = y;
- ShowSingleEntity(addrow);
- }
- //Binddgvmain();
- }
- private LayoutDetail AddDetail(TEntity row)
- {
- LayoutDetail addrow = new LayoutDetail();
- CurrDs.Add(addrow);
- int? minid = CurrDs.Where(t => t.ID < 0).Min(t => (int?)t.ID);
- int id = minid == null ? -1 : minid.Value - 1;
- addrow.ID = id;
- addrow.EntityID = row.ID;
- addrow.FCode = row.FCode;
- addrow.FName = row.FName;
- addrow.IPAddress = row.FIP;
- addrow.LocX = 0;
- addrow.LocY = 0;
- addrow.SizeW = 0.1;
- addrow.SizeH = 0.1;
- addrow.FontSize = 9;
- addrow.FColor = "";
- return addrow;
- }
- private LayoutDetail AddDetailFor(LayoutDetail addrow)
- {
- List<MoveControl> sels = MoveControl.FindSelControl();
- //LayoutDetail addrow = new LayoutDetail();
- CurrDs.Add(addrow);
- int? minid = CurrDs.Where(t => t.ID < 0).Min(t => (int?)t.ID);
- int id = minid == null ? -1 : minid.Value - 1;
- addrow.ID = id;
- //addrow.EntityTypeID = EntityType.Machine;
- //addrow.EntityID = row.ID;
- //addrow.FCode = row.FCode;
- //addrow.FName = row.FName;
- //addrow.IPAddress = row.IPAddress;
- addrow.LocX = 0;
- addrow.LocY = 0;
- addrow.SizeW = 0.1;
- addrow.SizeH = 0.1;
- if (sels.Count > 0)
- {
- addrow.SizeW = (double)(sels[0].currentControl as TEntityControl).Width / (double)panel2.Width;
- addrow.SizeH = (double)(sels[0].currentControl as TEntityControl).Height / (double)panel2.Height;
- }
- addrow.FontSize = 9;
- addrow.FColor = "";
- return addrow;
- }
- //private DataRow AddDetail(DataRow row)
- //{
- // DataRow addrow = CurrDs.Tables[CurrDetailTableName].NewRow();
- // CurrDs.Tables[CurrDetailTableName].Rows.Add(addrow);
- // object obj = CurrDs.Tables[CurrDetailTableName].Compute("min(id)", "id<0");
- // int id = obj.ToString() == "" ? -1 : int.Parse(obj.ToString()) - 1;
- // addrow["id"] = id;
- // addrow["EntityID"] = row["ID"];
- // addrow["实体代码"] = row["代码"];
- // addrow["实体名称"] = row["名称"];
- // addrow["IP地址"] = row["IP地址"];
- // addrow["X坐标"] = 0;
- // addrow["Y坐标"] = 0;
- // addrow["宽度"] = 100;
- // addrow["高度"] = 100;
- // addrow["字体大小"] = 9;
- // addrow["字体颜色"] = "";
- // // public static string LayoutDetail = "select 0 选择,b.FCode 实体代码,b.FName 实体名称,b.FIP IP地址,a.LocX X坐标,a.LocY Y坐标,a.SizeW 宽度"
- // //+ ",a.SizeH 高度,a.FontSize 字体大小,a.FColor 字体颜色,a.remark 备注"
- // return addrow;
- //}
- private void LayoutMstBaseFor_Shown(object sender, EventArgs e)
- {
- InitForm(CurrEntity);
- }
- //获取选中的控件
- private Control GetSelControl()
- {
- foreach (Control tempcontrol in panel2.Controls)
- {
- if (tempcontrol is FrameControl)
- {
- return (tempcontrol as FrameControl).baseControl;
- }
- }
- return null;
- }
- private Form CurrForm = null;
- public void CloseCurrForm()
- {
- CurrForm = null;
- }
- private void 属性ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- //TEntityControl temp = (TEntityControl)GetSelControl();
- //if (temp == null)
- // return;
- //ShowBase(temp);
- }
- private SetControlRectangle Rectory;
- void Rectory_SetRectangel(object sneder, Rectangle e)
- {
- this.Text = e.ToString();
- int x = e.X;
- int w = e.Width;
- int y = e.Y;
- int h = e.Height;
- if (e.Width < 0)
- {
- x = x - e.Width * -1;
- w = w * -1;
- }
- if (h < 0)
- {
- y = y - h * -1;
- h = h * -1;
- }
- Rectangle selrect = new Rectangle(x, y, w, h);
- foreach (MoveControl item in MoveControl.CurrList)
- {
- Rectangle temp = new Rectangle(item.currentControl.Location.X, item.currentControl.Location.Y, item.currentControl.Size.Width, item.currentControl.Size.Height);
- if (selrect.IntersectsWith(temp))
- {
- item.IsSelected = true;
- }
- }
- MoveControl.AddFrameControl();
- }
- private void LayoutMstBaseFor_Load(object sender, EventArgs e)
- {
- }
- private void 顶端对齐ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- List<MoveControl> sels = MoveControl.FindSelControl();
- if (sels.Count <= 1)
- return;
- MoveControl.ClearFrameControl();
- //panel2.Refresh();
- TEntityControl descontrol = cms.Tag as TEntityControl;
- foreach (var item in sels)
- {
- item.currentControl.Location = new Point(item.currentControl.Location.X, descontrol.Location.Y);
- }
- MoveControl.AddFrameControl();
- }
- private void panel2_Paint(object sender, PaintEventArgs e)
- {
- //ShowAllEntity();
- }
- private void button5_Click(object sender, EventArgs e)
- {
- List<MoveControl> sels = MoveControl.FindSelControl();
- foreach (MoveControl item in sels)
- {
- if (item.fc != null)
- {
- panel2.Controls.Remove(item.fc);
- item.fc.Dispose();
- item.fc = null;
- }
- }
- panel2.Refresh();
- //for(int i=panel2.Controls.Count-1;i>=0;i--)
- //{
- // panel2.Controls.Remove(panel2.Controls[i]);
- //}
- //panel2.Controls.Clear();
- //for(int i=MoveControl.CurrList.Count-1;i>=0;i--)
- //{
- // MoveControl.CurrList[i].ClearControl();
- //}
- //panel2.Refresh();
- //MoveControl.ClearAllControl();
- //panel2.Refresh();
- //foreach (MoveControl item in MoveControl.CurrList)
- //{
- // if(item.fc!=null)
- // {
- // panel2.Controls.Remove(item.fc);
- // item.fc = null;
- // }
- // item.currentControl.Refresh();
- //}
- //panel2.Refresh();
- //List<FrameControl> fclist = new List<FrameControl>();
- //foreach(Control item in panel2.Controls)
- //{
- // //if (item is TEntityControl)
- // // continue;
- // //panel2.Controls.Remove()
- // if (item is FrameControl)
- // fclist.Add(item as FrameControl);
- //}
- //foreach (FrameControl fc in fclist)
- // panel2.Controls.Remove(fc);
- //panel2.Refresh();
- }
- private void toolStripMenuItem1_Click(object sender, EventArgs e)
- {
- List<MoveControl> sels = MoveControl.FindSelControl();
- if (sels.Count <= 1)
- return;
- MoveControl.ClearFrameControl();
- //panel2.Refresh();
- TEntityControl descontrol = cms.Tag as TEntityControl;
- int desy = descontrol.Location.Y;
- int desh = descontrol.Size.Height;
- int y = 0;
- foreach (var item in sels)
- {
- y = desy + desh - item.currentControl.Size.Height;
- if (y < 0)
- y = 0;
- item.currentControl.Location = new Point(item.currentControl.Location.X, y);
- }
- MoveControl.AddFrameControl();
- }
- private void 左对齐ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- List<MoveControl> sels = MoveControl.FindSelControl();
- if (sels.Count <= 1)
- return;
- MoveControl.ClearFrameControl();
- //panel2.Refresh();
- TEntityControl descontrol = cms.Tag as TEntityControl;
- int desx = descontrol.Location.X;
- //int desh = descontrol.Size.Height;
- int y = 0;
- foreach (var item in sels)
- {
- item.currentControl.Location = new Point(desx, item.currentControl.Location.Y);
- }
- MoveControl.AddFrameControl();
- }
- private void 右对齐ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- List<MoveControl> sels = MoveControl.FindSelControl();
- if (sels.Count <= 1)
- return;
- MoveControl.ClearFrameControl();
- //panel2.Refresh();
- TEntityControl descontrol = cms.Tag as TEntityControl;
- int desx = descontrol.Location.X;
- int desw = descontrol.Size.Width;
- int x = 0;
- foreach (var item in sels)
- {
- x = desx + desw - item.currentControl.Size.Width;
- item.currentControl.Location = new Point(x, item.currentControl.Location.Y);
- }
- MoveControl.AddFrameControl();
- }
- private void 相同宽度ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- List<MoveControl> sels = MoveControl.FindSelControl();
- if (sels.Count <= 1)
- return;
- MoveControl.ClearFrameControl();
- //panel2.Refresh();
- TEntityControl descontrol = cms.Tag as TEntityControl;
- //int desx = descontrol.Location.X;
- int desw = descontrol.Size.Width;
- foreach (var item in sels)
- {
- item.currentControl.Size = new Size(desw, item.currentControl.Height);
- }
- MoveControl.AddFrameControl();
- }
- private void 相同高度ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- List<MoveControl> sels = MoveControl.FindSelControl();
- if (sels.Count <= 1)
- return;
- MoveControl.ClearFrameControl();
- //panel2.Refresh();
- TEntityControl descontrol = cms.Tag as TEntityControl;
- //int desx = descontrol.Location.X;
- int desh = descontrol.Size.Height;
- foreach (var item in sels)
- {
- item.currentControl.Size = new Size(item.currentControl.Width, desh);
- }
- MoveControl.AddFrameControl();
- }
- private void 相同大小ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- List<MoveControl> sels = MoveControl.FindSelControl();
- if (sels.Count <= 1)
- return;
- MoveControl.ClearFrameControl();
- //panel2.Refresh();
- TEntityControl descontrol = cms.Tag as TEntityControl;
- foreach (var item in sels)
- {
- item.currentControl.Size = new Size(descontrol.Size.Width, descontrol.Size.Height);
- }
- MoveControl.AddFrameControl();
- }
- private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- List<MoveControl> sels = MoveControl.FindSelControl();
- if (sels.Count <= 0)
- return;
- MoveControl.ClearFrameControl();
- foreach (var item in sels)
- {
- LayoutDetail tempentity = (item.currentControl as TEntityControl).CurrEntity;
- tempentity.DeleteEntity(CurrDs);
- panel2.Controls.Remove(item.currentControl);
- MoveControl.CurrList.Remove(item);
- }
- MoveControl.ClearFrameControl();
- panel2.Refresh();
- }
- private void 水平等距离ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- List<MoveControl> sels = MoveControl.FindSelControl().OrderBy(t => t.currentControl.Location.X).ToList();
- if (sels.Count <= 1)
- return;
- int count = sels.Count;
- int spacing = sels[count - 1].currentControl.Location.X - sels[0].currentControl.Location.X;
- for (int i = 0; i < count - 1; i++)
- {
- spacing = spacing - sels[i].currentControl.Size.Width;
- }
- int avgspacing = spacing / (count - 1);
- int x = sels[0].currentControl.Location.X;
- for (int i = 1; i < count; i++)
- {
- x += sels[i - 1].currentControl.Size.Width + avgspacing;
- sels[i].currentControl.Location = new Point(x, sels[i].currentControl.Location.Y);
- }
- MoveControl.AddFrameControl();
- }
- private void panel2_DragEnter(object sender, DragEventArgs e)
- {
- e.Effect = DragDropEffects.Move;
- }
- private void panel2_DragDrop(object sender, DragEventArgs e)
- {
- Type mactype = typeof(List<LayoutDetail>);
- List<LayoutDetail> details = (List<LayoutDetail>)e.Data.GetData(mactype);
- Point pt = panel2.PointToClient(new Point(e.X, e.Y));
- details = details.OrderBy(t => t.FCode).ToList();
- foreach (LayoutDetail detail in details)
- {
- AddDetailFor(detail);
- ShowSingleEntityFor(detail, pt);
- pt.X += LocX;
- pt.Y += LocY;
- }
- CurrMachineQuery.Binddgvmain();
- }
- private void button6_Click(object sender, EventArgs e)
- {
- List<MoveControl> sels = MoveControl.FindSelControl();
- foreach (MoveControl item in sels)
- {
- item.fc = new FrameControl(item.currentControl);
- panel2.Controls.Add(item.fc);
- //item.currentControl.BringToFront();
- item.fc.BringToFront();
- item.fc.Visible = true;
- item.fc.Draw();
- }
- }
- private void panel2_Resize(object sender, EventArgs e)
- {
- //ShowAllEntity();
- }
- private void toolStripMenuItem2_Click(object sender, EventArgs e)
- {
- List<MoveControl> sels = MoveControl.FindSelControl().OrderBy(t => t.currentControl.Location.Y).ToList();
- if (sels.Count <= 1)
- return;
- int count = sels.Count;
- int spacing = sels[count - 1].currentControl.Location.Y - sels[0].currentControl.Location.Y;
- for (int i = 0; i < count - 1; i++)
- {
- spacing = spacing - sels[i].currentControl.Size.Height;
- }
- int avgspacing = spacing / (count - 1);
- int y = sels[0].currentControl.Location.Y;
- for (int i = 1; i < count; i++)
- {
- y += sels[i - 1].currentControl.Size.Height + avgspacing;
- sels[i].currentControl.Location = new Point(sels[i].currentControl.Location.X, y);
- }
- MoveControl.AddFrameControl();
- }
- }
- }
|