ソースを参照

修改了弹窗

l2736 9 ヶ月 前
コミット
26a58953f5

+ 1 - 1
Shaker.Model/Model/ShakerControlModel.cs

@@ -135,7 +135,7 @@ namespace Shaker.Model
 
 
             DCVoltage4.MaxValue = 999;
             DCVoltage4.MaxValue = 999;
             DCVoltage4.MinValue = 0;
             DCVoltage4.MinValue = 0;
-            DCVoltage4.Address = 3021;
+            DCVoltage4.Address = 3023;
             DCVoltage4.B = 0;
             DCVoltage4.B = 0;
             DCVoltage4.K = 1;
             DCVoltage4.K = 1;
             DCVoltage4.Unit = "V";
             DCVoltage4.Unit = "V";

+ 5 - 4
ShakerControl/App.xaml

@@ -18,6 +18,7 @@
             <system:Double x:Key="WindowWidth">1024</system:Double>
             <system:Double x:Key="WindowWidth">1024</system:Double>
             <system:Double x:Key="WindowHeight">768</system:Double>
             <system:Double x:Key="WindowHeight">768</system:Double>
             <vm:MainViewModelBindingProxy x:Key="MainViewModel" />
             <vm:MainViewModelBindingProxy x:Key="MainViewModel" />
+            <vm:BindingProxy x:Key="Prompt" Data="{x:Static vm:PromptViewModel.Default}" />
             <convert:Type2ViewConverter x:Key="Type2ViewConverter" />
             <convert:Type2ViewConverter x:Key="Type2ViewConverter" />
             <convert:EnumToCollectionConverter x:Key="EnumToCollectionConverter" />
             <convert:EnumToCollectionConverter x:Key="EnumToCollectionConverter" />
             <convert:EnumToDescription x:Key="EnumToDescription" />
             <convert:EnumToDescription x:Key="EnumToDescription" />
@@ -340,8 +341,8 @@
             </Style>
             </Style>
             <Style
             <Style
                 x:Key="ComboBoxStyle1"
                 x:Key="ComboBoxStyle1"
-                TargetType="{x:Type ComboBox}"
-                BasedOn="{StaticResource InputElementBaseStyle}">
+                BasedOn="{StaticResource InputElementBaseStyle}"
+                TargetType="{x:Type ComboBox}">
                 <Setter Property="ItemContainerStyle" Value="{StaticResource ComboBoxItemBaseStyle1}" />
                 <Setter Property="ItemContainerStyle" Value="{StaticResource ComboBoxItemBaseStyle1}" />
                 <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
                 <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
                 <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
                 <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
@@ -359,8 +360,8 @@
             </Style>
             </Style>
             <Style
             <Style
                 x:Key="PowerAmplifierButtonStyle"
                 x:Key="PowerAmplifierButtonStyle"
-                TargetType="Button"
-                BasedOn="{StaticResource ButtonIcon}">
+                BasedOn="{StaticResource ButtonIcon}"
+                TargetType="Button">
                 <Style.Triggers>
                 <Style.Triggers>
                     <Trigger Property="IsMouseOver" Value="True">
                     <Trigger Property="IsMouseOver" Value="True">
                         <Setter Property="Foreground" Value="CadetBlue" />
                         <Setter Property="Foreground" Value="CadetBlue" />

+ 38 - 17
ShakerControl/MainWindow.xaml

@@ -218,6 +218,18 @@
                     Margin="0,10,40,0"
                     Margin="0,10,40,0"
                     HorizontalAlignment="Right"
                     HorizontalAlignment="Right"
                     VerticalAlignment="Top">
                     VerticalAlignment="Top">
+                    <Viewbox.Style>
+                        <Style TargetType="Viewbox">
+                            <Style.Triggers>
+                                <DataTrigger Binding="{Binding Path=MangerIsOnLine}" Value="True">
+                                    <Setter Property="ToolTip" Value="管理端在线" />
+                                </DataTrigger>
+                                <DataTrigger Binding="{Binding Path=MangerIsOnLine}" Value="False">
+                                    <Setter Property="ToolTip" Value="管理端离线" />
+                                </DataTrigger>
+                            </Style.Triggers>
+                        </Style>
+                    </Viewbox.Style>
                     <Path>
                     <Path>
                         <Path.Style>
                         <Path.Style>
                             <Style TargetType="Path">
                             <Style TargetType="Path">
@@ -225,12 +237,10 @@
                                     <DataTrigger Binding="{Binding Path=MangerIsOnLine}" Value="True">
                                     <DataTrigger Binding="{Binding Path=MangerIsOnLine}" Value="True">
                                         <Setter Property="Data" Value="{StaticResource OnlineGeometry}" />
                                         <Setter Property="Data" Value="{StaticResource OnlineGeometry}" />
                                         <Setter Property="Fill" Value="Green" />
                                         <Setter Property="Fill" Value="Green" />
-                                        <Setter Property="ToolTip" Value="管理端在线" />
                                     </DataTrigger>
                                     </DataTrigger>
                                     <DataTrigger Binding="{Binding Path=MangerIsOnLine}" Value="False">
                                     <DataTrigger Binding="{Binding Path=MangerIsOnLine}" Value="False">
                                         <Setter Property="Data" Value="{StaticResource OfflineGeometry}" />
                                         <Setter Property="Data" Value="{StaticResource OfflineGeometry}" />
                                         <Setter Property="Fill" Value="Red" />
                                         <Setter Property="Fill" Value="Red" />
-                                        <Setter Property="ToolTip" Value="管理端离线" />
                                     </DataTrigger>
                                     </DataTrigger>
                                 </Style.Triggers>
                                 </Style.Triggers>
                             </Style>
                             </Style>
@@ -242,17 +252,27 @@
                     Margin="0,10,10,0"
                     Margin="0,10,10,0"
                     HorizontalAlignment="Right"
                     HorizontalAlignment="Right"
                     VerticalAlignment="Top">
                     VerticalAlignment="Top">
+                    <Viewbox.Style>
+                        <Style TargetType="Viewbox">
+                            <Style.Triggers>
+                                <DataTrigger Binding="{Binding Path=MainPage.ShakerControl.AllowRemote}" Value="{x:Static data:AllowRemoteControl.Remote}">
+                                    <Setter Property="ToolTip" Value="本地控制" />
+                                </DataTrigger>
+                                <DataTrigger Binding="{Binding Path=MainPage.ShakerControl.AllowRemote}" Value="{x:Static data:AllowRemoteControl.Local}">
+                                    <Setter Property="ToolTip" Value="远程控制" />
+                                </DataTrigger>
+                            </Style.Triggers>
+                        </Style>
+                    </Viewbox.Style>
                     <Path Fill="White">
                     <Path Fill="White">
                         <Path.Style>
                         <Path.Style>
                             <Style TargetType="Path">
                             <Style TargetType="Path">
                                 <Style.Triggers>
                                 <Style.Triggers>
                                     <DataTrigger Binding="{Binding Path=MainPage.ShakerControl.AllowRemote}" Value="{x:Static data:AllowRemoteControl.Remote}">
                                     <DataTrigger Binding="{Binding Path=MainPage.ShakerControl.AllowRemote}" Value="{x:Static data:AllowRemoteControl.Remote}">
                                         <Setter Property="Data" Value="{StaticResource RemoteControl}" />
                                         <Setter Property="Data" Value="{StaticResource RemoteControl}" />
-                                        <Setter Property="ToolTip" Value="本地控制" />
                                     </DataTrigger>
                                     </DataTrigger>
                                     <DataTrigger Binding="{Binding Path=MainPage.ShakerControl.AllowRemote}" Value="{x:Static data:AllowRemoteControl.Local}">
                                     <DataTrigger Binding="{Binding Path=MainPage.ShakerControl.AllowRemote}" Value="{x:Static data:AllowRemoteControl.Local}">
                                         <Setter Property="Data" Value="{StaticResource LocalControl}" />
                                         <Setter Property="Data" Value="{StaticResource LocalControl}" />
-                                        <Setter Property="ToolTip" Value="远程控制" />
                                     </DataTrigger>
                                     </DataTrigger>
                                 </Style.Triggers>
                                 </Style.Triggers>
                             </Style>
                             </Style>
@@ -601,7 +621,8 @@
             Grid.Row="0"
             Grid.Row="0"
             Grid.RowSpan="3"
             Grid.RowSpan="3"
             AllowsTransparency="True"
             AllowsTransparency="True"
-            IsOpen="{Binding Prompt.IsOpen}"
+            DataContext="{Binding Source={StaticResource Prompt}, Path=Data}"
+            IsOpen="{Binding IsOpen}"
             Placement="Center"
             Placement="Center"
             PlacementTarget="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"
             PlacementTarget="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"
             PopupAnimation="Slide"
             PopupAnimation="Slide"
@@ -631,7 +652,7 @@
                                 FontSize="{StaticResource ContentTitleFontSize}"
                                 FontSize="{StaticResource ContentTitleFontSize}"
                                 FontWeight="Bold"
                                 FontWeight="Bold"
                                 Foreground="White"
                                 Foreground="White"
-                                Text="{Binding Prompt.Title}" />
+                                Text="{Binding Title}" />
                         </Border>
                         </Border>
                         <StackPanel
                         <StackPanel
                             Grid.Row="1"
                             Grid.Row="1"
@@ -646,8 +667,8 @@
                                 Height="60"
                                 Height="60"
                                 HorizontalAlignment="Center"
                                 HorizontalAlignment="Center"
                                 VerticalAlignment="Center"
                                 VerticalAlignment="Center"
-                                Visibility="{Binding Prompt.IconVisibility}">
-                                <Path Data="{Binding Prompt.IconGeometry, Mode=OneWay}" Fill="{Binding Prompt.IconBrush}" />
+                                Visibility="{Binding IconVisibility}">
+                                <Path Data="{Binding IconGeometry, Mode=OneWay}" Fill="{Binding IconBrush}" />
                             </Viewbox>
                             </Viewbox>
                             <TextBlock
                             <TextBlock
                                 Grid.Row="1"
                                 Grid.Row="1"
@@ -658,7 +679,7 @@
                                 VerticalAlignment="Center"
                                 VerticalAlignment="Center"
                                 FontSize="20"
                                 FontSize="20"
                                 Foreground="White"
                                 Foreground="White"
-                                Text="{Binding Prompt.Message}"
+                                Text="{Binding Message}"
                                 TextWrapping="Wrap" />
                                 TextWrapping="Wrap" />
                         </StackPanel>
                         </StackPanel>
                         <StackPanel
                         <StackPanel
@@ -670,20 +691,20 @@
                             <Button
                             <Button
                                 Width="88"
                                 Width="88"
                                 Height="38"
                                 Height="38"
-                                Command="{Binding Prompt.YesCommand}"
-                                Content="{Binding Prompt.YesText}"
+                                Command="{Binding YesCommand}"
+                                Content="{Binding YesText}"
                                 Cursor="Hand"
                                 Cursor="Hand"
-                                ToolTip="{Binding Prompt.YesText}"
-                                Visibility="{Binding Prompt.YesVisibility}" />
+                                ToolTip="{Binding YesText}"
+                                Visibility="{Binding YesVisibility}" />
                             <Button
                             <Button
                                 Width="88"
                                 Width="88"
                                 Height="38"
                                 Height="38"
                                 Margin="40,0,0,0"
                                 Margin="40,0,0,0"
-                                Command="{Binding Prompt.NoCommand}"
-                                Content="{Binding Prompt.NoText}"
+                                Command="{Binding NoCommand}"
+                                Content="{Binding NoText}"
                                 Cursor="Hand"
                                 Cursor="Hand"
-                                ToolTip="{Binding Prompt.NoText}"
-                                Visibility="{Binding Prompt.NoVisibility}" />
+                                ToolTip="{Binding NoText}"
+                                Visibility="{Binding NoVisibility}" />
 
 
                         </StackPanel>
                         </StackPanel>
                     </Grid>
                     </Grid>

+ 36 - 0
ShakerControl/Tools/DispatherInovke.cs

@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ShakerControl.Tools
+{
+    public static class DispatherInovke
+    {
+        public static void Inovke(Action action)
+        {
+            if (action == null) return;
+            if (App.Current.Dispatcher.Thread == Thread.CurrentThread)
+            {
+                action();
+            }
+            else
+            {
+                App.Current?.Dispatcher?.Invoke(action);
+            }
+        }
+        //public static void Inovke(this Action action)
+        //{
+        //    if (action == null) return;
+        //    if (App.Current.Dispatcher.Thread == Thread.CurrentThread)
+        //    {
+        //        action();
+        //    }
+        //    else
+        //    {
+        //        App.Current?.Dispatcher?.Invoke(action);
+        //    }
+        //}
+    }
+}

+ 15 - 40
ShakerControl/ViewModel/MainWindowViewModel.cs

@@ -17,6 +17,7 @@ using EventBus;
 using HandyControl.Interactivity;
 using HandyControl.Interactivity;
 using System.Windows.Controls;
 using System.Windows.Controls;
 using Shaker.ViewModel;
 using Shaker.ViewModel;
+using System.Windows.Markup;
 
 
 namespace ShakerControl.ViewModel
 namespace ShakerControl.ViewModel
 {
 {
@@ -219,19 +220,18 @@ namespace ShakerControl.ViewModel
             });
             });
             Paused();
             Paused();
         }
         }
-        public PromptViewModel Prompt { get; set; } = new PromptViewModel();
         public string ServerIP { get => serverIP; set =>UpdateProperty(ref serverIP, value); }
         public string ServerIP { get => serverIP; set =>UpdateProperty(ref serverIP, value); }
         public int ServerPort { get => serverPort; set =>UpdateProperty(ref serverPort, value); }
         public int ServerPort { get => serverPort; set =>UpdateProperty(ref serverPort, value); }
         public void Stop()=>tokenSource?.Cancel();
         public void Stop()=>tokenSource?.Cancel();
         public ViewModel.Setting.SettingViewModel Setting { get; } = new Setting.SettingViewModel();
         public ViewModel.Setting.SettingViewModel Setting { get; } = new Setting.SettingViewModel();
         public SystemConfigViewModel SystemConfig { get; } = new SystemConfigViewModel();
         public SystemConfigViewModel SystemConfig { get; } = new SystemConfigViewModel();
         public ICommand ExitCommand => new DelegateCommand(() =>
         public ICommand ExitCommand => new DelegateCommand(() =>
-        {
-            Prompt.Init();
-            Prompt.Message = "是否退出程序?";
-            Prompt.YesAction = () => App.Current.Shutdown(); ;
-            Prompt.IconType = IconType.Ask;
-            Prompt.IsOpen = true;
+        {            
+            PromptViewModel.Default.Init();
+            PromptViewModel.Default.Message = "是否退出程序?";
+            PromptViewModel.Default.YesAction = () => App.Current.Shutdown(); ;
+            PromptViewModel.Default.IconType = IconType.Ask;
+            PromptViewModel.Default.IsOpen = true;
         });
         });
 
 
         public ICommand ShutDownCommand => new DelegateCommand(() =>App.Current.Shutdown());
         public ICommand ShutDownCommand => new DelegateCommand(() =>App.Current.Shutdown());
@@ -271,33 +271,18 @@ namespace ShakerControl.ViewModel
                     bus = EasyMQ.ActiveHutch.Default.CreateBus($"tcp://{ServerIP}:{ServerPort}?alwaysSessionAsync=true", new EasyMQ.MessagePackSerializer());
                     bus = EasyMQ.ActiveHutch.Default.CreateBus($"tcp://{ServerIP}:{ServerPort}?alwaysSessionAsync=true", new EasyMQ.MessagePackSerializer());
                     bus.PubSub.Subscribe<Shaker.Model.MangerExitModel>((data, _) =>
                     bus.PubSub.Subscribe<Shaker.Model.MangerExitModel>((data, _) =>
                     {
                     {
-                        if (Thread.CurrentThread == App.Current.Dispatcher.Thread)
+                        DispatherInovke.Inovke(() =>
                         {
                         {
                             MangerIsOnLine = data.Online;
                             MangerIsOnLine = data.Online;
                             if (!data.Online)
                             if (!data.Online)
                             {
                             {
-                                Prompt.Init();
-                                Prompt.Message = "管理器已离线";
-                                Prompt.IconType = IconType.Error;
-                                Prompt.NoVisibility = Visibility.Collapsed;
-                                Prompt.IsOpen = true;
+                                PromptViewModel.Default.Init();
+                                PromptViewModel.Default.Message = "管理器已离线";
+                                PromptViewModel.Default.IconType = IconType.Error;
+                                PromptViewModel.Default.NoVisibility = Visibility.Collapsed;
+                                PromptViewModel.Default.IsOpen = true;
                             }
                             }
-                        }
-                        else
-                        {
-                            App.Current.Dispatcher.BeginInvoke(new Action(() =>
-                            {
-                                MangerIsOnLine = data.Online;
-                                if (!data.Online)
-                                {
-                                    Prompt.Init();
-                                    Prompt.Message = "管理器已离线";
-                                    Prompt.IconType = IconType.Error;
-                                    Prompt.NoVisibility = Visibility.Collapsed;
-                                    Prompt.IsOpen = true;
-                                }
-                            }));
-                        }
+                        });
                     });
                     });
                     bus.PubSub.Subscribe<SystemConfigModel>((data, _) =>
                     bus.PubSub.Subscribe<SystemConfigModel>((data, _) =>
                     {
                     {
@@ -310,17 +295,7 @@ namespace ShakerControl.ViewModel
             catch
             catch
             {
             {
                 MessageBoxHelper.Error("服务端未运行,程序退出");
                 MessageBoxHelper.Error("服务端未运行,程序退出");
-                if (Thread.CurrentThread == Application.Current.Dispatcher.Thread)
-                {
-                    App.Current.Shutdown();
-                }
-                else
-                {
-                    App.Current.Dispatcher.BeginInvoke(new Action(() =>
-                    {
-                        App.Current.Shutdown();
-                    }));
-                }
+                Tools.DispatherInovke.Inovke(() => App.Current.Shutdown());
                 return;
                 return;
             }
             }
             MainPage.Init();
             MainPage.Init();

+ 15 - 21
ShakerControl/ViewModel/PromptViewModel.cs

@@ -15,9 +15,13 @@ namespace ShakerControl.ViewModel
 {
 {
     internal class PromptViewModel:ViewModelBase<Shaker.Model.ModelBase>
     internal class PromptViewModel:ViewModelBase<Shaker.Model.ModelBase>
     {
     {
+        static PromptViewModel()
+        {
+
+        }
         private uint maxcount = 0;
         private uint maxcount = 0;
         private uint consumetime = 0;
         private uint consumetime = 0;
-        public PromptViewModel()
+        private PromptViewModel()
         {
         {
             timer.Stop();
             timer.Stop();
             timer.Interval = 1000;
             timer.Interval = 1000;
@@ -25,33 +29,22 @@ namespace ShakerControl.ViewModel
             timer.Elapsed += (sender, e) =>
             timer.Elapsed += (sender, e) =>
             {
             {
                 consumetime++;
                 consumetime++;
-                if (Thread.CurrentThread != App.Current.Dispatcher.Thread)
+                Tools.DispatherInovke.Inovke(() =>
                 {
                 {
-                    App.Current.Dispatcher.Invoke(() =>
+                    if (YesTextFunc != null)
                     {
                     {
-                        if(YesTextFunc!=null)
-                        {
-                            YesText = YesTextFunc(consumetime);
-                        }
-                        if(NoTextFunc!=null)
-                        {
-                            NoText = NoTextFunc(consumetime);
-                        }
-                        if (consumetime >= maxcount)
-                        {
-                            IsOpen = false;
-                            timer.Stop();
-                        }
-                    });
-                }
-                else
-                {
+                        YesText = YesTextFunc(consumetime);
+                    }
+                    if (NoTextFunc != null)
+                    {
+                        NoText = NoTextFunc(consumetime);
+                    }
                     if (consumetime >= maxcount)
                     if (consumetime >= maxcount)
                     {
                     {
                         IsOpen = false;
                         IsOpen = false;
                         timer.Stop();
                         timer.Stop();
                     }
                     }
-                }
+                });
             };
             };
         }
         }
         public override void Init()
         public override void Init()
@@ -73,6 +66,7 @@ namespace ShakerControl.ViewModel
             IsOpen = false;
             IsOpen = false;
             IconType = IconType.Info;
             IconType = IconType.Info;
         }
         }
+        public static PromptViewModel Default { get; } = new PromptViewModel();
         
         
         public Visibility IconVisibility { get => iconVisibility; set =>UpdateProperty(ref iconVisibility, value); }
         public Visibility IconVisibility { get => iconVisibility; set =>UpdateProperty(ref iconVisibility, value); }
         public IconType IconType 
         public IconType IconType 

+ 28 - 57
ShakerControl/ViewModel/ShakerControlViewModel.cs

@@ -166,33 +166,19 @@ namespace ShakerControl.ViewModel
                 MainWindowViewModel.Default.Bus.PubSub.Subscribe<Shaker.Model.ShakerControlModel>((model, _) =>
                 MainWindowViewModel.Default.Bus.PubSub.Subscribe<Shaker.Model.ShakerControlModel>((model, _) =>
                 {
                 {
                     PublishLog($"振动台{Description}的参数已修改");
                     PublishLog($"振动台{Description}的参数已修改");
-                    if (Thread.CurrentThread == App.Current.Dispatcher.Thread)
+                    Tools.DispatherInovke.Inovke(() =>
                     {
                     {
-                        MainWindowViewModel.Default.Prompt.Init();
-                        MainWindowViewModel.Default.Prompt.NoTextFunc = (index) => $"否({10 - index})";
-                        MainWindowViewModel.Default.Prompt.Message = $"振动台{Description}的参数已修改,是否重启程序?";
-                        MainWindowViewModel.Default.Prompt.YesAction = () =>
+                        PromptViewModel.Default.Init();
+                        PromptViewModel.Default.NoTextFunc = (index) => $"否({10 - index})";
+                        PromptViewModel.Default.Message = $"振动台{Description}的参数已修改,是否重启程序?";
+                        PromptViewModel.Default.YesAction = () =>
                         {
                         {
                             (App.Current as App)?.Restart();
                             (App.Current as App)?.Restart();
                         };
                         };
-                        MainWindowViewModel.Default.Prompt.SetTimeout(10);
-                        MainWindowViewModel.Default.Prompt.IsOpen = true;
-                    }
-                    else
-                    {
-                        App.Current.Dispatcher.Invoke(() =>
-                        {
-                            MainWindowViewModel.Default.Prompt.Init();
-                            MainWindowViewModel.Default.Prompt.NoTextFunc = (index) => $"否({10 - index})";
-                            MainWindowViewModel.Default.Prompt.Message = $"振动台{Description}的参数已修改,是否重启程序?";
-                            MainWindowViewModel.Default.Prompt.YesAction = () =>
-                            {
-                                (App.Current as App)?.Restart();
-                            };
-                            MainWindowViewModel.Default.Prompt.SetTimeout(10);
-                            MainWindowViewModel.Default.Prompt.IsOpen = true;
-                        });
-                    }
+                        PromptViewModel.Default.SetTimeout(10);
+                        PromptViewModel.Default.IsOpen = true;
+                    });
+                   
                 }, $"{Shaker.Model.GlobalVariable.ShakerIDKey} = '{model.Id}'");
                 }, $"{Shaker.Model.GlobalVariable.ShakerIDKey} = '{model.Id}'");
 
 
                 MainWindowViewModel.Default.Bus.RPC.Respond<Shaker.Model.SysControl, Shaker.Model.Result>(SystemControl, $"{Shaker.Model.GlobalVariable.ShakerIDKey} = '{model.Id}'");
                 MainWindowViewModel.Default.Bus.RPC.Respond<Shaker.Model.SysControl, Shaker.Model.Result>(SystemControl, $"{Shaker.Model.GlobalVariable.ShakerIDKey} = '{model.Id}'");
@@ -398,35 +384,20 @@ namespace ShakerControl.ViewModel
                                     {
                                     {
                                         Success = true,
                                         Success = true,
                                     };
                                     };
-                                    if(Thread.CurrentThread == App.Current.Dispatcher.Thread)
+                                    Tools.DispatherInovke.Inovke(() =>
                                     {
                                     {
-                                        MainWindowViewModel.Default.Prompt.Init();
-                                        MainWindowViewModel.Default.Prompt.Message = $"申请{Model.Description}的控制权限,是否同意?";
-                                        MainWindowViewModel.Default.Prompt.YesAction = () =>
+                                        PromptViewModel.Default.Init();
+                                        PromptViewModel.Default.Message = $"申请{Model.Description}的控制权限,是否同意?";
+                                        PromptViewModel.Default.YesAction = () =>
                                         {
                                         {
                                             AllowRemote = AllowRemoteControl.Remote;
                                             AllowRemote = AllowRemoteControl.Remote;
                                         };
                                         };
                                         uint count = MainWindowViewModel.Default.SystemConfig.RequestPermissionsTimeout / 1000;
                                         uint count = MainWindowViewModel.Default.SystemConfig.RequestPermissionsTimeout / 1000;
-                                        MainWindowViewModel.Default.Prompt.NoTextFunc = (index) => $"否({count - index})";
-                                        MainWindowViewModel.Default.Prompt.SetTimeout(count);
-                                        MainWindowViewModel.Default.Prompt.IsOpen = true;
-                                    }
-                                    else
-                                    {
-                                        App.Current.Dispatcher.BeginInvoke(() =>
-                                        {
-                                            MainWindowViewModel.Default.Prompt.Init();
-                                            MainWindowViewModel.Default.Prompt.Message = $"申请{Model.Description}的控制权限,是否同意?";
-                                            MainWindowViewModel.Default.Prompt.YesAction = () =>
-                                            {
-                                                AllowRemote = AllowRemoteControl.Remote;
-                                            };
-                                            uint count = MainWindowViewModel.Default.SystemConfig.RequestPermissionsTimeout / 1000;
-                                            MainWindowViewModel.Default.Prompt.NoTextFunc = (index) => $"否({count - index})";
-                                            MainWindowViewModel.Default.Prompt.SetTimeout(count);
-                                            MainWindowViewModel.Default.Prompt.IsOpen = true;
-                                        });
-                                    }
+                                        PromptViewModel.Default.NoTextFunc = (index) => $"否({count - index})";
+                                        PromptViewModel.Default.SetTimeout(count);
+                                        PromptViewModel.Default.IsOpen = true;
+                                    });
+                                   
                                     return new Result()
                                     return new Result()
                                     {
                                     {
                                         Success = true,
                                         Success = true,
@@ -565,11 +536,11 @@ namespace ShakerControl.ViewModel
             if (PLCControl.IsConnected) return;
             if (PLCControl.IsConnected) return;
             if (!PLCControl.Connect())
             if (!PLCControl.Connect())
             {
             {
-                MainWindowViewModel.Default.Prompt.Init();
-                MainWindowViewModel.Default.Prompt.IconType = IconType.Error;
-                MainWindowViewModel.Default.Prompt.NoVisibility = System.Windows.Visibility.Collapsed;
-                MainWindowViewModel.Default.Prompt.Message = "连接失败!";
-                MainWindowViewModel.Default.Prompt.IsOpen = true;
+                PromptViewModel.Default.Init();
+                PromptViewModel.Default.IconType = IconType.Error;
+                PromptViewModel.Default.NoVisibility = System.Windows.Visibility.Collapsed;
+                PromptViewModel.Default.Message = "连接失败!";
+                PromptViewModel.Default.IsOpen = true;
             }
             }
             else
             else
             {
             {
@@ -578,16 +549,16 @@ namespace ShakerControl.ViewModel
         });
         });
         public ICommand DisConnectCommand => new DelegateCommand(() =>
         public ICommand DisConnectCommand => new DelegateCommand(() =>
         {
         {
-            MainWindowViewModel.Default.Prompt.Init();
-            MainWindowViewModel.Default.Prompt.IconType = IconType.Ask;
-            MainWindowViewModel.Default.Prompt.Message = "是否断开连接?";
-            MainWindowViewModel.Default.Prompt.YesAction = () =>
+            PromptViewModel.Default.Init();
+            PromptViewModel.Default.IconType = IconType.Ask;
+            PromptViewModel.Default.Message = "是否断开连接?";
+            PromptViewModel.Default.YesAction = () =>
             {
             {
                 if (!PLCControl.IsConnected) return;
                 if (!PLCControl.IsConnected) return;
                 PublishLog("断开功放连接", LogType.Message);
                 PublishLog("断开功放连接", LogType.Message);
                 PLCControl.Disconnect();
                 PLCControl.Disconnect();
             };
             };
-            MainWindowViewModel.Default.Prompt.IsOpen = true;
+            PromptViewModel.Default.IsOpen = true;
         });
         });
     }
     }
 }
 }