private void AddActionTowers(List <TowerPredefinedMessageDTO> towersAction) { Application.Current.Dispatcher.Invoke(() => { towersAction.ForEach(x => ActionsList.Add(x)); }); }
/// <summary> /// Выполнение алгоритма по шагам /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void StepClick(object sender, RoutedEventArgs e) { if (_robot.CurrentAction == null) { _robot.CurrentAction = _algorithm.ActionList.FirstOrDefault(); } try { _robot.CurrentAction = _algorithmWork.ExecuteAction(_robot, _algorithm, _field); } catch { MessageBox.Show("Роботу встретился незнакомый цвет", "Ошибка"); } ActionsList.Focus(); ActionsList.SelectedIndex = _algorithm.ActionList.IndexOf(_robot.CurrentAction); if (_algorithmWork.CheckPosition(_algorithm, _robot)) { UpdateBackPattern(); DrawField(); } else { MessageBox.Show("Роботу запрещено покидать свой маленьки мир(", "Попытка выхода за пределы поля"); } }
/// <summary> /// Adds action. /// </summary> /// <param name="action">Action</param> public override void AddAction(HeaderAction action) { if (action == null) { return; } // Make sure the Save action is set only once string key = string.Format("HeaderActionsSaveSet_{0}_{1}", action.CommandArgument, ClientID); bool saveSet = ValidationHelper.GetBoolean(RequestStockHelper.GetItem(key), false); if (!(action is SaveAction) || !saveSet) { bool added = false; // Ensure correct index if (action.Index == -1) { action.Index = ActionsList.Count; } else { // Post processing of action attribute for (int i = 0; i < ActionsList.Count; i++) { if (ActionsList[i].Index == action.Index) { // Replace action with the same index ActionsList[i] = action; // Button added added = true; break; } } } // If action with the same index was not found, add it to the list if (!added) { ActionsList.Add(action); } // Keep flag if (action is SaveAction) { RequestStockHelper.Add(key, (action.BaseButton == null) || action.BaseButton.Visible); } } // Store base buttons if ((action.BaseButton != null) && !ProcessedBaseButtons.Contains(action.BaseButton)) { ProcessedBaseButtons.Add(action.BaseButton); } }
/// <summary> /// Перериовка холста /// </summary> private void UpdateCanvas() { Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate() { ActionsList.Focus(); ActionsList.SelectedIndex = _algorithm.ActionList.IndexOf(_robot.CurrentAction); UpdateBackPattern(); DrawField(); })); }
public UndoRedoMenuItemViewModel(ICommandStackService commandStackService, ILocalizerService localizerService) { _commandStackService = commandStackService; _localizerService = localizerService; UndoOneAction = new RelayCommand(async() => { await commandStackService.UndoCommands(1); }, () => _commandStackService.GetPrevAvailableCommands().Any()); RedoOneAction = new RelayCommand(async() => { await commandStackService.RedoCommands(1); }, () => _commandStackService.GetNextAvailableCommands().Any()); UndoActions = new RelayCommand(() => { ActionsList = _commandStackService.GetPrevAvailableCommands() .Select((s, num) => new CommandViewModel(num, s)).ToList(); IsCommandsPopupOpen = true; }, () => _commandStackService.GetPrevAvailableCommands().Any()); SelectCommand = new RelayCommand <object>(((args) => { if (!(args is MouseEventArgs mouseEventArgs)) { return; } if (!(mouseEventArgs.Source is FrameworkElement frameworkElement)) { return; } if (frameworkElement.DataContext is CommandViewModel commandViewModel) { ActionsList.Where(model => model.NumberOfCommand <= commandViewModel.NumberOfCommand) .ForEach(model => model.IsSelected = true); } })); _commandStackService.CommandsChanged += () => { RaisePropertyChanged(nameof(ActionsList)); RaisePropertyChanged(nameof(UndoButtonTooltip)); RaisePropertyChanged(nameof(RedoButtonTooltip)); (UndoOneAction as RelayCommand)?.RaiseCanExecuteChanged(); (RedoOneAction as RelayCommand)?.RaiseCanExecuteChanged(); (UndoActions as RelayCommand)?.RaiseCanExecuteChanged(); (RedoActions as RelayCommand)?.RaiseCanExecuteChanged(); }; }
private void CalculateSpaceNeeded() { long sourceDeletionSize = 0; // B long sourceCreationSize = 0; long destDeletionSize = 0; long destCreationSize = 0; var creationsAndDeletions = ActionsList.FindAll(x => x.ActionType == ActionType.Create //|| x.ActionType == ActionType.Delete ); foreach (var action in creationsAndDeletions) { var files = WorkingWithFiles.GetSourceAndDestFile(action.File1, action.File2); var sourceFile = files[FileType.Source]; var destFile = files[FileType.Destination]; if (action.ActionType == ActionType.Create) { if (action.ActionDirection == Direction.SourceToDestination) { destCreationSize += sourceFile.FileSize; } else { sourceCreationSize += destFile.FileSize; } } //if (action.ActionType == ActionType.Delete) //{ // if (action.ActionDirection == Direction.SourceToDestination) // { // destDeletionSize += destFile.FileSize; // } // else // { // sourceDeletionSize += sourceFile.FileSize; // } //} } _spaceNeededInSource = (int)Math.Round((double)(sourceCreationSize - sourceDeletionSize) / (1024 * 1024)); _spaceNeededInDestination = (int)Math.Round((double)(destCreationSize - destDeletionSize) / (1024 * 1024)); }
private void Shift(int turn, PlayerAction actionToInsert) { if (turn > ActionsList.Count) { return; } if (IsPerformingAdvancedSpecialOps(turn)) { return; } var endTurn = turn; while (endTurn < ActionsList.Count && GetActionForTurn(endTurn).FirstActionSegment.SegmentType.HasValue) { endTurn++; } ActionsList.Insert(turn - 1, new PlayerAction(actionToInsert?.FirstActionSegment.SegmentType, actionToInsert?.SecondActionSegment.SegmentType, actionToInsert?.BonusActionSegment.SegmentType)); ActionsList.RemoveAt(endTurn); }
/// <summary> /// Adds list of actions for Redo and Undo operations. Do not reverse before passing. /// </summary> public void AddActionsList(List <Action> redoActions, List <Action> undoActions) { void RedoActions() { foreach (var action in redoActions) { action(); } } undoActions.Reverse(); void UndoActions() { foreach (var action in undoActions) { action(); } } ActionsList.Add(new ActionsPair(UndoActions, RedoActions)); ActionsListIndex = ActionsList.Count - 1; }
public ActiveAreaActionsComponent(Rect rect, GUIContent content, GUIStyle style, params GUILayoutOption[] options) : base(rect, content, style, options) { actionsList = ScriptableObject.CreateInstance <ActionsList>(); }
/// <summary> /// Indicates if the menu has any action to display /// </summary> public bool HasAnyVisibleAction() { return(ActionsList.Any(action => action.IsVisible())); }
public void ResetSelection() { ActionsList.ClearSelection(); }
public ItemsWindowActions(Rect aStartPos, GUIContent aContent, GUIStyle aStyle, params GUILayoutOption[] aOptions) : base(aStartPos, aContent, aStyle, aOptions) { actionsList = ScriptableObject.CreateInstance <ActionsList>(); }
private void CreateActions(List <HeaderAction> actions, Control parent, int level, bool useTable, bool renderAsContextMenu) { int actionsCount = actions.Count; if (useTable) { parent.Controls.Add(new LiteralControl("<table cellpadding=\"0\" cellspacing=\"0\" class=\"_nodivs\"><tr>")); } // Sort actions by index to be sure the order is ensured for multiple actions if (actionsCount > 1) { // At least one action has index if (ActionsList.Exists(a => (a.Index != -1))) { // Sort the actions ActionsList.Sort((a1, a2) => a1.Index.CompareTo(a2.Index)); } } // Generate the actions for (int i = 0; i < actionsCount; ++i) { var action = actions[i]; // If the text is not specified or visibility is false, skip the action FormSubmitButton formButton = action.BaseButton as FormSubmitButton; if (!action.IsVisible() || ((action.BaseButton != null) && (!action.BaseButton.Visible || ((formButton != null) && !formButton.RegisterHeaderAction)))) { // Skip empty action action.Visible = false; continue; } // Set live site flag for resource strings action.IsLiveSite = IsLiveSite; // Start tag of the table if more then one action is defined if (useTable) { if (action.GenerateSeparatorBeforeAction && (i > 0)) { parent.Controls.Add(new LiteralControl("<td class=\"PadSeparator\"><span></span></td>")); } parent.Controls.Add(new LiteralControl("<td>")); } // Context menu container ContextMenuContainer container = null; bool enabled = Enabled && action.Enabled; bool renderCtxMenu = (action.AlternativeActions.Count > 0); if (renderCtxMenu) { container = new ContextMenuContainer { ID = "menuCont" + i, MenuID = ClientID + "m_" + level + i, ParentElementClientID = ClientID, RenderAsTag = HtmlTextWriterTag.Div, MouseButton = MouseButtonEnum.Both, OffsetY = 1, VerticalPosition = VerticalPositionEnum.Bottom, HorizontalPosition = HorizontalPositionEnum.Left, CssClass = "CtxContainer", Enabled = enabled, IsLiveSite = IsLiveSite }; if (action.Inactive) { parent.Controls.Add(container); } } // Get the action parameters string ctrlId = ID + "_HA_" + level + i; string cssClass = !string.IsNullOrEmpty(action.CssClass) ? action.CssClass : LinkCssClass; string commandName = !string.IsNullOrEmpty(action.CommandName) ? action.CommandName : action.EventName; string url = ResolveUrl(action.RedirectUrl); // Add HyperLink HyperLink link = new HyperLink(); link.ID = ctrlId; link.ToolTip = action.Tooltip; link.CssClass = enabled ? cssClass : (cssClass + "Disabled"); link.Enabled = enabled; link.Text = action.Text; // Add control to the panel AddControlToPanel(link, (action.Inactive && (container != null)) ? container : parent, renderAsContextMenu); if (enabled && !action.Inactive) { // Perform post-back if (!String.IsNullOrEmpty(commandName)) { string script = null; // Register encapsulation function if (!string.IsNullOrEmpty(action.OnClientClick)) { link.Attributes.Add("onclick", action.OnClientClick); if (action.RegisterShortcutScript) { script = "if(!PerfAction_" + ctrlId + "()) { return false; }"; string scriptFunction = "function PerfAction_" + ctrlId + "() { " + action.OnClientClick.TrimEnd(';') + "; return true; }"; ScriptHelper.RegisterStartupScript(Page, typeof(string), "PerfAction_" + ctrlId, scriptFunction, true); } } string argument = string.Join(";", new string[] { commandName, action.CommandArgument }); PostBackOptions opt = new PostBackOptions(this, argument) { PerformValidation = true, ValidationGroup = action.ValidationGroup }; string postbackScript = ControlsHelper.GetPostBackEventReference(this, opt, false, !PerformFullPostBack); link.NavigateUrl = "javascript:" + postbackScript; // Register the CRTL+S shortcut if (action.RegisterShortcutScript) { // Store action information for shortcut event validation registration shortcutAction = new HeaderAction() { IsLiveSite = IsLiveSite, CommandArgument = argument, ValidationGroup = action.ValidationGroup }; // Prepare action script string actionScript = script + " " + postbackScript + ";"; // SaveObject function will simply simulate clicking the control string scriptSave = string.Format(@"function SaveObject() {{ {0} }}", actionScript); ScriptHelper.RegisterShortcuts(Page); ScriptHelper.RegisterStartupScript(Page, typeof(string), ScriptHelper.SAVE_DOCUMENT_SCRIPT_KEY, scriptSave, true); } } else { link.Attributes.Add("onclick", action.OnClientClick); // Use URL only for standard link if (!String.IsNullOrEmpty(action.RedirectUrl)) { link.NavigateUrl = url; link.Target = action.Target; } // Register the CRTL+S shortcut for empty command name if (action.RegisterShortcutScript) { // SaveObject function will simply simulate clicking the control string scriptSave = string.Format(@"function SaveObject() {{ {0} }}", action.OnClientClick); ScriptHelper.RegisterShortcuts(Page); ScriptHelper.RegisterStartupScript(Page, typeof(string), ScriptHelper.SAVE_DOCUMENT_SCRIPT_KEY, scriptSave, true); } } } // Create image if URL is not empty Image img = null; string imageUrl = (UseSmallIcons && !string.IsNullOrEmpty(action.SmallImageUrl)) ? action.SmallImageUrl : action.ImageUrl; if (!string.IsNullOrEmpty(imageUrl)) { if (action.UseImageButton) { ImageButton imgButton = new ImageButton(); if (!action.Inactive && enabled) { imgButton.PostBackUrl = url; } img = imgButton; } else { img = new Image(); } // Set common properties img.ID = ID + "_HAI_" + level + i; img.ImageUrl = imageUrl; img.ToolTip = action.Tooltip; img.AlternateText = action.Text; img.CssClass = IconCssClass; img.Enabled = enabled; } // Add controls to the panel if (img != null) { link.Controls.Add(img); } if (!string.IsNullOrEmpty(action.Text)) { link.Controls.Add(new Label { Text = action.Text, CssClass = "Text" }); } // Alternative actions if (renderCtxMenu) { if (!action.Inactive) { container.RenderAsTag = HtmlTextWriterTag.Span; container.OffsetX = -1; parent.Controls.Add(container); container.Controls.Add(new LiteralControl("<span class=\"SepContextButton\"><span class=\"Arrow\"></span></span>")); } else { link.Controls.Add(new LiteralControl("<span class=\"ContextButton\"><span class=\"Arrow\"></span></span>")); } // Context menu ContextMenu menu = new ContextMenu(); container.MenuControl = menu; container.InitializeMenuControl(menu); if (!String.IsNullOrEmpty(ContextMenuCssClass)) { menu.OuterCssClass = this.ContextMenuCssClass; } menu.CssClass = "PortalContextMenu CMSEditMenu"; CreateActions(action.AlternativeActions, menu, i, false, true); } // Do not insert padding for last item if (i < actionsCount - 1) { parent.Controls.Add(new LiteralControl("<span class=\"Pad\"></span>")); } // Add free separator cell in table if it's not the last action if (useTable) { parent.Controls.Add(new LiteralControl(((i < actionsCount - 1) && RenderSeparator ? "</td><td style=\"width:" + SeparatorWidth + "px; \" />" : "</td>"))); } } // End tag of the table if (useTable) { parent.Controls.Add(new LiteralControl("</tr></table>")); } }
public void AddAction(Action action, Action reversed) { ActionsList.Add(new ActionsPair(action, reversed)); ActionsListIndex = ActionsList.Count - 1; }
private void Work() { IsNoActionRunning = false; try { #region Checks //Check whether file id is int if (!int.TryParse(ChosenFileId, out int FileId)) { IsCompleted = false; StateText = "Wrong File id!"; return; } //Check whether file id is correct if ((FileId >= FilesLoaded.Count()) || (FileId < 0)) { IsCompleted = false; StateText = "Wrong File id!"; return; } if (string.IsNullOrEmpty(ChosenAction)) { return; } string FilePath = string.Empty; //Load file path foreach (var item in FilesLoaded) { if (item.Id == FileId) { FilePath = item.FileRealName; break; } } //if file id points to empty record if (string.IsNullOrWhiteSpace(FilePath)) { IsCompleted = false; StateText = "File id is wrong."; return; } // if file was deleted after loading if (!File.Exists(FilePath)) { IsCompleted = false; StateText = "File doesnt exist."; return; } #endregion var AlphabetInCiphers = string.Empty; //Get chosen Alphabet if (ChosenAlphabet == AlphabetNamesList[0]) { AlphabetInCiphers = ResourceStrings.EngCapital; } else if (ChosenAlphabet == AlphabetNamesList[1]) { AlphabetInCiphers = ResourceStrings.RuCapital; } var ChosenCipherType = new SimpleCiphers(); //Find Chosen Algorithm for (int i = 0; i < CiphersList.Count(); ++i) { if (CiphersList[i] == ChosenCipher) { ChosenCipherType = (SimpleCiphers)i; } } var Algorithm = new SimpleCipheringAlgorithmFactory().NewAlgorithm(ChosenCipherType); Algorithm.Initialize(KeyValue, AlphabetInCiphers); var chosenActionType = new Operations(); for (int i = 0; i < ActionsList.Count(); ++i) { if (ActionsList[i] == ChosenAction) { chosenActionType = (Operations)i; } } var TextToWorkWith = File.ReadAllText(FilePath).ToUpper(); TextToWorkWith = GetFixedString(ref TextToWorkWith, AlphabetInCiphers, chosenActionType); //Encrypt if (chosenActionType == Operations.Encrypt) { ReturnedText = Algorithm.Encrypt(TextToWorkWith); File.WriteAllText(FilePath.Insert(FilePath.IndexOf("."), "Encrypted"), ReturnedText); StateText = "Successfully created text file " + Path.GetFileName(FilePath); } else//Decipher { ReturnedText = Algorithm.Decipher(TextToWorkWith); File.WriteAllText(FilePath.Insert(FilePath.IndexOf("."), "Decrypted"), ReturnedText); StateText = "Successfully created text file " + Path.GetFileName(FilePath); } IsCompleted = true; } catch (ArgumentException ex) { StateText = ex.Message; IsCompleted = false; } finally { IsNoActionRunning = true; } }
public void PadPlayerActions(int numberOfTurns) { var extraNullActions = Enumerable.Repeat(PlayerActionFactory.CreateEmptyAction(), numberOfTurns - ActionsList.Count); ActionsList.AddRange(extraNullActions); }
private void InitAppMenu() { MainMenuStrip.Items.AddRange(new[] { new MenuButton("&File") { DropDownItems = { new MenuButton("&New Solution", null, (s, a) => New()), new ToolStripSeparator(), new MenuButton("&Open Solution...", Icons.Icon_FileOpenFolder, (s, a) => Open(), Keys.Control | Keys.Shift | Keys.O) { }, new MenuButton("&Save Solution", Icons.Icon_FileSave, (s, a) => Save(ContextManager.File.FileName), Keys.Control | Keys.Shift | Keys.S) { }, new MenuButton("&Save Solution As...", Icons.Icon_FileSave, (s, a) => Save(null)) { }, new ToolStripSeparator(), new MenuButton("&Open Script...", Icons.Icon_FileOpen, (s, a) => OpenScript(), Keys.Control | Keys.O) { }, new ToolStripSeparator(), new MenuButton("&New Browser", null, (s, a) => new BrowserDocument(this), Keys.Control | Keys.N) { }, new ToolStripSeparator(), new MenuButton("&Save Data...", Icons.Icon_FileSaveAll, (s, a) => Core.DataUtils.Save(ContextManager.DataSet,ContextManager.File.OutputPath,null, this), Keys.Control | Keys.E) { }, new ToolStripSeparator(), new MenuButton("&Exit", null, (s, a) => Close(), Keys.Alt | Keys.F4), } }, new MenuButton("&Edit") { DropDownItems = { CreateNewActionMenu(new MenuButton("Add &Action", Icons.Icon_ActionAdd)), new MenuButton("&Remove Action", Icons.Icon_ActionRemove,(s, a) => ActionsList.RemoveSelected()), new ToolStripSeparator(), new MenuButton("Cu&t", Icons.Icon_EditCut, (s, a) => ForwardClipboardEvent(Keys.Control | Keys.X),Keys.Control | Keys.X), new MenuButton("&Copy", Icons.Icon_EditCopy, (s, a) => ForwardClipboardEvent(Keys.Control | Keys.C),Keys.Control | Keys.C), new MenuButton("&Paste", Icons.Icon_EditPaste, (s, a) => ForwardClipboardEvent(Keys.Control | Keys.V),Keys.Control | Keys.V), } }, new MenuButton("&View") { DropDownItems = { new MenuButton("Show &Actions", null, (s, a) => RightContainer.Visible = (s as ToolStripMenuItem).Checked) { CheckOnClick = true, CheckState = CheckState.Checked }, new MenuButton("&Show Log", null, (s, a) => LogAndData.Visible = (s as ToolStripMenuItem).Checked) { CheckOnClick = true, CheckState = CheckState.Checked }, new ToolStripSeparator(), new MenuButton("Clear &Log", null, (s, a) => LogAndData.LogTextBox.Clear()), new ToolStripSeparator(), new MenuButton("Refre&sh Data", null, (s, a) => LogAndData.RefreshDataTables()), new MenuButton("Clear &Data", null, (s, a) => ContextManager.ClearData()), }, }, new MenuButton("&Execute") { DropDownItems = { new MenuButton("Break A&ll", Icons.Icon_Break, (s, a) => ContextManager.BreakAll(), Keys.Control | Keys.Shift | Keys.Pause), new MenuButton("C&ontinue All", Icons.Icon_Step, (s, a) => ContextManager.ContinueAll()), new MenuButton("Stop &All", Icons.Icon_Step, (s, a) => ContextManager.StopAll()), } }, MainMenuStrip.MdiWindowListItem = MainMenuStrip.MdiWindowListItem = new MenuButton("&Window") { DropDownItems = { new MenuButton("&Cascade", null, (s, a) => LayoutMdi(MdiLayout.Cascade)), new MenuButton("&Tile Horizontaly", null, (s, a) => LayoutMdi(MdiLayout.TileHorizontal)), new MenuButton("&Tile Verticaly", null, (s, a) => LayoutMdi(MdiLayout.TileVertical)), new MenuButton("&Arrange Icons", null, (s, a) => LayoutMdi(MdiLayout.ArrangeIcons)), new ToolStripSeparator(), new MenuButton("Close All &Windows", null, (s, a) => CloseAllDocuments()), } }, new MenuButton("&Help") { DropDownItems = { new MenuButton("&About...", null, (s, a) => ShowAbout()) } } }); }
public TestModule() : base("Test Module") { ActionsList.Add(new TestAction1()); ActionCount = ActionsList.Count; }