예제 #1
0
        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.");
                        }
                    });
                }
            }
        }
예제 #2
0
        /// <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;
            }
        }
예제 #3
0
        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");
                });
            });
        }
예제 #4
0
        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");
                });
            });
        }
예제 #5
0
        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));
        }
예제 #6
0
 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");
                });
            });
        }
예제 #8
0
        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");
                });
            });
        }
예제 #9
0
 private void LoadElectricalSystems()
 {
     CursorHelper.ExecuteWithWaitCursor(LoadElectricalSystemsInternal);
 }
예제 #10
0
 private void LoadFacilities()
 {
     CursorHelper.ExecuteWithWaitCursor(LoadFacilitiesInternal);
 }
예제 #11
0
        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;
            }
        }