Skip to content

Commit 998728f

Browse files
Fix little bug, close #557.
1 parent 481549b commit 998728f

File tree

7 files changed

+46
-10
lines changed

7 files changed

+46
-10
lines changed

src/Sudoku.Strategying/Resources/StrategyingResources.Designer.cs

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Sudoku.Strategying/Resources/StrategyingResources.resx

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,6 @@
184184
<value>Single prefer rule: {0} is preferred as primary technique, Hidden Single in rows or columns {1}included</value>
185185
</data>
186186
<data name="EliminationCountConstraint" xml:space="preserve">
187-
<value>Elimination count rule: a step must contain {0} {1} elimination{2}</value>
187+
<value>Elimination count rule: a {3} step must contain {0} {1} elimination{2}</value>
188188
</data>
189189
</root>

src/Sudoku.Strategying/Resources/StrategyingResources.zh-cn.resx

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,6 @@
181181
<value>出数技巧偏好:希望以{0}技巧作为主技巧解题,行列排除{1}在计算之中</value>
182182
</data>
183183
<data name="EliminationCountConstraint" xml:space="preserve">
184-
<value>删数数量:一个步骤需要有 {0} {1} 个删数结论{2}</value>
184+
<value>删数数量:一个{3}步骤需要有 {0} {1} 个删数结论{2}</value>
185185
</data>
186186
</root>

src/Sudoku.Strategying/Strategying/Constraints/EliminationCountConstraint.cs

+10-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ public sealed partial class EliminationCountConstraint : Constraint, IComparison
1515
[StringMember]
1616
public int LimitCount { get; set; }
1717

18+
/// <summary>
19+
/// Indicates the technique used.
20+
/// </summary>
21+
[HashCodeMember]
22+
[StringMember]
23+
public Technique Technique { get; set; }
24+
1825
/// <inheritdoc/>
1926
[HashCodeMember]
2027
[StringMember]
@@ -33,7 +40,7 @@ public override bool Check(ConstraintCheckingContext context)
3340
var @operator = Operator.GetOperator<int>();
3441
foreach (var step in context.AnalyzerResult)
3542
{
36-
if (@operator(LimitCount, step.Conclusions.Length))
43+
if (step.Code == Technique && @operator(LimitCount, step.Conclusions.Length))
3744
{
3845
return true;
3946
}
@@ -52,6 +59,7 @@ public override string ToString(CultureInfo? culture = null)
5259
ResourceDictionary.Get("EliminationCountConstraint", culture),
5360
Operator.GetOperatorString(),
5461
LimitCount,
55-
LimitCount != 1 ? string.Empty : ResourceDictionary.Get("NounPluralSuffix", culture)
62+
LimitCount != 1 ? string.Empty : ResourceDictionary.Get("NounPluralSuffix", culture),
63+
Technique.GetName(culture)
5664
);
5765
}

src/SudokuStudio/Views/Pages/GeneratedPuzzleConstraintPage.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
</MenuFlyoutItem>
4949
<MenuFlyoutItem Text="{m:R Key=GeneratedPuzzleConstraintPage_EliminationCountConstraint}" Click="MenuFlyoutItem_Click">
5050
<MenuFlyoutItem.Tag>
51-
<con:EliminationCountConstraint LimitCount="5" Operator="GreaterThanOrEqual" />
51+
<con:EliminationCountConstraint Technique="LockedPair" LimitCount="5" Operator="GreaterThanOrEqual" />
5252
</MenuFlyoutItem.Tag>
5353
</MenuFlyoutItem>
5454
<MenuFlyoutItem Text="{m:R Key=GeneratedPuzzleConstraintPage_DifficultyLevelConstraint}" Click="MenuFlyoutItem_Click">

src/SudokuStudio/Views/Pages/GeneratedPuzzleConstraintPage.xaml.cs

+26-3
Original file line numberDiff line numberDiff line change
@@ -706,9 +706,9 @@ from technique in techniques select technique.GetName(App.CurrentCulture)
706706
};
707707
}
708708

709-
private SettingsCard? Create_EliminationCount(EliminationCountConstraint constraint)
709+
private SettingsExpander? Create_EliminationCount(EliminationCountConstraint constraint)
710710
{
711-
if (constraint is not { LimitCount: var limitCount, Operator: var @operator })
711+
if (constraint is not { LimitCount: var limitCount, Operator: var @operator, Technique: var technique })
712712
{
713713
return null;
714714
}
@@ -723,15 +723,38 @@ from technique in techniques select technique.GetName(App.CurrentCulture)
723723
//
724724
var limitCountControl = LimitCountControl(limitCount, constraint);
725725

726+
//
727+
// chosen techniques displayer
728+
//
729+
var displayerControl = new TextBlock
730+
{
731+
MaxWidth = 400,
732+
TextWrapping = TextWrapping.WrapWholeWords,
733+
VerticalAlignment = VerticalAlignment.Center,
734+
Text = $"{technique.GetName(App.CurrentCulture)}{ResourceDictionary.Get("_Token_Comma2", App.CurrentCulture)}"
735+
};
736+
737+
//
738+
// technique view
739+
//
740+
var techniqueControl = new TechniqueView { SelectionMode = TechniqueViewSelectionMode.Single, SelectedTechniques = [technique] };
741+
techniqueControl.CurrentSelectedTechniqueChanged += (_, e) =>
742+
{
743+
var technique = e.Technique;
744+
constraint.Technique = technique;
745+
displayerControl.Text = $"{technique.GetName(App.CurrentCulture)}{ResourceDictionary.Get("_Token_Comma2", App.CurrentCulture)}";
746+
};
747+
726748
return new()
727749
{
728750
Header = ResourceDictionary.Get("GeneratedPuzzleConstraintPage_EliminationCount", App.CurrentCulture),
729751
Margin = DefaultMargin,
752+
Items = { techniqueControl },
730753
Content = new StackPanel
731754
{
732755
Orientation = Orientation.Horizontal,
733756
Spacing = 3,
734-
Children = { operatorControl, limitCountControl }
757+
Children = { displayerControl, operatorControl, limitCountControl }
735758
},
736759
Tag = constraint
737760
};

src/docxml/Sudoku.Strategying.xml

+6-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)