private void LoadNode(XmlNode parent, ItemCollection items, NumericTreeViewItem parentItem) { foreach (XmlNode child in parent) { if (child.NodeType == XmlNodeType.Element && child.Name == "node") { string tmp = child.Attributes["range"].Value; bool withMin = tmp.Substring(0, 1) == "["; bool withMax = tmp.Substring(tmp.Length - 1, 1) == "]"; string tmp2 = tmp.Substring(1, tmp.Length - 2); int tmpIndex = tmp2.IndexOf('-'); float min, max; float.TryParse(tmp2.Substring(0, tmpIndex), out min); float.TryParse(tmp2.Substring(tmpIndex + 1), out max); NumericTreeViewItem c = new NumericTreeViewItem(0, 0, parentItem); c.UpdateInfo(min, max, withMin, withMax); items.Add(c); if (child.HasChildNodes) { LoadNode(child, c.Items, c); } } } }
//루트 라운딩 private void roundRoot() { bool minIsZero = list.Min() == 0; bool maxIsZero = list.Max() == 0; int minDigit = minIsZero ? 1 : (int)Math.Floor(Math.Log10(Math.Abs(list.Min()))) + 1; //최소값의 자리수 int maxDigit = maxIsZero ? 1 : (int)Math.Floor(Math.Log10(Math.Abs(list.Max()))) + 1; //최대값의 자리수 NumericTreeViewItem root = treeView.Items[0] as NumericTreeViewItem; float tmpRootMin = minIsZero ? 0 : (float)Math.Pow(10, minDigit - 1); int tmpMaxcoef = (int)(Math.Abs(list.Max()) / Math.Pow(10, maxDigit - 1)) + 1; float tmpRootMax = maxIsZero ? 0 : (float)(tmpMaxcoef * Math.Pow(10, maxDigit - 1)); root.UpdateInfo(tmpRootMin, tmpRootMax, true, false); //루트노드 업데이트 //노드의 min, max 로드 textBoxMin.Text = root.min.ToString(); textBoxMax.Text = root.max.ToString(); }