Exemple #1
0
 public ReactorViewModel(
     long id,
     long reactorId,
     string caption,
     string reactType,
     short reactNumber,
     IAppRepository repo,
     AuthenticationService authService,
     StatusMessageService messageService,
     IBookedOrderLookup orders,
     ITaskViewModelFactory factory
     )
 {
     ReactorScheduleID        = id;
     ReactorID                = reactorId;
     Caption                  = caption;
     ReactType                = reactType;
     ReactorNumber            = reactNumber;
     _repo                    = repo;
     _authService             = authService;
     _messageService          = messageService;
     _factory                 = factory;
     _orders                  = orders;
     _tasks                   = new TaskCollection();
     _insertCustomTaskCommand = new RelayCommand <String>((type) => InsertCustomTask(type), (type) => AuthenticationService.IsPlanner);
     _deleteTaskCommand       = new RelayCommand(RemoveSelectedTask, () => AuthenticationService.IsPlanner);
     _doubleClickCommand      = new RelayCommand <TaskViewModel>(OnDoubleClick);
     _workcells               = StaticRepository.Workcells.ToList();
 }
Exemple #2
0
 public MainViewModel(
     AuthenticationService authService,
     StatusMessageService messageService,
     ScheduleViewModel schedule)
 {
     _authService    = authService;
     _messageService = messageService;
     Schedule        = schedule;
 }
Exemple #3
0
 public MainViewModel(
     AuthenticationService authService,
     StatusMessageService messageService,
     ScheduleViewModel schedule)
 {
     _authService    = authService;
     _messageService = messageService;
     Schedule        = schedule;
     _appbuildnumber = "v" + Assembly.GetExecutingAssembly().GetName().Version.ToString();
 }
 public ScheduleViewModel(
     IAppRepository repo,
     AuthenticationService authService,
     StatusMessageService messageService,
     IReactorViewModelFactory reactorFactory,
     BookedOrdersViewModel orders)
 {
     _repo           = repo;
     _factory        = reactorFactory;
     _authService    = authService;
     _messageService = messageService;
     _bookedOrders   = orders;
 }
 public BookedOrdersViewModel(
     IAppRepository repo,
     IBookedOrderViewModelFactory factory,
     StatusMessageService messageService
     )
 {
     _repo                    = repo;
     _factory                 = factory;
     _messageService          = messageService;
     _tasksProperty           = typeof(BookedOrderViewModel).GetProperty("Tasks");
     Orders                   = new CollectionViewSource();
     _filters                 = new List <FilterInfo>();
     _filterByValueCommand    = new RelayCommand(FilterByValue);
     _filterByNonBlankCommand = new RelayCommand(FilterByNonBlank);
     _clearAllFiltersCommand  = new RelayCommand(ClearAllFilters);
     _filterByTextCommand     = new RelayCommand <String>(FilterByText);
     _copyValueCommand        = new RelayCommand <object>(CopyCellValue);
 }
        private void Document_Changed(object sender, DocumentChangeEventArgs e)
        {
            Packages.Clear();

            if (string.IsNullOrEmpty(Document.Text))
            {
                return;
            }

            try
            {
                var spec = SpecUtils.Deserialize(Document.Text);

                // initially specs do not have Ids - generate them once and keep them
                bool idsGenerated = false;
                foreach (var cluster in spec.Packages.SelectMany(p => p.Clusters))
                {
                    if (cluster.Id == null)
                    {
                        cluster.Id   = Guid.NewGuid().ToString();
                        idsGenerated = true;
                    }
                }

                if (idsGenerated)
                {
                    // we cannot change the doc while handling a doc change
                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        Document.Text = SpecUtils.Serialize(spec);
                        Save();
                    }));
                }

                Packages.AddRange(spec.Packages.Select(p => p.Name));
            }
            catch (Exception ex)
            {
                StatusMessageService.Publish(new StatusMessage("ERROR:" + ex));
            }

            CreateGraphCommand.RaiseCanExecuteChanged();
        }
Exemple #7
0
        private void OpenDocument(string path)
        {
            var presentation = PresentationCreationService.CreatePresentation(Path.GetDirectoryName(path));

            var processor = new BasicDocumentProcessor(presentation);

            processor.Process(path);

            if (processor.FailedItems.Any())
            {
                var sb = new StringBuilder();
                sb.AppendLine("Following items could not be loaded successfully:");
                sb.AppendLine();
                foreach (var item in processor.FailedItems)
                {
                    sb.AppendLine(string.Format("{0}: {1}", item.FailureReason, item.Item));
                }
                StatusMessageService.Publish(new StatusMessage(sb.ToString()));
            }

            Model.Presentation = presentation;

            myFileWatcher        = new FileSystemWatcher();
            myFileWatcher.Path   = Path.GetDirectoryName(path);
            myFileWatcher.Filter = Path.GetFileName(path);
            // http://stackoverflow.com/questions/19905151/system-io-filesystemwatcher-does-not-watch-file-changed-by-visual-studio-2013
            myFileWatcher.NotifyFilter        = NotifyFilters.LastWrite | NotifyFilters.CreationTime;
            myFileWatcher.Changed            += OnCurrentFileChanged;
            myFileWatcher.Error              += OnFileWatcherError;
            myFileWatcher.EnableRaisingEvents = true;

            // only synchronize presentations where we know the doc type and which were created from this module
            if (Path.GetExtension(path).Equals(".dot", StringComparison.OrdinalIgnoreCase))
            {
                myGraphToDotSynchronizer.Attach(presentation, p =>
                                                // enqueue to have less blocking of UI
                                                Application.Current.Dispatcher.BeginInvoke(new Action(() => SyncToDocument(p, path))));
            }
        }
Exemple #8
0
        private void OnInheritanceGraphCompleted(TypeRelationshipDocument document)
        {
            try
            {
                if (document == null)
                {
                    return;
                }

                if (!document.Graph.Nodes.Any())
                {
                    MessageBox.Show("No nodes found");
                    return;
                }

                var presentation = PresentationCreationService.CreatePresentation(Path.GetDirectoryName(AssemblyToAnalyseLocation));

                var captionModule   = presentation.GetPropertySetFor <Caption>();
                var tooltipModule   = presentation.GetPropertySetFor <ToolTipContent>();
                var edgeStyleModule = presentation.GetPropertySetFor <EdgeStyle>();

                presentation.Graph = document.Graph;

                foreach (var desc in document.Descriptors)
                {
                    captionModule.Add(new Caption(desc.Id, desc.Name));
                    tooltipModule.Add(new ToolTipContent(desc.Id, desc.FullName));
                }

                foreach (var entry in document.EdgeTypes)
                {
                    edgeStyleModule.Add(new EdgeStyle(entry.Key)
                    {
                        Color = entry.Value == ReferenceType.DerivesFrom ? Brushes.Black : Brushes.Blue
                    });
                }

                if (myAddToGraph && Model.Presentation != null && Model.Presentation.Graph != null)
                {
                    presentation = Model.Presentation.UnionWith(presentation,
                                                                () => PresentationCreationService.CreatePresentation(Path.GetDirectoryName(AssemblyToAnalyseLocation)));

                    myAddToGraph = false;
                }

                if (document.FailedItems.Any())
                {
                    foreach (var item in document.FailedItems)
                    {
                        var sb = new StringBuilder();
                        sb.AppendLine("Loading failed");
                        sb.AppendFormat("Item: {0}", item.Item);
                        sb.AppendLine();
                        sb.AppendFormat("Reason: {0}", item.FailureReason);
                        StatusMessageService.Publish(new StatusMessage(sb.ToString()));
                    }
                }

                Model.Presentation = presentation;
            }
            finally
            {
                myCancelBackgroundProcessing = null;
                ProgressValue = 0;
                IsReady       = true;
            }
        }