public override void Cleanup() { ActionItems?.Clear(); CenterActionItems?.Clear(); EndActionItems?.Clear(); StartActionItems?.Clear(); }
private void RenderActions() { string category = null; var margin = new Thickness(16, 0, 0, 0); foreach (var item in ActionItems.OrderBy(c => c.Category).ThenBy(c => c.Text)) { if (item.Category != category) { category = item.Category; var c = new ListBoxItem { Content = category, IsEnabled = false, FontWeight = FontWeights.Bold, BorderThickness = new Thickness(0, 0, 0, 1), BorderBrush = SystemColors.ControlDarkBrush, Foreground = SystemColors.WindowTextBrush, Margin = new Thickness(4, 8, 4, 0) }; Actions.Items.Add(c); } var listBoxItem = new ListBoxItem { Content = RenderText(item.Text.Trim()), Tag = item, Margin = margin }; Actions.Items.Add(listBoxItem); } }
/// <inheritdoc/> protected override void UndoAction() { foreach (var actionItem in ActionItems.Reverse().Where(x => x != null)) { actionItem.Undo(); } }
public RetirementsView(RetirementsViewModel viewModel) : base(viewModel) { InitializeComponent(); ActionItems.Add(new CommandItem("Сохранить", PackIconKind.Download, viewModel.SaveAsCommand)); }
/// <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 void OnHamburgerMenuItemClicked(object obj) { var glyphItem = obj as HamburgerMenuGlyphItem; if (glyphItem == null) { return; } switch (glyphItem.Label) { case "Qualifier Group Maintainence": //Check if already exists or not if (ActionItems.Any(tabItem => string.Compare("mnuQualGroup", tabItem.Name, StringComparison.OrdinalIgnoreCase) == 0)) { return; } ActionItems.Add(new MetroTabItem() { Name = "mnuQualGroup", Header = "Qualifier Group Maintenance", CloseButtonEnabled = true, IsSelected = true, Content = new QualifierGroupUc() }); break; default: break; } }
public JsonResult TimesheetReject(string[] DATA) { try { foreach (string i in DATA) { ActionItems res = JsonConvert.DeserializeObject <ActionItems>(i); NewEntryModel existing = DB.EmpTimeSheet.Find(res.TsID); if (existing != null) { existing.Status = Convert.ToInt64(ReadConfig.GetValue("StatusRejected")); existing.ApproveRejectComments = ""; existing.ApproveRejectStatus = "R"; existing.ApproveRejectUser = (long)Session[Constants.SessionEmpID]; existing.ApproveRejectDate = DateTime.Now; DB.EmpTimeSheet.Attach(existing); DB.Entry(existing).State = System.Data.Entity.EntityState.Modified; DB.SaveChanges(); } } } catch (Exception ex) { TempData["Error"] = ex.ToString(); LogHelper.ErrorLog(ex); } return(Json(new { data = true })); }
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); }
/// <inheritdoc/> protected override void RedoAction() { foreach (var actionItem in ActionItems.NotNull()) { actionItem.Redo(); } }
/// <inheritdoc/> protected override void RedoAction() { foreach (var actionItem in ActionItems.Where(x => x != null)) { actionItem.Redo(); } }
/// <inheritdoc/> protected override void UndoAction() { foreach (var actionItem in ActionItems.Reverse().NotNull()) { actionItem.Undo(); } }
/// <summary> /// Dependent type names of this entity /// </summary> public void DeleteChildren(DatabaseEntities dbContext) { foreach (var x in ActionItems.ToList()) { x.DeleteFull(dbContext); } }
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; } } }
public void AddActionItem(string name) { var res = Database.Instance.ActionItems.Where(x => x.Name == name).FirstOrDefault(); if (res != null) { ActionItems.Add(res.Id); } }
public void RemoveActionItem(ActionItem actionItem) { if (ActionItems == null || actionItem == null || !ActionItems.Contains(actionItem)) { return; } ActionItems.Remove(actionItem); UpdateProperties(); }
/// <summary> /// Active Dependent type names of this object /// </summary> public List <string> DependentObjectNames() { var dependentObjects = new List <string>(); if (ActionItems.Any()) { dependentObjects.Add(typeof(ActionItem).Name); } return(dependentObjects.Distinct().ToList()); }
/// <summary> /// 根据action位置排序分配index /// </summary> private void SortAction() { ActionItems = ActionItems.OrderBy(m => m.Y).ToList(); for (int i = 0; i < ActionItems.Count; i++) { //var item = Items.Where(m => m.ID == actionItems[i].ID).FirstOrDefault(); //if (item != null) //{ // item.Index = i; //} ActionItems[i].Action.Index = i; } ItemIndexChanged?.Invoke(this, null); }
/// <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); } } }
public PriplodsView(PriplodsViewModel viewModel) : base(viewModel) { InitializeComponent(); ActionItems.Add(new ActionItem("Фильтр", PackIconKind.Filter, PackIconKind.FilterOutline, new RelayCommand(sender => { if (sender is ActionItem item) { UpdateContent(item, new PriplodsFilterView() { DataContext = ViewModel }); } }))); ActionItems.Add(new CommandItem("Сохранить", PackIconKind.Download, viewModel.SaveAsCommand)); }
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 UpdateActionsLocation() { var actions = ActionItems.OrderBy(m => m.Y).ToList(); for (int i = 0; i < actions.Count; i++) { var actionPoint = actions[i].RenderTransform as TranslateTransform; if (i == 0) { actionPoint.Y = 0; actions[i].Y = 0; } else { var topAction = actions[i - 1]; actionPoint.Y = topAction.Y + topAction.ActualHeight; actions[i].Y = actionPoint.Y; } } }
private void Remove(ActionItem item) { double newHeight = ActionPanel.Height - item.ActualHeight; if (newHeight <= 0) { ActionPanel.Height = double.NaN; } else { ActionPanel.Height = newHeight; } ActionPanel.Children.Remove(item); ActionItems.Remove(item); if (ActionItems.Count == 1) { ActionPanel.Height = Double.NaN; } SortAction(); UpdateActionsLocation(); }
public void UpdateInventoryCategories() { Weapons.Clear(); ActionItems.Clear(); foreach (var gameItemQuantity in _Inventory) { if (gameItemQuantity.GameItem is Weapon) { Weapons.Add(gameItemQuantity); } if (gameItemQuantity.GameItem is ActionItem) { ActionItems.Add(gameItemQuantity); } if (gameItemQuantity.GameItem is Currency) { Booty.Add(gameItemQuantity); } } }
public static void LoadScript(Game game, string path) { Assembly assembly = null; switch (Path.GetExtension(path)) { case ".exe": case ".dll": assembly = LoadAssembly(path); break; case ".cs": assembly = CompileScript(path, cSharpCodeProvider); break; case ".vb": assembly = CompileScript(path, vBCodeProvider); break; } if (assembly != null) { foreach (IScript script in FindInterfaces <IScript>(assembly)) { loadedScripts.Add(script); script.Start(game); } foreach (ICommand cmd in FindInterfaces <ICommand>(assembly)) { Commands.RegisterCommand(cmd); } foreach (IActionItem actionItem in FindInterfaces <IActionItem>(assembly)) { ActionItems.RegisterAction(actionItem); } } }
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); }
/// <inheritdoc/> public bool ContainsAction(IActionItem actionItem) { return(ActionItems.Any(x => x == actionItem || (x is IAggregateActionItem && ((IAggregateActionItem)x).ContainsAction(actionItem)))); }
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; }
/// <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(); }