Beispiel #1
0
        public PageRateDoctor(ItemDoctor doctor)
        {
            InitializeComponent();
            this.doctor = doctor ?? throw new ArgumentNullException(nameof(doctor));
            MainWindow.Instance.SetupPage(this, ButtonBack, ButtonHome);

            Loaded += (s, e) => {
                (Application.Current.MainWindow as MainWindow).SetupTitle("Оцените приём у врача", doctor.Department + " @ " + doctor.Name);
            };

            foreach (UIElement uiElement in StackPanelRates.Children)
            {
                if (uiElement is Button button)
                {
                    MainWindow.ApplyStyleForButtons(new List <Button> {
                        uiElement as Button
                    });
                }
            }

            TextBlockDocName.Text     = doctor.Name;
            TextBlockDocName.FontSize = 40;
            ImageDocPhoto.Source      = ControlsFactory.ImageSourceForBitmap(
                (System.Drawing.Bitmap)ControlsFactory.GetImageForDoctor(doctor.Name));
        }
        public PageServices(string department)
        {
            InitializeComponent();
            MainWindow.Instance.SetupPage(this, ButtonBack, ButtonHome);

            UserContent.JournalOwnership = JournalOwnership.OwnsJournal;
            Loaded += (s, e) => {
                (Application.Current.MainWindow as MainWindow).SetupTitle("Услуги и цены");
            };

            MainWindow.ApplyStyleForButtons(new List <Button> {
                ButtonScrollDown, ButtonScrollUp
            });

            TextBlockDepartment.Text     = department;
            TextBlockDepartment.FontSize = 40;
            ImageDepartment.Source       = ControlsFactory.ImageSourceForBitmap((System.Drawing.Bitmap)ControlsFactory.GetImageForDepartment(department));

            List <ItemService> pageObjects = new List <ItemService>();
            List <ItemService> priceList   = Services.DataProvider.Services[department];

            for (int i = 0; i < priceList.Count; i++)
            {
                pageObjects.Add(priceList[i]);

                if (pageObjects.Count == 10)
                {
                    AddPageToList(pageObjects);
                }
            }

            if (pageObjects.Count > 0)
            {
                AddPageToList(pageObjects);
            }

            UserContent.Content = pages[0].Key;

            if (pages.Count > 1)
            {
                ButtonScrollDown.Click   += ButtonScrollDown_Click;
                ButtonScrollUp.Click     += ButtonScrollUp_Click;
                pages[0].Value.Background = new SolidColorBrush(Colors.Gray);

                ButtonScrollDown.Visibility   = Visibility.Visible;
                GridPagesIndicator.Visibility = Visibility.Visible;
            }

            currentPageIndex = 0;
        }
        public PageSchedule(string department)
        {
            InitializeComponent();
            MainWindow.Instance.SetupPage(this, ButtonBack, ButtonHome);

            UserContent.JournalOwnership = JournalOwnership.OwnsJournal;
            Loaded += (s, e) => {
                (Application.Current.MainWindow as MainWindow).SetupTitle("Расписание приёма врачей");
            };

            MainWindow.ApplyStyleForButtons(new List <Button> {
                ButtonScrollDown, ButtonScrollUp
            });

            TextBlockDepartment.Text     = department;
            TextBlockDepartment.FontSize = 40;
            ImageDepartment.Source       = ControlsFactory.ImageSourceForBitmap((System.Drawing.Bitmap)ControlsFactory.GetImageForDepartment(department));

            List <KeyValuePair <string, SortedDictionary <string, string> > > pageObjects = new List <KeyValuePair <string, SortedDictionary <string, string> > >();

            foreach (KeyValuePair <string, SortedDictionary <string, string> > keyValuePair in Services.DataProvider.Schedule[department])
            {
                pageObjects.Add(keyValuePair);

                if (pageObjects.Count == 11)
                {
                    AddPageToList(pageObjects);
                }
            }

            if (pageObjects.Count > 0)
            {
                AddPageToList(pageObjects);
            }

            UserContent.Content = pages[0].Key;

            if (pages.Count > 1)
            {
                ButtonScrollDown.Click   += ButtonScrollDown_Click;
                ButtonScrollUp.Click     += ButtonScrollUp_Click;
                pages[0].Value.Background = new SolidColorBrush(Colors.Gray);

                ButtonScrollDown.Visibility   = Visibility.Visible;
                GridPagesIndicator.Visibility = Visibility.Visible;
            }

            currentPageIndex = 0;
        }
        private void UpdateShiftKey(bool ignoreDoubleClick = false)
        {
            Color color;

            System.Drawing.Image image;

            bool isDoubleClick = (new TimeSpan(DateTime.Now.Ticks) - previousShiftKeyPress).TotalSeconds < 0.5 ? true : false;

            if (ignoreDoubleClick)
            {
                isDoubleClick = false;
            }

            if (isDoubleClick)
            {
                currentShiftKeyStatus = ShiftKeyStatus.Capslock;
                color = Services.Config.Instance.ColorButtonBackground;
                image = Properties.Resources.ButtonCapslock;
            }
            else if (currentShiftKeyStatus == ShiftKeyStatus.Unpressed)
            {
                currentShiftKeyStatus = ShiftKeyStatus.Pressed;
                color = Services.Config.Instance.ColorButtonBackground;
                image = Properties.Resources.ButtonShiftPressed;
            }
            else
            {
                currentShiftKeyStatus = ShiftKeyStatus.Unpressed;
                color = Services.Config.Instance.ColorDisabled;
                image = Properties.Resources.ButtonShiftUnpressed;
            }

            buttonShift.Background = new SolidColorBrush(color);
            buttonShift.Content    = ControlsFactory.CreateImage((System.Drawing.Bitmap)image);
            ChangeKeyboardCapitalizeStatus(buttonShift);

            previousShiftKeyPress = new TimeSpan(DateTime.Now.Ticks);
        }
        public Canvas CreateOnscreenKeyboard()
        {
            List <List <string> > keys = new List <List <string> >()
            {
                new List <string>()
                {
                    "(", ")", "'", "", "й", "ц", "у", "к", "е", "н", "г", "ш", "щ", "з", "х", "", "7", "8", "9"
                },
                new List <string>()
                {
                    "-", "+", "=", "", "ф", "ы", "в", "а", "п", "р", "о", "л", "д", "ж", "э", "", "4", "5", "6"
                },
                new List <string>()
                {
                    ":", ";", "!", "", "shift", "я", "ч", "с", "м", "и", "т", "ь", "б", "ю", "backspace", "", "1", "2", "3"
                },
                new List <string>()
                {
                    ",", ".", "?", "", "ё", "ъ", "Пробел", "Ввод", "", "", "0", ""
                }
            };

            int optionalKeysCount = 4;

            if (keyboardType == KeyboardType.Letters || keyboardType == KeyboardType.Numbers)
            {
                for (int i = 0; i < keys.Count; i++)
                {
                    if (keyboardType == KeyboardType.Letters)
                    {
                        keys[i].RemoveRange(keys[i].Count - optionalKeysCount, optionalKeysCount);
                        keys[i].RemoveRange(0, optionalKeysCount);
                    }
                    else if (keyboardType == KeyboardType.Numbers)
                    {
                        keys[i].RemoveRange(0, keys[i].Count - optionalKeysCount + 1);
                    }
                }
            }

            double keyboardSizeCoefficient = 0.9;

            if (keyboardType == KeyboardType.Numbers)
            {
                keys[3][2] = "backspace";
            }

            int keysInLine = keys[0].Count;
            int keysLines  = keys.Count;

            double keyboardHeight = (int)(availableHeight * keyboardSizeCoefficient);

            double distanceBetween = gap / 3;

            double buttonHeight = (keyboardHeight - distanceBetween * (keysLines - 1)) / keysLines;
            double buttonWidth  = buttonHeight;

            double keyboardWidth = buttonWidth * keysInLine + distanceBetween * (keysInLine - 1);

            double leftCornerShadow  = 4;
            double rightCornerShadow = 8;

            double keyboardX   = startX + (availableWidth - keyboardWidth) / 2;
            double keyboardY   = startY + availableHeight - keyboardHeight;
            double keyCurrentX = leftCornerShadow;
            double keyCurrentY = leftCornerShadow;

            Canvas canvasKeyboard = new Canvas {
                Width  = keyboardWidth + leftCornerShadow + rightCornerShadow,
                Height = keyboardHeight + leftCornerShadow + rightCornerShadow
            };

            //if (Services.Configuration.Instance.IsDebug)
            //	canvasKeyboard.Background = new SolidColorBrush(Colors.Yellow);

            currentShiftKeyStatus = ShiftKeyStatus.Unpressed;

            foreach (List <string> keysLine in keys)
            {
                foreach (string keyName in keysLine)
                {
                    if (string.IsNullOrEmpty(keyName))
                    {
                        keyCurrentX += buttonWidth + distanceBetween;
                        continue;
                    }

                    double fontScale = 1.3;

                    if (keyName.Equals("Пробел") || keyName.Equals("Ввод"))
                    {
                        fontScale = 1.0;
                    }

                    Button buttonKey = ControlsFactory.CreateButtonWithTextOnly(
                        keyName,
                        buttonWidth,
                        buttonHeight,
                        new System.Windows.Media.FontFamily("FuturaLightC"),
                        fontSize * fontScale,
                        FontWeights.Normal,
                        keyCurrentX,
                        keyCurrentY,
                        canvasKeyboard);
                    //buttonKey.VerticalContentAlignment = VerticalAlignment.Bottom;
                    //(buttonKey.Content as TextBlock).Background = Brushes.Red;
                    (buttonKey.Content as TextBlock).VerticalAlignment = VerticalAlignment.Center;

                    System.Drawing.Image imageToButton = null;
                    string tag = "";

                    switch (keyName)
                    {
                    case "shift":
                        tag              = "shift";
                        imageToButton    = Properties.Resources.ButtonShiftUnpressed;
                        buttonKey.Click += ButtonKeyShift_Click;
                        buttonShift      = buttonKey;
                        break;

                    case "backspace":
                        tag              = "backspace";
                        imageToButton    = Properties.Resources.ButtonBackspace;
                        buttonKey.Click += ButtonKeyBackspace_Click;
                        break;

                    case "Пробел":
                        tag              = "space";
                        buttonKey.Width  = buttonWidth * 7 + distanceBetween * 6;
                        keyCurrentX     += buttonKey.Width - buttonWidth;
                        buttonKey.Click += ButtonKeySpace_Click;
                        break;

                    case "Ввод":
                        tag              = "enter";
                        buttonKey.Width  = buttonWidth * 2 + distanceBetween;
                        keyCurrentX     += buttonKey.Width - buttonWidth;
                        buttonKey.Click += ButtonKeyEnter_Click;
                        buttonEnter      = buttonKey;
                        break;

                    case "clear":
                        tag              = "clear";
                        imageToButton    = Properties.Resources.ButtonClear;
                        buttonKey.Click += ButtonClear_Click;
                        break;

                    default:
                        break;
                    }

                    if (string.IsNullOrEmpty(tag))
                    {
                        buttonKey.Tag    = null;
                        buttonKey.Click += ButtonKey_Click;
                    }
                    else
                    {
                        buttonKey.Tag = tag;
                    }

                    if (keyName.Equals("shift") ||
                        keyName.Equals("backspace") ||
                        keyName.Equals("Ввод") ||
                        keyName.Equals("clear"))
                    {
                        buttonKey.Background = new SolidColorBrush(Services.Config.Instance.ColorDisabled);
                    }

                    if (imageToButton != null)
                    {
                        Image image = ControlsFactory.CreateImage((System.Drawing.Bitmap)imageToButton);
                        buttonKey.Content = image;
                    }

                    keyCurrentX += buttonWidth + distanceBetween;
                }

                keyCurrentX  = leftCornerShadow;
                keyCurrentY += buttonHeight + distanceBetween;
            }

            return(canvasKeyboard);
        }
Beispiel #6
0
        //protected double _leftCornerShadow = 0;
        //protected double _rightCornerShadow = 5;

        //protected ItemSurveyResult _surveyResult = null;



        public static void FillPanelWithElements(WrapPanel wrapPanel,
                                                 object[] elements,
                                                 ControlsFactory.ElementType type,
                                                 RoutedEventHandler eventHandler,
                                                 int elementsInRow)
        {
            if (elements == null)
            {
                throw new ArgumentNullException(nameof(elements));
            }

            if (wrapPanel == null)
            {
                throw new ArgumentNullException(nameof(wrapPanel));
            }

            double elementsCreated      = 0;
            double totalElementsCreated = 0;
            double linesCreated         = 0;
            double totalLines           = Math.Ceiling(elements.Length / (double)elementsInRow);

            double currentX;            // = 0;
            double currentY     = 0;
            double _elementsGap = 15;
            double rowsCount    = 6;

            if (type == ControlsFactory.ElementType.Doctor)
            {
                rowsCount = 2;
            }
            else if (type == ControlsFactory.ElementType.Search)
            {
                rowsCount = 1;
            }

            double       ElementWidth  = (wrapPanel.ActualWidth - _elementsGap * (elementsInRow - 1)) / elementsInRow;
            double       ElementHeight = (wrapPanel.ActualHeight - _elementsGap * (rowsCount - 1)) / rowsCount;
            ScrollViewer ScrollViewer  = new ScrollViewer {
                Width  = wrapPanel.ActualWidth,
                Height = wrapPanel.ActualHeight
            };

            bool isLastLineCentered = false;

            foreach (object element in elements)
            {
                if (element is string && string.IsNullOrEmpty((string)element))
                {
                    continue;
                }

                Button innerButton = ControlsFactory.CreateButtonWithImageAndText(
                    element,
                    ElementWidth,
                    ElementHeight,
                    type,
                    new FontFamily("FuturaLightC"),
                    30,
                    FontWeights.Normal);

                double bottomMargin       = _elementsGap;
                double rightMargin        = _elementsGap;
                double leftMargin         = 0;
                double _rightCornerShadow = 0;
                double _leftCornerShadow  = 0;

                if (elementsCreated == elementsInRow - 1)
                {
                    rightMargin = 0;
                }

                if (linesCreated == totalLines - 1)
                {
                    bottomMargin = _rightCornerShadow;

                    if (totalLines > 1 && !isLastLineCentered)
                    {
                        double lastElements      = elements.Length - totalElementsCreated;
                        double lastElementsWidth = lastElements * ElementWidth + _elementsGap * (lastElements - 1);
                        leftMargin         = (ScrollViewer.Width - _rightCornerShadow - lastElementsWidth) / 2.0d;
                        isLastLineCentered = true;
                    }
                }

                innerButton.Margin = new Thickness(leftMargin, 0, rightMargin, bottomMargin);

                wrapPanel.Children.Add(innerButton);
                innerButton.Click += eventHandler;
                elementsCreated++;
                totalElementsCreated++;

                if (elementsCreated >= elementsInRow)
                {
                    elementsCreated = 0;
                    linesCreated++;
                    currentX  = _leftCornerShadow;
                    currentY += ElementHeight + _elementsGap;
                }
            }
        }
        public PageSelectDoctor(string department, bool isSourceDocInfo = false)
        {
            InitializeComponent();
            MainWindow.Instance.SetupPage(this, ButtonBack, ButtonHome);
            this.isSourceDocInfo = isSourceDocInfo;
            title = isSourceDocInfo ? "Врачи" : "Оценка приёма у врача";

            UserContent.JournalOwnership = JournalOwnership.OwnsJournal;
            Loaded += (s, e) => {
                (Application.Current.MainWindow as MainWindow).SetupTitle(title, department);

                if (!isLoaded)
                {
                    List <ItemDoctor> pageObjects = new List <ItemDoctor>();
                    List <ItemDoctor> doctors     = Services.DataProvider.Survey[department];
                    for (int i = 0; i < doctors.Count; i++)
                    {
                        pageObjects.Add(doctors[i]);

                        if (pageObjects.Count == 10)
                        {
                            AddPageToList(pageObjects);
                        }
                    }

                    if (pageObjects.Count > 0)
                    {
                        AddPageToList(pageObjects);
                    }

                    UserContent.Content = pages[0].Key;

                    if (pages.Count > 1)
                    {
                        ButtonScrollDown.Click   += ButtonScrollDown_Click;
                        ButtonScrollUp.Click     += ButtonScrollUp_Click;
                        pages[0].Value.Background = new SolidColorBrush(Colors.Gray);

                        ButtonScrollDown.Visibility   = Visibility.Visible;
                        GridPagesIndicator.Visibility = Visibility.Visible;
                    }

                    currentPageIndex = 0;

                    isLoaded = true;
                }
            };

            MainWindow.ApplyStyleForButtons(new List <Button> {
                ButtonScrollDown, ButtonScrollUp
            });

            if (isSourceDocInfo)
            {
                TextBlockSubtitle.Text     = "Выберите врача, для просмотра подробной информации" + Environment.NewLine + "Для выбора коснитесь нужной кнопки:";
                TextBlockSubtitle.FontSize = 40;
            }

            TextBlockDepartment.Text     = department;
            TextBlockDepartment.FontSize = 40;
            TextBlockSubtitle.FontSize   = 40;
            ImageDepartment.Source       = ControlsFactory.ImageSourceForBitmap((System.Drawing.Bitmap)ControlsFactory.GetImageForDepartment(department));
        }