private void GetXMLCallBack(PaintUnit unitItem, XElement callBack, XElement setting) { if (unitItem.doubleClickCheck) { setting.SetValue(strList); //strList.Clear(); } if (unitItem.status) { foreach (CallBackLine curveItem in curveLineNameList) { if (curveItem.StartPoint.itemLocation == unitItem.itemLocation) { foreach (PaintUnit unit1 in unitNameList) { int indexofUnit = unitNameList.IndexOf(unit1) + 1; if (curveItem.EndPoint.itemLocation == unit1.itemLocation) { callBack.SetValue("step" + indexofUnit.ToString()); } } } } } else { callBack.SetValue("null"); } }
// private IPaintItem m_currentitem = null; #region drag tasks into Panel void panel1_DragDrop(object sender, DragEventArgs e) { string itemType = e.Data.GetData(typeof(string)).ToString(); Point leftTopPoint = this.PointToScreen(this.panel1.Location); switch (itemType) { case "Search Target": //Point leftTopPoint = this.PointToScreen(this.panel1.Location); PaintUnit search = new PaintUnit("Search Target", NAIAD_IDE_1._0.Properties.Resources.Search, new Point(e.X - leftTopPoint.X - NAIAD_IDE_1._0.Properties.Resources.Search.Width / 2, e.Y - leftTopPoint.Y - NAIAD_IDE_1._0.Properties.Resources.Search.Height / 2), new Pen(Color.Gray), this.Font, false, 1); this.panel1.PaintItems.Add(search); //.PaintItems.Add(item); this.panel1.Refresh(); //Reloads the file that is currently displayed in the object. break; case "Tracing Light": PaintUnit trace = new PaintUnit("Tracing Light", NAIAD_IDE_1._0.Properties.Resources.trace, new Point(e.X - leftTopPoint.X - NAIAD_IDE_1._0.Properties.Resources.trace.Width / 2, e.Y - leftTopPoint.Y - NAIAD_IDE_1._0.Properties.Resources.trace.Height / 2), new Pen(Color.Gray), this.Font, false, 2); this.panel1.PaintItems.Add(trace); //.PaintItems.Add(item); this.panel1.Refresh(); //Reloads the file that is currently displayed in the object. break; case "Change Shape": //Point leftTopPoint = this.PointToScreen(this.panel1.Location); PaintUnit change = new PaintUnit("Change Shape", NAIAD_IDE_1._0.Properties.Resources.Search, new Point(e.X - leftTopPoint.X - NAIAD_IDE_1._0.Properties.Resources.Search.Width / 2, e.Y - leftTopPoint.Y - NAIAD_IDE_1._0.Properties.Resources.Search.Height / 2), new Pen(Color.Gray), this.Font, false, 3); this.panel1.PaintItems.Add(change); //.PaintItems.Add(item); this.panel1.Refresh(); //Reloads the file that is currently displayed in the object. break; case "Fire Torpedo": //Point leftTopPoint = this.PointToScreen(this.panel1.Location); PaintUnit fire = new PaintUnit("Fire Torpedo", NAIAD_IDE_1._0.Properties.Resources.Search, new Point(e.X - leftTopPoint.X - NAIAD_IDE_1._0.Properties.Resources.Search.Width / 2, e.Y - leftTopPoint.Y - NAIAD_IDE_1._0.Properties.Resources.Search.Height / 2), new Pen(Color.Gray), this.Font, false, 4); this.panel1.PaintItems.Add(fire); //.PaintItems.Add(item); this.panel1.Refresh(); //Reloads the file that is currently displayed in the object. break; default: break; } //this.panel1.G // PaintPanel(); }
private string CreateSubJsonString(PaintUnit item, string itemName, JObject json2) { unitNameList.Sort((x, y) => x.itemLocation.X.CompareTo(y.itemLocation.X)); //int i = unitNameList.Count; //int callBackNnumber = 0; //foreach (PaintUnit unit in unitNameList) //{ //} //PutItemInList(); json2.Add("mission", itemName); if (item.doubleClickCheck) { JObject jset = new JObject(); jset.Add("Set", strList); json2.Add("Setting", jset); // strList.Clear(); } if (item.status) { foreach (CallBackLine curve in curveLineNameList) { if (curve.StartPoint.itemLocation == item.itemLocation) { foreach (PaintUnit unit in unitNameList) { if (curve.EndPoint.itemLocation == unit.itemLocation) { //unitNameList.Sort((x, y) => x.itemLocation.X.CompareTo(y.itemLocation.X)); int indexofUnit = unitNameList.IndexOf(unit); json2.Add("CallBack", "step" + (indexofUnit + 1).ToString()); } } } } //get curveline end point and return item //json2.Add("CallBack",return item.name) } else { json2.Add("CallBack", null); } return(json2.ToString(Formatting.None)); }