Esempio n. 1
0
        public Node GetChildNode(char c)
        {
            var invar = CharTool.ToLowerFast(c);
            var child = this.Children.FirstOrDefault(x => CharTool.ToLowerFast(x.NodeKey) == invar);

            return(child);
        }
Esempio n. 2
0
        private void SetChildSources(List <KeyValuePair <string, object> > source)
        {
            var visitedItems = new Dictionary <string, int>();

            foreach (var vp in source)
            {
                if (!Objects.Contains(vp.Value))
                {
                    Objects.Add(vp.Value);
                }

                if (string.IsNullOrEmpty(vp.Key) || string.IsNullOrWhiteSpace(vp.Key) || visitedItems.ContainsKey(vp.Key))
                {
                    continue;
                }
                else
                {
                    char key  = CharTool.ToLowerFast(vp.Key[0]);
                    Node node = Create(key);
                    // Düğüm oluştur.
                    var subNodeSource = this.CreateSubNodeSource(source, key, visitedItems);

                    if (subNodeSource.Count > 0)
                    {
                        node.SetChildSources(subNodeSource);
                    }

                    this.Children.Add(node);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 生成历史结账单
        /// </summary>
        /// <param name="order"></param>
        /// <param name="curorderDetailList"></param>
        /// <returns></returns>
        public static string GenerateHisorderBill(Hisorder order, List <HisorderDetail> DetailList)
        {
            int     col1 = 16, col2 = 8, col3 = 8;
            decimal sum = 0, qtys = 0;
            string  s = string.Empty;

            s += CharTool.Append(App.DinnerName);
            s += CharTool.Append("结账单");
            s += CharTool.Append("流水:" + order.HisorderId, AlignType.Left);
            s += CharTool.Split();

            s += CharTool.Append("品名", AlignType.Left, col1) + CharTool.Append("数量", AlignType.Left, col2) + CharTool.Append("单价", AlignType.Left, col3);
            s += "\n";

            foreach (var item in DetailList)
            {
                qtys += item.Quantity;
                sum  += item.Quantity * item.Price * item.DiscountRate;
                s    += CharTool.Append(item.DishName, AlignType.Left, col1) + CharTool.Append(item.Quantity, AlignType.Left, col2) + CharTool.Append(item.Price, AlignType.Left, col3);
                s    += "\n";
            }
            s += CharTool.Split();
            s += CharTool.Append("合计:", AlignType.Left, col1) + CharTool.Append(qtys.ToString("0.00"), AlignType.Left, col2) + CharTool.Append(sum.ToString("0.00"), AlignType.Left, col3);
            s += "\n";
            s += CharTool.Append(order.Paytype + "支付", AlignType.Left, col1);
            s += CharTool.Append("收银:" + App.OperatorId, AlignType.Right, col2 + col3);
            s += "\n";
            s += CharTool.Append(DateTime.Now, AlignType.Left);
            s += CharTool.Append("欢迎下次光临");
            return(s);
        }
Esempio n. 4
0
        public override bool Equals(object obj)
        {
            if (!(obj is Node))
            {
                return(false);
            }

            char c1 = CharTool.ToLowerFast((obj as Node).NodeKey);
            char c2 = CharTool.ToLowerFast(this.NodeKey);

            return(c1 == c2);
        }
Esempio n. 5
0
        private void circleToolButton(bool Checked)
        {
            if (Checked)
            {
                currentChartTool = CharTool.Circle;
                currentPoint     = null;
            }
            else
            {
                currentChartTool = CharTool.None;
            }

            UpdateCharsTool();
        }
Esempio n. 6
0
        private void multiToolButton(bool Checked)
        {
            if (Checked)
            {
                currentChartTool = CharTool.Multiline;
                currentPoint     = null;
            }
            else
            {
                currentChartTool = CharTool.None;
            }

            UpdateCharsTool();
        }
Esempio n. 7
0
        private List <KeyValuePair <string, object> > CreateSubNodeSource(List <KeyValuePair <string, object> > mainSource, char key, Dictionary <string, int> visitedItems)
        {
            List <KeyValuePair <string, object> > subNodeSource = new List <KeyValuePair <string, object> >();

            foreach (var vp in mainSource)
            {
                if (!string.IsNullOrEmpty(vp.Key))
                {
                    if (CharTool.ToLowerFast(vp.Key[0]) == key)
                    {
                        var item = new KeyValuePair <string, object>(vp.Key.Substring(1, vp.Key.Length - 1), vp.Value);
                        subNodeSource.Add(item);
                        if (!visitedItems.ContainsKey(vp.Key))
                        {
                            visitedItems.Add(vp.Key, 1);
                        }
                    }
                }
            }

            return(subNodeSource);
        }
Esempio n. 8
0
        public void AddNewItem(string path, object item)
        {
            if (string.IsNullOrEmpty(path) || string.IsNullOrWhiteSpace(path))
            {
                return;
            }

            char keyChar = CharTool.ToLowerFast(path[0]);

            if (!this.Children.Any(x => x.NodeKey == keyChar))
            {
                // Düğüm oluştur.
                if (!this.Objects.Contains(item))
                {
                    this.Objects.Add(item);
                }

                var child = CreateWithSource(keyChar, new List <KeyValuePair <string, object> >()
                {
                    new KeyValuePair <string, object>(path.Substring(1, path.Length - 1), item)
                });
                this.Children.Add(child);
            }
            else
            {
                // Düğüm zaten oluşturulmuş.
                Node child = this.GetChildNode(keyChar);

                if (!child.Objects.Contains(item))
                {
                    child.Objects.Add(item);
                }

                child.AddNewItem(path.Substring(1, path.Length - 1), item);
            }
        }
Esempio n. 9
0
        public HashSet <object> Search(string searchKey, ResultCompiling resultCompiling, CombineMode combineMode = CombineMode.Intersection)
        {
            /*
             * if (!this.IsReady)
             *  return new HashSet<object>();
             */

            this.SpellFixList.Clear();

            if (string.IsNullOrEmpty(searchKey.Trim(' ')))
            {
                return(this.DataSource);
            }

            if (this.Tree != null)
            {
                if (resultCompiling == ResultCompiling.Basic)
                {
                    Node node = this.Tree.FindNode(searchKey);

                    if (node != null)
                    {
                        return(node.Objects);
                    }
                    else
                    {
                        var unaccentedText = String.Join("", searchKey.Normalize(NormalizationForm.FormD).Where(c => CharTool.ToLowerFast(c) != c));
                        var node2          = this.Tree.FindNode(unaccentedText);

                        if (node2 != null)
                        {
                            return(node2.Objects);
                        }
                        else
                        {
                            return(this.GetSpellCheckerSuggestions(searchKey));
                        }
                    }
                }
                else
                {
                    List <string> searchKeys = searchKey.Split(' ').Select(tag => tag.Trim()).Where(tag => !string.IsNullOrEmpty(tag)).ToList();
                    if (searchKeys.Count == 1)
                    {
                        var  trimmedSearchKey = searchKey.Trim();
                        Node node             = this.Tree.FindNode(trimmedSearchKey);

                        if (node != null)
                        {
                            return(node.Objects);
                        }
                        else
                        {
                            var unaccentedText = ConvertTurkishCharsToEnglish(trimmedSearchKey);
                            var node2          = this.Tree.FindNode(unaccentedText);

                            if (node2 != null)
                            {
                                return(node2.Objects);
                            }
                            else
                            {
                                return(this.GetSpellCheckerSuggestions(trimmedSearchKey));
                            }
                        }
                    }

                    List <Node> nodeList = new List <Node>();
                    foreach (string key in searchKeys)
                    {
                        Node found = this.Tree.FindNode(key);
                        if (found != null)
                        {
                            nodeList.Add(found);
                        }
                    }

                    if (nodeList.Count > 0)
                    {
                        return(this.CombineResults(nodeList, combineMode));
                    }
                    else
                    {
                        return(this.GetSpellCheckerSuggestions(searchKeys.First()));
                    }
                }
            }
            else
            {
                return(new HashSet <object>());
            }
        }