protected override void OnExecute(Command command, ExecutionContext context, System.Drawing.Rectangle buttonRect)
        {
            if (excelWorksheet == null)
                excelWorksheet = new ExcelWorksheet();

            Window activeWindow = Window.ActiveWindow;

            double length = 0;
            foreach (ITrimmedCurve iTrimmedCurve in activeWindow.GetAllSelectedITrimmedCurves()) {
                length += iTrimmedCurve.Length;
            }

            excelWorksheet.SetCell(row++, 1, length);
        }
        protected override void OnExecute(Command command, ExecutionContext context, System.Drawing.Rectangle buttonRect)
        {
            if (excelWorksheet == null)
                excelWorksheet = new ExcelWorksheet();

            Window activeWindow = Window.ActiveWindow;

            List<ITrimmedCurve> iTrimmedCurves = new List<ITrimmedCurve>(activeWindow.GetAllSelectedITrimmedCurves());
            if (iTrimmedCurves.Count != 2)
                return;

            ITrimmedCurve curveA = iTrimmedCurves[0];
            ITrimmedCurve curveB = iTrimmedCurves[1];

            var intersections = new List<IntPoint<CurveEvaluation, CurveEvaluation>>(curveA.IntersectCurve(curveB));

            CurveEvaluation evalA = curveA.ProjectPoint(intersections[0].Point);
            CurveEvaluation evalB = curveB.ProjectPoint(intersections[0].Point);

            double angle = Math.Acos(Vector.Dot(evalA.Tangent.UnitVector, evalB.Tangent.UnitVector));

            excelWorksheet.SetCell(row++, 1, angle * 180 / Math.PI);
        }
        protected override void OnExecute(Command command, ExecutionContext context, System.Drawing.Rectangle buttonRect)
        {
            List<List<TreeVertex>> rows = WilfTree.GetRows(16);
            Window activeWindow = Window.ActiveWindow;
            Part part = activeWindow.Document.MainPart;

            //DesignBody designBody;
            //foreach (List<TreeVertex> row in rows) {
            //    foreach (TreeVertex vertex in row) {
            //        designBody = AddInHelper.CreateSphere(Point.Create((double) vertex.I / vertex.J, 0, 0), 0.001, part);
            //        designBody.Name = string.Format("{0}/{1}", vertex.I, vertex.J);
            //    }
            //}

            #if false // text output
            StreamWriter postScriptSteam = new StreamWriter(@"c:\wilf.txt");
            foreach (List<TreeVertex> row in rows) {
                foreach (TreeVertex vertex in row)
                    postScriptSteam.Write(string.Format("{0}/{1} ", vertex.I, vertex.J));

                postScriptSteam.Write("\n");
            }

            postScriptSteam.Close();
            #endif

            #if false // Excel output
            ExcelWorksheet worksheet = new ExcelWorksheet();
            int i = 1;
            foreach (List<TreeVertex> row in rows) {
                foreach (TreeVertex vertex in row) {
                    worksheet.SetCell(i, 1, vertex.Level);
                    worksheet.SetCell(i, 2, string.Format("={0}/{1}", vertex.I, vertex.J));
                    i++;
                }
            }
            #endif

            #if true // Excel output
            ExcelWorksheet worksheet = new ExcelWorksheet();
            int i = 1;
            foreach (List<TreeVertex> row in rows) {
                double max = 0;
                int index = 0;
                double value = 0;
                double maxValue = 0;
                int j = 0;
                foreach (TreeVertex vertex in row) {
                    value = (double)vertex.I / (double)vertex.J;
                    double result = 1 / Math.Log(value);
                    max = Math.Max(max, result);
                    if (result == max) {
                        index = j;
                        maxValue = value;
                    }

                    j++;
                }
                worksheet.SetCell(i, 1, (double)index);
                worksheet.SetCell(i, 2, maxValue);
                worksheet.SetCell(i, 3, max);
                i++;
            }
            #endif
        }