示例#1
0
        private void button_Click_add_to_export(object sender, RoutedEventArgs e)
        {
            EnvDTE80.DTE2 dte2 = FGetter.dte2;

            if (!dte2.Solution.IsOpen)
            {
                MessageBox.Show(string.Format(System.Globalization.CultureInfo.CurrentUICulture, "No solution is opened!"), "Couldn't find a solution");
                return;
            }
            if (dte2.Solution.Projects.Count == 0)
            {
                MessageBox.Show(string.Format(System.Globalization.CultureInfo.CurrentUICulture, "No projects is opened!"), "Couldn't find a project");
                return;
            }

            EnvDTE.Project project = dte2.Solution.Projects.Item(1);

            if (!CheckForProjectItem(project, "M3D_export.cpp"))
            {
                MessageBoxResult create_export_file = MessageBox.Show(
                    string.Format(System.Globalization.CultureInfo.CurrentUICulture, "Couldn't find M3D_export.cpp file. Would you like to create one?"),
                    "No export file", MessageBoxButton.OKCancel
                    );

                if (create_export_file != MessageBoxResult.OK)
                {
                    return;
                }

                button_Click_c_ex_btn(sender, e);
            }

            if (!FGetter.GetM3DFWStuff())
            {
                MessageBox.Show(string.Format(System.Globalization.CultureInfo.CurrentUICulture, "Couldn't find proper M3D definitions.\nDid you mess with the export file?"), "No proper definitions found!");
                return;
            }

            EnvDTE.EditPoint start_point1 = FGetter.getFctPtrList_function.GetStartPoint().CreateEditPoint();
            EnvDTE.EditPoint end_point1   = FGetter.getFctPtrList_function.GetEndPoint().CreateEditPoint();
            EnvDTE.EditPoint start_point2 = FGetter.getMemberFctPtrList_function.GetStartPoint().CreateEditPoint();
            EnvDTE.EditPoint end_point2   = FGetter.getMemberFctPtrList_function.GetEndPoint().CreateEditPoint();

            //EnvDTE.EditPoint place_to_write = end_point;

            if (!start_point1.FindPattern("//Body to be generated", 0, start_point1) || !start_point2.FindPattern("//Body to be generated", 0, start_point2))
            {
                MessageBox.Show(string.Format(System.Globalization.CultureInfo.CurrentUICulture, "Function definition requires the\n\"//Body to be generated\" comment\nto be properly recognized"), "No proper definitions found!");
                return;
            }

            start_point1.CharRight(22);
            start_point2.CharRight(22);

            if (content_list[ResListBox.SelectedIndex].Kind == FGetter.M3DCppFctKind.Free)
            {
                start_point1.Insert("\n\t\tdata.push_back(m3dfw::UFctInfo(\"" + ResListBox.SelectedItem.ToString() + "\", (UserFct_ptr)" + ResListBox.SelectedItem.ToString() + ");");
            }
            else if (content_list[ResListBox.SelectedIndex].Kind == FGetter.M3DCppFctKind.Member)
            {
                start_point2.Insert("\n\t\tdata.push_back(m3dfw::UMemberFctInfo(\"" + ResListBox.SelectedItem.ToString() + "\", CAST_TO_ACTOR_MEMBER(" + ResListBox.SelectedItem.ToString() + "));");
            }

            //EnvDTE.Document doc = dte2.Documents.Item("M3D_export.cpp").ProjectItem.FileCodeModel.CodeElements.Item;
        }