Skip to content

Commit

Permalink
1.关联关系功能,增加了两个业务对象间可以同时建立多个系的功能.
Browse files Browse the repository at this point in the history
2.模型编辑器本地化,未完成.官方正在解决此问题.暂未给出方案.
  • Loading branch information
tylike committed Sep 18, 2018
1 parent 861e45a commit 9248808
Show file tree
Hide file tree
Showing 17 changed files with 662 additions and 99 deletions.
6 changes: 6 additions & 0 deletions CIIP.Designer.Module.Win/CIIP.Designer.Module.Win.csproj
Expand Up @@ -276,6 +276,12 @@
<Compile Include="Editors\CodeEditor\SmartVisualStudio.Designer.cs">
<DependentUpon>SmartVisualStudio.cs</DependentUpon>
</Compile>
<Compile Include="ModelEditor\ModelEditorControlEx.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ModelEditor\ModelEditorForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
Expand Down
81 changes: 78 additions & 3 deletions CIIP.Designer.Module.Win/Editors/ObjectPropertyEditorEx.cs
@@ -1,29 +1,104 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using CIIP.Designer;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.Editors;
using DevExpress.ExpressApp.Localization;
using DevExpress.ExpressApp.Model;
using DevExpress.ExpressApp.SystemModule;
using DevExpress.ExpressApp.Win;
using DevExpress.ExpressApp.Win.Core;
using DevExpress.ExpressApp.Win.Editors;
using DevExpress.ExpressApp.Win.SystemModule;
using DevExpress.Xpo;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraEditors.Drawing;
using DevExpress.XtraEditors.ViewInfo;

namespace CIIP.Module.Win.Editors
{
[PropertyEditor(typeof(object), "OPE", false)]
public class ObjectPropertyEditorEx : ObjectPropertyEditor
public class AssignDefaultAssocicationInfoController : ObjectViewController<DetailView, PropertyBase>
{
public AssignDefaultAssocicationInfoController()
{

}

protected override void OnActivated()
{
base.OnActivated();
foreach (ObjectPropertyEditor objectPropertyEditor in View.GetItems<ObjectPropertyEditor>())
{
((ISupportViewShowing)objectPropertyEditor).ViewShowingNotification += AssignDefaultAssocicationInfoController_ViewShowingNotification;
}
}

private void AssignDefaultAssocicationInfoController_ViewShowingNotification(object sender, EventArgs e)
{
Application.ViewShowing += Application_ViewShowing;

}

private void Application_ViewShowing(object sender, ViewShowingEventArgs e)
{
Application.ViewShowing -= Application_ViewShowing;
if (e.View != null && e.View.Id == "AssocicationInfo_DetailView")
{
var associcationInfo = (AssocicationInfo)e.View.CurrentObject;
if (e.View.ObjectSpace.IsNewObject(associcationInfo))
{
if (associcationInfo.Properties.Count < 1)
{
associcationInfo.Properties.Add(e.View.ObjectSpace.GetObject(ViewCurrentObject));
}
//shownAddress.Street = ViewCurrentObject.DefaultStreet;
}
}
}

protected override void OnDeactivated()
{
base.OnDeactivated();
foreach (ObjectPropertyEditor objectPropertyEditor in View.GetItems<ObjectPropertyEditor>())
{
((ISupportViewShowing)objectPropertyEditor).ViewShowingNotification -= AssignDefaultAssocicationInfoController_ViewShowingNotification;
}
}

}


[PropertyEditor(typeof(AssocicationInfo), "OPE", false)]
public class ObjectPropertyEditorEx : ObjectPropertyEditor,IComplexViewItem
{
public ObjectPropertyEditorEx(Type objectType, IModelMemberViewItem model) : base(objectType, model)
{
}
XafApplication app;
IObjectSpace os;

void IComplexViewItem.Setup(IObjectSpace os, XafApplication app)
{
this.app = app;
this.os = os;
base.Setup(os, app);
}

protected override object CreateControlCore()
{
var c = base.CreateControlCore() as ObjectEdit;
c.Properties.NullText = "<<自动设置>>";
//c.ShowPopupWindow += C_ShowPopupWindow;
c.Properties.NullValuePrompt = "自动设置";
var manual = c.Properties.Buttons.FirstOrDefault(x => x.Kind == ButtonPredefines.Ellipsis);
if (manual != null)
{
manual.ToolTip = "手动设置";
manual.ToolTip = "手动设置";
}
var clear = new EditorButton(ButtonPredefines.Delete);
clear.Caption = "清除";
Expand Down
72 changes: 72 additions & 0 deletions CIIP.Designer.Module.Win/ModelEditor/ModelEditorControlEx.cs
@@ -0,0 +1,72 @@
using DevExpress.ExpressApp.Model;
using DevExpress.ExpressApp.Model.Core;
using DevExpress.ExpressApp.Utils;
using DevExpress.ExpressApp.Win.Core.ModelEditor;
using DevExpress.ExpressApp.Win.Core.ModelEditor.NodesTree;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
namespace CIIP.Win.ModelEditor
{
[ToolboxItem(false)]
public class ModelEditorControlEx : ModelEditorControl
{

public ModelEditorControlEx(ModelTreeList treeList,SettingsStorage settings) : base(treeList)
{
var fs = typeof(ModelEditorControl).GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
var field = fs.Single(x => x.Name == "settings"); //this.GetType().GetField("settings", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

field.SetValue(this, settings);
//ReflectionHelper..SetMemberValue(this, "settings", settings);
}
}

public class CIIPExtendModelInterfaceAdapter: ExtendModelInterfaceAdapter
{
public override string GetDisplayPropertyValue(object nodeObject)
{
var t = ((ModelTreeListNode)nodeObject).ModelNode;
Debug.WriteLine(t);

var caption = base.GetDisplayPropertyValue(nodeObject);
switch (caption)
{
case "ActionDesign":
return "按钮设置";
case "Actions":
return "按钮";

case "ActionToContainerMapping":
return "容器映射";
case "Controllers":
return "控制器";
case "DisableReasons":
return "禁用原因";
case "BOModel":
return "模型";
case "CreatableItems":
return "快速创建";
case "ImageSources":
return "图像来源";
case "Localization":
return "本地化";
case "NavigationItems":
return "导航设置";
case "Options":
return "选项";
case "Validation":
return "验证";
case "ViewItems":
return "视图项目";
case "Views":
return "视图";
default:
break;
}


return caption;
}
}
}
139 changes: 139 additions & 0 deletions CIIP.Designer.Module.Win/ModelEditor/ModelEditorForm.cs
@@ -0,0 +1,139 @@
using DevExpress.ExpressApp.Templates;
using DevExpress.ExpressApp.Utils;
using DevExpress.ExpressApp.Win.Controls;
using DevExpress.ExpressApp.Win.Core;
using DevExpress.ExpressApp.Win.Core.ModelEditor;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CIIP.Win.ModelEditor
{
[ToolboxItem(false)]
public class ModelEditorForm : DevExpress.ExpressApp.Win.Templates.Bars.DetailFormV2, IModelEditorSettings
{
public const string Title = "模型设置";
private IModelEditorController controller;
private SettingsStorage settingsStorage;
private ModelEditorControl modelEditorControl;
private bool dropModelDifs = false;
public ModelEditorForm(ModelEditorViewController controller, SettingsStorage settingsStorage)
: base()
{
this.settingsStorage = settingsStorage;
((IBarManagerHolder)this).BarManager.MainMenu.Visible = false;
var t = new CIIPExtendModelInterfaceAdapter();
//***********************************************************
//here modified
modelEditorControl = new ModelEditorControlEx(new DevExpress.ExpressApp.Win.Core.ModelEditor.NodesTree.ModelTreeList(t), settingsStorage);

controller.SetControl(modelEditorControl);
controller.SetTemplate(this);
this.controller = controller;
modelEditorControl.Dock = DockStyle.Fill;
((Control)((IViewSiteTemplate)this).ViewSiteControl).Controls.Add(modelEditorControl);
if (settingsStorage != null)
{
new FormStateAndBoundsManager().Load(this, settingsStorage);
}
Image modelEditorImage = ImageLoader.Instance.GetImageInfo("EditModel").Image;
if (modelEditorImage != null)
{
this.Icon = Icon.FromHandle(new Bitmap(modelEditorImage).GetHicon());
}
Text = Title;
Disposed += new EventHandler(ModelEditorForm_Disposed);
this.controller.LoadSettings();
this.Tag = "testdialog=ModelEditor";
}
void ModelEditorForm_Disposed(object sender, EventArgs e)
{
}
public void SetCaption(string text)
{
Text = string.IsNullOrEmpty(text) ? Title : string.Format("{0} - {1}", text, Title);
}
protected virtual DialogResult CloseModelEditorDialog()
{
return ModelEditorViewController.CloseModelEditorDialog;
}
protected override void OnClosing(CancelEventArgs e)
{
if (controller.IsModified)
{
switch (CloseModelEditorDialog())
{
case DialogResult.Yes:
{
if (controller.Save())
{
DialogResult = DialogResult.Yes;
}
else
{
e.Cancel = true;
}
break;
}
case DialogResult.No:
{
dropModelDifs = true;
break;
}
case DialogResult.Cancel:
{
e.Cancel = true;
break;
}
}
}
if (!e.Cancel)
{
//((ModelEditorViewController)controller).UnSubscribeEvents();
ModelEditorSaveSettings();
}
}
protected override void OnClosed(EventArgs e)
{
if (dropModelDifs)
{
controller.ReloadModel(false, false);
}
modelEditorControl.OnClosed();
controller.Dispose();
controller = null;
base.OnClosed(e);
}
protected override void Dispose(bool disposing)
{
lock (ModelEditorViewController.LockDisposeObject)
{
if (controller != null)
{
controller.IsDisposing = true;
}
base.Dispose(disposing);
controller = null;
settingsStorage = null;
if (disposing)
{
modelEditorControl.Dispose();
}
}
}
#region IModelEditorSettingsStorage Members
public void ModelEditorSaveSettings()
{
if (controller != null)
{
controller.SaveSettings();
}
modelEditorControl.CurrentModelTreeListNode = null;
new FormStateAndBoundsManager().Save(this, settingsStorage);
}
#endregion
}
}

0 comments on commit 9248808

Please sign in to comment.