示例#1
0
        protected override void TreeViewItem_Loaded(object sender, RoutedEventArgs e)
        {
            initHeader();
            addChild();

            int i = 0;
            double widthCount = 0;
            Basic lastChild = new Basic();
            foreach (Basic treeChild in this.Items)
            {
                if (treeChild.m_curCanvas != null)
                {
                    widthCount += treeChild.m_curCanvas.Width;
                    lastChild = treeChild;
                }
                i++;
            }
            if (lastChild.m_curCanvas != null)
            {
                widthCount -= lastChild.m_curCanvas.Width;
                lastChild.m_curCanvas.Width = m_curCanvas.Width - widthCount;
            }
        }
示例#2
0
文件: ResBasic.cs 项目: jaffrykee/ui
        public static void resetXeView(Basic uiView, out XmlElement xeView)
        {
            xeView = uiView.m_xe.OwnerDocument.CreateElement(uiView.m_xe.Name);

            foreach (XmlAttribute attr in uiView.m_xe.Attributes)
            {
                xeView.SetAttribute(attr.Name, attr.Value);
            }
            xeView.RemoveAttribute("x");
            xeView.RemoveAttribute("y");
            xeView.RemoveAttribute("visible");
            xeView.RemoveAttribute("dock");
            xeView.RemoveAttribute("anchor");
            xeView.RemoveAttribute("anchorSelf");
            xeView.SetAttribute("x", uiView.m_selScreenX.ToString());
            xeView.SetAttribute("y", uiView.m_selScreenY.ToString());
            xeView.SetAttribute("w", uiView.m_selW.ToString());
            xeView.SetAttribute("h", uiView.m_selH.ToString());
            xeView.SetAttribute("baseID", "selSkinTestCtrl");
            xeView.SetAttribute("skin", uiView.m_xe.GetAttribute("skin"));
        }
示例#3
0
        private void checkOverflow(Basic ctrlFrame)
        {
            CtrlDef_T ctrlDef;
            System.Drawing.Rectangle rectFrame = new System.Drawing.Rectangle(
                ctrlFrame.m_selScreenX, ctrlFrame.m_selScreenY, ctrlFrame.m_selW, ctrlFrame.m_selH);

            if (ctrlFrame != null && ctrlFrame.m_xe != null && ctrlFrame.m_xe.Name != "" && CtrlDef_T.isFrame(ctrlFrame.m_xe.Name) == true)
            {
                foreach (object item in ctrlFrame.Items)
                {
                    if (item is Basic)
                    {
                        Basic ctrlItem = (Basic)item;

                        if (ctrlItem.m_xe.GetAttribute("visible") != "false")
                        {
                            System.Drawing.Rectangle rectItem = new System.Drawing.Rectangle(
                                ctrlItem.m_selScreenX, ctrlItem.m_selScreenY, ctrlItem.m_selW, ctrlItem.m_selH);

                            if (ctrlItem.m_xe.Name != "event" && !rectFrame.Contains(rectItem))
                            {
                                Public.ResultLink.createResult("\r\n[" + ctrlItem.mx_text.Text + "]",
                                    Public.ResultType.RT_INFO, ctrlItem);
                                Public.ResultLink.createResult(" 超出了 ", Public.ResultType.RT_INFO);
                                Public.ResultLink.createResult("[" + ctrlFrame.mx_text.Text + "]",
                                    Public.ResultType.RT_INFO, ctrlFrame);
                                Public.ResultLink.createResult(" 的范围。", Public.ResultType.RT_INFO, ctrlItem);
                            }
                            checkOverflow(ctrlItem);
                        }
                    }
                }
            }
        }
示例#4
0
        public void refreshSkinEditor(Basic curCtrl = null)
        {
            if (curCtrl == null)
            {
                XmlControl curXmlCtrl = XmlControl.getCurXmlControl();

                if (curXmlCtrl != null && curXmlCtrl.m_curItem is Basic)
                {
                    m_curCtrl = (Basic)(curXmlCtrl.m_curItem);
                }
                else
                {
                    m_curCtrl = m_curCtrl;
                    XmlOperation.XmlAttr.AttrList.hiddenAllAttr();
                }
            }
            else
            {
                m_curCtrl = curCtrl;
            }
        }
示例#5
0
 public static void updateAttrToGL(XmlControl xmlCtrl, Basic uiCtrl, string attrName, string newValue)
 {
     if ((uiCtrl.m_xe.Name == "progress" && attrName == "value") || MainWindow.s_pW.mx_isUpdateMode.IsChecked == true)
     {
         MainWindow.s_pW.updateGL(System.IO.Path.GetFileName(xmlCtrl.m_openedFile.m_path) + ":" +
             uiCtrl.m_vId + ":" + attrName + ":" + newValue, W2GTag.W2G_NORMAL_UPDATE);
         return;
     }
     MainWindow.s_pW.updateXmlToGL(xmlCtrl);
 }
示例#6
0
        public static bool insertItemByXe(MainWindow pW, XmlControl xmlCtrl, XmlElement dstXe, XmlElement srcXe,ref int index)
        {
            CtrlDef_T nullCtrlDef;

            if (xmlCtrl != null)
            {
                XmlItem dstItem;
                XmlItem srcItem = null;
                Project.PlugIn.DataNode skinPtr;

                if (srcXe.Name != "BoloUI")
                {
                    if (!(xmlCtrl.m_mapXeItem.TryGetValue(srcXe, out srcItem) && srcItem != null))
                    {
                        return false;
                    }
                }

                if (CtrlDef_T.tryGetCtrlDef(dstXe.Name, out nullCtrlDef))
                {
                    dstItem = new Basic(dstXe, xmlCtrl, false);
                }
                else if (Project.PlugIn.DataNodeGroup.s_mapDataNodesDef["BoloUI"]["Skin"].m_mapDataNode.TryGetValue(dstXe.Name, out skinPtr) && skinPtr is SkinDef_T)
                {
                    if (srcItem != null && srcItem is ResBasic && ((ResBasic)srcItem).m_isSkinEditor)
                    {
                        dstItem = new ResBasic(dstXe, xmlCtrl, (SkinDef_T)skinPtr, true);
                    }
                    else
                    {
                        dstItem = new ResBasic(dstXe, xmlCtrl, (SkinDef_T)skinPtr, false);
                    }
                }
                else
                {
                    return false;
                }

                if (srcItem != null && index > srcItem.Items.Count)
                {
                    index = srcItem.Items.Count;
                }
                else
                {
                    if(index < 0)
                    {
                        index = 0;
                    }
                }

                if (srcXe.Name != "BoloUI")
                {
                    if (srcItem != null)
                    {
                        srcItem.Items.Insert(index, dstItem);
                        srcItem.mx_imgFolder.Visibility = System.Windows.Visibility.Visible;
                    }
                    else
                    {
                        return false;
                    }
                }
                else
                {
                    if (dstItem.m_type == "CtrlUI")
                    {
                        if (index > xmlCtrl.m_treeUI.Items.Count)
                        {
                            index = xmlCtrl.m_treeUI.Items.Count;
                        }
                        xmlCtrl.m_treeUI.Items.Insert(index, dstItem);
                    }
                    else if (dstItem.m_type == "Skin")
                    {
                        if (index > xmlCtrl.m_treeSkin.Items.Count)
                        {
                            index = xmlCtrl.m_treeSkin.Items.Count;
                        }
                        xmlCtrl.m_treeSkin.Items.Insert(index, dstItem);
                    }
                }

                return true;
            }

            return false;
        }
示例#7
0
        public void refreshControl(string skinName = "")
        {
            m_mapCtrlUI = new Dictionary<string, BoloUI.Basic>();
            m_mapImageSize = new Dictionary<string, long>();
            m_mapSkin = new Dictionary<string, BoloUI.ResBasic>();
            m_mapXeItem = new Dictionary<XmlElement, XmlItem>();
            m_isOnlySkin = true;
            clearNodeTreeFrame();
            m_xeRoot = m_xmlDoc.DocumentElement;

            if (m_xeRoot != null)
            {
                switch (m_xeRoot.Name)
                {
                    case "BoloUI":
                        {
                            m_showGL = true;
                            m_treeUI = new BoloUI.Basic(m_xeRoot, this, true);
                            m_treeSkin = new BoloUI.ResBasic(m_xeRoot, this, null);

                            MainWindow.s_pW.mx_treeCtrlFrame.Items.Add(m_treeUI);
                            m_treeUI.mx_text.Text = StringDic.getFileNameWithoutPath(m_openedFile.m_path);
                            m_treeUI.ToolTip = m_openedFile.m_path;
                            MainWindow.s_pW.mx_treeSkinFrame.Items.Add(m_treeSkin);
                            m_treeSkin.mx_text.Text = StringDic.getFileNameWithoutPath(m_openedFile.m_path);
                            m_treeSkin.ToolTip = m_openedFile.m_path;

                            m_treeUI.Items.Clear();
                            m_treeSkin.Items.Clear();

                            XmlNodeList xnl = m_xeRoot.ChildNodes;

                            foreach (XmlNode xnf in xnl)
                            {
                                if (xnf.NodeType == XmlNodeType.Element)
                                {
                                    XmlElement xe = (XmlElement)xnf;
                                    CtrlDef_T ctrlPtr;
                                    SkinDef_T skinPtr;

                                    if (CtrlDef_T.tryGetCtrlDef(xe.Name, out ctrlPtr))
                                    {
                                        m_treeUI.Items.Add(new Basic(xe, this, false));
                                        m_isOnlySkin = false;
                                        m_xeRootCtrl = xe;
                                    }
                                    else if (SkinDef_T.tryGetSkinDef(xe.Name, out skinPtr))
                                    {
                                        if (skinName == "" ||
                                            ((xe.Name == "skin" || xe.Name == "publicskin") && xe.GetAttribute("Name") == skinName))
                                        {
                                            ResBasic treeChild = new ResBasic(xe, this, skinPtr);

                                            //显示或隐藏皮肤节点
            // 											if (xe.Name != "skin" && xe.Name != "publicskin")
            // 											{
            // 												m_treeSkin.Items.Add(treeChild);
            // 											}
                                            m_treeSkin.Items.Add(treeChild);
                                            if (xe.Name == "skingroup")
                                            {
                                                refreshSkinDicByGroupName(xe.GetAttribute("Name"));
                                            }
                                        }
                                    }
                                }
                            }
                            refreshSkinDicByGroupName("publicskin");
                            MainWindow.s_pW.updateXmlToGL(this);
                            if (m_openedFile.m_preViewSkinName != null && m_openedFile.m_preViewSkinName != "")
                            {
                                BoloUI.ResBasic skinBasic;

                                if (m_mapSkin.TryGetValue(m_openedFile.m_preViewSkinName, out skinBasic))
                                {
                                    skinBasic.changeSelectItem(m_openedFile.m_prePlusCtrlUI);
                                }
                                else
                                {
                                    Public.ResultLink.createResult("\r\n没有找到该皮肤。(" + m_openedFile.m_preViewSkinName + ")",
                                        Public.ResultType.RT_WARNING);
                                }
                            }
                        }
                        break;
                    case "UIImageResource":
                        {
                            m_showGL = false;
                            if (ImageTools.ImageNesting.s_pW != null)
                            {
                                mx_root.AddChild(new PackImage(this, true));
                            }
                            else
                            {
                                mx_root.AddChild(new PackImage(this, false));
                            }
                        }
                        break;
                    default:
                        Public.ResultLink.createResult("\r\n这不是一个有效的BoloUI或UIImageResource文件。", Public.ResultType.RT_ERROR);
                        break;
                }
                if(m_showGL)
                {
                    MainWindow.s_pW.showGLCtrl(true, true);
                }
                else
                {
                    MainWindow.s_pW.showGLCtrl(false, true);
                }
            }
            else
            {
                Public.ResultLink.createResult("\r\nxml文件格式错误。", Public.ResultType.RT_ERROR);
            }
            checkAllUICtrlBaseId();
            refreshSkinDicForAll();
        }
示例#8
0
 public SelButton(MainWindow pW, Basic ctrl)
 {
     InitializeComponent();
     m_pW = pW;
     m_ctrlUI = ctrl;
 }