Exemplo n.º 1
0
        Node AddNode(string nodename = "")
        {
            if (string.IsNullOrEmpty(nodename))
            {
                nodename = "dict";
            }
            Node nodeAdded = null;

            if (treeViewAdvControl.SelectedNode != null)
            {
                Node          parent = treeViewAdvControl.SelectedNode.Tag as Node;
                PlistNodeData data   = GetNodeData(treeViewAdvControl.SelectedNode);
                if (!CheckAddNodePossible(data.nodeType))
                {
                    ShowErrorMsg(CDefines.GetDStr("AddChildFailure"));
                    return(null);
                }
                nodeAdded = AddChild(parent, nodename);
                if (data.nodeType == Constant.NodeTypeDefine.array)
                {
                    nodeAdded.Text = "item";
                }
            }
            else
            {
                nodeAdded = AddRoot(nodename);
            }
            PlistNodeData nodedata = InitNodeData(nodename);

            nodeAdded.Tag      = nodedata;
            nodeAdded.Image    = imageListToolbar.Images[nodedata.nodeType.ToString()];
            haveUnsavedChanges = true;
            return(nodeAdded);
        }
Exemplo n.º 2
0
 private bool XElementParser(XElement xelement, Node parent = null)
 {
     if (xelement == null)
     {
         return(false);
     }
     foreach (XElement xe in xelement.Elements())
     {
         if (xe.Name.LocalName == "key")
         {
             if (xe.ElementsAfterSelf().Count() <= 0)
             {
                 MessageBox.Show(CDefines.GetDStr("OpenFileError"));
                 return(false);
             }
             string   key     = xe.Value;
             XElement xeValue = xe.ElementsAfterSelf().First();
             Node     node    = DataParser(key, xeValue, parent);
             if (xeValue.Name.LocalName == "dict")
             {
                 XElementParser(xeValue, node);
             }
             else if (xeValue.Name.LocalName == "array")
             {
                 ArrayParser(xeValue, node);
             }
         }
     }
     return(true);
 }
Exemplo n.º 3
0
        private void btnApplyType_Click(object sender, EventArgs e)
        {
            if (cmbBoxNodeType.SelectedIndex < 0)
            {
                return;
            }
            if (treeViewAdvControl.SelectedNode == null)
            {
                ShowErrorMsg(CDefines.GetDStr("NothingSelected"));
                return;
            }
            Constant.NodeTypeDefine newtype = GetTypeFromName(cmbBoxNodeType.SelectedItem.ToString());
            PlistNodeData           data    = GetNodeData(treeViewAdvControl.SelectedNode);

            if (data.nodeType == newtype)
            {
                return;
            }
            object oldvalue = data.GetOldValue();

            data.nodeType = newtype;
            data.SetNewValue(oldvalue);
            RefreshEditPanel();
            RefreshTreeIcon(newtype);
        }
Exemplo n.º 4
0
        private void txtBoxNumberValue_Leave(object sender, EventArgs e)
        {
            if (treeViewAdvControl.SelectedNode == null)
            {
                return;
            }

            double num = 0;

            if (!double.TryParse(txtBoxNumberValue.Text, out num))
            {
                txtBoxNumberValue.Text = "0";
                ShowErrorMsg(CDefines.GetDStr("NotNumber"));
                return;
            }


            TreeNodeAdv   nodeadv = treeViewAdvControl.SelectedNode;
            PlistNodeData data    = GetNodeData(nodeadv);

            if (data.value_number != num)
            {
                data.value_number  = num;
                haveUnsavedChanges = true;
            }
        }
Exemplo n.º 5
0
        Node AddNodeAndValue(Node parent, string nodename, object nodevalue)
        {
            if (string.IsNullOrEmpty(nodename))
            {
                new Exception("node name can not be empty!");
            }
            Node nodeAdded = null;

            if (parent != null)
            {
                PlistNodeData data = parent.Tag as PlistNodeData;
                if (!CheckAddNodePossible(data.nodeType))
                {
                    ShowErrorMsg(CDefines.GetDStr("AddChildFailure"));
                    return(null);
                }
                nodeAdded = AddChild(parent, nodename);
            }
            else
            {
                nodeAdded = AddRoot(nodename);
            }

            Constant.NodeTypeDefine itemtype = GetItemTypeByValue(nodevalue);
            PlistNodeData           nodedata = InitNodeData(itemtype, nodename);

            nodedata.SetNewValue(nodevalue);
            nodeAdded.Tag      = nodedata;
            nodeAdded.Image    = imageListToolbar.Images[nodedata.nodeType.ToString()];
            haveUnsavedChanges = true;
            return(nodeAdded);
        }
Exemplo n.º 6
0
        private void pasteToolStripButton_Click(object sender, EventArgs e)
        {
            CCClipBoard clip = CCClipBoard.SingletonInstance();

            if (treeViewAdvControl.SelectedNode == null)
            {
                if (clip.PasteClip(_model, imageListToolbar))
                {
                    haveUnsavedChanges = true;
                }
                return;
            }
            Node          parent = treeViewAdvControl.SelectedNode.Tag as Node;
            PlistNodeData data   = GetNodeData(treeViewAdvControl.SelectedNode);

            if (!CheckAddNodePossible(data.nodeType))
            {
                ShowErrorMsg(CDefines.GetDStr("AddChildFailure"));
                return;
            }

            if (clip.PasteClip(treeViewAdvControl.SelectedNode, imageListToolbar))
            {
                haveUnsavedChanges = true;
            }
        }
Exemplo n.º 7
0
        public static bool SetLanguage(string lang, Form frm, ToolTip tip = null)
        {
            _language = lang;
            string    languageCfg = AppRootPath + "\\Language\\" + lang + ".xml";
            CLanguage langGetNow  = CLanguage.Deserialize(languageCfg);

            if (langGetNow == null)
            {
                MessageBox.Show(CDefines.GetDStr("MSG_NO_LANGUAGE"));
                return(false);
            }
            else
            {
                langInst = langGetNow;
                foreach (LanguageForm langForm in CDefines.langInst.Forms)
                {
                    if (langForm.Name == frm.Name)
                    {
                        foreach (LanguageItem item in langForm.Controls)
                        {
                            ChangeControl(item.name, item.text, item.tooltip, frm, tip);
                        }
                        foreach (LanguageItem item in langForm.Menus)
                        {
                            ChangeMenu(item.name, item.text, item.tooltip, frm);
                        }
                        foreach (LanguageItem item in langForm.Toolbars)
                        {
                            ChangeToolbar(item.name, item.text, item.tooltip, frm);
                        }
                        foreach (LanguageListView langView in langForm.ListViews)
                        {
                            Control[] ctrls = frm.Controls.Find(langView.Name, true);
                            if (ctrls != null && ctrls.Length > 0)
                            {
                                ListView listViewFind = ctrls[0] as ListView;
                                foreach (ColumnHeader col in listViewFind.Columns)
                                {
                                    if (langView.Columns[col.Index] != null)
                                    {
                                        col.Text = langView.Columns[col.Index].text;
                                    }
                                }
                                foreach (ListViewGroup grp in listViewFind.Groups)
                                {
                                    grp.Header = FindGroupInListView(grp.Name, langView.Groups);
                                }
                            }
                        }
                    }
                }

                return(true);
            }
        }
Exemplo n.º 8
0
        private void copyToolStripButton_Click(object sender, EventArgs e)
        {
            if (treeViewAdvControl.SelectedNode == null)
            {
                ShowErrorMsg(CDefines.GetDStr("NothingSelected"));
                return;
            }

            CCClipBoard clip = CCClipBoard.SingletonInstance();

            clip.SaveToPrivateClip(treeViewAdvControl.SelectedNode, null);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 反序列化XML字符串为对象
        /// </summary>
        /// <param name="xmlSource"></param>
        /// <returns></returns>
        public static CSetup Deserialize(string filename)
        {
            object obj = CDefines.Deserialize(filename, typeof(CSetup));

            if (obj == null)
            {
                return(new CSetup());
            }
            else
            {
                return((CSetup)obj);
            }
        }
Exemplo n.º 10
0
        private void cutToolStripButton_Click(object sender, EventArgs e)
        {
            if (treeViewAdvControl.SelectedNode == null)
            {
                ShowErrorMsg(CDefines.GetDStr("NothingSelected"));
                return;
            }

            CCClipBoard clip = CCClipBoard.SingletonInstance();

            clip.SaveToPrivateClip(treeViewAdvControl.SelectedNode, null);

            (treeViewAdvControl.SelectedNode.Tag as Node).Parent = null;
            haveUnsavedChanges = true;
        }
Exemplo n.º 11
0
        void UpdateKey(TextBox txtBox)
        {
            if (string.IsNullOrEmpty(txtBox.Text))
            {
                txtBox.Undo();
                ShowErrorMsg(CDefines.GetDStr("NodeNameNullError"));
                return;
            }
            if (treeViewAdvControl.SelectedNode == null)
            {
                return;
            }
            TreeNodeAdv nodeadv = treeViewAdvControl.SelectedNode;

            (nodeadv.Tag as Node).Text = txtBox.Text;
            haveUnsavedChanges         = true;
        }
Exemplo n.º 12
0
        private void importToolStripButton_Click(object sender, EventArgs e)
        {
            if (treeViewAdvControl.SelectedNode == null)
            {
                ImportCSV(null, Constant.NodeTypeDefine.dict);
                return;
            }

            Node          parent = treeViewAdvControl.SelectedNode.Tag as Node;
            PlistNodeData data   = GetNodeData(treeViewAdvControl.SelectedNode);

            if (!CheckAddNodePossible(data.nodeType))
            {
                ShowErrorMsg(CDefines.GetDStr("AddChildFailure"));
                return;
            }
            ImportCSV(parent, data.nodeType);
        }
Exemplo n.º 13
0
 bool CloseWithoutSave()
 {
     if (HaveUnsavedContent())
     {
         System.Windows.Forms.DialogResult res = MessageBox.Show(CDefines.GetDStr("SaveFileWarning"),
                                                                 CDefines.GetDStr("SaveFileWarningTitle"), MessageBoxButtons.YesNoCancel,
                                                                 MessageBoxIcon.Warning);
         if (res == System.Windows.Forms.DialogResult.Yes)
         {
             return(SaveFile());
         }
         else if (res == System.Windows.Forms.DialogResult.No)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 14
0
        /// <summary>
        /// 序列化为XML字符串
        /// </summary>
        /// <returns></returns>
        public void Serialize(string filename)
        {
            string strConfig = CDefines.Serialize(this, typeof(CSetup));

            File.WriteAllText(filename, strConfig, Encoding.UTF8);
        }
Exemplo n.º 15
0
 bool SetLanguage(string language)
 {
     return(CDefines.SetLanguage(language, this));
 }
Exemplo n.º 16
0
 void _DataNULLException()
 {
     throw new Exception(CDefines.GetDStr("UnknownException"));
 }
Exemplo n.º 17
0
 private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
 {
     CDefines.SetContextMenuLanguage(this.Name, contextMenuStrip1);
 }