//--------------------------------------
        //新マテリアルツリーコード
        //--------------------------------------

        //boxの上真ん中のxy座標を返す
        private (OP_MaterialBox, double, double) ShowMaterialTree2(material m, int all_material, int shift = 0, int level = 0)
        {
            double width_fix = Width - (Width_margin * 2);
            int    nodecount = tools.CountMaterial(m);
            double wn        = ((double)nodecount / (double)(2 * all_material)) * width_fix;

            wn -= BoxWidth / 2;

            double x_shift = ((double)shift / (double)all_material) * width_fix;
            double windowX = wn + x_shift + Width_margin;
            double windowY = CalcShowPointY(level, BoxHeight);

            //OP_MaterialBox matBox = ShowMaterial(m.Recipes, windowX, windowY);
            OP_MaterialBox matBox = ShowMaterial(m.Recipes, windowX, windowY);

            int shift2 = shift;

            foreach (material mx in m.material_childs)
            {
                int nodecount_c = tools.CountMaterial(mx);
                (OP_MaterialBox childBox, double childX, double childY) = ShowMaterialTree2(mx, all_material, shift2, level + 1);
                shift2 += nodecount_c;

                //線を引く
                Path p = new Path();
                p.Stroke          = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));
                p.StrokeThickness = 2;
                string geoStr = string.Format("M{0},{1} L{2},{3}", windowX + BoxWidth / 2, windowY + BoxHeight, childX, childY);
                p.Data        = Geometry.Parse(geoStr);
                childBox.path = p;
                main_grid.Children.Add(p);
            }

            if (m.material_childs.Count == 0)
            {
                double dw = width_fix / all_material;
                double x  = Width_margin + (dw * shift);

                double y = CalcShowPointY(level + 1, BoxHeight);

                foreach (List <op_stct2> ops in m.material_op)
                {
                    Material_StartBox opBox =  ShowMaterial(ops, x, y);

                    //線を引く
                    Path p = new Path();
                    p.Stroke          = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));
                    p.StrokeThickness = 2;
                    string geoStr = string.Format("M{0},{1} L{2},{3}", windowX + BoxWidth / 2, windowY + BoxHeight, x + BoxWidth / 2, y);
                    p.Data     = Geometry.Parse(geoStr);
                    opBox.path = p;
                    main_grid.Children.Add(p);

                    x += dw;
                }
            }


            return(matBox, windowX + BoxWidth / 2, windowY);
        }
        private OP_MaterialBox ShowMaterial(List <OP_Recipe2> m, double x, double y)
        {
            //int y_count = material_levels[y];
            OP_MaterialBox box = new OP_MaterialBox(tools.add_NULL_Recipe(material_slot, m));

            main_grid.Children.Add(box);
            material_boxs.Add(box);

            Thickness p = ConvertXY(x, y, box.Width, box.Height);

            box.Margin = p;

            return(box);
        }