Example #1
0
        public RepositoryViewModel()
        {
            // Initialize empty collections.
            Commits = new EnhancedObservableCollection<Commit> { };
            StatusItemsStaged = new EnhancedObservableCollection<StatusItem> { };
            StatusItemsUnstaged = new EnhancedObservableCollection<StatusItem> { };
            Branches = new EnhancedObservableCollection<Branch> { };
            Tags = new EnhancedObservableCollection<Tag> { };
            Remotes = new EnhancedObservableCollection<Remote> { };
            Submodules = new EnhancedObservableCollection<Submodule> { };
            Stashes = new EnhancedObservableCollection<Stash> { };
            RecentCommitMessages = new EnhancedObservableCollection<RecentCommitMessage>();

            CommitsPerPage = 150;
            RecentCommitMessageCount = 10;

            // Initialize commands.
            AddNoteCommand = new DelegateCommand(AddNote);
            CheckoutCommand = new DelegateCommand(Checkout);
            CreateBranchCommand = new DelegateCommand(CreateBranch);
            CreateTagCommand = new DelegateCommand(CreateTag);
            CommitCommand = new DelegateCommand(CommitChanges, CommitChanges_CanExecute);
            CopyHashCommand = new DelegateCommand(CopyHash);
            CopyPatchCommand = new DelegateCommand(CopyPatch);
            DeleteFileCommand = new DelegateCommand(DeleteFile);
            DeleteTagCommand = new DelegateCommand(DeleteTag);
            ExportPatchCommand = new DelegateCommand(ExportPatch);
            OpenAboutCommand = new DelegateCommand(OpenAbout);
            ResetSoftCommand = new DelegateCommand(ResetSoft);
            ResetMixedCommand = new DelegateCommand(ResetMixed);
            StageUnstageCommand = new DelegateCommand(StageUnstage);

            // Diff panel.
            StatusItemDiff = "";
        }
Example #2
0
        public RUSModuleSetDirectionVM(IRUSDevice device, BusyObject busy)
        {
            _device = device ?? throw new ArgumentNullException(nameof(device));
            IsBusy  = busy ?? throw new ArgumentNullException(nameof(busy));

            var descriptors = Requests.GetRequestDescription(_device.Id, Command.KEEP_MTF); // All other commands have the same body

            Entities = new EnhancedObservableCollection <CommandEntityVM>(
                descriptors.UserCommandDescriptors.Select(d => new CommandEntityVM(d)));

            SendCommand = new ActionCommand <Command>(sendAsync, IsBusy);

            async Task sendAsync(CommandParameter <Command> command)
            {
                using (IsBusy.BusyMode)
                {
                    assertViewValues();

                    if (command.IsSet)
                    {
                        await _device.BurnAsync(command.Value, Entities.Select(e => e.Entity), null, null);

                        Logger.LogOKEverywhere($"Команда отправлена");
                    }
                    else
                    {
                        Debugger.Break(); // Binding error
                    }
                }
            }
        }
        public ConfigReaderWriter(Stream file, Encoding encoding, string rootSection)
        {
            _file       = file;
            _encoding   = encoding;
            RootSection = new Section(rootSection);

            KVPs = new EnhancedObservableCollection <ConfigKVP>(
                KVPExtractor.ExtractAll(new StreamReader(_file, _encoding)));
            KVPs.CollectionChanged += Config_CollectionChanged;
            if (!file.CanWrite)
            {
                KVPs.MakeReadOnly();
            }
        }
Example #4
0
        public RepositoryViewModel()
        {
            // Initialize empty collections.
            Commits              = new EnhancedObservableCollection <Commit> {
            };
            StatusItems          = new EnhancedObservableCollection <StatusItem> {
            };
            Branches             = new EnhancedObservableCollection <Branch> {
            };
            Tags                 = new EnhancedObservableCollection <Tag> {
            };
            Remotes              = new EnhancedObservableCollection <Remote> {
            };
            Submodules           = new EnhancedObservableCollection <Submodule> {
            };
            Stashes              = new EnhancedObservableCollection <Stash> {
            };
            RecentCommitMessages = new EnhancedObservableCollection <RecentCommitMessage>();

            CommitsPerPage           = 150;
            RecentCommitMessageCount = 10;

            // Initialize status item view and group.
            StatusItemsGrouped = new ListCollectionView(StatusItems);
            StatusItemsGrouped.GroupDescriptions.Add(new PropertyGroupDescription("GenericStatus"));
            StatusItemsGrouped.SortDescriptions.Add(new SortDescription("GenericStatus", ListSortDirection.Descending));

            // Initialize commands.
            ExportPatchCommand  = new DelegateCommand(ExportPatch);
            CopyPatchCommand    = new DelegateCommand(CopyPatch);
            AddNoteCommand      = new DelegateCommand(AddNote);
            CopyHashCommand     = new DelegateCommand(CopyHash);
            TagCommand          = new DelegateCommand(CreateTag);
            CreateBranchCommand = new DelegateCommand(CreateBranch);
            ResetSoftCommand    = new DelegateCommand(ResetSoft);
            ResetMixedCommand   = new DelegateCommand(ResetMixed);
            OpenAboutCommand    = new DelegateCommand(OpenAbout);
            StageUnstageCommand = new DelegateCommand(StageUnstage);
            DeleteFileCommand   = new DelegateCommand(DeleteFile);
            CommitCommand       = new DelegateCommand(CommitChanges, CommitChanges_CanExecute);

            // Diff panel.
            StatusItemDiff = "";
        }
        public RepositoryViewModel()
        {
            // Initialize empty collections.
            Commits             = new EnhancedObservableCollection <Commit> {
            };
            StatusItemsStaged   = new EnhancedObservableCollection <StatusItem> {
            };
            StatusItemsUnstaged = new EnhancedObservableCollection <StatusItem> {
            };
            Branches            = new EnhancedObservableCollection <Branch> {
            };
            Tags                 = new EnhancedObservableCollection <Tag> {
            };
            Remotes              = new EnhancedObservableCollection <Remote> {
            };
            Submodules           = new EnhancedObservableCollection <Submodule> {
            };
            Stashes              = new EnhancedObservableCollection <Stash> {
            };
            RecentCommitMessages = new EnhancedObservableCollection <RecentCommitMessage>();

            CommitsPerPage           = 150;
            RecentCommitMessageCount = 10;

            // Initialize commands.
            AddNoteCommand      = new DelegateCommand(AddNote);
            CheckoutCommand     = new DelegateCommand(Checkout);
            CreateBranchCommand = new DelegateCommand(CreateBranch);
            CreateTagCommand    = new DelegateCommand(CreateTag);
            CommitCommand       = new DelegateCommand(CommitChanges, CommitChanges_CanExecute);
            CopyHashCommand     = new DelegateCommand(CopyHash);
            CopyPatchCommand    = new DelegateCommand(CopyPatch);
            DeleteFileCommand   = new DelegateCommand(DeleteFile);
            DeleteTagCommand    = new DelegateCommand(DeleteTag);
            ExportPatchCommand  = new DelegateCommand(ExportPatch);
            OpenAboutCommand    = new DelegateCommand(OpenAbout);
            ResetSoftCommand    = new DelegateCommand(ResetSoft);
            ResetMixedCommand   = new DelegateCommand(ResetMixed);
            StageUnstageCommand = new DelegateCommand(StageUnstage);

            // Diff panel.
            StatusItemDiff = "";
        }
        public RepositoryViewModel()
        {
            // Initialize empty collections.
            Commits = new EnhancedObservableCollection<Commit> { };
            StatusItems = new EnhancedObservableCollection<StatusItem> { };
            Branches = new EnhancedObservableCollection<Branch> { };
            Tags = new EnhancedObservableCollection<Tag> { };
            Remotes = new EnhancedObservableCollection<Remote> { };
            Submodules = new EnhancedObservableCollection<Submodule> { };
            Stashes = new EnhancedObservableCollection<Stash> { };
            RecentCommitMessages = new EnhancedObservableCollection<RecentCommitMessage>();

            CommitsPerPage = 150;
            RecentCommitMessageCount = 10;

            // Initialize status item view and group.
            StatusItemsGrouped = new ListCollectionView(StatusItems);
            StatusItemsGrouped.GroupDescriptions.Add(new PropertyGroupDescription("GenericStatus"));
            StatusItemsGrouped.SortDescriptions.Add(new SortDescription("GenericStatus", ListSortDirection.Descending));

            // Initialize commands.
            ExportPatchCommand = new DelegateCommand(ExportPatch);
            CopyPatchCommand = new DelegateCommand(CopyPatch);
            AddNoteCommand = new DelegateCommand(AddNote);
            CopyHashCommand = new DelegateCommand(CopyHash);
            TagCommand = new DelegateCommand(CreateTag);
            CreateBranchCommand = new DelegateCommand(CreateBranch);
            ResetSoftCommand = new DelegateCommand(ResetSoft);
            ResetMixedCommand = new DelegateCommand(ResetMixed);
            OpenAboutCommand = new DelegateCommand(OpenAbout);
            StageUnstageCommand = new DelegateCommand(StageUnstage);
            DeleteFileCommand = new DelegateCommand(DeleteFile);
            CommitCommand = new DelegateCommand(CommitChanges, CommitChanges_CanExecute);

            // Diff panel.
            StatusItemDiff = "";
        }
        private void OnStockAnalysisCompleted(IStockAnalysisResults args)
        {
            // set data indicators
            IsLoadingData = false;
            HasData = args.IsSuccess;
            Error = args.Error;

            // if anaylze was completed successfuly
            if (args.IsSuccess)
            {
                var clusters = args.Results
                                   .GroupBy(result => result.Cluster);
                // gether the results
                Results = new EnhancedObservableCollection<IGrouping<int, IStockAnalysisResult>>
                                                            (clusters.OrderBy(group => group.Key));
                // update status
                _statusUpdater.UpdateStatus($"Stock analysis completed with {args.EmptyClusters} empty clusters. " +
                                            $"Analysis took {args.Duration} ...");
            }
            else
            {
                // update status
                _statusUpdater.UpdateStatus($"Stock analysis failed. Analysis took {args.Duration} ...");
            }
        }
Example #8
0
        public Map() : base()
        {
            var resourcePath = LoadMapResources();

            WebView = new ChromiumWebBrowser(resourcePath + "\\Map.html");

            CefSharpSettings.LegacyJavascriptBindingEnabled = true;
            WebView.RegisterJsObject("jsInterface", this);

#if DEBUG
            WebView.ConsoleMessage += (s, e) =>
            {
                Console.WriteLine(e.Message);
            };
#endif

            this.Child = WebView;

            Sources = new EnhancedObservableCollection <ISource>();
            Sources.CollectionChanged += (s, e) =>
            {
                if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
                {
                    foreach (var n in e.NewItems)
                    {
                        var source = (n as ISource);

                        source.Map = this;
                        WebView.ExecuteScriptAsync("map.map.addSource('" + source.Id + "'," + source.ToJson() + ")");

                        if (n is GeoJsonSource)
                        {
                            (n as GeoJsonSource).CollectionChanged += GeoJsonSourceDataChanged;
                        }
                    }
                }
                else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
                {
                    foreach (var o in e.OldItems)
                    {
                        if (o is GeoJsonSource)
                        {
                            (o as GeoJsonSource).CollectionChanged -= GeoJsonSourceDataChanged;
                        }

                        var source = (o as ISource);
                        source.Map = null;
                        WebView.ExecuteScriptAsync("if(map.map.getSource('" + source.Id + "')){map.map.removeSource('" + source.Id + "')}");
                    }
                }
            };

            Layers = new EnhancedObservableCollection <BaseMapLayer>();
            Layers.CollectionChanged += (s, e) =>
            {
                if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
                {
                    if (e.NewItems != null)
                    {
                        foreach (var n in e.NewItems)
                        {
                            (n as BaseMapLayer).Map = this;
                            WebView.ExecuteScriptAsync("map.map.addLayer(" + (n as BaseMapLayer).ToJson() + ")");
                        }
                    }
                }
                else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
                {
                    if (e.OldItems != null)
                    {
                        foreach (var o in e.OldItems)
                        {
                            (o as BaseMapLayer).Map = null;
                            WebView.ExecuteScriptAsync("map.map.removeLayer('" + (o as BaseMapLayer).Id + "')");
                        }
                    }
                }
            };
        }
        private void SyncStocks(IEnumerable<IStock> stocks)
        {
            // create a factory method
            Func<IStock, IStockViewModel> factoryMethod = stock => new StockViewModel(stock);
            // init stock if the first time
            if (Stocks == null)
            {
                Stocks = new EnhancedObservableCollection<IStockViewModel>(stocks.Select(factoryMethod));
                return;
            }

            // reset data
            Stocks.Clear();
            Stocks.AddRange(stocks.Select(factoryMethod));
        }