예제 #1
0
파일: Main.cs 프로젝트: vehar/AltiumSharp
 private void ShowPropertyViewer()
 {
     if (_propertyViewer == null)
     {
         _propertyViewer             = new PropertyViewer();
         _propertyViewer.Owner       = this;
         _propertyViewer.FormClosed += (s, a) => _propertyViewer = null;
         _propertyViewer.Show(this);
     }
     _propertyViewer.SetSelectedObjects(_activePrimitives.ToArray());
     _propertyViewer.BringToFront();
     _propertyViewer.Focus();
 }
예제 #2
0
 private void ShowPropertyViewer(object[] items)
 {
     if (_propertyViewer == null)
     {
         _propertyViewer             = new PropertyViewer();
         _propertyViewer.Owner       = this;
         _propertyViewer.FormClosed += (s, a) => _propertyViewer = null;
         _propertyViewer.Changed    += (s, a) => UpdateUi(false);
         _propertyViewer.Show(this);
     }
     _propertyViewer.SetSelectedObjects(items);
     _propertyViewer.BringToFront();
     _propertyViewer.Focus();
 }
예제 #3
0
파일: Main.cs 프로젝트: vehar/AltiumSharp
        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;
            }
        }
예제 #4
0
        private void SetData(object fileData)
        {
            var saveLoading = _loading;

            _loading = true;
            try
            {
                SetActiveContainer(null);
                if (_propertyViewer != null)
                {
                    _propertyViewer.Close();
                    _propertyViewer = null;
                }

                IContainer container = null;

                gridPcbLibComponents.Rows.Clear();
                gridSchLibComponents.Rows.Clear();
                treeViewStructure.Nodes.Clear();
                Application.DoEvents();

                if (fileData is PcbLib pcbLib)
                {
                    tabComponents.SelectTab(tabPcbLib);

                    foreach (var component in pcbLib.Items)
                    {
                        var index = gridPcbLibComponents.Rows.Add(component.Pattern, component.Pads, component.Primitives.Count());
                        gridPcbLibComponents.Rows[index].Tag = component;
                    }

                    _displayUnit  = pcbLib.Header.DisplayUnit;
                    _snapGridSize = pcbLib.Header.SnapGridSize;
                    _renderer     = new PcbLibRenderer();
                    container     = pcbLib.Items.OfType <IContainer>().FirstOrDefault();
                }
                else if (fileData is SchLib schLib)
                {
                    tabComponents.SelectTab(tabSchLib);

                    foreach (var component in schLib.Items)
                    {
                        var index = gridSchLibComponents.Rows.Add(component.LibReference, component.ComponentDescription);
                        gridSchLibComponents.Rows[index].Tag = component;
                    }

                    _displayUnit  = schLib.Header.DisplayUnit;
                    _snapGridSize = schLib.Header.SnapGridSize;
                    _renderer     = new SchLibRenderer(schLib.Header, GetAssetsSchLib());
                    container     = schLib.Items.OfType <IContainer>().FirstOrDefault();
                }
                else if (fileData is SchDoc schDoc)
                {
                    tabComponents.SelectTab(tabSchLib);

                    var index = gridSchLibComponents.Rows.Add("SchDoc");
                    gridSchLibComponents.Rows[index].Tag = schDoc.Header;
                    foreach (var component in schDoc.Header.GetPrimitivesOfType <SchComponent>())
                    {
                        index = gridSchLibComponents.Rows.Add(component.LibReference, component.ComponentDescription);
                        gridSchLibComponents.Rows[index].Tag = component;
                    }

                    var sheet = schDoc.Header;
                    _displayUnit  = sheet.DisplayUnit;
                    _snapGridSize = sheet.SnapGridSize;
                    _renderer     = new SchLibRenderer(schDoc.Header, GetAssetsSchLib());
                    container     = schDoc.Items.OfType <IContainer>().FirstOrDefault();
                }

                _fileData = fileData;
                SetActiveContainer(container);
            }
            finally
            {
                _loading = saveLoading;
            }
        }