protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            Messenger.Default.Send(new GlobalHelper.SetHeaderTextMessageType {
                PageName = "Repository"
            });
            ReleaseBodyTextPanel.Visibility = Visibility.Collapsed;

            await ViewModel.Load(e.Parameter);

            ReadmeLoadingRing.IsActive = true;
            ReadmeWebView.NavigateToString("<html><head> <link rel =\"stylesheet\" href =\"ms-appx-web:///Assets/css/github-markdown.css\" type =\"text/css\" media =\"screen\" /> </head> <body> " + await RepositoryUtility.GetReadmeHTMLForRepository(ViewModel.Repository.Id) + " </body></html> ");
        }
Example #2
0
        private async Task LoadTrendingRepos(TimeRange range)
        {
            if (range == TimeRange.TODAY)
            {
                IsLoadingToday = CanLoadMoreToday = true;
                var repos = await RepositoryUtility.GetTrendingRepos(range, true);

                IsLoadingToday = false;

                if (repos != null)
                {
                    ZeroTodayCount          = false;
                    FirstTrendingReposToday = repos[0];
                    repos.RemoveAt(0);
                    TrendingReposToday = repos;
                }
                else
                {
                    ZeroTodayCount = true;
                    if (TrendingReposToday != null)
                    {
                        TrendingReposToday.Clear();
                    }
                }
            }
            else if (range == TimeRange.WEEKLY)
            {
                IsLoadingWeek = CanLoadMoreWeek = true;
                var repos = await RepositoryUtility.GetTrendingRepos(range, true);

                IsLoadingWeek = false;

                if (repos != null)
                {
                    ZeroWeeklyCount        = false;
                    FirstTrendingReposWeek = repos[0];
                    repos.RemoveAt(0);
                    TrendingReposWeek = repos;
                }
                else
                {
                    ZeroWeeklyCount = true;
                    if (TrendingReposWeek != null)
                    {
                        TrendingReposWeek.Clear();
                    }
                }
            }
            else
            {
                IsLoadingMonth = CanLoadMoreMonth = true;
                var repos = await RepositoryUtility.GetTrendingRepos(range, true);

                IsLoadingMonth = false;

                if (repos != null)
                {
                    ZeroMonthlyCount        = false;
                    FirstTrendingReposMonth = repos[0];
                    repos.RemoveAt(0);
                    TrendingReposMonth = repos;
                }
                else
                {
                    ZeroMonthlyCount = true;
                    if (TrendingReposMonth != null)
                    {
                        TrendingReposMonth.Clear();
                    }
                }
            }
        }
Example #3
0
        public async Task Load(Tuple <Repository, string, string> repoPath)  //This page recieves RepositoryId and name of the file
        {
            Content         = "";
            IsSupportedFile = true;
            Repository      = repoPath.Item1;
            Path            = repoPath.Item2;

            if (string.IsNullOrWhiteSpace(repoPath.Item3))
            {
                SelectedBranch = await RepositoryUtility.GetDefaultBranch(Repository.Id);
            }
            else
            {
                SelectedBranch = repoPath.Item3;
            }


            MarkdownOptions options = new MarkdownOptions
            {
                AsteriskIntraWordEmphasis = true,
                AutoNewlines     = true,
                StrictBoldItalic = true,
                AutoHyperlink    = false,
                LinkEmails       = true
            };
            Markdown markDown = new Markdown(options);

            if (!GlobalHelper.IsInternet())
            {
                Messenger.Default.Send(new GlobalHelper.NoInternetMessageType()); //Sending NoInternet message to all viewModels
            }
            else
            {
                Messenger.Default.Send(new GlobalHelper.HasInternetMessageType()); //Sending Internet available message to all viewModels
                isLoading = true;

                IsReadme = false;
                IsImage  = false;

                if ((Path.ToLower().EndsWith(".exe")) ||
                    (Path.ToLower().EndsWith(".pdf")) ||
                    (Path.ToLower().EndsWith(".ttf")) ||
                    (Path.ToLower().EndsWith(".suo")) ||
                    (Path.ToLower().EndsWith(".mp3")) ||
                    (Path.ToLower().EndsWith(".mp4")) ||
                    (Path.ToLower().EndsWith(".avi")))
                {
                    /*
                     * Unsupported file types
                     */
                    IsSupportedFile = false;
                    isLoading       = false;
                    return;
                }
                if ((Path.ToLower()).EndsWith(".png") ||
                    (Path.ToLower()).EndsWith(".jpg") ||
                    (Path.ToLower()).EndsWith(".jpeg") ||
                    (Path.ToLower().EndsWith(".gif")))
                {
                    /*
                     * Image file types
                     */

                    IsImage = true;
                    var uri = (await RepositoryUtility.GetRepositoryContentByPath(Repository.Id, Path, SelectedBranch))[0].DownloadUrl;
                    ImageFile = new BitmapImage(uri);
                    isLoading = false;
                    return;
                }
                if ((Path.ToLower()).EndsWith(".md"))
                {
                    /*
                     *  Files with .md extension will be shown with full markdown
                     */
                    IsReadme = true;

                    var str = (await RepositoryUtility.GetRepositoryContentByPath(Repository.Id, Path, SelectedBranch))[0].Content;
                    Content   = "<html><head><meta charset = \"utf-8\" /></head><body style=\"font-family: sans-serif\">" + markDown.Transform(str) + "</body></html>";
                    isLoading = false;
                    return;
                }

                Content   = (await RepositoryUtility.GetRepositoryContentByPath(Repository.Id, Path, SelectedBranch))[0].Content;
                isLoading = false;
            }
        }
Example #4
0
 public bool Save(Book obj)
 {
     using (SqlConnection con = RepositoryUtility.GetConnection())
     {
Example #5
0
 public async Task RefreshRepository()
 {
     Repository = await RepositoryUtility.GetRepository(Repository.Id);
 }
Example #6
0
        private async Task LoadTrendingRepos(TimeRange range)
        {
            if (range == TimeRange.TODAY)
            {
                var repos = await RepositoryUtility.GetTrendingRepos(range, true);

                IsLoadingToday = false;
                if (repos != null)
                {
                    TrendingReposToday = repos;

                    IsIncrementalLoadingToday = true;
                    //Second Incremental call
                    repos = await RepositoryUtility.GetTrendingRepos(range, false);

                    IsIncrementalLoadingToday = false;

                    if (repos != null)
                    {
                        foreach (var i in repos)
                        {
                            TrendingReposToday.Add(i);
                        }
                    }
                }
                else
                {
                    ZeroTodayCount = true;
                    if (TrendingReposToday != null)
                    {
                        TrendingReposToday.Clear();
                    }
                }
            }
            else if (range == TimeRange.WEEKLY)
            {
                var repos = await RepositoryUtility.GetTrendingRepos(range, true);

                IsLoadingWeek = false;
                if (repos != null)
                {
                    TrendingReposWeek = repos;

                    IsIncrementalLoadingWeek = true;
                    //Second Incremental call
                    repos = await RepositoryUtility.GetTrendingRepos(range, false);

                    IsIncrementalLoadingWeek = false;

                    if (repos != null)
                    {
                        foreach (var i in repos)
                        {
                            TrendingReposWeek.Add(i);
                        }
                    }
                }
                else
                {
                    ZeroWeeklyCount = true;
                    if (TrendingReposWeek != null)
                    {
                        TrendingReposWeek.Clear();
                    }
                }
            }
            else
            {
                var repos = await RepositoryUtility.GetTrendingRepos(range, true);

                IsLoadingMonth = false;
                if (repos != null)
                {
                    TrendingReposMonth = repos;

                    IsIncrementalLoadingMonth = true;
                    //Second Incremental call
                    repos = await RepositoryUtility.GetTrendingRepos(range, false);

                    IsIncrementalLoadingMonth = false;

                    if (repos != null)
                    {
                        foreach (var i in repos)
                        {
                            TrendingReposMonth.Add(i);
                        }
                    }
                }
                else
                {
                    ZeroMonthlyCount = true;
                    if (TrendingReposMonth != null)
                    {
                        TrendingReposMonth.Clear();
                    }
                }
            }
        }
Example #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="repoPath">Tuple with Repository, path and branch</param>
        /// <returns></returns>
        public async Task Load(Tuple <Repository, string, string> repoPath)
        {
            IsSupportedFile = true;
            Repository      = repoPath.Item1;
            Path            = repoPath.Item2;

            if (GlobalHelper.IsInternet())
            {
                isLoading = true;

                if (string.IsNullOrWhiteSpace(repoPath.Item3))
                {
                    SelectedBranch = await RepositoryUtility.GetDefaultBranch(Repository.Id);
                }
                else
                {
                    SelectedBranch = repoPath.Item3;
                }

                IsImage = false;

                if ((Path.ToLower().EndsWith(".exe")) ||
                    (Path.ToLower().EndsWith(".pdf")) ||
                    (Path.ToLower().EndsWith(".ttf")) ||
                    (Path.ToLower().EndsWith(".suo")) ||
                    (Path.ToLower().EndsWith(".mp3")) ||
                    (Path.ToLower().EndsWith(".mp4")) ||
                    (Path.ToLower().EndsWith(".avi")))
                {
                    /*
                     * Unsupported file types
                     */
                    IsSupportedFile = false;
                    isLoading       = false;
                    return;
                }
                if ((Path.ToLower()).EndsWith(".png") ||
                    (Path.ToLower()).EndsWith(".jpg") ||
                    (Path.ToLower()).EndsWith(".jpeg") ||
                    (Path.ToLower().EndsWith(".gif")))
                {
                    /*
                     * Image file types
                     */

                    IsImage = true;
                    String uri = (await RepositoryUtility.GetRepositoryContentByPath(Repository, Path, SelectedBranch))?[0].Content.DownloadUrl;
                    if (!string.IsNullOrWhiteSpace(uri))
                    {
                        ImageFile = new BitmapImage(new Uri(uri));
                    }
                    isLoading = false;
                    return;
                }
                if ((Path.ToLower()).EndsWith(".md"))
                {
                    /*
                     *  Files with .md extension
                     */
                    TextContent = (await RepositoryUtility.GetRepositoryContentByPath(Repository, Path, SelectedBranch))?[0].Content.Content;
                    isLoading   = false;
                    return;
                }

                /*
                 *  Code files
                 */

                String content = (await RepositoryUtility.GetRepositoryContentByPath(Repository, Path, SelectedBranch))?[0].Content.Content;
                if (content == null)
                {
                    IsSupportedFile = false;
                    isLoading       = false;
                    return;
                }
                SyntaxHighlightStyleEnum style = (SyntaxHighlightStyleEnum)SettingsService.Get <int>(SettingsKeys.HighlightStyleIndex);
                bool lineNumbers = SettingsService.Get <bool>(SettingsKeys.ShowLineNumbers);
                HTMLContent = await HiliteAPI.TryGetHighlightedCodeAsync(content, Path, style, lineNumbers, CancellationToken.None);

                if (HTMLContent == null)
                {
                    /*
                     *  Plain text files (Getting HTML for syntax highlighting failed)
                     */

                    RepositoryContent result = await RepositoryUtility.GetRepositoryContentTextByPath(Repository, Path, SelectedBranch);

                    if (result != null)
                    {
                        TextContent = result.Content;
                    }
                }

                if (HTMLContent == null && TextContent == null)
                {
                    IsSupportedFile = false;
                }

                isLoading = false;
            }
        }
        private static void CreateXML(List <TreeNode> nodeHierarchyElements)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                MessageBox.Show("Please select the newly created xml file");
                return;
            }
            RepositoryUtility utility  = new RepositoryUtility();
            RepositoryNode    nodeInfo = utility.ReadData(fileName);

            if (nodeInfo == null)
            {
                nodeInfo = new RepositoryNode();
            }
            List <UIControl> controlNodeColl = nodeInfo.ChildNodes;

            bool          isChildAdded = false;
            List <string> nameList     = new List <string>();

            foreach (var nodeElement in nodeHierarchyElements)
            {
                UIControl control = new UIControl();
                //Add Technology and ApplicationType
                control.ApplicationType = ApplicationTypes.Windows;
                control.TechnologyType  = TechnologyTypes.White;

                var aeNode        = (AutomationElementTreeNode)nodeElement.Tag;
                var currentNodeAE = aeNode.AutomationElement.Current;

                //Set display name to XML
                SetDisplayName(control, currentNodeAE);

                //Set Search Properties to XML
                SetSearchProperties(control, currentNodeAE);
                int index = -1; nameList.Add(control.Name);
                //
                if (FindControl(controlNodeColl, control, out index, nameList))
                {
                    //if control already eist in the file , index is the postion of the control
                    controlNodeColl = controlNodeColl[index].ChildNodes;
                }
                else
                {
                    // if control not exist then adding childern
                    int maxNumber = nameList.Take(nameList.Count() - 1).Where(x => x.StartsWith(control.Name)).Count();
                    // int.TryParse(maxuinode.Name.Substring(node.Name.Length).Remove(0, 1), out maxNumber);
                    control.Name    = control.Name + (maxNumber > 0 ? "_" + maxNumber.ToString() : "");
                    controlNodeColl = AddChild(controlNodeColl, control);
                    isChildAdded    = true;
                }
            }
            if (!isChildAdded)
            {
                DialogResult d = MessageBox.Show("Element already existing ...", "Duplicate Element !!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (d == DialogResult.OK)
                {
                    return;
                }
            }
            utility.WriteData(nodeInfo, fileName);
            MessageBox.Show("Element added successfully... \n\nFile Name: " + fileName, "Success !!", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private void openXML(List <TreeNode> nodeHierarchyElements)
        {
            List <string> controlNames = new List <string>();

            foreach (var nodeElement in nodeHierarchyElements)
            {
                controlNames.Add(((AutomationElementTreeNode)nodeElement.Tag).AutomationElement.Current.Name);
            }

            var query = controlNames.GroupBy(x => x).Where(g => g.Count() > 1).ToDictionary(x => x.Key, y => y.Count());

            if (string.IsNullOrEmpty(fileName))
            {
                MessageBox.Show("Please select the newly created xml file");
                return;
            }

            RepositoryUtility utility  = new RepositoryUtility();
            RepositoryNode    nodeInfo = (utility.ReadData(fileName) == null) ? new RepositoryNode() : utility.ReadData(fileName);

            List <UIControl> controlNodeColl = nodeInfo.ChildNodes;
            bool             isChildAdded = false;
            UIControl        control = null;
            List <string>    nameList = new List <string>(); int inc = 0;
            int i = 0; XDocument doc = null;

            foreach (var nodeElement in nodeHierarchyElements)
            {
                control = ConstructUIControlFromXMLNode(control, nodeElement);

                int index = -1; nameList.Add(control.Name);
                if (FindControl(controlNodeColl, control, out index, nameList))
                {
                    //if control already eist in the file , index is the postion of the control
                    controlNodeColl = controlNodeColl[index].ChildNodes;
                    int maxNumber = 0;
                    doc = new XDocument();
                    try
                    {
                        doc = XDocument.Load(fileName);
                        var count = doc.Descendants().Elements("ControlNode").Where(x => x.Attribute("DisplayName").Value.StartsWith(control.Name));
                        if (count.Count() > 0)
                        {
                            maxNumber = count.Count() + inc++;
                        }
                    }
                    catch
                    {
                        if (controlNames.Where(r => r.Equals(control.Name)).Count() > 1)
                        {
                            maxNumber = i++;
                        }
                    }
                    control.Name = control.Name + (maxNumber > 0 ? "_" + maxNumber.ToString() : "");
                }
                else
                {
                    int maxNumber = 0;
                    doc = new XDocument();
                    try
                    {
                        doc = XDocument.Load(fileName);
                    }
                    catch
                    {
                        if (controlNames.Where(r => r.Equals(control.Name)).Count() > 1)
                        {
                            maxNumber = i++;
                        }
                    }

                    var subfolders = doc.Descendants().Elements("ControlNode").Where(x => x.Attribute("DisplayName").Value.StartsWith(control.Name));
                    // if control not exist then adding childern
                    if (subfolders.Count() > 0)
                    {
                        maxNumber = subfolders.Count() + inc++;
                    }

                    // int.TryParse(maxuinode.Name.Substring(node.Name.Length).Remove(0, 1), out maxNumber);
                    control.Name    = control.Name + (maxNumber > 0 ? "_" + maxNumber.ToString() : "");
                    controlNodeColl = AddChild(controlNodeColl, control);
                    isChildAdded    = true;
                }
            }
            //UIControl topParent = GetTopParent(control);
            if (!isChildAdded)
            {
                DialogResult d = MessageBox.Show("Element already existing ...", "Duplicate Element !!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (d == DialogResult.OK)
                {
                    return;
                }
            }
            utility.WriteData(nodeInfo, fileName);
            MessageBox.Show("Element added successfully... \n\nFile Name: " + fileName, "Success !!", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Example #10
0
        private async void OnLaunchedOrActivated(IActivatedEventArgs args)
        {
            // Set the right theme-depending color for the alternating rows
            if (SettingsService.Get <bool>(SettingsKeys.AppLightThemeEnabled))
            {
                XAMLHelper.AssignValueToXAMLResource("OddAlternatingRowsBrush", new SolidColorBrush {
                    Color = Color.FromArgb(0x08, 0, 0, 0)
                });
            }
            if (args is LaunchActivatedEventArgs launchArgs)
            {
                if (!launchArgs.PrelaunchActivated)
                {
                    if (Window.Current.Content == null)
                    {
                        Window.Current.Content = new MainPage(null);
                        (Window.Current.Content as Page).OpenFromSplashScreen(launchArgs.SplashScreen.ImageLocation);
                    }
                }
                Activate();
                Window.Current.Activate();
                BackgroundTaskService.RegisterAppTriggerBackgroundTasks();
            }
            else if (args is ToastNotificationActivatedEventArgs toastActivatedEventArgs)
            {
                if (args.Kind == ActivationKind.Protocol)
                {
                    if (args.PreviousExecutionState == ApplicationExecutionState.Running)
                    {
                        await HandleProtocolActivationArguments(args);
                    }
                    else
                    {
                        if (Window.Current.Content == null)
                        {
                            Window.Current.Content = new MainPage(args);
                        }
                        Activate();
                    }
                }
                else if (args.Kind == ActivationKind.ToastNotification)
                {
                    var mainPageType = typeof(FeedView);
                    var backPageType = typeof(NotificationsView);
                    if (Window.Current.Content == null)
                    {
                        Window.Current.Content = new MainPage(args);
                    }
                    else
                    {
                        var svc = SimpleIoc
                                  .Default
                                  .GetInstance <IAsyncNavigationService>();
                        try
                        {
                            var toastArgs      = QueryString.Parse(toastActivatedEventArgs.Argument);
                            var notificationId = toastArgs["notificationId"] as string;
                            var repoId         = long.Parse(toastArgs["repoId"]);

                            string group = null,
                                   tag   = $"N{notificationId}+R{repoId}";

                            var repo = await RepositoryUtility.GetRepository(repoId);

                            switch (toastArgs["action"])
                            {
                            case "showIssue":
                                var issueNumber = int.Parse(toastArgs["issueNumber"]);

                                var issue = await IssueUtility.GetIssue(repo.Id, issueNumber);

                                tag  += $"+I{issueNumber}";
                                group = "Issues";
                                await svc.NavigateAsync(typeof(IssueDetailView), new Tuple <Repository, Issue>(repo, issue), backPageType : backPageType);

                                break;

                            case "showPr":
                                var prNumber = int.Parse(toastArgs["prNumber"]);
                                var pr       = await PullRequestUtility.GetPullRequest(repoId, prNumber);

                                tag  += $"+P{pr.Number}";
                                group = "PullRequests";
                                await svc.NavigateAsync(typeof(PullRequestDetailView), new Tuple <Repository, PullRequest>(repo, pr), backPageType : backPageType);

                                break;
                            }
                            if (!StringHelper.IsNullOrEmptyOrWhiteSpace(tag) && !StringHelper.IsNullOrEmptyOrWhiteSpace(group))
                            {
                                ToastNotificationManager.History.Remove(tag, group);
                            }
                            if (!StringHelper.IsNullOrEmptyOrWhiteSpace(notificationId))
                            {
                                await NotificationsService.MarkNotificationAsRead(notificationId);
                            }
                        }
                        catch
                        {
                            await svc.NavigateAsync(mainPageType);
                        }
                    }

                    Activate();
                    Window.Current.Activate();
                }
            }
            else if (args is StartupTaskActivatedEventArgs startupTaskActivatedEventArgs)
            {
                if (args.Kind == ActivationKind.StartupTask)
                {
                    var payload = ActivationKind.StartupTask.ToString();
                    if (Window.Current.Content == null)
                    {
                        Window.Current.Content = new MainPage(args);
                    }
                    (Window.Current.Content as Frame).Navigate(typeof(NotificationsView));
                }
            }
        }
Example #11
0
        public async Task Load(Tuple <Repository, string, string> repoPath)  //This page recieves RepositoryId and name of the file
        {
            IsSupportedFile = true;
            Repository      = repoPath.Item1;
            Path            = repoPath.Item2;

            if (string.IsNullOrWhiteSpace(repoPath.Item3))
            {
                SelectedBranch = await RepositoryUtility.GetDefaultBranch(Repository.Id);
            }
            else
            {
                SelectedBranch = repoPath.Item3;
            }


            MarkdownOptions options = new MarkdownOptions
            {
                AsteriskIntraWordEmphasis = true,
                AutoNewlines     = true,
                StrictBoldItalic = true,
                AutoHyperlink    = false,
                LinkEmails       = true
            };
            Markdown markDown = new Markdown(options);

            if (!GlobalHelper.IsInternet())
            {
                Messenger.Default.Send(new GlobalHelper.NoInternetMessageType()); //Sending NoInternet message to all viewModels
            }
            else
            {
                Messenger.Default.Send(new GlobalHelper.HasInternetMessageType()); //Sending Internet available message to all viewModels
                isLoading = true;
                IsImage   = false;

                if ((Path.ToLower().EndsWith(".exe")) ||
                    (Path.ToLower().EndsWith(".pdf")) ||
                    (Path.ToLower().EndsWith(".ttf")) ||
                    (Path.ToLower().EndsWith(".suo")) ||
                    (Path.ToLower().EndsWith(".mp3")) ||
                    (Path.ToLower().EndsWith(".mp4")) ||
                    (Path.ToLower().EndsWith(".avi")))
                {
                    /*
                     * Unsupported file types
                     */
                    IsSupportedFile = false;
                    isLoading       = false;
                    return;
                }
                if ((Path.ToLower()).EndsWith(".png") ||
                    (Path.ToLower()).EndsWith(".jpg") ||
                    (Path.ToLower()).EndsWith(".jpeg") ||
                    (Path.ToLower().EndsWith(".gif")))
                {
                    /*
                     * Image file types
                     */

                    IsImage = true;
                    // TODO: loading the WHOLE files list is really necessary here?
                    var uri = (await RepositoryUtility.GetRepositoryContentByPath(Repository, Path, SelectedBranch))[0].Content.DownloadUrl;
                    ImageFile = new BitmapImage(uri);
                    isLoading = false;
                    return;
                }
                if ((Path.ToLower()).EndsWith(".md"))
                {
                    /*
                     *  Files with .md extension will be shown with full markdown
                     */
                    HTMLBackgroundColor = Colors.White;
                    var str = (await RepositoryUtility.GetRepositoryContentByPath(Repository, Path, SelectedBranch))[0].Content.Content;
                    HTMLContent = "<html><head><meta charset = \"utf-8\" /></head><body style=\"font-family: sans-serif\">" + markDown.Transform(str) + "</body></html>";
                    isLoading   = false;
                    return;
                }

                String content = (await RepositoryUtility.GetRepositoryContentByPath(Repository, Path, SelectedBranch))?[0].Content.Content;
                if (content == null)
                {
                    IsSupportedFile = false;
                    isLoading       = false;
                    return;
                }
                SyntaxHighlightStyle style = (SyntaxHighlightStyle)SettingsService.Get <int>(SettingsKeys.HighlightStyleIndex);
                bool lineNumbers           = SettingsService.Get <bool>(SettingsKeys.ShowLineNumbers);
                HTMLContent = await HiliteAPI.TryGetHighlightedCodeAsync(content, Path, style, lineNumbers, CancellationToken.None);

                IsSupportedFile = HTMLContent != null;
                isLoading       = false;
            }
        }