public static void Main(string[] args) { //// *********************************************************** //// GroupDocs.Viewer Cloud API Examples //// *********************************************************** //TODO: Get your Client Id and Client Secret at https://dashboard.groupdocs.cloud (free registration is required). Constants.MyClientId = "XXXX-XXXX-XXXX-XXXX"; Constants.MyClientSecret = "XXXXXXXXXXXXXXXX"; Constants.MyStorage = "First Storage"; // Uploading sample test files from local disk to cloud storage Constants.UploadSampleTestFiles(); #region Basic usage GetSupportedFormats.Run(); GetDocumentInformation.Run(); GetAttachments.Run(); HtmlViewerExcludeFonts.Run(); HtmlViewerMinifyHtml.Run(); HtmlViewerResponsiveLayout.Run(); ImageViewerAddTextOverlay.Run(); ImageViewerAdjustImageSize.Run(); ImageViewerAdjustJpgQuality.Run(); ImageViewerGetTextCoordinates.Run(); PdfViewerAdjustJpgQuality.Run(); PdfViewerProtectPdf.Run(); #endregion #region AdvancedUsage ViewProtectedDocument.Run(); SpecifyEncoding.Run(); RenderWithCustomFonts.Run(); AddWatermark.Run(); RenderComments.Run(); RenderNotes.Run(); RenderHiddenPages.Run(); RenderConsecutivePages.Run(); RenderSelectedPages.Run(); ReplaceMissingFont.Run(); ReorderPages.Run(); FlipRotatePages.Run(); GetInfoForArchiveFile.Run(); RenderArchiveFolder.Run(); AdjustOutputImageSize.Run(); GetInfoForCadDrawing.Run(); RenderAllLayouts.Run(); RenderLayers.Run(); RenderSingleLayout.Run(); SplitIntoTiles.Run(); AdjustPageSize.Run(); RenameEmailFields.Run(); GetInfoForProjectFile.Run(); AdjustTimeUnit.Run(); RenderTimeInterval.Run(); GetInfoForOutlookDataFile.Run(); LimitCountOfItemsToRender.Run(); RenderFolder.Run(); FilterMessages.Run(); AdjustImageQuality.Run(); DisableCharsGrouping.Run(); EnableFontHinting.Run(); EnableLayeredRendering.Run(); GetInfoForPdfFile.Run(); RenderOriginalPageSize.Run(); AdjustTextOverflowInCells.Run(); RenderSpreadsheetWithGridLines.Run(); RenderHiddenColumnsAndRows.Run(); RenderPrintAreas.Run(); SkipRenderingOfEmptyColumns.Run(); SkipRenderingOfEmptyRows.Run(); SplitWorksheetsIntoPages.Run(); RenderTrackedChanges.Run(); SpecifyMaxCharsAndRows.Run(); RenderVisioDocumentFigures.Run(); FilterMailStorage.Run(); HtmlViewerLimitImageSize.Run(); HtmlViewerOptimizeForPrinting.Run(); #endregion Console.WriteLine("Completed!"); Console.ReadKey(); }
public void GatherComments() { lbl_totalCommentsInGrid.Invoke((MethodInvoker) delegate { lbl_totalCommentsInGrid.Text = "Total Row Count: 0"; }); ProgressSpinner_LoadComments.Invoke((MethodInvoker) delegate { ProgressSpinner_LoadComments.Visible = true; }); if (string.IsNullOrEmpty(SelectedProfileORClan) || string.IsNullOrEmpty(txtBox_Comments2GetCount.Text)) { Console.WriteLine("Please select the profile/group."); InfoForm.InfoHelper.CustomMessageBox.Show("Error", "Please select the profile/group."); return; } GridCommentsData.Invoke((MethodInvoker) delegate { GridCommentsData.Rows.Clear(); }); btn_doTask.Invoke((MethodInvoker) delegate { btn_doTask.Enabled = false; }); try { string ProfileORGroupComments = "https://steamcommunity.com/comment/" + SelectedProfileORClan + "/render/" + CheckProfileGroupInfo + "/-1/?count=" + txtBox_Comments2GetCount.Text; var parser = new HtmlParser(); var json = Web.DownloadString(ProfileORGroupComments); var renderComments = RenderComments.FromJson(json); var document = parser.ParseDocument(renderComments.CommentsHtml); var eCommentList = document.QuerySelectorAll("div.commentthread_comment"); //lbl_totalComments.Invoke((MethodInvoker)delegate //{ // lbl_totalComments.Text = "Total Count: " + renderComments.TotalCount.ToString(); //}); foreach (var eComment in eCommentList) { var CommentID = eComment.QuerySelector("div.commentthread_comment_text").GetAttribute("id").Replace("comment_content_", ""); var CommentContent = RemoveSpecialCharacters(eComment.QuerySelector("div.commentthread_comment_text").TextContent.Trim()); var Author = eComment.QuerySelector("a[class='hoverunderline commentthread_author_link']").GetAttribute("href").Replace("https://steamcommunity.com/profiles/", "").Replace("https://steamcommunity.com/id/", ""); var Time = eComment.QuerySelector("span.commentthread_comment_timestamp").GetAttribute("title").Replace("https://steamcommunity.com/profiles/", ""); // title=convertido int index = Time.IndexOf("@"); if (index > 0) { Time = Time.Substring(0, index); } // remove hours, only stay date string[] arrayComments = CommentContent.Split(' '); //string[] row = { CommentID, CommentContent, Author, Time }; //GridCommentsData.Invoke((MethodInvoker)delegate //{ // GridCommentsData.Rows.Add(row.Distinct().ToArray()); //}); List <string> vals = new List <string>();//PERVENT DUPLICATE KEY if (chck_containsWords.Checked && txtBox_filterWords.Text.Length != 0) { foreach (string item in arrayComments) { string[] filterSelectedWords = txtBox_filterWords.Text.Split(','); if (filterSelectedWords.Contains(item, StringComparison.OrdinalIgnoreCase) && !vals.Contains(CommentID)) { Console.WriteLine("DELETED: " + CommentID + " || " + CommentContent + "\n"); myList.Add(CommentID, new cmts { CommentContent = CommentContent, Author = Author, Time = Time }); vals.Add(CommentID); //AccountLogin.DeleteSelectedComment(CommentID, SelectedProfileORClan); Thread.Sleep(100); } } } } GridCommentsData.Invoke((MethodInvoker) delegate { foreach (KeyValuePair <string, cmts> item in myList) { GridCommentsData.Rows.Add(item.Key, item.Value.CommentContent, item.Value.Author, item.Value.Time); } }); lbl_totalCommentsInGrid.Invoke((MethodInvoker) delegate { lbl_totalCommentsInGrid.Text = "Total Row Count:" + GridCommentsData.Rows.Count.ToString(); }); CommentsList_ScrollBar.Invoke((MethodInvoker) delegate { CommentsList_ScrollBar.Maximum = GridCommentsData.Rows.Count; }); ProgressSpinner_LoadComments.Invoke((MethodInvoker) delegate { ProgressSpinner_LoadComments.Visible = false; }); lbl_totalCommentsInGrid.Invoke((MethodInvoker) delegate { lbl_totalCommentsInGrid.Visible = true; }); btn_doTask.Invoke((MethodInvoker) delegate { btn_doTask.Enabled = true; }); } catch (Exception e) { btn_doTask.Invoke((MethodInvoker) delegate { btn_doTask.Enabled = true; }); ProgressSpinner_LoadComments.Invoke((MethodInvoker) delegate { ProgressSpinner_LoadComments.Visible = false; }); Console.WriteLine("Error: " + e); } }
private void OnUpdate() { var frame = GetRenderFrameData(); // 非表示時は処理を行わない if (frame.Visibility == Visibility.Collapsed) { if (RenderComments.Count > 0) { foreach (var renderComment in RenderComments.ToArray()) { RenderComments.Remove(renderComment.Key); CommentCanvas.Children.Remove(renderComment.Value); renderComment.Value.DataContext = null; } } return; } // コメントの上下位置を管理するリストを更新 UpdateCommentVerticalPositionList(frame.CurrentVpos); // 表示すべきコメントを抽出して、表示対象として未登録のコメントを登録処理する var displayComments = GetDisplayCommentsOnCurrentVPos(frame.CurrentVpos, frame.CommentDisplayDuration); // Debug.WriteLine("comment: " + displayComments.Count()); // コメントの表示位置決定(直列実行) foreach (var comment in displayComments) { if (!comment.IsVisible) { continue; } CommentUI renderComment = RenderComments.ContainsKey(comment) ? RenderComments[comment] : null; bool isNeedCreateCommentUI = renderComment == null; if (isNeedCreateCommentUI) { renderComment = new CommentUI(); // フォントサイズの計算 // 画面サイズの10分の1*ベーススケール*フォントスケール var baseSize = frame.CanvasHeight * 0.1; const float PixelToPoint = 0.75f; var scaledFontSize = baseSize * frame.FontScale * comment.FontScale * PixelToPoint; comment.FontSize = (uint)Math.Ceiling(scaledFontSize); // フォントの影のオフセット量 comment.TextBGOffset = Math.Floor(FontSize * TextBGOffsetBias); // コメントの終了位置を更新 comment.EndPosition = comment.VideoPosition + frame.CommentDisplayDuration; // コメントカラー if (comment.Color == null) { comment.RealColor = frame.CommentDefaultColor; } else { comment.RealColor = comment.Color.Value; } // コメント背景の色を求める comment.BackColor = GetShadowColor(comment.RealColor); renderComment.DataContext = comment; renderComment.Visibility = Visibility.Visible; // 表示対象に登録 RenderComments.Add(comment, renderComment); CommentCanvas.Children.Add(renderComment); // コメントの表示サイズを得るために強制更新 renderComment.UpdateLayout(); // コメントを配置可能な高さを取得 var verticalPos = CalcAndRegisterCommentVerticalPosition(renderComment, frame); // コメントが画面の中に収まっている場合は表示 // 少しでも見切れる場合は非表示 if (verticalPos < 0 || (verticalPos + renderComment.DesiredSize.Height) > frame.CanvasHeight) { renderComment.Visibility = Visibility.Collapsed; // Debug.WriteLine("hide comment : " + comment.CommentText); } else { // コメントの縦の表示位置を設定 Canvas.SetTop(renderComment, verticalPos); if (comment.VAlign == VerticalAlignment.Bottom || comment.VAlign == VerticalAlignment.Top) { var left = frame.HalfCanvasWidth - (int)(renderComment.DesiredSize.Width * 0.5); Canvas.SetLeft(renderComment, left); Debug.WriteLine($"V={verticalPos}: [{renderComment.CommentData.CommentText}]"); } renderComment.Update(frame.CanvasWidth, frame.CurrentVpos); } } // CommentUIの表示位置を更新 if (!comment.VAlign.HasValue || comment.VAlign == VerticalAlignment.Center) { if (renderComment.Visibility == Visibility.Visible) { renderComment.Update(frame.CanvasWidth, frame.CurrentVpos); Canvas.SetLeft(renderComment, frame.CanvasWidth - renderComment.HorizontalPosition); } } } // 表示区間をすぎたコメントを表示対象から削除 var removeTargets = RenderComments .Where(x => CommentIsEndDisplay(x.Key, frame.CurrentVpos) || x.Key.IsNGComment) .Select(x => x.Value) .ToArray(); foreach (var renderComment in removeTargets) { RenderComments.Remove(renderComment.CommentData); CommentCanvas.Children.Remove(renderComment); renderComment.CommentData = null; } }