Example #1
0
        private void tsConfigOperation_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            switch (e.ClickedItem.Name)
            {
            case "tsbSaveConifgToDefault":
                try
                {
                    SaveSetting();
                    MessageBox.Show("设置保存成功!");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("设置保存失败:" + ex.Message);
                }
                break;

            case "tsbSaveConfigToFile":
                if (saveFileDialogConfig.ShowDialog() == DialogResult.OK)
                {
                    SerializableHelper.BinarySerializeObjectByPath <UICodeGenerationConfig>(saveFileDialogConfig.FileName,
                                                                                            uiconfig);
                }
                break;

            case "tsbOpenConfigFromFile":
                if (openFileDialogConfig.ShowDialog() == DialogResult.OK)
                {
                    uiconfig = SerializableHelper.BinaryDeserializeObjectByPath(openFileDialogConfig.FileName,
                                                                                DefaultConfig);
                    propertyGridSetting.SelectedObject = uiconfig;
                }
                break;
            }
        }
Example #2
0
 protected void toolStripTop_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
 {
     if (e.ClickedItem.Name == "toolStripButtonSaveCodeGenerateConifg")
     {
         try
         {
             SaveSetting();
             MessageBox.Show("设置保存成功!");
         }
         catch (Exception ex)
         {
             MessageBox.Show("设置保存失败:" + ex.Message);
         }
     }
     else if (e.ClickedItem.Name == "toolStripButtonConfigMygeneration")
     {
         DefaultProperties defaultProperties = new DefaultProperties();
         defaultProperties.ShowDialog();
     }
     else if (e.ClickedItem.Name == "toolStripButtonSaveAs")
     {
         if (this.saveFileDialogConfig.ShowDialog() == DialogResult.OK)
         {
             SerializableHelper.BinarySerializeObjectByPath <T>(this.saveFileDialogConfig.FileName,
                                                                this.config);
         }
     }
     else if (e.ClickedItem.Name == "toolStripButtonLoadConfig")
     {
         if (this.openFileDialogConfig.ShowDialog() == DialogResult.OK)
         {
             this.config = SerializableHelper.BinaryDeserializeObjectByPath(this.openFileDialogConfig.FileName,
                                                                            this.DefaultConfig);
             this.propertyGridSetting.SelectedObject = config;
         }
     }
 }
Example #3
0
 protected void GetSetting()
 {
     config = SerializableHelper.BinaryDeserializeObject <T>(ConfigKey, DefaultConfig);
 }
Example #4
0
 protected void SaveSetting()
 {
     SerializableHelper.BinarySerializeObject <T>(ConfigKey, config);
 }
Example #5
0
 protected void GetSetting()
 {
     uiconfig = SerializableHelper.BinaryDeserializeObject <UICodeGenerationConfig>(UIConfigkey, DefaultConfig, ConfigFileExt);
 }
Example #6
0
 protected void SaveSetting()
 {
     SerializableHelper.BinarySerializeObject <UICodeGenerationConfig>(UIConfigkey, uiconfig, ConfigFileExt);
 }