Эх сурвалжийг харах

1.添加双击选择模型

litong 6 сар өмнө
parent
commit
523010428f

+ 3 - 3
CollaborativePlatformMain/Form/MessageSubPage/SeconThreeDimensionalPage.xaml

@@ -49,7 +49,7 @@
 
                 <DockPanel>
                     <Label Content="选择模型:"/>
-                    <TextBox Text="双击选择模型地址" Width="120" Height="26" Foreground="Red" HorizontalAlignment="Left" MouseDoubleClick="TextBox_MouseDoubleClick"/>
+                    <TextBox Text="双击选择模型地址" Name="selectModelApplication" Width="300" Height="26" Foreground="Red" HorizontalAlignment="Left" MouseDoubleClick="TextBox_MouseDoubleClick"/>
                 </DockPanel>
 
                 <DockPanel HorizontalAlignment="Left" Margin="50,10,0,0">
@@ -62,8 +62,8 @@
             <StackPanel Name="sp_modelEmploy" Visibility="Collapsed" Margin="10,10,0,0" Height="430">
 
                 <DockPanel>
-                    <Label Content="选择模型" Margin="0,0,10,0"/>
-                    <TextBox Text="双击选择模型地址" Width="300" Height="26" Foreground="Red" HorizontalAlignment="Left" MouseDoubleClick="TextBox_MouseDoubleClick"/>
+                    <Label Content="选择模型" Margin="0,0,10,0"/>
+                    <TextBox Text="双击选择模型地址" Name="selectModelServices" Width="300" Height="26" Foreground="Red" HorizontalAlignment="Left" MouseDoubleClick="SelectmodelServices_MouseDoubleClick"/>
                 </DockPanel>
 
                 <StackPanel HorizontalAlignment="Left" Margin="0,30,0,0">

+ 38 - 2
CollaborativePlatformMain/Form/MessageSubPage/SeconThreeDimensionalPage.xaml.cs

@@ -195,7 +195,7 @@ namespace CollaborativePlatformMain.Form.MessageSubPage
                 sp_modelUser.Visibility = Visibility.Visible;
                 sp_modelEmploy.Visibility = Visibility.Collapsed;
             }
-            else if (value=="模型服务")
+            else if (value == "模型服务")
             {
                 sp_autoModel.Visibility = Visibility.Collapsed;
                 sp_modelUser.Visibility = Visibility.Collapsed;
@@ -229,7 +229,12 @@ namespace CollaborativePlatformMain.Form.MessageSubPage
         /// <param name="e"></param>
         private void TextBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
         {
-
+            bool isSelectDwg = ShowSelectDWGFiles(out string filePath);
+            if (isSelectDwg)
+            {
+                selectModelApplication.Text = "";
+                selectModelApplication.Text = filePath;
+            }
         }
 
         /// <summary>
@@ -250,5 +255,36 @@ namespace CollaborativePlatformMain.Form.MessageSubPage
             button.Margin = new Thickness(0, 5, 0, 0);
             sp_objectDraw.Children.Add(button);
         }
+
+
+        /// <summary>
+        /// 选择单个文件
+        /// </summary>
+        /// <param name="filePath"></param>
+        /// <returns></returns>
+        public static bool ShowSelectDWGFiles(out string filePath)
+        {
+            filePath = "";
+            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
+            dlg.Multiselect = false;//等于true表示可以选择多个文件
+            dlg.DefaultExt = ".rvt";
+            dlg.Filter = "RVT 文件|*.rvt";
+
+            if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK) return false;
+
+            filePath = dlg.FileName;
+            return true;
+
+        }
+
+        private void SelectmodelServices_MouseDoubleClick(object sender, MouseButtonEventArgs e)
+        {
+            bool isSelectDwg = ShowSelectDWGFiles(out string filePath);
+            if (isSelectDwg)
+            {
+                selectModelServices.Text = "";
+                selectModelServices.Text = filePath;
+            }
+        }
     }
 }