/// <inheritdoc/> protected override void RedoAction() { foreach (var actionItem in ActionItems.Where(x => x != null)) { actionItem.Redo(); } }
/// <summary> /// 生成if action /// </summary> /// <param name="action"></param> /// <returns></returns> private Core.Action.Models.ActionModel GenerateIFAction(ActionItem action) { //action input var inputdata = action.Builder.GetInputModelData() as IFActionInputModel; //else item var elseActionItem = ActionItems.Where(m => m.Action.ParentID == action.Action.ID && m.Action.ActionType == UI.Types.ActionType.IFElse).FirstOrDefault(); //end item var endActionItem = ActionItems.Where(m => m.Action.ParentID == action.Action.ID && m.Action.ActionType == UI.Types.ActionType.IFEnd).FirstOrDefault(); //pass actions var passActionItems = ActionItems.Where(m => m.Action.ParentID == action.Action.ID && m.Y > action.Y && m.Y < elseActionItem.Y).ToList(); var passActions = GenerateActions(passActionItems); //unpass actions var unpassActionItems = ActionItems.Where(m => m.Action.ParentID == action.Action.ID && m.Y > elseActionItem.Y && m.Y < endActionItem.Y).ToList(); var unpassActions = GenerateActions(unpassActionItems); var result = new Core.Action.Models.ActionModel() { ID = action.Action.ID, Action = Core.Action.Types.ActionType.IF, Parameter = new Core.Action.Models.IFActionParameterModel() { LeftInput = inputdata.Left, RightInput = inputdata.Right, Condition = inputdata.Condition == null ? Core.Action.Types.IFActionConditionType.Equal : (Core.Action.Types.IFActionConditionType)inputdata.Condition.ID, PassActions = passActions, NoPassActions = unpassActions }, Num = 1 }; return(result); }
private Core.Action.Models.ActionModel GenerateLoopsAction(ActionItem action) { //action input var inputdata = action.Builder.GetInputModelData() as LoopsActionInputModel; var endActionItem = ActionItems.Where(m => m.Action.ParentID == action.Action.ID && m.Action.ActionType == UI.Types.ActionType.LoopsEnd).FirstOrDefault(); //actions var actionItems = ActionItems.Where(m => m.Action.ParentID == action.Action.ID && m.Y > action.Y && m.Y < endActionItem.Y).ToList(); var actions = GenerateActions(actionItems); var result = new Core.Action.Models.ActionModel() { ID = action.Action.ID, Action = Core.Action.Types.ActionType.Loops, Parameter = new Core.Action.Models.LoopsActionParamsModel() { Count = inputdata.Count, Actions = actions, }, Num = 1 }; GeneratedItems.AddRange(actionItems); return(result); }
private void HandleMoveStart(ActionItem action) { AddActionBtn.Visibility = Visibility.Hidden; if (groupActionTypes.Contains(action.Action.ActionType)) { //移动的是带子级的 action时需要将它的子级全部隐藏 int start = action.Action.Index + 1; int end = ActionItems.Where(m => m.Action.ParentID == action.Action.ID).Last().Action.Index + 1; for (int i = start; i < end; i++) { ActionItems[i].Visibility = Visibility.Hidden; ActionItems[i].Margin = new Thickness(0); groupActionItems.Add(ActionItems[i]); } var bottomItems = ActionItems.Where(m => m.Y > action.Y && m.Visibility != Visibility.Hidden).ToList(); for (int i = 0; i < bottomItems.Count; i++) { var item = bottomItems[i]; var itemPoint = item.RenderTransform as TranslateTransform; if (i == 0) { itemPoint.Y = action.Y + action.ActualHeight; } else { itemPoint.Y = bottomItems[i - 1].Y + bottomItems[i - 1].ActualHeight; } item.Y = itemPoint.Y; } } }
/// <summary> /// 调整ifaction的间距 /// </summary> /// <param name="action"></param> private void ResetIfActionMargin(ActionItem action) { var actionPoint = action.RenderTransform as TranslateTransform; //查找当前控件的上一个控件 var topActionItems = ActionItems. Where( m => m.Visibility != Visibility.Hidden && m.Y < actionPoint.Y ). OrderBy(m => m.Y); ActionItem topActionItem = null; double addMargin = 0; if (topActionItems.Count() > 0) { //存在上一个时 topActionItem = topActionItems.Last(); if (topActionItem.Action.ActionType == UI.Types.ActionType.IF || topActionItem.Action.ParentID > 0 && topActionItem.Action.ActionType != UI.Types.ActionType.IFEnd) { //上一个action还是属于if子级 //addMargin = topActionItem.Margin.Left + 10; addMargin = topActionItem.Action.ActionType == UI.Types.ActionType.IF || topActionItem.Action.ParentID != action.Action.ID ? topActionItem.Margin.Left + 10 : 10; } } //调整间距 var ifactions = ActionItems.Where(m => m.Action.ID == action.Action.ID || m.Action.ParentID == action.Action.ID).OrderBy(m => m.Y).ToList(); foreach (var ifaction in ifactions) { var newmarigin = addMargin; if (ifaction.Action.ActionType != UI.Types.ActionType.IF && ifaction.Action.ActionType != UI.Types.ActionType.IFElse && ifaction.Action.ActionType != UI.Types.ActionType.IFEnd) { newmarigin = addMargin + 10; } ifaction.Margin = new Thickness(newmarigin, 0, newmarigin, 0); if (ifaction.Action.ActionType == UI.Types.ActionType.IF && ifaction != action) { ResetIfActionMargin(ifaction); } } }
private void Remove(int id) { var action = ActionItems.Where(m => m.Action.ID == id).FirstOrDefault(); if (groupActionTypes.Contains(action.Action.ActionType)) { var endaction = ActionItems.Where(m => m.Action.ParentID == id && groupEndActionTypes.Contains(m.Action.ActionType)).FirstOrDefault(); var actions = ActionItems.Where(m => m.Y >= action.Y && m.Y <= endaction.Y).ToList(); foreach (var item in actions) { Remove(item); } } else { Remove(action); } }
private void Remove(int id) { var action = ActionItems.Where(m => m.Action.ID == id).FirstOrDefault(); if (action.Action.ActionType == UI.Types.ActionType.IF) { var endaction = ActionItems.Where(m => m.Action.ParentID == id && m.Action.ActionType == UI.Types.ActionType.IFEnd).FirstOrDefault(); var actions = ActionItems.Where(m => m.Y >= action.Y && m.Y <= endaction.Y).ToList(); foreach (var item in actions) { Remove(item); } } else { Remove(action); } }
private void ExecForward() { var emailService = Resolver.Resolve <IEmailService>(); var selectedItems = ActionItems.Where(i => i.IsSelected); var body = ""; for (var i = 0; i < 4; i++) { body += Environment.NewLine + " "; } var c = 0; foreach (var selectedItem in selectedItems) { c++; body += string.Format("{0} ({1}) {2}", selectedItem.ActionTypeStr, selectedItem.InstanceId, Environment.NewLine); } var subject = string.Format("{0} unresolved Action Items regarding NWP Services Corporation", c); body += ""; emailService.ShowDraft(subject, body, true, string.Empty); }
/// <summary> /// 调整group类型action的间距 /// </summary> /// <param name="action"></param> private void ResetGroupActionMargin(ActionItem action) { var actionPoint = action.RenderTransform as TranslateTransform; //查找当前控件的上一个控件 var topActionItems = ActionItems. Where( m => m.Visibility != Visibility.Hidden && m.Y < actionPoint.Y ). OrderBy(m => m.Y); ActionItem topActionItem = null; double addMargin = 0; if (topActionItems.Count() > 0) { //存在上一个时 topActionItem = topActionItems.Last(); if (marginActionTypes.Contains(topActionItem.Action.ActionType)) { addMargin = topActionItem.Margin.Left + 10; } else if (topActionItem.Margin.Left > 0) { //上一个间距大于0时跟随 addMargin = topActionItem.Margin.Left; } } //调整所有子级的间距 var groupActions = ActionItems.Where(m => m.Action.ID == action.Action.ID || m.Action.ParentID == action.Action.ID).OrderBy(m => m.Y).ToList(); //foreach (var groupAction in groupActions) for (int i = 0; i < groupActions.Count; i++) { var groupAction = groupActions[i]; var newmarigin = addMargin; if (!marginActionTypes.Contains(groupAction.Action.ActionType) && !groupEndActionTypes.Contains(groupAction.Action.ActionType)) { newmarigin = addMargin + 10; } //if ( // i != 0 && // !groupActionTypes.Contains(groupAction.Action.ActionType) && // !noMoveActionTypes.Contains(groupAction.Action.ActionType) // ) //{ // newmarigin = groupActions[i - 1].Margin.Left; //} //if (i != 0) //{ // //获取当前控件的上一个控件 // var topAction = groupActions[i - 1]; // if (marginActionTypes.Contains(topAction.Action.ActionType) && !noMoveActionTypes.Contains(groupAction.Action.ActionType)) // { // //需要调整间距的类型 // newmarigin = topAction.Margin.Left + 10; // } //} groupAction.Margin = new Thickness(newmarigin, 0, newmarigin, 0); if (groupActionTypes.Contains(groupAction.Action.ActionType) && groupAction != action) { ResetGroupActionMargin(groupAction); } } }
private void HandleMoveEnd(ActionItem action) { AddActionBtn.Visibility = Visibility.Visible; var actionPoint = action.RenderTransform as TranslateTransform; //调整控件自身的位置对齐 //查找当前控件的上一个控件 var topActionItems = ActionItems. Where( m => m.Visibility != Visibility.Hidden && m.Y < actionPoint.Y ). OrderBy(m => m.Y); ActionItem topActionItem = null; //新的父级id int newParentID = 0; //新的间距 double newMargin = 0; //新的位置 double newActionY = 0; if (topActionItems.Count() > 0) { //存在上一个时需要判断是否需要调整父子级关系 //上一个action topActionItem = topActionItems.Last(); //调整自身对齐上一个 newActionY = topActionItem.Y + topActionItem.ActualHeight; //判断是否需要调整间距 if (marginActionTypes.Contains(topActionItem.Action.ActionType)) { //上一个是组类型的顶级action //自身设置为下级 newParentID = groupActionTypes.Contains(topActionItem.Action.ActionType) ? topActionItem.Action.ID : topActionItem.Action.ParentID; //设置间距 newMargin = topActionItem.Margin.Left + 10; } else if (topActionItem.Action.ParentID > 0 && topActionItem.Margin.Left > 0) { //上一个是某个action的子级 if (noMoveActionTypes.Contains(topActionItem.Action.ActionType)) { //上一个是不可移动的类型,说明是特殊action的子级 //找到它的父级 var topActionParent = ActionItems.Where(m => m.Action.ID == topActionItem.Action.ParentID).FirstOrDefault(); //跟随父级关系 newParentID = topActionParent.Action.ParentID; //跟随父级间距 newMargin = topActionParent.Margin.Left; } else { //自身设置为同等子级 newParentID = topActionItem.Action.ParentID; //设置同等间距 newMargin = topActionItem.Margin.Left; } } } //更新数据 actionPoint.Y = newActionY; action.Action.ParentID = newParentID; action.Margin = new Thickness(newMargin, 0, newMargin, 0); //如果移动的是组类型的还需要将它们的子级展开 if (groupActionTypes.Contains(action.Action.ActionType)) { //查找 action下方的action var bottomActions = ActionItems.Where(m => m.Y > actionPoint.Y && m.Visibility != Visibility.Hidden).OrderBy(m => m.Y).ToList(); //调整子级的位置 for (int i = 0; i < groupActionItems.Count; i++) { var actionItem = groupActionItems[i]; var actionItemPoint = actionItem.RenderTransform as TranslateTransform; double newY = 0; if (i == 0) { //第一个跟随移动的action newY = actionPoint.Y + action.ActualHeight; } else { //跟随前一个action var lastItem = groupActionItems[i - 1]; var lastItemPoint = lastItem.RenderTransform as TranslateTransform; newY = lastItemPoint.Y + lastItem.ActualHeight; } actionItemPoint.Y = newY; //恢复显示 actionItem.Visibility = Visibility.Visible; } if (bottomActions.Count > 0) { for (int i = 0; i < bottomActions.Count; i++) { var actionTTF = bottomActions[i].RenderTransform as TranslateTransform; if (i == 0) { actionTTF.Y = groupActionItems[groupActionItems.Count - 1].Y + groupActionItems[groupActionItems.Count - 1].ActualHeight; } else { var lastactionTTF = bottomActions[i - 1].RenderTransform as TranslateTransform; actionTTF.Y = lastactionTTF.Y + bottomActions[i - 1].ActualHeight; } bottomActions[i].Y = actionTTF.Y; } } groupActionItems.Clear(); } //排序 SortAction(); //调整间距 ResetAllActionsMarigin(); }
private void HandleActionMove(ActionItem action, double moveY) { bool moveUp = false; //更新自身Y action.Y = moveY; //查找相邻的action var items = ActionItems.Where(m => m.Y > moveY).OrderBy(m => m.Y); //相邻的action ActionItem item = null; //移动的距离 double moveLength = action.ActualHeight; //if (action.Action.ActionType == UI.Types.ActionType.IF) //{ // moveLength += ifActionItems.Sum(m => m.ActualHeight); //} if (oldMoveItemY > moveY) { //向上拖动 moveUp = true; //向上拖动,查找小于移动位置的action items = ActionItems.Where(m => m.Y < moveY).OrderBy(m => m.Y); } if (items.Count() > 0) { item = moveUp ? items.Last() : items.First(); } if (moveUp) { //向上拖动,查找小于移动位置的action if (item != null) { //存在时判断位置是否需要调换 if (moveY < item.Y + item.ActualHeight / 2) { //需要 (item.RenderTransform as TranslateTransform).Y += moveLength; //更新Y item.Y = (item.RenderTransform as TranslateTransform).Y; } } } else { //向下拖动 if (item != null) { //存在时判断位置是否需要调换 if (moveY + action.ActualHeight > item.Y + item.ActualHeight / 2) { //需要 (item.RenderTransform as TranslateTransform).Y -= moveLength; //更新Y item.Y = (item.RenderTransform as TranslateTransform).Y; if (ActionItems.Where(m => m.Y < item.Y && m.Visibility != Visibility.Hidden && m != item).ToList().Count() == 0) { (item.RenderTransform as TranslateTransform).Y = 0; item.Y = 0; } } } } //更新 oldMoveItemY = moveY; }
private void HandleMoveEnd(ActionItem action) { AddActionBtn.Visibility = Visibility.Visible; var actionPoint = action.RenderTransform as TranslateTransform; //调整控件自身的位置对齐 //查找当前控件的上一个控件 var topActionItems = ActionItems. Where( m => m.Visibility != Visibility.Hidden && m.Y < actionPoint.Y ). OrderBy(m => m.Y); ActionItem topActionItem = null; if (topActionItems.Count() > 0) { //存在上一个时 topActionItem = topActionItems.Last(); //调整自身对齐上一个 actionPoint.Y = topActionItem.Y + topActionItem.ActualHeight; //判断上一个是否是判断action if (topActionItem.Action.ActionType == UI.Types.ActionType.IF || topActionItem.Action.ActionType == UI.Types.ActionType.IFElse || topActionItem.Action.ParentID > 0 && topActionItem.Action.ActionType != UI.Types.ActionType.IFEnd) { //是的话需要将自身设置为if的下级 action.Action.ParentID = topActionItem.Action.ActionType == UI.Types.ActionType.IF ? topActionItem.Action.ID : topActionItem.Action.ParentID; //设置间距 double margin = topActionItem.Action.ActionType == UI.Types.ActionType.IF || topActionItem.Action.ActionType == UI.Types.ActionType.IFElse ? topActionItem.Margin.Left + 10 : topActionItem.Margin.Left; action.Margin = new Thickness(margin, 0, margin, 0); } else { //重置父级id action.Action.ParentID = 0; action.Margin = new Thickness(0); } } else { //不存在说明已经是第一个了 actionPoint.Y = 0; //重置父级id action.Action.ParentID = 0; action.Margin = new Thickness(0); } if (action.Action.ActionType == UI.Types.ActionType.IF) { //查找if action下方的action var bottomActions = ActionItems.Where(m => m.Y > actionPoint.Y && m.Visibility != Visibility.Hidden).OrderBy(m => m.Y).ToList(); //调整子级的位置 for (int i = 0; i < ifActionItems.Count; i++) { var actionItem = ifActionItems[i]; var actionItemPoint = actionItem.RenderTransform as TranslateTransform; double newY = 0; if (i == 0) { //第一个跟随移动的action newY = actionPoint.Y + action.ActualHeight; } else { //跟随前一个action var lastItem = ifActionItems[i - 1]; var lastItemPoint = lastItem.RenderTransform as TranslateTransform; newY = lastItemPoint.Y + lastItem.ActualHeight; } actionItemPoint.Y = newY; //恢复显示 actionItem.Visibility = Visibility.Visible; } if (bottomActions.Count > 0) { for (int i = 0; i < bottomActions.Count; i++) { var actionTTF = bottomActions[i].RenderTransform as TranslateTransform; if (i == 0) { actionTTF.Y = ifActionItems[ifActionItems.Count - 1].Y + ifActionItems[ifActionItems.Count - 1].ActualHeight; } else { var lastactionTTF = bottomActions[i - 1].RenderTransform as TranslateTransform; actionTTF.Y = lastactionTTF.Y + bottomActions[i - 1].ActualHeight; } bottomActions[i].Y = actionTTF.Y; } } ifActionItems.Clear(); //调整间距 ResetIfActionMargin(action); } //排序 SortAction(); }