Example #1
0
        private void AlarmOn(IUICommand command)
        {
            var a = (Vakat)command.Id;

            if (!Memory.alarmBlocked[a.rbr])
            {
                AlarmSkipping.StayAlarm(a);
                Notification.Create_New_Alarm(a);
                Body_Set();
            }
            else
            {
                Open_Edit_Panel(a);
            }
        }
Example #2
0
        private void Open_Edit_Panel(Vakat a)
        {
            Grid mainGrid = new Grid {
                MaxWidth = 360,
            };
            Flyout mainFlyout = new Flyout {
                Content = mainGrid, Placement = Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode.Full
            };

            mainGrid.RowDefinitions.Add(new RowDefinition());
            mainGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Auto)
            });
            // Setup Content
            var panel = new StackPanel
            {
                Margin = new Thickness(12),
            };

            panel.SetValue(Grid.RowProperty, 0);
            mainGrid.Children.Add(panel);

            TextBlock title = new TextBlock
            {
                Text       = a.time.Hour.ToString("00") + ":" + a.time.Minute.ToString("00") + " " + a.name,
                FontSize   = 22,
                FontWeight = FontWeights.Bold,
            };

            panel.Children.Add(title);

            double do_vakta = Get.Difference_Between_Times(DateTime.Now, a.time);

            #region Alarm settings
            TextBlock Alarm_TextBlock = new TextBlock
            {
                FontSize = 18,
            };

            double pred_alarm = Memory.predAlarm[a.rbr];

            Alarm_TextBlock.Text = Get.Minutes_Double_Format(pred_alarm) + " prije nastupa"; //time before prayer-time

            Slider Alarm_Slider = new Slider
            {
                Minimum = 1,
                Maximum = 60,
                Value   = pred_alarm,
            };
            Alarm_Slider.ValueChanged += (s, e) =>
            {
                Alarm_TextBlock.Text = Get.Minutes_Double_Format(Alarm_Slider.Value) + " prije nastupa"; //time before prayer-time
            };

            ToggleSwitch Alarm_ToggleSwitch = new ToggleSwitch
            {
                OffContent = "Isključeno",
                OnContent  = "Uključeno",
            };
            Alarm_ToggleSwitch.Tag  = Alarm_Slider;
            Alarm_ToggleSwitch.IsOn = !Memory.alarmBlocked[a.rbr];
            Alarm_Slider.IsEnabled  = !Memory.alarmBlocked[a.rbr];

            TextBlock Alarm_ToggleSwitch_Header = new TextBlock
            {
                FontSize = 18,
                Text     = "Alarm",
            };
            Alarm_ToggleSwitch.SetValue(ToggleSwitch.HeaderProperty, Alarm_ToggleSwitch_Header);
            Alarm_ToggleSwitch.Toggled += (s, e) =>
            {
                Alarm_Slider.IsEnabled = Alarm_ToggleSwitch.IsOn;
            };
            panel.Children.Add(Alarm_ToggleSwitch);
            panel.Children.Add(Alarm_TextBlock);
            panel.Children.Add(Alarm_Slider);
            #endregion

            #region Toast settings
            TextBlock Toast_TextBlock = new TextBlock
            {
                FontSize = 18,
            };

            double pred_toast = Memory.predToast[a.rbr];

            Toast_TextBlock.Text = Get.Minutes_Double_Format(pred_toast) + " prije nastupa"; //time before prayer-time

            Slider Toast_Slider = new Slider
            {
                Minimum = 1,
                Maximum = 60,
                Value   = pred_toast,
            };
            Toast_Slider.ValueChanged += (s, e) =>
            {
                Toast_TextBlock.Text = Get.Minutes_Double_Format(Toast_Slider.Value) + " prije nastupa"; //time before prayer-time
            };

            ToggleSwitch Toast_ToggleSwitch = new ToggleSwitch
            {
                OffContent = "Isključeno",
                OnContent  = "Uključeno",
            };
            Toast_ToggleSwitch.Tag  = Toast_Slider;
            Toast_ToggleSwitch.IsOn = !Memory.toastBlocked[a.rbr];
            Toast_Slider.IsEnabled  = !Memory.toastBlocked[a.rbr];

            TextBlock Toast_ToggleSwitch_Header = new TextBlock
            {
                FontSize = 18,
                Text     = "Notifikacija",
            };
            Toast_ToggleSwitch.SetValue(ToggleSwitch.HeaderProperty, Toast_ToggleSwitch_Header);
            Toast_ToggleSwitch.Toggled += (s, e) =>
            {
                Toast_Slider.IsEnabled = Toast_ToggleSwitch.IsOn;
            };
            panel.Children.Add(Toast_ToggleSwitch);
            panel.Children.Add(Toast_TextBlock);
            panel.Children.Add(Toast_Slider);
            #endregion

            #region Buttons
            Grid keyGrid = new Grid {
            };
            keyGrid.ColumnDefinitions.Add(new ColumnDefinition());
            keyGrid.ColumnDefinitions.Add(new ColumnDefinition());
            keyGrid.SetValue(Grid.RowProperty, 1);
            mainGrid.Children.Add(keyGrid);

            Button lBtn = new Button
            {
                Padding                    = new Thickness(6),
                Margin                     = new Thickness(3),
                BorderBrush                = new SolidColorBrush(Colors.White),
                BorderThickness            = new Thickness(1),
                HorizontalContentAlignment = HorizontalAlignment.Center,
                VerticalContentAlignment   = VerticalAlignment.Center,
                Content                    = "sačuvaj",
                HorizontalAlignment        = HorizontalAlignment.Stretch,
                VerticalAlignment          = VerticalAlignment.Stretch,
                MinHeight                  = 0,
                MinWidth                   = 0,
            };
            lBtn.Click += (s, e) =>
            {
                if (Alarm_ToggleSwitch.IsOn)
                {
                    var tmp1 = Memory.predAlarm;
                    var tmp2 = Memory.alarmBlocked;
                    tmp1[a.rbr]         = (int)Alarm_Slider.Value;
                    tmp2[a.rbr]         = false;
                    Memory.predAlarm    = tmp1;
                    Memory.alarmBlocked = tmp2;
                    Notification.Create_New_Alarm(a);
                }
                else
                {
                    var tmp2 = Memory.alarmBlocked;
                    tmp2[a.rbr]         = true;
                    Memory.alarmBlocked = tmp2;
                    AlarmSkipping.StayAlarm(a);
                }

                if (Toast_ToggleSwitch.IsOn)
                {
                    var tmp1 = Memory.predToast;
                    var tmp2 = Memory.toastBlocked;
                    tmp1[a.rbr]         = (int)Toast_Slider.Value;
                    tmp2[a.rbr]         = false;
                    Memory.predToast    = tmp1;
                    Memory.toastBlocked = tmp2;
                    Notification.Create_New_Toast(a);
                }
                else
                {
                    var tmp2 = Memory.toastBlocked;
                    tmp2[a.rbr]         = true;
                    Memory.toastBlocked = tmp2;
                    ToastSkipping.StayToast(a);
                }
                mainFlyout.Hide();
                loader.IsActive = true;
                Set.Group_Notifications(2, 0, false, a.rbr);
                loader.IsActive = false;
                Body_Set();
            };
            lBtn.SetValue(Grid.ColumnProperty, 0);
            keyGrid.Children.Add(lBtn);

            Button rBtn = new Button
            {
                Padding                    = new Thickness(6),
                Margin                     = new Thickness(3),
                BorderBrush                = new SolidColorBrush(Colors.White),
                BorderThickness            = new Thickness(1),
                HorizontalContentAlignment = HorizontalAlignment.Center,
                VerticalContentAlignment   = VerticalAlignment.Center,
                Content                    = "poništi",
                HorizontalAlignment        = HorizontalAlignment.Stretch,
                VerticalAlignment          = VerticalAlignment.Stretch,
                MinHeight                  = 0,
                MinWidth                   = 0,
            };
            rBtn.Click += (s, e) =>
            {
                mainFlyout.Hide();
            };
            rBtn.SetValue(Grid.ColumnProperty, 1);
            keyGrid.Children.Add(rBtn);
            #endregion

            #region Show dialog in Pane and what if closed Pane
            mainFlyout.ShowAt(this);
            #endregion
        }