Skip to content

Commit

Permalink
Added save info dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
ShendoXT committed Dec 2, 2023
1 parent 96877e1 commit 15c7c14
Show file tree
Hide file tree
Showing 15 changed files with 1,344 additions and 106 deletions.
Binary file modified MemcardRex.zip
Binary file not shown.
72 changes: 60 additions & 12 deletions cocoaapp/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

namespace MemcardRex
{
[Register ("AppDelegate")]
public partial class AppDelegate : NSApplicationDelegate
{
[Register("AppDelegate")]
public partial class AppDelegate : NSApplicationDelegate
{
//Number of open windows/documents/cards in the application
private int windowCount = 1;

public AppDelegate ()
{
public AppDelegate()
{

}
}

public override void DidFinishLaunching (NSNotification notification)
{
public override void DidFinishLaunching(NSNotification notification)
{
//Show experimental software alert
var alert = new NSAlert()
{
Expand All @@ -29,10 +29,48 @@ public override void DidFinishLaunching (NSNotification notification)
//alert.RunModal();
}

public override void WillTerminate (NSNotification notification)
{
// Insert code here to tear down your application
}
public override void WillTerminate(NSNotification notification)
{
// Insert code here to tear down your application
}

//Specific menu item enables/disableas
public void EnableFormatMenuItem()
{
removeSaveMItem.Enabled = true;
}

public void SetImportMenuItem(bool itemState)
{
importSaveMItem.Enabled = itemState;
}

public void DisableRestoreItem()
{
restoreSaveMItem.Enabled = false;
}

public void DisableDeleteItem()
{
deleteSaveMItem.Enabled = false;
}

//Enable or disable menu items based on the currently selected save
public void SetEditItemsState(bool itemStates)
{
editSaveHeaderMItem.Enabled = itemStates;
editSaveCommentMItem.Enabled = itemStates;
compareBufferMItem.Enabled = itemStates;
editIconMItem.Enabled = itemStates;
deleteSaveMItem.Enabled = itemStates;
restoreSaveMItem.Enabled = itemStates;
removeSaveMItem.Enabled = itemStates;
cpySaveTempBufferMItem.Enabled = itemStates;
pasteSaveTempBufferMItem.Enabled = itemStates;
importSaveMItem.Enabled = itemStates;
exportSaveMItem.Enabled = itemStates;
exportSaveRawMItem.Enabled = itemStates;
}

#region Custom Actions
[Export("newDocument:")]
Expand All @@ -48,6 +86,13 @@ public void NewDocument(NSObject sender)
windowCount++;
}

[Export("editSaveComment:")]
void EditSaveComment(NSObject sender)
{
var window = NSApplication.SharedApplication.KeyWindow.ContentViewController as ViewController;
window.EditSaveComment(sender);
}

//Open file menu item
[Export("openDocument:")]
public void OpenDialog(NSObject sender)
Expand Down Expand Up @@ -80,6 +125,7 @@ public void OpenDialog(NSObject sender)
};

alert.RunModal();
dlg.Dispose();
return;
}

Expand Down Expand Up @@ -110,6 +156,8 @@ public void OpenDialog(NSObject sender)
window.SetMemoryCard(path);
}
}

dlg.Dispose();
}
#endregion
}
Expand Down
124 changes: 124 additions & 0 deletions cocoaapp/AppDelegate.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 84 additions & 0 deletions cocoaapp/CommentDialogController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// This file has been autogenerated from a class added in the UI designer.

using System;

using Foundation;
using AppKit;
using System.Drawing;

namespace MemcardRex
{
public partial class CommentDialogController : NSViewController
{
#region Private Variables
private string _dialogTitle = "";
private string _comment = "";
private NSViewController _presentor;
#endregion

#region Computed Properties
public string DialogTitle
{
get { return _dialogTitle; }
set { _dialogTitle = value; }
}

public string Comment
{
get { return _comment; }
set { _comment = value; }
}

public NSViewController Presentor
{
get { return _presentor; }
set { _presentor = value; }
}
#endregion

public CommentDialogController (IntPtr handle) : base (handle)
{
}

#region Override Methods
public override void ViewWillAppear()
{
base.ViewWillAppear();

this.View.Window.Title = DialogTitle;

CommentTextInput.StringValue = Comment;


//Disable resizing of modal dialog
this.View.Window.StyleMask &= ~NSWindowStyle.Resizable;
}
#endregion

#region Events
public EventHandler DialogAccepted;

internal void RaiseDialogAccepted()
{
if (this.DialogAccepted != null)
this.DialogAccepted(this, EventArgs.Empty);
}
#endregion

[Export("ConfirmDialog:")]
void AcceptDialog(NSObject sender)
{
//Save changes
Comment = CommentTextInput.StringValue;

RaiseDialogAccepted();
Presentor.DismissViewController(this);
}

[Export("CancelDialog:")]
void CancelDialoga(NSObject sender)
{
Presentor.DismissViewController(this);
}
}
}
40 changes: 40 additions & 0 deletions cocoaapp/CommentDialogController.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 15c7c14

Please sign in to comment.