public FrmPipeBuildStyle(PipeBuildStyleClass pbsc)
 {
     InitializeComponent();
     this._style       = pbsc;
     this._edit        = true;
     this.Text         = "编辑-构筑物风格";
     this.btnSave.Text = "保存";
 }
 public FrmPipeBuildStyle()
 {
     InitializeComponent();
     this._style       = new PipeBuildStyleClass();
     this._edit        = false;
     this.Text         = "创建-构筑物风格";
     this.btnSave.Text = "创建";
 }
        public static List <FacStyleClass> GetFacStyleByFacClassCode(string fcCode)
        {
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

            try
            {
                IFeatureDataSet fds = DF3DPipeCreateApp.App.TemplateLib.OpenFeatureDataset("DataSet_BIZ");
                if (fds == null)
                {
                    return(null);
                }
                IObjectClass oc = fds.OpenObjectClass("OC_FacilityStyle");
                if (oc == null)
                {
                    return(null);
                }

                IQueryFilter filter = new QueryFilterClass
                {
                    WhereClause = string.Format("FacClassCode = '{0}'", fcCode)
                };
                cursor = oc.Search(filter, true);
                List <FacStyleClass> list = new List <FacStyleClass>();
                while ((row = cursor.NextRow()) != null)
                {
                    StyleType     type;
                    FacStyleClass fs = null;
                    if (row.FieldIndex("StyleType") >= 0 && Enum.TryParse <StyleType>(row.GetValue(row.FieldIndex("StyleType")).ToString(), out type))
                    {
                        Dictionary <string, string> dictionary = null;
                        if (row.FieldIndex("StyleInfo") >= 0)
                        {
                            object obj = row.GetValue(row.FieldIndex("StyleInfo"));
                            if (obj != null)
                            {
                                IBinaryBuffer buffer2 = row.GetValue(row.FieldIndex("StyleInfo")) as IBinaryBuffer;
                                if (buffer2 != null)
                                {
                                    dictionary = JsonTool.JsonToObject <Dictionary <string, string> >(Encoding.UTF8.GetString(buffer2.AsByteArray()));
                                }
                            }
                        }
                        switch (type)
                        {
                        case StyleType.PipeNodeStyle:
                            fs = new PipeNodeStyleClass(dictionary);
                            break;

                        case StyleType.PipeLineStyle:
                            fs = new PipeLineStyleClass(dictionary);
                            break;

                        case StyleType.PipeBuildStyle:
                            fs = new PipeBuildStyleClass(dictionary);
                            break;
                        }
                    }
                    if (fs == null)
                    {
                        continue;
                    }
                    if (row.FieldIndex("oid") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("oid"));
                        if (obj != null)
                        {
                            fs.Id = int.Parse(obj.ToString());
                        }
                    }
                    if (row.FieldIndex("ObjectId") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("ObjectId"));
                        if (obj != null)
                        {
                            fs.ObjectId = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("FacClassCode") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("FacClassCode"));
                        if (obj != null)
                        {
                            fs.FacClassCode = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("Name") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("Name"));
                        if (obj != null)
                        {
                            fs.Name = obj.ToString();
                        }
                    }
                    int index = row.FieldIndex("Thumbnail");
                    if (index != -1 && !row.IsNull(index))
                    {
                        IBinaryBuffer b = row.GetValue(index) as IBinaryBuffer;
                        if (row != null)
                        {
                            MemoryStream stream = new MemoryStream(b.AsByteArray());
                            fs.Thumbnail = Image.FromStream(stream);
                        }
                    }
                    list.Add(fs);
                }
                return(list);
            }
            catch (Exception exception)
            {
                return(null);
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (row != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                    row = null;
                }
            }
        }