예제 #1
0
        private void ToastOff(IUICommand command)
        {
            var a = (Vakat)command.Id;

            ToastSkipping.SkipToast(a);
            Notification.Delete(Notification.Create_Key(a, "toast"));
            Body_Set();
        }
예제 #2
0
        private void ToastOn(IUICommand command)
        {
            var a = (Vakat)command.Id;

            if (!Memory.toastBlocked[a.rbr])
            {
                ToastSkipping.StayToast(a);
                Notification.Create_New_Toast(a);
                Body_Set();
            }
            else
            {
                Open_Edit_Panel(a);
            }
        }
예제 #3
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
        }
예제 #4
0
        private void Show_Content_For_Portrait(Grid _listview, Vakat v)
        {
            string tema = "";

            if (Fixed.IsDarkTheme)
            {
                tema = "_white";                    //dodatak na imena ikonica
            }
            Vakat vakat = Year.year.months[DateTime.Now.Month - 1].days[DateTime.Now.Day - 1].vakti[v.rbr];

            if (vakat.time.DayOfWeek == DayOfWeek.Friday && vakat.rbr == 2)
            {
                vakat.name = "Podne (Džuma)";                                                             //Ako je petak i vakat podna, postavit dzumu
            }
            #region ListViewItem
            ListViewItem _ListViewItem = new ListViewItem
            {
                Tag = v,
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                VerticalContentAlignment   = VerticalAlignment.Stretch,
                Padding   = new Thickness(6, 0, 6, 0),
                Margin    = new Thickness(6, 0, 6, 0),
                Opacity   = 0,
                MinHeight = 0,
                MinWidth  = 0,
            };
            #region border line
            if (vakat.rbr != 5)
            {
                if (Fixed.IsDarkTheme)
                {
                    _ListViewItem.BorderBrush = new SolidColorBrush(Color.FromArgb(18, 255, 255, 255));
                }
                else
                {
                    _ListViewItem.BorderBrush = new SolidColorBrush(Color.FromArgb(18, 0, 0, 0));
                }
                _ListViewItem.BorderThickness = new Thickness(0, 0, 0, 1);
            }
            #endregion
            _ListViewItem.Tapped += (s, e) =>
            {
                ListViewItem gr  = s as ListViewItem;
                Vakat        vkt = (Vakat)gr.Tag;
                if (DateTime.Now < vkt.time)
                {
                    Open_Edit_Panel(vkt);
                }
            };
            _ListViewItem.Holding += async(s, e) =>
            {
                PopupMenu menu = new PopupMenu();

                ListViewItem gr  = s as ListViewItem;
                Vakat        vkt = (Vakat)gr.Tag;

                e.Handled = true;

                var    pointTransform = ((ListViewItem)s).TransformToVisual(Window.Current.Content);
                double w = e.GetPosition((ListViewItem)s).X;
                double h = e.GetPosition((ListViewItem)s).Y;

                if (e.HoldingState == HoldingState.Started)
                {
                    menu.Commands.Clear();

                    #region Alarm
                    if (!Memory.alarmBlocked[vkt.rbr] && !AlarmSkipping.IsSkipped(vkt))
                    {
                        menu.Commands.Add(new UICommand
                        {
                            Id      = vkt,
                            Label   = "Preskoči alarm",
                            Invoked = AlarmOff
                        });
                    }
                    else
                    {
                        menu.Commands.Add(new UICommand
                        {
                            Id      = vkt,
                            Label   = "Uključi alarm",
                            Invoked = AlarmOn
                        });
                    }
                    #endregion

                    #region Toast
                    if (!Memory.toastBlocked[vkt.rbr] && !ToastSkipping.IsSkipped(vkt))
                    {
                        menu.Commands.Add(new UICommand
                        {
                            Id      = vkt,
                            Label   = "Preskoči notifikaciju",
                            Invoked = ToastOff,
                        });
                    }
                    else
                    {
                        menu.Commands.Add(new UICommand
                        {
                            Id      = vkt,
                            Label   = "Uključi notifikaciju",
                            Invoked = ToastOn,
                        });
                    }
                    #endregion

                    Point screenCoords = new Point();
                    screenCoords = pointTransform.TransformPoint(new Point(w, h));

                    await menu.ShowForSelectionAsync(new Rect { X = screenCoords.X, Y = screenCoords.Y });
                }
            };

            _ListViewItem.SetValue(Grid.RowProperty, v.rbr);
            _listview.Children.Add(_ListViewItem);
            #endregion

            double dif_bet_date   = (v.time - DateTime.Now).TotalSeconds;
            string toastkey       = Notification.Create_Key(v, "toast");
            string alarmkey       = Notification.Create_Key(v, "alarm");
            Vakat  current_prayer = Get.Current_Prayer_Time();
            Vakat  next_prayer    = Get.Next_Prayer_Time();

            Grid Article_Grid = new Grid
            {
                Background = new SolidColorBrush(Colors.White),
            };
            if (Fixed.IsDarkTheme)
            {
                Article_Grid.Background = new SolidColorBrush(Colors.Black);
            }

            Grid _Grid = new Grid {
                VerticalAlignment = VerticalAlignment.Center,
            };
            _Grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(3, GridUnitType.Star),
            });
            _Grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(5, GridUnitType.Star),
            });
            _Grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Auto),
            });
            _Grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Auto),
            });

            #region 1st column - clock
            Viewbox clock_Vb = new Viewbox
            {
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                Margin  = new Thickness(6),
                Stretch = Stretch.Fill,
            };

            TextBlock clock_TB = new TextBlock
            {
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                FontSize            = 44,
                Text                   = vakat.time.ToString("HH:mm"),
                FontFamily             = new FontFamily("Segoe UI Semilight"),
                OpticalMarginAlignment = OpticalMarginAlignment.TrimSideBearings,
                FontWeight             = FontWeights.Light,
                TextAlignment          = TextAlignment.Center,
            };
            if (Fixed.IsDarkTheme)
            {
                clock_TB.Foreground = new SolidColorBrush(Colors.DarkGray);
            }
            else
            {
                clock_TB.Foreground = new SolidColorBrush(Colors.LightGray);
            }
            Day yesterday = Year.year.months[DateTime.Now.AddDays(-1).Month - 1].days[DateTime.Now.AddDays(-1).Day - 1];
            Day today     = Year.year.months[DateTime.Now.AddDays(0).Month - 1].days[DateTime.Now.AddDays(0).Day - 1];
            Day tomorow   = Year.year.months[DateTime.Now.AddDays(1).Month - 1].days[DateTime.Now.AddDays(1).Day - 1];
            if (current_prayer == v || current_prayer == yesterday.vakti[v.rbr] || current_prayer == today.vakti[v.rbr] || current_prayer == tomorow.vakti[v.rbr])
            {
                clock_TB.Foreground = new SolidColorBrush(Color.FromArgb(255, 157, 157, 0));
                clock_TB.FontWeight = FontWeights.Normal;
            }
            clock_Vb.SetValue(Grid.ColumnProperty, 0);
            clock_Vb.Child = clock_TB;
            _Grid.Children.Add(clock_Vb);
            #endregion
            #region 2nd column - title and subtitle
            Grid center_Grid = new Grid {
                VerticalAlignment = VerticalAlignment.Center,
            };
            center_Grid.SetValue(Grid.ColumnProperty, 1);

            StackPanel center_SP = new StackPanel {
                HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center
            };

            TextBlock title_TB = new TextBlock
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Bottom,
                FontSize            = 22,
                Text       = vakat.name.ToLower(),
                FontFamily = new FontFamily("Segoe UI Semilight"),
            };
            center_SP.Children.Add(title_TB);

            TextBlock subtitle_TB = new TextBlock
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Bottom,
                FontSize            = 22,
                Text       = (int)(dif_bet_date / 3600) + ":" + ((int)((dif_bet_date / 60) % 60)).ToString("00") + ":" + ((int)(dif_bet_date % 60)).ToString("00"),
                Foreground = new SolidColorBrush(Colors.LightGray),
                Opacity    = 0,
                FontFamily = new FontFamily("Segoe UI Semilight"),
            };
            if (Fixed.IsDarkTheme)
            {
                subtitle_TB.Foreground = new SolidColorBrush(Colors.DarkGray);
            }
            else
            {
                subtitle_TB.Foreground = new SolidColorBrush(Colors.LightGray);
            }
            if (next_prayer == v)
            {
                center_SP.Children.Add(subtitle_TB);
                subtitle_TB.Opacity = 1;
                DispatcherTimer dt = new DispatcherTimer {
                    Interval = new TimeSpan(0, 0, 1)
                };
                dt.Tick += (s, e) =>
                {
                    if (Get.Difference_Between_Times(DateTime.Now, v.time) < 0)
                    {
                        dt.Stop(); Frame.Navigate(typeof(MainPage));
                    }
                    dif_bet_date     = (v.time - DateTime.Now).TotalSeconds;
                    subtitle_TB.Text = (int)(dif_bet_date / 3600) + ":" + ((int)((dif_bet_date / 60) % 60)).ToString("00") + ":" + ((int)(dif_bet_date % 60)).ToString("00");
                };
                dt.Start();
            }
            else
            {
                subtitle_TB.Text = "-:--:--";
            }

            center_Grid.Children.Add(center_SP);
            _Grid.Children.Add(center_Grid);
            #endregion
            #region 3rd column - alarm icon
            Image alarm_Image = new Image
            {
                Width  = 32,
                Height = 32,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                Margin  = new Thickness(3, 0, 3, 0),
                Opacity = 0,
                Source  = new BitmapImage(new Uri("ms-appx:///Assets/Images/alarm" + tema + ".png")),
            };
            alarm_Image.SetValue(Grid.ColumnProperty, 3);
            _Grid.Children.Add(alarm_Image);

            if (!Memory.alarmBlocked[v.rbr])
            {
                alarm_Image.Opacity = 1;
                if (v.alarmSkipped)
                {
                    alarm_Image.Opacity = 0.15;
                }
            }
            #endregion
            #region 4th column - toast icon
            Image toast_Image = new Image
            {
                Width  = 32,
                Height = 32,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                Margin  = new Thickness(3, 0, 3, 0),
                Opacity = 0,
                Source  = new BitmapImage(new Uri("ms-appx:///Assets/Images/notification" + tema + ".png")),
            };
            toast_Image.SetValue(Grid.ColumnProperty, 3);
            _Grid.Children.Add(toast_Image);

            if (!Memory.toastBlocked[v.rbr])
            {
                alarm_Image.SetValue(Grid.ColumnProperty, 2);
                toast_Image.Opacity = 1;
                if (v.toastSkipped)
                {
                    toast_Image.Opacity = 0.15;
                }
            }
            else if (Memory.alarmBlocked[v.rbr])
            {
                alarm_Image.SetValue(Grid.ColumnProperty, 2);
            }
            else
            {
                toast_Image.SetValue(Grid.ColumnProperty, 2);
            }
            #endregion

            Article_Grid.Children.Add(_Grid);
            _ListViewItem.Content = Article_Grid;

            #region Storyboard
            Duration duration = new Duration(TimeSpan.FromMilliseconds(250));

            DoubleAnimation myDoubleAnimation1 = new DoubleAnimation();

            myDoubleAnimation1.Duration = duration;

            Storyboard sb = new Storyboard();
            sb.Duration = duration;

            sb.Children.Add(myDoubleAnimation1);

            Storyboard.SetTarget(myDoubleAnimation1, _ListViewItem);

            Storyboard.SetTargetProperty(myDoubleAnimation1, "Opacity");

            myDoubleAnimation1.To = 1;

            _ListViewItem.Resources.Add("unique_id", sb);
            #endregion

            sb.Begin();
        }