public void clear(NSObject sender)
        {
            NSDocumentController.sharedDocumentController().clearRecentDocuments(this);

            DoReload();
            m_table.reloadData();
        }
Ejemplo n.º 2
0
    public void Init()
    {
        AssertListener.Install();

        Registrar.CanInit = true;
        m_pool = new NSObject(NSObject.AllocAndInitInstance("NSAutoreleasePool"));
    }
Ejemplo n.º 3
0
    internal static void Main(string[] args)
    {
        try
        {
            Registrar.CanInit = true;

            // Make our app a foreground app (this is redundant if we were started via the
            // Finder or the open command, but important if we were started by directly
            // executing the launcher script).
            var psn = new ProcessSerialNumber();
            psn.highLongOfPSN = 0;
            psn.lowLongOfPSN = kCurrentProcess;

            int err = TransformProcessType(ref psn, kProcessTransformToForegroundApplication);
            if (err != 0)
                throw new InvalidOperationException("TransformProcessType returned " + err + ".");

            err = SetFrontProcess(ref psn);
            if (err != 0)
                throw new InvalidOperationException("SetFrontProcess returned " + err + ".");

            // Load the nib and run the main event loop.
            NSObject pool = new NSObject(NSObject.AllocAndInitInstance("NSAutoreleasePool"));
            App app = new App("MainMenu.nib");
            pool.release();

            app.Run();
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
        }
    }
Ejemplo n.º 4
0
        public void pressedOK(NSObject sender)
        {
            Unused.Value = sender;

            NSApplication.sharedApplication().stopModalWithCode(Enums.NSOKButton);
            window().orderOut(this);
        }
		public void addDir(NSObject sender)
		{
			NSOpenPanel panel = NSOpenPanel.openPanel();
			panel.setCanChooseFiles(false);
			panel.setCanChooseDirectories(true);
			panel.setAllowsMultipleSelection(true);
			panel.setCanCreateDirectories(false);
			
			int result = panel.runModalForDirectory_file_types(null, null, null);
			if (result == Enums.NSOKButton && panel.filenames().count() > 0)
			{
				NSMutableArray dirs = NSMutableArray.Create();
				
				NSUserDefaults defaults = NSUserDefaults.standardUserDefaults();
				dirs.addObjectsFromArray(defaults.arrayForKey(NSString.Create("default find directories")));
				
				foreach (NSString path in panel.filenames())
				{
					if (!dirs.containsObject(path))
						dirs.addObject(path);
				}
				
				defaults.setObject_forKey(dirs, NSString.Create("default find directories"));
				m_find.AddDefaultDirs();
			}
		}
Ejemplo n.º 6
0
        public static void NSBeginInformationalAlertSheet(NSString title, NSString defaultButton, NSString alternateButton, NSString otherButton, NSWindow docWindow, NSObject modalDelegate, string didEndSelector, string didDismissSelector, IntPtr contextInfo, NSString message)
        {
            Selector endSelector = didEndSelector != null ? new Selector(didEndSelector) : null;
            Selector dismissSelector = didDismissSelector != null ? new Selector(didDismissSelector) : null;

            NativeMethods.NSBeginInformationalAlertSheet(title, defaultButton, alternateButton, otherButton, docWindow, modalDelegate, endSelector, dismissSelector, contextInfo, message);
        }
Ejemplo n.º 7
0
    public void memoryTest(NSObject sender)
    {
        lock (m_lock)
        {
            if (m_checkingMemory)
            {
                m_checkingMemory = false;
                Monitor.PulseAll(m_lock);

                m_thread1 = null;
                m_thread2 = null;
            }
            else
            {
                NSObject app = (NSObject) new Class("NSApplication").Call("sharedApplication");
                NSObject window = (NSObject) app.Call("mainWindow");
                NSObject content = (NSObject) window.Call("contentView");
                NSObject view = (NSObject) content.Call("viewWithTag:", 33);

                if (!view.IsNil())
                {
                    m_thread1 = new Thread(this.DoDumpStatsThread);
                    m_thread1.Start();

                    m_thread2 = new Thread(this.DoMemoryThread);
                    m_thread2.Start(view);

                    m_checkingMemory = true;
                }
                else
                    Console.WriteLine("Couldn't find the simple layout view.");
            }
        }
    }
Ejemplo n.º 8
0
    public void removeLastBox(NSObject sender)
    {
        NSObject last = Subviews.LastObject().To<NSObject>();
        last.Call("removeFromSuperview");

        DoLayout();
    }
        public void generatePressed(NSObject sender)
        {
            Generate = true;

            NSApplication.sharedApplication().stopModalWithCode(Enums.NSOKButton);
            window().orderOut(this);
        }
Ejemplo n.º 10
0
        public void replaceAndFind(NSObject sender)
        {
            Unused.Value = sender;

            OnUpdateLists();
            Finder.ReplaceAndFind();
        }
Ejemplo n.º 11
0
        public void next(NSObject sender)
        {
            Unused.Value = sender;

            OnUpdateLists();
            Finder.FindNext();
        }
Ejemplo n.º 12
0
    public void ArrayArg()
    {
        NSObject pool = new NSObject(NSObject.AllocAndInitInstance("NSAutoreleasePool"));
        Class nsData = new Class("NSData");
        long bytes = DoGetMemory();

        for (int j = 1; j < 100; ++j)
        {
            for (int i = 0; i < NumIterations/100; ++i)
            {
                byte[] data = new byte[]{2, 5, 6, 3};

                NSObject d = new NSObject(nsData.Call("alloc"));
                NSObject e = (NSObject) d.Call("initWithBytes:length:", data, data.Length);
                e.release();
            }
            GC.Collect();
        }

        pool.release();
        GC.Collect();
        GC.WaitForPendingFinalizers();

        long delta = DoGetMemory() - bytes;
        if (delta/NumIterations > 4)
            Assert.Fail("ArrayArg used {0}K of memory ({1} bytes per iteration)!", delta/1024, delta/NumIterations);
    }
Ejemplo n.º 13
0
        public void cancelPressed(NSObject sender)
        {
            Unused.Value = sender;

            NSApplication.sharedApplication().endSheet(m_sheet.Value);
            m_sheet.Value.orderOut(this);
            m_dir = null;
        }
Ejemplo n.º 14
0
 public void applicationWillTerminate(NSObject notification)
 {
     #if DEBUG
     // These are fairly expensive to create and it's easy to mess up and
     // create tons inside loops so we'll print the count here.
     Console.WriteLine("{0} BigFloat instances were created.", BigFloat.InstanceCount);
     #endif
 }
Ejemplo n.º 15
0
 public void DeInit()
 {
     if (m_pool != null)
     {
         m_pool.release();
         m_pool = null;
     }
 }
Ejemplo n.º 16
0
        public void flagsCancel(NSObject sender)
        {
            Unused.Value = sender;

            NSApplication.sharedApplication().stopModal();
            window().orderOut(this);
            window().release();
        }
Ejemplo n.º 17
0
    // Action methods to add/remove boxes, giving us something to animate. Note that we
    // cause a relayout here; a better design is to relayout in the view automatically on
    // addition/removal of subviews.
    public void addABox(NSObject sender)
    {
        NSObject box = DoNewBox();
        AddSubView(box);
        box.release();

        DoLayout();
    }
Ejemplo n.º 18
0
        public void pressedCancel(NSObject sender)
        {
            Unused.Value = sender;

            NSApplication.sharedApplication().stopModalWithCode(Enums.NSCancelButton);
            window().orderOut(this);

            Text = string.Empty;
        }
Ejemplo n.º 19
0
        public void doubleClicked(NSObject sender)
        {
            int row = m_table.selectedRow();
            row = m_stack.Length - row - 1;		// frames are drawn top down

            m_selected = row;
            m_table.reloadData();
            Broadcaster.Invoke("changed stack frame", m_stack[row]);
        }
Ejemplo n.º 20
0
		public void setDefaultColor(NSObject sender)
		{
			NSColor color = sender.Call("color").To<NSColor>();
			
			NSUserDefaults defaults = NSUserDefaults.standardUserDefaults();
			NSData data = NSArchiver.archivedDataWithRootObject(color);
			defaults.setObject_forKey(data, NSString.Create("text default color"));
			
			Broadcaster.Invoke("text default color changed", null);
		}
		public void removeDirs(NSObject sender)
		{
			NSIndexSet selections = m_dirsTable.Value.selectedRowIndexes();
			NSMutableArray dirs = NSMutableArray.Create();
			NSUserDefaults defaults = NSUserDefaults.standardUserDefaults();
			dirs.addObjectsFromArray(defaults.arrayForKey(NSString.Create("default find directories")));
			
			dirs.removeObjectsAtIndexes(selections);
			defaults.setObject_forKey(dirs, NSString.Create("default find directories"));
		}
Ejemplo n.º 22
0
    public void DeallocTest2()
    {
        NSObject pool = new NSObject(NSObject.AllocAndInitInstance("NSAutoreleasePool"));

        MyDerived instance = (MyDerived) new Class("MyDerived").Call("alloc").Call("init");
        Assert.AreEqual(1L, instance.retainCount());
        instance.release();
        Assert.IsTrue(instance.Dead);

        pool.release();
    }
Ejemplo n.º 23
0
        /// <param name = "title">The default menu item text.</param>
        /// <param name = "selector">The name of the method to call when the menu item is selected.</param>
        /// <param name = "charCode">The menu item's key equivalent.</param>
        /// <param name = "target">The instance to call when the menu item is selected. If null the first responder is used.</param>
        public static NSMenuItem Create(string title, string selector, string charCode, NSObject target)
        {
            NSMenuItem result = (NSMenuItem) ms_class.Call("alloc").
                Call("initWithTitle:action:keyEquivalent:", NSString.Create(title),
                    selector != null ? new Selector(selector) : null, NSString.Create(charCode));
            result.autorelease();

            if (target != null)
                result.setTarget(target);

            return result;
        }
Ejemplo n.º 24
0
    public void ChainedCallTest()
    {
        NSObject pool = new NSObject(NSObject.AllocAndInitInstance("NSAutoreleasePool"));

        Class nsString = new Class("NSMutableString");
        NSObject str = (NSObject) nsString.Call("alloc").Call("initWithUTF8String:", Marshal.StringToHGlobalAuto("chained!"));

        string result = Marshal.PtrToStringAuto((IntPtr) str.Call("UTF8String"));
        Assert.AreEqual("chained!", result);

        pool.release();
    }
Ejemplo n.º 25
0
        public void okPressed(NSObject sender)
        {
            Unused.Value = sender;

            NSApplication.sharedApplication().endSheet(m_sheet.Value);
            m_sheet.Value.orderOut(this);

            // save ignored targets
            string s = m_ignoredTargets.Value.stringValue().description();
            m_dir.IgnoredTargets = Glob.Split(s);

            // save ignored items
            s = m_ignoredItems.Value.stringValue().description();
            m_dir.IgnoredItems = Glob.Split(s);

            // save add space
            m_dir.AddSpace = m_addSpace.Value.state() == 1;

            // save add brace line
            m_dir.AddBraceLine = m_addBraceLine.Value.state() == 1;

            // use tabs
            m_dir.UseTabs = m_useTabs.Value.state() == 0;

            // number of spaces
            s = m_numSpaces.Value.stringValue().description();
            m_dir.NumSpaces = int.Parse(s);

            // save path color
            NSUserDefaults defaults = NSUserDefaults.standardUserDefaults();
            string path = m_dir.Path;

            var color = this["pathColor"].Call("color").To<NSObject>();
            var data = NSArchiver.archivedDataWithRootObject(color);
            defaults.setObject_forKey(data, NSString.Create(path + "-path color"));

            // save file colors/globs
            for (int i = 1; i <= DirectoryItemStyler.FilesCount; ++i)
            {
                color = this["files" + i + "Color"].Call("color").To<NSObject>();
                data = NSArchiver.archivedDataWithRootObject(color);
                defaults.setObject_forKey(data, NSString.Create(path + "-files" + i + " color"));

                var globs = this["files" + i + "Globs"].Call("stringValue").To<NSObject>();
                defaults.setObject_forKey(globs, NSString.Create(path + "-files" + i + " globs"));
            }

            // force the table to reload
            m_dir.Reload();

            Broadcaster.Invoke("directory prefs changed", m_dir.Boss);
            m_dir = null;
        }
 public void doubleClicked(NSObject sender)
 {
     uint count = m_table.selectedRowIndexes().count();
     if (NSApplication.sharedApplication().delegate_().Call("shouldOpenFiles:", count).To<bool>())
     {
         Boss boss = Gear.ObjectModel.Create("Application");
         var launcher = boss.Get<ILaunch>();
         foreach (uint row in m_table.selectedRowIndexes())
         {
             launcher.Launch(m_files[(int) row].FullPath, -1, -1, 1);
         }
     }
 }
Ejemplo n.º 27
0
    public void addEntry(NSObject sender)
    {
        DoAppendData("Untitled", 0);

        m_tableView.reloadData();
        DoUpdateChart();

        uint row = m_data.count() - 1;
        var indexes = NSIndexSet.indexSetWithIndex(row);
        m_tableView.selectRowIndexes_byExtendingSelection(indexes, false);

        m_tableView.editColumn_row_withEvent_select(
            m_tableView.columnWithIdentifier(DataKeyLabel), (int) row, null, false);
    }
Ejemplo n.º 28
0
		public void changeMonoRoot(NSObject sender)
		{
			NSOpenPanel panel = NSOpenPanel.Create();
			panel.setTitle(NSString.Create("Choose Mono Root"));
			panel.setCanChooseDirectories(true);
			panel.setCanChooseFiles(false);
			panel.setAllowsMultipleSelection(false);
			
			int button = panel.runModal();
			if (button == Enums.NSOKButton && panel.filenames().count() > 0)
			{
				NSUserDefaults defaults = NSUserDefaults.standardUserDefaults();
				defaults.setObject_forKey(panel.filenames().lastObject(), NSString.Create("mono_root"));
				
				Broadcaster.Invoke("mono_root changed", null);
			}
		}
Ejemplo n.º 29
0
    public void dumpObjects(NSObject sender)
    {
        List<string> lines = new List<string>();

        GC.Collect();
        GC.WaitForPendingFinalizers();

        foreach (NSObject o in NSObject.Snapshot())
        {
            lines.Add(o.ToString("G", null));
        }

        lines.Sort();
        foreach (string line in lines)
            Console.WriteLine(line);
        Console.WriteLine(" ");
    }
        public void searchPressed(NSObject sender)
        {
            NSOpenPanel panel = NSOpenPanel.Create();
            panel.setTitle(NSString.Create("Choose Build Script"));
            panel.setCanChooseDirectories(false);
            panel.setCanChooseFiles(true);
            panel.setAllowsMultipleSelection(false);

            int button = panel.runModal();
            if (button == Enums.NSOKButton && panel.URLs().count() == 1)
            {
                NSURL url = panel.URL();
                Path = url.path().ToString();

                NSApplication.sharedApplication().stopModalWithCode(Enums.NSOKButton);
                window().orderOut(this);
            }
        }