private void LoadFromFile(string fileName) { if (Path.GetExtension(fileName).Equals(".pcblib", StringComparison.InvariantCultureIgnoreCase)) { using (var reader = new PcbLibReader()) { var data = reader.Read(fileName); SetData(data); } } else if (Path.GetExtension(fileName).Equals(".schlib", StringComparison.InvariantCultureIgnoreCase)) { using (var reader = new SchLibReader()) { var data = reader.Read(fileName); SetData(data); } } else if (Path.GetExtension(fileName).Equals(".schdoc", StringComparison.InvariantCultureIgnoreCase)) { using (var reader = new SchDocReader()) { var data = reader.Read(fileName); SetData(data); } } }
private void LoadComponents(string fileName) { _loading = true; try { SetActiveComponent(null); if (_propertyViewer != null) { _propertyViewer.Close(); _propertyViewer = null; } gridPcbLibComponents.Rows.Clear(); gridSchLibComponents.Rows.Clear(); Application.DoEvents(); if (Path.GetExtension(fileName).Equals(".pcblib", StringComparison.InvariantCultureIgnoreCase)) { tabComponents.SelectTab(tabPcbLib); using (var reader = new PcbLibReader(fileName)) { reader.Read(); foreach (var component in reader.Components) { var index = gridPcbLibComponents.Rows.Add(component.Name, component.Pads, component.Primitives.Count()); gridPcbLibComponents.Rows[index].Tag = component; } _displayUnit = reader.Header.DisplayUnit; _snapGridSize = reader.Header.SnapGridSize; _components = reader.Components.Cast <IComponent>().ToList(); _renderer = new PcbLibRenderer(); } } else if (Path.GetExtension(fileName).Equals(".schlib", StringComparison.InvariantCultureIgnoreCase)) { tabComponents.SelectTab(tabSchLib); using (var reader = new SchLibReader(fileName)) { reader.Read(); foreach (var component in reader.Components) { var index = gridSchLibComponents.Rows.Add(component.Name, component.Description); gridSchLibComponents.Rows[index].Tag = component; } _displayUnit = reader.Header.DisplayUnit; _snapGridSize = reader.Header.SnapGridSize; _components = reader.Components.Cast <IComponent>().ToList(); _renderer = new SchLibRenderer(reader.Header, reader.EmbeddedImages); } } SetActiveComponent(_components.FirstOrDefault()); } finally { _loading = false; } }