public void PasteValueWithoutTop(string clipStr) { DiyHide(); ClipModel clip = JsonConvert.DeserializeObject <ClipModel>(HttpUtility.UrlDecode(clipStr)); SinglePaste(clip); }
public static void MixerClipCreated(ClipModel clip) { if (GlobalEvents.OnMixerClipCreated != null) { GlobalEvents.OnMixerClipCreated(null, clip); } }
//收集参数 public static Dictionary <string, object> CollectParams(ClipModel clipData, params string[] ignoreFileNames) { Dictionary <string, object> paramDict = new Dictionary <string, object>(); foreach (FieldInfo fInfo in clipData.GetType().GetFields(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance)) { JsonIgnore ignoreAttr = (JsonIgnore)fInfo.GetCustomAttribute(typeof(JsonIgnore)); if (ignoreAttr != null) { continue; } if (ignoreFileNames != null && ignoreFileNames.Contains(fInfo.Name)) { continue; } object obj = fInfo.GetValue(clipData); if (obj == null) { continue; } paramDict.Add(fInfo.Name, obj); } return(paramDict); }
public override void DrawFields(FieldInfo fieldInfo) { if (fieldInfo.Name == "anim") { GUIContent lable = new GUIContent(fieldInfo.Name); float tmpHeight = GUIExtension.GetHeight(fieldInfo.FieldType, lable); UnityObjectAsset oldObj = (UnityObjectAsset)fieldInfo.GetValue(Target); ObjectDrawer objectDrawer = ObjectDrawer.CreateEditor(oldObj); objectDrawer.OnGUI(EditorGUILayout.GetControlRect(true, tmpHeight), lable); if (GUILayout.Button("设置为动画时长")) { AnimationClip clip = (AnimationClip)oldObj.GetObj(); if (clip != null) { ClipModel clipModel = Target as ClipModel; clipModel.SetEnd(clipModel.StartTime + clip.length); } } } else { base.DrawFields(fieldInfo); } }
public void CreateClip() { TestWrapper(async(MixerConnection connection) => { BroadcastModel broadcast = await connection.Broadcasts.GetCurrentBroadcast(); Assert.IsNotNull(broadcast); Assert.IsTrue(broadcast.id != Guid.Empty); bool canClipBeMade = await connection.Clips.CanClipBeMade(broadcast); Assert.IsTrue(canClipBeMade); ClipRequestModel clipRequest = new ClipRequestModel() { broadcastId = broadcast.id.ToString(), highlightTitle = "Test Clip " + DateTimeOffset.Now.ToString(), clipDurationInSeconds = 30 }; ClipModel createdClip = await connection.Clips.CreateClip(clipRequest); Assert.IsNotNull(createdClip); }); }
private void CreateClipView(Type clipType) { ClipModel clipModel = ReflectionHelper.CreateInstance(clipType) as ClipModel; clipModel.SetStart(0); clipModel.SetEnd(1); AddClip(clipModel); }
/// <summary> /// 增加条目 /// </summary> /// <param name="str"></param> private void AddClip(ClipModel clip) { string json = JsonConvert.SerializeObject(clip); json = HttpUtility.UrlEncode(json); webView1.CoreWebView2.ExecuteScriptAsync($"addData('{json}')"); }
/// <summary> /// 将粘贴条目设置到剪切板 /// </summary> /// <param name="id">索引</param> public void SetToClipboard(string clipStr) { DiyHide(); ClipModel clip = JsonConvert.DeserializeObject <ClipModel>(HttpUtility.UrlDecode(clipStr)); clipService.SetValueToClipboard(clip); }
private async Task ProcessClip(ClipModel clip, string clipName) { GlobalEvents.MixerClipCreated(clip); string clipUrl = string.Format("https://mixer.com/{0}?clip={1}", ChannelSession.User.username, clip.shareableId); if (this.ShowClipInfoInChat) { await ChannelSession.Chat.SendMessage("Clip Created: " + clipUrl); } this.extraSpecialIdentifiers[MixerClipURLSpecialIdentifier] = clipUrl; if (this.DownloadClip) { if (!Directory.Exists(this.DownloadDirectory)) { string error = "ERROR: The download folder specified for Mixer Clips does not exist"; Logger.Log(error); await ChannelSession.Chat.Whisper(ChannelSession.User.username, error); return; } if (!ChannelSession.Services.FileService.FileExists(MixerClipsAction.GetFFMPEGExecutablePath())) { string error = "ERROR: FFMPEG could not be found and the Mixer Clip can not be converted without it"; Logger.Log(error); await ChannelSession.Chat.Whisper(ChannelSession.User.username, error); return; } ClipLocatorModel clipLocator = clip.contentLocators.FirstOrDefault(cl => cl.locatorType.Equals(VideoFileContentLocatorType)); if (clipLocator != null) { string destinationFile = Path.Combine(this.DownloadDirectory, clipName + ".mp4"); #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed Task.Run(async() => { Process process = new Process(); process.StartInfo.FileName = MixerClipsAction.GetFFMPEGExecutablePath(); process.StartInfo.Arguments = string.Format("-i {0} -c copy -bsf:a aac_adtstoasc \"{1}\"", clipLocator.uri, destinationFile.ToFilePathString()); process.StartInfo.RedirectStandardOutput = true; process.StartInfo.UseShellExecute = false; process.StartInfo.CreateNoWindow = true; process.Start(); while (!process.HasExited) { await Task.Delay(500); } }); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed } } }
private void AddClipView(ClipModel clipData) { BaseClipView clipView = TimelineViewHelper.GetClipView(clipData); clipView.Init(window, Model); clipView.Track = this; Cliplist.Add(clipView); OnAddClipView(clipView); }
protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments) { if (ChannelSession.Chat != null) { if (this.ShowClipInfoInChat) { await ChannelSession.Chat.SendMessage("Sending clip creation request to Mixer..."); } string clipName = await this.ReplaceStringWithSpecialModifiers(this.ClipName, user, arguments); if (!string.IsNullOrEmpty(clipName) && MixerClipsAction.MinimumLength <= this.ClipLength && this.ClipLength <= MixerClipsAction.MaximumLength) { ClipModel clip = null; DateTimeOffset clipCreationTime = DateTimeOffset.Now; BroadcastModel broadcast = await ChannelSession.Connection.GetCurrentBroadcast(); if (broadcast != null) { if (await ChannelSession.Connection.CanClipBeMade(broadcast)) { clip = await ChannelSession.Connection.CreateClip(new ClipRequestModel() { broadcastId = broadcast.id.ToString(), highlightTitle = clipName, clipDurationInSeconds = this.ClipLength }); } } if (clip == null) { for (int i = 0; i < 10; i++) { await Task.Delay(2000); IEnumerable <ClipModel> clips = await ChannelSession.Connection.GetChannelClips(ChannelSession.Channel); clip = clips.OrderByDescending(c => c.uploadDate).FirstOrDefault(); if (clip != null && clip.uploadDate.ToLocalTime() >= clipCreationTime && clip.title.Equals(clipName)) { await this.ProcessClip(clip, clipName); return; } } await ChannelSession.Chat.SendMessage("ERROR: Unable to create clip or could not find clip, please verify that clips can be created by ensuring the Clips button on your stream is not grayed out."); } else { await this.ProcessClip(clip, clipName); } } } }
private async Task ProcessClip(ClipModel clip) { if (this.ShowClipInfoInChat) { await ChannelSession.Services.Chat.SendMessage("Clip Created: " + clip.url); } this.extraSpecialIdentifiers[ClipURLSpecialIdentifier] = clip.url; GlobalEvents.TwitchClipCreated(clip); }
private void CopyView() { string jsonStr = JsonMapper.ToJson(Clip); ClipModel newClip = JsonMapper.ToObject <ClipModel>(jsonStr); newClip.StartTime = Clip.StartTime + 2; newClip.EndTime = Clip.EndTime + 2; newClip.DurationTime = newClip.EndTime - newClip.StartTime; Track.AddClip(newClip); }
public async Task <IActionResult> Create([Bind("ID,Title,ReleaseDate,Genre,Price")] ClipModel movie) { if (ModelState.IsValid) { await _context.Add(movie); return(RedirectToAction("Index")); } return(View(movie)); }
/// <summary> /// 单个粘贴 /// </summary> /// <param name="clip"></param> private void SinglePaste(ClipModel clip) { //设置剪切板前取消监听 WinAPIHelper.RemoveClipboardFormatListener(wpfHwnd); clipService.SetValueToClipboard(clip); //Thread.Sleep(100); SendPasteKey(); //设置剪切板后恢复监听 WinAPIHelper.AddClipboardFormatListener(wpfHwnd); }
public ClipModel HandClip() { ClipModel clip = new ClipModel(); //如果有极小概率会出现 OpenClipboard 失败的异常,所以增加重试 for (int i = 0; i < 3; i++) { try { //处理剪切板微信自定义格式 if ((config.SupportFormat & ClipType.qq) != 0 && Clipboard.ContainsData(WECHAT_TYPE)) { HandleWeChat(clip); } //处理剪切板QQ自定义格式 else if ((config.SupportFormat & ClipType.qq) != 0 && Clipboard.ContainsData(QQ_RICH_TYPE)) { HandleQQ(clip); } //处理HTML类型 else if ((config.SupportFormat & ClipType.html) != 0 && Clipboard.ContainsData(DataFormats.Html)) { HandleHtml(clip); } //处理图片类型 else if ((config.SupportFormat & ClipType.image) != 0 && (Clipboard.ContainsImage() || Clipboard.ContainsData(DataFormats.Dib))) { HandleImage(clip); } //处理剪切板文件 else if ((config.SupportFormat & ClipType.file) != 0 && Clipboard.ContainsFileDropList()) { HandleFile(clip); } //处理剪切板文字 else if (Clipboard.ContainsText()) { HandleText(clip); } return(clip); } catch { } } return(clip); }
public override async Task <JObject> GetProcessedItem(UserViewModel user, IEnumerable <string> arguments, Dictionary <string, string> extraSpecialIdentifiers) { if (this.lastClip != null) { ClipLocatorModel clipLocator = this.lastClip.contentLocators.FirstOrDefault(cl => cl.locatorType.Equals(MixerClipsAction.VideoFileContentLocatorType)); if (clipLocator != null) { this.lastClipURL = clipLocator.uri; this.Effects.Duration = Math.Max(0, this.lastClip.durationInSeconds - 1); return(await base.GetProcessedItem(user, arguments, extraSpecialIdentifiers)); } this.lastClip = null; } return(null); }
public void BeginClip(SizeF size, ClipModel clipModel = ClipModel.Auto) { if (_picPanel != null && _picPanel.Visible) { if (ClipState) { return; } ClipState = true; _clipBounds = RectangleF.Empty; SetActionState(MouseState.Clip); _sizeF = size; _clipModel = clipModel; } }
public override Task LoadTestData() { this.lastClip = new ClipModel() { contentLocators = new List <ClipLocatorModel>() { new ClipLocatorModel() { locatorType = MixerClipsAction.VideoFileContentLocatorType, uri = "https://raw.githubusercontent.com/SaviorXTanren/mixer-mixitup/master/Wiki/MixerTestClip/manifest.m3u8" } }, durationInSeconds = 10 }; return(Task.FromResult(0)); }
public override async Task LoadTestData() { this.lastClip = new ClipModel() { contentLocators = new List <ClipLocatorModel>() { new ClipLocatorModel() { locatorType = MixerClipsAction.VideoFileContentLocatorType, uri = "https://raw.githubusercontent.com/SaviorXTanren/mixer-mixitup/master/Wiki/MixerTestClip/manifest.m3u8" } }, durationInSeconds = 5 }; await Task.Delay(5000); }
/// <summary> /// 处理剪切板文件类型 /// </summary> /// <param name="clip"></param> public void HandleFile(ClipModel clip) { string[] files = (string[])Clipboard.GetData(DataFormats.FileDrop); MemoryStream vMemoryStream = (MemoryStream)Clipboard.GetDataObject().GetData("Preferred DropEffect", true); DragDropEffects vDragDropEffects = (DragDropEffects)vMemoryStream.ReadByte(); //如果是剪切类型,不加入 if ((vDragDropEffects & DragDropEffects.Move) == DragDropEffects.Move) { return; } clip.Type = FILE_TYPE; clip.ClipValue = string.Join(",", files); //组装显示内容,按文件名分行 string displayStr = "<b>" + files.Length + " file"; if (files.Length > 1) { displayStr += "s"; } displayStr += "</b>"; int j = 0; foreach (string str in files) { if (j < 5) { displayStr += "<br>" + Path.GetFileName(str); } else if (j == 5) { displayStr += "<br>..."; break; } j++; } clip.DisplayValue = displayStr; }
/// <summary> /// 处理剪切板文字类型 /// </summary> /// <param name="clip"></param> public void HandleText(ClipModel clip) { string textStr = string.Empty; try { textStr = Clipboard.GetText(); } catch { if (Clipboard.ContainsData(DataFormats.UnicodeText)) { textStr = (string)Clipboard.GetData(DataFormats.UnicodeText); } } if (textStr == string.Empty) { return; } clip.ClipValue = textStr; clip.DisplayValue = textStr.Replace("<", "<").Replace(">", ">"); clip.Type = TEXT_TYPE; string[] array = clip.DisplayValue.Split('\n'); string tempStr = array[0]; if (array.Length > 0) { for (int j = 1; j < array.Length; j++) { if (j < 5) { tempStr += "<br>" + array[j]; } else if (j == 5 && j < array.Length - 1) { tempStr += "<br>..."; break; } } } clip.DisplayValue = tempStr; return; }
public override void OnInspectorGUI() { if (!ContextDataCache.TryGetContextData <GUIStyle>("BigLabel", out var bigLabel)) { bigLabel.value = new GUIStyle(GUI.skin.label); bigLabel.value.fontSize = 18; bigLabel.value.fontStyle = FontStyle.Bold; bigLabel.value.alignment = TextAnchor.MiddleLeft; bigLabel.value.stretchWidth = true; } ClipModel clipModel = Target as ClipModel; GUILayoutExtension.VerticalGroup(() => { GUILayout.Label("Clip:" + clipModel.TitleName, bigLabel.value); }); float tStart = EditorGUILayout.FloatField("Start", clipModel.StartTime); if (tStart != clipModel.StartTime) { clipModel.SetStart((float)tStart); } float tEnd = EditorGUILayout.FloatField("End", clipModel.EndTime); if (tEnd != clipModel.EndTime) { clipModel.SetEnd((float)tEnd); } EditorGUI.BeginDisabledGroup(true); EditorGUILayout.FloatField("Duration", clipModel.DurationTime); EditorGUI.EndDisabledGroup(); foreach (var field in Fields) { if (field.Name == "StartTime" || field.Name == "EndTime" || field.Name == "DurationTime") { continue; } DrawFields(field); } }
public override Task <OverlayItemBase> GetProcessedItem(UserViewModel user, IEnumerable <string> arguments, Dictionary <string, string> extraSpecialIdentifiers) { if (this.lastClip != null) { ClipModel clip = this.lastClip; this.lastClip = null; OverlayMixerClip item = this.Copy <OverlayMixerClip>(); ClipLocatorModel clipLocator = clip.contentLocators.FirstOrDefault(cl => cl.locatorType.Equals(MixerClipsAction.VideoFileContentLocatorType)); if (clipLocator != null) { item.URL = clipLocator.uri; item.Duration = Math.Max(0, clip.durationInSeconds - 1); return(Task.FromResult <OverlayItemBase>(item)); } } return(Task.FromResult <OverlayItemBase>(null)); }
private float CalcSequenceDurationTime() { float dur = 0; for (int i = 0; i < Tracklist.Count; i++) { BaseTrackView trackView = Tracklist[i]; trackView.Cliplist.ForEach((clip) => { ClipModel clipData = clip.Clip; if (clipData.EndTime > dur) { dur = clipData.EndTime; } }); } return(dur); }
/// <summary> /// 批量粘贴,由于循环太快、发送粘贴按键消息太慢,故延时 /// </summary> /// <param name="needPause"></param> private void BatchPaste(List <ClipModel> clipList) { //设置剪切板前取消监听 WinAPIHelper.RemoveClipboardFormatListener(wpfHwnd); for (int i = 0; i < clipList.Count; i++) { ClipModel clip = clipList[i]; if (i != clipList.Count - 1 && !clip.ClipValue.Contains("\n")) { clip.ClipValue += "\n"; } clipService.SetValueToClipboard(clip); SendPasteKey(); Thread.Sleep(50); } //设置剪切板后恢复监听 WinAPIHelper.AddClipboardFormatListener(wpfHwnd); }
public void GetClipsForChannel() { TestWrapper(async(MixerConnection connection) => { PrivatePopulatedUserModel user = await connection.Users.GetCurrentUser(); Assert.IsNotNull(user); IEnumerable <ClipModel> clips = await connection.Clips.GetChannelClips(user.channel); Assert.IsNotNull(clips); Assert.IsTrue(clips.Count() > 0); ClipModel clip = await connection.Clips.GetClip(clips.FirstOrDefault().shareableId); Assert.IsNotNull(clip); Assert.IsTrue(clip.shareableId.Equals(clips.FirstOrDefault().shareableId)); }); }
public void GetClip() { TestWrapper(async(TwitchConnection connection) => { IEnumerable <GameModel> games = await connection.NewAPI.Games.GetGamesByName("Fortnite"); Assert.IsNotNull(games); Assert.IsTrue(games.Count() > 0); IEnumerable <ClipModel> results = await connection.NewAPI.Clips.GetGameClips(games.First()); Assert.IsNotNull(results); Assert.IsTrue(results.Count() > 0); ClipModel result = await connection.NewAPI.Clips.GetClipByID(results.First().id); Assert.IsNotNull(result); Assert.IsNotNull(result.id); }); }
/// <summary> /// 处理剪切板微信类型 /// </summary> /// <param name="clip"></param> public void HandleWeChat(ClipModel clip) { MemoryStream stream = (MemoryStream)Clipboard.GetData(WECHAT_TYPE); string plainText = Clipboard.GetText(); clip.PlainText = plainText; byte[] b = stream.ToArray(); string xmlStr = Encoding.UTF8.GetString(b); clip.Type = WECHAT_TYPE; clip.ClipValue = xmlStr; XmlDocument document = new XmlDocument(); document.LoadXml(xmlStr); string displayValue = string.Empty; string value = string.Empty; bool onlyText = true; foreach (XmlNode node in document.DocumentElement.ChildNodes) { if (node.Name == "EditElement" && node.Attributes["type"].Value == "0") //文字类型 { displayValue += node.InnerText; value += node.InnerText; } else { onlyText = false; displayValue += "[表情]"; value += " "; } } if (onlyText) { clip.Type = TEXT_TYPE; clip.ClipValue = value; } clip.DisplayValue = displayValue; }
/// <summary> /// 处理剪切板HTML类型 /// </summary> /// <param name="clip"></param> public void HandleHtml(ClipModel clip) { string htmlStr = Clipboard.GetData(DataFormats.Html).ToString().Replace("&", "&"); string plainText = Clipboard.GetText(); //只有当html内容中有图片才当作html格式处理,否则做文本处理 if (GetOccurTimes(htmlStr.ToLower(), "<img") > GetOccurTimes(plainText.ToLower(), "<img")) { clip.ClipValue = htmlStr; string startTag = "<!--StartFragment-->"; string endTag = "<!--EndFragment-->"; //QQ上的多了个空格 if (!htmlStr.Contains(startTag)) { startTag = "<!--StartFragment -->"; } try { htmlStr = htmlStr.Substring(htmlStr.IndexOf(startTag) + startTag.Length, htmlStr.IndexOf(endTag) - (htmlStr.IndexOf(startTag) + startTag.Length)); } catch { } clip.DisplayValue = htmlStr; clip.PlainText = plainText; clip.Type = HTML_TYPE; if (!Clipboard.ContainsText() && htmlStr.ToLower().Contains("gif")) { clip.NeedOverride = true; } } else { HandleText(clip); } }