コード例 #1
0
 /// <summary>
 /// 获取样式节点
 /// </summary>
 private StyleXmlElement GetStyle(StyleType type, string name)
 {
     if (_currenDoc != null)
     {
         Designer.SaveToElement(_currenDoc.StyleElement);
         _currenDoc.Save(_currenDoc.StyleFilePath);
     }
     _currenDoc = StyleXmlDocument.GetStyleDocument(type, name);
     if (_currenDoc == null)
     {
         return(null);
     }
     return(_currenDoc.StyleElement);
 }
コード例 #2
0
 void comboBoxSelectStyle_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBoxSelectStyle.SelectedIndex < 0)
     {
         buttonDelete.Enabled = false;
         return;
     }
     buttonDelete.Enabled = true;
     if (_currenDoc != null)
     {
         Designer.SaveToElement(_currenDoc.StyleElement);
         _currenDoc.Save(_currenDoc.StyleFilePath);
     }
     _currenDoc = StyleXmlDocument.GetStyleDocument(_styleType, comboBoxSelectStyle.Text);
     DisplayStyle();
 }
コード例 #3
0
        void comboBoxSelectStyle_Leave(object sender, EventArgs e)
        {
            bool   _inItems = false;
            string _newName = this.GetText("newName");

            if (!string.IsNullOrEmpty(comboBoxSelectStyle.Text))
            {
                _newName = comboBoxSelectStyle.Text;
            }
            else
            {
                comboBoxSelectStyle.Text = _newName;
            }
            foreach (string fileName in comboBoxSelectStyle.Items)
            {
                if (fileName == _newName)
                {
                    _inItems = true;
                    break;
                }
            }
            if (_inItems)
            {
                buttonDelete.Enabled = true;
                if (_currenDoc != null)
                {
                    Designer.SaveToElement(_currenDoc.StyleElement);
                    _currenDoc.Save(_currenDoc.StyleFilePath);
                }
                _currenDoc = StyleXmlDocument.GetStyleDocument(_styleType, _newName);
            }
            else
            {
                buttonDelete.Enabled = false;

                if (_currenDoc != null)
                {
                    Designer.SaveToElement(_currenDoc.StyleElement);
                    _currenDoc.Save(_currenDoc.StyleFilePath);
                }
                CreateNewStyle(_newName);
                InitComboBox();
            }
            DisplayStyle();
        }
コード例 #4
0
        /// <summary>
        /// edit by zhenghao at 2008-06-19 11:00
        /// 静态方法:获取指定样式类型的所有样式名
        /// </summary>
        /// <returns></returns>
        public static string[] GetStyles(StyleType type)
        {
            List <string> _styles        = new List <string>();
            string        _stylePath     = StyleXmlDocument.GetDirectoryPath(type);
            DirectoryInfo _directoryInfo = new DirectoryInfo(_stylePath);

            if (!_directoryInfo.Exists)
            {
                Directory.CreateDirectory(_stylePath);
                _directoryInfo = new DirectoryInfo(_stylePath);
                return(_styles.ToArray());
            }
            FileInfo[] _fileInfos = _directoryInfo.GetFiles();
            foreach (FileInfo info in _fileInfos)
            {
                if (info.Extension.ToLower() == ".sdstyle")
                {
                    _styles.Add(Path.GetFileNameWithoutExtension(info.Name));
                }
            }
            return(_styles.ToArray());
        }
コード例 #5
0
        /// <summary>
        /// edit by zhenghao at 2008-06-19 15:45
        /// 当下拉框的选择项改变时
        /// </summary>
        /// <param name="styleType"></param>
        private void ComboBoxPageType_SelectdIndexChanged(StyleType styleType, ComboBox comboBox, Label lab)
        {
            int _count = comboBox.Items.Count;

            if (_count < 1 || comboBox.SelectedIndex >= _count)
            {
                return;
            }
            if (comboBox.SelectedIndex == _count - 1)
            {
                DesignStyleForm form = new DesignStyleForm(styleType);
                form.Owner = this;
                if (form.ShowDialog() == DialogResult.OK)
                {
                }
                InitCmbs();
            }
            else
            {
                string styleFileName = comboBox.Text;
                _listBoxPartsDic[styleType].StyleElement = StyleXmlDocument.GetStyleDocument(styleType, styleFileName).StyleElement;
            }
        }
コード例 #6
0
 /// <summary>
 /// 创建新的样式
 /// </summary>
 /// <param name="_newName"></param>
 private void CreateNewStyle(string _newName)
 {
     _currenDoc = StyleXmlDocument.CreatNewStyleDocument(_styleType, _newName);
 }