コード例 #1
0
        void OnClickOpenSelecetFile(object sender, EventArgs e)
        {
            OpenFileDialog ofD = new OpenFileDialog();

            var curPath = System.IO.Directory.GetCurrentDirectory();
            var subPath = curPath.Remove(curPath.IndexOf("Bin"));

            ofD.Multiselect = true;

            if (string.IsNullOrEmpty(mConfig.OpenTemplatePath))
            {
                ofD.InitialDirectory = subPath + "DemaciaGame\\Template\\";
            }
            else
            {
                ofD.InitialDirectory = mConfig.OpenTemplatePath;
            }
            ofD.Filter = "All Files(*.*)|*.*";

            foreach (var itm in comboBox_Templates.Items)
            {
                if (!(itm is CComboBoxItem))
                {
                    continue;
                }
                CComboBoxItem item = itm as CComboBoxItem;
                ofD.Filter += "|" + item.m_Type.ToString() + " Files(*" + item.m_strExt + ")|*" + item.m_strExt;
            }

            if (ofD.ShowDialog() == DialogResult.OK)
            {
                LoadSuffixInfo(ofD.FileNames);
            }
        }
コード例 #2
0
        private void button_Open_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofD = new OpenFileDialog();

            var curPath = System.IO.Directory.GetCurrentDirectory();
            var subPath = curPath.Remove(curPath.IndexOf("Kiang") + 5);

            ofD.InitialDirectory = subPath + "\\Release\\Template\\";
            ofD.Filter           = "All Files(*.*)|*.*";

            foreach (var itm in comboBox_Templates.Items)
            {
                if (!(itm is CComboBoxItem))
                {
                    continue;
                }
                CComboBoxItem item = itm as CComboBoxItem;
                ofD.Filter += "|" + item.m_Type.ToString() + " Files(*" + item.m_strExt + ")|*" + item.m_strExt;
            }

            if (ofD.ShowDialog() == DialogResult.OK)
            {
                OpenFile(ofD.FileName);
            }
        }
コード例 #3
0
        public object OpenFile(string strFile)
        {
            string strLine = "";

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            using (StreamReader sr = new StreamReader(strFile))
            {
                try
                {
                    doc.Load(sr);
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    return(null);
                }
            }
            strLine = doc.DocumentElement.Name;

            foreach (var itm in comboBox_Templates.Items)
            {
                if (!(itm is CComboBoxItem))
                {
                    continue;
                }
                CComboBoxItem item = itm as CComboBoxItem;

                if (item.m_Type.ToString() == strLine)
                {
                    comboBox_Templates.SelectedItem = item;
                    break;
                }
            }

            m_Instance = m_ServerCommonAssembly.CreateInstance(strLine);
            if (m_Instance == null)
            {
                m_Instance = m_UIEditorAssembly.CreateInstance(strLine);
            }
            if (m_Instance == null)
            {
                m_Instance = m_CSCommonAssembly.CreateInstance(comboBox_Templates.SelectedItem.ToString());
            }

            if (m_Instance == null)
            {
                MessageBox.Show("无法创建实例:" + strLine);
                return(null);
            }
            //Common.AutoSaveLoad.LoadProperty(m_Instance, strFile);
            ServerFrame.Config.IConfigurator.FillProperty(m_Instance, strFile);
            propertyGrid.SelectedObject = m_Instance;
            this.Text       = strFile;
            m_opendFileName = strFile;
            return(m_Instance);
        }
コード例 #4
0
        private void comboBox_Templates_SelectedIndexChanged(object sender, EventArgs e)
        {
            CComboBoxItem item = comboBox_Templates.SelectedItem as CComboBoxItem;

            if (item == null)
            {
                return;
            }

            treeView_Files.Nodes.Clear();

            SearchFolder(SearchFolderText, item);
            treeView_Files.ExpandAll();
            treeView_Files.Update();
        }
コード例 #5
0
        private void button_SaveAs_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfD  = new SaveFileDialog();
            CComboBoxItem  item = comboBox_Templates.SelectedItem as CComboBoxItem;

            if (item != null)
            {
                sfD.Filter = item.m_Type.ToString() + " Files(*" + item.m_strExt + ")|*" + item.m_strExt + "|All files(*.*)|*.*";
            }
            if (sfD.ShowDialog() == DialogResult.OK)
            {
                m_opendFileName = sfD.FileName;

                //Common.AutoSaveLoad.SaveProperty(m_Instance, m_Instance.GetType().ToString(), sfD.FileName);
                ServerFrame.Config.IConfigurator.SaveProperty(m_Instance, m_Instance.GetType().ToString(), sfD.FileName);
                this.Text = sfD.FileName;
            }
        }
コード例 #6
0
        private void cmbCategoryType_DropDown(object sender, EventArgs e)
        {
            CComboBoxItem oItem1 = new CComboBoxItem(1, "Food");

            CComboBoxItem oItem2 = new CComboBoxItem(0, "Non Food");

            oItem2.Display = "Non Food";

            oItem2.Value = 0;

            cmbCategoryType.Items.Clear();

            cmbCategoryType.Items.Add(oItem1);

            cmbCategoryType.Items.Add(oItem2);

            cmbCategoryType.DisplayMember = "Display";

            cmbCategoryType.ValueMember = "Value";
        }
コード例 #7
0
        private void LoadExistingData()
        {
            CCategoryManager oManager = new CCategoryManager();

            CResult    oResult = oManager.GetCategory2(m_categoryID);
            CCategory2 oCat    = new CCategory2();

            if (oResult.IsSuccess && oResult.Data != null)
            {
                oCat = (CCategory2)oResult.Data;
                txtCategoryName.Text = oCat.Category2Name;
                txtCatOrder.Text     = oCat.Category2Order.ToString();

                m_cattegoryOrder = oCat.Category2Order;

                txtColorName.Text = oCat.Category2Color.ToString();


                if (oCat.Category2ViewTable == 1)
                {
                    chkTable.Checked = true;
                }
                if (oCat.Category2ViewBar == 1)
                {
                    chkBar.Checked = true;
                }
                if (oCat.Category2ViewTakeAway == 1)
                {
                    chkTakeAway.Checked = true;
                }
            }

            oResult = oManager.GetCategoryAncestors(m_categoryID, 2);
            CCategoryAncestor oCatAnc = (CCategoryAncestor)oResult.Data;

            if (oResult.IsSuccess && oResult.Data != null)
            {
                int tmpCat2ID      = oCatAnc.Category2ID;
                int tmpCat1ID      = oCatAnc.Category1ID;
                int tmpParentCatID = oCatAnc.ParentCategoryID;

                FillParentCategory();

                FillFoodType(tmpParentCatID);

                cmbParent.SelectedValue = tmpParentCatID;

                cmbFoodType.SelectedValue = tmpCat1ID;

                CComboBoxItem oItem1 = new CComboBoxItem(1, "Food");

                CComboBoxItem oItem2 = new CComboBoxItem(0, "Non Food");


                cmbCategoryType.Items.Add(oItem1);

                cmbCategoryType.Items.Add(oItem2);

                cmbCategoryType.DisplayMember = "Display";

                cmbCategoryType.ValueMember = "Value";

                if (oCat.Category2Type == 1)
                {
                    cmbCategoryType.SelectedIndex = 0;
                }
                else if (oCat.Category2Type == 0)
                {
                    cmbCategoryType.SelectedIndex = 1;
                }
            }
        }
コード例 #8
0
        public Form1()
        {
            InitializeComponent();
            mInst = this;

            string fullPathname = ServerCommon.IServer.Instance.ExePath + "TemplateConfig.cfg";

            if (false == ServerFrame.Config.IConfigurator.FillProperty(mConfig, fullPathname))
            {
                //System.Windows.Forms.MessageBox.Show("请检查服务器配置文件");
                ServerFrame.Config.IConfigurator.SaveProperty(mConfig, "TemplateConfig", fullPathname);
            }
            propertyGrid1.SelectedObject = mConfig;

            ApplyConfig();


            string dir = System.AppDomain.CurrentDomain.BaseDirectory + "CodeLinker.dll";

            m_UIEditorAssembly = System.Reflection.Assembly.LoadFile(dir);

            var aTypes = m_UIEditorAssembly.GetTypes();

            //foreach (var type in aTypes)
            //{
            //    var atts = type.GetCustomAttributes(typeof(Device.CDataEditorAttribute), true);

            //    if (atts.Length > 0)
            //    {
            //        Device.CDataEditorAttribute dea = atts[0] as Device.CDataEditorAttribute;

            //        CComboBoxItem item = new CComboBoxItem()
            //        {
            //            m_Type = type,
            //            m_strExt = dea.m_strFileExt
            //        };

            //        comboBox_Templates.Items.Add(item);
            //    }
            //}

            dir = System.AppDomain.CurrentDomain.BaseDirectory + "ServerCommon.dll";
            //var dir = System.IO.Directory.GetCurrentDirectory() + "\\ServerCommon.dll";
            m_ServerCommonAssembly = System.Reflection.Assembly.LoadFile(dir);

            aTypes = m_ServerCommonAssembly.GetTypes();

            foreach (var type in aTypes)
            {
                var atts = type.GetCustomAttributes(typeof(ServerFrame.Editor.CDataEditorAttribute), true);

                if (atts.Length > 0)
                {
                    ServerFrame.Editor.CDataEditorAttribute dea = atts[0] as ServerFrame.Editor.CDataEditorAttribute;

                    CComboBoxItem item = new CComboBoxItem()
                    {
                        m_Type   = type,
                        m_strExt = dea.m_strFileExt
                    };

                    comboBox_Templates.Items.Add(item);
                }
            }

            dir = System.AppDomain.CurrentDomain.BaseDirectory + "CSCommon.dll";
            //var dir = System.IO.Directory.GetCurrentDirectory() + "\\ServerCommon.dll";
            m_CSCommonAssembly = System.Reflection.Assembly.LoadFile(dir);

            aTypes = m_CSCommonAssembly.GetTypes();

            foreach (var type in aTypes)
            {
                var atts = type.GetCustomAttributes(typeof(ServerFrame.Editor.CDataEditorAttribute), true);

                if (atts.Length > 0)
                {
                    ServerFrame.Editor.CDataEditorAttribute dea = atts[0] as ServerFrame.Editor.CDataEditorAttribute;

                    CComboBoxItem item = new CComboBoxItem()
                    {
                        m_Type   = type,
                        m_strExt = dea.m_strFileExt
                    };

                    comboBox_Templates.Items.Add(item);
                }
            }


            comboBox_Templates.SelectedIndex = 0;
        }
コード例 #9
0
        private void SearchFolder(string folder, CComboBoxItem item)
        {
            if (!System.IO.Directory.Exists(folder))
            {
                return;
            }
            var files = System.IO.Directory.EnumerateFiles(folder);

            foreach (var file in files)
            {
                var dotIdx = file.LastIndexOf('.');
                if (dotIdx < 0)
                {
                    continue;
                }

                if (file.Substring(dotIdx) != item.m_strExt)
                {
                    continue;
                }

                //string strLine = "";

                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                using (StreamReader sr = new StreamReader(file))
                {
                    try
                    {
                        doc.Load(sr);
                    }
                    catch (System.Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                        continue;
                    }
                    //do
                    //{
                    //    strLine += sr.ReadLine();
                    //} while (!(strLine.Length > 1 && strLine[0] == '<'));

                    //strLine = strLine.Remove(0, 1);
                    //strLine = strLine.Remove(strLine.Length - 1);
                }

                if (doc.DocumentElement != null && doc.DocumentElement.Name == item.m_Type.ToString())//strLine.Contains("<" + item.m_Type.ToString() + ">"))//(item.m_Type.ToString() == strLine)
                {
                    // 加入TreeView
                    var searchFolderIdx = file.IndexOf(textBox_SearchFolder.Text);
                    var tempFile        = file.Remove(0, searchFolderIdx + textBox_SearchFolder.Text.Length);
                    tempFile = tempFile.Replace("\\", "/");

                    var      splits     = tempFile.Split('/');
                    TreeNode parentNode = null;
                    TreeNode treeNode   = null;
                    foreach (var split in splits)
                    {
                        if (string.IsNullOrEmpty(split))
                        {
                            continue;
                        }

                        if (parentNode == null)
                        {
                            treeNode = GetTreeNode(split, treeView_Files);
                        }
                        else
                        {
                            treeNode = GetTreeNode(split, parentNode);
                        }

                        if (treeNode == null)
                        {
                            if (parentNode == null)
                            {
                                treeNode      = new TreeNode();
                                treeNode.Text = split;
                                treeView_Files.Nodes.Add(treeNode);
                                //treeNode.Expand();
                            }
                            else
                            {
                                treeNode      = new TreeNode();
                                treeNode.Text = split;
                                parentNode.Nodes.Add(treeNode);
                            }
                        }

                        parentNode = treeNode;
                    }
                }
            }

            var folders = System.IO.Directory.EnumerateDirectories(folder);

            foreach (var fd in folders)
            {
                SearchFolder(fd, item);
            }
        }
コード例 #10
0
        private void LoadExistingData()
        {
            CCategoryManager oManager = new CCategoryManager();

            CResult    oResult            = oManager.GetCategory4(m_selectionItemCategoryID);
            CCategory4 objSelectionOfItem = new CCategory4();

            if (oResult.IsSuccess && oResult.Data != null)
            {
                objSelectionOfItem = (CCategory4)oResult.Data;
                txtItemName.Text   = objSelectionOfItem.Category4Name;
                txtOrder.Text      = objSelectionOfItem.Category4Order.ToString();

                m_selectionItemOrder = objSelectionOfItem.Category4Order;

                txtDescription.Text     = objSelectionOfItem.Category4Description;
                txtTablePrice.Text      = objSelectionOfItem.Category4TablePrice.ToString("F02");
                txtTakeawayPrice.Text   = objSelectionOfItem.Category4TakeAwayPrice.ToString("F02");
                txtBarPrice.Text        = objSelectionOfItem.Category4BarPrice.ToString("F02");
                txtVateRate.Text        = objSelectionOfItem.vatRate.ToString();
                chkVateIncluded.Checked = objSelectionOfItem.vatIncluded;

                if (objSelectionOfItem.UnlimitStatus > 0)
                {
                    chkunlimited.Checked = true;
                    txtInitialQuantity.Clear();
                }
                else
                {
                    txtInitialQuantity.Text = objSelectionOfItem.InitialItemQuantity.ToString();
                }

                m_iRank = objSelectionOfItem.Rank;


                if (objSelectionOfItem.Category4ViewTable == 1)
                {
                    chkTable.Checked = true;
                }
                if (objSelectionOfItem.Category4ViewBar == 1)
                {
                    chkBar.Checked = true;
                }
                if (objSelectionOfItem.Category4ViewTakeAway == 1)
                {
                    chkTakeAway.Checked = true;
                }
            }

            oResult = oManager.GetCategoryAncestors(m_selectionItemCategoryID, 4);


            if (oResult.IsSuccess && oResult.Data != null)
            {
                CCategoryAncestor oCatAnc = (CCategoryAncestor)oResult.Data;

                int tmpCat4ID      = oCatAnc.Category4ID;
                int tmpCat3ID      = oCatAnc.Category3ID;
                int tmpCat2ID      = oCatAnc.Category2ID;
                int tmpCat1ID      = oCatAnc.Category1ID;
                int tmpParentCatID = oCatAnc.ParentCategoryID;

                CComboBoxItem oItem1 = new CComboBoxItem(1, "Active");

                CComboBoxItem oItem2 = new CComboBoxItem(0, "InActive");


                if (objSelectionOfItem.Category4OrderStatus == 1)
                {
                    rdoActive.Checked = true;
                }
                else if (objSelectionOfItem.Category4OrderStatus == 0)
                {
                    rdoInactive.Checked = true;
                }
                cmbParent.SelectedValue   = tmpParentCatID;
                cmbFoodType.SelectedValue = tmpCat1ID;
                cmbCategory.SelectedValue = tmpCat2ID;
                cmbFoodItem.SelectedValue = tmpCat3ID;
            }
        }