Example #1
0
        /// <summary>
        /// 把元素向底层移动
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnDown_Click(object sender, RoutedEventArgs e)
        {
            var select = gridElements.SelectedValue;

            if (select != null)
            {
                WatchElement element = (WatchElement)select;
                MoveZOrder(element, 1);
            }
        }
Example #2
0
        /// <summary>
        /// 添加元素
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            AddElementWindow add = new AddElementWindow(resolution);

            if (add.ShowDialog() ?? false)
            {
                WatchElement element = ClockDialCreater.CreaterElement(add.HWElement, canvasMain, curOpenFile);
                watchElements.Add(element);
            }
        }
Example #3
0
        /// <summary>
        /// 删除元素
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            var select = gridElements.SelectedValue;

            if (select != null)
            {
                WatchElement element  = (WatchElement)select;
                int          curIndex = 0;
                for (int i = 0; i < watchElements.Count; i++)
                {
                    if (watchElements[i].ID == element.ID)
                    {
                        curIndex = i;
                        break;
                    }
                }
                watchElements.RemoveAt(curIndex);
                canvasMain.Children.RemoveAt(curIndex);
            }
        }
Example #4
0
        /// <summary>
        /// 改变元素的zOrder
        /// </summary>
        /// <param name="element"></param>
        /// <param name="zOrder"></param>
        private void MoveZOrder(WatchElement element, int zOrder)
        {
            int curIndex = 0;

            for (int i = 0; i < watchElements.Count; i++)
            {
                if (watchElements[i].ID == element.ID)
                {
                    curIndex = i;
                    break;
                }
            }

            if (curIndex == 0 && zOrder < 0 || curIndex == watchElements.Count - 1 && zOrder > 0)
            {
                return;
            }

            watchElements.RemoveAt(curIndex);
            watchElements.Insert(curIndex + zOrder, element);
            canvasMain.Children.RemoveAt(curIndex);
            canvasMain.Children.Insert(curIndex + zOrder, element.DesignerControl);
            gridElements.SelectedIndex = curIndex + zOrder;
        }
Example #5
0
        /// <summary>
        /// element选择
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GridElements_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var select = gridElements.SelectedValue;

            if (select != null)
            {
                WatchElement element = (WatchElement)select;
                foreach (UIElement item in canvasMain.Children)
                {
                    Selector.SetIsSelected(item, false);
                }
                if (element.DesignerControl.Visibility == Visibility.Visible)
                {
                    Selector.SetIsSelected(element.DesignerControl, true);
                }

                if (element.HWElement is HWImage)
                {
                    ImageControl image = new ImageControl();
                    image.WatchElement = element;
                    gridAttribute.Children.Clear();
                    gridAttribute.Children.Add(image);
                }
                else if (element.HWElement is HWBox)
                {
                    BoxControl boxControl = new BoxControl
                    {
                        WatchElement = element
                    };
                    gridAttribute.Children.Clear();
                    gridAttribute.Children.Add(boxControl);
                }
                else if (element.HWElement is HWLine)
                {
                    LineControl Line = new LineControl
                    {
                        WatchElement = element
                    };
                    gridAttribute.Children.Clear();
                    gridAttribute.Children.Add(Line);
                }
                else if (element.HWElement is HWCircle)
                {
                    CircleControl circelControl = new CircleControl
                    {
                        WatchElement = element
                    };
                    gridAttribute.Children.Clear();
                    gridAttribute.Children.Add(circelControl);
                }
                else if (element.HWElement is HWSelectImage)
                {
                    SelecteImageControl selecte = new SelecteImageControl
                    {
                        WatchElement = element
                    };
                    gridAttribute.Children.Clear();
                    gridAttribute.Children.Add(selecte);
                }
                else if (element.HWElement is HWTextareaWithOneWildCard)
                {
                    TextareaWithOneWildCardControl textCtrl = new TextareaWithOneWildCardControl
                    {
                        WatchElement = element
                    };
                    gridAttribute.Children.Clear();
                    gridAttribute.Children.Add(textCtrl);
                }
                else if (element.HWElement is HWTextareaWithTwoWildCard)
                {
                    TextareaWithTwoWildCardControl textCtrl = new TextareaWithTwoWildCardControl
                    {
                        WatchElement = element
                    };
                    gridAttribute.Children.Clear();
                    gridAttribute.Children.Add(textCtrl);
                }
                else if (element.HWElement is HWTextureMapper)
                {
                    TextureMapperControl texture = new TextureMapperControl
                    {
                        WatchElement = element
                    };
                    gridAttribute.Children.Clear();
                    gridAttribute.Children.Add(texture);
                }
                else
                {
                    gridAttribute.Children.Clear();
                }
            }
        }