private static void SetImage(ItemPatient patient, bool isOk)
        {
            if (patient.CheckStateImage != null)
            {
                if (!isOk)
                {
                    patient.CheckStateImage.Source = ControlsFactory.GetImage(ControlsFactory.ImageType.NotificationRegistry);
                }

                patient.CheckStateImage.Visibility = Visibility.Visible;
            }
        }
Exemple #2
0
        public PageNotification(NotificationType type, string replacement = "", bool returnBack = false,
                                Exception exception = null, bool?isQueryException = null)
        {
            InitializeComponent();
            Console.WriteLine(@"http://CONSTRUCT_PageNotification.type." + type);

            Logging.ToLog("PageNotification - Отображение страницы типа: " + type);

            CurrentNotificationType = type;
            this.returnBack         = returnBack;

            string textTop    = string.Empty;
            string textBottom = string.Empty;

            ControlsFactory.ImageType imageType = ControlsFactory.ImageType.NotificationRegistry;
            string textToShow = string.Empty;

            title = Properties.Resources.title_notification;
            this.isQueryException = isQueryException;

            switch (type)
            {
            case NotificationType.Welcome:
                textToShow = Properties.Resources.notification_welcome;
                title      = Properties.Resources.title_welcome;
                MediaElementWelcomeAnimation.Visibility = Visibility.Visible;
                TextBlockAboutDeveloper.Visibility      = Visibility.Visible;
                GridImage.Visibility = Visibility.Hidden;
                KeepAlive            = true;
                isError = false;
                break;

            case NotificationType.NumberNotFound:
                textToShow = Properties.Resources.notification_nothing_found;
                imageType  = ControlsFactory.ImageType.NotificationNumberNotFound;
                break;

            case NotificationType.NoAppointmentsForNow:
                textToShow = Properties.Resources.notification_no_appointmetns_for_now;
                imageType  = ControlsFactory.ImageType.NotificationAppointmentsNotAvailable;
                break;

            case NotificationType.NameNotCorrect:
                textToShow = Properties.Resources.notification_wrong_name;
                imageType  = ControlsFactory.ImageType.NotificationWrongNumber;
                break;

            case NotificationType.FirstVisit:
                textToShow = Properties.Resources.notification_first_visit;
                imageType  = ControlsFactory.ImageType.NotificationFirstVisit;
                break;

            case NotificationType.VisitRegistryToCheckIn:
                textToShow            = Properties.Resources.notification_need_go_to_registry;
                ButtonInfo.Visibility = Visibility.Visible;
                ButtonInfo.Style      = BindingValues.Instance.StyleRoundCorner;
                break;

            case NotificationType.DbError:
                textToShow = Properties.Resources.notification_db_not_available;
                title      = Properties.Resources.title_welcome;

                TextBlockAboutDeveloper.Visibility = Visibility.Visible;
                imageType = ControlsFactory.ImageType.NotificationDbError;
                TextBlockTapToContinue.Visibility = Visibility.Collapsed;
                TextBlockBottom.Margin            = new Thickness(0);
                isError = true;

                SetupErrorNotification(exception);

                break;

            case NotificationType.Cash:
                imageType  = ControlsFactory.ImageType.NotificationCash;
                textToShow = Properties.Resources.notification_cash;
                break;

            case NotificationType.CheckInFailed:
                imageType  = ControlsFactory.ImageType.NotificationDbError;
                textToShow = Properties.Resources.notification_check_in_failed;
                TextBlockAboutDeveloper.Visibility = Visibility.Visible;
                isError = true;
                break;

            case NotificationType.AlreadyChecked:
                imageType  = ControlsFactory.ImageType.NotificationRegistry;
                textToShow = Properties.Resources.notification_already_checked;
                break;

            default:
                break;
            }

            ImageCenter.Source = ControlsFactory.GetImage(imageType);

            string[] splittedTextToShow = textToShow.Split(new string[] { "\r\n\r\n" }, StringSplitOptions.None);
            TextBlockTop.Text = splittedTextToShow[0].Replace("*", replacement);

            if (splittedTextToShow.Length > 1)
            {
                TextBlockBottom.Text = splittedTextToShow[1];
            }

            DataContext = BindingValues.Instance;

            IsVisibleChanged += (s, e) => {
                if ((bool)e.NewValue)
                {
                    BindingValues.Instance.SetUpMainWindow(title, true, isError);

                    if (CurrentNotificationType == NotificationType.DbError)
                    {
                        return;
                    }
                    Console.WriteLine("---PageNotification_PreviewMouseDown subscribe");
                    MainWindow.Instance.PreviewMouseDown += PageNotification_PreviewMouseDown;
                }
                else
                {
                    Console.WriteLine("---PageNotification_PreviewMouseDown unsubscribe");
                    MainWindow.Instance.PreviewMouseDown -= PageNotification_PreviewMouseDown;
                }
            };
        }
Exemple #3
0
        public PageShowAppointments(ItemPatient patient, bool returnBack)
        {
            InitializeComponent();
            Console.WriteLine(@"http://CONSTRUCT_PageShowAppointments");

            Logging.ToLog("PageShowAppointments - отображение страницы со списком назначений");

            this.returnBack = returnBack;
            this.patient    = patient ?? throw new ArgumentNullException(nameof(patient));
            schedIds        = patient.AppointmentsAvailable.Select(x => x.SchedID).ToList();

            string title = Properties.Resources.title_appointments.Replace("*", patient.Name);;

            if (patient.AppointmentsAvailable.Count == 0)
            {
                ButtonCheckIn.Visibility = Visibility.Hidden;

                if (patient.IsPrinterReady)
                {
                    ButtonPrint.Visibility = Visibility.Visible;
                    ButtonClose.Visibility = Visibility.Visible;
                }
                else
                {
                    ButtonCloseFull.Visibility = Visibility.Visible;
                }
            }

            BindingValues.Instance.SetUpMainWindow(title, true, false);

            int    row         = 0;
            double fontSize    = BindingValues.Instance.FontSizeMain;
            double fontSizeSub = BindingValues.Instance.FontSizeMain * 0.8;
            Brush  brushGray   = Brushes.LightGray;

            foreach (ItemAppointment item in patient.AppointmentsToShow)
            {
                TextBlock textBlockRoom = ControlsFactory.CreateTextBlock("Каб. " + item.RNum);
                textBlockRoom.FontSize          = fontSize;
                textBlockRoom.FontFamily        = BindingValues.Instance.FontFamilyMain;
                textBlockRoom.FontWeight        = FontWeights.Light;
                textBlockRoom.Margin            = new Thickness(10, 10, 20, 10);
                textBlockRoom.VerticalAlignment = VerticalAlignment.Top;
                Grid.SetRow(textBlockRoom, row);
                Grid.SetColumn(textBlockRoom, 0);
                GridAppointments.Children.Add(textBlockRoom);

                Border borderRoom = new Border {
                    HorizontalAlignment = HorizontalAlignment.Right,
                    Width      = 4,
                    Background = new SolidColorBrush(Color.FromRgb(171, 208, 71)),
                    Margin     = new Thickness(0, 5, 0, 5)
                };
                Grid.SetRow(borderRoom, row);
                Grid.SetColumn(borderRoom, 0);
                GridAppointments.Children.Add(borderRoom);

                StackPanel stackPanelTime = new StackPanel {
                    Orientation       = Orientation.Vertical,
                    Margin            = new Thickness(20, 10, 20, 10),
                    VerticalAlignment = VerticalAlignment.Center
                };
                Grid.SetRow(stackPanelTime, row);
                Grid.SetColumn(stackPanelTime, 1);
                GridAppointments.Children.Add(stackPanelTime);

                TextBlock textBlockTimeStart = ControlsFactory.CreateTextBlock(
                    "с " + ControlsFactory.ClearTimeString(item.DateTimeScheduleBegin),
                    horizontalAlignment: HorizontalAlignment.Right);
                textBlockTimeStart.FontSize   = fontSize;
                textBlockTimeStart.FontFamily = BindingValues.Instance.FontFamilyMain;
                textBlockTimeStart.FontWeight = FontWeights.Light;
                stackPanelTime.Children.Add(textBlockTimeStart);

                TextBlock textBlockTimeEnd = ControlsFactory.CreateTextBlock(
                    "до " + ControlsFactory.ClearTimeString(item.DateTimeScheduleEnd),
                    horizontalAlignment: HorizontalAlignment.Right);
                textBlockTimeEnd.FontSize   = fontSizeSub;
                textBlockTimeEnd.FontFamily = BindingValues.Instance.FontFamilyMain;
                textBlockTimeEnd.FontWeight = FontWeights.Light;
                textBlockTimeEnd.Foreground = brushGray;
                stackPanelTime.Children.Add(textBlockTimeEnd);

                Border borderTime = new Border {
                    HorizontalAlignment = HorizontalAlignment.Right,
                    Width      = 4,
                    Background = new SolidColorBrush(Color.FromRgb(171, 208, 71)),
                    Margin     = new Thickness(0, 5, 0, 5)
                };
                Grid.SetRow(borderTime, row);
                Grid.SetColumn(borderTime, 1);
                GridAppointments.Children.Add(borderTime);

                StackPanel stackPanelDoc = new StackPanel {
                    Orientation       = Orientation.Vertical,
                    Margin            = new Thickness(20, 10, 20, 10),
                    VerticalAlignment = VerticalAlignment.Center
                };
                Grid.SetRow(stackPanelDoc, row);
                Grid.SetColumn(stackPanelDoc, 2);
                GridAppointments.Children.Add(stackPanelDoc);

                TextBlock textBlockDoc = ControlsFactory.CreateTextBlock(item.DName);
                textBlockDoc.FontSize     = fontSize;
                textBlockDoc.FontWeight   = FontWeights.Light;
                textBlockDoc.FontFamily   = BindingValues.Instance.FontFamilyMain;
                textBlockDoc.TextTrimming = TextTrimming.CharacterEllipsis;
                stackPanelDoc.Children.Add(textBlockDoc);

                string deptString = item.DepName;
                if (deptString.Length > 45)
                {
                    deptString = deptString.Substring(0, 42) + "...";
                }

                TextBlock textBlockDept = ControlsFactory.CreateTextBlock(deptString);
                textBlockDept.FontSize     = fontSizeSub;
                textBlockDept.FontWeight   = FontWeights.Light;
                textBlockDept.FontFamily   = BindingValues.Instance.FontFamilyMain;
                textBlockDept.Foreground   = brushGray;
                textBlockDept.TextTrimming = TextTrimming.CharacterEllipsis;
                stackPanelDoc.Children.Add(textBlockDept);

                int    timeLeft       = item.GetMinutesLeftToBegin();
                string timeLeftString = string.Empty;
                Brush  brushTimeLeft  = brushGray;

                if (timeLeft >= -5 && timeLeft <= 5)
                {
                    timeLeftString = "Сейчас";

                    brushTimeLeft = new SolidColorBrush(Color.FromRgb(229, 92, 68));
                }
                else if (timeLeft > 5)
                {
                    timeLeftString = "Через " + timeLeft + " " +
                                     NumbersEndingHelper.GetDeclension(timeLeft);
                }

                Border borderDoc = new Border {
                    HorizontalAlignment = HorizontalAlignment.Right,
                    Width      = 4,
                    Background = new SolidColorBrush(Color.FromRgb(171, 208, 71)),
                    Margin     = new Thickness(0, 5, 0, 5)
                };
                Grid.SetRow(borderDoc, row);
                Grid.SetColumn(borderDoc, 2);
                GridAppointments.Children.Add(borderDoc);

                if (!string.IsNullOrEmpty(timeLeftString))
                {
                    TextBlock textBlockTimeLeft = ControlsFactory.CreateTextBlock(timeLeftString);
                    textBlockTimeLeft.FontSize            = fontSizeSub;
                    textBlockTimeLeft.FontWeight          = FontWeights.Light;
                    textBlockTimeLeft.FontFamily          = BindingValues.Instance.FontFamilyMain;
                    textBlockTimeLeft.Foreground          = brushTimeLeft;
                    textBlockTimeLeft.HorizontalAlignment = HorizontalAlignment.Right;
                    textBlockTimeLeft.VerticalAlignment   = VerticalAlignment.Bottom;
                    textBlockTimeLeft.Margin = new Thickness(20, 10, 10, 10);
                    Grid.SetRow(textBlockTimeLeft, row);
                    Grid.SetColumn(textBlockTimeLeft, 3);
                    GridAppointments.Children.Add(textBlockTimeLeft);
                }

                if (item.AlreadyChecked)
                {
                    StackPanel stackPanelChecked = new StackPanel()
                    {
                        Orientation         = Orientation.Horizontal,
                        Margin              = new Thickness(20, 17, 10, 10),
                        HorizontalAlignment = HorizontalAlignment.Right,
                        VerticalAlignment   = VerticalAlignment.Top
                    };

                    Image image = new Image()
                    {
                        Source            = ControlsFactory.GetImage(ControlsFactory.ImageType.NotificationOk),
                        MaxHeight         = 32,
                        MaxWidth          = 32,
                        VerticalAlignment = VerticalAlignment.Center
                    };
                    RenderOptions.SetBitmapScalingMode(image, BitmapScalingMode.HighQuality);
                    stackPanelChecked.Children.Add(image);

                    TextBlock textBlockChecked = new TextBlock()
                    {
                        Text              = "Отмечено ранее",
                        FontSize          = fontSizeSub,
                        FontWeight        = FontWeights.Light,
                        FontFamily        = BindingValues.Instance.FontFamilyMain,
                        Foreground        = brushGray,
                        Margin            = new Thickness(10, 0, 0, 0),
                        VerticalAlignment = VerticalAlignment.Center
                    };
                    stackPanelChecked.Children.Add(textBlockChecked);

                    Grid.SetRow(stackPanelChecked, row);
                    Grid.SetColumn(stackPanelChecked, 3);
                    GridAppointments.Children.Add(stackPanelChecked);
                }

                if (row > 0)
                {
                    GridAppointments.RowDefinitions.Add(new RowDefinition());

                    Border border = ControlsFactory.CreateBorder(row);
                    GridAppointments.Children.Add(border);
                }

                row++;

                if (patient.AppointmentsAvailable.Count == 0 &&
                    row == 4)
                {
                    break;
                }

                if (row == 6)
                {
                    break;
                }
            }

            DataContext       = BindingValues.Instance;
            IsVisibleChanged += (s, e) => {
                if ((bool)e.NewValue)
                {
                    if (isFirstLoad)
                    {
                        isFirstLoad = false;
                        return;
                    }

                    if (returnBack)
                    {
                        try {
                            NavigationService.GoBack();
                            NavigationService.RemoveBackEntry();
                        } catch (Exception exc) {
                            Logging.ToLog(exc.Message + Environment.NewLine + exc.StackTrace);
                        }
                    }
                }
            };
        }