public static string GetCommentFromProperties(string faner11, string faner12, string faner21, string faner22, double angle, SwAddin _mSwAddin, ModelDoc2 model) { bool fan11exist = !string.IsNullOrEmpty(faner11) && faner11 != "Нет"; bool fan12exist = !string.IsNullOrEmpty(faner12) && faner12 != "Нет"; bool fan21exist = !string.IsNullOrEmpty(faner21) && faner21 != "Нет"; bool fan22exist = !string.IsNullOrEmpty(faner22) && faner22 != "Нет"; FanersBools fb = new FanersBools(); if (fan11exist) fb = fb | FanersBools.Faner11; if (fan12exist) fb = fb | FanersBools.Faner12; if (fan21exist) fb = fb | FanersBools.Faner21; if (fan22exist) fb = fb | FanersBools.Faner22; #region comment from fb and angle if (Math.Abs(angle) < 0.00001) { switch (fb) { case FanersBools.Faner11: return "KROMKOY K SEBE"; case FanersBools.Faner12: return "KROMKOY OT SEBYA"; case FanersBools.Faner21: return "KROMKOY OT UPORA"; case FanersBools.Faner22: return "KROMKOY K UPORU"; case FanersBools.Faner21 | FanersBools.Faner22: case FanersBools.Faner12 | FanersBools.Faner11: case FanersBools.Faner11 | FanersBools.Faner12 | FanersBools.Faner21 | FanersBools.Faner22: OleDbCommand cm; OleDbDataReader rd; OleDbConnection oleDb; if (!_mSwAddin.OpenModelDatabase(model, out oleDb)) return "Error DB Access!"; cm = new OleDbCommand("SELECT * FROM decors_conf ORDER BY id ", oleDb); rd = cm.ExecuteReader(); rd.Read(); bool? textureDirection = rd["Texture direction"] as bool?; string retresult; if (textureDirection == null || textureDirection == false) retresult= "VOLOKNA GORIZONTALNO"; else retresult= "VOLOKNA VERTIKALNO"; if (faner11 == "N") { retresult = retresult + ", GOLOY K SEBE"; } return retresult; case FanersBools.Faner11 | FanersBools.Faner22: return "KROMKOY K UPORU & K SEBE"; case FanersBools.Faner11 | FanersBools.Faner21: return "KROMKOY OT UPORA & K SEBE"; case FanersBools.Faner12 | FanersBools.Faner22: return "KROMKOY K UPORU & OT SEBYA"; case FanersBools.Faner21 | FanersBools.Faner12: return "KROMKOY OT UPORA & OT SEBYA"; case FanersBools.Faner11 | FanersBools.Faner22 | FanersBools.Faner12: return "GOLOY OT UPORA"; case FanersBools.Faner11 | FanersBools.Faner12 | FanersBools.Faner21: return "GOLOY K UPORU"; case FanersBools.Faner11 | FanersBools.Faner21 | FanersBools.Faner22: return "GOLOY OT SEBYA"; case FanersBools.Faner12 | FanersBools.Faner21 | FanersBools.Faner22: return "GOLOY K SEBE"; default: return fb.ToString(); } } else if (Math.Abs(angle + 90) < 0.00001 || Math.Abs(angle - 270) < 0.00001)// { switch (fb) { case FanersBools.Faner11: return "KROMKOY OT UPORA"; case FanersBools.Faner12: return "KROMKOY K UPORU"; case FanersBools.Faner21: return "KROMKOY OT SEBYA"; case FanersBools.Faner22: return "KROMKOY K SEBE"; case FanersBools.Faner21 | FanersBools.Faner22: case FanersBools.Faner12 | FanersBools.Faner11: case FanersBools.Faner11 | FanersBools.Faner12 | FanersBools.Faner21 | FanersBools.Faner22: OleDbCommand cm; OleDbDataReader rd; OleDbConnection oleDb; if (!_mSwAddin.OpenModelDatabase(model, out oleDb)) return "Error DB Access!"; cm = new OleDbCommand("SELECT * FROM decors_conf ORDER BY id ", oleDb); rd = cm.ExecuteReader(); rd.Read(); bool? textureDirection = rd["Texture direction"] as bool?; string retresult; if (textureDirection == null || textureDirection == false) retresult= "VOLOKNA VERTIKALNO"; else retresult= "VOLOKNA GORIZONTALNO"; if (faner11 == "N") { retresult = retresult + ", GOLOY K SEBE"; } return retresult; case FanersBools.Faner11 | FanersBools.Faner22: return "KROMKOY OT UPORA & K SEBE"; case FanersBools.Faner11 | FanersBools.Faner21: return "KROMKOY OT UPORA & OT SEBYA"; case FanersBools.Faner12 | FanersBools.Faner22: return "KROMKOY K UPORU & K SEBE"; case FanersBools.Faner21 | FanersBools.Faner12: return "KROMKOY K UPORU & OT SEBYA"; case FanersBools.Faner11 | FanersBools.Faner22 | FanersBools.Faner12: return "GOLOY OT SEBYA"; case FanersBools.Faner11 | FanersBools.Faner12 | FanersBools.Faner21: return "GOLOY K SEBE"; case FanersBools.Faner11 | FanersBools.Faner21 | FanersBools.Faner22: return "GOLOY K UPORU"; case FanersBools.Faner12 | FanersBools.Faner21 | FanersBools.Faner22: return "GOLOY OT UPORA"; default: return fb.ToString(); } } else if (Math.Abs(angle - 180) < 0.00001 || Math.Abs(angle + 180) < 0.00001) { switch (fb) { case FanersBools.Faner11: return "KROMKOY OT SEBYA"; case FanersBools.Faner12: return "KROMKOY K SEBE"; case FanersBools.Faner21: return "KROMKOY K UPORU"; case FanersBools.Faner22: return "KROMKOY OT UPORA"; case FanersBools.Faner21 | FanersBools.Faner22: case FanersBools.Faner12 | FanersBools.Faner11: case FanersBools.Faner11 | FanersBools.Faner12 | FanersBools.Faner21 | FanersBools.Faner22: OleDbCommand cm; OleDbDataReader rd; OleDbConnection oleDb; if (!_mSwAddin.OpenModelDatabase(model, out oleDb)) return "Error DB Access!"; cm = new OleDbCommand("SELECT * FROM decors_conf ORDER BY id ", oleDb); rd = cm.ExecuteReader(); rd.Read(); bool? textureDirection = rd["Texture direction"] as bool?; string retresult; if (textureDirection == null || textureDirection == false) retresult= "VOLOKNA GORIZONTALNO"; else retresult= "VOLOKNA VERTIKALNO"; if (faner11 == "N") { retresult = retresult + ", GOLOY K SEBE"; } return retresult; case FanersBools.Faner11 | FanersBools.Faner22: return "KROMKOY OT UPORA & OT SEBYA"; case FanersBools.Faner11 | FanersBools.Faner21: return "KROMKOY K UPORU & OT SEBYA"; case FanersBools.Faner12 | FanersBools.Faner22: return "KROMKOY OT UPORA & K SEBE"; case FanersBools.Faner21 | FanersBools.Faner12: return "KROMKOY K UPORU & K SEBE"; case FanersBools.Faner11 | FanersBools.Faner22 | FanersBools.Faner12: return "GOLOY K UPORU"; case FanersBools.Faner11 | FanersBools.Faner12 | FanersBools.Faner21: return "GOLOY OT UPORA"; case FanersBools.Faner11 | FanersBools.Faner21 | FanersBools.Faner22: return "GOLOY K SEBE"; case FanersBools.Faner12 | FanersBools.Faner21 | FanersBools.Faner22: return "GOLOY OT SEBYA"; default: return fb.ToString(); } } else if (Math.Abs(angle - 90) < 0.00001) { switch (fb) { case FanersBools.Faner11: return "KROMKOY K UPORU"; case FanersBools.Faner12: return "KROMKOY OT UPORA"; case FanersBools.Faner21: return "KROMKOY K SEBE"; case FanersBools.Faner22: return "KROMKOY OT SEBYA"; case FanersBools.Faner21 | FanersBools.Faner22: case FanersBools.Faner12 | FanersBools.Faner11: case FanersBools.Faner11 | FanersBools.Faner12 | FanersBools.Faner21 | FanersBools.Faner22: OleDbCommand cm; OleDbDataReader rd; OleDbConnection oleDb; if (!_mSwAddin.OpenModelDatabase(model, out oleDb)) return "Error DB Access!"; cm = new OleDbCommand("SELECT * FROM decors_conf ORDER BY id ", oleDb); rd = cm.ExecuteReader(); rd.Read(); bool? textureDirection = rd["Texture direction"] as bool?; string retresult; if (textureDirection == null || textureDirection == false) retresult= "VOLOKNA VERTIKALNO"; else retresult= "VOLOKNA GORIZONTALNO"; if (faner11 == "N") { retresult = retresult + ", GOLOY K SEBE"; } return retresult; case FanersBools.Faner11 | FanersBools.Faner22: return "KROMKOY K UPORU & OT SEBYA"; case FanersBools.Faner11 | FanersBools.Faner21: return "KROMKOY K UPORU & K SEBE"; case FanersBools.Faner12 | FanersBools.Faner22: return "KROMKOY OT UPORA & OT SEBYA"; case FanersBools.Faner21 | FanersBools.Faner12: return "KROMKOY OT UPORA & K SEBE"; case FanersBools.Faner11 | FanersBools.Faner22 | FanersBools.Faner12: return "GOLOY K SEBE"; case FanersBools.Faner11 | FanersBools.Faner12 | FanersBools.Faner21: return "GOLOY OT SEBYA"; case FanersBools.Faner11 | FanersBools.Faner21 | FanersBools.Faner22: return "GOLOY OT UPORA"; case FanersBools.Faner12 | FanersBools.Faner21 | FanersBools.Faner22: return "GOLOY K UPORU"; default: return fb.ToString(); } } else return "angle ne kraten 90"; #endregion }
public static string GetComment(ModelDoc2 model, double angle, SwAddin _mSwAddin) { //Считать по тому, подавлены они физически или нет. Если Есть св-во Faner11 а тела нет или подавлено то записать в свойство пустую строку //если наоборот Тело есть а Faner11 -нет или пустое, то записать туда H или DefaultValue Component2 _swSelectedComponent =model.ConfigurationManager.ActiveConfiguration.GetRootComponent3(true); OleDbCommand cm; OleDbDataReader rd; OleDbConnection oleDb; if (!_mSwAddin.OpenModelDatabase(model, out oleDb)) return "Error DB Access!"; cm = new OleDbCommand("SELECT * FROM faners ORDER BY FanerName ", oleDb); rd = cm.ExecuteReader(); List<Faner> faners = new List<Faner>(); while (rd.Read()) { if (rd["FanerType"] as string != null) { faners.Add(new Faner((string)rd["FanerName"], (string)rd["FanerType"], (string)rd["DecorGroup"])); } else { faners.Add(new Faner((string)rd["FanerName"], string.Empty, (string)rd["DecorGroup"])); } } rd.Close(); FanersBools fb = new FanersBools(); Feature feature; foreach (var faner in faners) { switch (faner.FanerName.Substring(faner.FanerName.Length - 2, 2)) { case "11": feature = FindEdge(_swSelectedComponent, faner.AxFanerName); if (feature != null) { if (!feature.IsSuppressed()) fb = fb | FanersBools.Faner11; } break; case "12": feature = FindEdge(_swSelectedComponent, faner.AxFanerName); if (feature != null) { if (!feature.IsSuppressed()) fb = fb | FanersBools.Faner12; } break; case "21": feature = FindEdge(_swSelectedComponent, faner.AxFanerName); if (feature != null) { if (!feature.IsSuppressed()) fb = fb | FanersBools.Faner21; } break; case "22": feature = FindEdge(_swSelectedComponent, faner.AxFanerName); if (feature != null) { if (!feature.IsSuppressed()) fb = fb | FanersBools.Faner22; } break; } } if (angle == 0) { switch (fb) { case FanersBools.Faner11: return "KROMKOY K SEBE"; case FanersBools.Faner12: return "KROMKOY OT SEBYA"; case FanersBools.Faner21: return "KROMKOY OT UPORA"; case FanersBools.Faner22: return "KROMKOY K UPORU"; case FanersBools.Faner21 | FanersBools.Faner22: case FanersBools.Faner12 | FanersBools.Faner11: case FanersBools.Faner11 | FanersBools.Faner12 | FanersBools.Faner21 | FanersBools.Faner22: cm = new OleDbCommand("SELECT * FROM decors_conf ORDER BY id ", oleDb); rd = cm.ExecuteReader(); rd.Read(); bool? textureDirection = rd["Texture direction"] as bool?; if (textureDirection == null || textureDirection == false) return "VOLOKNA GORIZONTALNO"; else return "VOLOKNA VERTIKALNO"; case FanersBools.Faner11 | FanersBools.Faner22: return "KROMKOY K UPORU & K SEBE"; case FanersBools.Faner11 | FanersBools.Faner21: return "KROMKOY OT UPORA & K SEBE"; case FanersBools.Faner12 | FanersBools.Faner22: return "KROMKOY K UPORU & OT SEBYA"; case FanersBools.Faner21 | FanersBools.Faner12: return "KROMKOY OT UPORA & OT SEBYA"; case FanersBools.Faner11 | FanersBools.Faner22 | FanersBools.Faner12: return "GOLOY OT UPORA"; case FanersBools.Faner11 | FanersBools.Faner12 | FanersBools.Faner21: return "GOLOY K UPORU"; case FanersBools.Faner11 | FanersBools.Faner21 | FanersBools.Faner22: return "GOLOY OT SEBYA"; case FanersBools.Faner12 | FanersBools.Faner21 | FanersBools.Faner22: return "GOLOY K SEBE"; default: return fb.ToString(); } } else return "angle!=0"; }