Skip to content

Commit

Permalink
Fixes #290
Browse files Browse the repository at this point in the history
  • Loading branch information
emreeren committed Jul 19, 2013
1 parent 816926a commit 7bfb8ca
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
1 change: 1 addition & 0 deletions Samba.Domain/Models/Menus/ScreenMenuCategory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public virtual IList<ScreenMenuItem> ScreenMenuItems

public bool IsQuickNumeratorVisible { get { return NumeratorType == 1; } }
public bool IsNumeratorVisible { get { return NumeratorType == 2; } }

public int MaxItems { get; set; }

public void AddMenuItem(MenuItem menuItem)
Expand Down
8 changes: 4 additions & 4 deletions Samba.Modules.PosModule/MenuItemSelectorView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

<ListBox MinHeight="60" Grid.Row="1" Grid.Column="1" BorderThickness="0" Background="Transparent"
Visibility="{Binding IsQuickNumeratorVisible,Converter={StaticResource VisibilityConverter}}"
ItemsSource="{Binding QuickNumeratorValues}" SelectedItem="{Binding NumeratorValue,Mode=TwoWay}">
ItemsSource="{Binding QuickNumeratorValues}" SelectedItem="{Binding QuickNumeratorValue,Mode=TwoWay}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="1" />
Expand Down Expand Up @@ -167,7 +167,7 @@
</Grid>
</ScrollViewer>
</Grid>
<Grid Grid.Column="1" Grid.Row="3" Visibility="{Binding IsNumeratorVisible,Converter={StaticResource VisibilityConverter}}">
<Grid Grid.Column="1" Grid.Row="3" Visibility="{Binding IsNumberpadEditorVisible,Converter={StaticResource VisibilityConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
Expand All @@ -187,7 +187,7 @@
<FxButton:FlexButton MinWidth="40" Grid.Column="3" Grid.Row="0" Content='C' Command="{Binding ClearNumeratorCommand}"
Margin="2,0,0,2" Focusable="False" />
</Grid>
<UniformGrid Grid.Column="0" Grid.Row="1" Rows="4" Columns="3" Grid.ColumnSpan="2">
<UniformGrid Visibility="{Binding IsNumeratorVisible,Converter={StaticResource VisibilityConverter}}" Grid.Column="0" Grid.Row="1" Rows="4" Columns="3" Grid.ColumnSpan="2">
<FxButton:FlexButton Content="1" Command="{Binding TypeValueCommand}" CommandParameter="1"
Margin="0,0,2,2" Focusable="False" />
<FxButton:FlexButton Content="2" Command="{Binding TypeValueCommand}" CommandParameter="2"
Expand All @@ -214,7 +214,7 @@
Margin="0,0,2,2" Focusable="False" />
</UniformGrid>

<ItemsControl Grid.Row="2" Grid.Column="0" ItemsSource="{Binding AlphaButtonValues}">
<ItemsControl Visibility="{Binding IsNumeratorVisible,Converter={StaticResource VisibilityConverter}}" Grid.Row="2" Grid.Column="0" ItemsSource="{Binding AlphaButtonValues}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="1" />
Expand Down
26 changes: 16 additions & 10 deletions Samba.Modules.PosModule/MenuItemSelectorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public ScreenMenuCategory SelectedCategory
set { _selectedCategory = value; RaisePropertyChanged(() => SelectedCategory); }
}

public string QuickNumeratorValue { get { return !string.IsNullOrEmpty(NumeratorValue) ? NumeratorValue : (QuickNumeratorValues.FirstOrDefault()); } set { NumeratorValue = value; } }

public string NumeratorValue
{
get { return _applicationState.NumberPadValue ?? ""; }
Expand All @@ -54,6 +56,8 @@ public string NumeratorValue
_applicationStateSetter.SetNumberpadValue(value);
FilterMenuItems(_applicationState.NumberPadValue);
RaisePropertyChanged(() => NumeratorValue);
RaisePropertyChanged(() => IsNumberpadEditorVisible);
RaisePropertyChanged(() => QuickNumeratorValue);
}
}

Expand All @@ -65,6 +69,7 @@ public string NumeratorValue

public bool IsQuickNumeratorVisible { get { return SelectedCategory != null && SelectedCategory.IsQuickNumeratorVisible; } }
public bool IsNumeratorVisible { get { return SelectedCategory != null && SelectedCategory.IsNumeratorVisible; } }
public bool IsNumberpadEditorVisible { get { return IsNumeratorVisible || (IsQuickNumeratorVisible && !string.IsNullOrEmpty(NumeratorValue) && QuickNumeratorValues.All(x => x != NumeratorValue)) || (!IsQuickNumeratorVisible && !string.IsNullOrEmpty(NumeratorValue)); } }
public bool IsPageNumberNavigatorVisible { get { return SelectedCategory != null && SelectedCategory.PageCount > 1; } }
public VerticalAlignment MenuItemsVerticalAlignment { get { return SelectedCategory != null && SelectedCategory.MenuItemButtonHeight > 0 ? VerticalAlignment.Top : VerticalAlignment.Stretch; } }
public VerticalAlignment CategoriesVerticalAlignment { get { return Categories != null && Categories.Count > 0 && double.IsNaN(Categories[0].MButtonHeight) ? VerticalAlignment.Stretch : VerticalAlignment.Top; } }
Expand Down Expand Up @@ -184,7 +189,7 @@ private void FindMenuItem()
NumeratorValue = "";

if (quantity <= 0) return;

var weightBarcodePrefix = _settingService.ProgramSettings.WeightBarcodePrefix;
if (!string.IsNullOrEmpty(weightBarcodePrefix) && insertedData.StartsWith(weightBarcodePrefix))
{
Expand Down Expand Up @@ -227,8 +232,8 @@ private void OnMenuItemCommandExecute(ScreenMenuItem screenMenuItem)
decimal.TryParse(NumeratorValue, out selectedMultiplier);

if (IsQuickNumeratorVisible)
NumeratorValue = QuickNumeratorValues[0];
if (IsNumeratorVisible)
NumeratorValue = QuickNumeratorValues[0] != "1" ? QuickNumeratorValues[0] : "";
if (IsNumberpadEditorVisible)
NumeratorValue = "";

if (selectedMultiplier > 0)
Expand Down Expand Up @@ -330,14 +335,15 @@ private void OnCategoryCommandExecute(ScreenMenuCategory category)
if (IsQuickNumeratorVisible)
{
QuickNumeratorValues = string.IsNullOrEmpty(category.NumeratorValues) ? new[] { "1", "2", "3", "4", "5" } : category.NumeratorValues.Split(',');
NumeratorValue = QuickNumeratorValues[0];
NumeratorValue = QuickNumeratorValues[0] != "1" ? QuickNumeratorValues[0] : "";
}
else NumeratorValue = "";

AlphaButtonValues = string.IsNullOrEmpty(category.AlphaButtonValues) ? new string[0] : category.AlphaButtonValues.Split(',');

RaisePropertyChanged(() => IsQuickNumeratorVisible);
RaisePropertyChanged(() => IsNumeratorVisible);
RaisePropertyChanged(() => IsNumberpadEditorVisible);
RaisePropertyChanged(() => QuickNumeratorValues);
RaisePropertyChanged(() => AlphaButtonValues);
RaisePropertyChanged(() => MenuItemsVerticalAlignment);
Expand Down Expand Up @@ -411,12 +417,12 @@ private void OnTypeValueExecute(string obj)

public bool HandleTextInput(string text)
{
if (IsNumeratorVisible)
{
OnTypeValueExecute(text);
return true;
}
return false;
//if (IsNumeratorVisible)
//{
OnTypeValueExecute(text);
return true;
//}
//return false;
}
}
}

0 comments on commit 7bfb8ca

Please sign in to comment.