Beispiel #1
0
        /// <summary>
        /// Used for regression tests.
        /// </summary>
        public static void test_regression()
        {
            ObjectiveCRuntime.LoadFramework("Cocoa");
            ObjectiveCRuntime.Initialize();

            var test = new MonobjcTest();

            test.OnBeginTest += () => { _pool = new NSAutoreleasePool(); };
            test.OnEndTest   += () => { _pool.Release(); _pool = null; };

            test.TestAll(typeof(ObjectiveCRuntime).Assembly);
        }
Beispiel #2
0
        static void Main(string[] aArgs)
        {
            // when built with scons, the executing assembly appears in the KinskyDesktop.app/Contents/MacOs folder
            // whereas under MonoDevelop it is in the KinskyDesktop.app/Contents/Resources folder - this code will handle both
            string exeFolder      = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName);
            string contentsFolder = Path.GetDirectoryName(exeFolder);
            string resFolder      = Path.Combine(contentsFolder, "Resources");

            KinskyDesktop.Properties.Resources.SetBasePath(resFolder);

            ObjectiveCRuntime.LoadFramework("Cocoa");
            ObjectiveCRuntime.LoadFramework("Quartz");
            ObjectiveCRuntime.Initialize();

            NSApplication.Bootstrap();
            NSApplication.LoadNib("MainMenu.nib");
            NSApplication.RunApplication();
        }
Beispiel #3
0
 /// <summary>
 /// First method called.
 /// </summary>
 public static void Main()
 {
     try {
         //
         // NOTE: refer to monobjc documentation about this code.
         // load cocoa library
         ObjectiveCRuntime.LoadFramework("Cocoa");
         ObjectiveCRuntime.Initialize();
         //
         NSApplication.Bootstrap();
         // load application bundle
         NSApplication.LoadNib("Window.nib");
         NSApplication.RunApplication();
         //
     } catch (Exception exc) {
         // log errors:
         if (logger.IsFatalEnabled)
         {
             logger.Fatal("An exception at the top level was catched.", exc);
         }
     }
 }
Beispiel #4
0
        public static Process[] GetProcesses()
        {
            // spin up the objective-c runtime
            ObjectiveCRuntime.LoadFramework("Cocoa");
            ObjectiveCRuntime.Initialize();
            NSAutoreleasePool pool = new NSAutoreleasePool();

            // Create our process
            NSTask getPSTask        = new NSTask();
            NSPipe getPSStandardOut = new NSPipe();

            getPSTask.StandardOutput = getPSStandardOut;
            getPSTask.LaunchPath     = @"/bin/ps";

            // add some arguments
            NSString getPSargumentString = new NSString("-ax");
            NSArray  getPSarguments      = NSArray.ArrayWithObject(getPSargumentString);

            getPSTask.Arguments = getPSarguments;

            // We have liftoff
            getPSTask.Launch();
            getPSTask.WaitUntilExit();

            // Parse the output
            NSData   getPSoutput    = getPSStandardOut.FileHandleForReading.ReadDataToEndOfFile;
            NSString getPSoutString = new NSString(getPSoutput, NSStringEncoding.NSUTF8StringEncoding);


            // Split the string of output in to a list of processes
            string[] getPSsplitString = getPSoutString.ToString().Split(Environment.NewLine.ToCharArray());

            // Remove the first and last line of the output
            string[] processListAsStrings = new string[getPSsplitString.Length - 2];
            for (int x = 1; x < getPSsplitString.Length - 1; x++)
            {
                processListAsStrings[x - 1] = getPSsplitString[x];
            }


            Process[] processes = new Process[processListAsStrings.Length];


            for (int i = 0; i < processes.Length; i++)
            {
                string cleanString = RemoveExtraSpaces(processListAsStrings[i]);

                string[] processDetails = cleanString.Split(' ');
                Int32    procID         = Convert.ToInt32(processDetails[0]);

                string procName = string.Empty;
                for (int j = 4; j < processDetails.Length; j++)
                {
                    if (j == 4)
                    {
                        procName = procName + processDetails[j];
                    }
                    else
                    {
                        procName = procName + " " + processDetails[j];
                    }
                }

                //Console.WriteLine(procID.ToString() + procName);
                processes[i] = new Process(procID, procName);
            }

            // Dipose our Objective-C objects, gotta love reference counting
            pool.Release();

            return(processes);
        }