Esempio n. 1
0
        public AlphaInfoPage()
        {
            AlphaApp Root = AlphaFactory.MakeSureApp();

            Languages.AlphaLanguage L = AlphaFactory.MakeSureLanguage();

            Title   = L["Information"];
            Content = new StackLayout
            {
                Children =
                {
                    new TableView
                    {
                        Root = new TableRoot
                        {
                            new TableSection(L["Version"])
                            {
                                AlphaFactory.MakeCircleImageCell
                                (
                                    ImageSource: Root.GetApplicationImageSource(),
                                    Text: "1.00.000",
                                    Command: new Command
                                    (
                                        o => Device.OpenUri
                                        (
                                            AlphaFactory.MakeSureDomain().GetApplicationStoreUri()
                                        )
                                    ),
                                    OptionImageSource: Root.GetExportImageSource()
                                ),
                            },
                            new TableSection(L["Auther"])
                            {
                                AlphaFactory.MakeCircleImageCell
                                (
                                    ImageSource: Root.GetWraithImageSource(),
                                    Text: "@wraith13",
                                    Command: new Command(o => Device.OpenUri(new Uri("https://twitter.com/wraith13"))),
                                    OptionImageSource: Root.GetExportImageSource()
                                ),
                            },
                            new TableSection(L["Github Repository"])
                            {
                                AlphaFactory.MakeCircleImageCell
                                (
                                    ImageSource: Root.GetGitHubImageSource(),
                                    Text: "wraith13/keep.grass",
                                    Command: new Command(o => Device.OpenUri(new Uri("https://github.com/wraith13/keep.grass"))),
                                    OptionImageSource: Root.GetExportImageSource()
                                ),
                            },
                        }
                    },
                },
            };
        }
Esempio n. 2
0
        public AlphaMainPage()
        {
            Title = "keep.grass";

            UserLabel.Command = new Command(o => AlphaFactory.MakeSureApp().ShowSettingsPage());
            LastActivityStampLabel.Command = new Command(async o => await Domain.ManualUpdateLastPublicActivityAsync());
            //LeftTimeLabel.Command = new Command(async o => await Domain.ManualUpdateLastPublicActivityAsync());
#if WITH_PROGRESSBAR
            ProgressBar.Margin = new Thickness(0, 0, 0, 0);
#endif

            //Build();
        }
Esempio n. 3
0
 public AlphaFriendsPage()
 {
     Title = L["Rivals"];
     List  = new ListView
     {
         ItemTemplate = new DataTemplateEx(AlphaFactory.GetGitHubUserCellType())
                        .SetBindingList("ImageSourceUrl", "Text"),
     };
     List.ItemTapped += (sender, e) =>
     {
         DeleteButton.IsEnabled = null != e.Item;
     };
     AddButton = new Button
     {
         VerticalOptions   = LayoutOptions.Center,
         HorizontalOptions = LayoutOptions.FillAndExpand,
         Text    = L["Add"],
         Command = new Command
                   (
             o => AlphaFactory
             .MakeSureApp()
             .ShowSelectUserPage
             (
                 NewUser => AddUser(NewUser),
                 Settings.GetFriendList()
                 .Concat(Settings.UserName)
                 .Where(i => !string.IsNullOrWhiteSpace(i))
                 .ToList()
             )
                   ),
     };
     DeleteButton = new Button
     {
         VerticalOptions   = LayoutOptions.Center,
         HorizontalOptions = LayoutOptions.FillAndExpand,
         Text    = L["Delete"],
         Command = new Command
                   (
             o =>
         {
             var User = List.SelectedItem.GetValue <string>("Text");
             if (null != User)
             {
                 DeleteUser(User);
             }
         }
                   ),
     };
 }
Esempio n. 4
0
        public AlphaDetailPage(string UserName)
        {
            Title = User = UserName;

            LastActivityStampLabel.Command = new Command(o => AlphaFactory.MakeSureApp().ShowFeedPage(User));
            LeftTimeLabel.Command          = new Command(async o => await Domain.ManualUpdateLastPublicActivityAsync());

            //Build();

            CircleGraph.IsVisibleSatelliteTexts = true;
            CircleGraph.IsDoughnut    = false;
            CircleGraph.ActiveWait    = TimeSpan.FromMilliseconds(100);
            CircleGraph.AnimationSpan = TimeSpan.FromMilliseconds(500);
            CircleGraph.Now           = DateTime.Now;
        }
Esempio n. 5
0
        public AlphaSettingsPage()
        {
            Title        = L["Settings"];
            LanguageCell = AlphaFactory.MakePickerCell();

            UserLabel.Command = new Command
                                (
                o => AlphaFactory
                .MakeSureApp()
                .ShowSelectUserPage
                (
                    NewUser =>
            {
                Settings.UserName = NewUser;
                Root.OnChangeSettings();
            }
                )
                                );
        }
Esempio n. 6
0
        public AlphaSettingsPage()
        {
            Title = L["Settings"];

            UserLabel.Command = new Command
                                (
                o => AlphaFactory
                .MakeSureApp()
                .ShowSelectUserPage
                (
                    NewUser =>
            {
                Settings.UserName = NewUser;
                Domain.UpdateLastPublicActivityCoreAsync(NewUser).LeavingThrown();
                Root.OnChangeSettings();
                ApplyUser(Settings.UserName);
            }
                )
                                );
        }
Esempio n. 7
0
 public void InitCircleGraph(AlphaUserCircleGraph i, string User)
 {
     //i.BackgroundColor = Color.White;
     i.IsDoughnut = true;
     i.Now        = DateTime.Now;
     i.User       = User;
     i.GestureRecognizers.Clear();
     i.LastPublicActivity = default(DateTime);
     if (!string.IsNullOrWhiteSpace(User))
     {
         i.LastPublicActivity = Domain.GetLastPublicActivity(User);
         i.GestureRecognizers
         .Add
         (
             new TapGestureRecognizer()
         {
             Command = new Command(o => AlphaFactory.MakeSureApp().ShowDetailPage(User)),
         }
         );
     }
 }
Esempio n. 8
0
 public AlphaFeedPage(string User)
 {
     Title = L["Activity"];
     Domain.GetFeed(User).ContinueWith
     (
         t => Device.BeginInvokeOnMainThread
         (
             () =>
     {
         if (null == t.Exception)
         {
             Feed = t.Result;
             Build();
         }
         else
         {
             Debug.WriteLine(t.Exception);
             AlphaFactory.MakeSureApp().Navigation.PopAsync();
         }
     }
         )
     );
 }
Esempio n. 9
0
        public override void Build()
        {
            base.Build();
            Debug.WriteLine("AlphaMainPage.Rebuild();");

            AlphaApp Root = AlphaFactory.MakeSureApp();

            if (null == Friends || Settings.GetFriendCount() != Friends.Count())
            {
                Friends = Settings.GetFriendList().Select(i => AlphaFactory.MakeUserCircleGraph()).ToArray();
                for (var i = 0; i < Friends?.Count(); ++i)
                {
                    var Friend       = Settings.GetFriend(i);
                    var FriendCircle = Friends[i];
                    InitCircleGraph(FriendCircle, Friend);
                    FriendCircle.HorizontalOptions       = LayoutOptions.Center;
                    FriendCircle.VerticalOptions         = LayoutOptions.Center;
                    FriendCircle.IsVisibleLeftTimeBar    = false;
                    FriendCircle.IsVisibleSatelliteTexts = false;
                    FriendCircle.FontSize    *= 0.5f;
                    FriendCircle.CircleMargin = new Thickness(2.0);
                }
            }

            UpdateButton.Text = L["Update"];
            var SettingsButton = new Button
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Text    = L["Settings"],
                Command = new Command(o => Root.ShowSettingsPage()),
            };
            var ButtonFrame = new Grid()
            {
                VerticalOptions   = LayoutOptions.End,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
            }
            .HorizontalJustificate
            (
                UpdateButton,
                SettingsButton
            );

            if (Width <= Height)
            {
                CircleGraph.WidthRequest  = Width;
                CircleGraph.HeightRequest = Math.Floor(Height * 0.10);
                foreach (var Friend in Friends)
                {
                    Friend.WidthRequest  = Math.Floor(Width / Math.Min(Math.Max(Friends.Count(), 2), 4));
                    Friend.HeightRequest = Friend.WidthRequest;
                }
                var StackContent = new StackLayout
                {
                    Spacing = 0.0,
                };
                StackContent.Children.Add(CircleGraph);
                BuildFriends(StackContent, StackOrientation.Horizontal);
                StackContent.Children.Add(ButtonFrame);
                Content = StackContent;
            }
            else
            {
                CircleGraph.WidthRequest  = Math.Floor(Width * 0.10);
                CircleGraph.HeightRequest = Math.Floor(Height * 0.60);
                foreach (var Friend in Friends)
                {
                    Friend.HeightRequest = Math.Floor(Height / Math.Min(Math.Max(Friends.Count(), 2), 4));
                    Friend.WidthRequest  = Friend.HeightRequest;
                }
                var StackContent = new StackLayout
                {
                    Orientation     = StackOrientation.Horizontal,
                    VerticalOptions = LayoutOptions.FillAndExpand,
                    Spacing         = 0.0,
                };
                StackContent.Children.Add(CircleGraph);
                BuildFriends(StackContent, StackOrientation.Vertical);
                Content = new StackLayout
                {
                    Spacing = 0.0,
                    //BackgroundColor = Color.White,
                    Children =
                    {
                        StackContent,
                        ButtonFrame,
                    },
                };
            }

            //  Indicator を表示中にレイアウトを変えてしまうと簡潔かつ正常に Indicator を再表示できないようなので、問答無用でテキストを表示してしまう。
            UpdateButton.ShowText();

            ApplyCircleGraph(i => i.IsInvalidCanvas = true);
            OnUpdateLastPublicActivity(Settings.UserName, Domain.GetLastPublicActivity(Settings.UserName));

            var SettingsButtonAnimation = "DefaultButtn";

            if (SettingsButton.AnimationIsRunning(SettingsButtonAnimation))
            {
                SettingsButton.AbortAnimation(SettingsButtonAnimation);
            }
            AlphaTheme.Apply(this);

            if (string.IsNullOrWhiteSpace(CircleGraph.User))
            {
                var Theme = AlphaTheme.Get();
                SettingsButton.Animate
                (
                    SettingsButtonAnimation,
                    d =>
                {
                    var Rate = Math.Abs(Math.Sin(d));
                    SettingsButton.TextColor       = ColorEx.MergeWithRate(Theme.AccentColor, Theme.BackgroundColor, Rate);
                    SettingsButton.BackgroundColor = ColorEx.MergeWithRate(Theme.BackgroundColor, Theme.AccentColor, Rate);
                },
                    0.0,
                    1000.0,
                    16,
                    (uint)2000000,
                    Easing.Linear
                );
            }
        }
Esempio n. 10
0
        public AlphaSelectUserPage(Action <string> aReciever, IEnumerable <string> ExistUsers = null)
        {
            Reciever = aReciever;
            Title    = L["Select a user"];

            List = new ListView
            {
                ItemTemplate = new DataTemplateEx(AlphaFactory.GetGitHubUserCellType())
                               .SetBindingList("ImageSourceUrl", "Text"),
            };
            List.ItemTapped += (sender, e) =>
            {
                var User = e.Item.GetValue <string>("Text");
                if (null != User)
                {
                    Debug.WriteLine($"Select User: {User}");
                    Reciever(User);
                    Domain.AddRecentUser(User);
                }
                AlphaFactory.MakeSureApp().Navigation.PopAsync();
            };
            List.ItemsSource = Domain.GetRecentUsers()
                               .Where(i => !(ExistUsers?.Contains(i) ?? false))
                               .Select(i => ListItem.Make(i));

            var SearchCommand = new Command
                                (
                async() =>
            {
                List.IsVisible         = false;
                SearchButton.IsVisible = false;
                Indicator.IsVisible    = true;
                Indicator.IsRunning    = true;
                List.ItemsSource       = new object[] { };

                try
                {
                    var Json = await Domain.GetStringFromUrlAsync
                               (
                        GitHub.GetSearchUsersUrl(Search.Text)
                               );
                    Device.BeginInvokeOnMainThread
                    (
                        () =>
                    {
                        try
                        {
                            List.ItemsSource = GitHub.SearchResult <GitHub.SearchUser> .Parse(Json)
                                               .Items
                                               .Select(i => ListItem.Make(i));
                        }
                        catch (Exception Err)
                        {
                            Debug.WriteLine(Err);
                            if (!string.IsNullOrWhiteSpace(Search.Text))
                            {
                                List.ItemsSource = new[] { Search.Text.Trim() }
                                .Select(i => ListItem.Make(i));
                            }
                        }
                        Indicator.IsRunning = false;
                        Indicator.IsVisible = false;
                        List.IsVisible      = true;
                    }
                    );
                }
                catch (Exception Err)
                {
                    Debug.WriteLine(Err);
                    if (!string.IsNullOrWhiteSpace(Search.Text))
                    {
                        List.ItemsSource = new[] { Search.Text.Trim() }
                        .Select(i => ListItem.Make(i));
                    }
                    Indicator.IsRunning = false;
                    Indicator.IsVisible = false;
                    List.IsVisible      = true;
                }
            }
                                );

            Search = new SearchBar
            {
                Placeholder   = L["User's name etc."],
                SearchCommand = SearchCommand,
            };

            Indicator = new ActivityIndicator
            {
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                IsVisible         = false,
            };

            SearchButton = new Button
            {
                VerticalOptions   = LayoutOptions.StartAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Text      = L["Search"],
                Command   = SearchCommand,
                IsVisible = false,
            };

            Search.TextChanged += (sender, e) =>
            {
                var IsNullOrWhiteSpace = string.IsNullOrWhiteSpace(Search.Text);
                List.IsVisible         = IsNullOrWhiteSpace;
                Indicator.IsVisible    = false;
                SearchButton.IsVisible = !IsNullOrWhiteSpace;
            };

            Content = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                //Spacing = 1.0,
                //BackgroundColor = Color.Gray,
                Children =
                {
                    Search,
                    List,
                    Indicator,
                    SearchButton,
                }
            };
        }
Esempio n. 11
0
 public AlphaFriendsPage()
 {
     Title = L["Rivals"];
     List  = new ListView
     {
         ItemTemplate = new DataTemplateEx(AlphaFactory.GetGitHubUserCellType())
                        .SetBindingList("ImageSource", "Text"),
     };
     List.ItemTapped += (sender, e) =>
     {
         DeleteButton.IsEnabled = null != (e.Item as ListItem);
     };
     AddButton = new Button
     {
         VerticalOptions   = LayoutOptions.Center,
         HorizontalOptions = LayoutOptions.FillAndExpand,
         Text    = L["Add"],
         Command = new Command
                   (
             o => AlphaFactory
             .MakeSureApp()
             .ShowSelectUserPage
             (
                 NewUser =>
         {
             Settings.SetFriend(Settings.GetFriendCount(), NewUser);
             UpdateList();
             IsChanged = true;
         },
                 Settings.GetFriendList()
                 .Concat(Settings.UserName)
                 .Where(i => !string.IsNullOrWhiteSpace(i))
                 .ToList()
             )
                   ),
     };
     DeleteButton = new Button
     {
         VerticalOptions   = LayoutOptions.Center,
         HorizontalOptions = LayoutOptions.FillAndExpand,
         Text    = L["Delete"],
         Command = new Command
                   (
             o =>
         {
             var SelectedItem = List.SelectedItem as ListItem;
             if (null != SelectedItem)
             {
                 var OldFriendList = Settings.GetFriendList();
                 for (var i = OldFriendList.IndexOf(SelectedItem.Text); i < OldFriendList.Count(); ++i)
                 {
                     var NewFriend = OldFriendList.Skip(i + 1).FirstOrDefault("");
                     Settings.SetFriend(i, NewFriend);
                 }
                 IsChanged = true;
                 UpdateList();
             }
         }
                   ),
     };
 }
Esempio n. 12
0
        public override void Build()
        {
            base.Build();
            Debug.WriteLine("AlphaMainPage.Rebuild();");

            CircleGraph.Build(Width, Height);

            var MainTable = new TableView
            {
                Root = new TableRoot
                {
                    new TableSection(L["Github Account"])
                    {
                        UserLabel,
                    },
                    new TableSection(L["Last Acitivity Stamp"])
                    {
                        LastActivityStampLabel,
                    },
                    new TableSection(L["Left Time"])
                    {
                        LeftTimeLabel,
                    },
                },
            };

#if WITH_PROGRESSBAR
            ProgressBarFrame,
            var ProgressBarFrame = new Grid().HorizontalJustificate
                                   (
                ProgressBar
                                   );
#endif
            var ButtonFrame = new Grid().HorizontalJustificate
                              (
                new Button
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Text    = L["Update"],
                Command = new Command(async o => await Domain.ManualUpdateLastPublicActivityAsync()),
            },
                new Button
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Text    = L["Settings"],
                Command = new Command(o => AlphaFactory.MakeSureApp().ShowSettingsPage()),
            }
                              );
            ButtonFrame.BackgroundColor = Color.White;

            if (Width <= Height)
            {
                Content = new StackLayout
                {
                    Spacing         = 0.5,
                    BackgroundColor = Color.Gray,
                    Children        =
                    {
                        CircleGraph.AsView(),
                        MainTable,
#if WITH_PROGRESSBAR
                        ProgressBarFrame,
#endif
                        ButtonFrame,
                    },
                };
            }
            else
            {
                Content = new StackLayout
                {
                    Spacing         = 0.5,
                    BackgroundColor = Color.Gray,
                    Children        =
                    {
                        new StackLayout
                        {
                            Orientation = StackOrientation.Horizontal,
                            Spacing     = 0.5,
                            Children    =
                            {
                                CircleGraph.AsView(),
                                MainTable,
                            },
                        },
#if WITH_PROGRESSBAR
                        ProgressBarFrame,
#endif
                        ButtonFrame,
                    },
                };
            }
        }