public void SortDescendingOnName()
 {
     var comparer = new ConnectionInfoComparer<string>(node => node.Name)
     {
         SortDirection = ListSortDirection.Descending
     };
     var compareReturn = comparer.Compare(_con1, _con2);
     Assert.That(compareReturn, Is.Positive);
 }
        public void SortDescendingOnName()
        {
            var comparer = new ConnectionInfoComparer <string>(node => node.Name)
            {
                SortDirection = ListSortDirection.Descending
            };
            var compareReturn = comparer.Compare(_con1, _con2);

            Assert.That(compareReturn, Is.Positive);
        }
Beispiel #3
0
        public void SortOn <TProperty>(Func <ConnectionInfo, TProperty> propertyToCompare, ListSortDirection sortDirection = ListSortDirection.Ascending)
            where TProperty : IComparable <TProperty>
        {
            var connectionComparer = new ConnectionInfoComparer <TProperty>(propertyToCompare)
            {
                SortDirection = sortDirection
            };

            Children.Sort(connectionComparer);
            RaiseCollectionChangedEvent(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
        }
        private void Start(ScriptType scriptType)
        {
            UI.Cursor = System.Windows.Input.Cursors.Wait;
            Settings settings = new Settings();
            settings.electricSchemeTypeCode = 0;
            settings.firstPageFormat = "Формат А3 лист 1";
            settings.firstPageHeaderLineX = 0;
            settings.firstPageHeaderLineY = -12;
            settings.firstPageUttermostPositionY = -225;
            settings.subsequentPageFormat = "Формат А3_каб.журнал";
            settings.subsequentPageHeaderLineX = 0;
            settings.subsequentPageHeaderLineY = 287;
            settings.subsequentPageUttermostPositionY = 20;
            settings.lineFont = new E3Font();
            settings.headerFont = new E3Font(height: 3.5);
            settings.separatingSymbols = "?!.:, -";
            settings.verticalLineWidth = 0.5;
            settings.horizontalLineWidth = 0.2;
            settings.headerVerticalLineWidth = 0.5;
            settings.headerHorizontalLineWidth = 0.5;
            settings.bottomLineWidth = 0.5;
            settings.sheetTypeAttribute = "marka2";
            SaveSettings(settings);

            E3Project project = new E3Project(applicationInfo.ProcessId);
            Sheet sheet = project.GetSheetById(0);

            List<ConnectionInfo> connectionInfos;

            if (scriptType == ScriptType.ByConnections)
                connectionInfos = GetConnectionInfosByConnections(project, sheet, settings.electricSchemeTypeCode);
            else
                connectionInfos = GetConnectionInfosByCoresAndWires(project);

            connectionInfos.RemoveAll(ci => ci.assignmentFrom != ci.assignmentTo || String.IsNullOrEmpty(ci.assignmentFrom)); // удаляем все соединения, не идущие внутри одного шкафа
            ConnectionInfoComparer comparer = new ConnectionInfoComparer();
            connectionInfos.Sort(comparer);

            StringSeparator separator = new StringSeparator(settings.separatingSymbols.ToCharArray(), settings.lineFont, project.GetTextById(0));
            LineTemplate lineTemplate = new LineTemplate(new List<double>() { 35, 45, 45, 45, 45, 45, 45, 45, 45 }, settings.lineFont, 8, settings.verticalLineWidth, settings.horizontalLineWidth);
            LineTemplate headerLineTemplate = new LineTemplate(new List<double>() { 35, 45, 45, 45, 45, 45, 45, 45, 45 }, settings.headerFont, 8, settings.headerVerticalLineWidth, settings.headerHorizontalLineWidth);
            List<string> headerColumnNames = new List<string>(9){"Имя цепи", "От \"Места\"", "От \"Поз. обозначения\"", "От \"Вывода\"", "К \"Месту\"", "К \"Поз. обозначению\"", "К \"Выводу\"", "Тип провода", "Примечание"};
            Dictionary<string, Table> assignmentTables = new Dictionary<string, Table>();
            foreach (ConnectionInfo info in connectionInfos)
            {
                if (!assignmentTables.ContainsKey(info.assignmentFrom))
                {
                    HeaderText headerText = new HeaderText("Таблица соединений шкафа "+info.assignmentFrom, settings.headerFont, settings.headerFont.height + 1);
                    TablePageTemplate firstPageTemplate = new TablePageTemplate(settings.firstPageFormat, settings.firstPageHeaderLineX, settings.firstPageHeaderLineY, settings.firstPageUttermostPositionY, headerText);
                    TablePageTemplate subsequentPageTemplate = new TablePageTemplate(settings.subsequentPageFormat, settings.subsequentPageHeaderLineX, settings.subsequentPageHeaderLineY, settings.subsequentPageUttermostPositionY);
                    assignmentTables.Add(info.assignmentFrom, new Table(project, headerLineTemplate, headerColumnNames, lineTemplate, settings.bottomLineWidth, separator, firstPageTemplate, subsequentPageTemplate));
                }
                assignmentTables[info.assignmentFrom].AddLine(new List<string>(8) { info.signal, info.locationFrom, info.deviceFrom, info.pinFrom, info.locationTo, info.deviceTo, info.pinTo, info.type });
            }
            foreach (string key in assignmentTables.Keys)
            {
                assignmentTables[key].AddFinalGraphicLine();
                foreach (int id in assignmentTables[key].SheetIds)
                {
                    sheet.Id = id;
                    sheet.SetAttribute(settings.sheetTypeAttribute, key);
                }
            }
            project.Release();
            UI.Cursor = System.Windows.Input.Cursors.Arrow;
        }