/// <summary> /// Показать (установить данные для показа) детальное представление объекта операции /// </summary> /// <param name="obj">Объект операции</param> /// <param name="app">Объект XafApplication</param> /// <param name="sp">Объект ShowViewParameters</param> /// <exception cref="System.ArgumentNullException" /> public static void Show(this OperationObject obj, XafApplication app, ShowViewParameters sp) { if (obj == null) { throw new ArgumentNullException("obj"); } if (app == null) { throw new ArgumentNullException("app"); } if (sp == null) { throw new ArgumentNullException("sp"); } var isComposite = obj.Children != null && obj.Children.Count > 0; if (isComposite) { sp.CreatedView = app.CreateDetailView(ObjectSpaceInMemory.CreateNew(), "OperationObject_DetailView_(Composite)", true, obj); } else { sp.CreatedView = app.CreateDetailView(ObjectSpaceInMemory.CreateNew(), obj); } sp.TargetWindow = TargetWindow.NewModalWindow; sp.Context = TemplateContext.PopupWindow; }
void AddDialogController(ShowViewParameters showViewParameters) { var dialogController = new DialogController(); dialogController.AcceptAction.Model.SetValue("IsPostBackRequired", true); dialogController.CloseOnCurrentObjectProcessing = true; dialogController.AcceptAction.Executed+=AcceptActionOnExecuteCompleted; showViewParameters.Controllers.Add(dialogController); }
private void AttachDialogController(ShowViewParameters svp, XafApplication app) { var dc = app.CreateController<DialogController>(); dc.AcceptAction.Execute += AcceptAction_Execute; dc.CancelAction.Enabled.SetItemValue("Cancel Disabled", false); dc.CancelAction.Active.SetItemValue("Cancel Disabled", false); svp.Controllers.Add(dc); }
protected override void ShowViewFromNestedView(ShowViewParameters parameters, ShowViewSource showViewSource) { if (((IModelListViewOpenViewWhenNested)showViewSource.SourceFrame.View.Model).OpenViewWhenNestedStrategy==OpenViewWhenNestedStrategy.InMainWindow) Application.MainWindow.SetView(parameters.CreatedView, showViewSource.SourceFrame); else { base.ShowViewFromNestedView(parameters, showViewSource); } }
protected override void ReplaceLayer(ModelApplicationBase model, ModelApplicationBase layer, bool isCurrentUserModel, ShowViewParameters showViewParameters){ var showViewStrategyBase = (WinShowViewStrategyBase)Application.ShowViewStrategy; var modelApplicationBase = ((ModelApplicationBase)Application.Model); var lastLayer = modelApplicationBase.LastLayer; modelApplicationBase.RemoveLayer(lastLayer.Id); var dummyLayer = modelApplicationBase.CreatorInstance.CreateModelApplication(); dummyLayer.Id = lastLayer.Id; ModelApplicationHelper.AddLayer(modelApplicationBase, dummyLayer); var keyValue = ObjectSpace.GetKeyValue(View.CurrentObject); var objectType = View.ObjectTypeInfo.Type; var modelDetailView = View.Model; showViewStrategyBase.CloseAllWindows(); base.ReplaceLayer(model, layer, isCurrentUserModel,showViewParameters); showViewStrategyBase.ShowStartupWindow(); var xafApplication = ApplicationHelper.Instance.Application; var objectSpace = xafApplication.CreateObjectSpace(); var objectByKey = objectSpace.GetObjectByKey(objectType,keyValue); showViewStrategyBase = (WinShowViewStrategyBase)xafApplication.ShowViewStrategy; showViewParameters.CreatedView = xafApplication.CreateDetailView(objectSpace, modelDetailView, true, objectByKey); showViewStrategyBase.ShowView(showViewParameters, new ShowViewSource(null,null)); }
protected override void ShowReminderAlerts(object sender, ReminderEventArgs e) { var view = (DashboardView)Application.CreateView(Application.FindModelView("ReminderFormView")); var showViewParameters = new ShowViewParameters(view); var dashboardViewItems = view.GetItems<DashboardViewItem>().First(); showViewParameters.TargetWindow = TargetWindow.NewWindow; dashboardViewItems.ControlCreated += DashboardViewItemsOnControlCreated; Application.ShowViewStrategy.ShowView(showViewParameters, new ShowViewSource(Application.MainWindow, null)); }
private void AttachDialogController(ShowViewParameters svp, XafApplication app, MessageBoxEventHandler accept, EventHandler cancel) { LocalAccept = accept; LocalCancel = cancel; var dc = app.CreateController<DialogController>(); dc.AcceptAction.Execute += AcceptAction_Execute; dc.Cancelling += dc_Cancelling; svp.Controllers.Add(dc); }
// B135637 protected override void ShowViewInModalWindow(ShowViewParameters parameters, ShowViewSource showViewSource) { modalCount++; try { base.ShowViewInModalWindow(parameters, showViewSource); } finally { modalCount--; } }
public void SetView(ShowViewParameters showViewParameters) { _handleModelSaving = ((IModelViewModelSaving)View.Model).HandleModelSaving; ((IModelViewModelSaving)View.Model).HandleModelSaving = true; showViewParameters.CreatedView = Application.CreateView(View.Model); showViewParameters.CreatedView.CurrentObject = !ObjectSpace.IsNewObject(View.CurrentObject) ? showViewParameters.CreatedView.ObjectSpace.GetObject(View.CurrentObject) : showViewParameters.CreatedView.ObjectSpace.CreateObject(View.ObjectTypeInfo.Type); showViewParameters.TargetWindow = TargetWindow.Current; showViewParameters.Context = TemplateContext.View; }
protected override void InitShowViewParametersCore(ShowViewParameters parameters, string detailViewId, bool autoCloseWindow) { base.InitShowViewParametersCore(parameters, detailViewId, autoCloseWindow); parameters.Controllers.Add(new WinSyncAurumOperationDialogController { OperationManager = base.OperationManager, AutoCloseWindow = autoCloseWindow, Operation = base.Operation }); }
protected override void OpenSelectedItem() { var selectedReminders = GetSelectedReminders(); if (selectedReminders.Count <= 0) return; var appointment = selectedReminders[0].Appointment; var objectSpace = _xafApplication.CreateObjectSpace(); var objectType = (Type) appointment.CustomFields[Scheduler.Reminders.SchedulerStorage.BOType]; var obj = objectSpace.FindObject(objectType, new BinaryOperator("Oid", appointment.Id)); var detailView = _xafApplication.CreateDetailView(objectSpace, obj); var showViewParameters = new ShowViewParameters(detailView); _xafApplication.ShowViewStrategy.ShowView(showViewParameters, new ShowViewSource(_xafApplication.MainWindow, null)); }
protected override void ShowViewCore(ShowViewParameters parameters, ShowViewSource showViewSource) { if (parameters.CreatedView is DetailView) {// показываем детальные представления в модальных окнах //parameters.NewWindowTarget = NewWindowTarget.Separate; parameters.TargetWindow = TargetWindow.NewModalWindow; //AdditionalCustomization(parameters); } base.ShowViewCore(parameters, showViewSource); }
/// <summary> /// Показать окно предпросмотра отчета /// </summary> /// <param name="controller">Контроллер</param> /// <param name="reportType">Тип отчета</param> /// <param name="parametersObject">Объект параметров</param> /// <param name="showViewParameters">Объект DevExpress.ExpressApp.ShowViewParameters</param> public static void ShowPreview(this ReportServiceController controller, Type reportType, ReportParametersObjectBase parametersObject, ShowViewParameters showViewParameters) { var objectSpace = ReportDataProvider.ReportObjectSpaceProvider.CreateObjectSpace(typeof(ReportDataV2)); var reportData1 = objectSpace.FindObject<ReportDataV2>(new BinaryOperator("PredefinedReportType", reportType)); var reportData2 = (IReportDataV2)objectSpace.FindObject<XtraReportData>(new BinaryOperator("PredefinedReportType", reportType)); var report = ReportDataProvider.ReportsStorage.LoadReport(reportData1 ?? reportData2); var reportContainerHandler = ReportDataProvider.ReportsStorage.GetReportContainerHandle(reportData1 ?? reportData2); controller.ShowPreview(reportContainerHandler, parametersObject, parametersObject.GetCriteria(), true, parametersObject.GetSorting(), true, showViewParameters); }
/// <summary> /// Показать окно предпросмотра отчета /// </summary> /// <param name="reportController">Контроллер</param> /// <param name="reportContainerHandle">Дескриптор</param> /// <param name="parametersObject">Объект параметров</param> /// <param name="criteria">Критерий</param> /// <param name="canApplyCriteria">Можно ли применить критерий</param> /// <param name="sortProperty">Сортировка</param> /// <param name="canApplySortProperty">Можно ли применить сортировку</param> /// <param name="showViewParameters">Объект DevExpress.ExpressApp.ShowViewParameters</param> public static void ShowPreview(this ReportServiceController reportController, string reportContainerHandle, ReportParametersObjectBase parametersObject, CriteriaOperator criteria, bool canApplyCriteria, SortProperty[] sortProperty, bool canApplySortProperty, ShowViewParameters showViewParameters) { var objectSpace = ReportDataProvider.ReportObjectSpaceProvider.CreateObjectSpace(typeof(ReportDataV2)); Audit.ReportTrail.LogOperation(objectSpace, reportContainerHandle, parametersObject); var type = reportController.GetType().BaseType; var method = type.GetMethod("ShowReportPreview", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance, null, new Type[] { typeof(string), typeof(ReportParametersObjectBase), typeof(CriteriaOperator), typeof(bool), typeof(SortProperty[]), typeof(bool), typeof(ShowViewParameters) }, null); if (method != null) { method.Invoke(reportController, new object[] { reportContainerHandle, parametersObject, criteria, canApplyCriteria, sortProperty, canApplySortProperty, showViewParameters }); } }
/// <summary> /// Gets called when a view is shown /// </summary> /// <param name="parameters">ShowView Parameters</param> /// <param name="showViewSource">ShowView Source</param> protected override void ShowViewCore(ShowViewParameters parameters, ShowViewSource showViewSource){ _ShowInWizard = false; if (parameters.CreatedView is DetailView){ DictionaryNode wizardNode = parameters.CreatedView.Info.FindChildNode("Wizard"); _ShowInWizard = wizardNode != null && wizardNode.ChildNodes.Count > 0 && wizardNode.GetAttributeBoolValue("ShowInWizard", false); if (_ShowInWizard){ parameters.TargetWindow = TargetWindow.NewModalWindow; } } base.ShowViewCore(parameters, showViewSource); }
protected virtual void AddNewObject() { var svp = new ShowViewParameters(); IObjectSpace newObjectViewObjectSpace = _helper.Application.CreateObjectSpace(); object newObject = RuntimeHelpers.GetObjectValue(newObjectViewObjectSpace.CreateObject(_helper.LookupObjectTypeInfo.Type)); lookupObjectView = _helper.Application.CreateDetailView(newObjectViewObjectSpace, RuntimeHelpers.GetObjectValue(newObject), true); svp.CreatedView = lookupObjectView; newObjectViewObjectSpace.Committed += newObjectViewObjectSpace_Committed; newObjectViewObjectSpace.Disposed += newObjectViewObjectSpace_Disposed; svp.TargetWindow = TargetWindow.NewModalWindow; svp.Context = TemplateContext.PopupWindow; svp.Controllers.Add(_helper.Application.CreateController<DialogController>()); _helper.Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null)); }
private void AdditionalCustomization(ShowViewParameters parameters) { parameters.Context = TemplateContext.PopupWindow; parameters.CreateAllControllers = true; DialogController dialog = this.Application.CreateController<DialogController>(); dialog.Accepting += (o, a) => { parameters.CreatedView.ObjectSpace.CommitChanges(); }; dialog.Cancelling += (o, a) => { ((Controller)o).Frame.GetController<DevExpress.ExpressApp.Win.SystemModule.WinDetailViewController>().SuppressConfirmation = true; }; parameters.Controllers.Add(dialog); }
private void RepositoryItem_OnButtonClick(object sender, ButtonPressedEventArgs e) { if (e.Button.Kind == ButtonPredefines.Delete) { if (MessageBox.Show("Delete current view?", null,MessageBoxButtons.YesNo)==DialogResult.Yes) { deleteView(sender); return; } } else if (e.Button.Kind==ButtonPredefines.Ellipsis) { var objectSpace = Application.CreateObjectSpace(); var viewCloner = new ViewCloner(objectSpace.Session){Caption = Frame.GetController<ChangeVariantController>().ChangeVariantAction.SelectedItem.Caption}; var detailView = Application.CreateDetailView(objectSpace, viewCloner); var parameters = new ShowViewParameters(detailView) {TargetWindow = TargetWindow.NewModalWindow}; var controller = new DialogController(); controller.AcceptAction.Execute+=EditViewActionOnExecute; parameters.Controllers.Add(controller); Application.ShowViewStrategy.ShowView(parameters, new ShowViewSource(null, null)); } }
private void SaveAndCloseAction_Execute(object sender, SimpleActionExecuteEventArgs e) { ViewNavigationController navi = Frame.GetController<ViewNavigationController>(); try { DevExpress.Persistent.Validation.Validator.RuleSet.Validate(View.CurrentObject, new DevExpress.Persistent.Validation.ContextIdentifiers("Save")); //((DevExpress.ExpressApp.DC.DCBaseObject)View.CurrentObject).Save(); ((DevExpress.ExpressApp.Xpo.XPObjectSpace)View.ObjectSpace).Session.LockingOption = DevExpress.Xpo.LockingOption.Optimistic; View.ObjectSpace.CommitChanges(); ViewShortcut workspace = new ViewShortcut("Workspace", ""); ChoiceActionItem choiceItem = new ChoiceActionItem("workSpaceShortCut", workspace); navi.NavigateBackAction.Items.Add(choiceItem); try { navi.NavigateBackAction.DoExecute(navi.NavigateBackAction.Items.FirstActiveItem); } catch (Exception ex) { ShowViewParameters svp = new ShowViewParameters(); IObjectSpace mainViewObjectSpace = Application.CreateObjectSpace(); DashboardView mainView = Application.CreateDashboardView(mainViewObjectSpace, "Workspace", true); svp.CreatedView = mainView; svp.TargetWindow = TargetWindow.Default; svp.Context = TemplateContext.ApplicationWindow; Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null)); } } catch (Exception ex) { if (ex is DevExpress.Persistent.Validation.ValidationException) { throw; } }; }
protected virtual void ShowMapConfigView(ShowViewParameters parameters) { }
public void ShowPreview(string reportContainerHandle, ReportParametersObjectBase parametersObject, CriteriaOperator criteria, bool canApplyCriteria, SortProperty[] sortProperty, bool canApplySortProperty, ShowViewParameters showViewParameters) { base.ShowReportPreviewCore(reportContainerHandle, parametersObject, criteria, canApplyCriteria, sortProperty, canApplySortProperty, showViewParameters); }
void selectAcception_AcceptingAdmin(object sender, DialogControllerAcceptingEventArgs e) { ObjectSpace objectSpace = Application.CreateObjectSpace(); DevExpress.ExpressApp.ListView lv = ((DevExpress.ExpressApp.ListView)((WindowController)sender).Window.View); User u = (User)SecuritySystem.CurrentUser; XPCollection <Role> xpc = new XPCollection <Role>(u.Roles, new BinaryOperator("Name", "Administrators")); XPCollection <Role> xpc2 = new XPCollection <Role>(u.Roles, new BinaryOperator("Name", "DataAdmins")); if (xpc.Count + xpc2.Count > 0) { objectSpace.Session.BeginTransaction(); Student currentStudent; Lesson curLesson; foreach (string studentCode in listStudentCode) { currentStudent = objectSpace.FindObject <Student>( new BinaryOperator("StudentCode", studentCode)); foreach (Lesson lesson in lv.SelectedObjects) { curLesson = objectSpace.FindObject <Lesson>( new BinaryOperator("Oid", lesson.Oid)); RegisterDetail regdetail = new RegisterDetail(objectSpace.Session) { Student = currentStudent, Lesson = curLesson, RegisterState = objectSpace.FindObject <RegisterState>( new BinaryOperator("Code", "SELECTED")), CheckState = objectSpace.FindObject <RegisterState>( new BinaryOperator("Code", "NOTCHECKED")) }; RuleSet ruleSet = new RuleSet(); RuleSetValidationResult result = ruleSet.ValidateTarget(regdetail, DefaultContexts.Save); if (ValidationState.Invalid == result.GetResultItem("RegisterDetail.StudentRegLessonSemester").State) { regdetail.Delete(); } else { regdetail.Save(); } } } objectSpace.Session.CommitTransaction(); PopUpMessage ms = objectSpace.CreateObject <PopUpMessage>(); ms.Title = "Lỗi đăng ký"; ms.Message = string.Format("Error"); ShowViewParameters svp = new ShowViewParameters(); svp.CreatedView = Application.CreateDetailView( objectSpace, ms); svp.TargetWindow = TargetWindow.NewModalWindow; svp.CreatedView.Caption = "Thông báo"; DialogController dc = Application.CreateController <DialogController>(); svp.Controllers.Add(dc); dc.SaveOnAccept = false; Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null)); //// View.ObjectSpace.CommitChanges(); //View.ObjectSpace.Refresh(); //ListView view = null; //Frame currentFrame = ((ActionBase)sender).Controller.Frame; //switch (currentFrame.View.ObjectTypeInfo.Name) //{ // case "Student": // view = Application.CreateListView(objectSpace,typeof(RegisterDetail),true); // break; //} //currentFrame.SetView(view); //e.Cancel = true; } }
void selectAcception_Accepting(object sender, DialogControllerAcceptingEventArgs e) { ListView lv = (ListView)((WindowController)sender).Window.View; ObjectSpace objectSpace = Application.CreateObjectSpace(); PopUpMessage ms = objectSpace.CreateObject <PopUpMessage>(); int i = 0; if (View.SelectedObjects.Count > 0) { if (lv.SelectedObjects.Count > 0) { AccountTransactionFile actFile = objectSpace.FindObject <AccountTransactionFile>( CriteriaOperator.Parse("Oid=?", ((AccountTransactionFile)View.SelectedObjects[0]).Oid)); string tempStudentFolderPath; string tempStudentLogFile; string templogname = ""; if (HttpContext.Current != null) { tempStudentFolderPath = HttpContext.Current.Request.MapPath("~/tempFolder"); templogname = actFile.CsvFile.FileName + DateTime.Now.ToString("dd-MM-yyyy-HHmmss") + "-log.html"; tempStudentLogFile = HttpContext.Current.Request.MapPath("~/tempFolder/" + templogname); } else { tempStudentFolderPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "tempFolder"); templogname = actFile.CsvFile.FileName + DateTime.Now.ToString("dd-MM-yyyy-HHmmss") + "-log.html"; tempStudentLogFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "tempFolder/", templogname); } if (!Directory.Exists(tempStudentFolderPath)) { Directory.CreateDirectory(tempStudentFolderPath); } using (System.IO.StreamWriter fileStreamlog = new System.IO.StreamWriter(tempStudentLogFile, true)) { fileStreamlog.WriteLine("<html><header><title>" + actFile.CsvFile.FileName + DateTime.Now.ToString("dd-MM-yyyy-HHmmss") + "-log </title> "+ "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" />" + "</head><body>\r\n<table border=\"1px\"> <tr><Th>DÒNG</Th><th>MSSV</th><th>HỌ TÊN</Th><Th>SỐ TIỀN</Th><Th>NGÀY THỰC HIỆN</Th><Th> NỘI DUNG </Th><th>GHI CHÚ</th></Tr>"); foreach (MyImportResult myImportResult in lv.SelectedObjects) { if (myImportResult.CanImport) { fileStreamlog.WriteLine("<tr>"); AccountTransaction acc = objectSpace.CreateObject <AccountTransaction>(); string[] datas = myImportResult.Data.Split('|'); fileStreamlog.WriteLine(string.Format("<TD>{0}</TD>", myImportResult.Line)); acc.Student = objectSpace.FindObject <Student>(new BinaryOperator("StudentCode", datas[0])); fileStreamlog.WriteLine(string.Format("<TD>{0}</td><td>{1}</td>", acc.Student.StudentCode, acc.Student.FullName)); acc.MoneyAmount = Decimal.Parse(datas[3].ToString()); try { acc.TransactingDate = new DateTime(1900, 1, 1).AddDays( Double.Parse(datas[4].ToString()) - 2); } catch { acc.TransactingDate = DateTime.Now; } acc.Semester = objectSpace.FindObject <Semester>( CriteriaOperator.Parse("SemesterName = ?", actFile.Semester.SemesterName)); acc.Description = datas[5].ToString(); acc.DateCreated = acc.DateModified = DateTime.Now; acc.ImportDescription = actFile.Note; fileStreamlog.WriteLine(string.Format("<TD>{0:0,0}</td><td>{1:dd-MM-yyyy} {1:HH}:{1:mm}</td><td>{2}</td><td>{3}</td>", acc.MoneyAmount, acc.TransactingDate, acc.Description, actFile.Note)); acc.Save(); i++; fileStreamlog.WriteLine("</tr>"); } } fileStreamlog.WriteLine("</table></body></html>"); fileStreamlog.Close(); } objectSpace.SetModified(actFile); actFile.IsImported = true; actFile.ResultLink = "/tempFolder/" + templogname; objectSpace.CommitChanges(); this.View.Refresh(); ms.Title = "Kết quả import dữ liệu"; ms.Message = string.Format("Đã import thành công {0} dòng dữ liệu vào hệ thống", i); ShowViewParameters svp = new ShowViewParameters(); svp.CreatedView = Application.CreateDetailView( objectSpace, ms); svp.TargetWindow = TargetWindow.NewModalWindow; svp.CreatedView.Caption = "Thông báo"; DialogController dc = Application.CreateController <DialogController>(); svp.Controllers.Add(dc); dc.AcceptAction.Active.SetItemValue("object", false); dc.CancelAction.Caption = "Đóng"; dc.SaveOnAccept = false; Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null)); } } }
public SearchLookUpEditEx() { base.DataBindings.CollectionChanged += DataBindings_CollectionChanged; this.QueryCloseUp += (object sender, CancelEventArgs e) => { e.Cancel = preventClose; }; this.Popup += delegate(object sender, EventArgs e) { ControlCollection coll = this.PopupForm.Controls; DevExpress.XtraGrid.Editors.SearchEditLookUpPopup form = (coll[2] as DevExpress.XtraGrid.Editors.SearchEditLookUpPopup); foreach (System.Windows.Forms.Control SearchPopupC in form.Controls) { if (SearchPopupC is LayoutControl) { LayoutControl FormLayout = SearchPopupC as LayoutControl; FormLayout.BeginUpdate(); System.Windows.Forms.Control findButton = FormLayout.GetControlByName("btFind"); if (findButton != null) { LayoutControlItem current = FormLayout.GetItemByControl(findButton); current.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; } ListBtn = new SimpleButton(); ListBtn.Size = new System.Drawing.Size(25, 45); ListBtn.Text = CaptionHelper.GetLocalizedText("DialogButtons", "Go to list"); ListBtn.Name = "ListBtn"; if (FormLayout.GetControlByName("ListBtn") == null) { FormLayout.Controls.Add(ListBtn); } System.Windows.Forms.Control addButton = FormLayout.GetControlByName("btAddNew"); System.Windows.Forms.Control searchField = FormLayout.GetControlByName("teFind"); //System.Windows.Forms.Control clearValueBtn = FormLayout.GetControlByName("btClear"); //clearValueBtn.Visible = false; if (FormLayout.Items.FindByName("ListBtn") == null) FormLayout.AddItem(" ", ListBtn); System.Windows.Forms.Control ListViewBtn = FormLayout.GetControlByName("ListBtn"); System.Windows.Forms.Control gridTable = FormLayout.Controls[10]; //((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).DoubleClick += (object send, EventArgs eArgs) => //{ // if (((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).GetFocusedRow() != null) // { // EditValue = ((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).GetFocusedRow(); // preventClose = false; // this.ClosePopup(); // this.DoValidate(); // } //}; (gridTable as DevExpress.XtraGrid.GridControl).Click += (object send, EventArgs eArgs) => { // preventClose = true; if (((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).GetFocusedRow() != null) { EditValue = ((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).GetFocusedRow(); preventClose = false; this.DoValidate(); } }; //((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).OptionsSelection.EnableAppearanceHideSelection = false; //((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).FocusedRowChanged += (object send, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs eArgs) => //{ // if (((DevExpress.XtraGrid.Views.Grid.GridView)send).SelectedRowsCount != 0) // clearValueBtn.Enabled = true; // else // clearValueBtn.Enabled = false; //}; //(gridTable as DevExpress.XtraGrid.GridControl).FocusedViewChanged += (object send, DevExpress.XtraGrid.ViewFocusEventArgs eArgs) => //{ // if (((DevExpress.XtraGrid.Views.Grid.GridView)((DevExpress.XtraGrid.GridControl)send).MainView).SelectedRowsCount != 0) // clearValueBtn.Enabled = true; // else // clearValueBtn.Enabled = false; //}; if (addButton != null && searchField != null && /*clearValueBtn != null && */ListViewBtn != null && firstCreated != false) { //clearValueBtn.Text = CaptionHelper.GetLocalizedText("DialogButtons", "Select"); //clearValueBtn.Enabled = false; LayoutControlItem buttonToMove = FormLayout.GetItemByControl(addButton); LayoutControlItem textBoxToMove = FormLayout.GetItemByControl(searchField); LayoutControlItem ListBtnTomove = FormLayout.GetItemByControl(ListViewBtn); LayoutControlItem emptySpace = (LayoutControlItem)FormLayout.Items[9]; //LayoutControlItem clearValueBtnToMove = FormLayout.GetItemByControl(clearValueBtn); LayoutItemDragController dragController = new LayoutItemDragController(buttonToMove, textBoxToMove, MoveType.Inside, InsertLocation.After, LayoutType.Horizontal); buttonToMove.Move(dragController); ListBtnTomove.SizeConstraintsType = SizeConstraintsType.Custom; ListBtnTomove.Size = new Size(108, 26); ListBtnTomove.MinSize = new Size(108, 26); ListBtnTomove.MaxSize = new Size(108, 26); ListBtnTomove.Name = "ListBtn"; //LayoutItemDragController thirdController = new LayoutItemDragController(clearValueBtnToMove, //emptySpace, MoveType.Inside, InsertLocation.After, LayoutType.Horizontal); //clearValueBtnToMove.Move(thirdController); LayoutItemDragController secdragController = new LayoutItemDragController(ListBtnTomove, emptySpace, MoveType.Inside, InsertLocation.After, LayoutType.Horizontal); ListBtnTomove.Move(secdragController); firstCreated = false; } if (searchFieldEmpty) { addButton.Enabled = false; } //clearValueBtn.Click += (object send, EventArgs args) => // { // if (((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).GetFocusedRow() != null) // { // this.EditValue = ((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).GetFocusedRow(); // preventClose = false; // } // }; searchField.TextChanged += (object send, EventArgs args) => { if (((TextEdit)send).Text == string.Empty) { searchFieldEmpty = true; addButton.Enabled = false; } else { searchFieldEmpty = false; if (((DevExpress.XtraGrid.GridControl)gridTable).MainView.RowCount == 0) addButton.Enabled = true; ((DevExpress.XtraGrid.GridControl)gridTable).MainView.RowCountChanged += (object sendr, EventArgs eArgs) => { if (((DevExpress.XtraGrid.Views.Grid.GridView)sendr).RowCount == 0) addButton.Enabled = true; else addButton.Enabled = false; }; } }; ListBtn.Click += (object send, EventArgs args) => { if (!ListViewDisabled) { ShowViewParameters svp = new ShowViewParameters(); IObjectSpace ObjectsListViewObjectSpace = Properties.Helper.Application.CreateObjectSpace(); ObjectsListView = Properties.Helper.Application.CreateListView(ObjectsListViewObjectSpace, Properties.Helper.LookupObjectTypeInfo.Type, true); svp.CreatedView = ObjectsListView; svp.TargetWindow = TargetWindow.NewModalWindow; svp.Context = TemplateContext.View; svp.CreatedView.ObjectSpace.ObjectDeleted += (object sendr, ObjectsManipulatingEventArgs eArgs) => { ((DevExpress.ExpressApp.Xpo.XPObjectSpace)sendr).Session.AfterCommitTransaction += (object sendObject, SessionManipulationEventArgs EvArgs) => { foreach (object obj in eArgs.Objects) { if (EditValue != null) { if (obj.ToString() == EditValue.ToString()) { this.clear = true; EditValue = null; this.DoValidate(); } } } }; }; viewCreatedHandler += (object sendr, ViewCreatedEventArgs eArgs) => { eArgs.View.ObjectSpace.ObjectDeleted += (object sendObject, DevExpress.ExpressApp.ObjectsManipulatingEventArgs EvArgs) => { ((DevExpress.ExpressApp.Xpo.XPObjectSpace)sendObject).Session.AfterCommitTransaction += (object sendObject2, SessionManipulationEventArgs EvArgs2) => { foreach (object obj in EvArgs.Objects) { if (EditValue != null) { if (obj.ToString() == EditValue.ToString()) { this.clear = true; EditValue = null; this.DoValidate(); } } } }; }; Properties.Helper.Application.ViewCreated -= viewCreatedHandler; CreatedView = eArgs.View; CreatedView.Closed += CreatedView_Closed; }; svp.CreateAllControllers = true; Properties.Helper.Application.ViewCreated += viewCreatedHandler; Properties.Helper.Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null)); preventClose = false; this.ClosePopup(); } // if (((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).GetFocusedRow() != null) // { // IObjectSpace newObjectViewObjectSpace = Properties.Helper.Application.CreateObjectSpace(); // object deleting = ((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).GetFocusedRow(); // if (EditValue == deleting) // { // EditValue = null; // isDeleting = true; // } // newObjectViewObjectSpace.Delete(newObjectViewObjectSpace.GetObject(deleting)); // newObjectViewObjectSpace.CommitChanges(); // ((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).DeleteRow(((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).FocusedRowHandle); // preventClose = false; // } }; FormLayout.EndUpdate(); } } }; }
void selectAcception_AcceptingAdmin(object sender, DialogControllerAcceptingEventArgs e) { ObjectSpace objectSpace = Application.CreateObjectSpace(); DevExpress.ExpressApp.ListView lv = ((DevExpress.ExpressApp.ListView)((WindowController)sender).Window.View); User u = (User)SecuritySystem.CurrentUser; XPCollection<Role> xpc = new XPCollection<Role>(u.Roles, new BinaryOperator("Name", "Administrators")); XPCollection<Role> xpc2 = new XPCollection<Role>(u.Roles, new BinaryOperator("Name", "DataAdmins")); if (xpc.Count + xpc2.Count > 0) { objectSpace.Session.BeginTransaction(); Student currentStudent; Lesson curLesson; foreach (string studentCode in listStudentCode) { currentStudent = objectSpace.FindObject<Student>( new BinaryOperator("StudentCode", studentCode)); foreach (Lesson lesson in lv.SelectedObjects) { curLesson = objectSpace.FindObject<Lesson>( new BinaryOperator("Oid", lesson.Oid)); RegisterDetail regdetail = new RegisterDetail(objectSpace.Session) { Student = currentStudent, Lesson = curLesson, RegisterState = objectSpace.FindObject<RegisterState>( new BinaryOperator("Code", "SELECTED")), CheckState =objectSpace.FindObject<RegisterState>( new BinaryOperator("Code", "NOTCHECKED")) }; RuleSet ruleSet = new RuleSet(); RuleSetValidationResult result = ruleSet.ValidateTarget(regdetail, DefaultContexts.Save); if (ValidationState.Invalid == result.GetResultItem("RegisterDetail.StudentRegLessonSemester").State) { regdetail.Delete(); } else { regdetail.Save(); } } } objectSpace.Session.CommitTransaction(); PopUpMessage ms = objectSpace.CreateObject<PopUpMessage>(); ms.Title = "Lỗi đăng ký"; ms.Message = string.Format("Error"); ShowViewParameters svp = new ShowViewParameters(); svp.CreatedView = Application.CreateDetailView( objectSpace, ms); svp.TargetWindow = TargetWindow.NewModalWindow; svp.CreatedView.Caption = "Thông báo"; DialogController dc = Application.CreateController<DialogController>(); svp.Controllers.Add(dc); dc.SaveOnAccept = false; Application.ShowViewStrategy.ShowView(svp,new ShowViewSource(null,null)); //// View.ObjectSpace.CommitChanges(); //View.ObjectSpace.Refresh(); //ListView view = null; //Frame currentFrame = ((ActionBase)sender).Controller.Frame; //switch (currentFrame.View.ObjectTypeInfo.Name) //{ // case "Student": // view = Application.CreateListView(objectSpace,typeof(RegisterDetail),true); // break; //} //currentFrame.SetView(view); //e.Cancel = true; } }
protected override void ShowViewCore(ShowViewParameters parameters, ShowViewSource showViewSource) { if (parameters.TargetWindow == TargetWindow.Current && showViewSource.SourceFrame == MainWindow) { parameters.TargetWindow = TargetWindow.Default; } if (modalCount > 0) { parameters.TargetWindow = TargetWindow.NewModalWindow; } base.ShowViewCore(parameters, showViewSource); }
protected override void ShowMapConfigView(ShowViewParameters parameters) { base.ShowMapConfigView(parameters); parameters.Controllers.OfType <DialogController>().First().Disposed += (_, _) => ObjectSpace.Refresh(); }
protected override void ShowNavigationItem(SingleChoiceActionExecuteEventArgs args) { if (args.SelectedChoiceActionItem.Data == null) { base.ShowNavigationItem(args); return; } ViewId = ((DevExpress.ExpressApp.ViewShortcut)(args.SelectedChoiceActionItem.Data)).ViewId; if (string.IsNullOrEmpty(ViewId)) { DevExpress.XtraEditors.XtraMessageBox.Show("Не найдена форма для представления объекта"); return; } IModelDetailView modelDetailView = Application.FindModelView(ViewId) as IModelDetailView; if (modelDetailView == null) { //isPers = true; base.ShowNavigationItem(args); return; } // Знание, является ли объект NonPersisten пока не нужно //isPers = ((IModelDetailView)modelDetailView).AsObjectView.ModelClass.TypeInfo.IsPersistent; /* * // Случай, когда NonPersistent - объект создаём самостоятельно * Frame frame = Frame; * IObjectSpace objectSpace = Application.CreateObjectSpace(); * Type nonPersistentType = ((((((IModelNavigationItem)(args.SelectedChoiceActionItem.Model)).View).AsObjectView).ModelClass).TypeInfo).Type; * object newObj = objectSpace.CreateObject(nonPersistentType); * * // Показываем: * TargetWindow openMode = TargetWindow.Current; * dv = frame.Application.CreateDetailView(objectSpace, ViewId, true, newObj); * //dv = frame.Application.CreateDetailView(objectSpace, newObj); * //frame.SetView(dv); * * //DetailView dv = frame.Application.CreateDetailView(objectSpace, newObj, true); * dv.ViewEditMode = DevExpress.ExpressApp.Editors.ViewEditMode.Edit; * args.ShowViewParameters.Context = TemplateContext.View; * args.ShowViewParameters.CreateAllControllers = true; * args.ShowViewParameters.TargetWindow = openMode; * args.ShowViewParameters.CreatedView = dv; * base.ShowNavigationItem(args); */ // Показываем NonPersistent объект - ошибка!!! Frame frame = Frame; IObjectSpace objectSpace = Application.CreateObjectSpace(); Type nonPersistentType = ((((((IModelNavigationItem)(args.SelectedChoiceActionItem.Model)).View).AsObjectView).ModelClass).TypeInfo).Type; object newObj = objectSpace.CreateObject(nonPersistentType); // Показываем: TargetWindow openMode = TargetWindow.Current; dv = frame.Application.CreateDetailView(objectSpace, ViewId, true, newObj); //dv = frame.Application.CreateDetailView(objectSpace, newObj); //frame.SetView(dv); ShowViewParameters svp = new ShowViewParameters(); svp.CreatedView = dv; svp.TargetWindow = openMode; svp.Context = TemplateContext.View; svp.CreateAllControllers = true; frame.Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(frame, this.ShowNavigationItemAction)); /* * // Показываем обычный Persistent объект - та же ошибка!!! * Frame frame = Frame; * IObjectSpace objectSpace = Application.CreateObjectSpace(); * Type nonPersistentType = typeof(IntecoAG.ERM.CS.Country.csCountry); * object newObj = objectSpace.CreateObject(nonPersistentType); * * // Показываем: * TargetWindow openMode = TargetWindow.Current; * dv = frame.Application.CreateDetailView(objectSpace, "csCountry_DetailView", true, newObj); * //dv = frame.Application.CreateDetailView(objectSpace, newObj); * //frame.SetView(dv); * * ShowViewParameters svp = new ShowViewParameters(); * svp.CreatedView = dv; * svp.TargetWindow = openMode; * svp.Context = TemplateContext.View; * svp.CreateAllControllers = true; * frame.Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(frame, null)); */ }
public GenericMessageBox(ShowViewParameters svp, XafApplication app, string Message, MessageBoxEventHandler Accept, EventHandler Cancel) { CreateDetailView(svp, app, Message); AttachDialogController(svp, app, Accept, Cancel); }
void showDV(object sender, CustomProcessListViewSelectedItemEventArgs e) { Frame frame = Frame; View view = View; DevExpress.ExpressApp.ListView listView = view as DevExpress.ExpressApp.ListView; IEnumerable <MiniNavigationAttribute> mAttr = null; bool AttrExists = false; object currentObject = (object)view.CurrentObject; if (currentObject == null) { return; } Type objType = typeof(object); //string DetailViewID = ""; TargetWindow openMode = TargetWindow.Default; IObjectSpace objectSpace; Type NavigationChoiceType = (System.Type)(view.CurrentObject.GetType()); //.UnderlyingSystemType; //typeof(object); // Вставка механизма проверки модели на предмет умолчательного view для показа по 2-клик или Ввод { string path = ""; //string caption = ""; //TargetWindow openMode = TargetWindow.Default; IModelView modelView = null; bool IsMiniNavigationDefined = false; // Узел в модели IModelView node = null; node = View.Model.Application.Views[listView.Id]; //IModelListView node = View.Model.Application.Views.GetNode<IModelListView>(listView.Id); if (node != null) { // Перебираем все подузлы // node.GetNode(1) {ModelListViewFilters} DevExpress.ExpressApp.Model.IModelNode {ModelListViewFilters} for (int i = 0; i < node.NodeCount; i++) { IModelMiniNavigations miniNavigationNode = node.GetNode(i) as IModelMiniNavigations; if (miniNavigationNode != null) { // Сначала заполняем тот, что прописан по умолчанию IModelMiniNavigationItem miniNavigationDefaultItem = miniNavigationNode.DefaultMiniNavigationNode; if (miniNavigationDefaultItem != null) { path = miniNavigationDefaultItem.NavigationPath; //caption = miniNavigationDefaultItem.NavigationCaption; openMode = miniNavigationDefaultItem.TargetWindow; modelView = miniNavigationDefaultItem.View; IsMiniNavigationDefined = true; } //if (modelView == null) { if (!IsMiniNavigationDefined) { foreach (IModelMiniNavigationItem miniNavigationItem in miniNavigationNode.GetNodes <IModelMiniNavigationItem>()) { if (miniNavigationItem != miniNavigationDefaultItem) { path = miniNavigationItem.NavigationPath; //caption = miniNavigationItem.NavigationCaption; openMode = miniNavigationItem.TargetWindow; modelView = miniNavigationItem.View; IsMiniNavigationDefined = true; break; // Берём первый по расположению } } } break; } } // Если в модели ничего не найдено, то читаем атрибуты. if (!IsMiniNavigationDefined) { DevExpress.ExpressApp.DC.ITypeInfo objectTypeInfo = null; objectTypeInfo = listView.CollectionSource.ObjectTypeInfo; //typeObjectOfListView = objectTypeInfo.Type; mAttr = objectTypeInfo.FindAttributes <MiniNavigationAttribute>(); // Если ничего нет, то покидаем if (mAttr == null & !IsMiniNavigationDefined) { return; } SortedDictionary <int, MiniNavigationAttribute> sd = new SortedDictionary <int, MiniNavigationAttribute>(); IEnumerator <MiniNavigationAttribute> _enum = mAttr.GetEnumerator(); while (_enum.MoveNext()) { MiniNavigationAttribute attr = ((MiniNavigationAttribute)(_enum.Current)); sd.Add(attr.Order, attr); } foreach (KeyValuePair <int, MiniNavigationAttribute> kvp in sd) { AttrExists = true; MiniNavigationAttribute attr = kvp.Value; path = attr.NavigationPath; //caption = attr.NavigationCaptin; openMode = attr.TargetWindow; break; // Берём первый по порядку Order (он же и тот, что по умолчанию) } } if (AttrExists || IsMiniNavigationDefined) { // Получаем объект obj для показа BaseObject obj = GetObjectOnPathEnd(path, currentObject as BaseObject); if (obj == null) { DevExpress.XtraEditors.XtraMessageBox.Show( CommonMethods.GetMessage(MiniNavigatorControllerMessages.SHOWING_OBJECT_NOT_DEFINED), messageCaption, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); return; } Type ChoiceType = (System.Type)(obj.GetType()); //.UnderlyingSystemType; //typeof(object); string ViewID = Application.FindDetailViewId(ChoiceType); // По умолчанию - DetailView Frame resultFrame = frame; // Application.CreateFrame("new"); //TargetWindow openMode = (TargetWindow)e.SelectedChoiceActionItem.Data; // Небольшая разборка с сочетанием значений openMode в целях определения фрейма, в который грузить if (MasterDetailViewFrame != null && (openMode == TargetWindow.Current & ((frame as NestedFrame) != null | !view.IsRoot))) { // Тогда Current трактуем как корневое окно resultFrame = MasterDetailViewFrame; { objectSpace = resultFrame.Application.CreateObjectSpace(); //.View.ObjectSpace; object representativeObj = objectSpace.GetObject(obj); View dv = null; if (modelView != null) { if ((modelView as IModelDetailView) != null) { ViewID = (modelView as IModelDetailView).Id; dv = resultFrame.Application.CreateDetailView(objectSpace, ViewID, true, representativeObj) as DetailView; } else if ((modelView as IModelListView) != null) { ViewID = (modelView as IModelListView).Id; //ListView dv = resultFrame.Application.CreateListView(objectSpace, ChoiceType, true); CollectionSource colSource = new CollectionSource(objectSpace, ChoiceType); if (!colSource.IsLoaded) { colSource.Reload(); } dv = resultFrame.Application.CreateListView((modelView as IModelListView), colSource, true) as ListView; } } else { // Если навигация орпделена в модели, а view не определено, то образуем DetailView по умолчанию ViewID = Application.FindDetailViewId(ChoiceType); dv = resultFrame.Application.CreateDetailView(objectSpace, ViewID, true, representativeObj) as DetailView; } resultFrame.SetView(dv, true, resultFrame); } return; } // Общий алгоритм { objectSpace = resultFrame.Application.CreateObjectSpace(); object representativeObj = objectSpace.GetObject(obj); View dv = null; if (modelView != null) { if ((modelView as IModelDetailView) != null) { ViewID = (modelView as IModelDetailView).Id; dv = resultFrame.Application.CreateDetailView(objectSpace, ViewID, true, representativeObj) as DetailView; } else if ((modelView as IModelListView) != null) { ViewID = (modelView as IModelListView).Id; //ListView dv = resultFrame.Application.CreateListView(objectSpace, ChoiceType, true); //objectSpace = resultFrame.Application.CreateObjectSpace(); CollectionSource colSource = new CollectionSource(objectSpace, ChoiceType); if (!colSource.IsLoaded) { colSource.Reload(); } dv = resultFrame.Application.CreateListView((modelView as IModelListView), colSource, true) as ListView; } } else { // Если навигация определена в модели, а view не определено, то образуем DetailView по умолчанию ViewID = Application.FindDetailViewId(ChoiceType); dv = resultFrame.Application.CreateDetailView(objectSpace, ViewID, true, representativeObj) as DetailView; } ShowViewParameters svp = new ShowViewParameters(); svp.CreatedView = dv; svp.TargetWindow = openMode; svp.Context = TemplateContext.View; svp.CreateAllControllers = true; e.InnerArgs.ShowViewParameters.Assign(svp); return; } } } } // ПРОЧИЕ LISTVIEW // Грузим в отдельном окне e.Handled = false; openMode = TargetWindow.NewWindow; if (Frame as NestedFrame != null | !View.IsRoot) { openMode = TargetWindow.NewModalWindow; } e.InnerArgs.ShowViewParameters.TargetWindow = openMode; }
public GenericMessageBox(ShowViewParameters svp, XafApplication app, string Message) { CreateDetailView(svp, app, Message); AttachDialogController(svp, app); }
private void ModifyCurrentObject() { if (!lookup.ListViewDisabled) { ShowViewParameters svp = new ShowViewParameters(); IObjectSpace modifyObjectViewObjectSpace = m_helper.Application.CreateObjectSpace(); modifyObjectView = m_helper.Application.CreateListView(modifyObjectViewObjectSpace, this.m_helper.LookupObjectTypeInfo.Type, true); svp.CreatedView = modifyObjectView; svp.TargetWindow = TargetWindow.NewModalWindow; svp.Context = TemplateContext.View; svp.NewWindowTarget = NewWindowTarget.Separate; svp.CreatedView.ObjectSpace.ObjectDeleted += (object sender, DevExpress.ExpressApp.ObjectsManipulatingEventArgs args) => { ((DevExpress.ExpressApp.Xpo.XPObjectSpace)sender).Session.AfterCommitTransaction += (object sendObject, SessionManipulationEventArgs EvArgs) => { foreach (object obj in args.Objects) { if (lookup.EditValue != null) { if (obj.ToString() == lookup.EditValue.ToString()) { ClearCurrentObject(); } } } }; }; viewCreatedHandler += (object send, ViewCreatedEventArgs args) => { args.View.ObjectSpace.ObjectDeleted += (object sender, DevExpress.ExpressApp.ObjectsManipulatingEventArgs eArgs) => { ((DevExpress.ExpressApp.Xpo.XPObjectSpace)sender).Session.AfterCommitTransaction += (object sendObject, SessionManipulationEventArgs EvArgs) => { foreach (object obj in eArgs.Objects) { if (lookup.EditValue != null) { if (obj.ToString() == lookup.EditValue.ToString()) { ClearCurrentObject(); } } } }; }; m_helper.Application.ViewCreated -= viewCreatedHandler; CreatedView = args.View; CreatedView.Closed += CreatedView_Closed; }; svp.CreateAllControllers = true; m_helper.Application.ViewCreated += viewCreatedHandler; m_helper.Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null)); } /*ShowViewParameters svp = new ShowViewParameters(); IObjectSpace modifyObjectViewObjectSpace = m_helper.Application.CreateObjectSpace(); object modifyObject = modifyObjectViewObjectSpace.GetObject<typeof()>(lookup.EditValue); modifyObjectView = m_helper.Application.CreateDetailView(modifyObjectViewObjectSpace, modifyObject, true); modifyObjectView.Closed += (modifyObjectView_Closed); modifyObjectView.AllowNew.SetItemValue("CanNotNewFromLookupPropertyEditor", false); modifyObjectView.AllowDelete.SetItemValue("CanNotDeleteFromLookupPropertyEditor", false); svp.CreatedView = modifyObjectView; modifyObjectViewObjectSpace.Committed += (modifyObjectViewObjectSpace_Committed); svp.TargetWindow = TargetWindow.NewModalWindow; svp.Context = TemplateContext.View; m_helper.Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null));*/ }
void Accept(object sender, ShowViewParameters showViewParameters) { new GenericMessageBox(showViewParameters, Application, "Ok button pressed"); }
void AddDialogController(ShowViewParameters showViewParameters) { var dialogController = new DialogController(); dialogController.ViewClosing += (o, eventArgs) => Export(((View)o).CurrentObject); showViewParameters.Controllers.Add(dialogController); }
private void MiniNavigationAction_Execute(object sender, SingleChoiceActionExecuteEventArgs e) { if (e.CurrentObject == null) { return; } if (MiniNavigationAction.SelectedItem == null) { return; } object currentObj = e.CurrentObject; Frame frame = Frame; View view = View; string path = e.SelectedChoiceActionItem.Id; //if (selId == path) return; String selId = path; if ((view as DetailView) != null & selId == "This") { return; } BaseObject obj = GetObjectOnPathEnd(path, (BaseObject)currentObj); if (obj == null) { DevExpress.XtraEditors.XtraMessageBox.Show( CommonMethods.GetMessage(MiniNavigatorControllerMessages.SHOWING_OBJECT_NOT_DEFINED), messageCaption, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); return; } Type ChoiceType = (System.Type)(obj.GetType()); //.UnderlyingSystemType; //typeof(object); string ViewID = Application.FindDetailViewId(ChoiceType); // По умолчанию - DetailView // Считывание из модели view, через которое надо показать объект и оно задано IModelView modelView = null; DevExpress.ExpressApp.ListView listView = view as DevExpress.ExpressApp.ListView; DevExpress.ExpressApp.DetailView detailView = view as DevExpress.ExpressApp.DetailView; //if (IsMiniNavigationDefined) { // // Узел в модели // IModelView node = null; // node = View.Model.Application.Views[((listView != null) ? listView.Id : "") + ((detailView != null) ? detailView.Id : "")]; // if (node != null) { // // Перебираем все подузлы // // node.GetNode(1) {ModelListViewFilters} DevExpress.ExpressApp.Model.IModelNode {ModelListViewFilters} // for (int i = 0; i < node.NodeCount; i++) { //IModelMiniNavigations miniNavigationNode = node.GetNode(i) as IModelMiniNavigations; IModelMiniNavigations miniNavigationNode = FindMiniNavigationModel(View); if (miniNavigationNode != null) { foreach (IModelMiniNavigationItem miniNavigationItem in miniNavigationNode.GetNodes <IModelMiniNavigationItem>()) { if (miniNavigationItem.NavigationPath == selId) { modelView = miniNavigationItem.View; break; } } //break; } // } // } //} Frame resultFrame = frame; // Application.CreateFrame("new"); TargetWindow openMode = (TargetWindow)e.SelectedChoiceActionItem.Data; // Сбрасываем состояние списка MiniNavigationAction.SelectedItem = null; MiniNavigationAction.SelectedIndex = 0; // Небольшая разборка с сочетанием значений openMode и типа текущего View - List или Detail - в целях // определения фрейма, в который грузить if (MasterDetailViewFrame != null && (openMode == TargetWindow.Current & (view as ListView) != null & ((frame as NestedFrame) != null | !view.IsRoot))) { // Тогда Current трактуем как корневое окно resultFrame = MasterDetailViewFrame; { //IObjectSpace objectSpace = resultFrame.View.ObjectSpace; IObjectSpace objectSpace = resultFrame.Application.CreateObjectSpace(); // Всё равно предыдущий ObjectSpace теряется в этом случае object representativeObj = objectSpace.GetObject(obj); View dv = null; if (modelView != null) { if ((modelView as IModelDetailView) != null) { ViewID = (modelView as IModelDetailView).Id; dv = resultFrame.Application.CreateDetailView(objectSpace, ViewID, true, representativeObj) as DetailView; } else if ((modelView as IModelListView) != null) { ViewID = (modelView as IModelListView).Id; //ListView dv = resultFrame.Application.CreateListView(objectSpace, ChoiceType, true); CollectionSource colSource = new CollectionSource(objectSpace, ChoiceType); if (!colSource.IsLoaded) { colSource.Reload(); } dv = resultFrame.Application.CreateListView((modelView as IModelListView), colSource, true) as ListView; } } else { ViewID = Application.FindDetailViewId(ChoiceType); dv = resultFrame.Application.CreateDetailView(objectSpace, ViewID, true, representativeObj) as DetailView; } resultFrame.SetView(dv, true, resultFrame); } return; } // Общий алгоритм { IObjectSpace objectSpace = null; // Анализ того, какой ObjectSpace нужен if ((frame as NestedFrame) != null | !view.IsRoot) { objectSpace = resultFrame.View.ObjectSpace.CreateNestedObjectSpace(); } //objectSpace = resultFrame.View.ObjectSpace.CreateNestedObjectSpace(); if (objectSpace == null) { objectSpace = resultFrame.Application.CreateObjectSpace(); } object representativeObj = objectSpace.GetObject(obj); //ViewID = Application.FindDetailViewId(ChoiceType); //DetailView dv = frame.Application.CreateDetailView(objectSpace, ViewID, true, representativeObj); View dv = null; if (modelView != null) { if ((modelView as IModelDetailView) != null) { ViewID = (modelView as IModelDetailView).Id; dv = resultFrame.Application.CreateDetailView(objectSpace, ViewID, true, representativeObj) as DetailView; } else if ((modelView as IModelListView) != null) { ViewID = (modelView as IModelListView).Id; //ListView dv = resultFrame.Application.CreateListView(objectSpace, ChoiceType, true); //objectSpace = resultFrame.Application.CreateObjectSpace(); CollectionSource colSource = new CollectionSource(objectSpace, ChoiceType); if (!colSource.IsLoaded) { colSource.Reload(); } dv = resultFrame.Application.CreateListView((modelView as IModelListView), colSource, true) as ListView; } } else { ViewID = Application.FindDetailViewId(ChoiceType); dv = resultFrame.Application.CreateDetailView(objectSpace, ViewID, true, representativeObj) as DetailView; } ShowViewParameters svp = new ShowViewParameters(); svp.CreatedView = dv; svp.TargetWindow = openMode; svp.Context = TemplateContext.View; svp.CreateAllControllers = true; e.ShowViewParameters.Assign(svp); } }
protected override void ShowViewFromLookupView(ShowViewParameters parameters, ShowViewSource showViewSource) { ShowViewInModalWindow(parameters, showViewSource); }
private void VersionApprove_Execute(object sender, SimpleActionExecuteEventArgs e) { View view = View; Frame frame = Frame; // Запускаем метод Approve текущего объекта VersionRecord currentObj = View.CurrentObject as VersionRecord; if (currentObj == null) { DevExpress.XtraEditors.XtraMessageBox.Show("Документ не поддерживает операцию утверждения"); return; } IVersionBusinessLogicSupport mainObj = currentObj.MainObject as IVersionBusinessLogicSupport; if (mainObj == null) { DevExpress.XtraEditors.XtraMessageBox.Show("Документ не поддерживает операцию утверждения"); return; } // Паша: добавил сохранение объекта перед Approve, иначе только что созданная версия не находиться в списке версий:( view.ObjectSpace.CommitChanges(); mainObj.Approve(currentObj); view.ObjectSpace.CommitChanges(); // Прежняя концепция (с SimpleContract и т.д.) предполагала, что главный объект показывается пользователю со списком // его версий. Новая концепция предполагает вместо показа главного объекта всегда показывать его Current версию, а если // таковой нет, то версию со статусом NEW. // Замечание. Наличие записи сос статусом NEW означает, что Currentу главного объекта и есть эта запись со статусом NEW //Type objType = (System.Type)((System.Reflection.MemberInfo)((mainObj).GetType())); //string DetailViewID = Application.FindDetailViewId(objType); //IObjectSpace objectSpace = frame.Application.CreateObjectSpace(); //object passedDisplayedObject = objectSpace.GetObject(mainObj); // Основной объект: //object DisplayedObject = currentObj.MainObject; object DisplayedObject = (mainObj as crmContractDeal).Current; // Определяем DetailView string DetailViewId = frame.Application.FindDetailViewId(DisplayedObject.GetType()); IObjectSpace objectSpace = Application.CreateObjectSpace(); object passedDisplayedObject = objectSpace.GetObject(DisplayedObject); // Показываем //CommonMethods.ShowConcreteDetailViewInWindow(frame, objectSpace, DetailViewId, passedDisplayedObject, TargetWindow.Current); TargetWindow openMode = TargetWindow.Current; DetailView dv = frame.Application.CreateDetailView(objectSpace, DetailViewId, true, passedDisplayedObject); ShowViewParameters svp = new ShowViewParameters() { CreatedView = dv, TargetWindow = openMode, Context = TemplateContext.View, CreateAllControllers = true }; e.ShowViewParameters.Assign(svp); }
protected override void ShowViewFromCommonView(ShowViewParameters parameters, ShowViewSource showViewSource) { WinWindow existWindow = FindWindowByView(parameters.CreatedView); if (existWindow != null) { parameters.CreatedView.Dispose(); parameters.CreatedView = existWindow.View; existWindow.Show(); } else { ShowViewInNewWindow(parameters, showViewSource); } }
private void newObjController_ObjectCreating(object sender, ObjectCreatingEventArgs e) { IObjectSpace objectSpace = e.ObjectSpace; // objectdisposedexception fix currentDoctor = objectSpace.GetObject(currentDoctor); currentPacient = objectSpace.GetObject(currentPacient); MedService newMedService = objectSpace.CreateObject <MedService>(); if (currentVisitCase != null || currentMedService != null) { var lookAndFeel = new UserLookAndFeel(this); var result = XtraMessageBox.Show(lookAndFeel, "Создать новое посещение?", "Уточнение", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question); if (result == System.Windows.Forms.DialogResult.No) { result = XtraMessageBox.Show(lookAndFeel, "Услуга производится в ЛПУ?", "Уточнение", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question); // устанавливаем услугу по умолчанию SetService(newMedService, result == System.Windows.Forms.DialogResult.Yes); newMedService.Case = currentVisitCase != null ? currentVisitCase : currentMedService.VisitCase; e.NewObject = newMedService; objectSpace.CommitChanges(); // Обновление представления пациента ObjectSpace.CommitChanges(); ((DetailView)ObjectSpace.Owner).Refresh(); return; } } ShowViewParameters svp = new ShowViewParameters(); IObjectSpace os = Application.CreateObjectSpace(); DetailView dv = Application.CreateDetailView(os, new VisitCaseParameters()); svp.CreatedView = dv; svp.TargetWindow = TargetWindow.NewModalWindow; DialogController dc = new DialogController(); dc.Accepting += (o, e_) => { var visitCaseParameters = e_.AcceptActionArgs.CurrentObject as VisitCaseParameters; VisitCase newVisitCase = objectSpace.CreateObject <VisitCase>(); newVisitCase.Pacient = objectSpace.GetObject(currentPacient); newVisitCase.Cel = visitCaseParameters.CelPosesch; newVisitCase.Mesto = visitCaseParameters.Mesto; newMedService.Case = newVisitCase; // устанавливаем услугу по умолчанию SetService(newMedService, visitCaseParameters.Mesto == MestoObsluzhivaniya.LPU); objectSpace.CommitChanges(); // Обновление представления пациента ObjectSpace.CommitChanges(); ((DetailView)ObjectSpace.Owner).Refresh(); }; dc.CancelAction.Caption = "Отмена"; svp.Controllers.Add(dc); Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null)); e.NewObject = newMedService; }
protected virtual void OpenCurrentObject() { ShowViewParameters svp = new ShowViewParameters(); IObjectSpace openObjectViewObjectSpace = helper.Application.CreateObjectSpace(); object targetObject = openObjectViewObjectSpace.GetObject(lookup.EditValue); if (targetObject != null) { openObjectViewObjectSpace.Committed += openObjectViewObjectSpace_Committed; openObjectViewObjectSpace.Disposed += openObjectViewObjectSpace_Disposed; lookupObjectView = helper.Application.CreateDetailView(openObjectViewObjectSpace, targetObject, true); svp.CreatedView = lookupObjectView; helper.Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null)); } }
protected override void ShowViewCore(ShowViewParameters parameters, ShowViewSource showViewSource) { ((BlazorApplication)Application).MainWindow.SetView(parameters.CreatedView); }
private void AddNewObject() { IObjectSpace newObjectViewObjectSpace = m_helper.Application.CreateObjectSpace(); object newObject = newObjectViewObjectSpace.CreateObject(m_helper.LookupObjectTypeInfo.Type); if (typeof(IInsurance).IsAssignableFrom(newObject.GetType())) { (newObject as IInsurance).IsuranceName = lookup.GetTextBoxValue(); } if (typeof(IDepartment).IsAssignableFrom(newObject.GetType())) { ShowViewParameters svp = new ShowViewParameters(); ((IDepartment)newObject).FacilityData = lookup.GetTextBoxValue(); //((DevExpress.ExpressApp.Xpo.XPObjectSpace)newObjectViewObjectSpace).Session.CommitTransaction(); //newObjectViewObjectSpace.CommitChanges(); newObjectView = m_helper.Application.CreateDetailView(newObjectViewObjectSpace, newObject, true); newObjectView.Closed += newObjectView_Closed; svp.CreatedView = newObjectView; newObjectViewObjectSpace.Committed += newObjectViewObjectSpace_Committed; svp.TargetWindow = TargetWindow.NewModalWindow; svp.Context = TemplateContext.View; m_helper.Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null)); } if (typeof(IIdentifyCardType).IsAssignableFrom(newObject.GetType())) { ((IIdentifyCardType)newObject).DocumentName = lookup.GetTextBoxValue(); } if (newObject.GetType() == typeof(MitsarDataStudio.Module.BusinessObjects.ExaminationType)) { ShowViewParameters svp = new ShowViewParameters(); ((MitsarDataStudio.Module.BusinessObjects.ExaminationType)newObject).Name = lookup.GetTextBoxValue(); newObjectView = m_helper.Application.CreateDetailView(newObjectViewObjectSpace, newObject, true); newObjectView.Closed += newObjectView_Closed; svp.CreatedView = newObjectView; newObjectViewObjectSpace.Committed += newObjectViewObjectSpace_Committed; svp.TargetWindow = TargetWindow.NewModalWindow; svp.Context = TemplateContext.View; m_helper.Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null)); } if (newObject.GetType() == typeof(MitsarDataStudio.Module.BusinessObjects.EnumerationItem)) { ShowViewParameters svp = new ShowViewParameters(); ((MitsarDataStudio.Module.BusinessObjects.EnumerationItem)newObject).Name = lookup.GetTextBoxValue(); newObjectView = m_helper.Application.CreateDetailView(newObjectViewObjectSpace, newObject, true); newObjectView.Closed += newObjectView_Closed; svp.CreatedView = newObjectView; newObjectViewObjectSpace.Committed += newObjectViewObjectSpace_Committed; svp.TargetWindow = TargetWindow.NewModalWindow; svp.Context = TemplateContext.View; m_helper.Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null)); } try { if (!newObjectViewObjectSpace.IsDisposed) newObjectViewObjectSpace.CommitChanges(); lookup.EditValue = m_helper.ObjectSpace.GetObject(newObject); lookup.DoValidate(); } catch (Exception ex) { }; //ShowViewParameters svp = new ShowViewParameters(); //IObjectSpace newObjectViewObjectSpace = m_helper.Application.CreateObjectSpace(); //object newObject = newObjectViewObjectSpace.CreateObject(m_helper.LookupObjectTypeInfo.Type); //newObjectView = m_helper.Application.CreateDetailView(newObjectViewObjectSpace, newObject, true); //newObjectView.Closed += newObjectView_Closed; //svp.CreatedView = newObjectView; //newObjectViewObjectSpace.Committed += newObjectViewObjectSpace_Committed; //svp.TargetWindow = TargetWindow.NewModalWindow; //svp.Context = TemplateContext.View; //m_helper.Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null)); }
protected override void ShowViewFromNestedView(ShowViewParameters parameters, ShowViewSource showViewSource) { throw new NotImplementedException(); }
/// <summary> /// Fires afer the Finish button has been clicked /// </summary> /// <param name="sender">Wizard Control</param> /// <param name="e">Cancel EventArgs</param> private void WizardControl_FinishClick(object sender, CancelEventArgs e) { if (!View.ObjectTypeInfo.IsPersistent && !Validate(_WizardForm.WizardControl.SelectedPage as XafWizardPage)) { e.Cancel = true; return; } UpdateControllers(View); var currentObject = View.CurrentObject; var controller = Frame.GetController<DetailViewController>(); if (controller.SaveAndCloseAction.Active && controller.SaveAndCloseAction.Enabled) { Frame.GetController<DetailViewController>().SaveAndCloseAction.DoExecute(); } else { Frame.GetController<CloseWindowController>().CloseAction.DoExecute(); } if (_WizardForm.ShowRecordAfterCompletion) { var os = Application.CreateObjectSpace(); var showViewParameter = new ShowViewParameters { Context = TemplateContext.View, CreatedView = Application.CreateDetailView(os, os.GetObject(currentObject)), TargetWindow = TargetWindow.NewWindow }; Application.ShowViewStrategy.ShowView(showViewParameter, new ShowViewSource(null, null)); } }
protected override void ShowViewInCurrentWindow(ShowViewParameters parameters, ShowViewSource showViewSource) { throw new NotImplementedException(); }
private void OnDetailViewButtonClick(object sender, ButtonPressedEventArgs e) { if (e.Button == DetailViewButton) { IObjectSpace objectSpace = base.Helper.Application.CreateObjectSpace(); if (this.ControlValue != null) { object @object = objectSpace.GetObject(this.ControlValue); View view = null; if (base.Model != null) { view = base.Helper.Application.CreateDetailView(objectSpace, @object); } ShowViewParameters showViewParameters = new ShowViewParameters(view); showViewParameters.TargetWindow = TargetWindow.Default; base.Helper.Application.ShowViewStrategy.ShowView(showViewParameters, new ShowViewSource(null, null)); } } }
protected override void ShowViewInModalWindow(ShowViewParameters parameters, ShowViewSource sourceFrame) { throw new NotImplementedException(); }