public IExecutable ManageCommand(string[] inputArgs) { IExecutable command = null; string commandType = inputArgs[0]; switch (commandType) { case "create": command = new CreateCommand(this.Engine, inputArgs[1], int.Parse(inputArgs[2]), int.Parse(inputArgs[3]), (BehaviorTypes)Enum.Parse(typeof(BehaviorTypes), inputArgs[4]), (AttackTypes)Enum.Parse(typeof(AttackTypes), inputArgs[5])); break; case "attack": command = new AttackCommand(this.Engine, inputArgs[1], inputArgs[2]); break; case "pass": command = new PassCommand(); break; case "status": command = new StatusCommand(this.Engine); break; case "drop": command = new DropCommand(); break; } return command; }
private void HandleDropCommand(DropCommand dropCommand) { GetComponent <Rigidbody>().isKinematic = false; GetComponent <Rigidbody>().AddForce(new Vector3(UnityEngine.Random.value * dropCommand.Force * 0.1f, UnityEngine.Random.value * dropCommand.Force, UnityEngine.Random.value * dropCommand.Force * 0.1f)); }
public IExecutable ManageCommand(string[] inputArgs) { IExecutable command = null; string commandType = inputArgs[0]; switch (commandType) { case "create": command = new CreateCommand(this.Engine, inputArgs[1], int.Parse(inputArgs[2]), int.Parse(inputArgs[3]), (BehaviorTypes)Enum.Parse(typeof(BehaviorTypes), inputArgs[4]), (AttackTypes)Enum.Parse(typeof(AttackTypes), inputArgs[5])); break; case "attack": command = new AttackCommand(this.Engine, inputArgs[1], inputArgs[2]); break; case "pass": command = new PassCommand(); break; case "status": command = new StatusCommand(this.Engine); break; case "drop": command = new DropCommand(); break; } return(command); }
private void HACK_Control_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { DropLinkEventArgs args = null; if (PotentialLinkSource != null) { object target = PotentialLinkTarget != null ? PotentialLinkTarget.Vertex : null; object edge = LinkBeingMoved != null ? LinkBeingMoved.Edge : null; args = new DropLinkEventArgs(PotentialLinkSource.Vertex, target, edge); LinkBeingMoved = null; } if (args != null && DropCommand.CanExecute(args)) { /// checking if Target is different HACK_NODE is related to hard to reproduce error /// somehow when you drag a link quickly to the existing node, but you don't really reach it or you are too far from node, then the target appears to be HACK_NODE if (args.Target == null || (args.Target != null && args.Target.ToString().Equals("HACK_Node") == false)) { DropCommand.Execute(args); } } CancelAllDragging(); }
public SchedulerModel() { ControlDropCommand = new DropCommand(Command_OnDrop); SettingsProvider provider = new SettingsProvider(); provider.SettingsLoaded += OnSettingsLoaded; provider.RequestSettings(""); }
void IDropTarget.Drop(IDropInfo dropInfo) { try { if (m_lastDragedOverElement != null) { m_lastDragedOverElement.Opacity = 1; } if (DropCommand != null) { DropCommand.Execute(new Tuple <object, object>(dropInfo.Data, dropInfo.TargetItem)); } if (ItemContainerGenerator.ContainerFromItem(dropInfo.Data) is LuiAccordionItem sourceContainer) { if (ItemContainerGenerator.ContainerFromItem(dropInfo.TargetItem) is LuiAccordionItem targetContainer) { DropItem(sourceContainer, targetContainer); } } } catch (Exception ex) { logger.Error(ex); } }
private void HandleDropCommand(DropCommand dropCommand) { GetComponent<Rigidbody>().isKinematic = false; GetComponent<Rigidbody>().AddForce(new Vector3(UnityEngine.Random.value * dropCommand.Force * 0.1f, UnityEngine.Random.value * dropCommand.Force, UnityEngine.Random.value * dropCommand.Force * 0.1f)); }
protected override void OnAttached() { base.OnAttached(); AssociatedObject.AllowDrop = true; AssociatedObject.DragOver += (s, e) => { if ((DropCommand?.CanExecute(DragDropManager.DragData)).GetValueOrDefault()) { e.Effects = DragDropEffects.Move; } else { e.Effects = DragDropEffects.None; } e.Handled = true; }; AssociatedObject.Drop += (s, e) => { if ((DropCommand?.CanExecute(DragDropManager.DragData)).GetValueOrDefault()) { DropCommand?.Execute(GetConvertedData(DragDropManager.DragData)); } e.Handled = true; }; }
public void Execute(DropCommand command) { foreach (var item in CopiedNodes) { item.FilterId = WorkspaceService.CurrentWorkspace.CurrentGraph.CurrentFilter.Identifier; } }
private void ExecuteDropCommandIfAvailable(IDataObject data) { if (DropCommand != null) { var sourceObject = GetObjectFromData(data); DropCommand.Execute(sourceObject); } }
public static DropCommand Drop(this Selector selector) { var dropCommand = new DropCommand(selector.Client) { ParentSelector = selector }; return(dropCommand); }
private bool IsValidDropTarget(IDataObject dataObject) { if (DropCommand == null) { return(false); } return(DropCommand.CanExecute(GetObjectFromData(dataObject))); }
public async Task SendDrop(DropEventArgs args) { if (!AllowDrop) { return; } DropCommand?.Execute(DropCommandParameter); Drop?.Invoke(this, args); if (!args.Handled) { var dataView = args.Data; var internalProperties = dataView.PropertiesInternal; IView dragSource = null; ImageSource sourceTarget = await dataView.GetImageAsync(); string text = await dataView.GetTextAsync(); if (internalProperties.ContainsKey("DragSource")) { dragSource = (IView)internalProperties["DragSource"]; if (sourceTarget == null && dragSource is IImageElement imageElement) { sourceTarget = imageElement.Source; } if (String.IsNullOrWhiteSpace(text)) { text = dragSource.GetStringValue(); } } if (Parent is IImageElement && sourceTarget == null) { sourceTarget = text; } if (Parent is Image image) { image.Source = sourceTarget; } else if (Parent is ImageButton ib) { ib.Source = sourceTarget; } else if (Parent is Button b) { b.ImageSource = sourceTarget; } Parent?.TrySetValue(text); } }
private void OnDrop(object sender, DragEventArgs e) { System.Diagnostics.Debug.WriteLine("DropBehavior.OnDrop"); // ドロップ風 if (DropCommand != null) { var data = e.Data.GetData(DataType?.ToString() ?? "test"); DropCommand.Execute(data); e.Handled = true; } }
private void MultiSelectDataGrid_Drop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.StringFormat) && DropCommand != null && DropCommand.CanExecute(e.Data.GetData(DataFormats.StringFormat))) { DropCommand.Execute(e.Data.GetData(DataFormats.StringFormat)); } if (DropDataCommand != null && DropDataCommand.CanExecute(e.Data)) { DropDataCommand.Execute(e.Data); } }
private void AssociatedObject_PreviewDrop(object sender, DragEventArgs e) { if (e.AllowedEffects == DragDropEffects.None) { e.Handled = true; return; } if (DropCommand != null) { DropCommand.Execute(e.Data.GetData(DragID)); } e.Handled = true; }
private void OnDrop(object sender, DragEventArgs e) { if (overedItem != null) { overedItem.BorderBrush = originalBorderBrush; overedItem.BorderThickness = originalBorderThickness; } var sourceData = e.Data.GetData(e.Data.GetFormats()[0]); var targetData = (sender as FrameworkElement).DataContext; if (DropCommand != null && (DropOnSelf || sourceData != targetData) && (CanDropPredicate == null || CanDropPredicate(sender as T))) { DropCommand.Execute(new Tuple <object, object>(sourceData, targetData)); } draggedItem = null; e.Handled = true; }
void HACK_Control_PreviewMouseMove(object sender, MouseEventArgs e) { Point clickPoint = e.GetPosition(GraphLayout); DependencyObject obj = (DependencyObject)GraphLayout.InputHitTest(clickPoint); GraphSharp.Controls.VertexControl parent = null; if (obj != null) { parent = obj.GetParent <GraphSharp.Controls.VertexControl>(this); } if (parent != null && parent != PotentialLinkSource && DropCommand.CanExecute(new DropLinkEventArgs(PotentialLinkSource.Vertex, parent.Vertex, null))) { PotentialLinkTarget = parent; } else { PotentialLinkTarget = null; } }
public void DropCommandTest() { Cell cell = new Cell(new Vector2Int(0, 0)); Entity actor = new Entity(new Inventory(1)) { Name = "TEST_ENTITY" }; actor.Move(null, cell); Entity item = new Entity { Name = "TEST_ITEM" }; item.Move(null, cell); actor.GetComponent <Inventory>().AddItem(item); DropCommand cmd = new DropCommand(actor); CommandResult result = cmd.Execute(); Assert.True(cell.HasItem(item)); Assert.True(result == CommandResult.Succeeded); }
void IDropable.Drop(object data, DropLocation location) { var droppedElement = data as NodeItem; if (droppedElement == null) { return; } var arg = new NodeDropRequest { DroppedNode = droppedElement.State.DataContext, DropTarget = Root, Location = location }; if (DropCommand != null && DropCommand.CanExecute(arg)) { DropCommand.Execute(arg); } }
private void TryParseDropCommand(SparqlUpdateParserContext context) { bool silent = false; //May possibly have a SILENT Keyword IToken next = context.Tokens.Dequeue(); if (next.TokenType == Token.SILENT) { silent = true; next = context.Tokens.Dequeue(); } //Then expect a GRAPH followed by a URI or one of the DEFAULT/NAMED/ALL keywords if (next.TokenType == Token.GRAPH) { Uri u = this.TryParseGraphRef(context); DropCommand cmd = new DropCommand(u, ClearMode.Graph, silent); context.CommandSet.AddCommand(cmd); } else if (next.TokenType == Token.DEFAULT) { context.CommandSet.AddCommand(new DropCommand(ClearMode.Default, silent)); } else if (next.TokenType == Token.NAMED) { context.CommandSet.AddCommand(new DropCommand(ClearMode.Named, silent)); } else if (next.TokenType == Token.ALLWORD) { context.CommandSet.AddCommand(new DropCommand(ClearMode.All, silent)); } else { throw ParserHelper.Error("Unexpected Token '" + next.GetType().ToString() + "' encountered, expected a GRAPH <URI> to specify the Graph to DROP or one of the DEFAULT/NAMED/ALL keywords", next); } }
// TODO handle the defaultGraph case internal static INode ToSpinRdf(this SparqlUpdateCommand query, IGraph g) { INode root = g.CreateBlankNode(); SpinVariableTable varTable = new SpinVariableTable(g); switch (query.CommandType) { case SparqlUpdateCommandType.Add: g.Assert(root, RDF.PropertyType, SP.ClassAdd); AddCommand add = (AddCommand)query; if (add.SourceUri == null) { g.Assert(root, SP.PropertyGraphIRI, SP.PropertyDefault); } else { g.Assert(root, SP.PropertyGraphIRI, RDFUtil.CreateUriNode(add.SourceUri)); } if (add.DestinationUri == null) { g.Assert(root, SP.PropertyInto, SP.PropertyDefault); } else { g.Assert(root, SP.PropertyInto, RDFUtil.CreateUriNode(add.DestinationUri)); } break; case SparqlUpdateCommandType.Clear: g.Assert(root, RDF.PropertyType, SP.ClassClear); if (((ClearCommand)query).TargetUri == null) { g.Assert(root, SP.PropertyGraphIRI, SP.PropertyDefault); } else { g.Assert(root, SP.PropertyGraphIRI, RDFUtil.CreateUriNode(((ClearCommand)query).TargetUri)); } break; case SparqlUpdateCommandType.Copy: g.Assert(root, RDF.PropertyType, SP.ClassCopy); CopyCommand copy = (CopyCommand)query; if (copy.SourceUri == null) { g.Assert(root, SP.PropertyGraphIRI, SP.PropertyDefault); } else { g.Assert(root, SP.PropertyGraphIRI, RDFUtil.CreateUriNode(copy.SourceUri)); } if (copy.DestinationUri == null) { g.Assert(root, SP.PropertyInto, SP.PropertyDefault); } else { g.Assert(root, SP.PropertyInto, RDFUtil.CreateUriNode(copy.DestinationUri)); } break; case SparqlUpdateCommandType.Create: g.Assert(root, RDF.PropertyType, SP.ClassCreate); CreateCommand create = (CreateCommand)query; if (create.TargetUri == null) { g.Assert(root, SP.PropertyGraphIRI, SP.PropertyDefault); } else { g.Assert(root, SP.PropertyGraphIRI, RDFUtil.CreateUriNode(create.TargetUri)); } break; case SparqlUpdateCommandType.Delete: g.Assert(root, RDF.PropertyType, SP.ClassModify); DeleteCommand delete = (DeleteCommand)query; if (delete.GraphUri != null) { g.Assert(root, SP.PropertyWith, RDFUtil.CreateUriNode(delete.GraphUri)); } // TODO handle the usings g.Assert(root, SP.PropertyDeletePattern, delete.DeletePattern.ToSpinRdf(g, varTable)); g.Assert(root, SP.PropertyWhere, delete.WherePattern.ToSpinRdf(g, varTable)); break; case SparqlUpdateCommandType.DeleteData: g.Assert(root, RDF.PropertyType, SP.ClassDeleteData); g.Assert(root, SP.PropertyData, ((DeleteDataCommand)query).DataPattern.ToSpinRdf(g, varTable)); break; case SparqlUpdateCommandType.Drop: g.Assert(root, RDF.PropertyType, SP.ClassDrop); DropCommand drop = (DropCommand)query; if (drop.TargetUri == null) { g.Assert(root, SP.PropertyGraphIRI, SP.PropertyDefault); } else { g.Assert(root, SP.PropertyGraphIRI, RDFUtil.CreateUriNode(drop.TargetUri)); } g.Assert(root, SP.PropertyGraphIRI, RDFUtil.CreateUriNode(((DropCommand)query).TargetUri)); break; case SparqlUpdateCommandType.Insert: g.Assert(root, RDF.PropertyType, SP.ClassModify); InsertCommand insert = (InsertCommand)query; if (insert.GraphUri != null) { g.Assert(root, SP.PropertyWith, RDFUtil.CreateUriNode(insert.GraphUri)); } g.Assert(root, SP.PropertyInsertPattern, insert.InsertPattern.ToSpinRdf(g, varTable)); g.Assert(root, SP.PropertyWhere, insert.WherePattern.ToSpinRdf(g, varTable)); break; case SparqlUpdateCommandType.InsertData: g.Assert(root, RDF.PropertyType, SP.ClassInsertData); g.Assert(root, SP.PropertyData, ((InsertDataCommand)query).DataPattern.ToSpinRdf(g, varTable)); break; case SparqlUpdateCommandType.Load: g.Assert(root, RDF.PropertyType, SP.ClassLoad); LoadCommand load = (LoadCommand)query; if (load.SourceUri == null) { g.Assert(root, SP.PropertyGraphIRI, SP.PropertyDefault); } else { g.Assert(root, SP.PropertyGraphIRI, RDFUtil.CreateUriNode(load.SourceUri)); } if (load.TargetUri == null) { g.Assert(root, SP.PropertyInto, SP.PropertyDefault); } else { g.Assert(root, SP.PropertyInto, RDFUtil.CreateUriNode(load.TargetUri)); } break; case SparqlUpdateCommandType.Modify: g.Assert(root, RDF.PropertyType, SP.ClassModify); ModifyCommand modify = (ModifyCommand)query; if (modify.GraphUri != null) { g.Assert(root, SP.PropertyWith, RDFUtil.CreateUriNode(modify.GraphUri)); } if (modify.DeletePattern != null) { g.Assert(root, SP.PropertyDeletePattern, modify.DeletePattern.ToSpinRdf(g, varTable)); } if (modify.InsertPattern != null) { g.Assert(root, SP.PropertyInsertPattern, modify.InsertPattern.ToSpinRdf(g, varTable)); } g.Assert(root, SP.PropertyWhere, modify.WherePattern.ToSpinRdf(g, varTable)); break; case SparqlUpdateCommandType.Move: g.Assert(root, RDF.PropertyType, SP.ClassMove); MoveCommand move = (MoveCommand)query; if (move.SourceUri == null) { g.Assert(root, SP.PropertyGraphIRI, SP.PropertyDefault); } else { g.Assert(root, SP.PropertyGraphIRI, RDFUtil.CreateUriNode(move.SourceUri)); } if (move.DestinationUri == null) { g.Assert(root, SP.PropertyInto, SP.PropertyDefault); } else { g.Assert(root, SP.PropertyInto, RDFUtil.CreateUriNode(move.DestinationUri)); } break; case SparqlUpdateCommandType.Unknown: throw new NotSupportedException("Unkown SPARQL update query encountered " + query.ToString()); } return(root); }
/// <summary> /// Processes a DROP command /// </summary> /// <param name="cmd">Drop Command</param> public void ProcessDropCommand(DropCommand cmd) { this.ProcessCommand(cmd); }
public void SparqlUpdateCreateDrop() { TripleStore store = new TripleStore(); Console.WriteLine("Store has " + store.Graphs.Count + " Graphs"); //Create a couple of Graphs using Create Commands CreateCommand create1 = new CreateCommand(new Uri("http://example.org/1")); CreateCommand create2 = new CreateCommand(new Uri("http://example.org/2")); store.ExecuteUpdate(create1); store.ExecuteUpdate(create2); Assert.Equal(3, store.Graphs.Count); Assert.Empty(store.Triples); //Trying the same Create again should cause an error try { store.ExecuteUpdate(create1); Assert.True(false, "Executing a CREATE command twice without the SILENT modifier should error"); } catch (SparqlUpdateException) { Console.WriteLine("Executing a CREATE command twice without the SILENT modifier errored as expected"); } //Equivalent Create with SILENT should not error CreateCommand create3 = new CreateCommand(new Uri("http://example.org/1"), true); try { store.ExecuteUpdate(create3); Console.WriteLine("Executing a CREATE for an existing Graph with the SILENT modifier suppressed the error as expected"); } catch (SparqlUpdateException) { Assert.True(false, "Executing a CREATE for an existing Graph with the SILENT modifier should not error"); } DropCommand drop1 = new DropCommand(new Uri("http://example.org/1")); store.ExecuteUpdate(drop1); Assert.Equal(2, store.Graphs.Count); try { store.ExecuteUpdate(drop1); Assert.True(false, "Trying to DROP a non-existent Graph should error"); } catch (SparqlUpdateException) { Console.WriteLine("Trying to DROP a non-existent Graph produced an error as expected"); } DropCommand drop2 = new DropCommand(new Uri("http://example.org/1"), ClearMode.Graph, true); try { store.ExecuteUpdate(drop2); Console.WriteLine("Trying to DROP a non-existent Graph with the SILENT modifier suppressed the error as expected"); } catch (SparqlUpdateException) { Assert.True(false, "Trying to DROP a non-existent Graph with the SILENT modifier should suppress the error"); } }
private void RegisterCommands() { BlinkGoBackButtonCommand = new DelegateCommand(() => { GoPreviousImage(); }); BlinkGoNextButtonCommand = new DelegateCommand(() => { GoNextImage(); }); BuildBookContextMenuCommand = new DelegateCommand <ContextMenuEventArgs>(args => { BuildContextMenus_Books(); (args.Source as FrameworkElement).ContextMenu.IsOpen = true; }); BuildContentsContextMenuCommand = new DelegateCommand <ContextMenuEventArgs>(args => { BuildContextMenus_Contents(); (args.Source as FrameworkElement).ContextMenu.IsOpen = true; }); ChangeStarCommand = new DelegateCommand <ObservableCollection <BookViewModel> >(args => { IDialogResult result = new DialogResult(); IDialogParameters parameters = new DialogParameters(); parameters.Add("Book", args.First()); dialogService.ShowDialog(nameof(ChangeStar), parameters, ret => result = ret); UpdateStarLevel(); }); CloseTabCommand = new DelegateCommand(() => { MainWindowViewModel.Value.CloseTab(this); }); CloseSearchPaneCommand = new DelegateCommand(() => { CloseSearchPane(); }); DropCommand.Subscribe(args => { foreach (var dropPlugin in DropPlugins) { dropPlugin.Value.Execute(args.Data); } }) .AddTo(disposables); ExportBooksCommand = new DelegateCommand(() => { var books = BookListViewSelectedItems; OpenExportDialog(books.ToArray()); }); FilterBooksCommand = new DelegateCommand(() => { MainWindowViewModel.Value.NewContentTab(BookListViewSelectedItems); }); LeftKeyDownCommand = new DelegateCommand(() => { if (OpenedPage != null) { GoPreviousImage(); } else if (OpenedBook != null) { //Do nothing } else { //Do nothing } }); MouseWheelCommand = new DelegateCommand <MouseWheelEventArgs>(args => { var delta = args.Delta; if (OpenedPage != null) { if (delta > 0) //奥方向に回転 { GoPreviousImage(); } else if (delta < 0) //手前方向に回転 { GoNextImage(); } } else if (OpenedBook != null) { //Do nothing } else { //Do nothing } }); OpenBookCommand = new DelegateCommand(() => { OpenBook(BookListViewSelectedItems.First()); }); OpenBookInNewTabCommand = new DelegateCommand(() => { MainWindowViewModel.Value.NewContentTab(BookListViewSelectedItems.First()); MainWindowViewModel.Value.ActiveDocumentViewModel.OpenBook(BookListViewSelectedItems.First()); }); OpenBookPropertyDialogCommand = new DelegateCommand(() => { var books = BookListViewSelectedItems; OpenBookPropertyDialog(books.First()); }); OpenImageByDefaultProgramCommand = new DelegateCommand <object>((p) => { OpenImageByDefaultProgram(p as IEnumerable <PageViewModel>); }); OpenSearchPaneCommand = new DelegateCommand(() => { OpenSearchPane(); }); RightKeyDownCommand = new DelegateCommand(() => { if (OpenedPage != null) { GoNextImage(); } else if (OpenedBook != null) { //Do nothing } else { //Do nothing } }); RemakeThumbnailOfBookCommand = new DelegateCommand(async() => { var books = BookListViewSelectedItems; await RemakeThumbnail(books); }); RemakeThumbnailOfPageCommand = new DelegateCommand(async() => { var pages = ContentsListViewSelectedItems; await RemakeThumbnail(pages); }); RemoveBookCommand = new DelegateCommand(async() => { var books = BookListViewSelectedItems; await RemoveBook(books.ToArray()); }); RemovePageCommand = new DelegateCommand <object>(async(p) => { await RemovePage(p as IEnumerable <PageViewModel>); }); SearchInNewTabCommand = new DelegateCommand(() => { MainWindowViewModel.Value.NewSearchTab(BookCabinet.OnStage); }); SendBookToExistTabCommand = new DelegateCommand <IDocumentViewModelBase>(p => { foreach (var item in BookListViewSelectedItems) { p.BookCabinet.AddToMemory(item); } }); SendBookToNewTabCommand = new DelegateCommand(() => { MainWindowViewModel.Value.NewContentTab(BookListViewSelectedItems); }); ScrapPagesCommand = new DelegateCommand <object>(async(p) => { await ScrapPages(p as IEnumerable <PageViewModel>); }); XButton1MouseButtonDownCommand = new DelegateCommand(() => { if (OpenedPage != null) { CloseImage(); } else if (OpenedBook != null) { CloseBook(); } else { if (BookCabinet.IsSearching) { ClearSearchResult(); CloseSearchPane(); RestoreScrollOffset(BeforeSearchPosition); } } }); XButton2MouseButtonDownCommand = new DelegateCommand(() => { if (OpenedPage != null) { //Do nothing } else if (OpenedBook != null) { //Do nothing } else { //Do nothing } }); }
/// <summary> /// Processes a DROP command. /// </summary> /// <param name="cmd">Drop Command.</param> /// <param name="context">SPARQL Update Evaluation Context.</param> protected virtual void ProcessDropCommandInternal(DropCommand cmd, SparqlUpdateEvaluationContext context) { cmd.Evaluate(context); }
/// <summary> /// Processes a DROP command. /// </summary> /// <param name="cmd">Drop Command.</param> public void ProcessDropCommand(DropCommand cmd) { ProcessDropCommandInternal(cmd, GetContext()); }
/// <summary> /// Processes a DROP command /// </summary> /// <param name="cmd">Drop Command</param> public void ProcessDropCommand(DropCommand cmd) { this.ProcessDropCommandInternal(cmd, this.GetContext()); }