Search Support

This commit is contained in:
Justin Aquadro 2012-11-10 20:32:46 -05:00
parent e1259d6880
commit e38b9fca53
15 changed files with 1576 additions and 97 deletions

View file

@ -21,6 +21,11 @@ namespace NBTExplorer
mainWindowController.Window.AppDelegate = this;
}
public override bool ApplicationShouldTerminateAfterLastWindowClosed (NSApplication sender)
{
return true;
}
public NSMenuItem MenuAbout
{
get { return _menuAbout; }
@ -156,17 +161,37 @@ namespace NBTExplorer
get { return _menuInsertCompound; }
}
partial void ActionCut (MonoMac.Foundation.NSObject sender)
partial void ActionOpen (NSObject sender)
{
mainWindowController.Window.ActionOpen();
}
partial void ActionOpenFolder (NSObject sender)
{
mainWindowController.Window.ActionOpenFolder();
}
partial void ActionOpenMinecraft (NSObject sender)
{
mainWindowController.Window.ActionOpenMinecraft();
}
partial void ActionSave (NSObject sender)
{
mainWindowController.Window.ActionSave();
}
partial void ActionCut (NSObject sender)
{
mainWindowController.Window.ActionCut();
}
partial void ActionCopy (MonoMac.Foundation.NSObject sender)
partial void ActionCopy (NSObject sender)
{
mainWindowController.Window.ActionCopy();
}
partial void ActionPaste (MonoMac.Foundation.NSObject sender)
partial void ActionPaste (NSObject sender)
{
mainWindowController.Window.ActionPaste();
}
@ -196,6 +221,16 @@ namespace NBTExplorer
mainWindowController.Window.ActionMoveNodeDown();
}
partial void ActionFind (NSObject sender)
{
mainWindowController.Window.ActionFind();
}
partial void ActionFindNext (NSObject sender)
{
mainWindowController.Window.ActionFindNext();
}
partial void ActionInsertByte (NSObject sender)
{
mainWindowController.Window.ActionInsertByteTag();

35
Mac/CancelFindWindow.cs Normal file
View file

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MonoMac.Foundation;
using MonoMac.AppKit;
namespace NBTExplorer.Mac
{
public partial class CancelFindWindow : MonoMac.AppKit.NSWindow
{
#region Constructors
// Called when created from unmanaged code
public CancelFindWindow (IntPtr handle) : base (handle)
{
Initialize ();
}
// Called when created directly from a XIB file
[Export ("initWithCoder:")]
public CancelFindWindow (NSCoder coder) : base (coder)
{
Initialize ();
}
// Shared initialization code
void Initialize ()
{
}
#endregion
}
}

30
Mac/CancelFindWindow.designer.cs generated Normal file
View file

@ -0,0 +1,30 @@
// WARNING
//
// This file has been generated automatically by MonoDevelop to store outlets and
// actions made in the Xcode designer. If it is removed, they will be lost.
// Manual changes to this file may not be handled correctly.
//
using MonoMac.Foundation;
namespace NBTExplorer.Mac
{
[Register ("CancelFindWindowController")]
partial class CancelFindWindowController
{
[Action ("ActionCancel:")]
partial void ActionCancel (MonoMac.Foundation.NSObject sender);
void ReleaseDesignerOutlets ()
{
}
}
[Register ("CancelFindWindow")]
partial class CancelFindWindow
{
void ReleaseDesignerOutlets ()
{
}
}
}

246
Mac/CancelFindWindow.xib Normal file
View file

@ -0,0 +1,246 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1080</int>
<string key="IBDocument.SystemVersion">12C2034</string>
<string key="IBDocument.InterfaceBuilderVersion">2844</string>
<string key="IBDocument.AppKitVersion">1187.34</string>
<string key="IBDocument.HIToolboxVersion">625.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">2844</string>
</object>
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSButton</string>
<string>NSButtonCell</string>
<string>NSCustomObject</string>
<string>NSView</string>
<string>NSWindowTemplate</string>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
<integer value="1" key="NS.object.0"/>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSCustomObject" id="1001">
<string key="NSClassName">CancelFindWindowController</string>
</object>
<object class="NSCustomObject" id="1003">
<string key="NSClassName">FirstResponder</string>
</object>
<object class="NSCustomObject" id="1004">
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSWindowTemplate" id="748157544">
<int key="NSWindowStyleMask">1</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{131, 74}, {398, 100}}</string>
<int key="NSWTFlags">611844096</int>
<string key="NSWindowTitle">Searching...</string>
<string key="NSWindowClass">CancelFindWindow</string>
<nil key="NSViewClass"/>
<nil key="NSUserInterfaceItemIdentifier"/>
<object class="NSView" key="NSWindowView" id="312036702">
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSButton" id="309733224">
<reference key="NSNextResponder" ref="312036702"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{158, 13}, {82, 32}}</string>
<reference key="NSSuperview" ref="312036702"/>
<reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="841196979">
<int key="NSCellFlags">67108864</int>
<int key="NSCellFlags2">134217728</int>
<string key="NSContents">Cancel</string>
<object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double>
<int key="NSfFlags">1044</int>
</object>
<string key="NSCellIdentifier">_NS:9</string>
<reference key="NSControlView" ref="309733224"/>
<int key="NSButtonFlags">-2038284288</int>
<int key="NSButtonFlags2">129</int>
<string key="NSAlternateContents"/>
<string type="base64-UTF8" key="NSKeyEquivalent">Gw</string>
<int key="NSPeriodicDelay">200</int>
<int key="NSPeriodicInterval">25</int>
</object>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
</object>
</object>
<string key="NSFrameSize">{398, 100}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1280, 778}}</string>
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
<bool key="NSWindowIsRestorable">YES</bool>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">window</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="748157544"/>
</object>
<int key="connectionID">6</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">ActionCancel:</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="309733224"/>
</object>
<int key="connectionID">9</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
<object class="NSArray" key="object" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="1001"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="1003"/>
<reference key="parent" ref="0"/>
<string key="objectName">First Responder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-3</int>
<reference key="object" ref="1004"/>
<reference key="parent" ref="0"/>
<string key="objectName">Application</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">2</int>
<reference key="object" ref="748157544"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="312036702"/>
</object>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">3</int>
<reference key="object" ref="312036702"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="309733224"/>
</object>
<reference key="parent" ref="748157544"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">7</int>
<reference key="object" ref="309733224"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="841196979"/>
</object>
<reference key="parent" ref="312036702"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">8</int>
<reference key="object" ref="841196979"/>
<reference key="parent" ref="309733224"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.IBPluginDependency</string>
<string>-2.IBPluginDependency</string>
<string>-3.IBPluginDependency</string>
<string>2.IBPluginDependency</string>
<string>2.IBWindowTemplateEditedContentRect</string>
<string>2.NSWindowTemplate.visibleAtLaunch</string>
<string>3.IBPluginDependency</string>
<string>7.IBPluginDependency</string>
<string>8.IBPluginDependency</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{319, 371}, {606, 354}}</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<reference key="dict.values" ref="0"/>
</object>
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">9</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">CancelFindWindow</string>
<string key="superclassName">NSWindow</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/CancelFindWindow.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">CancelFindWindowController</string>
<string key="superclassName">NSWindowController</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/CancelFindWindowController.h</string>
</object>
</object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
<integer value="3000" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
</data>
</archive>

View file

@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MonoMac.Foundation;
using MonoMac.AppKit;
namespace NBTExplorer.Mac
{
public partial class CancelFindWindowController : MonoMac.AppKit.NSWindowController
{
#region Constructors
// Called when created from unmanaged code
public CancelFindWindowController (IntPtr handle) : base (handle)
{
Initialize ();
}
// Called when created directly from a XIB file
[Export ("initWithCoder:")]
public CancelFindWindowController (NSCoder coder) : base (coder)
{
Initialize ();
}
// Call to load from the XIB/NIB file
public CancelFindWindowController () : base ("CancelFindWindow")
{
Initialize ();
}
// Shared initialization code
void Initialize ()
{
}
#endregion
//strongly typed window accessor
public new CancelFindWindow Window
{
get {
return (CancelFindWindow)base.Window;
}
}
public void Accept ()
{
NSApplication.SharedApplication.StopModalWithCode((int)ModalResult.OK);
}
public void Cancel ()
{
NSApplication.SharedApplication.StopModalWithCode((int)ModalResult.Cancel);
}
partial void ActionCancel (MonoMac.Foundation.NSObject sender)
{
NSApplication.SharedApplication.StopModalWithCode((int)ModalResult.Cancel);
}
}
}

35
Mac/FindWindow.cs Normal file
View file

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MonoMac.Foundation;
using MonoMac.AppKit;
namespace NBTExplorer.Mac
{
public partial class FindWindow : MonoMac.AppKit.NSWindow
{
#region Constructors
// Called when created from unmanaged code
public FindWindow (IntPtr handle) : base (handle)
{
Initialize ();
}
// Called when created directly from a XIB file
[Export ("initWithCoder:")]
public FindWindow (NSCoder coder) : base (coder)
{
Initialize ();
}
// Shared initialization code
void Initialize ()
{
}
#endregion
}
}

64
Mac/FindWindow.designer.cs generated Normal file
View file

@ -0,0 +1,64 @@
// WARNING
//
// This file has been generated automatically by MonoDevelop to store outlets and
// actions made in the Xcode designer. If it is removed, they will be lost.
// Manual changes to this file may not be handled correctly.
//
using MonoMac.Foundation;
namespace NBTExplorer.Mac
{
[Register ("FindWindowController")]
partial class FindWindowController
{
[Outlet]
MonoMac.AppKit.NSButton _nameToggle { get; set; }
[Outlet]
MonoMac.AppKit.NSButton _valueToggle { get; set; }
[Outlet]
MonoMac.AppKit.NSTextField _nameField { get; set; }
[Outlet]
MonoMac.AppKit.NSTextField _valueField { get; set; }
[Action ("ActionFind:")]
partial void ActionFind (MonoMac.Foundation.NSObject sender);
[Action ("ActionCancel:")]
partial void ActionCancel (MonoMac.Foundation.NSObject sender);
void ReleaseDesignerOutlets ()
{
if (_nameToggle != null) {
_nameToggle.Dispose ();
_nameToggle = null;
}
if (_valueToggle != null) {
_valueToggle.Dispose ();
_valueToggle = null;
}
if (_nameField != null) {
_nameField.Dispose ();
_nameField = null;
}
if (_valueField != null) {
_valueField.Dispose ();
_valueField = null;
}
}
}
[Register ("FindWindow")]
partial class FindWindow
{
void ReleaseDesignerOutlets ()
{
}
}
}

611
Mac/FindWindow.xib Normal file
View file

@ -0,0 +1,611 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1080</int>
<string key="IBDocument.SystemVersion">12C2034</string>
<string key="IBDocument.InterfaceBuilderVersion">2844</string>
<string key="IBDocument.AppKitVersion">1187.34</string>
<string key="IBDocument.HIToolboxVersion">625.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">2844</string>
</object>
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSButton</string>
<string>NSButtonCell</string>
<string>NSCustomObject</string>
<string>NSTextField</string>
<string>NSTextFieldCell</string>
<string>NSView</string>
<string>NSWindowTemplate</string>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
<integer value="1" key="NS.object.0"/>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSCustomObject" id="1001">
<string key="NSClassName">FindWindowController</string>
</object>
<object class="NSCustomObject" id="1003">
<string key="NSClassName">FirstResponder</string>
</object>
<object class="NSCustomObject" id="1004">
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSWindowTemplate" id="748157544">
<int key="NSWindowStyleMask">1</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{131, 74}, {421, 118}}</string>
<int key="NSWTFlags">611844096</int>
<string key="NSWindowTitle">Find</string>
<string key="NSWindowClass">FindWindow</string>
<nil key="NSViewClass"/>
<nil key="NSUserInterfaceItemIdentifier"/>
<object class="NSView" key="NSWindowView" id="312036702">
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSButton" id="1054503563">
<reference key="NSNextResponder" ref="312036702"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{18, 82}, {61, 18}}</string>
<reference key="NSSuperview" ref="312036702"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="162661195"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="341166991">
<int key="NSCellFlags">-2080374784</int>
<int key="NSCellFlags2">268435456</int>
<string key="NSContents">Name:</string>
<object class="NSFont" key="NSSupport" id="583360529">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double>
<int key="NSfFlags">1044</int>
</object>
<string key="NSCellIdentifier">_NS:9</string>
<reference key="NSControlView" ref="1054503563"/>
<int key="NSButtonFlags">1211912448</int>
<int key="NSButtonFlags2">2</int>
<object class="NSCustomResource" key="NSNormalImage" id="824791932">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSSwitch</string>
</object>
<object class="NSButtonImageSource" key="NSAlternateImage" id="806878124">
<string key="NSImageName">NSSwitch</string>
</object>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
<int key="NSPeriodicDelay">200</int>
<int key="NSPeriodicInterval">25</int>
</object>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
</object>
<object class="NSButton" id="46593628">
<reference key="NSNextResponder" ref="312036702"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{18, 50}, {61, 18}}</string>
<reference key="NSSuperview" ref="312036702"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="30318933"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="902018411">
<int key="NSCellFlags">67108864</int>
<int key="NSCellFlags2">268435456</int>
<string key="NSContents">Value:</string>
<reference key="NSSupport" ref="583360529"/>
<string key="NSCellIdentifier">_NS:9</string>
<reference key="NSControlView" ref="46593628"/>
<int key="NSButtonFlags">1211912448</int>
<int key="NSButtonFlags2">2</int>
<reference key="NSNormalImage" ref="824791932"/>
<reference key="NSAlternateImage" ref="806878124"/>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
<int key="NSPeriodicDelay">200</int>
<int key="NSPeriodicInterval">25</int>
</object>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
</object>
<object class="NSTextField" id="162661195">
<reference key="NSNextResponder" ref="312036702"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{102, 81}, {299, 22}}</string>
<reference key="NSSuperview" ref="312036702"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="46593628"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="684116786">
<int key="NSCellFlags">-1804599231</int>
<int key="NSCellFlags2">272630784</int>
<string key="NSContents"/>
<reference key="NSSupport" ref="583360529"/>
<string key="NSCellIdentifier">_NS:9</string>
<reference key="NSControlView" ref="162661195"/>
<bool key="NSDrawsBackground">YES</bool>
<object class="NSColor" key="NSBackgroundColor" id="7773899">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">textBackgroundColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
</object>
</object>
<object class="NSColor" key="NSTextColor" id="314138322">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">textColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
</object>
</object>
</object>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
</object>
<object class="NSTextField" id="30318933">
<reference key="NSNextResponder" ref="312036702"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{102, 49}, {299, 22}}</string>
<reference key="NSSuperview" ref="312036702"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="728691861"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="341615923">
<int key="NSCellFlags">-1804599231</int>
<int key="NSCellFlags2">272630784</int>
<string key="NSContents"/>
<reference key="NSSupport" ref="583360529"/>
<string key="NSCellIdentifier">_NS:9</string>
<reference key="NSControlView" ref="30318933"/>
<bool key="NSDrawsBackground">YES</bool>
<reference key="NSBackgroundColor" ref="7773899"/>
<reference key="NSTextColor" ref="314138322"/>
</object>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
</object>
<object class="NSButton" id="562800975">
<reference key="NSNextResponder" ref="312036702"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{325, 13}, {82, 32}}</string>
<reference key="NSSuperview" ref="312036702"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="7285492">
<int key="NSCellFlags">67108864</int>
<int key="NSCellFlags2">134217728</int>
<string key="NSContents">Find</string>
<reference key="NSSupport" ref="583360529"/>
<string key="NSCellIdentifier">_NS:9</string>
<reference key="NSControlView" ref="562800975"/>
<int key="NSButtonFlags">-2038284288</int>
<int key="NSButtonFlags2">129</int>
<string key="NSAlternateContents"/>
<string type="base64-UTF8" key="NSKeyEquivalent">DQ</string>
<int key="NSPeriodicDelay">200</int>
<int key="NSPeriodicInterval">25</int>
</object>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
</object>
<object class="NSButton" id="728691861">
<reference key="NSNextResponder" ref="312036702"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{243, 13}, {82, 32}}</string>
<reference key="NSSuperview" ref="312036702"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="562800975"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="341956957">
<int key="NSCellFlags">67108864</int>
<int key="NSCellFlags2">134217728</int>
<string key="NSContents">Cancel</string>
<reference key="NSSupport" ref="583360529"/>
<string key="NSCellIdentifier">_NS:9</string>
<reference key="NSControlView" ref="728691861"/>
<int key="NSButtonFlags">-2038284288</int>
<int key="NSButtonFlags2">129</int>
<string key="NSAlternateContents"/>
<string type="base64-UTF8" key="NSKeyEquivalent">Gw</string>
<int key="NSPeriodicDelay">200</int>
<int key="NSPeriodicInterval">25</int>
</object>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
</object>
</object>
<string key="NSFrameSize">{421, 118}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1054503563"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1600, 1178}}</string>
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
<bool key="NSWindowIsRestorable">YES</bool>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">window</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="748157544"/>
</object>
<int key="connectionID">6</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">_nameToggle</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="1054503563"/>
</object>
<int key="connectionID">25</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">_valueToggle</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="46593628"/>
</object>
<int key="connectionID">26</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">_nameField</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="162661195"/>
</object>
<int key="connectionID">27</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">_valueField</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="30318933"/>
</object>
<int key="connectionID">28</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">ActionFind:</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="562800975"/>
</object>
<int key="connectionID">29</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">ActionCancel:</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="728691861"/>
</object>
<int key="connectionID">30</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
<object class="NSArray" key="object" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="1001"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="1003"/>
<reference key="parent" ref="0"/>
<string key="objectName">First Responder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-3</int>
<reference key="object" ref="1004"/>
<reference key="parent" ref="0"/>
<string key="objectName">Application</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">2</int>
<reference key="object" ref="748157544"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="312036702"/>
</object>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">3</int>
<reference key="object" ref="312036702"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="162661195"/>
<reference ref="46593628"/>
<reference ref="1054503563"/>
<reference ref="30318933"/>
<reference ref="562800975"/>
<reference ref="728691861"/>
</object>
<reference key="parent" ref="748157544"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">7</int>
<reference key="object" ref="1054503563"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="341166991"/>
</object>
<reference key="parent" ref="312036702"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">8</int>
<reference key="object" ref="341166991"/>
<reference key="parent" ref="1054503563"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">9</int>
<reference key="object" ref="46593628"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="902018411"/>
</object>
<reference key="parent" ref="312036702"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">10</int>
<reference key="object" ref="902018411"/>
<reference key="parent" ref="46593628"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">11</int>
<reference key="object" ref="162661195"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="684116786"/>
</object>
<reference key="parent" ref="312036702"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">12</int>
<reference key="object" ref="684116786"/>
<reference key="parent" ref="162661195"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">13</int>
<reference key="object" ref="30318933"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="341615923"/>
</object>
<reference key="parent" ref="312036702"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">14</int>
<reference key="object" ref="341615923"/>
<reference key="parent" ref="30318933"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">15</int>
<reference key="object" ref="562800975"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="7285492"/>
</object>
<reference key="parent" ref="312036702"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">16</int>
<reference key="object" ref="7285492"/>
<reference key="parent" ref="562800975"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">17</int>
<reference key="object" ref="728691861"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="341956957"/>
</object>
<reference key="parent" ref="312036702"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">18</int>
<reference key="object" ref="341956957"/>
<reference key="parent" ref="728691861"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.IBPluginDependency</string>
<string>-2.IBPluginDependency</string>
<string>-3.IBPluginDependency</string>
<string>10.IBPluginDependency</string>
<string>11.IBPluginDependency</string>
<string>12.IBPluginDependency</string>
<string>13.IBPluginDependency</string>
<string>14.IBPluginDependency</string>
<string>15.IBPluginDependency</string>
<string>16.IBPluginDependency</string>
<string>17.IBPluginDependency</string>
<string>18.IBPluginDependency</string>
<string>2.IBPluginDependency</string>
<string>2.IBWindowTemplateEditedContentRect</string>
<string>2.NSWindowTemplate.visibleAtLaunch</string>
<string>3.IBPluginDependency</string>
<string>7.IBPluginDependency</string>
<string>8.IBPluginDependency</string>
<string>9.IBPluginDependency</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{319, 371}, {606, 354}}</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<reference key="dict.values" ref="0"/>
</object>
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">30</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">FindWindow</string>
<string key="superclassName">NSWindow</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/FindWindow.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">FindWindowController</string>
<string key="superclassName">NSWindowController</string>
<object class="NSMutableDictionary" key="actions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>ActionCancel:</string>
<string>ActionFind:</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>ActionCancel:</string>
<string>ActionFind:</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBActionInfo">
<string key="name">ActionCancel:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">ActionFind:</string>
<string key="candidateClassName">id</string>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>_nameField</string>
<string>_nameToggle</string>
<string>_valueField</string>
<string>_valueToggle</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSTextField</string>
<string>NSButton</string>
<string>NSTextField</string>
<string>NSButton</string>
</object>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>_nameField</string>
<string>_nameToggle</string>
<string>_valueField</string>
<string>_valueToggle</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBToOneOutletInfo">
<string key="name">_nameField</string>
<string key="candidateClassName">NSTextField</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">_nameToggle</string>
<string key="candidateClassName">NSButton</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">_valueField</string>
<string key="candidateClassName">NSTextField</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">_valueToggle</string>
<string key="candidateClassName">NSButton</string>
</object>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/FindWindowController.h</string>
</object>
</object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
<integer value="3000" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<object class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
<string key="NS.key.0">NSSwitch</string>
<string key="NS.object.0">{15, 15}</string>
</object>
</data>
</archive>

View file

@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MonoMac.Foundation;
using MonoMac.AppKit;
namespace NBTExplorer.Mac
{
public partial class FindWindowController : MonoMac.AppKit.NSWindowController
{
#region Constructors
// Called when created from unmanaged code
public FindWindowController (IntPtr handle) : base (handle)
{
Initialize ();
}
// Called when created directly from a XIB file
[Export ("initWithCoder:")]
public FindWindowController (NSCoder coder) : base (coder)
{
Initialize ();
}
// Call to load from the XIB/NIB file
public FindWindowController () : base ("FindWindow")
{
Initialize ();
}
// Shared initialization code
void Initialize ()
{
}
#endregion
//strongly typed window accessor
public new FindWindow Window
{
get {
return (FindWindow)base.Window;
}
}
public bool MatchName
{
get { return _nameToggle.State == NSCellStateValue.On; }
}
public bool MatchValue
{
get { return _valueToggle.State == NSCellStateValue.On; }
}
public string NameToken
{
get { return _nameField.StringValue; }
}
public string ValueToken
{
get { return _valueField.StringValue; }
}
partial void ActionFind (NSObject sender)
{
NSApplication.SharedApplication.StopModalWithCode((int)ModalResult.OK);
}
partial void ActionCancel (NSObject sender)
{
NSApplication.SharedApplication.StopModalWithCode((int)ModalResult.Cancel);
}
}
}

View file

@ -8,6 +8,7 @@ using NBTExplorer.Mac;
using System.IO;
using NBTExplorer.Model;
using Substrate.Nbt;
using System.Threading;
namespace NBTExplorer
{
@ -31,6 +32,7 @@ namespace NBTExplorer
// Shared initialization code
void Initialize ()
{
Delegate = new WindowDelegate(this);
InitializeIconRegistry();
FormHandlers.Register();
NbtClipboardController.Initialize(new NbtClipboardControllerMac());
@ -98,6 +100,22 @@ namespace NBTExplorer
}
}
public class WindowDelegate : NSWindowDelegate
{
private MainWindow _main;
public WindowDelegate (MainWindow main) {
_main = main;
}
public override bool WindowShouldClose (NSObject sender)
{
//Settings.Default.RecentFiles = Settings.Default.RecentFiles;
//Settings.Default.Save();
return _main.ConfirmExit();
}
}
public class MyDelegate : NSOutlineViewDelegate
{
private MainWindow _main;
@ -163,11 +181,16 @@ namespace NBTExplorer
#region Actions
partial void ActionOpenFolder (MonoMac.Foundation.NSObject sender)
partial void ActionOpenFolder (NSObject sender)
{
OpenFolder ();
}
partial void ActionSave (NSObject sender)
{
ActionSave ();
}
#endregion
private string _openFolderPath = null;
@ -189,6 +212,23 @@ namespace NBTExplorer
UpdateUI();
}
private void OpenFile ()
{
NSOpenPanel opanel = new NSOpenPanel ();
opanel.CanChooseDirectories = false;
opanel.CanChooseFiles = true;
//opanel.AllowsMultipleSelection = true;
if (opanel.RunModal() == (int)NSPanelButtonType.Ok) {
List<string> paths = new List<string>();
foreach (var url in opanel.Urls)
paths.Add(url.Path);
OpenPaths(paths);
}
UpdateUI();
}
private void OpenMinecraftDirectory ()
{
try {
@ -203,7 +243,7 @@ namespace NBTExplorer
OpenPaths(new string[] { path });
}
catch (Exception e) {
//NSAlert.WithMessage("Could not open default Minecraft save directory", "OK", null, null, null).RunModal();
NSAlert.WithMessage("Operation Failed", "OK", null, null, "Could not open default Minecraft save directory").RunModal();
Console.WriteLine(e.Message);
try {
@ -219,7 +259,7 @@ namespace NBTExplorer
UpdateUI();
}
private void OpenPaths (string[] paths)
private void OpenPaths (IEnumerable<string> paths)
{
_dataSource.Nodes.Clear ();
_mainOutlineView.ReloadData ();
@ -242,37 +282,6 @@ namespace NBTExplorer
_mainOutlineView.ReloadData();
UpdateUI();
// UpdateOpenMenu();
/*_nodeTree.Nodes.Clear();
foreach (string path in paths) {
if (Directory.Exists(path)) {
DirectoryDataNode node = new DirectoryDataNode(path);
_nodeTree.Nodes.Add(CreateUnexpandedNode(node));
AddPathToHistory(Settings.Default.RecentDirectories, path);
}
else if (File.Exists(path)) {
DataNode node = null;
foreach (var item in FileTypeRegistry.RegisteredTypes) {
if (item.Value.NamePatternTest(path))
node = item.Value.NodeCreate(path);
}
if (node != null) {
_nodeTree.Nodes.Add(CreateUnexpandedNode(node));
AddPathToHistory(Settings.Default.RecentFiles, path);
}
}
}
if (_nodeTree.Nodes.Count > 0) {
_nodeTree.Nodes[0].Expand();
}
UpdateUI();
UpdateOpenMenu();*/
}
private void ExpandNode (TreeDataNode node)
@ -302,7 +311,7 @@ namespace NBTExplorer
if (node == null || !node.IsExpanded)
return;
/*Console.WriteLine("Collapse Node: " + node.Data.NodeDisplay);
Console.WriteLine("Collapse Node: " + node.Data.NodeDisplay);
DataNode backNode = node.Data;
if (backNode.IsModified)
@ -311,7 +320,7 @@ namespace NBTExplorer
backNode.Collapse();
node.IsExpanded = false;
node.Nodes.Clear();*/
node.Nodes.Clear();
}
private void RefreshChildNodes (TreeDataNode node, DataNode dataNode)
@ -361,6 +370,29 @@ namespace NBTExplorer
get { return _mainOutlineView.ItemAtRow (_mainOutlineView.SelectedRow) as TreeDataNode; }
}
public void ActionOpen ()
{
if (ConfirmOpen())
OpenFile();
}
public void ActionOpenFolder ()
{
if (ConfirmOpen ())
OpenFolder ();
}
public void ActionOpenMinecraft ()
{
if (ConfirmOpen ())
OpenMinecraftDirectory();
}
public void ActionSave ()
{
Save ();
}
public void ActionCopy ()
{
CopyNode (SelectedNode);
@ -401,6 +433,16 @@ namespace NBTExplorer
MoveNodeDown (SelectedNode);
}
public void ActionFind ()
{
SearchNode (SelectedNode);
}
public void ActionFindNext ()
{
SearchNextNode();
}
public void ActionInsertByteTag ()
{
CreateNode (SelectedNode, TagType.TAG_BYTE);
@ -567,50 +609,6 @@ namespace NBTExplorer
node.Data.ChangeRelativePosition(1);
RefreshChildNodes(node.Parent, node.Data.Parent);
}
/*private void CopyNode (TreeNode node)
{
if (node == null || !(node.Tag is DataNode))
return;
DataNode dataNode = node.Tag as DataNode;
if (!dataNode.CanCopyNode)
return;
dataNode.CopyNode();
}
private void CutNode (TreeNode node)
{
if (node == null || !(node.Tag is DataNode))
return;
DataNode dataNode = node.Tag as DataNode;
if (!dataNode.CanCutNode)
return;
if (dataNode.CutNode()) {
UpdateUI(node.Parent.Tag as DataNode);
UpdateNodeText(node.Parent);
node.Remove();
}
}
private void PasteNode (TreeNode node)
{
if (node == null || !(node.Tag is DataNode))
return;
DataNode dataNode = node.Tag as DataNode;
if (!dataNode.CanPasteIntoNode)
return;
if (dataNode.PasteNode()) {
node.Text = dataNode.NodeDisplay;
RefreshChildNodes(node, dataNode);
UpdateUI(dataNode);
}
}*/
private void Save ()
{
@ -621,16 +619,186 @@ namespace NBTExplorer
UpdateUI();
}
private static ModalResult RunWindow (NSWindowController controller)
{
int response = NSApplication.SharedApplication.RunModalForWindow (controller.Window);
controller.Window.Close();
controller.Window.OrderOut(null);
if (!Enum.IsDefined(typeof(ModalResult), response))
response = 0;
return (ModalResult)response;
}
private CancelFindWindowController _searchForm;
private SearchStateMac _searchState;
/*private bool ConfirmExit ()
private void SearchNode (TreeDataNode node)
{
if (node == null)
return;
if (!node.Data.CanSearchNode)
return;
FindWindowController form = new FindWindowController();
if (RunWindow (form) != ModalResult.OK)
return;
_searchState = new SearchStateMac(this) {
RootNode = node.Data,
SearchName = form.NameToken,
SearchValue = form.ValueToken,
DiscoverCallback = SearchDiscoveryCallback,
CollapseCallback = SearchCollapseCallback,
EndCallback = SearchEndCallback,
};
SearchNextNode();
}
private void SearchNextNode ()
{
if (_searchState == null)
return;
SearchWorker worker = new SearchWorker (_searchState);
Thread t = new Thread (new ThreadStart (worker.Run));
t.IsBackground = true;
t.Start ();
_searchForm = new CancelFindWindowController ();
if (RunWindow (_searchForm) == ModalResult.Cancel) {
worker.Cancel();
_searchState = null;
}
t.Join();
}
private void SearchDiscoveryCallback (DataNode node)
{
Console.WriteLine ("Discovery: " + node.NodeDisplay);
TreeDataNode frontNode = FindFrontNode(node);
Console.WriteLine (" Front Node: " + frontNode.Data.NodeDisplay);
_mainOutlineView.SelectRow (_mainOutlineView.RowForItem(frontNode), false);
_mainOutlineView.ScrollRowToVisible(_mainOutlineView.RowForItem(frontNode));
//_nodeTree.SelectedNode = FindFrontNode(node);
if (_searchForm != null) {
_searchForm.Accept();
_searchForm = null;
}
}
private void SearchCollapseCallback (DataNode node)
{
CollapseBelow(node);
}
private void SearchEndCallback (DataNode node)
{
_searchForm.Cancel();
_searchForm = null;
NSAlert.WithMessage("End of Results", "OK", null, null, "").RunModal();
}
private TreeDataNode GetRootFromDataNodePath (DataNode node, out Stack<DataNode> hierarchy)
{
hierarchy = new Stack<DataNode>();
while (node != null) {
hierarchy.Push(node);
node = node.Parent;
}
DataNode rootDataNode = hierarchy.Pop();
TreeDataNode frontNode = null;
foreach (TreeDataNode child in _dataSource.Nodes) {
if (child.Data == rootDataNode)
frontNode = child;
}
return frontNode;
}
private TreeDataNode FindFrontNode (DataNode node)
{
Stack<DataNode> hierarchy;
TreeDataNode frontNode = GetRootFromDataNodePath(node, out hierarchy);
if (frontNode == null)
return null;
while (hierarchy.Count > 0) {
if (!frontNode.IsExpanded) {
_mainOutlineView.ExpandItem(frontNode);
_mainOutlineView.ReloadItem(frontNode);
}
DataNode childData = hierarchy.Pop();
foreach (TreeDataNode childFront in frontNode.Nodes) {
if (childFront.Data == childData) {
frontNode = childFront;
break;
}
}
}
return frontNode;
}
private void CollapseBelow (DataNode node)
{
Stack<DataNode> hierarchy;
TreeDataNode frontNode = GetRootFromDataNodePath (node, out hierarchy);
if (frontNode == null)
return;
while (hierarchy.Count > 0) {
if (!frontNode.IsExpanded)
return;
DataNode childData = hierarchy.Pop ();
foreach (TreeDataNode childFront in frontNode.Nodes) {
if (childFront.Data == childData) {
frontNode = childFront;
break;
}
}
}
if (frontNode.IsExpanded) {
_mainOutlineView.CollapseItem (frontNode);
frontNode.IsExpanded = false;
}
}
private bool ConfirmExit ()
{
if (CheckModifications()) {
if (MessageBox.Show("You currently have unsaved changes. Close anyway?", "Unsaved Changes", MessageBoxButtons.OKCancel) != DialogResult.OK)
int id = NSAlert.WithMessage("Unsaved Changes", "OK", "Cancel", "", "You currently have unsaved changes. Close anyway?").RunModal();
if (id != 1)
return false;
}
return true;
}*/
}
private bool ConfirmOpen ()
{
if (CheckModifications()) {
int id = NSAlert.WithMessage("Unsaved Changes", "OK", "Cancel", "", "You currently have unsaved changes. Open new location anyway?").RunModal();
if (id != 1)
return false;
}
return true;
}
private bool CheckModifications ()
{
@ -656,7 +824,7 @@ namespace NBTExplorer
_appDelegate.MenuSave.Enabled = CheckModifications();
_appDelegate.MenuFind.Enabled = false;
//_appDelegate.MenuFindNext.Enabled = _searchState != null;
_appDelegate.MenuFindNext.Enabled = _searchState != null;
_toolbarSave.Enabled = _appDelegate.MenuSave.Enabled;
}
@ -689,7 +857,7 @@ namespace NBTExplorer
_appDelegate.MenuMoveUp.Enabled = node.CanMoveNodeUp;
_appDelegate.MenuMoveDown.Enabled = node.CanMoveNodeDown;
_appDelegate.MenuFind.Enabled = node.CanSearchNode;
//_appDelegate.MenuFindNext.Enabled = _searchState != null;
_appDelegate.MenuFindNext.Enabled = _searchState != null;
_toolbarSave.Enabled = _appDelegate.MenuSave.Enabled;
}

View file

@ -2,10 +2,10 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1080</int>
<string key="IBDocument.SystemVersion">12B2080</string>
<string key="IBDocument.SystemVersion">12C2034</string>
<string key="IBDocument.InterfaceBuilderVersion">2844</string>
<string key="IBDocument.AppKitVersion">1187</string>
<string key="IBDocument.HIToolboxVersion">624.00</string>
<string key="IBDocument.AppKitVersion">1187.34</string>
<string key="IBDocument.HIToolboxVersion">625.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">2844</string>
@ -70,6 +70,7 @@
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>0156226B-2E18-4406-BBE6-7C88F62B4E27</string>
<string>A7443D4A-610D-4239-8FC6-AD74A87D607E</string>
<string>B62CA8DD-7D49-4BF3-B4AB-417078852D8B</string>
<string>NSToolbarFlexibleSpaceItem</string>
<string>NSToolbarSpaceItem</string>
@ -93,7 +94,29 @@
<string key="NSToolbarItemMinSize">{0, 0}</string>
<string key="NSToolbarItemMaxSize">{0, 0}</string>
<bool key="NSToolbarItemEnabled">YES</bool>
<bool key="NSToolbarItemAutovalidates">YES</bool>
<bool key="NSToolbarItemAutovalidates">NO</bool>
<int key="NSToolbarItemTag">-1</int>
<bool key="NSToolbarIsUserRemovable">YES</bool>
<int key="NSToolbarItemVisibilityPriority">0</int>
</object>
<object class="NSToolbarItem" id="128477937">
<object class="NSMutableString" key="NSToolbarItemIdentifier">
<characters key="NS.bytes">A7443D4A-610D-4239-8FC6-AD74A87D607E</characters>
</object>
<string key="NSToolbarItemLabel">Rename</string>
<string key="NSToolbarItemPaletteLabel">Rename</string>
<string key="NSToolbarItemToolTip"/>
<nil key="NSToolbarItemView"/>
<object class="NSCustomResource" key="NSToolbarItemImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">selection-input-24</string>
</object>
<nil key="NSToolbarItemTarget"/>
<nil key="NSToolbarItemAction"/>
<string key="NSToolbarItemMinSize">{0, 0}</string>
<string key="NSToolbarItemMaxSize">{0, 0}</string>
<bool key="NSToolbarItemEnabled">YES</bool>
<bool key="NSToolbarItemAutovalidates">NO</bool>
<int key="NSToolbarItemTag">-1</int>
<bool key="NSToolbarIsUserRemovable">YES</bool>
<int key="NSToolbarItemVisibilityPriority">0</int>
@ -115,7 +138,7 @@
<string key="NSToolbarItemMinSize">{0, 0}</string>
<string key="NSToolbarItemMaxSize">{0, 0}</string>
<bool key="NSToolbarItemEnabled">YES</bool>
<bool key="NSToolbarItemAutovalidates">YES</bool>
<bool key="NSToolbarItemAutovalidates">NO</bool>
<int key="NSToolbarItemTag">-1</int>
<bool key="NSToolbarIsUserRemovable">YES</bool>
<int key="NSToolbarItemVisibilityPriority">0</int>
@ -182,17 +205,20 @@
</object>
</object>
</object>
<object class="NSArray" key="NSToolbarIBAllowedItems">
<object class="NSMutableArray" key="NSToolbarIBAllowedItems">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="367445820"/>
<reference ref="767736573"/>
<reference ref="994350550"/>
<reference ref="386220062"/>
<reference ref="128477937"/>
</object>
<object class="NSArray" key="NSToolbarIBDefaultItems">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="994350550"/>
<reference ref="386220062"/>
<reference ref="367445820"/>
<reference ref="128477937"/>
<reference ref="767736573"/>
</object>
<object class="NSArray" key="NSToolbarIBSelectableItems" id="0">
@ -338,6 +364,7 @@
<string key="NSFrame">{{1, 544}, {761, 15}}</string>
<reference key="NSSuperview" ref="595155248"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:60</string>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
<int key="NSsFlags">1</int>
@ -527,6 +554,7 @@
<reference ref="767736573"/>
<reference ref="994350550"/>
<reference ref="386220062"/>
<reference ref="128477937"/>
</object>
<reference key="parent" ref="748157544"/>
</object>
@ -619,6 +647,11 @@
<reference key="object" ref="931793253"/>
<reference key="parent" ref="765672105"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">78</int>
<reference key="object" ref="128477937"/>
<reference key="parent" ref="919098349"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@ -650,6 +683,7 @@
<string>72.IBPluginDependency</string>
<string>73.IBPluginDependency</string>
<string>74.IBPluginDependency</string>
<string>78.IBPluginDependency</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -678,6 +712,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
@ -692,7 +727,7 @@
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">77</int>
<int key="maxID">78</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@ -824,6 +859,7 @@
<string>NSMenuMixedState</string>
<string>disk-24</string>
<string>folder-open-24</string>
<string>selection-input-24</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -831,6 +867,7 @@
<string>{10, 3}</string>
<string>{24, 24}</string>
<string>{24, 24}</string>
<string>{24, 24}</string>
</object>
</object>
</data>

61
Mac/SearchStateMac.cs Normal file
View file

@ -0,0 +1,61 @@
using System;
using MonoMac.AppKit;
using NBTExplorer.Model;
using System.Collections.Generic;
namespace NBTExplorer.Mac
{
public class SearchStateMac : ISearchState
{
private NSWindow _sender;
public SearchStateMac (NSWindow sender)
{
_sender = sender;
}
public Action<DataNode> DiscoverCallback { get; set; }
public Action<DataNode> ProgressCallback { get; set; }
public Action<DataNode> CollapseCallback { get; set; }
public Action<DataNode> EndCallback { get; set; }
#region ISearchState
public DataNode RootNode { get; set; }
public string SearchName { get; set; }
public string SearchValue { get; set; }
public IEnumerator<DataNode> State { get; set; }
public void InvokeDiscoverCallback (DataNode node)
{
if (_sender != null && DiscoverCallback != null)
_sender.BeginInvokeOnMainThread(delegate { DiscoverCallback(node); });
//_sender.BeginInvokeOnMainThread(DiscoverCallback, new object[] { node });
}
public void InvokeProgressCallback (DataNode node)
{
if (_sender != null && ProgressCallback != null)
_sender.BeginInvokeOnMainThread(delegate { ProgressCallback(node); });
//_sender.BeginInvokeOnMainThread(ProgressCallback, new object[] { node });
}
public void InvokeCollapseCallback (DataNode node)
{
if (_sender != null && CollapseCallback != null)
_sender.BeginInvokeOnMainThread(delegate { CollapseCallback(node); });
//_sender.BeginInvokeOnMainThread(CollapseCallback, new object[] { node });
}
public void InvokeEndCallback (DataNode node)
{
if (_sender != null && EndCallback != null)
_sender.BeginInvokeOnMainThread(delegate { EndCallback(node); });
//_sender.BeginInvokeOnMainThread(EndCallback, new object[] { node });
}
#endregion
}
}

View file

@ -53,7 +53,7 @@ namespace NBTExplorer.Mac
public bool HasChildren
{
get { return _children.Count > 0 || _dataNode.HasUnexpandedChildren; }
get { return _children.Count > 0 || _dataNode.Nodes.Count > 0 || _dataNode.HasUnexpandedChildren; }
}
public void AddNode (TreeDataNode node)

View file

@ -51,8 +51,9 @@ namespace NBTExplorer.Mac
public override bool ItemExpandable (NSOutlineView outlineView, NSObject item)
{
TreeDataNode nodeItem = item as TreeDataNode;
if (nodeItem != null)
if (nodeItem != null) {
return nodeItem.HasChildren;
}
return false;
}

View file

@ -185,6 +185,17 @@
</Compile>
<Compile Include="NbtClipboardController.cs" />
<Compile Include="Mac\NbtClipboardControllerMac.cs" />
<Compile Include="Mac\SearchStateMac.cs" />
<Compile Include="Mac\FindWindow.cs" />
<Compile Include="Mac\FindWindowController.cs" />
<Compile Include="Mac\FindWindow.designer.cs">
<DependentUpon>FindWindow.cs</DependentUpon>
</Compile>
<Compile Include="Mac\CancelFindWindow.cs" />
<Compile Include="Mac\CancelFindWindowController.cs" />
<Compile Include="Mac\CancelFindWindow.designer.cs">
<DependentUpon>CancelFindWindow.cs</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\Dead_Bush.png" />
@ -245,6 +256,8 @@
<InterfaceDefinition Include="Mac\EditNameWindow.xib" />
<InterfaceDefinition Include="Mac\CreateNodeWindow.xib" />
<InterfaceDefinition Include="Mac\EditValueWindow.xib" />
<InterfaceDefinition Include="Mac\FindWindow.xib" />
<InterfaceDefinition Include="Mac\CancelFindWindow.xib" />
</ItemGroup>
<ItemGroup>
<Content Include="Resources\Dead_Bush_256.icns" />