private void MallowMultiMoveClick(object sender, RoutedEventArgs e) { MallowGroup sourceGroup = MallowSource.CurrentSource.Current; MallowGroup targetGroup = (sender as MenuItem)?.DataContext as MallowGroup; if (MallowList.SelectedItems.Count == 0 || sourceGroup is null || targetGroup is null || sourceGroup == targetGroup) { return; } Mallow[] mallows = new Mallow[MallowList.SelectedItems.Count]; MallowList.SelectedItems.CopyTo(mallows, 0); for (int i = 0; i < mallows.Length; i++) { Mallow mallow = mallows[i]; if (!sourceGroup.Mallows.Contains(mallow)) { continue; } targetGroup.Mallows.Insert(i, mallow); sourceGroup.Mallows.Remove(mallow); } }
private void CreateMallowClick(object sender, RoutedEventArgs e) { if (MallowSource.CurrentSource.Current is null) { return; } Mallow mallow = new Mallow(); mallow.SetValuesOnDeserialized(new StreamingContext()); MallowSource.CurrentSource.Current.Mallows.Insert(0, mallow); MallowSource.CurrentSource.Current.CurrentMallow = mallow; }
private void RenderPictureMultiClick(object sender, RoutedEventArgs e) { if (MallowList.SelectedItems.Count == 0 || MallowSource.CurrentSource.Current is null) { return; } Mallow[] mallows = new Mallow[MallowList.SelectedItems.Count]; MallowList.SelectedItems.CopyTo(mallows, 0); PictureRender.RenderMultiple(mallows); }
public static void RenderSingle(Mallow mallow) { string fileName = SelectSaveFilePath(); if (string.IsNullOrEmpty(fileName)) { return; } Render(new List <KeyValuePair <string, Mallow> > { new KeyValuePair <string, Mallow>(fileName, mallow) }); }
private void MallowMoveClick(object sender, RoutedEventArgs e) { Mallow source = ((sender as MenuItem)?.CommandParameter as FrameworkElement)?.DataContext as Mallow; MallowGroup sourceGroup = MallowSource.CurrentSource.Current; MallowGroup targetGroup = (sender as MenuItem)?.DataContext as MallowGroup; if (source is null || sourceGroup is null || targetGroup is null || sourceGroup == targetGroup || !sourceGroup.Mallows.Contains(source)) { return; } targetGroup.Mallows.Insert(0, source); sourceGroup.Mallows.Remove(source); }
private void MallowMultiDeleteClick(object sender, RoutedEventArgs e) { if (MallowList.SelectedItems.Count == 0 || MallowSource.CurrentSource.Current is null || !ConfirmDelete()) { return; } Mallow[] mallows = new Mallow[MallowList.SelectedItems.Count]; MallowList.SelectedItems.CopyTo(mallows, 0); foreach (Mallow mallow in mallows) { if (mallow is null || !MallowSource.CurrentSource.Current.Mallows.Contains(mallow)) { continue; } MallowSource.CurrentSource.Current.Mallows.Remove(mallow); } }
public void PushMallow(Mallow mallow, Action completed) { if (mallow is null) { return; } Push(JObject.FromObject(new { type = "msg", data = new { msg = mallow.LocalMessage, response = mallow.LocalResponse, createTime = mallow.LocalCreateTime is null ? 0 : DateTimeUtils.ConvertDateToJsTicks((DateTime)mallow.LocalCreateTime), responseTime = mallow.LocalResponseTime is null ? 0 : DateTimeUtils.ConvertDateToJsTicks((DateTime)mallow.LocalResponseTime) } }), completed);
public Mallow[] Parse(string rawData) { JArray data = (JArray)JObject.Parse(rawData)["items"]; if (data is null) { return(Array.Empty <Mallow>()); } List <Mallow> mallows = new List <Mallow>(); foreach (JToken rawItem in data) { Mallow mallow = new Mallow { OriginalMessage = (string)rawItem["content"] }; mallow.SetValuesOnDeserialized(new StreamingContext()); mallows.Add(mallow); } return(mallows.ToArray()); }
static void RenderDoWork(object sender, DoWorkEventArgs args) { if (!(sender is ProgressDialog dialog)) { return; } if (!(args.Argument is List <KeyValuePair <string, Mallow> > mallows)) { return; } if (dialog.CancellationPending) { return; } dialog.ReportProgress(0, "准备导出…", "加载渲染组件"); PictureRenderCore renderCore = PictureRenderCore.CreateRenderCore(); if (dialog.CancellationPending) { renderCore.Dispose(); return; } dialog.ReportProgress(0, "准备导出…", "加载展示场景"); renderCore.LoadFrame(); for (int index = 0; index < mallows.Count; index++) { if (dialog.CancellationPending) { renderCore.Dispose(); return; } dialog.ReportProgress((int)Math.Floor(index * 100 / (double)mallows.Count), "正在导出图片…", $"第{index}个,共{mallows.Count}个"); string fileName = mallows[index].Key; Mallow mallow = mallows[index].Value; bool pushed = false; WebPush.Current.PushMallow(mallow, () => pushed = true); while (true) { if (pushed) { break; } } Task <Bitmap> task = renderCore.Capture(); task.Wait(); task.Result.Save(fileName); } dialog.ReportProgress(100, "正在导出图片…", "正在清理"); renderCore.Dispose(); //dialog.Dispose(); }