123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.Xml;
- using System.IO;
- using System.Collections;
- namespace FPER {
- public partial class FormField : Form
- { // field form class
- public XMLReader xmlR = null;
- public List<XMLField> xField = null;
- public Dev_Type_Set DataType_Set = null;
- List<Button> LButton = new List<Button>();
- public ArrayList lActLoop = new ArrayList();
- Graphics g;
- int iGetDataIndex = 0;
- // cyim 2013.7.31 타화면전환시 화면갱신이 늦게 되는 문제
- // 현장도면에서 곧바로 설비연동 화면으로 진입시 화면갱신이 늦게되는 문제
- // 근본적인 문제는 현장도면에서 정보를 요청하는것이 있는 경우에 (버튼 연타도 마찬가지) 데몬이 늦게 응답해주어서 발생되는 문제이다.
- // 즉, 응답오기전까지는 누르지 못하게 막음. 단, 화면전환이후 화면갱신이 느리게 될수있는 여지가 있다
- bool CommDaemonAck_Received = false;
- public FormField(List<XMLField> xField, Dev_Type_Set DataType_Set)
- {
- InitializeComponent();
- this.xField = xField;
- this.DataType_Set = DataType_Set;
- // this.SetLTypeImage();
- g = panel1.CreateGraphics();
- g.Clear(SystemColors.ControlLight);
- }
- MDIParent mdi = null;
- private void FormField_Load(object sender, EventArgs e)
- {
- // cyim 2013.8.1 : 더블버퍼링 적용
- SetStyle(ControlStyles.UserPaint, true);
- //this.UpdateStyles();
- SetStyle(ControlStyles.AllPaintingInWmPaint, true);
- //this.UpdateStyles();
- SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
- this.UpdateStyles();
-
- // form load event
- this.mdi = (MDIParent)this.MdiParent;
- this.mdi.SelectMenuIndex = 7;
- this.init();
- }
- private void init()
- { // init form data
- if (xField != null)
- {
- // //Util.UDebugMessage("xField.Length = " + xField.Count.ToString(), 0, 0);
- this.comboBox1.Items.Clear();
- foreach (XMLField field in xField)
- {
- this.comboBox1.Items.Add(field.Name);
- }
- if (xField.Count > 0)
- {
- this.comboBox1.SelectedIndex = 0;
- }
- }
- }
- void GetAllDataListForce()
- { // ActiveLoop 리스트의 데이터를 읽는다. (에러 체크 하지 않음.)
- //foreach (Loop loop in this.LActiveLoop) {
- // this.getData(loop.boardID, loop.loopNo);
- // System.Threading.Thread.Sleep(50);
- //}
- int iBoardID = 0;
- int iLoopNo = 0;
- for (int iLoop = 0; iLoop < lActLoop.Count; iLoop++)
- {
- iBoardID = Convert.ToInt16(lActLoop[iLoop]) / 10;
- iLoopNo = Convert.ToInt16(lActLoop[iLoop]) % 10;
- this.getData(iBoardID, iLoopNo);
- System.Threading.Thread.Sleep(200);
- }
- // iGetDataIndex = 0;
- }
- void GetDataList()
- {
- if (lActLoop.Count > 0)
- {
- int iBoardID = Convert.ToInt16(lActLoop[iGetDataIndex]) / 10;
- int iLoopNo = Convert.ToInt16(lActLoop[iGetDataIndex]) % 10;
- this.getData(iBoardID, iLoopNo);
- System.Threading.Thread.Sleep(200);
- iGetDataIndex++;
- if (iGetDataIndex >= lActLoop.Count)
- {
- iGetDataIndex = 0;
- }
- }
- }
- void GetAllDataList()
- { // ActiveLoop 리스트의 데이터를 통신상 에러를 체크 하면서 읽음.
- /*
- foreach(Loop loop in this.LActiveLoop){
- if (loop.calltime > 0 && Environment.TickCount - loop.calltime > 5000) {
- this.SetComunicationError(loop.boardID,loop.loopNo,-4);// time out
- }
- bool get = this.getData(loop.boardID, loop.loopNo);
- if (get == false) {
- this.SetComunicationError(loop.boardID, loop.loopNo, -3);// deamon error
- }
- if (loop.calltime < 0) {
- loop.calltime = Environment.TickCount;
- }
- System.Threading.Thread.Sleep(200);
- }
- */
- int iBoardID = 0;
- int iLoopNo = 0;
- for (int iLoop = 0; iLoop < lActLoop.Count; iLoop++)
- {
- iBoardID = Convert.ToInt16(lActLoop[iLoop]) / 10;
- iLoopNo = Convert.ToInt16(lActLoop[iLoop]) % 10;
- //if (loop.calltime > 0 && Environment.TickCount - loop.calltime > 5000)
- //{
- // this.SetComunicationError(iBoardID, iLoopNo, -4);// time out
- //}
- bool get = this.getData(iBoardID, iLoopNo);
- if (get == false)
- {
- this.SetComunicationError(iBoardID, iLoopNo, -3);// deamon error
- }
- //if (loop.calltime < 0)
- //{
- // loop.calltime = Environment.TickCount;
- //}
- System.Threading.Thread.Sleep(200);
- }
- }
- void SetComunicationError(int boardID, int loopNo, int errorCode)
- {// set error image
- // int index = 0;
- foreach (XMLDevice dev in this.xField[this.comboBox1.SelectedIndex].LDevice)
- {
- if (dev.Board_ID == boardID && dev.Loop_No == loopNo)
- {
- UpdateDev(dev, errorCode);
- }
- // index++;
- }
- }
- /*
- Loop GetLoop(int boardID, int loopNo) { // set upload loop
- Loop ret = null;
- foreach (Loop loop in this.LActiveLoop) {
- if (loop.Match(boardID, loopNo)) {
- ret = loop;
- break;
- }
- }
- return ret;
- }
- */
- bool getData(int BoardID, int Loop)
- {
- // cyim 2013.7.31 타화면전환시 화면갱신이 늦게 되는 문제
- if (CommDaemonAck_Received == true)
- {
- return false;
- }
- else
- {
- CommDaemonAck_Received = true;
- // loop data upload function
- bool ret = false;
- MDIParent mdi = (MDIParent)this.MdiParent;
- dCommandResponse d = new dCommandResponse(UpdateData);
- CmdInfo cmd = new CmdInfo(prt_cmd_define.read_repeater_all, mdi.myReceiverID, 1, Loop, BoardID, d);
- ret = mdi.ui.runCommand(cmd);
- return ret;
- }
- }
- // 현장도면에서도 차단표시를 합니다.
- // frmControlMode.cs 에서 사용하는 함수명은 동일하지만 파라미터가 틀립니다.
- // frmControlMode.cs 에서는 중계기 단위로 체크하지만 , FormField.cs 에서는 디바이스별로 체크해야 합니다
- // cyim 2013.10.2 : 차단 표시
- private bool Repeater_GetData_Circuit_CutInfo(RepeaterDeviceTypeInfo repinfo, XMLDevice dev)
- {
- if (dev == null) return false;
- // 입력인지 출력인지 구분
- if (dev.Inout_Type == "I")
- {
- if (repinfo.inDeviceTypeInfos[dev.Device_ID - 1] == null)
- return false;
- else
- return repinfo.inDeviceTypeInfos[dev.Device_ID - 1].CutFlag;
- }
- else
- {
- if (repinfo.outDeviceTypeInfos[dev.Device_ID - 1] == null)
- return false;
- else
- return repinfo.outDeviceTypeInfos[dev.Device_ID - 1].CutFlag;
- }
- }
- public void UpdateData(CmdInfo cmd)
- {// device data update
- try
- {
- // MDIParent mdi = (MDIParent)this.MdiParent;
- //Loop loop = this.GetLoop(cmd.boardNo, cmd.loopNo);
- //if (loop != null) {
- // loop.calltime = -1;
- //}
- // cyim 2013.7.31 타화면전환시 화면갱신이 늦게 되는 문제
- CommDaemonAck_Received = false;
- //try {
- if (cmd.ResponseData is RCVData_NACK)
- {
- #if _DEBUG
- //Util.UDebugMessage("UpdateData RCVData_NACK", 0, 0);
- #endif
- this.SetComunicationError(cmd.boardNo, cmd.loopNo, -2);// nack error : board error
- }
- if (cmd.ResponseData is RCVData_ReadRepeaterPointAll)
- {
- RCVData_ReadRepeaterPointAll ResponseData = (RCVData_ReadRepeaterPointAll)cmd.ResponseData;
- RepeaterData[] data = ResponseData.Data;
- if (cmd.Command == prt_cmd_define.read_repeater_all || cmd.ResCommand == prt_res_define.read_repeater_all)
- {
- /*if (savBoardID == cmd.boardNo && savLoop == cmd.loopNo) */
- {
- ReceiverTypeInfo Receiverinfo = mdi.ui.MyReceiverTypeInfo; //수신기설정
- BoardTypeInfo brdinfo = Receiverinfo.Get_RepeaterType(ResponseData.TBD_ID); //통신보드savBoardID의 loop0의 설정값
- RepeaterDeviceTypeInfo[] repinfo;
- RepeaterPointUnit[] repdata;
- // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경
- if (ResponseData.Repeater_loop == 0)
- {
- repinfo = brdinfo.Loop0_RepeaterType; //통신보드 + Loop0 + 127개 중계기 설정값
- repdata = brdinfo.Loop0_RepeaterUnit_Data; //127개 중계기 데이터
- }
- else if (ResponseData.Repeater_loop == 1)
- {
- repinfo = brdinfo.Loop1_RepeaterType; //통신보드 + Loop1 + 127개 중계기 설정값
- repdata = brdinfo.Loop1_RepeaterUnit_Data; //127개 중계기 데이터
- }
- else if (ResponseData.Repeater_loop == 2)
- {
- repinfo = brdinfo.Loop2_RepeaterType; //통신보드 + Loop2 + 127개 중계기 설정값
- repdata = brdinfo.Loop2_RepeaterUnit_Data; //127개 중계기 데이터
- }
- else if (ResponseData.Repeater_loop == 3)
- {
- repinfo = brdinfo.Loop3_RepeaterType; //통신보드 + Loop3 + 127개 중계기 설정값
- repdata = brdinfo.Loop3_RepeaterUnit_Data; //127개 중계기 데이터
- }
- else
- {
- repinfo = null;
- repdata = null;
- }
- // int index = 0;
- foreach (XMLDevice dev in this.xField[this.comboBox1.SelectedIndex].LDevice)
- {
- if (dev.DevID != "")
- {
- int a = dev.Device_ID;
- if (dev.Board_ID == cmd.boardNo && dev.Loop_No == cmd.loopNo)
- {
- int status = -100;// unkonun error
- if (repdata[dev.Repeater_ID - 1].RepeaterErr)
- {
- status = -1;// repeater comm error
- }
- // cyim 2013.10.2 : 차단 표시 (중계기 차단)
- else if (repinfo[dev.Repeater_ID - 1].CutFlag == true)
- {
- status = 4; // 차단 상태값
- }
- // cyim 2013.10.2 : 차단 표시 (회로 차단)
- else if (Repeater_GetData_Circuit_CutInfo(repinfo[dev.Repeater_ID - 1], dev) == true)
- {
- status = 4; // 차단 상태값
- }
- else if (dev.Inout_Type == "I")
- {
- switch (dev.Device_ID)
- {
- case 1:
- status = data[dev.Repeater_ID - 1].Repeater_state_1;
- break;
- case 2:
- status = data[dev.Repeater_ID - 1].Repeater_state_2;
- break;
- case 3:
- status = data[dev.Repeater_ID - 1].Repeater_state_3;
- break;
- case 4:
- status = data[dev.Repeater_ID - 1].Repeater_state_4;
- break;
- }
- }
- else
- {
- switch (dev.Device_ID)
- {
- case 1:
- status = data[dev.Repeater_ID - 1].Repeater_output_1_W ? 0 : 1;
- break;
- case 2:
- status = data[dev.Repeater_ID - 1].Repeater_output_2_W ? 0 : 1;
- break;
- case 3:
- status = data[dev.Repeater_ID - 1].Repeater_output_3_W ? 0 : 1;
- break;
- case 4:
- status = data[dev.Repeater_ID - 1].Repeater_output_4_W ? 0 : 1;
- break;
- }
- }
- //if(status != -1) {
- //this.UpdateDevImage(index, status, dev.Device_Type);
- UpdateDev(dev, status);
- //}
- }
- }
- // index++;
- }
- //for (int repeaterNo = 0; repeaterNo < data.Length; repeaterNo++) {
- // RepeaterPointUnit newdata = new RepeaterPointUnit(repeaterNo + 1, data[repeaterNo]);
- // //데이터저장
- // repdata[repeaterNo] = newdata;
- // //각 셀에 중계기 데이터 표시
- // //GRIDCELL[repeaterNo].Set_DeviceUnit(newdata);
- //}
- //선택된 셀의 데이터를 dataGridView2에 표시한다..
- //dataGridView1_SelectionChanged(dataGridView1, System.EventArgs.Empty);
- }
- }
- }
- //}
- //catch (Exception ex) {
- // MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.Source), Application.ProductName);
- //}
- //finally {
- // //버튼 비활성 해제
- // //button_end(true);
- //}
- ////정상응답처리-------------------------------------------끝
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- void ClearActiveLoop()
- {
- lActLoop.Clear();
- }
- void AddActiveLoop(int iBoardID, int iLoopNo)
- {
- // cyim 2013.7.3 아이콘깜빡임 문제 수정
- // 디버깅 결과, NACK 가 들어오면서 화면이 물음표로 전환되는 것이 문제로 판단됩니다.
- // NACK 를 받는 이유는 FieldSetting.xml 에 회로번호가 널값이라면 통신보드 0으로 인식하여 이에 해당하는 패킷을 생성 및 요청하게 되므로
- // NACK 가 들어올 수 밖에 없습니다. (당연히 물리적으로 통신보드 아이디값 0 은 존재하지 않습니다)
- // 즉, 다시 물음표로 보였다가 다시 정상동작 아이콘으로 반복 표시되는 현상이 발생하는 것입니다.
- // 회로번호 널값에 의한 통신보드 0 값은 통신요청하지 않도록 수정합니다
- if (iBoardID == 0) return;
-
- int iConvert = iBoardID * 10 + iLoopNo;
- if (lActLoop.Contains(iConvert) == false)
- {
- lActLoop.Add(iConvert);
- }
- }
- /*
- List<Loop> LActiveLoop = new List<Loop>();
- void ClearLActiveLoop() {// clear update loop
- this.LActiveLoop.Clear();
- }
- void AddLActiveLoop(int boardID, int loopNo) { // add update loop
- bool add = true;
- foreach (Loop loop in LActiveLoop) {
- if (loop.Match(boardID, loopNo)) {
- add = false;
- break;
- }
- }
- if (add) {
- this.LActiveLoop.Add(new Loop(boardID, loopNo));
- }
- }
- class Loop { // loop class
- public int boardID = -1;
- public int loopNo = -1;
- public int calltime = -1;
- public Loop(int boardID , int loopNo) {
- this.boardID = boardID;
- this.loopNo = loopNo;
- }
- public bool Match(int boardID, int loopNo) { // check same loop
- bool ret = false;
- if (this.boardID == boardID && this.loopNo == loopNo) {
- ret = true;
- }
- return ret;
- }
- }
- */
- Image GetTypeImage(string imgType)
- { // get base type image form list
- Image ret = null;
- ret = DataType_Set.GetDevImage(imgType);
- return ret;
- }
- int selectedFieldIndex = -1;
- private void SetField(int fieldIndex)
- {// set base filed image
- try
- {
- // cyim 2013.3.15 화면깜빡임 문제 수정 -> cyim 2013.7.3 원복함 : 다른페이지 전환시 팝업창이 남아있다
- // 아래의 코드가 제일 문제이다. 아래 코드가 적용되면 당연히 디바이스 팝업창이 사라지면서 Paint 함수를 중복 호출이 되어버린다..
- if (formDevice != null && formDevice.Created)
- {
- this.formDevice.Visible = false;
- }
-
- if (this.selectedFieldIndex != fieldIndex && xField != null)
- // if (xField != null)
- {
- #if _DEBUG
- //Util.UDebugMessage(string.Format("SetField fieldIndex = {0} , xField.Count= {1}, TickCount = {2}", fieldIndex, xField.Count, Environment.TickCount), 0, 100);
- #endif
- this.selectedFieldIndex = fieldIndex;
- if (xField.Count > fieldIndex && xField[fieldIndex] != null)
- { // XML Field 가 생성되었고, XML Field의 수가 FieldIndex보다 큰 경우 수행..
- this.timer1.Stop();
- // 통신을 수행할 통신보드/루프 리스트를 초기화 한다.
- //this.ClearLActiveLoop();
- ClearActiveLoop();
- // cyim 2013.3.15 화면깜빡임 문제 수정
- // 그래픽 화면을 지운다.
- //g.Clear(SystemColors.Control);
- #if _DEBUG
- //Util.UDebugMessage(string.Format("+SetField SetBaseImage TickCount = {0}", Environment.TickCount), 0, 100);
- #endif
- XMLField field = xField[fieldIndex]; // XML Field 재 생성
- this.SetBaseImage(field.imagePath); // 배경 이미지를 그린다.
- #if _DEBUG
- //Util.UDebugMessage(string.Format("-SetField UpdateXMLFieldData TickCount = {0}", Environment.TickCount), 0, 100);
- #endif
- try
- {
- for (int i = 0; i < field.Count_Dev; i++)
- { // FieldIndex에 해당하는 포인트 데이터갯수만큼 루프를 돈다.
- XMLDevice dev = field.LDevice[i]; //
- //this.AddLActiveLoop(dev.Board_ID, dev.Loop_No); // 현재 화면에 해당하는 BoardID와 LoopNO를 리스트로 구성한다.
- AddActiveLoop(dev.Board_ID, dev.Loop_No);
- this.xField[fieldIndex].LDevice[i].Image = DataType_Set.GetDevImagePath(xField[fieldIndex].LDevice[i].DevIconID);
- this.SetDevImage(xField[fieldIndex].LDevice[i]); // 디바이스 이미지를 화면에 표출한다.
- }
- for (int i = 0; i < xField[fieldIndex].LButton.Count; i++)
- {
- SetBtnImage(xField[fieldIndex].LButton[i]);
- }
- this.GetAllDataListForce(); // Active Loop 내의 데이터를 (에러체크 하지 않고) 읽는다.
- // 화면의 초기 업데이트를 위해서 읽는 것 같다.
- // 데이터 읽기 Index를 0 으로 리셋한다.
- iGetDataIndex = 0;
- #if _DEBUG
- //Util.UDebugMessage(string.Format("-SetField XMLDevice TickCount = {0}", Environment.TickCount), 0, 100);
- #endif
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- #if _DEBUG
- //Util.UDebugMessage(string.Format("+SetField SetButtonImage TickCount = {0}", Environment.TickCount), 0, 100);
- #endif
- // foreach (XMLButton button in xField[fieldIndex].LButton) {
- // this.SetButtonImage(button);
- // }
- #if _DEBUG
- //Util.UDebugMessage(string.Format("+SetField SetButtonImage TickCount = {0}", Environment.TickCount), 0, 100);
- #endif
- this.timer1.Start();
- } // if (xField.Count > fieldIndex && xField[fieldIndex] != null)
- } // if (xField != null)
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- public void SetBaseImage(string img_path)
- {// set filed base image
- //panel1.BackgroundImage = Image.FromFile(img_path);
- //g.DrawImage(Image.FromFile(img_path), 0, 0);
- // cyim 2013.7.3 해상도에 따른 이미지 크기가 변경되는 문제 수정 (상위 주석처리함)
- Image Temp = Image.FromFile(img_path);
- g.DrawImage(Temp, 0, 0, Temp.Width, Temp.Height);
- }
- public void UpdateDev(XMLDevice device, int status)
- {
- if (device.Image == "")
- {
- #if _DEBUG
- //Util.UDebugMessage(string.Format("SetDevImage icon_path == null "), 0, 0);
- #endif
- }
- else
- {
- // Graphics g = panel1.CreateGraphics();
- Bitmap m_Dev = new Bitmap(GetTypeImage(device.DevIconID));
- g.DrawImage(m_Dev, device.Xposition, device.Yposition, m_Dev.Width, m_Dev.Height); // cyim 2013.7.3 해상도에 따른 이미지 크기가 변경되는 문제 수정
- string sPath = System.IO.Path.GetDirectoryName(device.Image);
- switch (status)
- {
- case 0: // 감지
- if (device.dev_type == "IC") // 설비 입력
- {
- Bitmap m_Detect = new Bitmap(Path.Combine(sPath, "설비동작.png")); // 파랑 ㅁ
- g.DrawImage(m_Detect, device.Xposition, device.Yposition, m_Detect.Width, m_Detect.Height); // cyim 2013.7.3 해상도에 따른 이미지 크기가 변경되는 문제 수정
- }
- else if ((device.dev_type == "IA") || (device.dev_type == "IB"))
- {
- Bitmap m_Detect = new Bitmap(Path.Combine(sPath, "화재감지.png")); // 빨강 ㅁ
- g.DrawImage(m_Detect, device.Xposition, device.Yposition, m_Detect.Width, m_Detect.Height);// cyim 2013.7.3 해상도에 따른 이미지 크기가 변경되는 문제 수정
- }
- break;
- case 1: // 정상
- break;
- case 3: // 단선
- Bitmap m_Broken = new Bitmap(Path.Combine(sPath, "Error.png"));// X
- g.DrawImage(m_Broken, device.Xposition, device.Yposition, m_Broken.Width, m_Broken.Height); // cyim 2013.7.3 해상도에 따른 이미지 크기가 변경되는 문제 수정
- break;
- // cyim 2013.10.2 : 차단 표시 (회로 차단)
- case 4:
- Bitmap m_Cut = new Bitmap(Path.Combine(sPath, "차단.png")); // =
- g.DrawImage(m_Cut, device.Xposition, device.Yposition, m_Cut.Width, m_Cut.Height);
- break;
- default: // 중계기 이상 (status = -1)
- Bitmap m_Odd = new Bitmap(Path.Combine(sPath, "중계기이상.png")); // ?
- g.DrawImage(m_Odd, device.Xposition, device.Yposition, m_Odd.Width, m_Odd.Height); // cyim 2013.7.3 해상도에 따른 이미지 크기가 변경되는 문제 수정
- break;
- }
- device.status = status;
- // g.Dispose();
- }
- }
- public void SetBtnImage(XMLButton button)
- {
- // Graphics g = panel1.CreateGraphics();
- Bitmap m_Dev = new Bitmap(button.ImagePath);
- g.DrawImage(m_Dev, button.Xposition, button.Yposition, m_Dev.Width, m_Dev.Height);// cyim 2013.7.3 해상도에 따른 이미지 크기가 변경되는 문제 수정
- // g.Dispose();
- }
- /*
- public void SetButtonImage(XMLButton button) { // set button image to field
- #if _DEBUG
- //Util.UDebugMessage(string.Format("+SetButtonImage "), 0, 0);
- #endif
- Button btnMove = new Button();
- this.LButton.Add(btnMove);
-
- btnMove.Parent = this.panel1;
- btnMove.Location = new Point(button.xposition, button.yposition);
- btnMove.FlatStyle = FlatStyle.Flat;
- if (button.imagePath == "") {
- #if _DEBUG
- //Util.UDebugMessage(string.Format("SetButtonImage imgPath == null "), 0, 0);
- #endif
- }
- else {
- //btnMove.Width = loadicon.Width;
- if (button.name != "") {
- //Image loadicon = new Bitmap(new Bitmap(button.imagePath), button.width, button.height - 20);
- //btnMove.Image = loadicon;
- btnMove.Image = new Bitmap(button.imagePath);
- //btnMove.ImageAlign = ContentAlignment.TopCenter;
- //btnMove.TextAlign = ContentAlignment.BottomCenter;
- }
- else {
- //Image loadicon = new Bitmap(new Bitmap(button.imagePath), button.width, button.height);
- //btnMove.Image = loadicon;
- btnMove.Image = new Bitmap(button.imagePath);
- //btnMove.ImageAlign = ContentAlignment.MiddleCenter;
- }
- }
- //btnMove.Name = button.name;
- //btnMove.Padding = new Padding(3);
- //btnMove.BackColor = Color.Transparent;
- btnMove.Tag = button;
- //btnMove.Text = button.name;
- btnMove.Width = button.width + 5;
- btnMove.Height = button.height + 5;
- btnMove.MouseDown += new MouseEventHandler(BtnMouseClick);
- }
- */
- /*
- void BtnMouseClick(object sender, MouseEventArgs e) { // field button click event
- #if _DEBUG
- //Util.UDebugMessage("BtnMouseClick", 0, 0);
- #endif
- if (e.Button == MouseButtons.Left) {
- Button btnM = (Button)sender;
- XMLButton button = (XMLButton)btnM.Tag;
- this.comboBox1.SelectedIndex = button.jumpField;
- }
- }
- */
- public void SetDevImage(XMLDevice device)
- { // set one device image to filed
- if (device.DevIconID == "")
- {
- #if _DEBUG
- //Util.UDebugMessage(string.Format("SetDevImage icon_path == null "), 0, 0);
- #endif
- }
- else
- {
- // Graphics g = panel1.CreateGraphics();
- Bitmap m_Dev = new Bitmap(GetTypeImage(device.DevIconID));
- g.DrawImage(m_Dev, device.Xposition, device.Yposition, m_Dev.Width, m_Dev.Height); // cyim 2013.7.3 해상도에 따른 이미지 크기가 변경되는 문제 수정
- // g.Dispose();
- }
- }
- FormDevice formDevice = null;
- private void btnWinClose_Click(object sender, EventArgs e)
- { // filed close event
- try
- {
- this.Close();
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
- { // set select list
- this.SetField(this.comboBox1.SelectedIndex);
- }
- public void JumpField(int id)
- {
- // cyim 2015.7.30 화재발생시 점프할 페이지 지정 루틴에 예외처리 추가
- if (this.comboBox1.Items.Count <= 0)
- return;
- // filed change using index
- // lch 13.07.19 - 속도개선 작업
- if (this.comboBox1.InvokeRequired)
- {
- dCommandFuctionCall d = new dCommandFuctionCall(JumpField);
- this.comboBox1.Invoke(d, new object[] { id });
- }
- else
- {
- #if _DEBUG
- //Util.UDebugMessage(string.Format("JumpField JUMP_FIELD_ID = {0}", id), 0, 0);
- #endif
- for (int i = 0; i < this.xField.Count; i++)
- {
- if (id == this.xField[i].FieldID)
- {
- this.comboBox1.SelectedIndex = i;
- //this.SetField(i);
- break;
- }
- }
- }
- }
- private void timer1_Tick(object sender, EventArgs e)
- { // data update tmer
- //this.GetAllDataList();
- GetDataList();
- }
- private void FormField_Activated(object sender, EventArgs e)
- { // form active event
- try
- {
- this.mdi.SelectMenuIndex = 7;
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- void FormField_Disposed(object sender, System.EventArgs e)
- { // form dispose event
- try
- {
- this.mdi.SelectMenuIndex = 0;
- g.Dispose();
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void FormField_FormClosing(object sender, FormClosingEventArgs e)
- { // form close event
- try
- {
- if (formDevice != null && formDevice.Created)
- {
- this.formDevice.Close();
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- // 특정 상황에서, 화면을 다시 그린다.
- private void panel1_Paint(object sender, PaintEventArgs e)
- {
- selectedFieldIndex = -1;
- SetField(comboBox1.SelectedIndex);
- }
- // 화면에서 디바이스 아이콘을 선택하면 상태정보를 출력한다
- private void panel1_MouseDown(object sender, MouseEventArgs e)
- {
-
- // 판넬 마우스 다운 이벤트
- // 위치 확인하여, 해당 디바이스 메시지를 띄운다.
- int i;
- // 마우스 위치를 확인.
- int iX = e.Location.X;
- int iY = e.Location.Y;
- // 디바이스의 위치
- int iXX;
- int iYY;
- // cyim
- // 배경 화면에는 2가지 타입의 아이콘이 존재한다
- // XMLButton : 버튼 아이콘으로서 페이지간 이동하도록 링크가 설정되어 있다.
- // XMLDevice : 디바이스 아이콘으로서 장치 정보를 나타낸다.
-
- // 마우스 포인트 정보를 이용하여 버튼을 추출하고, 그 버튼의 점프 페이지 정보를 확인한다.
- for (i = 0; i < xField[this.comboBox1.SelectedIndex].LButton.Count; i++)
- {
- iXX = xField[this.comboBox1.SelectedIndex].LButton[i].Xposition;
- iYY = xField[this.comboBox1.SelectedIndex].LButton[i].Yposition;
- if ((iX >= iXX) && (iX <= (iXX + xField[this.comboBox1.SelectedIndex].LButton[i].width)))
- {
- if ((iY >= iYY) && (iY <= (iYY + xField[this.comboBox1.SelectedIndex].LButton[i].height)))
- {
- // 화면 상단의 콤보박스 셋팅
- // 인덱스가 변경되는 순간 해당 페이지로 이동한다 -> comboBox1_SelectedIndexChanged
- comboBox1.SelectedIndex = xField[this.comboBox1.SelectedIndex].LButton[i].jumpField;
- // cyim 2013.3.15 화면깜빡임 문제 수정
- // 루프문 최소화
- break;
- }
- }
- }
- // 마우스 포인트 정보를 이용하여 디바이스를 추출하고, 그 디바이스의 정보를 확인한다.
- for (i = 0; i < xField[this.comboBox1.SelectedIndex].Count_Dev; i++)
- {
- iXX = xField[this.comboBox1.SelectedIndex].LDevice[i].Xposition;
- iYY = xField[this.comboBox1.SelectedIndex].LDevice[i].Yposition;
- if ((iX >= iXX) && (iX <= (iXX + 24)))
- {
- if ((iY >= iYY) && (iY <= (iYY + 24)))
- {
- // DeviceForm 의 내용을 표시한다.
- // 이미 할당되면 적용안됨, 새로운 폼이라면 메모리 할당
- if (formDevice == null)
- {
- formDevice = new FormDevice(this.mdi);
- formDevice.Owner = this;
- formDevice.Visible = false;
- formDevice.Show();// 데이타를 아직 표시하지 않았으므로 표시는 하지 않는다.
- }
- // 표시 불가
- formDevice.Visible = false;
- // 아이디
- formDevice.devID = this.xField[this.comboBox1.SelectedIndex].LDevice[i].DevID;
- // 폼헤더 상단 문구
- formDevice.Text = this.xField[this.comboBox1.SelectedIndex].LDevice[i].dev_name;
- // 디바이스 정보
- formDevice.SetDeviceInformText(string.Format(
- "장치 번호 : " + this.xField[this.comboBox1.SelectedIndex].LDevice[i].Device_ViewID +
- "\r\n장치 이름 : " + this.xField[this.comboBox1.SelectedIndex].LDevice[i].dev_name +
- "\r\n위 치 : " + this.xField[this.comboBox1.SelectedIndex].LDevice[i].position));
- // 이미지
- formDevice.SetDeviceImage(GetTypeImage(this.xField[this.comboBox1.SelectedIndex].LDevice[i].DevIconID));
- // 디바이스 상태
- formDevice.SetDeciceStatusText("상 태 : " + this.xField[this.comboBox1.SelectedIndex].LDevice[i].StatusStr);
- // 위치
- formDevice.Location = new Point(Control.MousePosition.X + 5, Control.MousePosition.Y + 5);
- // 표시
- formDevice.Visible = true;
- // cyim 2013.3.15 화면깜빡임 문제 수정
- // 루프문 최소화
- break;
- }
- }
- }
- }
- }
- }
|