ЗАВИСИМОСТИ СТИЛЕЙ 0.365 public partial class View { public static double btnSmall { get { return GetHeight(12); } } public static double btnNormal { get { return GetHeight(14); } } public static double btnLarge { get { return GetHeight(16); } } public static double btnExtraLarge { get { return GetHeight(24); } } public static double btnIconSize { get { return GetHeight(25); } } // ---- public static double menuItemSize { get { return GetHeight(14); } } public static double menuItemVerticalPadding { get { return GetHeight(1); } } public static double OrderTopBarItemSize { get { return GetHeight(17); } } // Default Text Styles // шрифты с M на конце служат для изображения цены, т.к. она иногда не влазит public static double FontSizeSmall { get { return GetHeight(10); } } public static double FontSizeNormal { get { return GetHeight(12); } } public static double FontSizeMedium { get { return GetHeight(14); } } public static double FontSizeLargeM { get { return GetHeight(15); } } public static double FontSizeLarge { get { return GetHeight(18); } } public static double FontSizeLargerM { get { return GetHeight(20); } } public static double FontSizeLarger { get { return GetHeight(28); } } public static double FontSizeSuperLargeM { get { return GetHeight(32); } } public static double FontSizeSuperLarge { get { return GetHeight(36); } } public static double FontSizeExtraLargeM { get { return GetHeight(39); } } public static double FontSizeExtraLarge { get { return GetHeight(48); } } public static double FontSizeWaiterOrdersInfo { get { return GetHeight(16); } } public static double FontSizeTopBarButton { get { return GetHeight(16); } } public static double FontSizeNumpad { get { return GetHeight(60); } } public static double FontSizeNumpadAdditional { get { return GetHeight(32); } } public static double FontSizeNumpadSmallAdditional { get { return GetHeight(20); } } public static double FontSizeSmallNumpad { get { return GetHeight(44); } } // Offsets public static double BaselineOffsetLarge { get { return GetHeight(2); } } // Lines public static double SymbolLineThicknessLarge { get { return GetHeight(2); } } // list item heights public static double commonOrderItemHeight { get { return GetHeight(30); } } public static double paymentOrderItemHeight { get { return GetHeight(20); } } public static double paymentItemHeight { get { return GetHeight(40); } } public static double tableSize { get { return GetHeight(80); } } public static double waiterItemHeight { get { return GetHeight(60); } } public static double reportItemHeight { get { return GetHeight(40); } } public static GridLength PriceColWidth { get { return new GridLength(GetHeight(90)); } } public static GridLength AmountColWidth { get { return new GridLength(GetHeight(60)); } } public static double AmountColWidthWaiterScreen { get { return GetHeight(24); } } public static GridLength GridAmountColWidthWaiterScreen { get { return new GridLength(AmountColWidthWaiterScreen); } } public static GridLength KdsColorColWidth { get { return new GridLength(GetHeight(250)); } } public static double AmountColMargin { get { return GetHeight(60); } } // Margins public static double VerticalMargin { get { return GetHeight(8); } } public static double HorisontalMargin { get { return GetHeight(10); } } public static double OrderHeaderMargin { get { return GetHeight(3); } } public static double KitchenDeliveryTextHorisontalMargin { get { return GetHeight(8); } } public static double KitchenHeaderTimerMargin { get { return GetHeight(10); } } public static double KitchenHeaderIconMargin { get { return GetHeight(2); } } public static double KitchenHeaderContentMargin { get { return GetHeight(2); } } // Bad names public static double FontSize11 { get { return GetHeight(11); } } public static double FontSize16 { get { return GetHeight(16); } } public static double FontSize22 { get { return GetHeight(22); } } public static double FontSize24 { get { return GetHeight(24); } } public static double FontSize26 { get { return GetHeight(26); } } public static double FontSize30 { get { return GetHeight(30); } } internal static double GetHeight(double unit) { var mainWindow = Application.Current.MainWindow as IMainWindow; if (mainWindow == null || mainWindow.MainPanel == null) return unit; if (mainWindow.MainPanel.ActualHeight < SaneSize) return unit; var scale = mainWindow.MainPanel.ActualHeight / DefaultWindowHeight; var result = unit * scale; return result > 0 ? result : unit; } } public partial class View : UserControl { public static readonly RoutedCommand ExitCommand = new RoutedCommand("Exit", typeof(View)); public readonly CommandBinding ExitCommandBinding = new CommandBinding(ExitCommand, (s, e) => { }); private const double DefaultWindowWidth = 1024; private const double DefaultWindowHeight = 768; private const double SaneSize = 100; private const int RowsCount = 11; private const int WindowHeightReserved = 6; private const int ColumnsCount = 10; private const int WindowWidthReserved = 13; #region Row heights public static double DefaultRowHeight { get { if (IsInDesignModeStatic) return DefaultWindowHeight; var height = ((IMainWindow)Application.Current.MainWindow).MainPanel.ActualHeight; return ((height > SaneSize ? height : DefaultWindowHeight) - WindowHeightReserved) / RowsCount; } } public static double DefaultRowHeightX0_25 { get { return DefaultRowHeight * 0.25; } } public static double DefaultRowHeightX0_4 { get { return DefaultRowHeight * 0.4; } } public static double DefaultRowHeightX0_5 { get { return DefaultRowHeight * 0.5; } } public static double DefaultRowHeightX0_7 { get { return DefaultRowHeight * 0.7; } } public static double DefaultRowHeightX0_8 { get { return DefaultRowHeight * 0.8; } } public static double DefaultRowHeightX1_25 { get { return DefaultRowHeight * 1.25; } } public static double DefaultRowHeightX1_5 { get { return DefaultRowHeight * 1.5; } } public static double DefaultRowHeightX1_75 { get { return DefaultRowHeight * 1.75; } } public static double DefaultRowHeightX2 { get { return DefaultRowHeight * 2; } } public static double DefaultRowHeightX2_5 { get { return DefaultRowHeight * 2.5; } } public static double DefaultRowHeightX3 { get { return DefaultRowHeight * 3; } } public static double DefaultRowHeightX4 { get { return DefaultRowHeight * 4; } } public static double DefaultRowHeightX5 { get { return DefaultRowHeight * 5; } } public static double DefaultRowHeightX6 { get { return DefaultRowHeight * 6; } } public static double DefaultRowHeightX7 { get { return DefaultRowHeight * 7; } } public static double DefaultRowHeightX8 { get { return DefaultRowHeight * 8; } } public static double DefaultRowHeightX9 { get { return DefaultRowHeight * 9; } } public static double DefaultRowHeightX10 { get { return DefaultRowHeight * 10; } } public static GridLength GridRowHeightX0_25 { get { return new GridLength(DefaultRowHeightX0_25); } } public static GridLength GridRowHeightX0_5 { get { return new GridLength(DefaultRowHeightX0_5); } } public static GridLength GridRowHeightX0_7 { get { return new GridLength(DefaultRowHeightX0_7); } } public static GridLength GridRowHeightX0_8 { get { return new GridLength(DefaultRowHeightX0_8); } } public static GridLength GridRowHeight { get { return new GridLength(DefaultRowHeight); } } public static GridLength GridRowHeightX1_5 { get { return new GridLength(DefaultRowHeightX1_5); } } public static GridLength GridRowHeightX2 { get { return new GridLength(DefaultRowHeightX2); } } public static GridLength GridRowHeightX2_5 { get { return new GridLength(DefaultRowHeightX2_5); } } public static GridLength GridRowHeightX3 { get { return new GridLength(DefaultRowHeightX3); } } public static GridLength GridRowHeightX4 { get { return new GridLength(DefaultRowHeightX4); } } public static GridLength GridRowHeightX5 { get { return new GridLength(DefaultRowHeightX5); } } public static GridLength GridRowHeightX6 { get { return new GridLength(DefaultRowHeightX6); } } public static GridLength GridRowHeightX7 { get { return new GridLength(DefaultRowHeightX7); } } public static GridLength GridRowHeightX8 { get { return new GridLength(DefaultRowHeightX8); } } public static GridLength GridRowHeightX9 { get { return new GridLength(DefaultRowHeightX9); } } #endregion #region Column widths public static double DefaultColumnWidth { get { if (IsInDesignModeStatic) return DefaultWindowHeight; var width = ((IMainWindow)Application.Current.MainWindow).MainPanel.ActualWidth; return ((width > SaneSize ? width : DefaultWindowWidth) - WindowWidthReserved) / ColumnsCount; } } public static double DefaultColumnWidthX0_10 { get { return DefaultColumnWidth * 0.1; } } public static double DefaultColumnWidthX0_25 { get { return DefaultColumnWidth * 0.25; } } public static double DefaultColumnWidthX0_5 { get { return DefaultColumnWidth * 0.5; } } public static double DefaultColumnWidthX0_75 { get { return DefaultColumnWidth * 0.75; } } public static double DefaultColumnWidthX1_25 { get { return DefaultColumnWidth * 1.25; } } public static double DefaultColumnWidthX1_5 { get { return DefaultColumnWidth * 1.5; } } public static double DefaultColumnWidthX1_75 { get { return DefaultColumnWidth * 1.75; } } public static double DefaultColumnWidthX4partof3 { get { return DefaultColumnWidth * 4 / 3; } } public static double DefaultColumnWidthX2 { get { return DefaultColumnWidth * 2; } } public static double DefaultColumnWidthX2_25 { get { return DefaultColumnWidth * 2.25; } } public static double DefaultColumnWidthX2_5 { get { return DefaultColumnWidth * 2.5; } } public static double DefaultColumnWidthX3 { get { return DefaultColumnWidth * 3; } } public static double DefaultColumnWidthX3_25 { get { return DefaultColumnWidth * 3.25; } } public static double DefaultColumnWidthX4 { get { return DefaultColumnWidth * 4; } } public static double DefaultColumnWidthX4_5 { get { return DefaultColumnWidth * 4.5; } } public static double DefaultColumnWidthX5 { get { return DefaultColumnWidth * 5; } } public static double DefaultColumnWidthX6 { get { return DefaultColumnWidth * 6; } } public static double DefaultColumnWidthX7 { get { return DefaultColumnWidth * 7; } } public static double DefaultColumnWidthX8 { get { return DefaultColumnWidth * 8; } } public static double DefaultColumnWidthX9 { get { return DefaultColumnWidth * 9; } } public static double DefaultColumnWidthX10 { get { return DefaultColumnWidth * 10; } } public static GridLength GridColumnWidth { get { return new GridLength(DefaultColumnWidth); } } public static GridLength GridColumnWidthX0_10 { get { return new GridLength(DefaultColumnWidthX0_10); } } public static GridLength GridColumnWidthX0_25 { get { return new GridLength(DefaultColumnWidthX0_25); } } public static GridLength GridColumnWidthX0_5 { get { return new GridLength(DefaultColumnWidthX0_5); } } public static GridLength GridColumnWidthX0_75 { get { return new GridLength(DefaultColumnWidthX0_75); } } public static GridLength GridColumnWidthX4partof3 { get { return new GridLength(DefaultColumnWidthX4partof3); } } public static GridLength GridColumnWidthX1_5 { get { return new GridLength(DefaultColumnWidthX1_5); } } public static GridLength GridColumnWidthX1_75 { get { return new GridLength(DefaultColumnWidthX1_75); } } public static GridLength GridColumnWidthX2 { get { return new GridLength(DefaultColumnWidthX2); } } public static GridLength GridColumnWidthX2_25 { get { return new GridLength(DefaultColumnWidthX2_25); } } public static GridLength GridColumnWidthX2_5 { get { return new GridLength(DefaultColumnWidthX2_5); } } public static GridLength GridColumnWidthX3 { get { return new GridLength(DefaultColumnWidthX3); } } public static GridLength GridColumnWidthX4 { get { return new GridLength(DefaultColumnWidthX4); } } public static GridLength GridColumnWidthX5 { get { return new GridLength(DefaultColumnWidthX5); } } public static GridLength GridColumnWidthX6 { get { return new GridLength(DefaultColumnWidthX6); } } #endregion private static IViewManagerBase viewManager; public static IViewManagerBase ViewManager { get { return viewManager ?? (viewManager = UnityHelper.GetFactoryContainer().Resolve()); } } public IModelFactory ModelFactory { get { return ModelFactoryBase.Instance; } } public View() { CommandBindings.Add(ExitCommandBinding); Style = FindResource(typeof (View)) as Style; } protected static HitTestResult ElementHitTest(UIElement input) { return VisualTreeHelper.HitTest(input, Mouse.GetPosition(input)); } protected static bool IsElementHit(UIElement input) { return ElementHitTest(input) != null; } #region Design mode private static bool? isInDesignMode; /// /// Gets a value indicating whether the control is in design mode (running in Blend /// or Visual Studio). /// public static bool IsInDesignModeStatic { get { if (!isInDesignMode.HasValue) { var prop = DesignerProperties.IsInDesignModeProperty; isInDesignMode = (bool)DependencyPropertyDescriptor .FromProperty(prop, typeof(FrameworkElement)) .Metadata.DefaultValue; } return isInDesignMode.Value; } } #endregion } public static partial class AdditionalProps { public static readonly DependencyProperty SymbolProperty = DependencyProperty.RegisterAttached("Symbol", typeof(object), typeof(AdditionalProps), new PropertyMetadata(default(object))); public static object GetSymbol([NotNull] FrameworkElement element) { if (element == null) throw new ArgumentNullException("element"); return (object)element.GetValue(SymbolProperty); } public static void SetSymbol([NotNull] FrameworkElement element, object value) { if (element == null) throw new ArgumentNullException("element"); element.SetValue(SymbolProperty, value); } public static readonly DependencyProperty SymbolFontSizeProperty = DependencyProperty.RegisterAttached("SymbolFontSize", typeof(double), typeof(AdditionalProps), new PropertyMetadata(default(double))); public static double GetSymbolFontSize([NotNull] FrameworkElement element) { if (element == null) throw new ArgumentNullException("element"); return (double)element.GetValue(SymbolFontSizeProperty); } public static void SetSymbolFontSize([NotNull] FrameworkElement element, double value) { if (element == null) throw new ArgumentNullException("element"); element.SetValue(SymbolFontSizeProperty, value); } }