コード例 #1
0
    public static List<NamedValue> ConvertToNamedValueList(IntPtr pXmlSection)
    {
      if (IntPtr.Zero == pXmlSection)
        return null;

      List<Rhino.Render.NamedValue> list = new List<NamedValue>();

      IntPtr pIterator = UnsafeNativeMethods.Rdk_XmlSection_GetIterator(pXmlSection);

      //Fill the property list from the XML section
      if (pIterator != IntPtr.Zero)
      {
        while (true)
        {
          using (var sh = new StringHolder())
          {
            Variant variant = new Variant();

            if (1 == UnsafeNativeMethods.Rdk_XmlSection_NextParam(pXmlSection, pIterator, sh.ConstPointer(), variant.ConstPointer()))
            {
              NamedValue nv = new NamedValue(sh.ToString(), variant.AsObject());
              list.Add(nv);
            }
            else
              break;
          }
        }

        UnsafeNativeMethods.Rdk_XmlSection_DeleteIterator(pIterator);
      }

      return list;
    }
コード例 #2
0
 string GetStringHelper(UnsafeNativeMethods.ArgsGetLineStringConsts which)
 {
   IntPtr ptr_const_this = ConstPointer();
   using (var sh = new StringHolder())
   {
     IntPtr ptr_string = sh.NonConstPointer();
     UnsafeNativeMethods.CArgsRhinoGetLine_GetString(ptr_const_this, which, ptr_string);
     return sh.ToString();
   }
 }
コード例 #3
0
 internal static ConstructionPlane FromIntPtr(IntPtr pConstructionPlane)
 {
   if (IntPtr.Zero == pConstructionPlane)
     return null;
   ConstructionPlane rc = new ConstructionPlane();
   using (var sh = new StringHolder())
   {
     IntPtr ptr_string = sh.NonConstPointer();
     UnsafeNativeMethods.ON_3dmConstructionPlane_Copy(pConstructionPlane,
                                                      ref rc.m_plane,
                                                      ref rc.m_grid_spacing,
                                                      ref rc.m_snap_spacing,
                                                      ref rc.m_grid_line_count,
                                                      ref rc.m_grid_thick_frequency,
                                                      ref rc.m_bDepthBuffered,
                                                      ptr_string);
     rc.m_name = sh.ToString();
   }
   return rc;
 }
コード例 #4
0
 /// <summary>
 /// Returns all of the imagePath items in Rhino's search imagePath list. See "Options Files settings" in the Rhino help file for more details.
 /// </summary>
 public static string[] GetSearchPaths()
 {
   using (var sh = new StringHolder())
   {
     int count = SearchPathCount;
     string[] rc = new string[count];
     for (int i = 0; i < count; i++)
     {
       IntPtr pStringHolder = sh.NonConstPointer();
       UnsafeNativeMethods.RhDirectoryManager_SearchPath(i, pStringHolder);
       rc[i] = sh.ToString();
     }
     return rc;
   }
 }
コード例 #5
0
 /// <summary>
 /// Internal method used to get string values from the C++ SDK
 /// </summary>
 /// <param name="which">Id of string value to get</param>
 /// <returns>Returns the requested string value.</returns>
 internal string GetString(StringIds which)
 {
   IntPtr pConstThis = ConstPointer();
   using (var sh = new StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     UnsafeNativeMethods.Rdk_RenderContent_GetString(pConstThis, pString, (int)which);
     return sh.ToString();
   }
 }
コード例 #6
0
 public string ToString(IFormatProvider provider)
 {
   using (var sh = new StringHolder())
   {
     UnsafeNativeMethods.Rdk_Variant_GetStringValue(ConstPointer(), sh.NonConstPointer());
     return sh.ToString();
   }
 }
コード例 #7
0
 /// <summary>
 /// Constructs a dictionary containing as keys the default names and as value the default macro.
 /// <para>The returned dicionary contains a copy of the settings.</para>
 /// </summary>
 /// <returns>A new dictionary with the default name/macro combinantions.</returns>
 public static System.Collections.Generic.Dictionary<string, string> GetDefaults()
 {
   var rc = new System.Collections.Generic.Dictionary<string,string>();
   IntPtr pCommandAliasList = UnsafeNativeMethods.CRhinoAppAliasList_New();
   int count = UnsafeNativeMethods.CRhinoAppAliasList_Count(pCommandAliasList);
   using (var shName = new StringHolder())
   using (var shMacro = new StringHolder())
   {
     IntPtr pName = shName.NonConstPointer();
     IntPtr pMacro = shMacro.NonConstPointer();
     for (int i = 0; i < count; i++)
     {
       if (UnsafeNativeMethods.CRhinoAppAliasList_Item(i, pName, pCommandAliasList))
       {
         string name = shName.ToString();
         if (UnsafeNativeMethods.CRhinoAppAliasList_GetMacro(name, pMacro, pCommandAliasList))
         {
           string macro = shMacro.ToString();
           rc[name] = macro;
         }
       }
     }
   }
   UnsafeNativeMethods.CRhinoAppAliasList_Delete(pCommandAliasList);
   return rc;
 }
コード例 #8
0
 ///<summary>Returns a list of command alias names.</summary>
 ///<returns>An array of strings. This can be empty.</returns>
 public static string[] GetNames()
 {
   int count = UnsafeNativeMethods.CRhinoAppAliasList_Count(IntPtr.Zero);
   string[] rc = new string[count];
   using(var sh = new StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     for (int i = 0; i < count; i++)
     {
       if (UnsafeNativeMethods.CRhinoAppAliasList_Item(i, pString, IntPtr.Zero))
         rc[i] = sh.ToString();
     }
   }
   return rc;
 }
コード例 #9
0
    static AppearanceSettingsState CreateState(bool current)
    {
      IntPtr pAppearanceSettings = UnsafeNativeMethods.CRhinoAppAppearanceSettings_New(current);
      AppearanceSettingsState rc = new AppearanceSettingsState();
      using (var sh = new StringHolder())
      {
        IntPtr pString = sh.NonConstPointer();
        UnsafeNativeMethods.CRhinoAppearanceSettings_DefaultFontFaceNameGet(pString, pAppearanceSettings);
        rc.DefaultFontFaceName = sh.ToString();
      }
      rc.DefaultLayerColor = GetColor(idxDefaultLayerColor, pAppearanceSettings);
      rc.SelectedObjectColor = GetColor(idxSelectedObjectColor, pAppearanceSettings);
      rc.LockedObjectColor = GetColor(idxLockedObjectColor, pAppearanceSettings);
      rc.WorldCoordIconXAxisColor = GetColor(idxWorldIconXColor, pAppearanceSettings);
      rc.WorldCoordIconYAxisColor = GetColor(idxWorldIconYColor, pAppearanceSettings);
      rc.WorldCoordIconZAxisColor = GetColor(idxWorldIconZColor, pAppearanceSettings);
      rc.TrackingColor = GetColor(idxTrackingColor, pAppearanceSettings);
      rc.FeedbackColor = GetColor(idxFeedbackColor, pAppearanceSettings);
      rc.DefaultObjectColor = GetColor(idxDefaultObjectColor, pAppearanceSettings);
      rc.ViewportBackgroundColor = GetColor(idxViewportBackgroundColor, pAppearanceSettings);
      rc.FrameBackgroundColor = GetColor(idxFrameBackgroundColor, pAppearanceSettings);
      rc.CommandPromptTextColor = GetColor(idxCommandPromptTextColor, pAppearanceSettings);
      rc.CommandPromptHypertextColor = GetColor(idxCommandPromptHypertextColor, pAppearanceSettings);
      rc.CommandPromptBackgroundColor = GetColor(idxCommandPromptBackgroundColor, pAppearanceSettings);
      rc.CrosshairColor = GetColor(idxCrosshairColor, pAppearanceSettings);
      rc.PageviewPaperColor = GetColor(idxPageviewPaperColor, pAppearanceSettings);
      rc.CurrentLayerBackgroundColor = GetColor(idxCurrentLayerBackgroundColor, pAppearanceSettings);
      rc.EchoPromptsToHistoryWindow = UnsafeNativeMethods.CRhinoAppAppearanceSettings_GetBool(idxEchoPromptsToHistoryWindow, pAppearanceSettings);
      rc.EchoCommandsToHistoryWindow = UnsafeNativeMethods.CRhinoAppAppearanceSettings_GetBool(idxEchoCommandsToHistoryWindow, pAppearanceSettings);
      rc.ShowFullPathInTitleBar = UnsafeNativeMethods.CRhinoAppAppearanceSettings_GetBool(idxFullPathInTitleBar, pAppearanceSettings);
      rc.ShowCrosshairs = UnsafeNativeMethods.CRhinoAppAppearanceSettings_GetBool(idxCrosshairsVisible, pAppearanceSettings);
      UnsafeNativeMethods.CRhinoAppAppearanceSettings_Delete(pAppearanceSettings);

      // also add grid settings
      IntPtr pGridSettings = UnsafeNativeMethods.CRhinoAppGridSettings_New(current);

      rc.GridThickLineColor = GetGridColor(idxThickLineColor, pGridSettings);
      rc.GridThinLineColor = GetGridColor(idxThinLineColor, pGridSettings);
      rc.GridXAxisLineColor = GetGridColor(idxXAxisColor, pGridSettings);
      rc.GridYAxisLineColor = GetGridColor(idxYAxisColor, pGridSettings);
      rc.GridZAxisLineColor = GetGridColor(idxZAxisColor, pGridSettings);
      UnsafeNativeMethods.CRhinoAppGridSettings_Delete(pGridSettings);

      return rc;
    }
コード例 #10
0
 ///<summary>The list of commands to not repeat.</summary>
 public static string[] CommandNames()
 {
   using(var sh = new StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     UnsafeNativeMethods.CRhinoAppDontRepeatCommandSettings_GetDontRepeatList(pString);
     string s = sh.ToString();
     string[] rc =  s.Split(new char[] { ' ', '\n' });
     for (int i = 0; i < rc.Length; i++)
     {
       rc[i] = rc[i].Trim();
     }
     return rc;
   }
 }
コード例 #11
0
    /*
    /// <summary>
    /// Shows the content chooser to allow the user to select a new or existing content.
    /// </summary>
    /// <param name="defaultType">The content type that will be initially selected in the 'New' tab.</param>
    /// <param name="defaultInstanceId">The content instance that will be initially selected in the 'Existing' tab.</param>
    /// <param name="kinds">Which content kinds will be displayed.</param>
    /// <param name="instanceIdOut">The UUID of the chosen item. Depending on eRhRdkSccResult, this can be the type id of a content type or the instance id of an existing content.</param>
    /// <param name="flags">Tabs specifications.</param>
    /// <param name="doc">A Rhino document.</param>
    /// <returns>The result.</returns>
    public static ShowContentChooserResults ShowContentChooser(Guid defaultType, Guid defaultInstanceId, RenderContentKind kinds, ref Guid instanceIdOut, ShowContentChooserFlags flags, RhinoDoc doc)
    {
      return (ShowContentChooserResults)UnsafeNativeMethods.Rdk_Globals_ShowContentChooser(defaultType, defaultInstanceId, RenderContent.KindString(kinds), ref instanceIdOut, (int)flags, doc.m_docId);
    }
    */
 
    /// <summary>
    /// Finds a file and also handles network shares.
    /// <remarks>This is a replacement for CRhinoFileUtilities::FindFile().</remarks>
    /// </summary>
    /// <param name="fullPathToFile">The file to be found.</param>
    /// <returns>The found file.</returns>
    public static string FindFile(string fullPathToFile)
    {
      using (var sh = new StringHolder())
      {
        IntPtr pString = sh.NonConstPointer();
        bool found = (1 == UnsafeNativeMethods.Rdk_Globals_FindFile(fullPathToFile, pString));

        return found ? sh.ToString() : null;
      }
    }
コード例 #12
0
 /// <summary>
 /// Gets list of command names in Rhino. This list does not include Test, Alpha, or System commands.
 /// </summary>
 /// <param name="english">
 ///  if true, retrieve the english name for every command.
 ///  if false, retrieve the local name for every command.
 /// </param>
 /// <param name="loaded">
 /// if true, only get names of currently loaded commands.
 /// if false, get names of all registered (may not be currently loaded) commands.
 /// </param>
 /// <returns>An array instance with command names. This array could be empty, but not null.</returns>
 public static string[] GetCommandNames(bool english, bool loaded)
 {
   IntPtr pStrings = UnsafeNativeMethods.ON_StringArray_New();
   int count = UnsafeNativeMethods.CRhinoCommandManager_GetCommandNames(pStrings, english, loaded);
   string[] rc = new string[count];
   using (var sh = new StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     for( int i=0; i<count; i++ )
     {
       UnsafeNativeMethods.ON_StringArray_Get(pStrings, i, pString);
       rc[i] = sh.ToString();
     }
   }
   UnsafeNativeMethods.ON_StringArray_Delete(pStrings);
   return rc;
 }
コード例 #13
0
 /// <summary>
 /// Prompts the user for a save file name and the width, height and depth of an image to be saved.
 /// </summary>
 /// <param name="filename">The original file path.</param>
 /// <param name="width">A width.</param>
 /// <param name="height">An height.</param>
 /// <param name="colorDepth">A color depth.</param>
 /// <returns>The new file name.</returns>
 public static string PromptForSaveImageFileParameters(string filename, ref int width, ref int height, ref int colorDepth)
 {
   using (var sh = new StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     bool bRet = 1==UnsafeNativeMethods.Rdk_Globals_PromptForSaveImageFileParams(filename, ref width, ref height, ref colorDepth, pString);
     
     if (bRet)
       return sh.ToString();
   }
   return null;      
 }
コード例 #14
0
 /// <summary>
 /// Gets an array of most recent command descriptions.
 /// </summary>
 /// <returns>An array of command descriptions.</returns>
 public static MostRecentCommandDescription[] GetMostRecentCommands()
 {
   IntPtr pDisplayStrings = UnsafeNativeMethods.ON_StringArray_New();
   IntPtr pMacros = UnsafeNativeMethods.ON_StringArray_New();
   int count = UnsafeNativeMethods.CRhinoApp_GetMRUCommands(pDisplayStrings, pMacros);
   MostRecentCommandDescription[] rc = new MostRecentCommandDescription[count];
   using(var sh = new StringHolder() )
   {
     IntPtr pString = sh.NonConstPointer();
     for (int i = 0; i < count; i++)
     {
       var mru = new MostRecentCommandDescription();
       UnsafeNativeMethods.ON_StringArray_Get(pDisplayStrings, i, pString);
       mru.DisplayString = sh.ToString();
       UnsafeNativeMethods.ON_StringArray_Get(pMacros, i, pString);
       mru.Macro = sh.ToString();
       rc[i] = mru;
     }
   }
   UnsafeNativeMethods.ON_StringArray_Delete(pDisplayStrings);
   UnsafeNativeMethods.ON_StringArray_Delete(pMacros);
   return rc;
 }
コード例 #15
0
 public bool TryGetString(int id, out string value)
 {
   value = string.Empty;
   using (var sh = new StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     bool rc = UnsafeNativeMethods.CRhinoHistoryRecord_GetString(m_pConstRhinoHistoryRecord, id, pString);
     if (rc)
       value = sh.ToString();
     return rc;
   }
 }
コード例 #16
0
 string GetStringHelper(int which)
 {
   IntPtr pConstThis = ConstPointer();
   using (var sh = new StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     UnsafeNativeMethods.CArgsRhinoGetLine_GetString(pConstThis, which, pString);
     return sh.ToString();
   }
 }
コード例 #17
0
 static string GetFileString(int which)
 {
   using (var sh = new StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     UnsafeNativeMethods.CRhinoAppFileSettings_GetFile(which, pString);
     return sh.ToString();
   }
 }
コード例 #18
0
 /// <summary>
 /// Gets localized unit system name.  Uses current application locale id.
 /// </summary>
 /// <param name="units">The unit system.</param>
 /// <param name="capitalize">true if the name should be capitalized.</param>
 /// <param name="singular">true if the name is expressed for a singular element.</param>
 /// <param name="abbreviate">true if name should be the abbreviation.</param>
 /// <returns>The unit system name.</returns>
 public static string UnitSystemName(UnitSystem units, bool capitalize, bool singular, bool abbreviate)
 {
   using (var sh = new StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     UnsafeNativeMethods.CRhinoApp_UnitSystemName((int)units, capitalize, singular, abbreviate, pString);
     return sh.ToString();
   }
 }
コード例 #19
0
 ///<summary>Input list of commands that force AutoSave prior to running.</summary>
 public static string[] AutoSaveBeforeCommands()
 {
   using (var sh = new StringHolder())
   {
     IntPtr pStringHolder = sh.NonConstPointer();
     UnsafeNativeMethods.RhFileSettings_AutosaveBeforeCommands(pStringHolder);
     string s = sh.ToString();
     if( string.IsNullOrEmpty(s) )
       return null;
     return s.Split(new char[] { ' ' });
   }
 }
コード例 #20
0
 /// <summary>
 /// Get a string version of a number in a given unit system / display mode.
 /// </summary>
 /// <param name="x">The number to format into a string.</param>
 /// <param name="units">The unit system for the number.</param>
 /// <param name="mode">How the number should be formatted.</param>
 /// <param name="precision">The precision of the number.</param>
 /// <param name="appendUnitSystemName">Adds unit system name to the end of the number.</param>
 /// <returns>The formatted number.</returns>
 public static string FormatNumber( double x, UnitSystem units, DistanceDisplayMode mode, int precision, bool appendUnitSystemName )
 {
   using (var sh = new StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     UnsafeNativeMethods.RHC_RhinoFormatNumber(x, (int)units, (int)mode, precision, appendUnitSystemName, pString);
     return sh.ToString();
   }
 }
コード例 #21
0
    static GeneralSettingsState CreateState(bool current)
    {
      IntPtr pGeneralSettings = UnsafeNativeMethods.CRhinoAppGeneralSettings_New(current);
      GeneralSettingsState rc = new GeneralSettingsState();

      rc.MouseSelectMode = (MouseSelectMode)UnsafeNativeMethods.CRhinoAppGeneralSettings_GetInt(pGeneralSettings, idxMouseSelectMode);
      rc.MaximumPopupMenuLines = UnsafeNativeMethods.CRhinoAppGeneralSettings_GetInt(pGeneralSettings, idxMaxPopupMenuLines);
      rc.MinimumUndoSteps = UnsafeNativeMethods.CRhinoAppGeneralSettings_GetInt(pGeneralSettings, idxMinUndoSteps);
      rc.MaximumUndoMemoryMb = UnsafeNativeMethods.CRhinoAppGeneralSettings_GetInt(pGeneralSettings, idxMaxUndoMemoryMb);
      rc.NewObjectIsoparmCount = UnsafeNativeMethods.CRhinoAppGeneralSettings_GetInt(pGeneralSettings, idxNewObjectIsoparmCount);
      rc.MiddleMouseMode = (MiddleMouseMode)UnsafeNativeMethods.CRhinoAppGeneralSettings_GetInt(pGeneralSettings, idxMiddleMouseMode);

      using (var sh = new StringHolder())
      {
        IntPtr pStringHolder = sh.NonConstPointer();
        UnsafeNativeMethods.CRhinoAppGeneralSettings_GetString(IntPtr.Zero, idxMiddleMousePopupToolbar, pStringHolder);
        rc.MiddleMousePopupToolbar = sh.ToString();
        UnsafeNativeMethods.CRhinoAppGeneralSettings_GetString(IntPtr.Zero, idxMiddleMouseMacro, pStringHolder);
        rc.MiddleMouseMacro = sh.ToString();
      }
      rc.EnableContextMenu = UnsafeNativeMethods.CRhinoAppGeneralSettings_GetBool(pGeneralSettings, idxEnableContextMenu);
      int ms = UnsafeNativeMethods.CRhinoAppGeneralSettings_GetInt(pGeneralSettings, idxContextMenuDelay);
      rc.ContextMenuDelay = TimeSpan.FromMilliseconds(ms);
      rc.AutoUpdateCommandHelp = UnsafeNativeMethods.CRhinoAppGeneralSettings_GetBool(pGeneralSettings, idxAutoUpdateCommandContext);

      UnsafeNativeMethods.CRhinoAppGeneralSettings_Delete(pGeneralSettings);
      return rc;
    }
コード例 #22
0
 //const int idxUrl = 1;
 string GetString(int which)
 {
   IntPtr ptr = ConstPointer();
   using (var sh = new StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     UnsafeNativeMethods.ON_3dmObjectAttributes_GetSetString(ptr, which, false, null, pString);
     return sh.ToString();
   }
 }
コード例 #23
0
 /// <summary>
 /// Get macro associated with a given keyboard shortcut
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public static string GetMacro(ShortcutKey key)
 {
   using (var sh = new StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     UnsafeNativeMethods.CRhinoAppShortcutKeys_Macro((int)key, pString);
     return sh.ToString();
   }
 }
コード例 #24
0
 /// <summary>
 /// Gets the data folder for machine or current user.
 /// </summary>
 /// <param name="currentUser">true if the query relates to the current user.</param>
 /// <returns>A directory to user or machine data.</returns>
 public static string GetDataFolder(bool currentUser)
 {
   using (var sh = new StringHolder())
   {
     IntPtr pStringHolder = sh.NonConstPointer();
     int which = currentUser ? idxGetRhinoRoamingProfileDataFolder : idxGetRhinoApplicationDataFolder;
     UnsafeNativeMethods.CRhinoFileUtilities_GetDataFolder(pStringHolder, which);
     return sh.ToString();
   }
 }
コード例 #25
0
 ///<summary>Returns the macro of a command alias.</summary>
 ///<param name='alias'>[in] The name of the command alias.</param>
 public static string GetMacro(string alias)
 {
   using (var sh = new StringHolder())
   {
     IntPtr pMacro = sh.NonConstPointer();
     UnsafeNativeMethods.CRhinoAppAliasList_GetMacro(alias, pMacro, IntPtr.Zero);
     return sh.ToString();
   }
 }
コード例 #26
0
 /// <summary>
 /// A "child slot" is the specific "slot" that a child (usually a texture) occupies.
 /// This is generally the "use" of the child - in other words, the thing the child
 /// operates on.  Some examples are "color", "transparency".
 /// </summary>
 /// <param name="childSlotName">The named of the child slot to receive the parameter name for.</param>
 /// <returns>The default behaviour for these functions is to return the input string.  Sub-classes may (in the future) override these functions to provide different mappings.</returns>
 public string ParamNameFromChildSlotName(String childSlotName)
 {
   using (var sh = new StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     IntPtr pConstThis = ConstPointer();
     UnsafeNativeMethods.Rdk_RenderContent_ParamNameFromChildSlotName(pConstThis, childSlotName, pString);
     return sh.ToString();
   }
 }
コード例 #27
0
 public static string StringFromProjection(BackgroundProjections projection)
 {
   using (var sh = new StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     UnsafeNativeMethods.Rdk_SimulatedTexture_StringFromProjection(pString, (int)projection);
     return sh.ToString();
   }
 }
コード例 #28
0
 /// <summary>
 /// Searches for a file using Rhino's search imagePath. Rhino will look for a file in the following locations:
 /// 1. The current document's folder.
 /// 2. Folder's specified in Options dialog, File tab.
 /// 3. Rhino's System folders.
 /// </summary>
 /// <param name="fileName">short file name to search for.</param>
 /// <returns> full imagePath on success; null on error.</returns>
 public static string FindFile(string fileName)
 {
   using (var sh = new StringHolder())
   {
     IntPtr pStringHolder = sh.NonConstPointer();
     UnsafeNativeMethods.RhDirectoryManager_FindFile(fileName, pStringHolder);
     return sh.ToString();
   }
 }
コード例 #29
0
 /// <summary>
 /// Returns a list of recently opened files. Note that this function does not
 /// check to make sure that these files still exist.
 /// </summary>
 /// <returns>An array of strings with the paths to the recently opened files.</returns>
 public static string[] RecentlyOpenedFiles()
 {
   IntPtr pStrings = UnsafeNativeMethods.ON_StringArray_New();
   int count = UnsafeNativeMethods.CRhinoApp_RecentlyOpenedFiles(pStrings);
   string[] rc = new string[count];
   if (count > 0)
   {
     using (var sh = new StringHolder())
     {
       IntPtr pStringHolder = sh.NonConstPointer();
       for (int i = 0; i < count; i++)
       {
         UnsafeNativeMethods.ON_StringArray_Get(pStrings, i, pStringHolder);
         rc[i] = sh.ToString();
       }
     }
   }
   UnsafeNativeMethods.ON_StringArray_Delete(pStrings);
   return rc;
 }
コード例 #30
0
 static bool OnIsFactoryProductAcceptableAsChild(int serialNumber, IntPtr contentFactoryPointer, IntPtr childSlotName)
 {
   var content = FromSerialNumber(serialNumber);
   if (content == null) return true;
   var child_slot_name = System.Runtime.InteropServices.Marshal.PtrToStringUni(childSlotName);
   using (var string_holder = new StringHolder())
   {
     var pointer = string_holder.NonConstPointer();
     UnsafeNativeMethods.Rdk_Factory_Kind(contentFactoryPointer, pointer);
     var factory_kind = string_holder.ToString();
     var id = UnsafeNativeMethods.Rdk_Factory_TypeId(contentFactoryPointer);
     var result = content.IsFactoryProductAcceptableAsChild(id, factory_kind, child_slot_name);
     return result;
   }
 }