예제 #1
0
 public void Calculate()
 {
     IsProgress = true;
     Task       = Task.Factory.StartNew(CalcCore).ContinueWith(x => {
         DispatcherService.BeginInvoke(new Action(() => IsProgress = false));
     });
 }
예제 #2
0
        public void UpdateCPS()
        {
            //DispatcherService.BeginInvoke(() =>
            //{
            //    //UpdataCP(CPS.First());
            //    UpdataCP(CP);
            //});

            //CP = new ControlParameter();
            //UpdataCP(CP);
            DI.Param1 = new Random(Guid.NewGuid().GetHashCode()).Next(0, 100).ToString();
            DI.Param2 = new Random(Guid.NewGuid().GetHashCode()).Next(0, 100).ToString();
            DI.Param3 = new Random(Guid.NewGuid().GetHashCode()).Next(0, 100).ToString();
            DispatcherService.BeginInvoke(() =>
            {
                CP.Param1 = 100;
                CP.Param2 = 76;
                CP.Param3 = 60;
                CP.Param4 = 23;

                DI.Param1 = new Random(Guid.NewGuid().GetHashCode()).Next(0, 100).ToString();
                DI.Param2 = new Random(Guid.NewGuid().GetHashCode()).Next(0, 100).ToString();
                DI.Param3 = new Random(Guid.NewGuid().GetHashCode()).Next(0, 100).ToString();
            });
        }
예제 #3
0
 private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     DispatcherService.BeginInvoke(() =>
     {
         this.MachineTime = this.watch.Elapsed;
         this.RaisePropertiesChanged();
     });
 }
예제 #4
0
        public void InvokeAsync_Test02()
        {
            var  service   = new DispatcherService();
            bool isStopped = false;

            service.BeginInvoke(() => { isStopped = true; });
            Assert.IsFalse(isStopped);
            DispatcherHelper.DoEvents();
            Assert.IsTrue(isStopped);
        }
예제 #5
0
        public void InvokeAsync_Test03()
        {
            var  service   = new DispatcherService();
            bool isStopped = false;

            Task.Factory.StartNew(() => service.BeginInvoke(() => { isStopped = true; }));
            Assert.IsFalse(isStopped);
            EnqueueWait(() => isStopped);
            Assert.IsTrue(isStopped);
        }
예제 #6
0
        public void InvokeAsync_Test01()
        {
            var service = new DispatcherService();

            service.Delay = TimeSpan.FromMilliseconds(200);
            var sw = System.Diagnostics.Stopwatch.StartNew();

            Task.Factory.StartNew(() => service.BeginInvoke(() => sw.Stop()));
            EnqueueWait(() => !sw.IsRunning);
            Assert.IsTrue(sw.Elapsed.TotalMilliseconds >= 180, sw.ElapsedMilliseconds.ToString());
        }
예제 #7
0
        /// <summary>
        /// 有工单被顶掉,更新选中的任务
        /// </summary>
        /// <param name="state"></param>
        /// <param name="action"></param>
        void whenSchTaskReplaced(AppState state, IAction action)
        {
            var mqAction = (MqActions.SchTaskReplaced)action;

            //设置默认选中的工单任务
            if (mqAction.MachineCode == MachineCode)
            {
                DispatcherService.BeginInvoke(() => {
                    SchTaskTab.SetDefaultSelected();
                });
            }
        }
예제 #8
0
 public void RefreshClients(Client cClient, Client wClient)
 {
     DispatcherService?.BeginInvoke(() =>
     {
         this.cClient.CopyFrom(cClient);
         this.wClient.CopyFrom(wClient);
         LoggedIn = Me.LoggedIn;
         if (LoggedIn && notifyDevice != null)
         {
             notifyDevice.Stop();
         }
         UpdateCommands();
     });
 }
예제 #9
0
        public override void PageQuery(int pageIndex)
        {
            Task.Run(async() =>
            {
                var result = await Key.GetValueByListAsync(PageSize, PageIndex);

                DispatcherService.BeginInvoke(() =>
                {
                    Values    = new KeyListValueCollection(result.values);
                    PageIndex = result.pageIndex;
                    PageCount = result.pageCount;
                });
            });
        }
예제 #10
0
        public void InvokeAsync_Test05()
        {
            var  service  = new DispatcherService();
            bool val1     = false;
            bool complete = false;

            service.BeginInvoke(() => {
                Assert.IsFalse(val1);
                val1 = true;
            }).ContinueWith(o => {
                val1     = true;
                complete = true;
            });
            EnqueueWait(() => complete);
            Assert.IsTrue(val1);
        }
예제 #11
0
        public void OrderSocketData(ResponseExchangeDashboardOrderDataModel item)
        {
            try
            {
                if (!IsLoad)
                {
                    return;
                }

                if (CoinMarketPrc == null)
                {
                    return;
                }

                if (item.marketCode == PriceCode && item.curcyCd == StringEnum.GetStringValue(SelectCoinCode))
                {
                    //List<ResponseExchangeDashboardOrderListModel> SellOrderTemp = item.list.Where(w => w.sellTranPrc != "" || w.sellCnAmt != "").Select(s => new ResponseExchangeDashboardOrderListModel { sellCnAmt = s.sellCnAmt, sellTranPrc = s.sellTranPrc, floatFormat = s.floatFormat }).Take(16).Reverse().ToList();
                    List <ResponseExchangeDashboardOrderListModel> SellOrderTemp = item.list.Where(w => w.sellTranPrc != "" || w.sellCnAmt != "").Select(s => new ResponseExchangeDashboardOrderListModel {
                        sellCnAmt = s.sellCnAmt, sellTranPrc = s.sellTranPrc, floatFormat = s.floatFormat
                    }).Take(16).ToList();
                    List <ResponseExchangeDashboardOrderListModel> BuyOrderTemp = item.list.Where(w => w.buyTranPrc != "" || w.buyCnAmt != "").Select(s => new ResponseExchangeDashboardOrderListModel {
                        buyCnAmt = s.buyCnAmt, buyTranPrc = s.buyTranPrc, floatFormat = s.floatFormat
                    }).Take(16).ToList();

                    if (BuyOrderTemp != null)
                    {
                        DispatcherService.BeginInvoke(() =>
                        {
                            BuyOrderListUpdateProcess(BuyOrderTemp, BuyOrdelData);
                        });
                    }
                    if (SellOrderTemp != null)
                    {
                        DispatcherService.BeginInvoke(() =>
                        {
                            SellOrderListUpdateProcess(SellOrderTemp, SellOrdelData);
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
        }
예제 #12
0
        public void InvokeAsync_Test06()
        {
            var service = new DispatcherService();

            service.Delay = TimeSpan.FromMilliseconds(100);
            bool val1     = false;
            bool complete = false;

            service.BeginInvoke(() => {
                Assert.IsFalse(val1);
                val1 = true;
            }).ContinueWith(o => {
                val1     = true;
                complete = true;
            });
            EnqueueWait(() => complete);
            Assert.IsTrue(val1);
        }
예제 #13
0
        public void MakeMovement(Tuple <AxisTypes, double> info)
        {
            var para = new ManualParameter
            {
                Speed          = this.Speed,
                Acceleration   = GlobalModel.Params.LayerConfig.EmptyMoveAcceleratedSpeed,
                Step           = this.IsStepMove ? this.Step * info.Item2 : MAX_DISTANCE * info.Item2,
                Axis           = info.Item1,
                IsPointMoveCut = this.IsPointMoveCut
            };

            this.UpdateStep(para);
            if (para.Step == 0)
            {
                return;
            }

            //Update UI before movement
            if (this.IsStepMove)
            {
                this.running = true;
                this.NotityStatusChanged("Running");
            }
            Messenger.Default.Send <bool>(true, "OnManualMovement");       //this => Machining ViewModel
            this.AddSysLog("停止-->点动", Color.Black);
            Messenger.Default.Send <object>("PointMove", "UpdateOperation");
            OperationEngine.Instance.MakeManualMovementAsync(para).ContinueWith(x =>
            {
                Messenger.Default.Send <bool>(false, "OnManualMovement");  //this => Machining ViewModel
                if (this.IsStepMove)
                {
                    this.running = false;
                    this.NotityStatusChanged("Idle");
                }
                if (this.IsPointMoveCut)
                {
                    DispatcherService.BeginInvoke(() => this.IsPointMoveCut = false);
                }
                this.AddSysLog("点动-->停止", Color.Black);
                Messenger.Default.Send <object>("Idle", "UpdateOperation");
            });
        }
예제 #14
0
        public void FillSocketData(ResponseExchangeDashboardFillDataModel item)
        {
            try
            {
                if (!IsLoad)
                {
                    return;
                }

                if (item.marketCode == PriceCode && item.curcyCd == StringEnum.GetStringValue(SelectCoinCode))
                {
                    DispatcherService.BeginInvoke(() =>
                    {
                        if (item != null && item.list.Count > 0)
                        {
                            for (int i = 0; i < item.list.Count - 1; i++)
                            {
                                if (i + 1 <= item.list.Count - 1)
                                {
                                    item.list[i].fillPrc = decimal.Parse(item.list[i].coinPrc) >= decimal.Parse(item.list[i + 1].coinPrc) ? "0" : "1";
                                }
                                else
                                {
                                    item.list[i].fillPrc = "0";
                                }
                            }
                            FillData = item.list.Take(20).ToList();
                        }
                        else
                        {
                            FillData = new List <ResponseExchangeDashboardFillListModel>();
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
        }
예제 #15
0
        public void CoinInfoSocketData(ResponseCoinInfoDataModel item)
        {
            try
            {
                if (!IsLoad)
                {
                    return;
                }

                if (item.marketCode == PriceCode && item.curcyCd == StringEnum.GetStringValue(SelectCoinCode))
                {
                    DispatcherService.BeginInvoke(() =>
                    {
                        CoinMarketPrc = item.ytdPrc;
                    });
                }
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
        }
예제 #16
0
        private void OnDisplayChanged(object arg)
        {
            bool flag = (bool)arg;

            if (flag)
            {
                this.ExecuteCmd("AttachToMenu", null);
                this.timer.Start();
            }
            else
            {
                this.ExecuteCmd("RemoveFromMenu", null);
                this.timer.Stop();

                this.Progress    = 0;
                this.MachineTime = TimeSpan.Zero;
                DispatcherService.BeginInvoke(() =>
                {
                    this.RaisePropertyChanged(x => x.Progress);
                    this.RaisePropertyChanged(x => x.MachineTime);
                });
            }
        }
        public NewConnectionViewModel(IMessageService messageService, IConnectionService connectionService)
        {
            _messageService    = messageService;
            _connectionService = connectionService;

            // Test command
            TestCommand = new DelegateCommand(() =>
            {
                Task.Run(async() =>
                {
                    var success = await Connection.TestConnectAsync();
                    DispatcherService.BeginInvoke(() => _messageService.Show("Redis Viewer", success ? "Successful connection to redis-server" : "Can't connect to redis-server"));
                });
            });

            // Save command
            OkCommand = new DelegateCommand(() =>
            {
                Task.Run(async() =>
                {
                    if (await _connectionService.AddAsync(Connection)) // If added success
                    {
                        DispatcherService.BeginInvoke(() => CloseDialog(ButtonResult.OK, new DialogParameters {
                            { "connection_info", Connection }
                        }));
                    }
                    else
                    {
                        DispatcherService.BeginInvoke(() => _messageService.Show("Redis Viewer", "Add connection profile failed"));
                    }
                });
            });

            // Cancel command
            CancelCommand = new DelegateCommand(() => CloseDialog(ButtonResult.Cancel));
        }
예제 #18
0
        private void OnMachineOnce(object arg)
        {
            DispatcherService.BeginInvoke(() =>
            {
                this.CurrentCount = ++GlobalModel.Params.MachineCount.FinishedCount;
                int total         = GlobalModel.Params.MachineCount.PlanTotalCount;
                if (this.CurrentCount == total)
                {
                    var operType = GlobalModel.Params.MachineCount.MachineFinishedType;
                    switch (operType)
                    {
                    case MachineFinishedTypes.None:
                        break;

                    case MachineFinishedTypes.BanMachine:
                        break;

                    case MachineFinishedTypes.ShowTips:
                        this.MsgBoxService.ShowMessage($"计划加工{total}次,已完成!", "消息", MessageButton.OK, MessageIcon.Information);
                        break;
                    }
                }
            });
        }
        public void Loaded()
        {
            try
            {
                IsLoad   = true;
                listSize = 10;
                RepeatTimer.Start();

                //string sCheckValue = ini.GetCheckID("ViewTermAgree", "Check");
                //if (!sCheckValue.Equals(string.Empty))
                //{
                //    bCheck = true;
                //    bCheckEnable = true;
                //}
                //else
                //{
                //    bCheck = false;
                //    bCheckEnable = false;
                //}

                using (RequestArbitrageGetSignInfoModel req = new RequestArbitrageGetSignInfoModel())
                {
                    req.userEmail = MainViewModel.LoginDataModel.userEmail;

                    using (ResponseArbitrageGetSignInfoModel res = WebApiLib.SyncCallEncrypt <ResponseArbitrageGetSignInfoModel, RequestArbitrageGetSignInfoModel>(req))
                    {
                        if (res.resultStrCode == "000")
                        {
                            if (res.data.failCd.Equals(""))
                            {
                                arbiExchangeList = new ObservableCollection <ResponseArbitrageGetSignInfoListModel>();
                                arbiExchangeList = res.data.list;

                                if (res.data.list.Where(x => x.joinYn == "N").Count() + res.data.list.Where(x => x.joinYn == "F").Count() > 0)
                                {
                                    Task.Run(() =>
                                    {
                                        DispatcherService.BeginInvoke(() =>
                                        {
                                            ArbitrageSignUpPopAdditionalService pop = new ArbitrageSignUpPopAdditionalService();
                                            ((ArbitrageSignUpPopAdditionalServiceViewModel)pop.DataContext).signUpList = res.data.list;
                                            pop.ShowDialog();
                                            if (((ArbitrageSignUpPopAdditionalServiceViewModel)pop.DataContext).bDialogResult == true)
                                            {
                                                GetArbitrageData(_OrderCode);
                                                bTotalSignCheck = true;
                                            }
                                            else
                                            {
                                                bTotalSignCheck = false;
                                            }
                                        });
                                    });
                                }
                                else
                                {
                                    GetArbitrageData(_OrderCode);
                                    bTotalSignCheck = true;
                                }
                            }
                            else if (res.data.failCd.Equals("998"))
                            {
                                Alert alert = new Alert(Localization.Resource.Arbitrage_SignUpPop_Alert_1, 300, 160);
                                alert.ShowDialog();
                                return;
                            }
                        }
                    }
                }

                GetArbitrageTradeList();
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
        }
예제 #20
0
        private async void Compile()
        {
            if (String.IsNullOrEmpty(Settings.Default.TrunkLocation))
            {
                if (_messageService.Show("You must first set your trunk location! Want to do this right now?", "Trunk location not set!", MessageButton.YesNo, MessageImage.Question) == MessageResult.Yes)
                {
                    SetTrunkLocation();
                }

                return;
            }

            if (_isCloning)
            {
                _messageService.ShowError("Cloning in progress. Please wait until this has finished!");

                return;
            }

            if (_isCompiling)
            {
                if (_compilerCts != null)
                {
                    _compilerCts.Cancel();
                }

                _messageService.ShowError("Compiling has been aborted!");

                return;
            }

            if (Busy)
            {
                _messageService.ShowError("TrinityCore Manager is currently busy. Please wait.");

                return;
            }

            bool x64 = CompilePlatform.Equals("x64", StringComparison.OrdinalIgnoreCase);

            if (x64 && !Environment.Is64BitOperatingSystem)
            {
                _messageService.ShowError("Your operating system is not 64 bit!");

                return;
            }

            _compilerCts = new CancellationTokenSource();

            OutputText = String.Empty;

            var progress = new Progress <string>(prog => _dispatcherService.BeginInvoke(() =>
            {
                OutputText += prog + Environment.NewLine;
            }));

            Busy = true;
            BusyIndeterminate = true;

            _isCompiling = true;

            string temp = FileHelper.GenerateTempDirectory();

            bool result = await CMake.Generate(Settings.Default.TrunkLocation, temp, x64, progress, _compilerCts.Token);


            if (result)
            {
                _compilerCts = new CancellationTokenSource();

                result = await TCCompiler.Compile(temp, x64, progress, _compilerCts.Token);

                if (result)
                {
                    FileHelper.CopyDirectory(Path.Combine(temp, "bin", "Release"), Settings.Default.ServerFolder);
                }
                else
                {
                    _messageService.ShowError("Compile has failed!");
                }

                FileHelper.DeleteDirectory(temp);
            }
            else
            {
                _messageService.ShowError("Compile has failed!");
            }

            Busy = false;
            BusyIndeterminate = false;

            _isCompiling = false;
        }
예제 #21
0
 void CalcCore()
 {
     DispatcherService.BeginInvoke(() => {
         IsCompleted = true;
     });
 }
예제 #22
0
        public void CoinSocketData(ResponseExchangeDashboardCoinDataModel item)
        {
            try
            {
                if (!IsLoad)
                {
                    return;
                }

                if (item.marketCode == HeaderCode && int.Parse(SelectTime.Value) == int.Parse(item.Time))
                {
                    DispatcherService.BeginInvoke(() =>
                    {
                        ObservableCollection <ResponseExchangeDashboardCoinListModel> deleteItemList = new ObservableCollection <ResponseExchangeDashboardCoinListModel>();

                        for (int i = 0; i < item.list.Count; i++)
                        {
                            if (item.list[i].chgPrc > 0)
                            {
                                item.list[i].Image = "/Images/ico_up_arr_red.png";
                            }
                            else if (item.list[i].chgPrc == 0)
                            {
                                item.list[i].Image = "/Images/ico_stop_change.png";
                            }
                            else if (item.list[i].chgPrc < 0)
                            {
                                item.list[i].Image = "/Images/ico_down_arr_blue.png";
                            }

                            if (SelectCoinCode == EnumLib.ExchangeCurrencyCode.KRW)
                            {
                                CmdSelectCoin(item.list[0]);
                            }
                            else
                            {
                                if ((tempCoin != StringEnum.GetStringValue(SelectCoinCode)) && (item.list[i].curcyCd == StringEnum.GetStringValue(SelectCoinCode)))
                                {
                                    tempCoin = StringEnum.GetStringValue(SelectCoinCode);
                                    if (SelectItem == null)
                                    {
                                        CmdSelectCoin(item.list[i]);
                                    }
                                    SelectItem = item.list[i];
                                }
                                else if (item.list[i].curcyCd == StringEnum.GetStringValue(SelectCoinCode))
                                {
                                    txt_Quotes = item.list[i].coinPrc;
                                    txt_Rate   = item.list[i].volume;
                                    txt_Volume = item.list[i].svcTranAmt;
                                }
                            }

                            if (item.list[i].curcyCd == StringEnum.GetStringValue(SelectCoinCode))
                            {
                                item.list[i].bold_Gb = FontWeights.Bold;
                            }
                            else
                            {
                                item.list[i].bold_Gb = FontWeights.Normal;
                            }
                            item.list[i].coinImage = "/Images/ico_nav_" + item.list[i].coinNm + ".png";
                            //item.list[i].ieoImage = "/Images/btn_ieo_s.png";
                            item.list[i].coinNmView = item.list[i].coinNm + "/" + HeaderName;

                            //if (item.list[i].coinNm.Equals("ADM"))
                            //{
                            //    item.list[i].ieoVisible = Visibility.Visible;
                            //}

                            if (item.list[i].coinNm == HeaderName)
                            {
                                ResponseExchangeDashboardCoinListModel temp = item.list.Where(x => x.coinNm == HeaderName).First();
                                if (temp != null)
                                {
                                    deleteItemList.Add(item.list[i]);
                                }
                            }

                            if (item.list[i].coinNm.Equals("USDT"))
                            {
                                deleteItemList.Add(item.list[i]);
                            }
                        }

                        foreach (var dItem in deleteItemList)
                        {
                            item.list.Remove(dItem);
                        }

                        CoinPriceData = item.list;
                    });
                }
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
        }
예제 #23
0
        public void CmdSelectCoin(ResponseExchangeDashboardCoinListModel list)
        {
            try
            {
                DispatcherService.BeginInvoke(() =>
                {
                    if (list == null)
                    {
                        return;
                    }

                    if (ParentModel == null)
                    {
                        return;
                    }

                    //if (list.coinNm.Equals("VSTC"))
                    //{
                    //    Alert alert = new Alert(Localization.Resource.Common_Alert_1);
                    //    alert.ShowDialog();
                    //    return;
                    //}

                    if (tempCoinCd != list.curcyCd || HeaderName != tempPriceType)
                    {
                        tempCoinCd    = list.curcyCd;
                        tempPriceType = HeaderName;

                        if (HeaderName == list.coinNm || CoinPriceData.Any(x => x.coinNm == list.coinNm) == false)
                        {
                            SelectItem = CoinPriceData[0];
                        }
                        else
                        {
                            SelectItem = list;
                        }

                        if (HeaderVisible == Visibility.Visible)
                        {
                            img_main_coin = "/Images/img_ex_" + SelectItem.coinNm + ".png";
                            txt_Quotes    = SelectItem.coinPrc;
                            txt_Rate      = SelectItem.volume;
                            txt_Volume    = SelectItem.svcTranAmt;
                        }

                        SelectCoinCode = StringEnum.ToEnum <EnumLib.ExchangeCurrencyCode>(SelectItem.curcyCd);

                        if (ParentModel.Equals("ExchangeDashboardViewModel"))
                        {
                            ((ExchangeDashboardViewModel)ParentViewModel).ChangeCoin(HeaderName, HeaderCode, StringEnum.ToEnum <EnumLib.ExchangeCurrencyCode>(SelectItem.curcyCd));
                        }
                        else if (ParentModel.Equals("CoinTradingViewModel"))
                        {
                            ((CoinTradingViewModel)ParentViewModel).SetCoin(HeaderName, HeaderCode, SelectItem.curcyCd);
                        }
                        else if (ParentModel.Equals("TradeHistoryTradingViewModel"))
                        {
                            ((TradeHistoryTradingViewModel)ParentViewModel).SetCoinTradeHistory(HeaderName, SelectCoinCode);
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
            }
        }
예제 #24
0
        public ShellViewModel(IRegionManager regionManager, IRegionDialogService dialogService,
                              IConnectionService connectionService)
        {
            _regionManager     = regionManager;
            _dialogService     = dialogService;
            _connectionService = connectionService;

            // Page load command
            LoadCommand = new DelegateCommand(async() =>
            {
                // Get all connections from json configuration file
                var connection = await _connectionService.GetAllAsync();

                if (connection != null && connection.Count > 0)
                {
                    DispatcherService.BeginInvoke(() => Connections = connection);
                }
            });

            // Treeview item selection command
            NavCommand = new DelegateCommand <object>(async(item) =>
            {
                // Connection
                if (item is ConnectionInfo connection)
                {
                    // If connection is un-connecting or disconnected, start connection
                    if (!connection.IsConnecting && !connection.IsConnected)
                    {
                        await connection.ConnectAsync();
                    }
                    return;
                }

                // Database
                if (item is DatabaseInfo database)
                {
                    if (!database.IsInitialized)
                    {
                        await database.LoadKeyAsync(); // load all keys
                    }
                    return;
                }

                // Key
                if (item is KeyInfo key)
                {
                    _regionManager.ShowKeyViewer(key); // show key detail view
                    return;
                }
            });

            // New key view command
            NewKeyCommand = new DelegateCommand <DatabaseInfo>((database) =>
            {
                // Show new key view
                _dialogService.ShowNewKey(database, c =>
                {
                    // If add new key success, append the KeyInfo to the Treeview, not need reload the Treeview
                    if (c.Result == ButtonResult.OK)
                    {
                    }
                });
            });

            // New connection view command
            NewConnectionCommand = new DelegateCommand(() =>
            {
                // Show new connection view
                _dialogService.ShowNewConnection(c =>
                {
                    // If add new connection success, append the ConnectionInfo to the Treeview, not need reload the Treeview
                    if (c.Result == ButtonResult.OK &&
                        c.Parameters.TryGetValue <ConnectionInfo>("connection_info", out var connection) && connection != null)
                    {
                        // Maybe Treeview is null
                        if (Connections == null)
                        {
                            Connections = new ConnectionCollection();
                        }

                        Connections.Add(connection);
                    }
                });
            });
        }