Exemplo n.º 1
0
        /// <summary>
        /// Save dxf file by to provided path;
        /// </summary>
        public bool SaveDxfToFile(String filePath, ProfilesFamily selFamily,
                                  List <ProfileItem> profileItem, ViewOptions viewOption)
        {
            if (!IsFamilyHasDxfDrawer(selFamily))
            {
                #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "!IsFamilyHasDxfDrawer(selFamily)");
                #endif
                return(false);
            }
            if ((profileItem == null) || (profileItem.Count == 0))
            {
                #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "((profileItem == null) || (profileItem.Count == 0))");
                #endif
                return(false);
            }

            if (filePath.Length < 2)
            {
                #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "filePath.Length < 2");
                #endif
                return(false);
            }

            String dxfBody = genDxfBody(selFamily.profileDrawerId, viewOption, profileItem);
            if (dxfBody.Length == 0)
            {
                #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "dxfBody.Length == 0");
                #endif
                return(false);
            }

            try
            {
                StreamWriter outputFile = new StreamWriter(filePath);
                outputFile.WriteLine(dxfBody);
                outputFile.Close();
            }
            catch (IOException e)
            {
                #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "IOException : " + e.Message.ToString());
                #endif
                return(false);
            }
            return(true);
        }
Exemplo n.º 2
0
        public void GetprofilesImage(System.Windows.Controls.Image image, ProfilesFamily selectedFamily)
        {
            if (DBConnection == null)
            {
                #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "DBConnection == null");
                #endif
                return;
            }
            image.Source = null;

            if (selectedFamily == null)
            {
                #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "selectedProfile == null");
                #endif
                return;
            }

            if (selectedFamily.profileImageId == 0)
            {
                #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "selectedFamily.profileImageId == 0");
                #endif
                return;
            }

            SQLiteCommand sqlcmd = DBConnection.CreateCommand();
            sqlcmd.CommandText = "SELECT * FROM TIMAGE WHERE id=" + selectedFamily.profileImageId.ToString() + " LIMIT 1";
            try
            {
                SQLiteDataReader dataReader = sqlcmd.ExecuteReader();
                if (dataReader.Read())
                {
                    image.Source = LoadImage((byte[])dataReader["imagedata"]);
                }
            }
            catch (SQLiteException e)
            {
                #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "SQL Error: " + e.Message.ToString());
                #endif
            }
        }
Exemplo n.º 3
0
 private void FamilyCBChange(object sender, SelectionChangedEventArgs e)
 {
     #if DEBUG
     Log.Notice(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name);
     #endif
     ComboBox       cmb          = sender as ComboBox;
     ProfilesFamily ActiveFamily = cmb?.SelectedItem as ProfilesFamily;
     MVC.LoadProfilesList(ActiveFamily);
     if (profilesCB.Items.Count > 0)
     {
         profilesCB.SelectedIndex = 0;
     }
     MVC.LoadImage(ActiveFamily, imageSection);
     DxfGB.IsEnabled   = MVC.HasDXFDrawer(cmb.SelectedItem as ProfilesFamily);
     familiDescTB.Text = ActiveFamily?.descryption ?? "";
 }
Exemplo n.º 4
0
        public void GetProfilesList(ObservableCollection <Profiles> profilesList, ProfilesFamily selectedFamily)
        {
            if (DBConnection == null)
            {
                #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "DBConnection == null");
                #endif
                return;
            }

            profilesList.Clear();
            if (selectedFamily == null)
            {
                #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "selectedFamily == null");
                #endif
                return;
            }

            SQLiteCommand sqlcmd = DBConnection.CreateCommand();
            sqlcmd.CommandText = "SELECT * FROM TPROFILES WHERE familyid=" + selectedFamily.id.ToString();
            try
            {
                SQLiteDataReader dataReader = sqlcmd.ExecuteReader();
                while (dataReader.Read())
                {
                    profilesList.Add(new Profiles(Convert.ToInt32(dataReader["id"]), Convert.ToInt32(dataReader["familyid"]),
                                                  Convert.ToString(dataReader["profilename"])));
                }
            }
            catch (SQLiteException e)
            {
                #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "SQL Error: " + e.Message.ToString());
                #endif

                profilesList.Clear();
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Check is family has dxf drawer
 /// </summary>
 public bool IsFamilyHasDxfDrawer(ProfilesFamily checkedFamily)
 {
     if (checkedFamily == null)
     {
         #if DEBUG
         Log.Warning(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                     "checkedFamily == null");
         #endif
         return(false);
     }
     bool result = false;
     if (checkedFamily.profileDrawerId > 0)
     {
         result = true;
     }
     #if DEBUG
     Log.Notice(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                "profileDrawerId=" + checkedFamily.profileDrawerId.ToString() + " is " + result.ToString());
     #endif
     return(result);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Open DXF File
        /// </summary>
        public void OpenDXFFile(Profiles selectedProfile, bool frontViewP,
                                bool topViewP, bool sideViewP)
        {
            #if DEBUG
            Log.Notice(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name);
            #endif

            if (selectedProfile == null)
            {
                #if DEBUG
                Log.Warning(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                            "selectedProfile == null");
                #endif
                return;
            }

            ProfilesFamily profileFamily = null;
            foreach (ProfilesFamily family in familyList)
            {
                if (family.id == selectedProfile.profileFamilyId)
                {
                    profileFamily = family;
                }
            }

            if (profileFamily == null)
            {
                #if DEBUG
                Log.Warning(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                            "profileFamily == null");
                #endif
                return;
            }

            if (!D3D.IsFamilyHasDxfDrawer(profileFamily))
            {
                #if DEBUG
                Log.Warning(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                            "!D3D.IsFamilyHasDxfDrawer(profileFamily)");
                #endif
                return;
            }

            String tempPath = Path.GetTempPath() + selectedProfile.profileName + "_" + GKCommon.GetUniqueKey(4).ToLower() +
                              "_" + Controller.DXFFileExt;

            if (!D3D.SaveDxfToFile(tempPath, profileFamily, new List <ProfileItem>(listViewData.ToList()),
                                   new ViewOptions()
            {
                topView = topViewP, frontView = frontViewP, sideView = sideViewP
            }))
            {
                #if DEBUG
                Log.Warning(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                            "!D3D.SaveDxfToFile");
                #endif
                return;
            }
            try
            {
                System.Diagnostics.Process.Start(tempPath);
            }
            catch (ObjectDisposedException e)
            {
                #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "ObjectDisposedException : " + e.Message.ToString());
                #endif
            }
            catch (FileNotFoundException e)
            {
            #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "FileNotFoundException : " + e.Message.ToString());
            #endif
            }
            catch (System.ComponentModel.Win32Exception e)
            {
                #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "System.ComponentModel.Win32Exception : " + e.Message.ToString());
                #endif
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Load profiles image from DB in to image
 /// </summary>
 public void LoadImage(ProfilesFamily selectedFamily, System.Windows.Controls.Image image)
 {
     DB.GetprofilesImage(image, selectedFamily);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Load profiles list from DB in to Controller.profilesList
 /// </summary>
 public void LoadProfilesList(ProfilesFamily selectedFamily)
 {
     DB.GetProfilesList(profilesList, selectedFamily);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Is Profiles family has DXF Draawer
 /// </summary>
 public bool HasDXFDrawer(ProfilesFamily checkedFamily)
 {
     return(D3D.IsFamilyHasDxfDrawer(checkedFamily));
 }
Exemplo n.º 10
0
        /// <summary>
        /// Save DXF File
        /// </summary>
        public void SaveDXFFile(Profiles selectedProfile, bool frontViewP,
                                bool topViewP, bool sideViewP)
        {
            #if DEBUG
            Log.Notice(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name);
            #endif

            if (selectedProfile == null)
            {
            #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "selectedProfile == null");
            #endif
                return;
            }

            ProfilesFamily profileFamily = null;
            foreach (ProfilesFamily family in familyList)
            {
                if (family.id == selectedProfile.profileFamilyId)
                {
                    profileFamily = family;
                }
            }

            if (profileFamily == null)
            {
            #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "profileFamily == null");
            #endif
                return;
            }

            if (!D3D.IsFamilyHasDxfDrawer(profileFamily))
            {
            #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "!D3D.IsFamilyHasDxfDrawer(profileFamily)");
            #endif
                return;
            }

            SaveFileDialog savefile = new SaveFileDialog
            {
                FileName = selectedProfile.profileName + Controller.DXFFileExt,
                Filter   = "DXF Files|*" + Controller.DXFFileExt
            };

            if (savefile.ShowDialog() == false)
            {
                #if DEBUG
                Log.Notice(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                           "User canceled save dialog");
                #endif
                return;
            }

            if (!D3D.SaveDxfToFile(savefile.FileName, profileFamily, new List <ProfileItem>(listViewData.ToList()),
                                   new ViewOptions()
            {
                topView = topViewP, frontView = frontViewP, sideView = sideViewP
            }))
            {
                #if DEBUG
                Log.Warning(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                            "!D3D.SaveDxfToFile");
                #endif
                return;
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// Check is family has dxf drawer
 /// </summary>
 public bool IsFamilyHas3DView(ProfilesFamily checkedFamily)
 {
     return(false);
 }