예제 #1
0
        private void DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
        {
            DragThumb tb = (sender as DragThumb);

            if ((tb == null) || (tb.IsReadOnly))
            {
                return;
            }

            IsDragging = true;

            if (bMultiSelect) //多选情况下
            {
                tb.IsSelected = !tb.IsSelected;
            }
            else
            {
                tb.IsSelected = true;
            }
            if (tb.IsSelected)
            {
                _CurSelectedDragThumb = tb;  //将当前的设置为选择
            }

            _orthogonalBeginPoint = new Point(tb.Position.X, tb.Position.Y);
        }
예제 #2
0
 void DesignerItem_Loaded(object sender, RoutedEventArgs e)
 {
     Console.Write("item loaded");
     if (base.Template != null)
     {
         ContentPresenter contentPresenter =
             this.Template.FindName("PART_ContentPresenter", this) as ContentPresenter;
         if (contentPresenter != null)
         {
             UIElement contentVisual = VisualTreeHelper.GetChild(contentPresenter, 0) as UIElement;
             if (contentVisual != null)
             {
                 DragThumb thumb = this.Template.FindName("PART_DragThumb", this) as DragThumb;
                 if (thumb != null)
                 {
                     ControlTemplate template =
                         DesignerItem.GetDragThumbTemplate(contentVisual) as ControlTemplate;
                     if (template != null)
                     {
                         thumb.Template = template;
                     }
                     (this.Template.FindName("lblComponentName", this) as Label).Content = primaryField;
                     (this.Template.FindName("lblComponentDesc", this) as Label).Content = secondaryField;
                 }
             }
         }
     }
 }
예제 #3
0
 void DesignerItem_Loaded(object sender, RoutedEventArgs e)
 {
     if (base.Template != null)
     {
         ContentPresenter contentPresenter =
             this.Template.FindName("PART_ContentPresenter", this) as ContentPresenter;
         if (contentPresenter != null)
         {
             UIElement contentVisual = VisualTreeHelper.GetChild(contentPresenter, 0) as UIElement;
             if (contentVisual != null)
             {
                 DragThumb thumb = this.Template.FindName("PART_DragThumb", this) as DragThumb;
                 if (thumb != null)
                 {
                     ControlTemplate template =
                         DesignerItem.GetDragThumbTemplate(contentVisual) as ControlTemplate;
                     if (template != null)
                     {
                         thumb.Template = template;
                     }
                     if (this.BookmarkBase == null || this.BookmarkBase.NodeType == string.Empty)
                     {
                         this.BookmarkBase = BookmarkFactory.GetBookmark(EnumHelper.GetEnumByString <ActivityTypeEnum>((contentPresenter.Content is Grid) ? (contentPresenter.Content as Grid).Tag.ToString()
                         : (contentPresenter.Content as System.Windows.Shapes.Shape).Tag.ToString()));
                     }
                 }
             }
         }
     }
 }
 void DesignerItem_Loaded(object sender, RoutedEventArgs e)
 {
     if (base.Template != null)
     {
         ContentPresenter contentPresenter =
             this.Template.FindName("PART_ContentPresenter", this) as ContentPresenter;
         if (contentPresenter != null)
         {
             UIElement contentVisual = VisualTreeHelper.GetChild(contentPresenter, 0) as UIElement;
             if (contentVisual != null)
             {
                 DragThumb thumb = this.Template.FindName("PART_DragThumb", this) as DragThumb;
                 if (thumb != null)
                 {
                     ControlTemplate template =
                         DesignerItem.GetDragThumbTemplate(contentVisual) as ControlTemplate;
                     if (template != null)
                     {
                         thumb.Template = template;
                     }
                 }
             }
         }
     }
 }
예제 #5
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (ColumnLocal.ActualWidth > (this.ActualWidth - 15.0))
            {
                ColumnLocal.Width = new GridLength(this.ActualWidth - 15.0);
            }

            this.PreviewMouseUp += new MouseButtonEventHandler(window_PreviewMouseUp);
            this.Drop           += new DragEventHandler(window_Drop);
            this.Closing        += new CancelEventHandler(Window_Closing);
            this.GiveFeedback   += new GiveFeedbackEventHandler(window_GiveFeedback);

            ClientHelper.Owner           = this;
            ClientHelper.OnLock         += new ClientHelper.ClientHandler(Lock);
            ClientHelper.OnUnLock       += new ClientHelper.ClientHandler(UnLock);
            ClientHelper.OnConnecting   += new ClientHelper.StateHandler(Connecting);
            ClientHelper.OnConnected    += new ClientHelper.StateHandler(Connected);
            ClientHelper.OnDisconnected += new ClientHelper.StateHandler(Disconnected);

            ButtonServerConnect.Focus();

            SetPhrases();

            DragThumb.Set(this);

            await setLocalList(LocalHelper.Home);

            LocalHelper.OnListChanged += new LocalHelper.DirectoryHandler(localListChanged);
            TaskbarHelper.MainTaskbar  = MainTaskbar;

            AppMessage.Set(DetailList);
            DetailList.ItemsSource = AppMessage.Items;

            LabelServerTime.DataContext  = ClientHelper.Counts;
            LabelServerCount.DataContext = ClientHelper.Counts;

            ((INotifyPropertyChanged)(ServerList.View as GridView).Columns[0]).PropertyChanged += new PropertyChangedEventHandler(WidthPropertyChanged);
            hideServerToolbarAnimation.Completed += new EventHandler(hideServerToolbarAnimationCompleted);
            ServerItemsToolbarAnimation.Freeze();
            hideServerToolbarAnimation.Freeze();

            DragSelection.Register(this, LocalList, 0.0, 0.0, "ListBoxItem");
            DragSelection.Register(this, ServerList, 0.0, 20.0, "ListViewItem");

            DragWatcher.Source    = "PlusFTP.DragItems";
            DragWatcher.OnDraged += new DragWatcher.DragWatcherHandler(DragWatcher_Draged);

            AppLanguage.OnUpdated += new AppLanguage.UpdatedHandler(LanguageUpdated);

            CryptoHashing.Password = "******";

            VersionHelper.AppUrlHomePage = "http://PlusFTP.com/";
            VersionHelper.VersionUrl     = "http://PlusFTP.com/v";
            VersionHelper.NewAppUrl      = "http://PlusFTP.com/download/";
            if (AppSettings.Get("App", "CheckVersion", true) && (bool)await VersionHelper.Check())
            {
                NewVersionWindow.Initialize(this);
            }
        }
예제 #6
0
 public void SetZIndex(DragThumb dragImage, int zIndex)
 {
     if (dragImage == null)
     {
         return;
     }
     dragImage.ZIndex = zIndex;
 }
예제 #7
0
 /// <summary>
 /// 设置到最前面
 /// </summary>
 /// <param name="dragImage"></param>
 public void BringToFront(DragThumb dragImage)
 {
     if (dragImage == null)
     {
         return;
     }
     dragImage.ZIndex = DragThumbs.Count;
     ReOrderAllDragImage();
 }
예제 #8
0
 /// <summary>
 /// 设置到最底层
 /// </summary>
 /// <param name="dragImage"></param>
 public void SendToBack(DragThumb dragImage)
 {
     if (dragImage == null)
     {
         return;
     }
     dragImage.ZIndex = -1;
     ReOrderAllDragImage();
 }
예제 #9
0
        private void button_Copy_Click(object sender, RoutedEventArgs e)
        {
            DragThumb di = canvas1.CurSelectedDragThumb;

            if (di == null)
            {
                return;
            }
            di.Source = new BitmapImage(new Uri(tbImage.Text));
        }
예제 #10
0
        private void ReOrderAllDragImage()
        {
            var orderDragImages = DragThumbs.OrderBy(c => c.ZIndex).ToList();

            for (int i = 0; i <= orderDragImages.Count() - 1; i++)
            {
                DragThumb di = orderDragImages[i];
                SetZIndex(di, i);
            }
        }
        private void BuildDragThumb(ref DragThumb thumb)
        {
            if (thumb != null)
            {
                return;
            }

            thumb = new DragThumb();

            _thumbsCanvas.Children.Add(thumb);
        }
예제 #12
0
        void DesignerItem_Loaded(object sender, RoutedEventArgs e)
        {
            if (base.Template != null)
            {
                ContentPresenter contentPresenter =
                    this.Template.FindName("PART_ContentPresenter", this) as ContentPresenter;

                if (contentPresenter != null)
                {
                    UIElement contentVisual = VisualTreeHelper.GetChild(contentPresenter, 0) as UIElement;

                    if (contentVisual != null)
                    {
                        DragThumb thumb = this.Template.FindName("PART_DragThumb", this) as DragThumb;
                        if (thumb != null)
                        {
                            ControlTemplate template =
                                DesignerItem.GetDragThumbTemplate(contentVisual) as ControlTemplate;
                            if (template != null)
                            {
                                thumb.Template = template;
                            }

                            //Para que sea responsive
                            this.Height = (double)contentVisual.GetAnimationBaseValue(HeightProperty);
                            this.Width  = (double)contentVisual.GetAnimationBaseValue(WidthProperty);

                            /*Traigo la TAG del elemento hijo y la convierto en string*/
                            var tag = (contentVisual.GetAnimationBaseValue(TagProperty) ?? "").ToString();
                            if (tag == "DIAG")
                            {
                                this.Tag = "DIAG";        //Le pongo la TAG al item del diagram designer
                            }
                            else if (tag == "COND")       //Si es un nodo_condicion le cambio la altura
                            {
                                this.Height = 60;
                            }
                            else if (tag == "REFR")
                            {
                                this.Tag = "REFR";
                            }
                            /*Traigo el Uid del elemento hijo y la convierto en string*/
                            var uid = (contentVisual.GetAnimationBaseValue(UidProperty) ?? "").ToString();
                            if (uid == "Principal")
                            {
                                this.Uid = "Principal";      //Le pongo la uid al item del diagram designer
                            }
                        }
                    }
                }
            }
        }
예제 #13
0
        /// <summary>
        /// 移除控件
        /// </summary>
        /// <param name="dragThumb"></param>
        public void RemoveDragThumb(DragThumb dragThumb)
        {
            if (dragThumb == null)
            {
                return;
            }
            this.Children.Remove(dragThumb);

            bSaved = false;
            SelectDragThumbs.Remove(dragThumb);
            DragThumbs.Remove(dragThumb);
            ReOrderAllDragImage();  //重新排序
        }
        public UIImageControl()
        {
            InitializeComponent();
            DragThumb.ApplyTemplate();
            ControlTemplate template = DragThumb.Template;

            _imgMainImage = (Image)template.FindName("uiObjImage", DragThumb);
            _scrollviewer = (ScrollViewer)template.FindName("UIScrollViewer", DragThumb);
            RegisterEvents();
            _imgMainImage.MouseDown += Image_MouseDown;
            _emSelectedState         = emSelectedState.Selected;
            topleft     = new Point();
            bottomright = new Point();
        }
예제 #15
0
        /// <summary>
        /// 下降一层
        /// </summary>
        /// <param name="dragImage"></param>
        public void BackOnce(DragThumb dragImage)
        {
            if (dragImage == null)
            {
                return;
            }
            DragThumb tag = GetDragImageByZIndex(dragImage.ZIndex - 1);

            if (tag == null)
            {
                return;              //已经是最底层了
            }
            tag.ZIndex++;
            dragImage.ZIndex--;
        }
예제 #16
0
        /// <summary>
        /// 上移一层
        /// </summary>
        /// <param name="dragThumb"></param>
        public void FrontOnce(DragThumb dragThumb)
        {
            if (dragThumb == null)
            {
                return;
            }
            DragThumb tag = GetDragImageByZIndex(dragThumb.ZIndex + 1);

            if (tag == null)
            {
                return;              //已经是最上层了
            }
            tag.ZIndex--;
            dragThumb.ZIndex++;
        }
예제 #17
0
        private void bVSpan_ItemClick(object sender, ItemClickEventArgs e)
        {
            //垂直平均
            if (cvMain.SelectDragThumbs.Count <= 2)
            {
                return;
            }

            DragThumb firstThumb = cvMain.SelectDragThumbs.OrderBy(c => c.Position.Y).FirstOrDefault();
            DragThumb lastThumb  = cvMain.SelectDragThumbs.OrderByDescending(c => (c.Position.Y + c.Height)).FirstOrDefault();

            if (firstThumb == null || lastThumb == null)
            {
                return;
            }

            double minTop = firstThumb.Position.Y;

            double maxBotton = lastThumb.Position.Y + lastThumb.Height;

            double span = (maxBotton - minTop - cvMain.SelectDragThumbs.Sum(c => c.Height)) /
                          (cvMain.SelectDragThumbs.Count - 1);

            if (span < 0)
            {
                span = 0;
            }

            double preBotton = firstThumb.Position.Y + firstThumb.Height;

            foreach (DragThumb thumb in cvMain.SelectDragThumbs.OrderBy(c => c.Position.Y))
            {
                if (thumb.Equals(firstThumb))
                {
                    continue;
                }

                double newTop = preBotton + span;
                thumb.MoveToNewPosition(thumb.Position.X, newTop, true);

                preBotton = thumb.Position.Y + thumb.Height;
            }
        }
예제 #18
0
        public override void OnApplyTemplate()
        {
            ContentPresenter contentPresenter = this.GetTemplateChild("PART_ContentPresenter") as ContentPresenter;
            DragThumb        thumb            = this.GetTemplateChild("PART_DragThumb") as DragThumb;

            if (thumb != null)
            {
                ControlTemplate template =
                    DesignerItem.GetDragThumbTemplate(Content as UIElement) as ControlTemplate;
                if (template != null)
                {
                    thumb.Template = template;
                }
            }

            ConnectorDecorator = this.GetTemplateChild("PART_ConnectorDecorator") as Control;

            base.OnApplyTemplate();
        }
예제 #19
0
        private void bHSpan_ItemClick(object sender, ItemClickEventArgs e)
        {
            //水平平均
            if (cvMain.SelectDragThumbs.Count <= 2)
            {
                return;
            }

            DragThumb firstThumb = cvMain.SelectDragThumbs.OrderBy(c => c.Position.X).FirstOrDefault();
            DragThumb lastThumb  = cvMain.SelectDragThumbs.OrderByDescending(c => (c.Position.X + c.Width)).FirstOrDefault();

            if (firstThumb == null || lastThumb == null)
            {
                return;
            }

            double minLeft = firstThumb.Position.X;

            double maxRight = lastThumb.Position.X + lastThumb.Width;

            double span = (maxRight - minLeft - cvMain.SelectDragThumbs.Sum(c => c.Width)) /
                          (cvMain.SelectDragThumbs.Count - 1);

            if (span < 0)
            {
                span = 0;
            }

            double preRight = firstThumb.Position.X + firstThumb.Width;

            foreach (DragThumb thumb in cvMain.SelectDragThumbs.OrderBy(c => c.Position.X))
            {
                if (thumb.Equals(firstThumb))
                {
                    continue;
                }

                double newLeft = preRight + span;
                thumb.MoveToNewPosition(newLeft, thumb.Position.Y, true);

                preRight = thumb.Position.X + thumb.Width;
            }
        }
예제 #20
0
        void DesignerItem_Loaded(object sender, RoutedEventArgs e)
        {
            // if DragThumbTemplate and ConnectorDecoratorTemplate properties of this class
            // are set these templates are applied;
            // Note: this method is only executed when the Loaded event is fired, so
            // setting DragThumbTemplate or ConnectorDecoratorTemplate properties after
            // will have no effect.
            if (base.Template != null)
            {
                ContentPresenter contentPresenter =
                    this.Template.FindName("PART_ContentPresenter", this) as ContentPresenter;
                if (contentPresenter != null)
                {
                    UIElement contentVisual = VisualTreeHelper.GetChild(contentPresenter, 0) as UIElement;
                    if (contentVisual != null)
                    {
                        DragThumb thumb = this.Template.FindName("PART_DragThumb", this) as DragThumb;
                        Control   connectorDecorator = this.Template.FindName("PART_ConnectorDecorator", this) as Control;

                        if (thumb != null)
                        {
                            ControlTemplate template =
                                DesignerItem.GetDragThumbTemplate(contentVisual) as ControlTemplate;
                            if (template != null)
                            {
                                thumb.Template = template;
                            }
                        }


                        if (connectorDecorator != null)
                        {
                            ControlTemplate template =
                                DesignerItem.GetConnectorDecoratorTemplate(contentVisual) as ControlTemplate;
                            if (template != null)
                            {
                                connectorDecorator.Template = template;
                            }
                        }
                    }
                }
            }
        }
예제 #21
0
파일: cmdComment.cs 프로젝트: mff-uk/xcase
 protected override void InitializeCommand(NewPositionableElementMacroCommand command)
 {
     base.InitializeCommand(command);
     ((NewModelCommentToDiagramCommand)command).Text = text;
     if (ActiveDiagramView.SelectedRepresentants.Count() == 1)
     {
         Element element = ActiveDiagramView.ElementRepresentations.GetElementRepresentedBy(ActiveDiagramView.SelectedRepresentants.First());
         if (element is Comment)
         {
             if ((element as Comment).AnnotatedElement != null)
             {
                 ((NewModelCommentToDiagramCommand)command).AnnotatedElement = (element as Comment).AnnotatedElement;
             }
         }
         else
         {
             ((NewModelCommentToDiagramCommand)command).AnnotatedElement = element;
         }
         DragThumb   thumb      = ActiveDiagramView.SelectedRepresentants.First() as DragThumb;
         ISelectable selectable = ActiveDiagramView.SelectedRepresentants.First() as ISelectable;
         if (command.X == 40 && command.Y == 40)
         {
             if (thumb != null)
             {
                 command.X = (thumb).ActualWidth + 20;
                 command.Y = 20;
             }
             else if (selectable != null)
             {
                 command.X = selectable.GetBounds().GetCenter().X + 40;
                 command.X = selectable.GetBounds().GetCenter().Y;
             }
         }
         else
         {
             if (thumb != null)
             {
                 command.X -= (thumb).Left;
                 command.Y -= (thumb).Top;
             }
         }
     }
 }
예제 #22
0
        /// <summary>
        /// 重新绘制宽度、高度等高线
        /// </summary>
        /// <param name="curThumb">当前的控件</param>
        /// <param name="bDrawWidth">是否绘制宽度</param>
        /// <param name="bDrawHeight">是否绘制高度</param>
        public void ReDrawWidthHeightLines(DragThumb curThumb, bool bDrawWidth, bool bDrawHeight)
        {
            ClearWidthHeightLines();

            //Top Buttom HCenter Left Rigth VCenter
            double TOLERANCE = 0.00001;

            foreach (DragThumb dt in DragThumbs)
            {
                if (dt.Equals(curThumb))
                {
                    continue;
                }

                #region 绘制宽度

                if (bDrawWidth)
                {
                    if (Math.Abs(curThumb.Width - dt.Width) < TOLERANCE)
                    {
                        curThumb.DrawWidthLine(this);
                        dt.DrawWidthLine(this);
                    }
                }

                #endregion

                #region 绘制高度

                if (bDrawHeight)
                {
                    if (Math.Abs(curThumb.Height - dt.Height) < TOLERANCE)
                    {
                        curThumb.DrawHeightLine(this);
                        dt.DrawHeightLine(this);
                    }
                }

                #endregion
            }
        }
예제 #23
0
        private void showDragThumb(IDataObject idb)
        {
            ImageSource icon;
            int         count = 0;

            string[] files = idb.GetData(DataFormats.FileDrop) as string[];

            if ((files.Length == 1) && (files[0].Ends(DragWatcher.Source)))
            {
                icon  = IconHelper.Get(CachedItems[0].FullName, CachedItems[0].IsFile, CachedItems[0].Extension, false);
                count = CachedItems.Length;
            }
            else
            {
                bool isFile = FileHelper.Exists(files[0]);
                icon  = IconHelper.Get(files[0], isFile, isFile ? FileHelper.GetExtension(files[0]) : string.Empty, false);
                count = files.Length;
            }

            DragThumb.Show(icon, count);
        }
 void DesignerItem_Loaded(object sender, RoutedEventArgs e)
 {
     if (base.Template != null)
     {
         //var tmp = (ControlTemplate)FindResource("DesignerItem");
         this.Caption    = (Label)Template.FindName("lblCaption", this);
         Caption.Content = "N/A";
         if (this.DataBinding != null)
         {
             this.DataBinding.SetMyLabel(this.Caption);
             this.DataBinding.Name = this.DataBinding.Caption;
             this.Caption.Content  = this.DataBinding.Name;
         }
         else
         {
             DataBinding = new ExecutionUnitDataBinding(Caption);
         }
         ContentPresenter contentPresenter =
             this.Template.FindName("PART_ContentPresenter", this) as ContentPresenter;
         if (contentPresenter != null)
         {
             UIElement contentVisual = VisualTreeHelper.GetChild(contentPresenter, 0) as UIElement;
             if (contentVisual != null)
             {
                 DragThumb thumb = this.Template.FindName("PART_DragThumb", this) as DragThumb;
                 if (thumb != null)
                 {
                     ControlTemplate template =
                         DesignerItem.GetDragThumbTemplate(contentVisual) as ControlTemplate;
                     if (template != null)
                     {
                         thumb.Template = template;
                     }
                 }
             }
         }
     }
 }
예제 #25
0
 void DesignerItem_Loaded(object sender, RoutedEventArgs e)
 {
     if (base.Template != null)
     {
         ContentPresenter contentPresenter =
             this.Template.FindName("PART_ContentPresenter", this) as ContentPresenter;
         if (contentPresenter != null)
         {
             UIElement contentVisual = VisualTreeHelper.GetChild(contentPresenter, 0) as UIElement;
             if (contentVisual != null)
             {
                 DragThumb thumb = this.Template.FindName("PART_DragThumb", this) as DragThumb;
                 if (thumb != null)
                 {
                     ControlTemplate template =
                         DesignerItem.GetDragThumbTemplate(contentVisual) as ControlTemplate;
                     if (template != null)
                     {
                         thumb.Template = template;
                     }
                     /*Traigo la TAG del elemento hijo y la convierto en string*/
                     var tag = (contentVisual.GetAnimationBaseValue(TagProperty) ?? "").ToString();
                     if (tag == "DIAG")
                     {
                         this.Tag = "DIAG";    //Le pongo la TAG al item del diagram designer
                     }
                     /*Traigo el Uid del elemento hijo y la convierto en string*/
                     var uid = (contentVisual.GetAnimationBaseValue(UidProperty) ?? "").ToString();
                     if (uid == "Inicializar")
                     {
                         this.Uid = "Inicializar"; //Le pongo la uid al item del diagram designer
                     }
                 }
             }
         }
     }
 }
예제 #26
0
        private DragThumb GetDragImageByZIndex(int zIndex)
        {
            DragThumb di = DragThumbs.Find(c => c.ZIndex == zIndex);

            return(di);
        }
예제 #27
0
 private void window_PreviewMouseUp(object sender, MouseButtonEventArgs e)
 {
     draggingFrom = DraggingFrom.None;
     DragThumb.Hide();
 }
예제 #28
0
        public bool LoadFile(string filePath)
        {
            if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath))
            {
                return(false);
            }

            XDocument xmlDoc = new XDocument();

            xmlDoc = XDocument.Load(filePath);

            XElement root = xmlDoc.Elements("root").FirstOrDefault();

            if (root == null)
            {
                return(false);
            }

            XElement drags = root.Elements("FlowDesigns").FirstOrDefault();

            if (drags == null)
            {
                return(false);
            }

            RemoveAllDragThumb(); //清除所有

            IEnumerable <XElement> nodes = drags.Elements();

            foreach (XElement item in nodes)
            {
                string name        = item.Attribute("Name")?.Value ?? "";
                string position    = item.Attribute("Position")?.Value ?? "0,0";
                string size        = item.Attribute("Size")?.Value ?? "10,10";
                string source      = item.Attribute("Source")?.Value ?? "";              //图片路径
                string sBackground = item.Attribute("Background")?.Value ?? "#FF00ACFF"; //背景色
                Brush  background  = new SolidColorBrush((Color)ColorConverter.ConvertFromString(sBackground));

                string sBorderBrush = item.Attribute("BorderBrush")?.Value ?? "White"; //边框
                Brush  borderBrush  = new SolidColorBrush((Color)ColorConverter.ConvertFromString(sBorderBrush));

                EmFlowCtrlType ctrlType =
                    (EmFlowCtrlType)
                    System.Enum.Parse(typeof(EmFlowCtrlType), item.Attribute("ItemType")?.Value ?? "None");      //控件类型
                EmBasicShape shapeType =
                    (EmBasicShape)System.Enum.Parse(typeof(EmBasicShape), item.Attribute("Shape")?.Value ?? "None");

                DragThumb newThumb = new DragThumb();

                if (ctrlType == EmFlowCtrlType.Image)
                {
                    if (!source.Contains(":"))
                    {
                        source = System.Environment.CurrentDirectory + (source[0] == '/' ? "" : "/") + source;
                    }
                    if (File.Exists(source))
                    {
                        newThumb = AddDragImage(name, SafeConverter.SafeToSize(size),
                                                SafeConverter.SafeToPoint(position),
                                                new BitmapImage(new Uri(source)), background, borderBrush);
                    }
                }
                else if (ctrlType == EmFlowCtrlType.PolygonSharp)
                {
                    newThumb = AddDragShape(name, shapeType, SafeConverter.SafeToSize(size),
                                            SafeConverter.SafeToPoint(position), background, borderBrush);
                }
                else if (ctrlType == EmFlowCtrlType.CircleSharp)
                {
                    newThumb = AddDragCircle(name, SafeConverter.SafeToSize(size),
                                             SafeConverter.SafeToPoint(position), background, borderBrush);
                }
                else if (ctrlType == EmFlowCtrlType.Video)
                {
                    newThumb = AddDragVideo(name, SafeConverter.SafeToSize(size),
                                            SafeConverter.SafeToPoint(position), source);
                }
                string sForeground = item.Attribute("Foreground")?.Value ?? "#FF000000"; //字体颜色
                Brush  foreground  = new SolidColorBrush((Color)ColorConverter.ConvertFromString(sForeground));
                newThumb.Foreground = foreground;
                string sFontWeight          = item.Attribute("FontWeight")?.Value ?? "Normal"; //文本粗体
                FontWeightConverter convert = new FontWeightConverter();
                newThumb.FontWeight = (FontWeight)convert.ConvertFromString(sFontWeight);
                string sFontSize = item.Attribute("FontSize")?.Value ?? "12";  //文字大小
                newThumb.FontSize = Double.Parse(sFontSize);

                newThumb.MonitorItem      = SafeConverter.SafeToBool(item.Attribute("Monitor"));          //是否监控
                newThumb.ReadOnlyCanClick = SafeConverter.SafeToBool(item.Attribute("ReadOnlyCanClick")); //是否可以单击

                string text = item.Attribute("Text")?.Value ?? "";
                newThumb.Text = text;
            }
            return(true);
        }
예제 #29
0
        /// <summary>
        /// 重新绘制对齐线
        /// </summary>
        /// <param name="curThumb">当前的控件</param>
        /// <param name="bDrawTop">是否绘制Top</param>
        /// <param name="bDrawBottom">是否绘制Bottom</param>
        /// <param name="bDrawHCenter">是否绘制水平中线</param>
        /// <param name="bDrawLeft">是否绘制Left</param>
        /// <param name="bDrawRight">是否绘制Right</param>
        /// <param name="bDrawVCenter">是否绘制垂直中线</param>
        public void ReDrawAlignLines(DragThumb curThumb, bool bDrawTop, bool bDrawBottom, bool bDrawHCenter, bool bDrawLeft, bool bDrawRight, bool bDrawVCenter)
        {
            ClearAlignLies();

            #region 绘制对齐线

            foreach (DragThumb dt in DragThumbs)
            {
                if (dt.Equals(curThumb))
                {
                    continue;
                }
                if (SelectDragThumbs.Contains(dt))
                {
                    continue;                                 //内部的线不绘制
                }
                double theLeft    = dt.Position.X;
                double theRight   = theLeft + dt.Width;
                double theVCenter = theLeft + (dt.Width / 2);  //垂直中心

                double theTop     = dt.Position.Y;
                double theBottom  = theTop + dt.Height;
                double theHCenter = theTop + (dt.Height / 2); //水平中心

                //Top Buttom HCenter Left Rigth VCenter
                double TOLERANCE = 0.00001;

                #region Draw Top

                if (bDrawTop)
                {
                    if (Math.Abs(theTop - curThumb.Position.Y) < TOLERANCE)
                    {
                        Line line = NewAlignLine();

                        if (theLeft + dt.Width < curThumb.Position.X) //基准在左边
                        {
                            line.X1 = theLeft + dt.Width;
                        }
                        else
                        {
                            line.X1 = theLeft;
                        }
                        if (curThumb.Position.X + curThumb.Width < theLeft) //基准在右边
                        {
                            line.X2 = curThumb.Position.X + curThumb.Width;
                        }
                        else
                        {
                            line.X2 = curThumb.Position.X;
                        }

                        line.Y1 = curThumb.Position.Y;
                        line.Y2 = curThumb.Position.Y;

                        AlignLines.Add(line);
                        this.Children.Add(line);
                    }
                }

                #endregion

                #region Draw Bottom

                if (bDrawBottom)
                {
                    if (Math.Abs(curThumb.Position.Y + curThumb.Height - theBottom) < TOLERANCE)
                    {
                        Line line = NewAlignLine();
                        if (theLeft + dt.Width < curThumb.Position.X) //基准在左边
                        {
                            line.X1 = theLeft + dt.Width;
                        }
                        else
                        {
                            line.X1 = theLeft;
                        }
                        if (curThumb.Position.X + curThumb.Width < theLeft) //基准在右边
                        {
                            line.X2 = curThumb.Position.X + curThumb.Width;
                        }
                        else
                        {
                            line.X2 = curThumb.Position.X;
                        }

                        line.Y1 = theBottom;
                        line.Y2 = theBottom;

                        AlignLines.Add(line);
                        this.Children.Add(line);
                    }
                }

                #endregion

                #region Draw theHCenter

                if (bDrawHCenter)
                {
                    if (Math.Abs(curThumb.Position.Y + (curThumb.Height / 2) - theHCenter) < TOLERANCE)
                    {
                        Line line = NewAlignLine();

                        if (theLeft + dt.Width < curThumb.Position.X) //基准在左边
                        {
                            line.X1 = theLeft + dt.Width;
                        }
                        else
                        {
                            line.X1 = theLeft;
                        }
                        if (curThumb.Position.X + curThumb.Width < theLeft) //基准在右边
                        {
                            line.X2 = curThumb.Position.X + curThumb.Width;
                        }
                        else
                        {
                            line.X2 = curThumb.Position.X;
                        }

                        line.Y1 = theHCenter;
                        line.Y2 = theHCenter;

                        AlignLines.Add(line);
                        this.Children.Add(line);
                    }
                }

                #endregion

                #region Draw Left

                if (bDrawLeft)
                {
                    if (Math.Abs(theLeft - curThumb.Position.X) < TOLERANCE)
                    {
                        Line line = NewAlignLine();

                        if (theTop + dt.Height < curThumb.Position.Y) //基准在上边
                        {
                            line.Y1 = theTop + dt.Height;
                        }
                        else
                        {
                            line.Y1 = theTop;
                        }
                        if (curThumb.Position.Y + curThumb.Height < theTop) //基准在下边
                        {
                            line.Y2 = curThumb.Position.Y + curThumb.Height;
                        }
                        else
                        {
                            line.Y2 = curThumb.Position.Y;
                        }

                        line.X1 = curThumb.Position.X;
                        line.X2 = curThumb.Position.X;

                        AlignLines.Add(line);
                        this.Children.Add(line);
                    }
                }

                #endregion

                #region Draw Right

                if (bDrawRight)
                {
                    if (Math.Abs(curThumb.Position.X + curThumb.Width - theRight) < TOLERANCE)
                    {
                        Line line = NewAlignLine();

                        if (theTop + dt.Height < curThumb.Position.Y) //基准在上边
                        {
                            line.Y1 = theTop + dt.Height;
                        }
                        else
                        {
                            line.Y1 = theTop;
                        }
                        if (curThumb.Position.Y + curThumb.Height < theTop) //基准在下边
                        {
                            line.Y2 = curThumb.Position.Y + curThumb.Height;
                        }
                        else
                        {
                            line.Y2 = curThumb.Position.Y;
                        }

                        line.X1 = theRight;
                        line.X2 = theRight;

                        AlignLines.Add(line);
                        this.Children.Add(line);
                    }
                }

                #endregion

                #region Draw theVCenter

                if (bDrawVCenter)
                {
                    if (Math.Abs(curThumb.Position.X + (curThumb.Width / 2) - theVCenter) < TOLERANCE)
                    {
                        Line line = NewAlignLine();

                        if (theTop + dt.Height < curThumb.Position.Y) //基准在上边
                        {
                            line.Y1 = theTop + dt.Height;
                        }
                        else
                        {
                            line.Y1 = theTop;
                        }
                        if (curThumb.Position.Y + curThumb.Height < theTop) //基准在下边
                        {
                            line.Y2 = curThumb.Position.Y + curThumb.Height;
                        }
                        else
                        {
                            line.Y2 = curThumb.Position.Y;
                        }

                        line.X1 = theVCenter;
                        line.X2 = theVCenter;

                        AlignLines.Add(line);
                        this.Children.Add(line);
                    }
                }

                #endregion
            }

            #endregion
        }
예제 #30
0
        public List <Shape> WidthHeightLines = new List <Shape>(); //宽高展示线

        #region 移动控件元素

        private void DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
        {
            DragThumb tb = (sender as DragThumb);

            if ((tb == null) || (tb.BResizing) || (tb.IsReadOnly))
            {
                return;
            }

            ClearAlignLies();
            Point oldPosition = new Point(tb.Position.X, tb.Position.Y);
            Point newPosition = new Point(tb.Position.X, tb.Position.Y);

            double addV = e.VerticalChange;
            double addH = e.HorizontalChange;

            #region 对齐到网格

            if (!BCtrl) //不是Ctrl
            {
                if (Math.Abs(addV) > 0.0001)
                {
                    addV = addV - (addV % 5);
                }
                if (Math.Abs(addH) > 0.0001)
                {
                    addH = addH - (addH % 5);
                }
            }

            #endregion

            #region 设置新的坐标值

            if (BOrthogonal)          //正交
            {
                if (LcDirection == 1) //锁定高度方向
                {
                    newPosition.Y += addV;
                }
                else
                {
                    newPosition.X += addH;
                }
            }
            else
            {
                newPosition.X += addH;
                newPosition.Y += addV;
            }

            #endregion

            #region 获取对齐的坐标

            const double AlignSpan = 10;

            double theNewTop  = newPosition.Y;
            double theNewLeft = newPosition.X;

            double HSpan = AlignSpan; //水平移动间隔 - 停靠
            double VSpan = AlignSpan; //垂直移动间隔 - 停靠

            foreach (DragThumb thumb in DragThumbs)
            {
                if (thumb.Equals(tb))
                {
                    continue;
                }

                double theLeft    = thumb.Position.X;
                double theTop     = thumb.Position.Y;
                double theRight   = theLeft + thumb.Width;
                double theButtom  = theTop + thumb.Height;
                double theHCenter = theTop + (thumb.Height / 2); //水平中心
                double theVCenter = theLeft + (thumb.Width / 2); //垂直中心

                #region 水平 对齐 Top,Buttom, HCenter

                if (Math.Abs(newPosition.Y - theTop) <= HSpan)  //查找水平方向最小间隔的控件
                {
                    HSpan     = Math.Abs(newPosition.Y - theTop);
                    theNewTop = theTop;
                }

                if (Math.Abs(newPosition.Y + tb.Height - theButtom) <= HSpan)  //查找水平方向最小间隔的控件
                {
                    HSpan     = Math.Abs(newPosition.Y + tb.Height - theButtom);
                    theNewTop = theButtom - tb.Height;
                }

                if (Math.Abs(newPosition.Y + (tb.Height / 2) - theHCenter) <= HSpan)  //查找水平方向最小间隔的控件
                {
                    HSpan     = Math.Abs(newPosition.Y + (tb.Height / 2) - theHCenter);
                    theNewTop = theHCenter - (tb.Height / 2);
                }
                #endregion

                #region 垂直 对齐

                #region 水平 对齐 Left,Right, VCenter


                if (Math.Abs(newPosition.X - theLeft) <= VSpan) //查找垂直方向最小间隔的控件
                {
                    VSpan      = Math.Abs(newPosition.X - theLeft);
                    theNewLeft = theLeft;
                }

                if (Math.Abs(newPosition.X + tb.Width - theRight) <= VSpan)  //查找垂直方向最小间隔的控件
                {
                    VSpan      = Math.Abs(newPosition.X + tb.Width - theRight);
                    theNewLeft = theRight - tb.Width;
                }

                if (Math.Abs(newPosition.X + (tb.Width / 2) - theVCenter) <= VSpan)  //查找垂直方向最小间隔的控件
                {
                    VSpan      = Math.Abs(newPosition.X + (tb.Width / 2) - theVCenter);
                    theNewLeft = theVCenter - (tb.Width / 2);
                }
                #endregion

                #endregion
            }

            #endregion

            newPosition.X = theNewLeft;
            newPosition.Y = theNewTop;

            #region 更新控件的位置

            tb.MoveToNewPosition(newPosition.X, newPosition.Y, true);

            #endregion

            #region 更新所有选择的控件的位置

            foreach (var dragThumb in SelectDragThumbs)
            {
                if (dragThumb.Equals(tb))
                {
                    continue;
                }

                dragThumb.MoveBySpan(tb.Position.X - oldPosition.X, tb.Position.Y - oldPosition.Y, true);
            }

            #endregion

            ReDrawAlignLines(tb, true, true, true, true, true, true);

            bSaved = false;
        }