/// <summary> /// Checks what operations are available for dragging onto the target with the drag files. /// </summary> /// <param name="dragEventArgs">The <see cref="System.Windows.Forms.DragEventArgs"/> instance containing the event data.</param> protected override void DragEnter(DragEventArgs dragEventArgs) { // Check the drag files - if they're all XML, we can validate them against the XSD. dragEventArgs.Effect = DragItems.All(di => string.Compare(Path.GetExtension(di), ".xml", StringComparison.InvariantCultureIgnoreCase) == 0) ? DragDropEffects.Link : DragDropEffects.None; }
/// <inheritdoc /> protected override DragDropEffect OnDragEnterHeader(DragData data) { if (_dragOverItems == null) { _dragOverItems = new DragItems(ValidateDragItem); } _dragOverItems.OnDragEnter(data); return(GetDragEffect(data)); }
void View_Drop(object sender, DragEventArgs e) { GridView[] DayViews = { FirstDay, SecondDay, ThirdDay }; GridView[] ItemSources = { FirstDay, SecondDay, ThirdDay, AddView, AgendaList }; int index = -1; foreach (GridView Day in DayViews) { //放置的VIEW if (sender.Equals(Day)) { //放置的位置 index = Day.Items.IndexOf(rect); //拖曳的ITEM for (int i = DragItems.Count - 1; i >= 0; i--) { //拖曳的ITEM來源VIEW foreach (GridView ItemSource in ItemSources) { int itemIndex = ItemSource.Items.IndexOf(DragItems.ElementAt(i)); if (itemIndex != -1) { object temp = ItemSource.Items.ElementAt(i); ItemSource.Items.RemoveAt(itemIndex); //Agendas.add() if (index != -1) { Day.Items.Insert(index, CreateItem()); } else { Day.Items.Add(CreateItem()); } } } if (IsAddNewItem) { IsAddNewItem = false; Day.Items.Add(CreateItem()); } } } } foreach (GridView Day in DayViews) { Day.Items.Remove(rect); } rect = null; for (int i = 0; i < DragItems.Count; i++) { //FirstDay.Items.Add(DragItems[i]) //(((Rectangle)sender).Parent as GridView).Items.Insert(,DragItems[i]); } }
protected override void Drop(DragEventArgs dragEventArgs) { new Process { StartInfo = { FileName = this.SelectedItemPath, Verb = "Run", Arguments = DragItems.AsArgumentList() } }.Start(); }
public virtual void EndDrag(bool doCommit) { if (doCommit) { var bounds = DragItems.Select(p => p.Bounds).ToArray(); Controller.UpdateItemsBounds(DragItems, bounds); } else { RestoreBounds(); } DragItems = null; InitialBounds = null; }
/// <inheritdoc /> public override DragDropEffect OnDragEnter(ref Float2 location, DragData data) { base.OnDragEnter(ref location, data); if (_dragOverItems == null) { _dragOverItems = new DragItems(ValidateDragItem); } _dragOverItems.OnDragEnter(data); var result = GetDragEffect(data); _validDragOver = result != DragDropEffect.None; return(result); }
/// <inheritdoc /> public override DragDropEffect OnDragEnter(ref Vector2 location, DragData data) { base.OnDragEnter(ref location, data); // Check if drop file(s) if (data is DragDataFiles) { _validDragOver = true; return(DragDropEffect.Copy); } // Check if drop asset(s) if (_dragOverItems == null) { _dragOverItems = new DragItems(ValidateDragItem); } _dragOverItems.OnDragEnter(data); _validDragOver = _dragOverItems.HasValidDrag; return(_dragOverItems.Effect); }
public virtual void BeginDrag(Point start, DiagramItem item, DragThumbKinds kind) { Start = start; DragKind = kind; if (kind == DragThumbKinds.Center) { if (!item.CanMove || !IsMovable(item)) { return; } if (!View.Selection.Contains(item)) { View.Selection.Set(item); } DragItems = View.Selection.Where(p => p.CanMove && IsMovable(p)).ToArray(); } else { DragItems = new DiagramItem[] { item }; } InitialBounds = DragItems.Select(p => p.Bounds).ToArray(); View.DragAdorner = CreateAdorner(); }
/// <inheritdoc /> protected override void DoDragDrop() { DoDragDrop(DragItems.GetDragData(_folder)); }
protected override void DragEnter(DragEventArgs dragEventArgs) { var supported = DragItems.All(di => supportedImageExtensions.Contains(Path.GetExtension(di).ToLower())); dragEventArgs.Effect = supported ? DragDropEffects.Link : DragDropEffects.None; }
private bool IsDragged(FlowNode node) { return(DragItems.Where(p => p.ModelElement == node).Count() > 0); }
void View_Drop(object sender, DragEventArgs e) { GridView[] DayViews = { FirstDay, SecondDay, ThirdDay, AgendaList }; GridView[] ItemSources = { FirstDay, SecondDay, ThirdDay, AddView, AgendaList }; int index = -1; foreach (GridView Day in DayViews) { //放置的VIEW if (sender.Equals(Day)) { //放置的位置 index = Day.Items.IndexOf(rect); //拖曳的ITEM for (int i = DragItems.Count - 1; i >= 0; i--) { //拖曳的ITEM來源VIEW foreach (GridView ItemSource in ItemSources) { int itemIndex = ItemSource.Items.IndexOf(DragItems.ElementAt(i)); if (itemIndex != -1) { object temp = ItemSource.Items.ElementAt(i); ItemSource.Items.RemoveAt(itemIndex); //Agendas.add() NewAgenda(); /* * if (index != -1) * { * Day.Items.Insert(index, CreateItem()); * } * else * { * Day.Items.Add(CreateItem()); * }*/ } } if (IsAddNewItem) { int dayindex = -1; IsAddNewItem = false; //Day.Items.Add(CreateItem()); for (int j = 0; j < DayViews.Length; j++) { if (Day.Equals(DayViews[j])) { dayindex = j; } } if (dayindex == -1) { } else if (dayindex < 3) { //<<<<<<< HEAD DateTime leftTime = firstDate.AddDays(dayindex); DateTime rightTime = firstDate.AddDays(dayindex); if (index == -1 && Day.Items.Count == 0) { //新增第一筆資料 } //else if (index==0) //{ // //抓右邊 // rightTime = ((Agenda)((Day.Items[1] as GridView).Items[0] as StackPanel).Tag)._startDateTime.Value; // leftTime = ((Agenda)((Day.Items[1] as GridView).Items[0] as StackPanel).Tag)._startDateTime.Value; //} //else if (index == Day.Items.Count - 1 || index == -1 && Day.Items.Count != 0) //{ // //抓左邊 // if (index == -1) // { // index = Day.Items.Count; // } // StackPanel a = (StackPanel)(Day.Items[index - 1] as GridView).Items[0]; // Agenda Iagenda = (Agenda)((Day.Items[index - 1] as GridView).Items[0] as StackPanel).Tag; // rightTime = Iagenda.EndDateTime.Value; // leftTime = Iagenda.EndDateTime.Value; //} //else //{ // //抓兩邊 // rightTime = ((Agenda)((Day.Items[index + 1] as GridView).Items[0] as StackPanel).Tag)._startDateTime.Value; // leftTime = ((Agenda)((Day.Items[index - 1] as GridView).Items[0] as StackPanel).Tag).EndDateTime.Value; //} //if (index == -1 && Day.Items.Count == 0) //{ // App.MyEditAgendaPage.SetStartDate(firstDate.AddDays(dayindex)); // App.MyEditAgendaPage.SetEndDate(firstDate.AddDays(dayindex)); // App.MyEditAgendaPage.SetNewState(); // App.MyEditAgendaPage.SetPreviousPage(App.DailyPage); // Window.Current.Content = App.MyEditAgendaPage; //} App.MyEditAgendaPage.SetStartDate(firstDate.AddDays(dayindex)); App.MyEditAgendaPage.SetEndDate(firstDate.AddDays(dayindex)); App.MyEditAgendaPage.SetNewState(); App.MyEditAgendaPage.SetPreviousPage(App.DailyPage); Window.Current.Content = App.MyEditAgendaPage; //} //else //{ // App.MyEditAgendaPage.SetStartDate(leftTime); // App.MyEditAgendaPage.SetEndDate(rightTime); // App.MyEditAgendaPage.SetNewState(); // App.MyEditAgendaPage.SetPreviousPage(App.DailyPage); // Window.Current.Content = App.MyEditAgendaPage; //} //======= // App.MyEditAgendaPage.SetStartDate(firstDate); // App.MyEditAgendaPage.SetEndDate(firstDate); // App.MyEditAgendaPage.SetNewState(); // App.MyEditAgendaPage.SetPreviousPage(App.DailyPage); // Window.Current.Content = App.MyEditAgendaPage; // } // else if (dayindex == 1) // { // App.MyEditAgendaPage.SetStartDate(firstDate.AddDays(1)); // App.MyEditAgendaPage.SetEndDate(firstDate.AddDays(1)); // App.MyEditAgendaPage.SetNewState(); // App.MyEditAgendaPage.SetPreviousPage(App.DailyPage); // Window.Current.Content = App.MyEditAgendaPage; // } // else if (dayindex == 2) // { // App.MyEditAgendaPage.SetStartDate(firstDate.AddDays(2)); // App.MyEditAgendaPage.SetEndDate(firstDate.AddDays(2)); // App.MyEditAgendaPage.SetNewState(); // App.MyEditAgendaPage.SetPreviousPage(App.DailyPage); // //App.MyEditAgendaPage. // Window.Current.Content = App.MyEditAgendaPage; //>>>>>>> e6102835d3c1c886f6af430444fbd69730937cd3 } else { //新增代辦事項 } } } } } foreach (GridView Day in DayViews) { Day.Items.Remove(rect); } rect = null; }