private void OnSelectedAttachmentChanged() { Attachments.ForEach((x) => { x.IsSelected = false; }); if (SelectedAttachment != null) { SelectedAttachment.IsSelected = true; if (!IsImageAttachement(SelectedAttachment)) { CursorHelper.ExecuteWithWaitCursor(() => { try { Process.Start(SelectedAttachment.ImageSource); } catch { _windowManager.ShowError("Open Attachment", "Windows cannot open this document."); } }); } } }
/// <summary> /// Initializes a new instance of the <see cref = "DockableContentConductor" /> class. /// </summary> /// <param name = "viewModel">The view model.</param> /// <param name = "view">The view.</param> public DockableContentConductor(object viewModel, BaseDockableContent view) { m_ViewModel = viewModel; m_View = view; view.IsActiveContentChanged += (sender, args) => { var baseDockableContent = sender as BaseDockableContent; if (baseDockableContent != null && baseDockableContent.IsActiveContent) { var activatable = baseDockableContent.ViewModel as IActivate; if (activatable != null && !activatable.IsActive) { CursorHelper.ExecuteWithWaitCursor(activatable.Activate); } } }; var deactivatable = viewModel as IDeactivate; if (deactivatable != null) { view.Closed += OnClosed; deactivatable.Deactivated += OnDeactivated; } var guard = viewModel as IGuardClose; if (guard != null) { view.Closing += OnClosing; } }
public void Save() { // validation CursorHelper.ExecuteWithWaitCursor(() => { SaveFacility(false, delegate(InvFacility facility) { LoadFacility(facility); _windowManager.Inform("Save Facility", "Facility saved successfully"); EventAggregator.PublishOnUIThread(new FacilityUpdatedMessage() { FacilityUpdateType = FacilityUpdateType.Updated, Facility = facility, }); }, delegate { _windowManager.ShowError("Save Facility", "Facility save failed"); }); }); }
public void Save() { // validation CursorHelper.ExecuteWithWaitCursor(() => { this.Facility.SaveFacility(true, delegate(InvFacility facility) { this.Facility.Model = facility; _windowManager.Inform("Create Facility", "Facility saved successfully"); this.DialogResult = true; EventAggregator.PublishOnUIThread(new FacilityUpdatedMessage() { FacilityUpdateType = FacilityUpdateType.Create, Facility = facility, }); }, delegate { _windowManager.ShowError("Create Facility", "Facility save failed"); }); }); }
private void InitItems() { Items.Add(new ActionItem("Sync All", () => { var success = true; var syncService = IoC.Get <ISyncService>(); var scopeName = ConfigurationManager.AppSettings["Scope"]; var localConnectionString = ConfigurationManager.ConnectionStrings["LocalConnectionString"].ConnectionString; var remoteConnectionString = ConfigurationManager.ConnectionStrings["RemoteConnectionString"].ConnectionString; CursorHelper.ExecuteWithWaitCursor(() => { success = syncService.Synchronize(scopeName, localConnectionString, remoteConnectionString); if (success) { _windowManager.Inform("Sync", "synced successfully"); } else { _windowManager.ShowError("Sync", "sync failed"); } }); })); Items.Add(new ActionItem("Sync Up", null)); Items.Add(new ActionItem("Sync Down", null)); }
public void Cancel() { if (_windowManager.Confirm("Facility Details", "Cancel all unsaved changes for this facility?")) { CursorHelper.ExecuteWithWaitCursor(() => { this.ReLoadFacility(); }); } }
public void Save() { // validation CursorHelper.ExecuteWithWaitCursor(() => { this.FacilityAttachment.SaveAttachment(true, delegate(InvFacilityAttachment facilityAttachment) { this.FacilityAttachment.Model = facilityAttachment; _windowManager.Inform("Create Attachment", "Attachment saved successfully"); this.DialogResult = true; }, delegate { _windowManager.ShowError("Create Attachment", "Attachment save failed"); }); }); }
public void DeleteAttachment() { if (SelectedAttachment == null || !_windowManager.Confirm("Delete Attachment", "Delete this attachment?")) { return; } CursorHelper.ExecuteWithWaitCursor(() => { this.SelectedAttachment.DeleteAttachment( delegate(InvFacilityAttachment facilityAttachment) { _windowManager.Inform("Delete Attachment", "Attachment deleted successfully"); UnloadAttachment(SelectedAttachment); Attachments.Remove(SelectedAttachment); SelectedAttachment = null; }, delegate { _windowManager.ShowError("Delete Attachment", "Attachment delete failed"); }); }); }
private void LoadElectricalSystems() { CursorHelper.ExecuteWithWaitCursor(LoadElectricalSystemsInternal); }
private void LoadFacilities() { CursorHelper.ExecuteWithWaitCursor(LoadFacilitiesInternal); }
public void OpenFacility(object context, EventArgs eventArgs) { var treeNode = context as TreeNode <object>; if (treeNode == null) { return; } if (treeNode.TreeNodeType == TreeNodeType.System) { CursorHelper.ExecuteWithWaitCursor(() => { //reload var facility = treeNode.Value as InvFacility; facility = _facilitiesService.GetFacility(facility.SYNC_ID); if (facility == null) { _windowManager.ShowError("Open Facility", "cannot load facility"); return; } var facilityInfoVm = new FacilityInfoViewModel(facility, _applicationContext, this.EventAggregator); var facilityDetailVM = new FacilityDetailViewModel(facility, facilityInfoVm, _windowManager, EventAggregator, _applicationContext, _facilitiesService); var manager = IoC.Get <IDockWindowManager>(); manager.ShowDocumentWindow(facilityDetailVM, null); }); } else if (treeNode.TreeNodeType == TreeNodeType.Component) { CursorHelper.ExecuteWithWaitCursor(() => { //reload var equipment = treeNode.Value as InvEquipment; var facility = equipment.InvFacility; facility = _facilitiesService.GetFacility(facility.SYNC_ID); if (facility == null) { _windowManager.ShowError("Open Facility", "cannot load facility"); return; } var facilityInfoVm = new FacilityInfoViewModel(facility, _applicationContext, this.EventAggregator); var facilityDetailVM = new FacilityDetailViewModel(facility, facilityInfoVm, _windowManager, EventAggregator, _applicationContext, _facilitiesService); var manager = IoC.Get <IDockWindowManager>(); manager.ShowDocumentWindow(facilityDetailVM, null); // select proper component EventAggregator.PublishOnUIThread(new EquipmentSelectedMessage() { Equipment = equipment }); }); } if (eventArgs is RoutedEventArgs) { ((RoutedEventArgs)eventArgs).Handled = true; } }