コード例 #1
0
ファイル: rhinosdkfont.cs プロジェクト: xNETHook/rhinocommon
        public static string[] AvailableFontFaceNames()
        {
            IntPtr pStringArray = UnsafeNativeMethods.ON_StringArray_New();
            int    count        = UnsafeNativeMethods.CRhinoFontTable_GetFontNames(pStringArray);

            string[] rc = new string[count];
            using (Rhino.Runtime.StringHolder sh = new Runtime.StringHolder())
            {
                IntPtr pStringHolder = sh.NonConstPointer();
                for (int i = 0; i < count; i++)
                {
                    UnsafeNativeMethods.ON_StringArray_Get(pStringArray, i, pStringHolder);
                    rc[i] = sh.ToString();
                }
            }
            UnsafeNativeMethods.ON_StringArray_Delete(pStringArray);
            if (count < 1)
            {
                System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection();
                rc = new string[fonts.Families.Length];
                for (int i = 0; i < fonts.Families.Length; i++)
                {
                    rc[i] = fonts.Families[i].Name;
                }
            }
            Array.Sort(rc);
            return(rc);
        }
コード例 #2
0
ファイル: Localization.cs プロジェクト: xNETHook/rhinocommon
 /// <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 (Rhino.Runtime.StringHolder sh = new Runtime.StringHolder())
     {
         IntPtr pString = sh.NonConstPointer();
         UnsafeNativeMethods.RHC_RhinoFormatNumber(x, (int)units, (int)mode, precision, appendUnitSystemName, pString);
         return(sh.ToString());
     }
 }
コード例 #3
0
        //const int idxUrl = 1;
        string GetString(int which)
        {
            IntPtr ptr = ConstPointer();

            using (Rhino.Runtime.StringHolder sh = new Runtime.StringHolder())
            {
                IntPtr pString = sh.NonConstPointer();
                UnsafeNativeMethods.ON_3dmObjectAttributes_GetSetString(ptr, which, false, null, pString);
                return(sh.ToString());
            }
        }
コード例 #4
0
        string GetStringHelper(int which)
        {
            IntPtr pConstThis = ConstPointer();

            using (Rhino.Runtime.StringHolder sh = new Runtime.StringHolder())
            {
                IntPtr pString = sh.NonConstPointer();
                UnsafeNativeMethods.CArgsRhinoGetLine_GetString(pConstThis, which, pString);
                return(sh.ToString());
            }
        }
コード例 #5
0
 ///<summary>The list of commands to not repeat.</summary>
 public static string[] CommandNames()
 {
   using(Rhino.Runtime.StringHolder sh = new Runtime.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;
   }
 }
コード例 #6
0
 ///<summary>Input list of commands that force AutoSave prior to running.</summary>
 public static string[] AutoSaveBeforeCommands()
 {
   using (Rhino.Runtime.StringHolder sh = new Runtime.StringHolder())
   {
     IntPtr pStringHolder = sh.NonConstPointer();
     UnsafeNativeMethods.RhFileSettings_AutosaveBeforeCommands(pStringHolder);
     string s = sh.ToString();
     if( string.IsNullOrEmpty(s) )
       return null;
     return s.Split(new char[] { ' ' });
   }
 }
コード例 #7
0
ファイル: Localization.cs プロジェクト: gwinsky/rhinocommon
 /// <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 (Rhino.Runtime.StringHolder sh = new Runtime.StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     UnsafeNativeMethods.RHC_RhinoFormatNumber(x, (int)units, (int)mode, precision, appendUnitSystemName, pString);
     return sh.ToString();
   }
 }
コード例 #8
0
ファイル: rdk_content.cs プロジェクト: kalvo/rhinocommon
 /// <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 (Runtime.StringHolder sh = new Runtime.StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     UnsafeNativeMethods.Rdk_RenderContent_GetString(pConstThis, pString, (int)which);
     return sh.ToString();
   }
 }
コード例 #9
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(Runtime.StringHolder shName = new Runtime.StringHolder())
   using (Runtime.StringHolder shMacro = new Runtime.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;
 }
コード例 #10
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(Runtime.StringHolder sh = new Runtime.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;
 }
コード例 #11
0
 //const int idxUrl = 1;
 string GetString(int which)
 {
   IntPtr ptr = ConstPointer();
   using (Rhino.Runtime.StringHolder sh = new Runtime.StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     UnsafeNativeMethods.ON_3dmObjectAttributes_GetSetString(ptr, which, false, null, pString);
     return sh.ToString();
   }
 }
コード例 #12
0
 string GetStringHelper(int which)
 {
   IntPtr pConstThis = ConstPointer();
   using(Rhino.Runtime.StringHolder sh = new Runtime.StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     UnsafeNativeMethods.CArgsRhinoGetLine_GetString(pConstThis, which, pString);
     return sh.ToString();
   }
 }
コード例 #13
0
ファイル: rhinosdkget.cs プロジェクト: austinlaw/rhinocommon
 public static string GetFileNameScripted(Custom.GetFileNameMode mode, string defaultName)
 {
   using (Rhino.Runtime.StringHolder sh = new Runtime.StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     UnsafeNativeMethods.CRhinoGetFileDialog_Get2((int)mode, defaultName, pString);
     return sh.ToString();
   }
 }
コード例 #14
0
ファイル: rhinosdkget.cs プロジェクト: austinlaw/rhinocommon
 public static string GetFileName(Custom.GetFileNameMode mode, string defaultName, string title, System.Windows.Forms.IWin32Window parent)
 {
   using (Rhino.Runtime.StringHolder sh = new Runtime.StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     IntPtr pParent = parent != null ? parent.Handle : IntPtr.Zero;
     UnsafeNativeMethods.CRhinoGetFileDialog_Get((int)mode, defaultName, title, pParent, pString);
     return sh.ToString();
   }
 }
コード例 #15
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 (Rhino.Runtime.StringHolder sh = new Runtime.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;
    }
コード例 #16
0
 /// <summary>
 /// Get macro associated with a given keyboard shortcut
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public static string GetMacro(ShortcutKey key)
 {
   using (Rhino.Runtime.StringHolder sh = new Runtime.StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     UnsafeNativeMethods.CRhinoAppShortcutKeys_Macro((int)key, pString);
     return sh.ToString();
   }
 }
コード例 #17
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 (Rhino.Runtime.StringHolder sh = new Runtime.StringHolder())
   {
     IntPtr pStringHolder = sh.NonConstPointer();
     int which = currentUser ? idxGetRhinoRoamingProfileDataFolder : idxGetRhinoApplicationDataFolder;
     UnsafeNativeMethods.CRhinoFileUtilities_GetDataFolder(pStringHolder, which);
     return sh.ToString();
   }
 }
コード例 #18
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 (Runtime.StringHolder sh = new Runtime.StringHolder())
   {
     IntPtr pMacro = sh.NonConstPointer();
     UnsafeNativeMethods.CRhinoAppAliasList_GetMacro(alias, pMacro, IntPtr.Zero);
     return sh.ToString();
   }
 }
コード例 #19
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 (Rhino.Runtime.StringHolder sh = new Runtime.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;
 }
コード例 #20
0
ファイル: rdk_content.cs プロジェクト: kalvo/rhinocommon
 /// <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="paramName">The name of a parameter field. Since child textures will usually correspond with some
 ///parameter (they generally either replace or modify a parameter over UV space) these functions are used to
 ///specify which parameter corresponded with child slot.  If there is no correspondence, return the empty
 ///string.</param>
 /// <returns>
 /// The default behavior 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 ChildSlotNameFromParamName(String paramName)
 {
   using (Runtime.StringHolder sh = new Runtime.StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     IntPtr pConstThis = ConstPointer();
     UnsafeNativeMethods.Rdk_RenderContent_ChildSlotNameFromParamName(pConstThis, paramName, pString);
     return sh.ToString();
   }
 }
コード例 #21
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 (Rhino.Runtime.StringHolder sh = new Runtime.StringHolder())
   {
     IntPtr pStringHolder = sh.NonConstPointer();
     UnsafeNativeMethods.RhDirectoryManager_FindFile(fileName, pStringHolder);
     return sh.ToString();
   }
 }
コード例 #22
0
 public bool TryGetString(int id, out string value)
 {
   value = string.Empty;
   using (Rhino.Runtime.StringHolder sh = new Runtime.StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     bool rc = UnsafeNativeMethods.CRhinoHistoryRecord_GetString(m_pConstRhinoHistoryRecord, id, pString);
     if (rc)
       value = sh.ToString();
     return rc;
   }
 }
コード例 #23
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 (Rhino.Runtime.StringHolder sh = new Runtime.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;
   }
 }
コード例 #24
0
ファイル: rhinosdkplugin.cs プロジェクト: gwinsky/rhinocommon
 /// <summary>
 /// Gets names of all "non-test" commands for a given plug-in.
 /// </summary>
 /// <param name="pluginId">The plug-in ID.</param>
 /// <returns>An array with all plug-in names. This can be empty, but not null.</returns>
 public static string[] GetEnglishCommandNames(Guid pluginId)
 {
   IntPtr pStrings = UnsafeNativeMethods.ON_StringArray_New();
   int count = UnsafeNativeMethods.CRhinoPluginManager_GetCommandNames(pluginId, pStrings);
   string[] rc = new string[count];
   using (Rhino.Runtime.StringHolder sh = new Runtime.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;
 }
コード例 #25
0
 static string GetFileString(int which)
 {
   using (Rhino.Runtime.StringHolder sh = new Runtime.StringHolder())
   {
     IntPtr pString = sh.NonConstPointer();
     UnsafeNativeMethods.CRhinoAppFileSettings_GetFile(which, pString);
     return sh.ToString();
   }
 }