private void ClockAdd_Click(object sender, RoutedEventArgs e) { if (SourceClocks.SelectedItems.Count > 0) { foreach (var OneItem in SourceClocks.SelectedItems) { ViewModel.Clocks.Add(OneItem.ToString()); } ViewModel.Setup(); } }
bool ParseItem(OneItem item, int index, ZombieState state) { state.id = index; state.blueEyes = item.eyes; state.visibilty = item.visible; state.startPosition = new Vector3(item.start_position.x, item.start_position.y, item.start_position.z); state.targetPosition = new Vector3(item.target_position.x, item.target_position.y, item.target_position.z); state.rate = item.target_position.rate; return(true); }
private void ClockRemove_Click(object sender, RoutedEventArgs e) { if (DestinationClocks.SelectedItems.Count > 0) { List <string> ToRemove = new List <string>(); foreach (var OneItem in DestinationClocks.SelectedItems) { ToRemove.Add(OneItem.ToString()); } ToRemove.ForEach(item => ViewModel.Clocks.Remove(item)); ViewModel.Setup(); } }
public void CopyProperties(QnSProjectAward.Contracts.Business.Account.IIdentityUser other) { if (other == null) { throw new System.ArgumentNullException(nameof(other)); } bool handled = false; BeforeCopyProperties(other, ref handled); if (handled == false) { Id = other.Id; OneItem.CopyProperties(other.OneItem); AnotherItem.CopyProperties(other.AnotherItem); } AfterCopyProperties(other); }
private void ConversionDown_Click(object sender, RoutedEventArgs e) { if (DestinationConversions.SelectedItems.Count > 0) { List <string> ToMove = new List <string>(); foreach (var OneItem in DestinationConversions.SelectedItems) { ToMove.Add(OneItem.ToString()); } ToMove.ForEach(item => { int Index = ViewModel.Conversions.IndexOf(item); if (Index < ViewModel.Conversions.Count - 1) { ViewModel.Conversions.Move(Index, Index + 1); } }); } }
public void CopyProperties(QnSProjectAward.Contracts.Business.Account.IAppAccess other) { if (other == null) { throw new System.ArgumentNullException(nameof(other)); } bool handled = false; BeforeCopyProperties(other, ref handled); if (handled == false) { Id = other.Id; OneItem.CopyProperties(other.OneItem); ClearManyItems(); foreach (var item in other.ManyItems) { AddManyItem(item); } } AfterCopyProperties(other); }
private void Button1_Click(object sender, EventArgs e) { try { if (MessageBox.Show("هل تريد طباعة هذه الفاتورة", "Super Market", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { this.Cursor = Cursors.WaitCursor; OneItem myRep = new OneItem(); int id = Convert.ToInt32(dgSupp.CurrentRow.Cells[0].Value); myRep.SetParameterValue("@Id", id); FrmCry frm = new FrmCry(); frm.crystalReportViewer1.ReportSource = myRep; this.Cursor = Cursors.Hand; frm.ShowDialog(); } } catch { return; } }
static int MergeValues( Hashtable table, XmlNode root, long nDays, ValueStyle valuestyle, ref List<string> touched_keys, out string strError) { strError = ""; string strCode = DomUtil.GetAttr(root, "code"); XmlNodeList nodes = root.SelectNodes("category"); foreach (XmlNode node in nodes) { string strCategoryName = DomUtil.GetAttr(node, "name"); XmlNodeList items = node.SelectNodes("item"); foreach (XmlNode item in items) { string strItemName = DomUtil.GetAttr(item, "name"); string strPath = strCode.Replace("/", "\\") + "/" + strCategoryName.Replace("/", "\\") + "/" + strItemName.Replace("/", "\\"); // 2015/4/3 替换了字符 touched_keys.Add(strPath); OneItem info = (OneItem)table[strPath]; if (info == null) { info = new OneItem(); info.Path = strPath; table[strPath] = info; // 补齐以前欠缺的list值 if ((valuestyle & ValueStyle.List) != 0) { for (long i = 0; i < nDays; i++) { info.Values.Add(0); } } } string strItemValue = DomUtil.GetAttr(item, "value"); double v = 0; if (double.TryParse(strItemValue, out v) == false) { strError = "XML片断 '"+item.OuterXml+"' 中value属性值 '"+strItemValue+"' 格式错误"; return -1; } info.Total += v; if ((valuestyle & ValueStyle.List) != 0) info.Values.Add(v); } } return 0; }
void OnChangeDB(SimpleFirebaseUnity.Firebase sender, DataSnapshot snapshot) { DoDebug("[OBSERVER] Last updated changed to: " + snapshot.RawJson); foreach (var key in snapshot.Keys) { string strItem = JsonHelper.GetJsonObject(snapshot.RawJson, key); string numbersOnly = Regex.Replace(key, "[^0-9]", ""); if (string.IsNullOrEmpty(numbersOnly)) { continue; } int index = int.Parse(numbersOnly); OneItem item = JsonUtility.FromJson <OneItem>(strItem); if (zombieStatesMap.ContainsKey(index)) { ParseItem(item, index, zombieStatesMap[index]); } else { ZombieState zombie = new ZombieState(); if (ParseItem(item, index, zombie)) { zombieStatesMap[zombie.id] = zombie; zombieStateList.Add(zombie); } } } //Do something with the data in args.Snapshot //if (db != null && db.items.Count > 0) //{ // foreach (var item in db.items) // { // if (zombieStatesMap.ContainsKey(item.id)) // { // ParseItem(item, zombieStatesMap[item.id]); // } // else // { // ZombieState zombie = new ZombieState(); // if (ParseItem(item, zombie)) // { // zombieStatesMap[zombie.id] = zombie; // zombieStateList.Add(zombie); // } // } // } //} if (ZombieStateChanged != null) { foreach (var pair in zombieStatesMap) { ZombieStateChanged(this, new ZombieStateEventArgs(pair.Key, pair.Value)); } } }
// 把Hashtable中的值写入XML文件中 static int WriteToXmlFile( Hashtable table, string strOutputFilename, ValueStyle style, out string strError) { strError = ""; XmlDocument dom = new XmlDocument(); dom.LoadXml("<root />"); foreach (string path in table.Keys) { string[] parts = path.Split(new char[] { '/' }); if (parts.Length != 3) { strError = "hashtable中路径 '" + parts + "' 格式错误。应为三段形态"; return(-1); } /* * // 2015/4/3 * if (parts.Length < 3) * { * strError = "hashtable中路径 '" + path + "' 格式错误。应为至少三段形态"; * return -1; * } * */ string strCode = parts[0]; string strCategoryName = parts[1]; string strItemName = parts[2]; XmlNode nodeLibrary = null; if (string.IsNullOrEmpty(strCode) == true) { nodeLibrary = dom.DocumentElement; } else { nodeLibrary = dom.DocumentElement.SelectSingleNode("library[@code='" + strCode + "']"); if (nodeLibrary == null) { nodeLibrary = dom.CreateElement("library"); dom.DocumentElement.AppendChild(nodeLibrary); DomUtil.SetAttr(nodeLibrary, "code", strCode); } } XmlNode nodeCategory = nodeLibrary.SelectSingleNode("category[@name='" + strCategoryName + "']"); if (nodeCategory == null) { nodeCategory = dom.CreateElement("category"); nodeLibrary.AppendChild(nodeCategory); DomUtil.SetAttr(nodeCategory, "name", strCategoryName); } XmlNode nodeItem = nodeCategory.SelectSingleNode("item[@name='" + strItemName + "']"); if (nodeItem == null) { nodeItem = dom.CreateElement("item"); nodeCategory.AppendChild(nodeItem); DomUtil.SetAttr(nodeItem, "name", strItemName); } OneItem info = (OneItem)table[path]; DomUtil.SetAttr(nodeItem, "value", info.GetValueString(style)); } dom.Save(strOutputFilename); return(0); }
static int MergeValues( Hashtable table, XmlNode root, long nDays, ValueStyle valuestyle, ref List <string> touched_keys, out string strError) { strError = ""; string strCode = DomUtil.GetAttr(root, "code"); XmlNodeList nodes = root.SelectNodes("category"); foreach (XmlNode node in nodes) { string strCategoryName = DomUtil.GetAttr(node, "name"); XmlNodeList items = node.SelectNodes("item"); foreach (XmlNode item in items) { string strItemName = DomUtil.GetAttr(item, "name"); string strPath = strCode.Replace("/", "\\") + "/" + strCategoryName.Replace("/", "\\") + "/" + strItemName.Replace("/", "\\"); // 2015/4/3 替换了字符 touched_keys.Add(strPath); OneItem info = (OneItem)table[strPath]; if (info == null) { info = new OneItem(); info.Path = strPath; table[strPath] = info; // 补齐以前欠缺的list值 if ((valuestyle & ValueStyle.List) != 0) { for (long i = 0; i < nDays; i++) { info.Values.Add(0); } } } string strItemValue = DomUtil.GetAttr(item, "value"); double v = 0; if (double.TryParse(strItemValue, out v) == false) { strError = "XML片断 '" + item.OuterXml + "' 中value属性值 '" + strItemValue + "' 格式错误"; return(-1); } info.Total += v; if ((valuestyle & ValueStyle.List) != 0) { info.Values.Add(v); } } } return(0); }
// 将一个DOM中的全部值合并到hashtable中 // parameters: // nDays 本次合并前,已经累加了多少天的数据 static int MergeValues( string strLibraryCodeList, Hashtable table, XmlDocument dom, long nDays, ValueStyle valuestyle, out string strError) { strError = ""; if (dom == null) { if ((valuestyle & ValueStyle.List) == 0) { return(0); } // 为每个列表增加一个0 foreach (string path in table.Keys) { OneItem info = (OneItem)table[path]; info.Values.Add(0); } return(0); } List <string> touched_keys = new List <string>(); // 根下的全部<category> int nRet = MergeValues( table, dom.DocumentElement, nDays, valuestyle, ref touched_keys, out strError); if (nRet == -1) { return(-1); } // <library>元素下的<category> XmlNodeList nodes = dom.DocumentElement.SelectNodes("library"); foreach (XmlNode node in nodes) { string strCode = DomUtil.GetAttr(node, "code"); if (SessionInfo.IsGlobalUser(strLibraryCodeList) == false && StringUtil.IsInList(strCode, strLibraryCodeList) == false) { continue; } nRet = MergeValues( table, node, nDays, valuestyle, ref touched_keys, out strError); if (nRet == -1) { return(-1); } } if ((valuestyle & ValueStyle.List) != 0) { // 2012/11/5 // 为没有处理到的列表增加一个0 foreach (string path in table.Keys) { int index = touched_keys.IndexOf(path); if (index != -1) { touched_keys.RemoveAt(index); // 逐渐缩小数组,有利于加快速度 continue; } OneItem info = (OneItem)table[path]; info.Values.Add(0); } } return(0); }