Beispiel #1
0
        private void FileFolderLogic(string text, Action <string> editLogic, TextBlock errorTbl, bool lookingAtFolder, bool needsToBeExe = false)
        {
            if (text.Length == 0)
            {
                editLogic(text);
                errorTbl.Visibility = Visibility.Collapsed;
                MasterCustomPage.SaveProfiles();
                return;
            }

            if (needsToBeExe || !lookingAtFolder && File.Exists(text) || lookingAtFolder && Directory.Exists(text))
            {
                if (needsToBeExe && text.Split('.').Last() != "exe")
                {
                    errorTbl.Visibility = Visibility.Visible;
                }
                else
                {
                    if (needsToBeExe)
                    {
                        text = text.Remove(0, text.LastIndexOf("\\") + 1);
                    }
                    editLogic(text);
                    errorTbl.Visibility = Visibility.Collapsed;
                    MasterCustomPage.SaveProfiles();
                }
            }
            else
            {
                errorTbl.Visibility = Visibility.Visible;
            }
        }
Beispiel #2
0
        private void TimespanLogic(string time, Action <TimeSpan> editLogic, TextBlock errorTbl)
        {
            if (MasterCustomPage.CurrentButton == null)
            {
                return;
            }

            if (time.Length == 0)
            {
                editLogic(TimeSpan.Zero);
                errorTbl.Visibility = Visibility.Collapsed;
                MasterCustomPage.SaveProfiles();
                return;
            }

            if (TimeSpan.TryParseExact(time, "h\\:mm\\:ss", new NumberFormatInfo(), out var span))
            {
                editLogic(span);
                errorTbl.Visibility = Visibility.Collapsed;
                MasterCustomPage.SaveProfiles();
            }
            else
            {
                errorTbl.Visibility = Visibility.Visible;
            }
        }
Beispiel #3
0
        private void DayButton_OnClick(object sender, RoutedEventArgs e)
        {
            if (((Button)sender).Background == App.Current.Resources["AccentColour1SCBrush"])
            {
                MasterCustomPage.Profiles[MasterCustomPage.CurrentButton.Content.ToString()].Triggers.Time.Days.Add((DayOfWeek)((Button)sender).Tag);
                ((Button)sender).SetResourceReference(ButtonBase.BackgroundProperty, "AccentColour2SCBrush");
            }
            else
            {
                MasterCustomPage.Profiles[MasterCustomPage.CurrentButton.Content.ToString()].Triggers.Time.Days.Remove((DayOfWeek)((Button)sender).Tag);
                ((Button)sender).SetResourceReference(ButtonBase.BackgroundProperty, "AccentColour1SCBrush");
            }

            MasterCustomPage.SaveProfiles();
        }
        public MasterCustomPage(double pageWidth)
        {
            InitializeComponent();

            LoadProfiles();
            _MasterCustomPage = this;
            Width             = pageWidth;

            //TriggerWatch.Start();
            MakeJumpList();

            _tabPage = new TabPage(new[]
            {
                new TabItem
                {
                    TabName = App.Text.CustomPage,
                    Page    = new CustomPage()
                },
                new TabItem
                {
                    TabName = App.Text.CustomTriggers,
                    Page    = new TriggerPage(pageWidth)
                }
            });
            for (var i = 0; i < Profiles?.Count; i++)
            {
                MakeMenuButton(Profiles.ElementAt(i).Key);
            }

            tbProfiles.ItemsSource = ProfileButtons;
            tbProfiles.Items.Refresh();

            if (CurrentButton != null)
            {
                CurrentButton.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
            }
            else
            {
                ProfileButtons[App.Config.SelectedCustom].RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
            }

            tbProfiles.Visibility = tbProfiles.Items.Count == 1 ? Visibility.Collapsed : Visibility.Visible;

            frmContent.Content = _tabPage;
        }
Beispiel #5
0
        private Task UpdateProfile(string profileName, string text1, string text2, string largeKey,
                                   string largeText, string smallKey, string smallText, string clientID, bool showTime)
        {
            var oldProfile = MasterCustomPage.Profiles[profileName];

            MasterCustomPage.Profiles[profileName] = new CustomProfile
            {
                LargeKey  = largeKey,
                Text1     = text1,
                Text2     = text2,
                LargeText = largeText,
                SmallKey  = smallKey,
                SmallText = smallText,
                ShowTime  = showTime,
                ClientID  = clientID,
                Name      = profileName,
                Triggers  = oldProfile.Triggers
            };
            MasterCustomPage.SaveProfiles();

            return(Task.CompletedTask);
        }
Beispiel #6
0
        private Task UpdateProfile(string profileName, string text1 = null, string text2 = null, string largeKey = null,
                                   string largeText = null, string smallKey = null, string smallText             = null, string clientID = null, bool?showTime = null)
        {
            if (!IsLoaded)
            {
                return(Task.CompletedTask);
            }

            var profile = MasterCustomPage.Profiles[profileName];

            profile.LargeKey  = largeKey ?? profile.LargeKey;
            profile.Text1     = text1 ?? profile.Text1;
            profile.Text2     = text2 ?? profile.Text2;
            profile.LargeText = largeText ?? profile.LargeText;
            profile.SmallKey  = smallKey ?? profile.SmallKey;
            profile.SmallText = smallText ?? profile.SmallText;
            profile.ShowTime  = showTime ?? profile.ShowTime;
            profile.ClientID  = clientID ?? profile.ClientID;
            MasterCustomPage.SaveProfiles();

            return(Task.CompletedTask);
        }