Exemplo n.º 1
0
        void menuitem_添加描述_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            InputBox frm = new InputBox("请输入内容", "添加描述", 200);

            frm.Owner = MainWindow.instance;
            if (frm.ShowDialog() == true)
            {
                EJ.InterfaceInModule data = new EJ.InterfaceInModule()
                {
                    ModuleID = InterfaceItemNode.Module.id,
                    x        = (int)m_RightButtonDownPoint.X,
                    y        = (int)m_RightButtonDownPoint.Y,
                    Type     = typeof(DescriptionView).FullName,
                };
                try
                {
                    DescriptionView desc = new DescriptionView(frm.Value, data);

                    data.JsonData = desc.GetJsonData();
                    data.id       = Helper.Client.InvokeSync <int>("UpdateInterfaceInModule", data);
                    data.ChangedProperties.Clear();

                    desc.Margin = new Thickness(m_RightButtonDownPoint.X, m_RightButtonDownPoint.Y, 0, 0);
                    m_Grid.Children.Add(desc);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(MainWindow.instance, ex.Message);
                }
            }
        }
Exemplo n.º 2
0
 public void ClearSelected()
 {
     foreach (var item in m_Grid.Children)
     {
         if (item is DescriptionView)
         {
             DescriptionView view = (DescriptionView)item;
             view.IsSelected = false;
         }
     }
 }
Exemplo n.º 3
0
        void afterMoving()
        {
            //重新调整所有箭头
            Panel           parent = this.Parent as Panel;
            DescriptionView target = null;

            foreach (FrameworkElement item in parent.Children)
            {
                if (item.Equals(this) == false && item is DescriptionView)
                {
                    target = item as DescriptionView;
                    if (target.m_jsonObj.Connects.Count(m => m.ToWhere == this.InterfaceInModule.id) > 0)
                    {
                        target.ResetConnects();
                    }
                }
            }
            this.ResetConnects();
        }
Exemplo n.º 4
0
 void loadItems()
 {
     try
     {
         var items = Helper.Client.InvokeSync <EJ.InterfaceInModule[]>("GetInterfaceInModule", this.InterfaceItemNode.Module.id.Value);
         foreach (var item in items)
         {
             Type type = typeof(InterfaceItemNode).Assembly.GetType(item.Type);
             if (type == typeof(UI.DescriptionView))
             {
                 DescriptionView view = new DescriptionView("", item);
                 view.LoadJsonData(item.JsonData);
                 view.Margin = new Thickness((double)item.x, (double)item.y, 0, 0);
                 if (item.width != null)
                 {
                     view.Width  = item.width.Value;
                     view.Height = item.height.Value;
                 }
                 m_Grid.Children.Add(view);
             }
             else if (type == typeof(UI.ClassView))
             {
                 ClassView view = new ClassView(item);
                 view.Margin = new Thickness((double)item.x, (double)item.y, 0, 0);
                 m_Grid.Children.Add(view);
             }
         }
         this.Dispatcher.BeginInvoke(new Action(() =>
         {
             foreach (FrameworkElement view in m_Grid.Children)
             {
                 if (view is DescriptionView)
                 {
                     ((DescriptionView)view).LoadConnects();
                 }
             }
         }), System.Windows.Threading.DispatcherPriority.Loaded, null);
     }
     catch (Exception ex)
     {
         Helper.ShowError(ex);
     }
 }
Exemplo n.º 5
0
        protected override void OnMouseUp(System.Windows.Input.MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Right)
            {
                return;
            }

            if (m_titleMoving || m_changingSize)
            {
                e.Handled = true;
                e.MouseDevice.Capture(null);


                InterfaceInModule.x = (int)this.Margin.Left;
                InterfaceInModule.y = (int)this.Margin.Top;
                if (m_changingSize)
                {
                    m_changingSize           = false;
                    InterfaceInModule.width  = (int)this.Width;
                    InterfaceInModule.height = (int)this.Height;
                }
                Helper.Client.InvokeSync <string>("UpdateInterfaceInModule", InterfaceInModule);

                if (m_titleMoving)
                {
                    m_titleMoving = false;
                    this.OnMoveCompleted( );
                }
            }
            else if (m_connecting)
            {
                e.Handled    = true;
                m_connecting = false;
                e.MouseDevice.Capture(null);

                if (m_connectingArrow != null)
                {
                    Panel           parent = this.Parent as Panel;
                    DescriptionView target = null;
                    foreach (FrameworkElement item in parent.Children)
                    {
                        if (item.Equals(this) == false && item is DescriptionView)
                        {
                            target = item as DescriptionView;
                            Point p = this.TranslatePoint(m_connectingArrow.EndPoint, target);
                            if (p.X > 0 && p.Y > 0 && p.X < target.ActualWidth && p.Y < target.ActualHeight)
                            {
                                break;
                            }
                            target = null;
                        }
                    }
                    if (target != null)
                    {
                        Point   p       = this.TranslatePoint(m_connectingArrow.EndPoint, target);
                        Connect connect = new Connect()
                        {
                            ArrowFromWhere = m_connectingFromWhere,
                            ToWhere        = target.InterfaceInModule.id.Value,
                            x1             = m_connectingArrow.StartPoint.X,
                            y1             = m_connectingArrow.StartPoint.Y,
                            x2             = p.X,
                            y2             = p.Y,
                        };
                        this.AddConnect(connect);
                        this.m_jsonObj.Connects.Add(connect);
                        InterfaceInModule.JsonData = m_jsonObj.ToJsonString();
                        try
                        {
                            Helper.Client.InvokeSync <string>("UpdateInterfaceInModule", InterfaceInModule);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(MainWindow.instance, ex.Message);
                        }
                    }
                    m_grid.Children.Remove(m_connectingArrow);
                    m_connectingArrow = null;
                }
            }
        }
Exemplo n.º 6
0
        internal void AddConnect(Connect connect)
        {
            ArrowLineWithText arrow = new ArrowLineWithText();

            arrow.MouseDown += arrow_MouseDown;
            arrow.MouseMove += arrow_MouseMove;
            arrow.MouseUp   += arrow_MouseUp;
            arrow.Tag        = connect;
            Panel           parent = this.Parent as Panel;
            DescriptionView target = null;

            foreach (FrameworkElement item in parent.Children)
            {
                if (item.Equals(this) == false && item is DescriptionView)
                {
                    target = item as DescriptionView;
                    if (target.InterfaceInModule.id == connect.ToWhere)
                    {
                        break;
                    }
                    target = null;
                }
            }
            if (target == null)
            {
                return;
            }
            if (connect.ArrowFromWhere == ArrowFromWhere.LeftRight)
            {
                if (target.Margin.Left > this.Margin.Left)
                {
                    arrow.StartPoint = new Point(this.ActualWidth, connect.y1);
                    Point p = target.TranslatePoint(new Point(0, connect.y2), this);
                    arrow.EndPoint = new Point(p.X, p.Y);
                }
                else
                {
                    arrow.StartPoint = new Point(0, connect.y1);
                    Point p = target.TranslatePoint(new Point(target.ActualWidth, connect.y2), this);
                    arrow.EndPoint = new Point(p.X, p.Y);
                }
            }
            else
            {
                if (target.Margin.Top > this.Margin.Top)
                {
                    arrow.StartPoint = new Point(connect.x1, this.ActualHeight);
                    Point p = target.TranslatePoint(new Point(connect.x2, 0), this);
                    arrow.EndPoint = new Point(p.X, p.Y);
                }
                else
                {
                    arrow.StartPoint = new Point(connect.x1, 0);
                    Point p = target.TranslatePoint(new Point(connect.x2, target.ActualHeight), this);
                    arrow.EndPoint = new Point(p.X, p.Y);
                }
            }
            arrow.Stroke          = Brushes.Blue;
            arrow.StrokeThickness = 1;
            arrow.Cursor          = Cursors.Hand;
            arrow.TextAlignment   = TextAlignment.Center;
            arrow.Margin          = new Thickness(0, 0, -100000, -10000000);
            arrow.IsTextUp        = true;
            arrow.Text            = connect.Text;
            m_grid.Children.Add(arrow);
        }
Exemplo n.º 7
0
        internal bool ResetConnect(Connect connect)
        {
            ArrowLineWithText arrow = null;

            foreach (var item in m_grid.Children)
            {
                if (item is ArrowLineWithText)
                {
                    arrow = (ArrowLineWithText)item;
                    if (arrow.Tag == connect)
                    {
                        break;
                    }
                    arrow = null;
                }
            }
            if (arrow == null)
            {
                return(false);
            }
            Panel           parent = this.Parent as Panel;
            DescriptionView target = null;

            foreach (FrameworkElement item in parent.Children)
            {
                if (item.Equals(this) == false && item is DescriptionView)
                {
                    target = item as DescriptionView;
                    if (target.InterfaceInModule.id == connect.ToWhere)
                    {
                        break;
                    }
                    target = null;
                }
            }
            if (target == null)
            {
                //目标没有了,留个箭头干嘛
                m_grid.Children.Remove(arrow);
                return(false);
            }
            if (connect.ArrowFromWhere == ArrowFromWhere.LeftRight)
            {
                if (target.Margin.Left > this.Margin.Left)
                {
                    arrow.StartPoint = new Point(this.ActualWidth, connect.y1);
                    Point p = target.TranslatePoint(new Point(0, connect.y2), this);
                    arrow.EndPoint = new Point(p.X, p.Y);
                }
                else
                {
                    arrow.StartPoint = new Point(0, connect.y1);
                    Point p = target.TranslatePoint(new Point(target.ActualWidth, connect.y2), this);
                    arrow.EndPoint = new Point(p.X, p.Y);
                }
            }
            else
            {
                if (target.Margin.Top > this.Margin.Top)
                {
                    arrow.StartPoint = new Point(connect.x1, this.ActualHeight);
                    Point p = target.TranslatePoint(new Point(connect.x2, 0), this);
                    arrow.EndPoint = new Point(p.X, p.Y);
                }
                else
                {
                    arrow.StartPoint = new Point(connect.x1, 0);
                    Point p = target.TranslatePoint(new Point(connect.x2, target.ActualHeight), this);
                    arrow.EndPoint = new Point(p.X, p.Y);
                }
            }
            if (!string.IsNullOrEmpty(arrow.Text))
            {
                arrow.InvalidateVisual();
            }
            return(true);
        }