Exemple #1
0
        public void AddExecUnSelectPartCommand(SnipPagePart part)
        {
            UnSelectPartCommand cmd = new UnSelectPartCommand(part);

            cmd.Execute();
            AddCommand(cmd);
        }
Exemple #2
0
        /// <summary>
        /// 改变节点选择状态后
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void treeViewChannels_AfterCheck(object sender, TreeViewEventArgs e)
        {
            TreeNode node      = e.Node;
            string   channelId = node.Tag.ToString();

            if (node.Checked)
            {
                NavigationPart nvPart = (NavigationPart)SnipPagePart.Create(SnipPageDesigner, SnipPartType.Navigation);
                nvPart.ChannelID        = channelId;
                _navigations[channelId] = nvPart;
                nvPart.Width_Css        = DEFAULTWIDTH;
            }
            else
            {
                _navigations.Remove(channelId);
            }
            if (_navigations.Values.Count <= 1)
            {
                checkBoxUsedSeparator.Checked = false;
                checkBoxUsedSeparator.Enabled = false;
            }
            else
            {
                checkBoxUsedSeparator.Enabled = true;
            }
        }
Exemple #3
0
 public SetPropertyPartCommand(SnipPagePart part, T oldValue, T newValue, SetPropertyCore <T> setCoreMethod, PartAction action)
     : base(part, action)
 {
     _oldValue           = oldValue;
     _newValue           = newValue;
     this._setCoreMethod = setCoreMethod;
 }
Exemple #4
0
        public SnipPagePart[] GetPartsAt(Point point)
        {
            List <SnipPagePart> parts = new List <SnipPagePart>();

            SnipPagePart part  = PartContainer.GetPartAt(point, false);
            bool         isHit = true;

            while (part != null && isHit)
            {
                parts.Add(part);
                isHit = false;
                if (part.HasChild)
                {
                    foreach (SnipPagePart p in part.ChildParts)
                    {
                        if (p.HitTest(point))
                        {
                            part  = p;
                            isHit = true;
                            break;
                        }
                    }
                }
            }
            return(parts.ToArray());
        }
Exemple #5
0
        public void AddExecRemovePartCommand(SnipPagePart part)
        {
            RemovePartCommand cmd = new RemovePartCommand(part);

            cmd.Execute();
            AddCommand(cmd);
            Designer.IsModified = true;
        }
Exemple #6
0
        public void AddExecInsertPartCommand(SnipPagePart part, IPartContainer parent, int index)
        {
            InsertPartCommand cmd = new InsertPartCommand(part, parent, index);

            cmd.Execute();
            AddCommand(cmd);
            Designer.IsModified = true;
        }
Exemple #7
0
        public void AddExecAddPartCommand(IPartContainer parent, SnipPagePart part)
        {
            AddPartCommand cmd = new AddPartCommand(parent, part);

            cmd.Execute();
            AddCommand(cmd);
            Designer.IsModified = true;
        }
Exemple #8
0
        public void AddExecSetPropertyPartCommand <T>(SnipPagePart part, T oldValue, T newValue, SetPropertyCore <T> setCoreMethod, PartAction action)
        {
            SetPropertyPartCommand <T> cmd = new SetPropertyPartCommand <T>(part, oldValue, newValue, setCoreMethod, action);

            cmd.Execute();
            AddCommand(cmd);
            Designer.IsModified = true;
        }
Exemple #9
0
        public override bool CanInto(SnipPagePart targetPart)
        {
            if (targetPart.PartType == SnipPartType.List)
            {
                return(true);
            }

            return(base.CanInto(targetPart));
        }
Exemple #10
0
        /// <summary>
        /// 检查传入的Part是否可以放入当前Part中
        /// </summary>
        public virtual bool CanInto(SnipPagePart targetPart)
        {
            ///静态的和导航的可以放置在任何位置
            if (targetPart.PartType == SnipPartType.Static ||
                targetPart.PartType == SnipPartType.Navigation)
            {
                return(true);
            }

            return(false);
        }
Exemple #11
0
 /// <summary>
 /// 鼠标双击
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void SnipPageDesigner_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left && Control.ModifierKeys != Keys.Control)
     {
         SnipPagePart part = Designer.GetPartAt(Designer.PointToClient(Control.MousePosition), true);
         if (part != null)
         {
             Designer.EditPart(part, false);
         }
     }
 }
Exemple #12
0
 /// <summary>
 /// add by fenggy 2006-06-13 处理PART的定位
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SdsiteXmlDocument_OrientationPart(object sender, EventArgs <string[]> e)
 {                                                                               //
     //因为所有打开的页面片设计器都回相应该事件,所以只处理目标页面片!其他的过滤掉
     if (this._snipId.Equals(e.Item[0].ToString()))                              //e.Item[0]页面片ID
     {
         SnipPagePart part = SnipPageDesigner.GetPartByID(e.Item[1].ToString()); //e.Item[1]欲定位PART 的ID
         if (part != null)
         {
             this.SnipPageDesigner.SelectPartAndCheck(part);
         }
     }
 }
Exemple #13
0
        private void GetParts(SnipPagePartCollection snipPagePartCollection, XmlElement partsEle, SnipPageDesigner designer)
        {
            XmlNodeList _nodes = partsEle.SelectNodes("part");

            foreach (XmlNode node in _nodes)
            {
                SnipPartXmlElement partEle = (SnipPartXmlElement)node;
                SnipPagePart       part    = SnipPagePart.Parse(partEle, designer);

                snipPagePartCollection.Add(part);
                GetParts(part.ChildParts, partEle, designer);
            }
        }
Exemple #14
0
        /// <summary>
        /// 将element里保存的数据读取到parts(递归)
        /// </summary>
        private void GetParts(SnipPagePart part, XmlElement element)
        {
            XmlNodeList _nodes = element.SelectNodes("part");

            //part.ChildParts.Clear();
            foreach (XmlNode node in _nodes)
            {
                SnipPartXmlElement partEle = (SnipPartXmlElement)node;
                SnipPagePart       _part   = SnipPagePart.Parse(partEle, this.Designer);

                part.ChildParts.Add(_part);
                GetParts(_part, partEle);
            }
        }
Exemple #15
0
 private void checkBoxProject_CheckedChanged(object sender, EventArgs e)
 {
     comboBoxProject.Enabled = checkBoxProject.Checked;
     labelProject.Enabled    = checkBoxProject.Checked;
     if (checkBoxProject.Checked)
     {
         ListBoxPart lbPart = (ListBoxPart)SnipPagePart.Create(_part.Designer, SnipPartType.ListBox);
         lbPart.StyleType = StyleType.ProjectPageListPart;
         _listBoxPartsDic[StyleType.ProjectPageListPart] = lbPart;
     }
     else
     {
         _listBoxPartsDic.Remove(StyleType.ProjectPageListPart);
     }
 }
Exemple #16
0
        private int AddToDicLayout(Dictionary <int, LineData> dicLinesData, SnipPagePart part, int startLine)
        {
            int i     = 0;
            int multi = part.FactLines;

            for (; i < multi; i++)
            {
                LineData lineData;
                if (!dicLinesData.TryGetValue(startLine + i, out lineData))
                {
                    lineData = new LineData(i, part.Index);
                    dicLinesData.Add(startLine + i, lineData);
                }
                lineData.LineParts.Add(part);
            }
            return(i);
        }
Exemple #17
0
 public SnipPagePart GetPartAt(Point point, bool isRecursiveChilds)
 {
     //modify: zhenghao at 2008-06-23 10:00
     //先找所有被选择的
     foreach (SnipPagePart part in PartContainer.ChildParts)
     {
         if (!part.Selected)
         {
             continue;
         }
         if (part.HitTest(point))
         {
             if (isRecursiveChilds && part.HasChild)
             {
                 SnipPagePart temp = part.GetPartAt(point, true);
                 if (temp != null)
                 {
                     return(temp);
                 }
             }
             return(part);
         }
     }
     foreach (SnipPagePart part2 in PartContainer.ChildParts)
     {
         if (part2.Selected)
         {
             continue;
         }
         if (part2.HitTest(point))
         {
             if (isRecursiveChilds && part2.HasChild)
             {
                 SnipPagePart temp = part2.GetPartAt(point, true);
                 if (temp != null)
                 {
                     return(temp);
                 }
             }
             return(part2);
         }
     }
     return(null);
 }
Exemple #18
0
 void SnipPageDesigner_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left && Control.ModifierKeys != Keys.Control)
     {
         SnipPagePart part = SnipPageDesigner.GetPartAt(SnipPageDesigner.PointToClient(Control.MousePosition), true);
         if (part != null)
         {
             SnipPageDesigner.EditPart(part, false);
             // from:郑浩 计划改为 双击后 “编辑” 2008.03.03早
             ////Point point = SnipPageDesigner.PointToClient(Control.MousePosition);
             ////if (part.HitTest(point))
             ////{
             //CssSetupForm form = new CssSetupForm(part.Css, CurType.Part);
             //if (form.ShowDialog() == DialogResult.OK)
             //{
             //    part.Css = form.CSSText;
             //}
             ////}
         }
     }
 }
Exemple #19
0
        /// <summary>
        /// 当前part的实际像素宽度
        /// </summary>
        /// <param name="cssLongness"></param>
        /// <returns></returns>
        public int CssLongnessToPixel(string cssLongness, SnipPagePart part, LineData lineData)
        {
            if (string.IsNullOrEmpty(cssLongness))
            {
                return(0);
            }

            ///处理px
            if (cssLongness.EndsWith("px", StringComparison.InvariantCultureIgnoreCase))
            {
                return(int.Parse(cssLongness.Substring(0, cssLongness.Length - 2)));
            }
            ///处理%
            else if (cssLongness.EndsWith("%", StringComparison.InvariantCultureIgnoreCase))
            {
                int width = 0;
                if (part != null)
                {
                    width = part.ParentContainer.WidthPixel;
                    if (part.Float_Css == "none")
                    {
                        foreach (SnipPagePart p in lineData.LineParts)
                        {
                            width -= p.WidthPixel;
                        }
                    }
                }
                else
                {
                    width = PartContainer.ParentContainer.WidthPixel;
                }
                return(width * int.Parse(cssLongness.Substring(0, cssLongness.Length - 1)) / 100);
            }
            ///处理其他,默认是纯数字,当像素处理
            else
            {
                return(int.Parse(cssLongness));
            }
        }
Exemple #20
0
        static public void ShowForm(SnipPagePart[] parts)
        {
            ///若跟上次的一样,则不改变,不做操作
            if (_prevParts != null && IsSame(_prevParts, parts))
            {
                return;
            }

            ///隐藏不需要显示的Form
            int sameCount = -1;

            if (_prevParts != null && _prevParts.Length > 0)
            {
                int prevLength = _prevParts.Length;
                for (int i = 0; i < prevLength; i++)
                {
                    if (i < parts.Length && _prevParts[i] == parts[i])
                    {
                        sameCount = i;
                    }
                    else
                    {
                        _listUsingForm[sameCount + 1].HideForm();
                    }
                }
            }

            ///根据位置显示HalfOpacityForm
            for (int i = sameCount + 1; i < parts.Length; i++)
            {
                SnipPagePart part = parts[i];
                ///delete:Point screenLocation = part.Designer.PointToScreen(part.LocationForDesignerDisplay);
                Point screenLocation = part.Designer.PointToScreen(part.LocationForDesigner);
                ShowForm(screenLocation.X, screenLocation.Y, part.Bounds.Width, part.Bounds.Height);
            }
            _prevParts = parts;
        }
Exemple #21
0
 /// <summary>
 /// add by fenggy 2008-06-16 根据ID从PartCollection中寻找对应的PART
 /// </summary>
 /// <param name="PartID"></param>
 /// <param name="ChildParts"></param>
 /// <returns></returns>
 private SnipPagePart GetPartFromPartCollection(string PartID, SnipPagePartCollection ChildParts)
 {
     foreach (SnipPagePart part in ChildParts)
     {
         SnipPagePart retPart = null;
         if (part.PartID.Equals(PartID))
         {
             retPart = part;
         }
         if (retPart != null)
         {
             return(retPart);
         }
         if (part.ChildParts.Count > 0)
         {
             retPart = GetPartFromPartCollection(PartID, part.ChildParts);
             if (retPart != null)
             {
                 return(retPart);
             }
         }
     }
     return(null);
 }
Exemple #22
0
 internal PartCommand(SnipPagePart part, PartAction action)
 {
     this._action = action;
     this._part   = part;
 }
Exemple #23
0
 public void AddExecSetPropertyPartCommand <T>(SnipPagePart part, T oldValue, T newValue, SetPropertyCore <T> setCoreMethod)
 {
     AddExecSetPropertyPartCommand <T>(part, oldValue, newValue, setCoreMethod, PartAction.None);
 }
Exemple #24
0
 public InsertPartCommand(SnipPagePart part, IPartContainer parent, int index)
     : base(part)
 {
     this._parent = parent;
     this._index  = index;
 }
Exemple #25
0
        void SnipItem_MouseMove(object sender, MouseEventArgs e)
        {
            if (_snipItemIsMouseDown)
            {
                ///检查鼠标移动的位置有没有达到拖拽的最小值
                int minDrawDropValue = 5;
                if ((Math.Abs(Control.MousePosition.X - _prevMouseLocation.X) > minDrawDropValue) ||
                    (Math.Abs(Control.MousePosition.Y - _prevMouseLocation.Y) > minDrawDropValue))
                {
                    TreeView            _item          = (TreeView)sender;
                    MdiSnipDesignerForm _activeMdiForm = WorkbenchForm.MainForm.ActiveView as MdiSnipDesignerForm;

                    SnipPagePart part = null;
                    switch (_item.SelectedNode.Name)
                    {
                    case "_insertBoxItem":
                        if (_activeMdiForm != null)
                        {
                            part = SnipPagePart.Create(_activeMdiForm.SnipPageDesigner, SnipPartType.Box);
                        }
                        break;

                    case "_insertTextItem":
                        if (_activeMdiForm != null)
                        {
                            part = SnipPagePart.Create(_activeMdiForm.SnipPageDesigner, SnipPartType.Static);
                        }
                        break;

                    case "_insertListItem":
                        if (_activeMdiForm != null)
                        {
                            part = SnipPagePart.Create(_activeMdiForm.SnipPageDesigner, SnipPartType.List);
                        }
                        break;

                    case "_insertNavigationItem":
                        if (_activeMdiForm != null)
                        {
                            //part = SnipPagePart.Create(_activeMdiForm.SnipPageDesigner, SnipPartType.NavigationBox);
                        }
                        break;

                    case "_insertChannelItem":
                        if (_activeMdiForm != null)
                        {
                            //part = SnipPagePart.Create(_activeMdiForm.SnipPageDesigner, SnipPartType.Navigation);
                        }
                        break;

                    case "_insertPathItem":
                        if (_activeMdiForm != null)
                        {
                            part = SnipPagePart.Create(_activeMdiForm.SnipPageDesigner, SnipPartType.Path);
                        }
                        break;

                    default:
                        break;
                    }
                    _snipItemIsMouseDown = false;

                    if (part != null)
                    {
                        _activeMdiForm.SnipPageDesigner.StartPartDragDrop(part);
                        _activeMdiForm.SnipPageDesigner.Capture = true;
                        _activeMdiForm.Activate();
                    }
                }
            }
        }
Exemple #26
0
 public SetPropertyPartCommand(SnipPagePart part, T oldValue, T newValue, SetPropertyCore <T> setCoreMethod)
     : this(part, oldValue, newValue, setCoreMethod, PartAction.None)
 {
 }
Exemple #27
0
 public AddPartCommand(IPartContainer parent, SnipPagePart part)
     : base(part)
 {
     this._parent = parent;
 }
Exemple #28
0
 internal PartCommand(SnipPagePart part)
     : this(part, PartAction.None)
 {
 }
Exemple #29
0
        /// <summary>
        /// 简单工厂,创建不同SnipPartType的Part
        /// </summary>
        static public SnipPagePart Create(SnipPageDesigner designer, SnipPartType type)
        {
            SnipPagePart part;

            switch (type)
            {
            case SnipPartType.None:
            case SnipPartType.Static:
            {
                part       = new StaticPart(designer);
                part.Title = StringParserService.Parse("${res:snipDesign.text.staticPartText}");
                break;
            }

            case SnipPartType.Box:
            {
                part       = new SnipPagePart(designer);
                part.Title = StringParserService.Parse("${res:snipDesign.text.box}");
                break;
            }

            case SnipPartType.Navigation:
            {
                part       = new NavigationPart(designer);
                part.Title = StringParserService.Parse("${res:snipDesign.text.navigationPartText}");
                break;
            }

            case SnipPartType.List:
            {
                part       = ListPart.Create(designer);
                part.Title = StringParserService.Parse("${res:snipDesign.text.listPartText}");
                break;
            }

            case SnipPartType.ListBox:
            {
                part       = ListBoxPart.Create(designer);
                part.Title = StringParserService.Parse("${res:snipDesign.text.listBoxPartText}");
                break;
            }

            case SnipPartType.Attribute:
            {
                part       = AttributePart.Create(designer);
                part.Title = StringParserService.Parse("${res:snipDesign.text.attributePartText}");
                break;
            }

            case SnipPartType.Path:
            {
                part       = new PathPart(designer);
                part.Title = StringParserService.Parse("${res:snipDesign.text.pathPartText}");
                break;
            }

            default:
                throw new Exception("开发期异常。未知的SnipPartType:" + type);
            }
            part.PartID   = XmlUtilService.CreateIncreaseId();
            part.PartType = type;
            return(part);
        }
Exemple #30
0
        /// <summary>
        /// 布局其下的ChildParts
        /// </summary>
        public void LayoutParts()
        {
            if (Designer._isUpdateData)
            {
                return;
            }

            int currentLine = 0;
            int innerLines  = 0;
            Dictionary <int, LineData> dicLinesData = new Dictionary <int, LineData>();

            for (int i = 0; i < PartContainer.ChildParts.Count; i++)
            {
                SnipPagePart part = PartContainer.ChildParts[i];

                ///若此Part有子Part,则先对其内部进行布局
                if (part.HasChild)
                {
                    part.LayoutParts();
                }

                int leftOffset  = PartContainer.Padding.Left;  //此变量是将要出现的控件的水平起始位置
                int rightOffset = PartContainer.Padding.Right; //此变量是将要出现的控件的水平结束位置

                ///取出当前行位置对应的LineData
                LineData lineData = null;
                if (!dicLinesData.TryGetValue(currentLine, out lineData))
                {
                    lineData = new LineData(currentLine, i);
                    dicLinesData.Add(currentLine, lineData);
                }
                else
                {
                    ///遍历来检测当前插入行的左右边界
                    foreach (SnipPagePart r in lineData.LineParts)
                    {
                        if (r.Float_Css == "left")
                        {
                            leftOffset = r.Bounds.X + r.Bounds.Width;
                        }
                        else if (r.Float_Css == "right")
                        {
                            rightOffset = PartContainer.FactWidth - r.Bounds.X;
                        }
                    }
                }

                ///剩余的宽度
                int spare = PartContainer.FactWidth - leftOffset - rightOffset;

                ///若剩余宽度太小,则另起一行
                if (spare != (PartContainer.FactWidth - PartContainer.Padding.Left - PartContainer.Padding.Right) && spare < 5)
                {
                    currentLine++;
                    i--;
                    continue;
                }

                int height = SnipPageDesigner.PartHeight * part.FactLines;// +(SnipPageDesigner.PartSeparator * 2);
                int width  = CssLongnessToPixel(part.Width_Css, part, lineData);
                part.WidthPixel = width;
                ///若剩余宽度不够,则另起一行
                if (part.Float_Css != "none" && spare != (PartContainer.FactWidth - PartContainer.Padding.Left - PartContainer.Padding.Right) && spare < part.WidthPixel)
                {
                    currentLine++;
                    i--;
                    continue;
                }
                int x = (part.Float_Css != "right") ? leftOffset : PartContainer.FactWidth - (rightOffset + width);
                int y = currentLine * SnipPageDesigner.PartHeight + PartContainer.Padding.Top;

                part.Bounds = new Rectangle(x, y, width, height);
                int line = AddToDicLayout(dicLinesData, part, currentLine);

                innerLines = Math.Max(innerLines, currentLine + part.FactLines);
                if (part.Float_Css == "none")
                {
                    ///由于不是浮动行,则下一个Part要重新起一行:currentLine递增
                    currentLine += line;
                }
            }

            PartContainer.ResetInnerLines(innerLines);

            if (PartContainer is SnipPageDesigner)
            {
                var designer = ((SnipPageDesigner)PartContainer);
                designer.Height = PartContainer.InnerLines * SnipPageDesigner.PartHeight + ((SnipPageDesigner)PartContainer).Padding.Vertical;

                int cx = 0, cy = 0;
                cx = (designer.Parent.Width - designer.Width) / 2;
                cy = (designer.Parent.Height - designer.Height) / 2;
                designer.Location = new Point(cx, cy);
            }
            else if (PartContainer is SnipPagePart)
            {
                ((SnipPagePart)PartContainer).Invalidate();
            }

            PartContainer.Designer.OnPartsLayouted(EventArgs.Empty);
        }