Esempio n. 1
0
 ///<summary>Set Rhino command prompt.</summary>
 ///<param name="prompt">The new prompt text.</param>
 public static void SetCommandPrompt(string prompt)
 {
     UnsafeNativeMethods.CRhinoApp_SetCommandPrompt(prompt, null);
     RhinoApp.Wait();
 }
Esempio n. 2
0
 private void OnRenamed(object source, RenamedEventArgs e)
 {
     RhinoApp.InvokeOnUiThread(RenamedHook, RuntimeSerialNumber, e.OldFullPath, e.FullPath);
 }
Esempio n. 3
0
 private void OnRenamed(object source, RenamedEventArgs e)
 {
     RhinoApp.InvokeOnUiThread(RenamedHook, Pointer, e.OldFullPath, e.FullPath);
 }
Esempio n. 4
0
 // Define the event handlers.
 private void OnChanged(object source, FileSystemEventArgs e)
 {
     RhinoApp.InvokeOnUiThread(ChangedHook, RuntimeSerialNumber, (RhinoFileWatcherChangeReason)e.ChangeType, e.FullPath);
 }
Esempio n. 5
0
        public bool Watch(string path, string filter)
        {
            if (Disposed)
            {
                return(false);
            }

            UnWatch();

            try
            {
                UnWatch();
                path   = ConvertPathToOSPath(path);
                filter = ConvertPathToOSPath(filter);

                // Check to see if this is a path to a file name
                IsFile = !Directory.Exists(path);

                if (IsFile)
                {
                    // Use the file name as the filter
                    filter = Path.GetFileName(path);
                    // Get the file directory to use as the path
                    path = Path.GetDirectoryName(path);
                }

                //Now find a corresponding watcher from the dictionary
                string key = System.IO.Path.Combine(path, filter);
                RefCountedFileSystemWatcher watcher = null;

                if (g_file_system_watchers.TryGetValue(key, out watcher) && null != watcher)
                {
                    Watcher = watcher;
                    Watcher.AddRef();
                }
                else
                {
                    watcher = new RefCountedFileSystemWatcher();

                    g_file_system_watchers.Add(key, watcher);
                    watcher.Impl.Path   = path;
                    watcher.Impl.Filter = filter ?? "*.*";

                    Watcher = watcher;
                }

                Watcher.Impl.Changed += OnChanged;
                Watcher.Impl.Created += OnChanged;
                Watcher.Impl.Deleted += OnChanged;
                Watcher.Impl.Renamed += OnRenamed;

                Watcher.Impl.EnableRaisingEvents = true;

                return(true);
            }
            catch (Exception e)
            {
                var message = string.IsNullOrWhiteSpace(path)
          ? UI.Localization.LocalizeString("RhinoFileWatcher.Watch *error* empty path", 39)
          : string.Format(UI.Localization.LocalizeString("RhinoFileWatcher.Watch *error* parsing path name \"{0}\"", 40), path);

                RhinoApp.WriteLine(message);
                RhinoFileEventWatcherHooks.DumpException(e);

                return(false);
            }
        }