Ejemplo n.º 1
0
        public void DeleteElement(BaseElement el)
        {
            if ((el == null) || (el is ConnectorElement)) return;
            //Delete link
            if (el is BaseLinkElement)
            {
                var lnk = (BaseLinkElement) el;
                DeleteLink(lnk);
                return;
            }

            //Delete node
            if (el is NodeElement)
            {
                var conn = ((NodeElement) el);
                foreach (var elconn in conn.Connectors)
                {
                    for (var i = elconn.Links.Count - 1; i>=0; i--)
                    {
                        var lnk = (BaseLinkElement) elconn.Links[i];
                        DeleteLink(lnk);
                    }
                }
                    
                if (SelectedNodes.Contains(el))
                    SelectedNodes.Remove(el);
            }

            if (SelectedElements.Contains(el))
                SelectedElements.Remove(el);

            Elements.Remove(el);
                
            OnAppearancePropertyChanged(new EventArgs());
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 删除选中元素
 /// </summary>
 /// <param name="element"></param>
 private void SelectedElementRemove(UIElement element)
 {
     if (SelectedElements.Contains(element))
     {
         SelectedElements.Remove(element);
         ((IControlBase)element).SetUnFocus();
     }
 }
Ejemplo n.º 3
0
        public void SelectElements(Rectangle selectionRectangle)
        {
            SelectedElements.EnabledCalc = false;
            SelectedNodes.EnabledCalc    = false;

            // Add all "hitable" elements
            foreach (BaseElement element in Elements)
            {
                if (!(element is IControllable))
                {
                    continue;
                }
                var ctrl = ((IControllable)element).GetController();
                if (!ctrl.HitTest(selectionRectangle))
                {
                    continue;
                }
                if (!(element is ConnectorElement))
                {
                    SelectedElements.Add(element);
                }

                if (element is NodeElement)
                {
                    SelectedNodes.Add(element);
                }
            }

            //if the seleciont isn't a expecific link, remove links
            // without 2 elements in selection
            if (SelectedElements.Count > 1)
            {
                foreach (BaseElement el in Elements)
                {
                    var lnk = el as BaseLinkElement;
                    if (lnk == null)
                    {
                        continue;
                    }

                    if ((!SelectedElements.Contains(lnk.Connector1.ParentElement)) ||
                        (!SelectedElements.Contains(lnk.Connector2.ParentElement)))
                    {
                        SelectedElements.Remove(lnk);
                    }
                }
            }

            SelectedElements.EnabledCalc = true;
            SelectedNodes.EnabledCalc    = true;

            OnElementSelection(this, new ElementSelectionEventArgs(SelectedElements));
        }
Ejemplo n.º 4
0
 public void DeleteLink(BaseLinkElement lnk, bool callHandler = true)
 {
     if (lnk == null) return;
     lnk.Connector1.RemoveLink(lnk);
     lnk.Connector2.RemoveLink(lnk);
                     
     if (Elements.Contains(lnk))
         Elements.Remove(lnk);
     if (SelectedElements.Contains(lnk))
         SelectedElements.Remove(lnk);
     if (callHandler)
         OnLinkRemoved(new ElementEventArgs(lnk));
     OnAppearancePropertyChanged(new EventArgs());
 }
Ejemplo n.º 5
0
        private void InternalSelectedElements_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (SuppressNotificationsCounter > 0)
            {
                return;
            }

            try
            {
                SuppressNotifications();
                switch (e.Action)
                {
                case NotifyCollectionChangedAction.Add:
                case NotifyCollectionChangedAction.Remove:
                case NotifyCollectionChangedAction.Replace:
                    if (e.OldItems != null)
                    {
                        foreach (var item in e.OldItems.Cast <FieldExposer <T_Item> >())
                        {
                            if (SelectedElements.Contains(item.InnerItem))
                            {
                                SelectedElements.Remove(item.InnerItem);
                            }
                        }
                    }
                    if (e.NewItems != null)
                    {
                        foreach (var item in e.NewItems.Cast <FieldExposer <T_Item> >())
                        {
                            if (!SelectedElements.Contains(item.InnerItem))
                            {
                                SelectedElements.Add(item.InnerItem);
                            }
                        }
                    }
                    break;

                case NotifyCollectionChangedAction.Reset:
                    SelectedElements.Clear();
                    break;
                }
            }
            finally
            {
                AllowNotifications();
            }
        }
Ejemplo n.º 6
0
        private void Button_OnClick(UIElement sender)
        {
            ISelectable element = (sender as ISelectable);

            if (element.GetStatus())
            {
                SelectedElements.Add(element);
            }
            else
            {
                SelectedElements.Remove(element);
            }
            if (SelectedCountChanded != null)
            {
                SelectedCountChanded(SelectedElements.Count);
            }
        }
Ejemplo n.º 7
0
        public void DeleteLink(BaseLinkElement linkElement)
        {
            if (linkElement != null)
            {
                linkElement.Connector1.RemoveLink(linkElement);
                linkElement.Connector2.RemoveLink(linkElement);

                if (_elements.Contains(linkElement))
                {
                    _elements.Remove(linkElement);
                }
                if (SelectedElements.Contains(linkElement))
                {
                    SelectedElements.Remove(linkElement);
                }
                OnAppearancePropertyChanged(new EventArgs());
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Act when the source collection has been changed.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The kind of modification</param>
        private void Source_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
                foreach (var item in e.NewItems)
                {
                    Elements.Add(new FieldExposer <T_Item>(DataAccessor, (T_Item)item));
                }
                break;

            case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
                if (e.OldItems.Count == 1)
                {
                    T_Item item  = (T_Item)e.OldItems[0];
                    var    found = Elements.Where(element => element.InnerItem.Equals(item)).FirstOrDefault();
                    if (found == null)
                    {
                        throw new InvalidOperationException("Unexpected behavior: element not in list!");
                    }
                    Elements.Remove(found);
                    var selected = SelectedElements.Where(element => element.Equals(item)).FirstOrDefault();
                    if (selected != null)
                    {
                        SelectedElements.Remove(selected);
                    }
                }
                else
                {
                    throw new InvalidOperationException("Cannot remove more than one item at once!");
                }
                break;

            default:
                Elements = new ObservableCollection <FieldExposer <T_Item> >();
                foreach (var item in (ObservableCollection <T_Item>)sender)
                {
                    Elements.Add(new FieldExposer <T_Item>(DataAccessor, (T_Item)item));
                }
                RaisePropertyChanged("Elements");
                break;
            }
        }
Ejemplo n.º 9
0
        public void DeleteElement(BaseElement element)
        {
            if ((element != null) && !(element is ConnectorElement))
            {
                //Delete link
                if (element is BaseLinkElement)
                {
                    var linkElement = (BaseLinkElement)element;
                    DeleteLink(linkElement);
                    return;
                }

                //Delete node
                if (element is NodeElement)
                {
                    var conn = (NodeElement)element;
                    foreach (var connectorElement in conn.Connectors)
                    {
                        for (var i = connectorElement.Links.Count - 1; i >= 0; i--)
                        {
                            var linkElement = (BaseLinkElement)connectorElement.Links[i];
                            DeleteLink(linkElement);
                        }
                    }

                    if (SelectedNodes.Contains(element))
                    {
                        SelectedNodes.Remove(element);
                    }
                }

                if (SelectedElements.Contains(element))
                {
                    SelectedElements.Remove(element);
                }

                _elements.Remove(element);

                OnAppearancePropertyChanged(new EventArgs());
            }
        }
Ejemplo n.º 10
0
        #pragma warning disable 1998
        protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
        {
            __Blazor.Movies_Blazor.Client.Shared.MultipleSelectorTypeahead.TypeInference.CreateCustomTypeahead_0(__builder, 0, 1,
#line 2 "C:\Users\Yorik\Desktop\Blazor_Movies\Movies_Blazor\Client\Shared\MultipleSelectorTypeahead.razor"
                                                                                                                 (string search) => SearchMethod(search)

#line default
#line hidden
                                                                                                                 , 2, Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this,
#line 3 "C:\Users\Yorik\Desktop\Blazor_Movies\Movies_Blazor\Client\Shared\MultipleSelectorTypeahead.razor"
                                                                                                                                                                                   (T item) => SelectedElement(item)

#line default
#line hidden
                                                                                                                                                                                   ), 3, (context) => (__builder2) => {
                __builder2.AddMarkupContent(4, "\r\n        ");
                __builder2.AddContent(5,
#line 5 "C:\Users\Yorik\Desktop\Blazor_Movies\Movies_Blazor\Client\Shared\MultipleSelectorTypeahead.razor"
                                      MyResultTemplate(context)

#line default
#line hidden
                                      );
                __builder2.AddMarkupContent(6, "\r\n    ");
            }
                                                                                                                 );
            __builder.AddMarkupContent(7, "\r\n\r\n");
            __builder.OpenElement(8, "ul");
            __builder.AddAttribute(9, "class", "list-group");
            __builder.AddMarkupContent(10, "\r\n");
#line 10 "C:\Users\Yorik\Desktop\Blazor_Movies\Movies_Blazor\Client\Shared\MultipleSelectorTypeahead.razor"
            foreach (var item in SelectedElements)
            {
#line default
#line hidden
                __builder.AddContent(11, "        ");
                __builder.OpenElement(12, "li");
                __builder.AddAttribute(13, "draggable", "true");
                __builder.AddAttribute(14, "ondragstart", Microsoft.AspNetCore.Components.EventCallback.Factory.Create <Microsoft.AspNetCore.Components.Web.DragEventArgs>(this,
#line 12 "C:\Users\Yorik\Desktop\Blazor_Movies\Movies_Blazor\Client\Shared\MultipleSelectorTypeahead.razor"
                                                                                                                                                                           () => HandleDragStart(item)

#line default
#line hidden
                                                                                                                                                                           ));
                __builder.AddAttribute(15, "ondragover", Microsoft.AspNetCore.Components.EventCallback.Factory.Create <Microsoft.AspNetCore.Components.Web.DragEventArgs>(this,
#line 12 "C:\Users\Yorik\Desktop\Blazor_Movies\Movies_Blazor\Client\Shared\MultipleSelectorTypeahead.razor"
                                                                                                                                                                          () => HandleDragOver(item)

#line default
#line hidden
                                                                                                                                                                          ));
                __builder.AddAttribute(16, "class", "list-group-item list-group-item-action");
                __builder.AddMarkupContent(17, "\r\n            ");
                __builder.AddContent(18,
#line 14 "C:\Users\Yorik\Desktop\Blazor_Movies\Movies_Blazor\Client\Shared\MultipleSelectorTypeahead.razor"
                                     MyListTemplate(item)

#line default
#line hidden
                                     );
                __builder.AddMarkupContent(19, "\r\n\r\n            ");
                __builder.OpenElement(20, "span");
                __builder.AddAttribute(21, "onclick", Microsoft.AspNetCore.Components.EventCallback.Factory.Create <Microsoft.AspNetCore.Components.Web.MouseEventArgs>(this,
#line 16 "C:\Users\Yorik\Desktop\Blazor_Movies\Movies_Blazor\Client\Shared\MultipleSelectorTypeahead.razor"
                                                                                                                                                                        () => SelectedElements.Remove(item)

#line default
#line hidden
                                                                                                                                                                        ));
                __builder.AddAttribute(22, "class", "badge badge-primary badge-pill");
                __builder.AddAttribute(23, "style", "cursor:pointer");
                __builder.AddContent(24, "×");
                __builder.CloseElement();
                __builder.AddMarkupContent(25, "\r\n        ");
                __builder.CloseElement();
                __builder.AddMarkupContent(26, "\r\n");
#line 19 "C:\Users\Yorik\Desktop\Blazor_Movies\Movies_Blazor\Client\Shared\MultipleSelectorTypeahead.razor"
            }

#line default
#line hidden
            __builder.CloseElement();
        }