Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation, priority, control, html update #9

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ChangeLogs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT UNLESS YOU KNOW WHAT YOU ARE DOING.
# CHANGE LOG

[Next version (6dd69f7c243c61051fa1da9c581d4e8be3b8df66)]

[Next version (ef25acf72cea2921c196b912dfbaedb8cd18ec76)]
- Added: BeginLearning, Exit
- Added: AssignGrade, ExecuteRepetition
- Added: Color JSON converter
Expand Down Expand Up @@ -176,6 +177,8 @@
- Misc minor improvements
- Misc fixes
- Misc. minor changes
- Navigation, priority, control, html update
- Co-authored-by: kpence <[email protected]>
- Change the type casts to soft casts
- Is there a reason they aren't soft casts using `as` rather than hard casts? It can be a bit confusing from the name because AsWeb, AsImage etc. suggest they will return null on failure rather than throwing.
- Fix: Attempt at fixing #SuperMemoAssistant/228
Expand Down
3 changes: 3 additions & 0 deletions src/SuperMemoAssistant.Interop/Interop/SMConst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ public static class Files
public const string TextMemFileName = "text.mem";
public const string TextRtfFileName = "text.rtf";
public const string TextRtxFileName = "text.rtx";
public const string CommentMemFileName = "comment.mem";
public const string CommentRtfFileName = "comment.rtf";
public const string CommentRtxFileName = "comment.rtx";
public const string VideoMemFileName = "video.mem";
public const string VideoRtxFileName = "video.rtx";
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ namespace SuperMemoAssistant.Interop.SuperMemo.Content.Controls
public interface IControlHtml : IControlTextBase
{
IntPtr? DocumentHwnd { get; }
public mshtml.IHTMLDocument2 Document { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public enum ElementFieldFlags
Concept = 1024,
AFactor = 2048,
Deleted = 4096,
Comment = 8192,
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
//
//
// Created On: 2020/03/29 00:21
// Modified On: 2020/04/07 06:23
// Modified By: Alexis
// Modified On: 2022/12/17 06:23
// Modified By: - Alexis
// - Ki

#endregion

Expand Down Expand Up @@ -82,6 +83,8 @@ public ElementWrapper(IElement element)
/// <inheritdoc />
public string Title => Original.Title;
/// <inheritdoc />
public string Comment => Original.Comment;
/// <inheritdoc />
public bool Deleted => Original.Deleted;
/// <inheritdoc />
public ElementType Type => Original.Type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace SuperMemoAssistant.Interop.SuperMemo.Elements.Types
using Core;
using Models;
using Registry.Members;
using SuperMemoAssistant.Interop.SuperMemo.Registry;
using UI.Element;

/// <summary>Represents an element in SuperMemo. See <see cref="IElementRegistry" /></summary>
Expand All @@ -51,6 +52,9 @@ public interface IElement
/// <summary>The element's title (in the KT and registry)</summary>
string Title { get; }

/// <summary>The element's comment (in the KT and registry)</summary>
string Comment { get; }

/// <summary>Whether this element is marked as deleted.</summary>
bool Deleted { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public interface ISuperMemoRegistry
/// <summary>The Text registry</summary>
ITextRegistry Text { get; }

/// <summary>The Comment registry</summary>
ICommentRegistry Comment { get; }

/// <summary>The image registry</summary>
IImageRegistry Image { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,14 @@ public enum LearningMode
Pending = 9,
Drill = 10,
}

//TODO: check these values and use in SetPriority
/*public enum Grade : int
{
Bad = 0,
Fail = 1,
Pass = 2,
Good = 3,
Great = 4,
}*/
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#region License & Metadata

// The MIT License (MIT)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

#endregion




namespace SuperMemoAssistant.Interop.SuperMemo.Registry.Members
{
/// <summary>A text string from the text registry</summary>
public interface IComment : IRegistryMember
{
/// <summary>The text member's text content</summary>
string Value { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#region License & Metadata

// The MIT License (MIT)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
//
// Created On: 2022/12/17 00:21
// Modified On: 2022/12/17 04:51
// Modified By: Ki

#endregion




namespace SuperMemoAssistant.Interop.SuperMemo.Registry.Types
{
using Members;

/// <summary>The <see cref="IText" /> registry</summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1710:Identifiers should have correct suffix", Justification = "<Pending>")]
public interface ICommentRegistry : IRegistry<IComment>
{
/// <summary>Adds a new text member to the registry</summary>
/// <param name="text">The text content</param>
/// <returns>The created registry member id, or -1 if the operation failed</returns>
int Add(string text);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,23 @@ int GenerateCloze(bool memorize = true,
/// <returns>Success of operation</returns>
bool Done();

/// <summary>Dismisses the element</summary>
/// <param name="elNo">The element number</param>
/// <returns>Success of operation</returns>
bool DismissElement(int elNo);

/// <summary>Executes the "Next Repetition" function used after grading in the Element window</summary>
/// <returns>Success of operation</returns>
bool NextRepetition();

/// <summary>Navigates to the previous element in the navigator.</summary>
/// <returns>Success of operation</returns>
bool BackButtonClick();

/// <summary>Navigates to the next element in the navigator.</summary>
/// <returns>Success of operation</returns>
bool ForwardButtonClick();

/// <summary>Raises an event when the element in the Element window changes</summary>
event Action<SMDisplayedElementChangedEventArgs> OnElementChanged;

Expand All @@ -163,6 +180,53 @@ int GenerateCloze(bool memorize = true,
/// <returns>Success of operation</returns>
bool PostponeRepetition(int interval);

/// <summary>Changes the element grade</summary>
/// <param name="grade">The new grade on a range from 0 to 4 inclusive (SM18)</param>
/// <returns>Success of operation</returns>
bool SetGrade(int grade);

/// <summary>Not yet implemented. Gets the priority of the element with the element number</summary>
/// <param name="elementNumber">The element number</param>
/// <returns>The priority of the element; 0 if unsuccessful operation</returns>
float GetElementPriority(int elementNumber);

/// <summary>Gets data from the current element in string format</summary>
/// <returns>The data from the current element in string format</returns>
string GetElementAsText();

/// <summary>
/// Begin Learning Mode. This might not always work as intended depending on the current
/// <see cref="LearningMode" />
/// <param name="learningMode">The current learning mode?</param>
/// </summary>
/// <returns>Success of operation</returns>
bool BeginLearning(LearningMode learningMode);

// <summary>
/// Not yet implemented
/// </summary>
/// <returns>Success of operation</returns>
bool FindText();

/// <summary>
/// Set the title of the Element internally. This change may not reflect on the
/// current SM window until it is restarted.
/// </summary>
/// <returns>Success of operation</returns>
bool SetTitle(int elementId, string title);

// <summary>
/// Attach a new comment to the element.
/// </summary>
/// <returns>Success of operation</returns>
bool AppendComment(int elementId, string comment);

// <summary>
/// Set the priority of the element from 0 to 100.
/// </summary>
/// <returns>Success of operation</returns>
bool SetPriority(int elementId, double priority);

/// <summary>
/// Executes a repetition on the current element and postpones it for <paramref name="interval" /> days. If
/// <paramref name="adjustPriority" /> is true, also changes the priority depending on the given interval
Expand Down