Esempio n. 1
0
        void BUILDING_Click(object sender, RoutedEventArgs e)
        {
            if (LenghtBaseFrame.Text == "")
            {
                return;
            }

            if (FrameOffset.Text == "")
            {
                try
                {
                    FrameOffset.Text = Convert.ToString((Convert.ToDouble(LenghtBaseFrame.Text) / 2));
                }
                catch (Exception)
                {
                    FrameOffset.Text = Convert.ToString((Convert.ToDouble(LenghtBaseFrame.Text) / 2));
                }
            }

            //goto m2;

            //ModelSw

            var sw = new ModelSw();

            sw.MontageFrame(
                WidthBaseFrame.Text,
                LenghtBaseFrame.Text,
                Thikness.Text,
                TypeOfFrame.Text,
                FrameOffset.Text,
                MaterialMontageFrame.SelectedValue.ToString(),
                new[]
            {
                Ral1.Text, CoatingType1.Text, CoatingClass1.Text,
                Ral1.SelectedValue?.ToString() ?? ""
            });

            FrameOffset.Text = "";

            return;

m1:         // VentsCadLibrary

            try
            {
                using (var server = new VentsCadLibrary.VentsCad())
                {
                    var newDumper = new VentsCadLibrary.VentsCad.MontageFrame(TypeOfFrame.Text, WidthBaseFrame.Text, LenghtBaseFrame.Text, FrameOffset.Text,
                                                                              new VentsCadLibrary.VentsCad.ProductFactory.Material
                    {
                        Name     = MaterialMontageFrame.Text,
                        Thikness = Thikness.Text,
                        Value    = MaterialMontageFrame.SelectedValue.ToString(),
                    });
                    if (!newDumper.Exist)
                    {
                        newDumper.Build();
                    }
                    var place = newDumper.GetPlace();
                    MessageBox.Show(place.Path + "\n" + place.IdPdm + "\n" + place.ProjectId);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return;

m2:         // VentsCadService

            MessageBox.Show("VentsCadService");

            try
            {
                var serv = new ServiceV(
                    new VentsCadService.Parameters
                {
                    Name = "montageFrame",
                    Type = new VentsCadService.Type {
                        SubType = TypeOfFrame.Text
                    },
                    Sizes = new VentsCadService.Sizes[]
                    {
                        new VentsCadService.Sizes
                        {
                            Width       = TypeOfFrame.Text,
                            Lenght      = WidthBaseFrame.Text,
                            Additional1 = FrameOffset.Text
                        }
                    },
                    Materials = new VentsCadService.Material[]
                    {
                        new VentsCadService.Material
                        {
                            Name     = MaterialMontageFrame.Text,
                            Thikness = Thikness.Text,
                            Value    = MaterialMontageFrame.SelectedValue.ToString(),
                        }
                    }
                });
                var Build = new Task(serv.build);
                Build.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            FrameOffset.Text = "";
        }
        void BUILDING_Click(object sender, RoutedEventArgs e)
        {
            if (LenghtBaseFrame.Text == "") return;
            
            if (FrameOffset.Text == "")
            {
                try
                {
                    FrameOffset.Text = Convert.ToString((Convert.ToDouble(LenghtBaseFrame.Text) / 2));
                }
                catch (Exception)
                {
                    FrameOffset.Text = Convert.ToString((Convert.ToDouble(LenghtBaseFrame.Text) / 2));
                }
            }

            //goto m2;

            //ModelSw

            var sw = new ModelSw();

            sw.MontageFrame(
                WidthBaseFrame.Text,
                LenghtBaseFrame.Text,
                Thikness.Text,
                TypeOfFrame.Text,
                FrameOffset.Text,
                MaterialMontageFrame.SelectedValue.ToString(),
                new[]
                {
                    Ral1.Text, CoatingType1.Text, CoatingClass1.Text,
                    Ral1.SelectedValue?.ToString() ?? ""
                });

            FrameOffset.Text = "";

            return;

            m1: // VentsCadLibrary

            try
            {
                using (var server = new VentsCadLibrary.VentsCad())
                {
                    var newDumper = new VentsCadLibrary.VentsCad.MontageFrame(TypeOfFrame.Text, WidthBaseFrame.Text, LenghtBaseFrame.Text, FrameOffset.Text,
                        new VentsCadLibrary.VentsCad.ProductFactory.Material
                        {
                            Name = MaterialMontageFrame.Text,
                            Thikness = Thikness.Text,
                            Value = MaterialMontageFrame.SelectedValue.ToString(),
                        });
                    if (!newDumper.Exist)
                    {
                        newDumper.Build();
                    }
                    var place = newDumper.GetPlace();
                    MessageBox.Show(place.Path + "\n" + place.IdPdm + "\n" + place.ProjectId);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return;

            m2:  // VentsCadService

            MessageBox.Show("VentsCadService");

            try
            {
                var serv = new ServiceV(
                    new VentsCadService.Parameters
                    {
                        Name = "montageFrame",   
                        Type = new VentsCadService.Type { SubType = TypeOfFrame.Text },                   
                        Sizes = new VentsCadService.Sizes[]
                        {
                            new VentsCadService.Sizes
                            {
                                Width = TypeOfFrame.Text,
                                Lenght = WidthBaseFrame.Text,
                                Additional1 = FrameOffset.Text
                            }
                        },
                        Materials = new VentsCadService.Material[]
                        {
                            new VentsCadService.Material
                            {
                                Name = MaterialMontageFrame.Text,
                                Thikness = Thikness.Text,
                                Value = MaterialMontageFrame.SelectedValue.ToString(),
                            }
                        }
                    });
                var Build = new Task(serv.build);
                Build.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            FrameOffset.Text = "";
        }
        void UserControl_Loaded_1(object sender, RoutedEventArgs e)
        {
            _bw.DoWork += ((o, args) =>
            {
                Dispatcher.Invoke(DispatcherPriority.Background, EmptyDelegate);
                // Dispatcher.Thread.SetApartmentState(new ApartmentState());
                Dispatcher.InvokeAsync(() =>
                {
                    try
                    {
                        var sw = new ModelSw();


                        if (Unit50Full.IsChecked == true)
                        {
                            if (FrameOffset.Text == "")
                            {
                                try
                                {
                                    FrameOffset.Text = Convert.ToString(Convert.ToDouble(Lenght.Text) / 2);
                                }
                                catch (Exception)
                                {
                                    FrameOffset.Text = Convert.ToString(Convert.ToDouble(Lenght.Text) / 2);
                                }
                            }


                            //Dispatcher.Invoke(
                            //    () =>
                            //        sw.UnitAsmbly(SizeOfUnit.Text, "00", "",WidthU.Text, HeightU.Text,
                            //            Lenght.Text, Thikness.Text, TypeOfFrame.Text,
                            //            FrameOffset.Text, new[] { null, TypeOfPanel50.Text }, MaterialP1.Text, MaterialP2.Text, "", ""));
                            ////  Parallel.Invoke(() => sw.UnitAsmbly(SizeOfUnit.Text, "00", WidthU.Text, HeightU.Text, Lenght.Text, Thikness.Text, TypeOfFrame.Text, FrameOffset.Text));
                            //sw.UnitAsmbly(SizeOfUnit.Text, "00", WidthU.Text, HeightU.Text,
                            //    Lenght.Text, Thikness.Text, TypeOfFrame.Text, FrameOffset.Text);
                        }
                        else if (MontageFrame50.IsChecked == true)
                        {
                            if (FrameOffset.Visibility == Visibility.Collapsed &
                                LenghtBaseFrame.Text != "")
                            {
                                try
                                {
                                    FrameOffset.Text = Convert.ToString((Convert.ToDouble(LenghtBaseFrame.Text) / 2));
                                }
                                catch (Exception)
                                {
                                    FrameOffset.Text = Convert.ToString(150);
                                }
                            }

                            sw.MontageFrame(WidthBaseFrame.Text, LenghtBaseFrame.Text, Thikness.Text,
                                            TypeOfFrame.Text, FrameOffset.Text, MaterialMontageFrame.Text, null);
                        }
                        else if (TypeOfUnit50.IsChecked == true)
                        {
                        }
                        else if (Panel50.IsChecked == true)
                        {
                            sw.Panels50Build(
                                new[] { null, TypeOfPanel50.Text },
                                WidthPanel.Text,
                                HeightPanel.Text,
                                new[] { "Az", null },
                                new[] { "Az", null },
                                null);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                });
            });
            //Dispatcher.Thread.SetApartmentState(new ApartmentState());
            Dispatcher.InvokeAsync(() =>
            {
                //var sw = new ModelSw();
                //sw.CreateDistDirectory(string.Format(@"{0}\{1}", @Properties.Settings.Default.DestinationFolder,
                //    sw.Unit50Folder));
                //sw.CreateDistDirectory(string.Format(@"{0}\{1}", @Properties.Settings.Default.DestinationFolder,
                //    sw.Panel50DestinationFolder));
                //sw.CreateDistDirectory(string.Format(@"{0}\{1}", @Properties.Settings.Default.DestinationFolder,
                //    sw.BaseFrameDestinationFolder));
            });
        }
        void UserControl_Loaded_1(object sender, RoutedEventArgs e)
        {
            _bw.DoWork += ((o, args) =>
            {
                Dispatcher.Invoke(DispatcherPriority.Background, EmptyDelegate);
               // Dispatcher.Thread.SetApartmentState(new ApartmentState());
                Dispatcher.InvokeAsync( ()=>
            {
                                        try
                                        {
                                            var sw = new ModelSw();


                                            if (Unit50Full.IsChecked == true)
                                            {
                                                if (FrameOffset.Text == "")
                                                {
                                                    try
                                                    {
                                                        FrameOffset.Text = Convert.ToString(Convert.ToDouble(Lenght.Text) / 2);
                                                    }
                                                    catch (Exception)
                                                    {
                                                        FrameOffset.Text = Convert.ToString(Convert.ToDouble(Lenght.Text) / 2);
                                                    }
                                                }


                                                //Dispatcher.Invoke(
                                                //    () =>
                                                //        sw.UnitAsmbly(SizeOfUnit.Text, "00", "",WidthU.Text, HeightU.Text,
                                                //            Lenght.Text, Thikness.Text, TypeOfFrame.Text,
                                                //            FrameOffset.Text, new[] { null, TypeOfPanel50.Text }, MaterialP1.Text, MaterialP2.Text, "", ""));
                                                ////  Parallel.Invoke(() => sw.UnitAsmbly(SizeOfUnit.Text, "00", WidthU.Text, HeightU.Text, Lenght.Text, Thikness.Text, TypeOfFrame.Text, FrameOffset.Text));
                                                //sw.UnitAsmbly(SizeOfUnit.Text, "00", WidthU.Text, HeightU.Text,
                                                //    Lenght.Text, Thikness.Text, TypeOfFrame.Text, FrameOffset.Text);
                                            }
                                            else if (MontageFrame50.IsChecked == true)
                                            {
                                                if (FrameOffset.Visibility == Visibility.Collapsed &
                                                    LenghtBaseFrame.Text != "")
                                                {
                                                    try
                                                    {
                                                        FrameOffset.Text = Convert.ToString((Convert.ToDouble(LenghtBaseFrame.Text)/2));
                                                    }
                                                    catch (Exception)
                                                    {
                                                        FrameOffset.Text = Convert.ToString(150);
                                                    }
                                                }
                                                
                                                sw.MontageFrame(WidthBaseFrame.Text, LenghtBaseFrame.Text, Thikness.Text,
                                                    TypeOfFrame.Text, FrameOffset.Text, MaterialMontageFrame.Text, null);
                                            }
                                            else if (TypeOfUnit50.IsChecked == true)
                                            {

                                            }
                                            else if (Panel50.IsChecked == true)
                                            {
                                                sw.Panels50Build(
                                                    new[] { null, TypeOfPanel50.Text }, 
                                                    WidthPanel.Text, 
                                                    HeightPanel.Text,
                                                    new[] { "Az", null }, 
                                                    new[] { "Az", null }, 
                                                    null);
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            MessageBox.Show(ex.Message);
                                        }
            });
            });
            //Dispatcher.Thread.SetApartmentState(new ApartmentState());
            Dispatcher.InvokeAsync(() =>
            {
                //var sw = new ModelSw();
                //sw.CreateDistDirectory(string.Format(@"{0}\{1}", @Properties.Settings.Default.DestinationFolder,
                //    sw.Unit50Folder));
                //sw.CreateDistDirectory(string.Format(@"{0}\{1}", @Properties.Settings.Default.DestinationFolder,
                //    sw.Panel50DestinationFolder));
                //sw.CreateDistDirectory(string.Format(@"{0}\{1}", @Properties.Settings.Default.DestinationFolder,
                //    sw.BaseFrameDestinationFolder));
            });
        }