public override void ResponseReceived(byte[] parameter)
        {
            switch ((UninstallProgramsCommunication)parameter[0])
            {
            case UninstallProgramsCommunication.ResponseInstalledPrograms:
                var serializer = new Serializer(typeof(List <AdvancedUninstallableProgram>));
                var list       = serializer.Deserialize <List <AdvancedUninstallableProgram> >(parameter, 1);
                RefreshList?.Invoke(this, list);
                LogService.Receive(string.Format((string)Application.Current.Resources["ReceivedPrograms"],
                                                 list.Count,
                                                 FormatBytesConverter.BytesToString(parameter.Length - 1)));
                break;

            case UninstallProgramsCommunication.ResponseProgramUninstallerStarted:
                LogService.Receive((string)Application.Current.Resources["UninstallProgramStarted"]);
                break;

            case UninstallProgramsCommunication.ResponseUninstallFailed:
                LogService.Error(string.Format((string)Application.Current.Resources["UninstallFailed"],
                                               Encoding.UTF8.GetString(parameter, 1, parameter.Length - 1)));
                break;

            case UninstallProgramsCommunication.ResponseEntryNotFound:
                LogService.Receive((string)Application.Current.Resources["UninstalIdNotFound"]);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#2
0
        public void Search(string exportLocalName, DateTime exportDateFrom, DateTime exportDateTo)
        {
            LoadStarted?.Invoke();
            ExportsSearchCryteria searchCryteria = BuildCryteria(exportLocalName, exportDateFrom, exportDateTo);
            List <Export>         result         = Map(searchService.GetExports(searchCryteria));

            LoadCompleted?.Invoke();
            RefreshList?.Invoke(result);
        }
示例#3
0
文件: FormList.cs 项目: Pumpet/Robin
        /// <summary>Загрузка данных в грид</summary>
        public void LoadGrid(DataList grid = null, object key = null)
        {
            var g = grid ?? ActiveGrid;

            if (g == null || g.FindForm() != this)
            {
                return;
            }

            var handled = false;

            if (RefreshList != null)
            {
                var ea = new RefreshListEventArgs()
                {
                    Handled = false, Grid = g, Key = key
                };
                RefreshList.Invoke(this, ea);
                handled = ea.Handled;
            }

            if (!handled)
            {
                if (!gridFirstTime && ModifierKeys == Keys.Shift)
                {
                    g.ClearFilter();
                }

                if (g == MainGrid)
                {
                    MainGrid.LoadData(key, extParams);
                    if (gridFirstTime)
                    {
                        Ctx?.LoadFormOptions(this, FormOptionsSetType.Grid);
                    }
                }
                else
                {
                    g.LoadData(key);
                }
            }

            g.Select();
            g.Focus();
            NeedRefresh = false;
        }
        public GameObjectListViewModel(IGameManager gameManager,
                                       IRegionManager regionManager,
                                       IEventAggregator eventAggregator,
                                       IContainerExtension containerExtension,
                                       IApplicationCommands applicationCommands
                                       )
        {
            _gameManager        = gameManager;
            _regionManager      = regionManager;
            _eventAggregator    = eventAggregator;
            _containerExtension = containerExtension;

            //TODO : 두 번쨰 로딩에서 오브젝트 클릭하면 터지는 거 해결하기
            ObjectSelectedCommand = new DelegateCommand(OnObjectSelected);
            AddNewObjectCommand   = new DelegateCommand(AddNewObject);

            applicationCommands.AddNewGameObjectCommand.RegisterCommand(AddNewObjectCommand);
            applicationCommands.GetCurrentGameObject = () =>
            {
                return(SelectedObject);
            };

            eventAggregator.GetEvent <SavefileLoadedEvent>().Subscribe(() =>
            {
                SelectedObjectIndex = -1;

                //Refresh region content
                GameObjects.Clear();
                GameObjects.AddRange(_gameManager.GameObjects);
            });

            eventAggregator.GetEvent <GameObjectModifiedEvent>().Subscribe((obj) =>
            {
                RefreshList?.Invoke();
            });
        }
        public override void ResponseReceived(byte[] parameter)
        {
            Serializer serializer;

            switch ((TaskManagerCommunication)parameter[0])
            {
            case TaskManagerCommunication.ResponseFullList:
                if (Processes != null)
                {
                    Processes.ToList().ForEach(x => x.Dispose());
                }
                serializer = new Serializer(typeof(List <AdvancedProcessInfo>));
                Processes  =
                    new List <AdvancedProcessInfo> (
                        serializer.Deserialize <List <AdvancedProcessInfo> > (parameter, 1));
                if (RefreshList != null)
                {
                    RefreshList.Invoke(this, Processes);
                }
                break;

            case TaskManagerCommunication.ResponseChanges:
                serializer = new Serializer(typeof(ProcessListChangelog));
                var changelog = serializer.Deserialize <ProcessListChangelog> (parameter, 1);

                foreach (
                    var process in
                    changelog.ClosedProcesses.Select(
                        closedProcess => Processes.FirstOrDefault(x => x.Id == closedProcess))
                    .Where(process => process != null))
                {
                    process.Dispose();
                    Processes.Remove(process);
                }
                foreach (var processInfo in changelog.NewProcesses)
                {
                    Processes.Add(new AdvancedProcessInfo(processInfo));
                }

                if (RefreshList != null)
                {
                    RefreshList.Invoke(this, Processes);
                }
                break;

            case TaskManagerCommunication.ResponseTaskKillFailed:
                if (TaskKillFailed != null)
                {
                    TaskKillFailed.Invoke(this, EventArgs.Empty);
                }
                break;

            case TaskManagerCommunication.ResponseTaskKilled:
                if (TaskKilled != null)
                {
                    TaskKilled.Invoke(this, EventArgs.Empty);
                }
                break;

            default:
                return;
            }
        }
        private static void Process()
        {
            Console.WriteLine("Processing Started");

            Delivery currentDeliveryStart = deliveryList[0];

            ShowDeliveryData?.Invoke();
            IdUpdated?.Invoke(currentDeliveryStart.Id);

            while (deliveryList.Count != 0)
            {
                timer.Start();

                Delivery currentDelivery = deliveryList[0];
                DeliveryService.EvaluatePriorities(ElapsedTime);

                RemoveDeliveryData?.Invoke();
                IdUpdated?.Invoke(currentDelivery.Id);
                ShowDeliveryData?.Invoke();

                Console.WriteLine($"Delivering ID: {currentDelivery.Id}");

                //double additionalTimeFactor;

                //if (currentDelivery.PackageType == PackageType.Mini)
                //{
                //    additionalTimeFactor = 1;
                //}
                //else if (currentDelivery.PackageType == PackageType.Standaard)
                //{
                //    additionalTimeFactor = 1.2;
                //}
                //else
                //{
                //    additionalTimeFactor = 1.5;
                //}

                int waitTimeMilliseconds = (int)(((currentDelivery.TravelTime)) * 100);

                double timeFactor = (double)3.6 * ((currentDelivery.TravelTime) / (double)10);

                double progressValue = ((double)10 / ((double)waitTimeMilliseconds)) * 2;


                //GUI freezes

                //Task deliveryThread = Task.Run(() => Deliver(elapsedTime, waitTimeMilliseconds));
                //deliveryThread.Wait(waitTimeMilliseconds);

                //Task remainingTimeThread = Task.Run(() => RemainingTime(elapsedTime, waitTimeMilliseconds));
                //remainingTimeThread.Wait(waitTimeMilliseconds);

                //GUI freezes

                while (timer.ElapsedMilliseconds < waitTimeMilliseconds)
                {
                    string currentInfo   = "Pakket is onderweg!";
                    int    elapsedTime   = (int)timer.ElapsedMilliseconds;
                    int    remainingTime = (waitTimeMilliseconds - elapsedTime);
                    ProgressUpdated?.Invoke(currentInfo, progressValue, remainingTime);
                }

                Console.WriteLine($"Finished ID {currentDelivery.Id} in {currentDelivery.TravelTime} min");

                deliveryList.RemoveAt(0);
                RefreshList?.Invoke();

                RemoveDeliveryData?.Invoke();
                IdUpdated?.Invoke(currentDelivery.Id);
                ShowDeliveryData?.Invoke();

                timer.Reset();
                timer.Stop();
            }

            string packageGone = "Er is geen pakket onderweg.";

            ProgressUpdated?.Invoke(packageGone, 0, 0);

            RemoveDeliveryData?.Invoke();

            Console.WriteLine("Processing Stopped");

            Processing = false;
        }
        public override void ResponseReceived(byte[] parameter)
        {
            Serializer serializer;

            switch ((TaskManagerCommunication)parameter[0])
            {
            case TaskManagerCommunication.ResponseFullList:
                Processes?.ToList().ForEach(x => x.Dispose());
                serializer    = new Serializer(typeof(List <AdvancedProcessInfo>));
                _allProcesses =
                    new List <AdvancedProcessInfo>(
                        serializer.Deserialize <List <AdvancedProcessInfo> >(parameter, 1));
                RecreateProcessList();
                LogService.Receive(string.Format((string)Application.Current.Resources["ReceivedProcesses"],
                                                 _allProcesses.Count, FormatBytesConverter.BytesToString(parameter.Length - 1)));
                RefreshList?.Invoke(this, Processes);
                break;

            case TaskManagerCommunication.ResponseChanges:
                serializer = new Serializer(typeof(ProcessListChangelog));
                var changelog = serializer.Deserialize <ProcessListChangelog>(parameter, 1);

                foreach (
                    var process in
                    changelog.ClosedProcesses.Select(
                        closedProcess => _allProcesses.FirstOrDefault(x => x.Id == closedProcess))
                    .Where(process => process != null))
                {
                    process.Dispose();
                    _allProcesses.Remove(process);
                }
                foreach (var processInfo in changelog.NewProcesses)
                {
                    _allProcesses.Add(new AdvancedProcessInfo(processInfo));
                }
                RecreateProcessList();
                LogService.Receive(string.Format((string)Application.Current.Resources["ReceivedChanges"],
                                                 changelog.ClosedProcesses.Count, changelog.NewProcesses.Count));
                RefreshList?.Invoke(this, Processes);
                break;

            case TaskManagerCommunication.ResponseTaskKillFailed:
                LogService.Error(string.Format((string)Application.Current.Resources["TaskKillFailed"],
                                               Encoding.UTF8.GetString(parameter, 1, parameter.Length - 1)));
                break;

            case TaskManagerCommunication.ResponseTaskKilled:
                LogService.Receive((string)Application.Current.Resources["TaskSuccessfulKilled"]);
                break;

            case TaskManagerCommunication.ResponsePrioritySet:
                LogService.Receive((string)Application.Current.Resources["PrioritySet"]);
                break;

            case TaskManagerCommunication.ResponseSetPriorityFailed:
                LogService.Error(string.Format((string)Application.Current.Resources["SetPriorityFailed"],
                                               Encoding.UTF8.GetString(parameter, 1, parameter.Length - 1)));
                break;

            case TaskManagerCommunication.ResponseProcessTreeKilled:
                LogService.Receive((string)Application.Current.Resources["ProcessTreeKilled"]);
                break;

            case TaskManagerCommunication.ResponseProcessSuspended:
                LogService.Receive((string)Application.Current.Resources["ProcessSuspended"]);
                break;

            case TaskManagerCommunication.ResponseProcessResumed:
                LogService.Receive((string)Application.Current.Resources["ProcessResumed"]);
                break;

            case TaskManagerCommunication.ResponseWindowActionDone:
                LogService.Receive((string)Application.Current.Resources["ChangeWindowStateSucceeded"]);
                break;

            case TaskManagerCommunication.ResponseWindowActionFailed:
                LogService.Error((string)Application.Current.Resources["ChangeWindowStateFailed"]);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }