Esempio n. 1
0
 public void AfterChangeParent(DesignerItem designerItem, DesignerItem newParent, Point newPosition, List<DesignerItem> selectedItemsAllSubItems)
 {
     ChangeParent(newParent, designerItem);
     RemoveHelperConnection();
     Canvas.SetTop(designerItem, newPosition.Y);
     Canvas.SetLeft(designerItem, newPosition.X);
     DesignerItems.ForEach(x => { x.IsNewParent = false; });
     ConnectToNewParent(newParent);
     var items = selectedItemsAllSubItems.Where(x => x.ItemParentId.IsNullOrEmpty()).ToList();
     if (newParent == null)
     {
         foreach (var item in items)
         {
             Canvas.SetLeft(item, newPosition.X);
             Canvas.SetTop(item, newPosition.Y - (designerItem.OriginalTop - item.OriginalTop));
         }
         var topBelowZero =
             items.Where(item => newPosition.Y - (designerItem.OriginalTop - item.OriginalTop) < 0).ToList();
         if (topBelowZero.Any())
         {
             var minTopItem = topBelowZero.Aggregate((a, b) => Canvas.GetTop(a) < Canvas.GetTop(b) ? a : b);
             var v = Math.Abs(Canvas.GetTop(minTopItem));
             items.ForEach(x => { Canvas.SetTop(x, Canvas.GetTop(x) + v); });
         }
         var leftBelowZero = items.Where(item => newPosition.X < 0).ToList();
         if (leftBelowZero.Any())
         {
             var minLeftItem = topBelowZero.Aggregate((a, b) => Canvas.GetLeft(a) < Canvas.GetLeft(b) ? a : b);
             var v = Math.Abs(Canvas.GetLeft(minLeftItem));
             items.ForEach(x => { Canvas.SetLeft(x, Canvas.GetTop(x) + v); });
         }
     }
     Arrange();
 }
Esempio n. 2
0
 void ChangeParent(DesignerItem designerItem)
 {
     DiagramControl.DiagramManager.SetDragItemChildFlag();
     NewParent = DiagramControl.DiagramManager.ChangeParent(designerItem);
     if (_shadows == null) { _shadows = DiagramControl.DiagramManager.CreateShadows(designerItem, NewParent); }
     DiagramControl.DiagramManager.CreateHelperConnection(NewParent, designerItem);
     DiagramControl.DiagramManager.MoveUpAndDown(NewParent, designerItem);
 }
Esempio n. 3
0
        protected override void CreateGroups() {
            base.CreateGroups();

            var designerItem = new DesignerItem("Layout", "Customize the current view's layout and preview its data.", typeof(LayoutViewCustomizer), GetDefaultLargeImage(4), GetDefaultSmallImage(4), null);
            var designerGroup = new DesignerGroup("Layout", "Customize the current view's layout and preview its data.", GetDefaultLargeImage(4)){
                designerItem
            };
            Groups.Add(designerGroup);
        }
 public void SetComponentNode(IEnumerable <XElement> itemsXML)
 {
     foreach (XElement itemXML in itemsXML)
     {
         Guid         id   = new Guid(itemXML.Element("ID").Value);
         DesignerItem item = DeserializeDesignerItem(itemXML, id, 0, 0);
         this.Children.Add(item);
         SetConnectorDecoratorTemplate(item);
     }
 }
Esempio n. 5
0
 public static DesignerCanvas designerCanvas(this DesignerItem designerItem)
 {
     return((DesignerCanvas)designerItem.wpfInvoke(
                () => {
         if (designerItem.notNull() && designerItem.Parent.notNull() && designerItem.Parent is DesignerCanvas)
         {
             return (DesignerCanvas)designerItem.Parent;
         }
         return null;
     }));
 }
Esempio n. 6
0
 public static Connection add_Connection(this DesignerCanvas designerCanvas, DesignerItem designerItem1, DesignerItem designerItem2, string position1, string position2)
 {
     return((Connection)designerCanvas.wpfInvoke(
                () => {
         var connector1 = designerItem1.connector(position1);
         var connector2 = designerItem2.connector(position2);
         var connection = new DiagramDesigner.Connection(connector1, connector2);
         designerCanvas.Children.Add(connection);
         return connection;
     }));
 }
Esempio n. 7
0
        private void mainCanvas_SelectedItemChangedEvent(object sender, ISelectable item)
        {
            DesignerItem designerItem = item as DesignerItem;

            if (designerItem != null)
            {
                designerItem.ContextMenu = (ContextMenu)MenuService.ContextMenuResource["item"];
            }
            CustomProperty property = new CustomProperty(designerItem.EuipType);

            ((Window1)App.Current.MainWindow).PropertyBrowser.SelectedObject = designerItem.EuipType;
        }
Esempio n. 8
0
 private static void AssignFlowChartViewModeAndView(DesignerItem item, Tuple <ViewModels.ViewModelBase, UserControl> result)
 {
     if (result != null)
     {
         result.Item2.DataContext = result.Item1;
         var path = item.Content;
         item.Content = result.Item2;
         (result.Item2.FindName("NewContent") as ContentControl).Content = path;
         item.UpdateLayout();
         item.Selected += Item_Selected;
     }
 }
 private void SetConnectorDecoratorTemplate(DesignerItem item)
 {
     if (item.ApplyTemplate() && item.Content is UIElement)
     {
         ControlTemplate template  = DesignerItem.GetConnectorDecoratorTemplate(item.Content as UIElement);
         Control         decorator = item.Template.FindName("PART_ConnectorDecorator", item) as Control;
         if (decorator != null && template != null)
         {
             decorator.Template = template;
         }
     }
 }
Esempio n. 10
0
 protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e)
 {
     var diagramControl = DiagramControl;
     if (diagramControl == null) return;
     if (_shadows != null)
         diagramControl.DiagramManager.FinishChangeParent(NewParent);
     _shadows = null;
     NewParent = null;
     DiagramControl.DiagramManager.RestoreDragItemChildFlag();
     _verticalOffset = 0;
     _horizontalOffset = 0;
 }
Esempio n. 11
0
        private Connector GetConnector(Guid itemID, String connectorName)
        {
            DesignerItem designerItem = (from item in this.Children.OfType <DesignerItem>()
                                         where item.ID == itemID
                                         select item).FirstOrDefault();

            Control connectorDecorator = designerItem.Template.FindName("PART_ConnectorDecorator", designerItem) as Control;

            connectorDecorator.ApplyTemplate();

            return(connectorDecorator.Template.FindName(connectorName, connectorDecorator) as Connector);
        }
Esempio n. 12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void onModifyBlock(DesignerItem sender)
 {
     if (this.EditedObject != null && sender.Tag != null)
     {
         TransformationTreeItem entity = (TransformationTreeItem)sender.Tag;
     }
     this.IsModify = true;
     if (Change != null)
     {
         Change();
     }
 }
Esempio n. 13
0
        protected override void CreateGroups()
        {
            base.CreateGroups();

            var designerItem  = new DesignerItem("Layout", "Customize the current view's layout and preview its data.", typeof(LayoutViewCustomizer), GetDefaultLargeImage(4), GetDefaultSmallImage(4), null);
            var designerGroup = new DesignerGroup("Layout", "Customize the current view's layout and preview its data.", GetDefaultLargeImage(4))
            {
                designerItem
            };

            Groups.Add(designerGroup);
        }
 private List<DesignerItem> CreateChildDesignerItem(DesignerItem parentDesignerItem, List<ItemData> itemDatas)
 {
     List<DesignerItem> DesignerItems = new List<DesignerItem>();
     var child = itemDatas.Where(x => x.ItemParentId == parentDesignerItem.ItemId);
     foreach (var userDataSource in child)
     {
         var childDesignerItem = CreateChildItem(userDataSource.ItemId, parentDesignerItem.ItemId, userDataSource.Text, userDataSource);
         DesignerItems.Add(childDesignerItem);
         DesignerItems.AddRange(CreateChildDesignerItem(childDesignerItem, itemDatas));
     }
     return DesignerItems;
 }
Esempio n. 15
0
 public static Connector connector(this DesignerItem designerItem, string topLeftBottomOrRight)
 {
     return((Connector)designerItem.wpfInvoke(
                () => {
         var designerCanvas = designerItem.designerCanvas();
         if (designerItem.notNull() && designerCanvas.notNull())
         {
             return (DiagramDesigner.Connector)designerCanvas.invoke("GetConnector", designerItem.ID, topLeftBottomOrRight);
         }
         return null;
     }));
 }
Esempio n. 16
0
        void controlLocation_PropertyYChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            DesignerItem     item = sender as DesignerItem;
            PropertyYCommand command;

            if (PropertyChanged != null && item != null)
            {
                command = new PropertyYCommand(item);
                command.Execute(e.OldValue, e.NewValue);
                PropertyChanged(command);
            }
        }
Esempio n. 17
0
        void controlFont_PropertyFontFamilyChanged(object sender, RoutedPropertyChangedEventArgs <FontFamily> e)
        {
            DesignerItem        item = sender as DesignerItem;
            PropertyFontCommand command;

            if (PropertyChanged != null && item != null)
            {
                command = new PropertyFontCommand(item);
                command.Execute(e.OldValue, e.NewValue);
                PropertyChanged(command);
            }
        }
        protected override void OnPreviewMouseRightButtonDown(MouseButtonEventArgs e)//右击显示图元类型
        {
            base.OnPreviewMouseRightButtonDown(e);
            DesignerContainer item = e.Source as DesignerContainer;

            if (item != null)
            {
                DesignerItem o = item.Content as DesignerItem;
                o._controlID = item.ID;
                o.ShowWindow();
            }
        }
Esempio n. 19
0
        private void DragBottom(double scale, DesignerItem item, SelectionService selectionService)
        {
            IEnumerable<DesignerItem> groupItems = selectionService.GetGroupMembers(item).Cast<DesignerItem>();
            double groupTop = Canvas.GetTop(item);
            foreach (DesignerItem groupItem in groupItems)
            {
                double groupItemTop = Canvas.GetTop(groupItem);
                double delta = (groupItemTop - groupTop) * (scale - 1);

                Canvas.SetTop(groupItem, groupItemTop + delta);
                groupItem.Height = groupItem.ActualHeight * scale;
            }
        }
Esempio n. 20
0
        private void DragLeft(double scale, DesignerItem item, SelectionService selectionService)
        {
            IEnumerable<DesignerItem> groupItems = selectionService.GetGroupMembers(item).Cast<DesignerItem>();

            double groupLeft = Canvas.GetLeft(item) + item.Width;
            foreach (DesignerItem groupItem in groupItems)
            {
                double groupItemLeft = Canvas.GetLeft(groupItem);
                double delta = (groupLeft - groupItemLeft) * (scale - 1);
                Canvas.SetLeft(groupItem, groupItemLeft - delta);
                groupItem.Width = groupItem.ActualWidth * scale;
            }
        }
Esempio n. 21
0
        void OnDesignerItemSelected(object sender, System.Windows.RoutedEventArgs e)
        {
            DesignerItem item = sender as DesignerItem;

            FreeImageAlgorithmsWPFImage imObject = item.Content as FreeImageAlgorithmsWPFImage;

            if (imObject != null)
            {
                string fileName = System.IO.Path.GetFileNameWithoutExtension(imObject.FilePath);
                this.Text = "Manual Import " + fileName;
                item.BringToFront();
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Cette methode est appelée lorsau'on a ajouté un lien entre deaux blocks
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="child"></param>
        protected void onAddLink(DesignerItem parent, DesignerItem child)
        {
            if (parent.Tag == null || child.Tag == null)
            {
                return;
            }
            TransformationTreeItem parentTag = (TransformationTreeItem)parent.Tag;
            TransformationTreeItem childTag  = (TransformationTreeItem)child.Tag;

            this.EditedObject.ForgetItem(childTag);
            parentTag.AddChild(childTag);
            this.IsModify = true;
        }
        private List <DesignerItem> CreateChildDesignerItem(DesignerItem parentDesignerItem, List <ItemData> itemDatas)
        {
            List <DesignerItem> DesignerItems = new List <DesignerItem>();
            var child = itemDatas.Where(x => x.ItemParentId == parentDesignerItem.ItemId);

            foreach (var userDataSource in child)
            {
                var childDesignerItem = CreateChildItem(userDataSource.ItemId, parentDesignerItem.ItemId, userDataSource.Text, userDataSource);
                DesignerItems.Add(childDesignerItem);
                DesignerItems.AddRange(CreateChildDesignerItem(childDesignerItem, itemDatas));
            }
            return(DesignerItems);
        }
Esempio n. 24
0
        private void DragTop(double scale, DesignerItem item, SelectionService selectionService)
        {
            IEnumerable <DesignerItem> groupItems = selectionService.GetGroupMembers(item).Cast <DesignerItem>();
            double groupBottom = Canvas.GetTop(item) + item.Height;

            foreach (DesignerItem groupItem in groupItems)
            {
                double groupItemTop = Canvas.GetTop(groupItem);
                double delta        = (groupBottom - groupItemTop) * (scale - 1);
                Canvas.SetTop(groupItem, groupItemTop - delta);
                groupItem.Height = groupItem.ActualHeight * scale;
            }
        }
Esempio n. 25
0
        private void DragLeft(double scale, DesignerItem item, SelectionService selectionService)
        {
            IEnumerable <DesignerItem> groupItems = selectionService.GetGroupMembers(item).Cast <DesignerItem>();

            double groupLeft = Canvas.GetLeft(item) + item.Width;

            foreach (DesignerItem groupItem in groupItems)
            {
                double groupItemLeft = Canvas.GetLeft(groupItem);
                double delta         = (groupLeft - groupItemLeft) * (scale - 1);
                Canvas.SetLeft(groupItem, groupItemLeft - delta);
                groupItem.Width = groupItem.ActualWidth * scale;
            }
        }
Esempio n. 26
0
        /// <summary>
        /// Cette methode est appelée lorsau'on a supprimé un lien entre deaux blocks
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="child"></param>
        protected void onDeleteLink(DesignerItem parent, DesignerItem child)
        {
            if (parent.Tag == null || child.Tag == null)
            {
                return;
            }
            Kernel.Domain.Entity parentTag = (Kernel.Domain.Entity)parent.Tag;
            Kernel.Domain.Entity childTag  = (Kernel.Domain.Entity)child.Tag;

            parentTag.ForgetChild(childTag);
            childTag.parent = null;
            this.EditedObject.UpdateEntity(childTag);
            this.IsModify = true;
        }
        public static DependencyObject DeSerializFromXElementControl(XElement xml)
        {
            if (!ValidXml(xml))
            {
                return(null);
            }
            XAttribute   typeAttribute = xml.Attribute(_TypeStr);
            DesignerItem dobj          = GetItemObjectControl(typeAttribute);

            if (dobj == null)
            {
                return(null);
            }
            IDesignerChildable childable    = dobj as IDesignerChildable;
            XElement           childelement = xml.Element(_DesignerelementStr);

            var pros = GetSerializPropertys(dobj);

            dobj._listProperty = pros;
            if (pros != null)
            {
                foreach (var pro in pros)
                {
                    XElement element = xml.Element(pro.Name);
                    if (element == null)
                    {
                        continue;
                    }
                    if (element.Value == "NaN")
                    {
                        continue;
                    }
                    try
                    {
                        pro.guid = element.Attribute("ID").Value;
                    }
                    catch { pro.guid = Guid.NewGuid().ToString(); }

                    if (pro.Descriptor.PropertyType == typeof(object))
                    {
                        pro.SetValue(element.Value);
                    }
                    else
                    {
                        pro.SetValue(pro.Converter.ConvertFromString(element.Value));
                    }
                }
            }
            return(dobj);
        }
Esempio n. 28
0
        public Connector GetConnector(Guid itemID, String connectorName, IList <DesignerItem> designerItems, ConnectorOrientation orientation)
        {
            //logger.Info("Inicio Obtener Conector");
            DesignerItem designerItem = (from item in designerItems
                                         where item.ID == itemID
                                         select item).FirstOrDefault();
            Connector result = new Connector();

            result.Name = connectorName;
            result.ParentDesignerItem = designerItem;
            result.Orientation        = orientation;
            //logger.Info("Fin Obtener Conector");
            return(result);
        }
Esempio n. 29
0
        void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
        {
            DesignerItem   designerItem = this.DataContext as DesignerItem;
            DesignerCanvas designer     = VisualTreeHelper.GetParent(designerItem) as DesignerCanvas;

            if (designerItem != null && designer != null && designerItem.IsSelected)
            {
                double minLeft = double.MaxValue;
                double minTop  = double.MaxValue;

                // we only move DesignerItems
                var designerItems = from item in designer.SelectedItems
                                    where item is DesignerItem
                                    select item;

                foreach (DesignerItem item in designerItems)
                {
                    double left = Canvas.GetLeft(item);
                    double top  = Canvas.GetTop(item);

                    minLeft = double.IsNaN(left) ? 0 : Math.Min(left, minLeft);
                    minTop  = double.IsNaN(top) ? 0 : Math.Min(top, minTop);
                }

                double deltaHorizontal = Math.Max(-minLeft, e.HorizontalChange);
                double deltaVertical   = Math.Max(-minTop, e.VerticalChange);

                foreach (DesignerItem item in designerItems)
                {
                    double left = Canvas.GetLeft(item);
                    double top  = Canvas.GetTop(item);

                    if (double.IsNaN(left))
                    {
                        left = 0;
                    }
                    if (double.IsNaN(top))
                    {
                        top = 0;
                    }

                    Canvas.SetLeft(item, left + deltaHorizontal);
                    Canvas.SetTop(item, top + deltaVertical);
                }

                designer.InvalidateMeasure();
                e.Handled = true;
            }
        }
Esempio n. 30
0
 void subFlowDesigner_SubflowMagnifyIconDoubleClick(object sender, EventArgs e)
 {
     try
     {
         DesignerItem     designerItem     = ((RoutedEventArgs)e).OriginalSource as DesignerItem;
         SubFlowExecution subFlowExecution = GetSubflowExecution();
         var dataStores = subFlowExecution.GetDataObjectForDesignerItem(designerItem.ID, true, null);
         DataPreviewWindow dataPreviewWindow = new DataPreviewWindow(dataStores.First());
         dataPreviewWindow.Show();
     }
     catch (Exception ex)
     {
         HandleWindowOpenExceptions(ex);
     }
 }
Esempio n. 31
0
        private void onMoveLinkSource(DesignerItem oldParent, DesignerItem child, DesignerItem newParent)
        {
            if (oldParent.Tag == null || child.Tag == null || newParent.Tag == null)
            {
                return;
            }
            TransformationTreeItem oldParentTag = (TransformationTreeItem)oldParent.Tag;
            TransformationTreeItem newParentTag = (TransformationTreeItem)newParent.Tag;
            TransformationTreeItem childTag     = (TransformationTreeItem)child.Tag;

            oldParentTag.ForgetChild(childTag);
            childTag.parent = null;
            newParentTag.AddChild(childTag);
            this.IsModify = true;
        }
Esempio n. 32
0
 private static void AssignSimulationViewModeAndView(DesignerItem item, Tuple <ViewModels.ViewModelBase, UserControl> result)
 {
     if (result != null)
     {
         result.Item2.DataContext = result.Item1;
         item.Content             = result.Item2;
         item.UpdateLayout();
         item.DataContext = null;
         var connectors = item.GetConnectors();
         foreach (var connector in connectors)
         {
             connector.ConnectionChanged += Connector_ConnectionChanged;
         }
     }
 }
Esempio n. 33
0
 public static DesignerItem designMode(this DesignerItem designerItem, bool value)
 {
     return((DesignerItem)designerItem.wpfInvoke(
                () => {
         foreach (var subItem in designerItem.controls_Wpf())
         {
             if ((subItem is DesignerItem).isFalse())
             {
                 subItem.IsHitTestVisible = value.not();
             }
         }
         //designerItem.IsHitTestVisible = value;
         return designerItem;
     }));
 }
Esempio n. 34
0
        private void SetConnectorDecoratorTemplate()
        {
            var item = DesignerItem;
//            if (item.ApplyTemplate() && item.Content is UIElement)
//            {
            ControlTemplate template  = DesignerItem.GetConnectorDecoratorTemplate(item.Content as UIElement);
            Control         decorator = item.Template.FindName("PART_ConnectorDecorator", item) as Control;

            if (decorator != null && template != null)
            {
                decorator.Template = template;
            }
            //}
            item.IsSelected = true;
        }
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (!_displayOnly && e.Source is DesignerItem)
            {
                if (_currentDesignItem == null)
                {
                    _currentDesignItem = e.Source as DesignerItem;
                    // _currentDesignItem.ChangeColorToWhite();
                }

                if (((DesignerItem)e.Source) != _currentDesignItem)
                {
                    _currentDesignItem.RestoreOriginalColor();
                    _currentDesignItem = e.Source as DesignerItem;
                    _currentDesignItem.ChangeColorToWhite();

                    InvalidateVisual();
                    RaiseComponentItemChanged(new EventArgs());
                }
                //_currentDesignItem.BorderBrush = Brushes.BlueViolet;
                //_currentDesignItem.BorderThickness = new Thickness(10,10,10,10);

                //if (_currentDesignItem.Style.TargetType.GetType() == typeof(TextBox))
                //{
                //   // _currentDesignItem

                //}

                //_currentDesignItem = "Orange";
                // in case that this click is the start of a
                // drag operation we cache the start point
                // var point = new Point?(e.GetPosition(this));

                //foreach (Control item in Children)
                //{
                //    Rect itemRect = VisualTreeHelper.GetDescendantBounds(item);
                //    Rect itemBounds = item.TransformToAncestor(this).TransformBounds(itemRect);
                //    if (itemRect.Contains(e.GetPosition(this)) && item is DesignerItem)
                //    {
                //        item.Focus();
                //    }
                //    Focus();
                //    e.Handled = true;
                //}
            }
        }
Esempio n. 36
0
        private static DesignerItem DeserializeDesignerItem(XElement itemXML, Guid id, double OffsetX, double OffsetY)
        {
            DesignerItem item = new DesignerItem(id);

            item.Width    = Double.Parse(itemXML.Element("Width").Value, CultureInfo.InvariantCulture);
            item.Height   = Double.Parse(itemXML.Element("Height").Value, CultureInfo.InvariantCulture);
            item.ParentID = new Guid(itemXML.Element("ParentID").Value);
            item.IsGroup  = Boolean.Parse(itemXML.Element("IsGroup").Value);
            Canvas.SetLeft(item, Double.Parse(itemXML.Element("Left").Value, CultureInfo.InvariantCulture) + OffsetX);
            Canvas.SetTop(item, Double.Parse(itemXML.Element("Top").Value, CultureInfo.InvariantCulture) + OffsetY);
            Canvas.SetZIndex(item, Int32.Parse(itemXML.Element("zIndex").Value));
            Object content = XamlReader.Load(XmlReader.Create(new StringReader(itemXML.Element("Content").Value)));

            item.Content = content;
            return(item);
        }
Esempio n. 37
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void onModifyBlock(DesignerItem sender)
 {
     if (this.EditedObject != null && sender.Tag != null)
     {
         Kernel.Domain.Entity entity = (Kernel.Domain.Entity)sender.Tag;
         if (entity.parent != null)
         {
             entity.parent.UpdateChild(entity);
         }
         else
         {
             this.EditedObject.UpdateEntity(entity);
         }
         this.IsModify = true;
     }
 }
Esempio n. 38
0
        /// <summary>
        /// 递归查找流程线条,线条是否已经连接。       
        /// </summary>
        /// <param name="SourceDesignerItem">原元素</param>
        /// <param name="HitDesignerItem">目标元素</param>
        /// <returns>True-存在,False-不存在</returns>
        public bool TraversalParentElement(DesignerItem SourceDesignerItem, DesignerItem HitDesignerItem)
        {
            bool result = false;
            foreach (var item in this.designerCanvas.Children)
            {
                if (item is Connection)
                {
                    var sinkItem = item as Connection;
                    if (sinkItem.Source.ParentDesignerItem == hitDesignerItem && sinkItem.Sink.ParentDesignerItem == SourceDesignerItem)//判断相邻两个元素是否存在线条
                    {
                        if (sinkItem.Source.ParentDesignerItem == hitDesignerItem && sinkItem.Sink.ParentDesignerItem == SourceDesignerItem)
                        {
                            result = true;
                            break;
                        }
                    }
                    if (TempDesignerItem != null)
                    {
                        if (TempDesignerItem == hitDesignerItem)
                        {
                            result = true;
                            break;
                        }
                    }

                    if (sinkItem.Sink.ParentDesignerItem == SourceDesignerItem)//判断不相邻两个元素是否存在线条
                    {
                        if (sinkItem.Source.ParentDesignerItem != hitDesignerItem)
                        {
                            TempDesignerItem = sinkItem.Source.ParentDesignerItem;
                            result = this.TraversalParentElement(sinkItem.Source.ParentDesignerItem, hitDesignerItem);
                        }
                    }
                }
            }
            return result;
        }
Esempio n. 39
0
 public void SetItemStyle(DesignerItem designerItem, ItemStyle itemStyle)
 {
     string s = JsonConvert.SerializeObject(itemStyle);
     var oType = designerItem.DataContext.GetType();
     var itemStyleField = ItemStyleField;
     var p = oType.GetProperty(itemStyleField);
     p.SetValue(designerItem.DataContext, s, null);
 }
Esempio n. 40
0
    public static List<DesignerItem> QueryDesigners(string sSalonId)
    {
        _listDesigner.Clear();
        int nSalonId = int.Parse(sSalonId);
        string sqlcmd = "SELECT * FROM " + DBName1 + ".ezNailDesigner WHERE Enabled = 1 AND SalonID = " + nSalonId;

        DataTable dt1 = DBOperate.SelectFromTable(DBconnect, sqlcmd);
        for (int k = 0; k < dt1.Rows.Count; k++)
        {
            DataRow dr = dt1.Rows[k];
            int designerId = 0;
            if (GlobalVar.web_version == 1)
            {
                designerId = (int)dr["ClientDesignerId"];
            }
            else
            {
                designerId = (int)dr["LocalDesignerId"];
            }
            string name = (string)dr["Name"];

            DesignerItem item = new DesignerItem();
            item.localDesignerID = designerId;
            item.designerName = name;
            _listDesigner.Add(item);
        }
        //     DBOperate.Insert_ezOrderDetail(ConnectionString.GlobalLocalConnectionString, 0, (int)EnumData.DesignID.DEFAULT, e.Item.Text, e.Item.StartDate, e.Item.EndDate,
        //"", "", "", "", designerId, _salonID, 0, 0, 0, false, e.Item.Date.Date, (int)EnumData.Status.INITIAL, DateTime.Now);
        return _listDesigner;
    }
Esempio n. 41
0
 void CreateConnection(DesignerItem newParent, DesignerItem designerItem)
 {
     var source = GetItemConnector(newParent, PARENT_CONNECTOR);
     var sink = GetItemConnector(designerItem, CHILD_CONNECTOR);
     var connection = new Connection(source, sink);
     source.Connections.Add(connection);
     DesignerCanvas.Children.Add(connection);
 }
Esempio n. 42
0
        private void HitTesting(Point hitPoint)
        {
            bool hitConnectorFlag = false;

            DependencyObject hitObject = designerCanvas.InputHitTest(hitPoint) as DependencyObject;
            while (hitObject != null &&
                   hitObject != sourceConnector.ParentDesignerItem &&
                   hitObject.GetType() != typeof(DesignerCanvas))
            {
                if (hitObject is Connector)
                {
                    HitConnector = hitObject as Connector;
                    hitConnectorFlag = true;
                }

                if (hitObject is DesignerItem)
                {
                    HitDesignerItem = hitObject as DesignerItem;
                    if (!hitConnectorFlag)
                        HitConnector = null;
                    return;
                }
                hitObject = VisualTreeHelper.GetParent(hitObject);
            }

            HitConnector = null;
            HitDesignerItem = null;
        }
Esempio n. 43
0
        /// <summary>
        /// 测试是否已经命中元素
        /// </summary>
        /// <param name="hitPoint">鼠标点击的坐标</param>
        private void HitTesting(Point hitPoint)
        {
            bool hitConnectorFlag = false;
            DependencyObject hitObject = designerCanvas.InputHitTest(hitPoint) as DependencyObject;
            while (hitObject != null &&
                   hitObject != sourceConnector.ParentDesignerItem &&
                   hitObject.GetType() != typeof(MyCanvas))
            {
                if (hitObject is Connector)
                {
                    HitConnector = hitObject as Connector;
                    hitConnectorFlag = true;
                }

                if (hitObject is DesignerItem)
                {
                    HitDesignerItem = hitObject as DesignerItem;
                    var parentitem = hitDesignerItem.FindVisualTreeAncestor(x => x is Connector);
                    Control connectorDecorator = HitDesignerItem.Template.FindName("PART_ConnectorDecorator", HitDesignerItem) as Control;
                    List<DependencyObject> item = connectorDecorator.FindVisualTreeChildren(x => x is Connector);

                    foreach (var connector in item)
                    {
                        var data = connector as Connector;
                        if (Math.Abs(data.Position.X - hitPoint.X) < 18 && Math.Abs(data.Position.Y - hitPoint.Y) < 18)
                        {
                            hitConnector = data;
                            hitConnectorFlag = true;
                            break;
                        }
                    }
                    if (!hitConnectorFlag)
                    {
                        HitConnector = null;
                    }
                    return;
                }
                hitObject = VisualTreeHelper.GetParent(hitObject);
            }

            HitConnector = null;
            HitDesignerItem = null;
        }
Esempio n. 44
0
 void Collapse(DesignerItem item)
 {
     var child = item.ChildrenDesignerItems;
     foreach (var c in child)
     {
         Collapse(c);
         if (c.CanCollapsed)
         {
             c.Suppress = true;
             c.IsExpanded = false;
             c.Suppress = false;
         }
         Hide(c);
     }
     item.Suppress = true;
     item.IsExpanded = false;
     item.Suppress = false;
 }
Esempio n. 45
0
 List<DesignerItem> Arrange(DesignerItem designerItem)
 {
     List<DesignerItem> list = new List<DesignerItem>();
     if (designerItem == null) return list;
     var directSubItems = designerItem.ChildrenDesignerItems;
     designerItem.UpdateExpander();
     if (directSubItems == null || directSubItems.Count == 0) return list;
     var subItems = directSubItems
         .OrderBy(x => Canvas.GetTop(x)).ToList();
     foreach (var sub in subItems)
     {
         var top = double.IsNaN(Canvas.GetTop(designerItem)) ? 0 : Canvas.GetTop(designerItem) + designerItem.ActualHeight + list.Sum(x => x.ActualHeight);
         list.Add(sub);
         var left = Canvas.GetLeft(designerItem) + GetOffset(designerItem);
         Canvas.SetTop(sub, top);
         Canvas.SetLeft(sub, left);
         SavePosition(sub);
         list.AddRange(Arrange(sub));/*递归*/
     }
     return list;
 }
Esempio n. 46
0
 void ExpandArrange(DesignerItem designerItem)
 {
     var allCollapsedSubItems = GetAllCollapsedSubItems(designerItem);
     if (!allCollapsedSubItems.Any()) return;
     double h = 0d;
     foreach (var allSubItem in allCollapsedSubItems)
     {
         allSubItem.UpdateLayout();
         h += allSubItem.ActualHeight;
     }
     var subItems = GetAllSubItems(designerItem);
     if (subItems.Any())
     {
         var last = subItems.Aggregate((a, b) => a.Top > b.Top ? a : b);
         var list = DesignerItems.Where(x =>
         x.Top > last.Top).ToList();
         foreach (var item in list)
         {
             Canvas.SetTop(item, Canvas.GetTop(item) + h);
         }
     }
 }
Esempio n. 47
0
    private void DragRight(double scale, DesignerItem item, SelectionService selectionService)
    {
      var groupItems = selectionService.GetGroupMembers(item).Cast<DesignerItem>();

      var groupLeft = Canvas.GetLeft(item);
      foreach (var groupItem in groupItems)
      {
        var groupItemLeft = Canvas.GetLeft(groupItem);
        var delta = (groupItemLeft - groupLeft)*(scale - 1);

        Canvas.SetLeft(groupItem, groupItemLeft + delta);
        groupItem.Width = groupItem.ActualWidth*scale;
      }
    }
Esempio n. 48
0
 List<DesignerItem> CreateDesignerItem(List<Item> source, List<Item> childItems, DesignerItem root)
 {
     var list = new List<DesignerItem>();
     foreach (var e in childItems)
     {
         var r = e;
         var d = new DesignerItem(r.Data, this);
         d.ItemStyle = JsonConvert.DeserializeObject<ItemStyle>(GetItemStyle(r.Data));
         d.ItemStyle.designerItem = d;
         d.ParentDesignerItem = root;
         root.ChildrenDesignerItems.Add(d);
         list.Add(d);
         var childs = source.Where(x => x.PId == r.Id).ToList();
         var c = CreateDesignerItem(source, childs, d);
         if (c.Any())
         {
             list.AddRange(c);
         }
     }
     return list;
 }
Esempio n. 49
0
        internal ObservableCollection<DesignerItem> GenerateDesignerItemList(IList itemSource)
        {
            var result = new ObservableCollection<DesignerItem>();
            var list = new List<DesignerItem>();
            var dic = (from object item in itemSource
                       select new Item()
                       {
                           Id = GetId(item),
                           PId = GetPId(item),
                           Data = item
                       }).ToList();
            var roots = dic.Where(x => x.PId.IsNullOrEmpty()).ToList();
            if (roots.Any())
            {
                foreach (var r in roots)
                {
                    var d = new DesignerItem(r.Data, this)
                    {
                        ParentDesignerItem = null,
                        ItemStyle = JsonConvert.DeserializeObject<ItemStyle>(GetItemStyle(r.Data))
                    };
                    d.ItemStyle.designerItem = d;
                    list.Add(d);
                    var childs = dic.Where(x => x.PId == r.Id).ToList();
                    list.AddRange(CreateDesignerItem(dic, childs, d));
                }
            }
            else //复制粘贴时调用
            {
                var r = dic.Where(x => dic.All(y => y.Id != x.PId));
                foreach (var item in r)
                {
                    var d = new DesignerItem(item.Data, this);
                    d.ItemStyle = JsonConvert.DeserializeObject<ItemStyle>(GetItemStyle(item.Data));
                    d.ItemStyle.designerItem = d;
                    var parent = Manager.GetDesignerItemById(item.PId);
                    d.ParentDesignerItem = parent;
                    parent.ChildrenDesignerItems.Add(d);
                    list.Add(d);
                    var childs = dic.Where(x => x.PId == item.Id).ToList();
                    list.AddRange(CreateDesignerItem(dic, childs, d));
                }
            }

            foreach (var designerItem in list)
            {
                result.Add(designerItem);
            }
            return result;
        }
Esempio n. 50
0
 void Expand(DesignerItem item)
 {
     item.Suppress = true;
     item.IsExpanded = true;
     item.Suppress = false;
     var child = item.ChildrenDesignerItems;
     foreach (var c in child)
     {
         if (!c.IsExpanded)
         {
             c.Suppress = true;
             c.IsExpanded = true;
             c.Suppress = false;
             Show(c);
         }
         Expand(c);
     }
 }
        void thumbDragThumb_DragStarted(object sender, DragStartedEventArgs e)
        {
            this.HitDesignerItem = null;
            this.HitConnector = null;
            this.pathGeometry = null;
            this.Cursor = Cursors.Cross;
            this.connection.StrokeDashArray = new DoubleCollection(new double[] { 1, 2 });

            if (sender == sourceDragThumb)
            {
                fixConnector = connection.Sink;
                dragConnector = connection.Source;
            }
            else if (sender == sinkDragThumb)
            {
                dragConnector = connection.Sink;
                fixConnector = connection.Source;
            }
        }
        void thumbDragThumb_DragCompleted(object sender, DragCompletedEventArgs e)
        {
            if (HitConnector != null)
            {
                if (connection != null)
                {
                    if (connection.Source == fixConnector)
                        connection.Sink = this.HitConnector;
                    else
                        connection.Source = this.HitConnector;
                }
            }

            this.HitDesignerItem = null;
            this.HitConnector = null;
            this.pathGeometry = null;
            this.connection.StrokeDashArray = null;
            this.InvalidateVisual();
        }
Esempio n. 53
0
 /*根据取得的newParent,改变特定item的连线*/
 void ConnectToNewParent(DesignerItem newParent)
 {
     if (_diagramControl.SingleRoot && newParent == null) return;
     var items = GetSelectedItems();
     var itemsToChangeParent = items.Where(a => items.All(y => y.ItemId != a.ItemParentId));/*在选中的集合a中,只改变“父节点不在集合a中的”节点*/
     foreach (var designerItem in itemsToChangeParent)
     {
         if (designerItem.ParentDesignerItem != null)
         {
             designerItem.ParentDesignerItem.ChildrenDesignerItems.Remove(designerItem);
         }
         designerItem.ParentDesignerItem = newParent;
         designerItem.UpdateExpander();
         if (newParent != null)
         { newParent.ChildrenDesignerItems.Add(designerItem); }
         designerItem.ItemParentId = newParent == null ? "" : newParent.ItemId;
         if (_diagramControl.Items.Any())//用items初始化的
         {
             var x = designerItem.DataContext as DiagramItem;
             if (x != null)
             {
                 x.PId = designerItem.ItemParentId;
             }
         }
         else //用ItemsSource初始化的
         {
             SetPId(designerItem);
         }
         var connections = GetItemConnections(designerItem).Where(x => Equals(x.Sink.ParentDesignerItem, designerItem)).ToList();
         if (connections.Any())//有连线
         {
             connections.ForEach(connection =>
             {
                 if (newParent != null)/*有新父节点,则改变连线到新父节点*/ { connection.Source = GetItemConnector(newParent, PARENT_CONNECTOR); }
                 else/*没有新父节点,则移除连线*/ { RemoveConnection(connection); }
             });
         }
         else if /*没有连线,但是有新父节点*/ (newParent != null)
         {
             CreateConnection(newParent, designerItem);
         }
     }
 }
Esempio n. 54
0
        static void AddAction(DiagramControl dc, IList newItems)
        {

            if (newItems == null || newItems.Count == 0) return;
            if (newItems.Count > 1)
            {
                if (dc.ItemsSource == null) return;
                if (dc.Check())
                {
                    dc.Bind(newItems);
                }
            }
            else //增加单一节点
            {
                foreach (var newItem in newItems)
                {
                    var model = newItem as DataModel;
                    if (model == null) continue;

                    var item = new DesignerItem(newItem, dc);
                    item.ItemStyle = JsonConvert.DeserializeObject<ItemStyle>(dc.GetItemStyle(newItem));
                    item.ItemStyle.designerItem = item;
                    var parentid = dc.GetPId(newItem);
                    if (parentid.IsNotEmpty())
                    {
                        var parent = dc.Manager.GetDesignerItemById(parentid);
                        parent.ChildrenDesignerItems.Add(item);
                        item.ParentDesignerItem = parent;
                        dc.Manager.DrawChild(parent, item, new List<DesignerItem>());
                        if (dc.IsAddAfter)/*增加子节点*/
                        {
                            var childs = dc.Manager.GetAllSubItems(parent).Where(x => !x.Equals(item));
                            var lastChild = !childs.Any() ? parent : childs.Aggregate((a, b) => Canvas.GetTop(a) > Canvas.GetTop(b) ? a : b);
                            var below = dc.DesignerItems.Where(x => Canvas.GetTop(x) > Canvas.GetTop(lastChild)).ToList();

                            dc.AddToMessage("增加子节点", dc.Manager.GetTime(() =>
                            {
                                below.ForEach(x => { Canvas.SetTop(x, Canvas.GetTop(x) + item.ActualHeight); });
                                Canvas.SetTop(item, Canvas.GetTop(lastChild) + lastChild.ActualHeight);
                            }));
                            dc.Manager.SetSelectItem(item);
                        }
                        else/*增加相邻节点*/
                        {
                            var s = dc.DesignerCanvas.SelectionService.CurrentSelection.ConvertAll<DesignerItem>(x => x as DesignerItem);
                            if (!s.Any()) return;
                            var selectedItem = s.FirstOrDefault();
                            if (selectedItem == null) return;

                            DesignerItem libling;
                            var down = dc.DesignerItems.Where(x => x.Level == selectedItem.Level && Canvas.GetTop(x) > Canvas.GetTop(selectedItem) && x.ParentDesignerItem.Equals(selectedItem.ParentDesignerItem)).ToList();
                            if (down.Any())
                            {
                                libling = down.Aggregate((a, b) => Canvas.GetTop(a) < Canvas.GetTop(b) ? a : b);
                                var below = dc.DesignerItems.Where(x => Canvas.GetTop(x) > Canvas.GetTop(libling)).ToList();
                                below.Add(libling);
                                dc.AddToMessage("增加相邻节点", dc.Manager.GetTime(() =>
                                {
                                    below.ForEach(x => { Canvas.SetTop(x, Canvas.GetTop(x) + item.ActualHeight); });
                                    Canvas.SetTop(item, Canvas.GetTop(libling) - libling.ActualHeight);
                                }));
                            }
                            else
                            {
                                var childs = dc.Manager.GetAllSubItems(parent);
                                var lastChild = !childs.Any() ? parent : childs.Aggregate((a, b) => Canvas.GetTop(a) > Canvas.GetTop(b) ? a : b);

                                var below = dc.DesignerItems.Where(x => Canvas.GetTop(x) > Canvas.GetTop(lastChild)).ToList();
                                dc.AddToMessage("增加相邻节点", dc.Manager.GetTime(() =>
                                {
                                    below.ForEach(x => { Canvas.SetTop(x, Canvas.GetTop(x) + item.ActualHeight); });
                                    Canvas.SetTop(item, Canvas.GetTop(lastChild) + lastChild.ActualHeight);
                                }));
                            }
                        }
                    }
                    else
                    {
                        dc.Manager.DrawRoot(item);
                        item.ApplyTemplate();
                        item.SetTemplate();
                        item.UpdateLayout();
                        if (dc.ItemsSource.Count > 1)
                        {
                            Canvas.SetTop(item, dc.GetTop(newItem) - item.ActualHeight / 2);
                            Canvas.SetLeft(item, dc.GetLeft(newItem) - item.ActualWidth / 2);
                        }
                        else
                        {
                            Canvas.SetTop(item, 0);
                            Canvas.SetLeft(item, 0);
                        }
                    }
                    dc.DesignerItems.Add(item);
                    dc.Manager.SetSelectItem(item);
                    dc.Manager.Scroll(item);
                    dc.Manager.SavePosition();
                }
            }



        }
Esempio n. 55
0
 void CollapseArrange(DesignerItem designerItem)
 {
     var allSubItems = GetAllExpandedSubItems(designerItem);
     double h = 0d;
     allSubItems.ForEach(x => { h += x.ActualHeight; });
     var subItems = GetAllSubItems(designerItem);
     var last = subItems.Any() ? subItems.Aggregate((a, b) =>
       a.Top > b.Top ? a : b) : designerItem;
     var list = DesignerItems.Where(x =>
     x.Top > last.Top).ToList();
     foreach (var item in list)
     {
         Canvas.SetTop(item, Canvas.GetTop(item) - h);
     }
 }
Esempio n. 56
0
 void DrawDesignerItem(DesignerItem item)
 {
     if (item.DataContext == null) return;
     GenerateDesignerItemContent(item, DEFAULT_FONT_COLOR_BRUSH);
     if (!DesignerCanvas.Children.Contains(item))
     {
         DesignerCanvas.Children.Add(item);
         var menu = DesignerItem.GetItemContextMenu(_diagramControl);
         menu.DataContext = _diagramControl.DataContext;
         item.ContextMenu = menu;
     }
     SetWidth(item);
 }
Esempio n. 57
0
 void ChangeParent(DesignerItem newParent, DesignerItem designerItem)
 {
     if (newParent != null)
     {
         if (designerItem.ParentDesignerItem != null)
         {
             designerItem.ParentDesignerItem.ChildrenDesignerItems.Remove(designerItem);
         }
         designerItem.UpdateExpander();
         designerItem.ParentDesignerItem = newParent;
         newParent.ChildrenDesignerItems.Add(designerItem);
     }
 }
Esempio n. 58
0
 //第二种方案,直接取下方相邻节点
 DesignerItem DownSiblingDesignerItem(DesignerItem selectedItem)
 {
     var items = DesignerItems.Where(x => Canvas.GetTop(x) > Canvas.GetTop(selectedItem) && GetRoot(x).Equals(GetRoot(selectedItem)));
     if (items.Any())
     {
         var item = items.Aggregate((a, b) => Canvas.GetTop(a) < Canvas.GetTop(b) ? a : b);
         return item;
     }
     return null;
 }
Esempio n. 59
0
 private void DragTop(double scale, DesignerItem item, SelectionService selectionService)
 {
   var groupItems = selectionService.GetGroupMembers(item).Cast<DesignerItem>();
   var groupBottom = Canvas.GetTop(item) + item.Height;
   foreach (var groupItem in groupItems)
   {
     var groupItemTop = Canvas.GetTop(groupItem);
     var delta = (groupBottom - groupItemTop)*(scale - 1);
     Canvas.SetTop(groupItem, groupItemTop - delta);
     groupItem.Height = groupItem.ActualHeight*scale;
   }
 }
Esempio n. 60
0
 //第一种方案
 DesignerItem DownDesignerItem(DesignerItem selectedItem, List<DesignerItem> siblingDesignerItems)
 {
     DesignerItem selectedDesignerItem = null;
     var down = siblingDesignerItems
         .Where(x => x.Top > selectedItem.Top).ToList();
     if (down.Any()) //1.优先找相邻节点,处于下方的节点
     {
         selectedDesignerItem = down.Aggregate((a, b) => a.Top < b.Top ? a : b);
     }
     else //没有处于下方的相邻节点,2.有父亲节点,则找其父亲的,处于下方的相邻节点,3.如果没有父亲节点,就找子节点
     {
         var parents =
            DesignerItems.Where(x => x.ItemId == selectedItem.ItemParentId).ToList();
         if (parents.Count() == 1 && parents.FirstOrDefault() != null) //有父节点,父节点邻居,处于下方的节点
         {
             var parent = parents.FirstOrDefault();
             if (parent != null)
             {
                 var parentSibling =
                     DesignerItems.Where(
                         x => x.ItemParentId == parent.ItemParentId
                              && x.Top > parent.Top).ToList();
                 if (parentSibling.Any())
                 {
                     selectedDesignerItem =
                         parentSibling.Aggregate((a, b) => a.Top > b.Top ? a : b);
                 }
             }
         }
         if (selectedDesignerItem == null)//没有父节点,找子节点
         {
             var child = DesignerItems.Where(x => x.ItemParentId == selectedItem.ItemId).ToList();
             if (child.Any())
             {
                 selectedDesignerItem = child.Aggregate((a, b) => a.Top < b.Top ? a : b);
             }
         }
     }
     return selectedDesignerItem;
 }