Esempio n. 1
0
        public void AddTab(object tabId = null, string tabText = null, Bitmap icon = null, object tag = null, bool?insertToTheLeft = null, bool select = true)
        {
            lock (_syncRoot)
            {
                tabText = tabText ?? GetDefaultText(Count);
                var tabIcon = icon ?? DefaultIcon;
                int width   = getTabWidth(tabText, tabIcon, CloseIcon);

                TabIds.Add(tabId);
                Texts.Add(tabText);
                Icons.Add(tabIcon);
                Widths.Add(width);
                Tags.Add(tag);
            }

            OnLayout(new LayoutEventArgs(this, null));
            Invalidate();

            int index = Count - 1;

            TabAdded?.Invoke(this, index);

            if (select)
            {
                SelectedIndex = index;
            }

            if ((insertToTheLeft ?? AddNewTabsToTheLeft) && index != 0)
            {
                RelocateTab(index, 0, selectRelocated: select);
            }
        }
Esempio n. 2
0
        public void RelocateTab(int fromIndex, int toIndex, bool selectRelocated)
        {
            object selectedId = TabIds[SelectedIndex];

            if (fromIndex != toIndex && toIndex >= 0 && toIndex < Count)
            {
                lock (_syncRoot)
                {
                    Texts  = Texts.Reorder(fromIndex, toIndex);
                    TabIds = TabIds.Reorder(fromIndex, toIndex);
                    Widths = Widths.Reorder(fromIndex, toIndex);
                    Icons  = Icons.Reorder(fromIndex, toIndex);
                    Tags   = Tags.Reorder(fromIndex, toIndex);
                }
            }

            if (selectRelocated)
            {
                SelectedIndex = toIndex;
            }
            else
            {
                SelectedIndex = TabIds.IndexOf(selectedId);
            }

            TabReordered?.Invoke(this);
        }
Esempio n. 3
0
        public IEnumerable <DocumentTable> GetTables()
        {
            var table = new PdfPTable(3)
            {
                WidthPercentage = 100
            };

            table.SetWidths(Widths.Split(',').Select(int.Parse).ToArray());

            table.DefaultCell.BackgroundColor = new GrayColor(0.9f);
            table.DefaultCell.SetLeading(15, 0);
            table.DefaultCell.Padding = 5.0f;

            var titles = Titles.Split(',');

            table.AddCell(new Phrase(titles[0], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[1], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[2], PdfFonts.Bold));

            table.HeaderRows = 1;
            table.DefaultCell.BackgroundColor = BaseColor.WHITE;

            foreach (var rel in GetAllSafety())
            {
                table.AddCell(new Phrase(rel.Safety.Description, PdfFonts.Normal));
                table.AddCell(new Phrase(rel.Location, PdfFonts.Normal));

                if (rel.Safety.Image != null)
                {
                    var fullName = string.Format(@"{0}\{1}", RootDirectory, rel.Safety.Image.Path);

                    try
                    {
                        var image = Image.GetInstance(fullName);
                        image.ScaleToFit(Math.Min(150, image.Width), Math.Min(150, image.Height));

                        var cell = new PdfPCell(image)
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER,
                            VerticalAlignment   = Element.ALIGN_MIDDLE,
                            Padding             = 5.0f
                        };

                        table.AddCell(cell);
                    }
                    catch
                    {
                        table.AddCell(new Phrase("BILDET " + fullName + " IKKE FUNNET!"));
                    }
                }
                else
                {
                    table.AddCell("");
                }
            }

            return(new List <DocumentTable> {
                new DocumentTable("", table)
            });
        }
Esempio n. 4
0
        public void RemoveTab(int index)
        {
            TabRemoving?.Invoke(this, index);

            lock (_syncRoot)
            {
                Texts.RemoveAt(index);
                TabIds.RemoveAt(index);
                Widths.RemoveAt(index);
                Icons.RemoveAt(index);
                Tags.RemoveAt(index);

                var selectedIndex = SelectedIndex >= index
                                        ? SelectedIndex - 1
                                        : SelectedIndex;

                selectedIndex = getValidIndex(selectedIndex);
                setSelectedIndex(selectedIndex);
            }

            OnLayout(new LayoutEventArgs(this, null));
            Invalidate();

            TabRemoved?.Invoke(this);
        }
Esempio n. 5
0
 internal override void parse(string str, ref int pos, ReleaseVersion release, int len, ConcurrentDictionary <int, BaseClassIfc> dictionary)
 {
     base.parse(str, ref pos, release, len, dictionary);
     HorizontalWidths = ParserSTEP.StripBool(str, ref pos, len);
     Widths.AddRange(ParserSTEP.StripListDouble(str, ref pos, len));
     Slopes.AddRange(ParserSTEP.StripListDouble(str, ref pos, len));
     Tags.AddRange(ParserSTEP.SplitListStrings(ParserSTEP.StripField(str, ref pos, len)).ConvertAll(x => ParserIfc.Decode(x)));
 }
Esempio n. 6
0
        private void layout(object sender, LayoutEventArgs e)
        {
            var width = SlopeSize.Width * (Count + 1) + Widths.Sum();

            if (AllowAddingTabs)
            {
                width = width - SlopeSize.Width + 2 * AddButtonSlopeSize.Width + AddButtonWidth;
            }

            Width = width;
        }
Esempio n. 7
0
        public void TranslateTo(Messages.RejectedChange message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            message.AddRoadSegment = new Messages.AddRoadSegment
            {
                TemporaryId          = TemporaryId,
                StartNodeId          = TemporaryStartNodeId ?? StartNodeId,
                EndNodeId            = TemporaryEndNodeId ?? EndNodeId,
                Geometry             = GeometryTranslator.Translate(Geometry),
                MaintenanceAuthority = MaintenanceAuthority,
                GeometryDrawMethod   = GeometryDrawMethod,
                Morphology           = Morphology,
                Status                = Status,
                Category              = Category,
                AccessRestriction     = AccessRestriction,
                LeftSideStreetNameId  = LeftSideStreetNameId.GetValueOrDefault(),
                RightSideStreetNameId = RightSideStreetNameId.GetValueOrDefault(),
                Lanes = Lanes
                        .Select(item => new Messages.RequestedRoadSegmentLaneAttribute
                {
                    AttributeId  = item.TemporaryId,
                    Count        = item.Count,
                    Direction    = item.Direction,
                    FromPosition = item.From,
                    ToPosition   = item.To
                })
                        .ToArray(),
                Widths = Widths
                         .Select(item => new Messages.RequestedRoadSegmentWidthAttribute
                {
                    AttributeId  = item.TemporaryId,
                    Width        = item.Width,
                    FromPosition = item.From,
                    ToPosition   = item.To
                })
                         .ToArray(),
                Surfaces = Surfaces
                           .Select(item => new Messages.RequestedRoadSegmentSurfaceAttribute
                {
                    AttributeId  = item.TemporaryId,
                    Type         = item.Type,
                    FromPosition = item.From,
                    ToPosition   = item.To
                })
                           .ToArray()
            };
        }
Esempio n. 8
0
        public IEnumerable <DocumentTable> GetTables()
        {
            var table = new PdfPTable(4)
            {
                WidthPercentage = 100
            };

            var titles = Titles.Split(',');

            table.SetWidths(Widths.Split(',').Select(int.Parse).ToArray());

            table.DefaultCell.BackgroundColor   = new GrayColor(0.9f);
            table.DefaultCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            table.AddCell(new Phrase(titles[0], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[1], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[2], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[3], PdfFonts.Bold));

            table.DefaultCell.BackgroundColor   = BaseColor.WHITE;
            table.DefaultCell.VerticalAlignment = Element.ALIGN_TOP;

            var attachments = GetAttachments(Role).ToList();

            attachments.Sort(delegate(IFileRelation f1, IFileRelation f2)
            {
                if (f1.Vendor != null && f2.Vendor != null)
                {
                    return(f1.Vendor.Name == f2.Vendor.Name ?
                           String.Compare(f1.Name, f2.Name, StringComparison.Ordinal) :
                           String.Compare(f1.Vendor.Name, f2.Vendor.Name, StringComparison.Ordinal));
                }

                if (f1.Vendor == null && f2.Vendor != null)
                {
                    return(-1);
                }

                return(1);
            });

            foreach (var attachment in attachments)
            {
                AddAttachmentRow(attachment, table);
            }

            return(new List <DocumentTable> {
                new DocumentTable("", table)
            });
        }
        private void PopulateWidthAndColour(Textile selectedTextile)
        {
            Widths.Clear();
            Colours.Clear();

            foreach (var colour in selectedTextile.Colours)
            {
                Colours.Add(colour);
            }
            SelectedColourIndex = 0;

            foreach (var width in selectedTextile.Widths)
            {
                Widths.Add(width);
            }
            SelectedWidthIndex = 0;
        }
Esempio n. 10
0
        private int getDraggingOverIndex(int dragCurrentX, int dragStartedX, int draggingIndex)
        {
            int delta = dragCurrentX - dragStartedX;

            IEnumerable <int> widths;
            int deltaAbs = Math.Abs(delta);
            int sign     = Math.Sign(delta);

            int passedCount = 0;

            if (delta > 0)
            {
                widths = Widths.Skip(draggingIndex + 1);
            }
            else if (delta < 0)
            {
                widths = Widths.Take(draggingIndex).Reverse();
            }
            else
            {
                widths = Enumerable.Empty <int>();
            }

            foreach (int width in widths)
            {
                int totalWidth = width + SlopeSize.Width;
                if (totalWidth <= deltaAbs)
                {
                    passedCount += sign;
                    deltaAbs    -= totalWidth;
                }
                else
                {
                    break;
                }
            }

            var tabIndex = draggingIndex + passedCount;

            return(tabIndex);
        }
Esempio n. 11
0
        /// <summary>
        /// Notifies the widths.
        /// </summary>
        /// <param name="cameraButtonContainerWidth">Camera button container width.</param>
        public void NotifyWidths(float cameraButtonContainerWidth)
        {
            CameraButtonContainerWidth = cameraButtonContainerWidth;

            Widths?.Invoke(this, cameraButtonContainerWidth);
        }
Esempio n. 12
0
        public IEnumerable <DocumentTable> GetTables()
        {
            var table = new PdfPTable(17)
            {
                WidthPercentage = 100
            };

            table.SetWidths(Widths.Split(',').Select(int.Parse).ToArray());

            var titles = Titles.Split(',');

            table.DefaultCell.Rowspan         = 2;
            table.DefaultCell.BackgroundColor = new GrayColor(0.9f);

            table.AddCell(new Phrase(titles[0], PdfFonts.SmallBold));
            table.AddCell(new Phrase(titles[1], PdfFonts.SmallBold));
            table.AddCell(new Phrase(titles[2], PdfFonts.SmallBold));

            table.DefaultCell.Rotation          = 90;
            table.DefaultCell.VerticalAlignment = Element.ALIGN_MIDDLE;
            table.AddCell(new Phrase(titles[3], PdfFonts.SmallBold));

            table.DefaultCell.Rotation            = 0;
            table.DefaultCell.Rowspan             = 1;
            table.DefaultCell.Colspan             = 8;
            table.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
            table.AddCell(new Phrase(titles[4], PdfFonts.SmallBold));

            table.DefaultCell.Colspan             = 2;
            table.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
            table.DefaultCell.VerticalAlignment   = Element.ALIGN_TOP;
            table.AddCell(new Phrase(titles[5], PdfFonts.SmallBold));

            table.DefaultCell.Colspan = 1;
            table.DefaultCell.Rowspan = 2;
            table.AddCell(new Phrase(titles[6], PdfFonts.SmallBold));
            table.AddCell(new Phrase(titles[7], PdfFonts.SmallBold));
            table.AddCell(new Phrase(titles[8], PdfFonts.SmallBold));

            table.DefaultCell.Rotation          = 90;
            table.DefaultCell.Rowspan           = 1;
            table.DefaultCell.VerticalAlignment = Element.ALIGN_MIDDLE;
            table.AddCell(new Phrase(titles[9], PdfFonts.TinyBold));
            table.AddCell(new Phrase(titles[10], PdfFonts.TinyBold));
            table.AddCell(new Phrase(titles[11], PdfFonts.TinyBold));
            table.AddCell(new Phrase(titles[12], PdfFonts.TinyBold));
            table.AddCell(new Phrase(titles[13], PdfFonts.TinyBold));
            table.AddCell(new Phrase(titles[14], PdfFonts.TinyBold));
            table.AddCell(new Phrase(titles[15], PdfFonts.TinyBold));
            table.AddCell(new Phrase(titles[16], PdfFonts.TinyBold));

            table.AddCell(new Phrase(titles[17], PdfFonts.SmallBold));
            table.AddCell(new Phrase(titles[18], PdfFonts.SmallBold));

            table.HeaderRows = 2;

            table.DefaultCell.Rotation        = 0;
            table.DefaultCell.BackgroundColor = BaseColor.WHITE;

            var maintenances = GetAllMaintenance();

            var enumerable = maintenances as IList <Maintenance> ?? maintenances.ToList();

            foreach (var maintenance in enumerable)
            {
                AddMaintenanceRow(maintenance, table);
            }

            table.DefaultCell.Colspan = 17;
            table.AddCell(" ");

            table.DefaultCell.Colspan             = 4;
            table.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
            table.AddCell(new Phrase(Info, PdfFonts.Small));

            table.DefaultCell.Colspan             = 1;
            table.DefaultCell.Rotation            = 90;
            table.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
            table.DefaultCell.VerticalAlignment   = Element.ALIGN_MIDDLE;

            table.AddCell(new Phrase("24", PdfFonts.Tiny));
            table.AddCell(new Phrase("168", PdfFonts.Tiny));
            table.AddCell(new Phrase("336", PdfFonts.Tiny));
            table.AddCell(new Phrase("720", PdfFonts.Tiny));
            table.AddCell(new Phrase("2160", PdfFonts.Tiny));
            table.AddCell(new Phrase("4320", PdfFonts.Tiny));
            table.AddCell(new Phrase("8640", PdfFonts.Tiny));
            table.AddCell(new Phrase(">8640", PdfFonts.Tiny));

            table.DefaultCell.Colspan = 5;
            table.AddCell("");

            table.DefaultCell.Rotation = 0;

            var vendors = enumerable
                          .Select(m => m.Vendor)
                          .Where(v => v != null)
                          .Distinct()
                          .OrderBy(v => v.Name);

            foreach (var vendor in vendors)
            {
                var abbreviation = GetVendorAbbreviation(vendor);

                table.DefaultCell.Colspan             = 16;
                table.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
                table.AddCell(new Phrase(abbreviation + " = " + vendor.Name + "  " + Info2, PdfFonts.SmallBold));

                table.DefaultCell.Colspan             = 1;
                table.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
                table.AddCell(GetVendorLink(vendor));
            }

            return(new List <DocumentTable> {
                new DocumentTable("", table)
            });
        }
Esempio n. 13
0
        public IEnumerable <DocumentTable> GetTables()
        {
            var table = new PdfPTable(8)
            {
                WidthPercentage = 100
            };

            table.SetWidths(Widths.Split(',').Select(int.Parse).ToArray());

            table.DefaultCell.Padding         = 3.0f;
            table.DefaultCell.BackgroundColor = new GrayColor(0.9f);

            var titles = Titles.Split(',');

            table.AddCell(new Phrase(titles[1], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[0], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[2], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[3], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[4], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[5], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[6], PdfFonts.Bold));
            table.AddCell(new Phrase(Documentation.Project.ProjectNumber, PdfFonts.Bold));

            table.HeaderRows = 1;
            table.DefaultCell.BackgroundColor = BaseColor.WHITE;

            var vendors = new List <Vendor>();

            foreach (var rel in Documentation.Project.Components.Where(rel => rel.Component is Component && rel.IncludeInManual)
                     .OrderBy(rel => rel.Component.Vendor != null ? rel.Component.Vendor.Name : "")
                     .ThenBy(rel => rel.Component.Category != null ? rel.Component.Category.Name : "")
                     .ThenBy(rel => rel.Component.Name))
            {
                table.AddCell(GetVendorLink(rel.Component.Vendor));
                table.AddCell(new Phrase(rel.Component.Category != null ? GetCategoryPath(rel.Component.Category) : "", PdfFonts.Normal));
                table.AddCell(new Phrase(rel.Component.Name, PdfFonts.Normal));
                table.AddCell(new Phrase(rel.Component.Description, PdfFonts.Normal));

                if (rel.Component.Image != null)
                {
                    var fullName = string.Format(@"{0}\{1}", RootDirectory, rel.Component.Image.Path);

                    try
                    {
                        var image = Image.GetInstance(fullName);
                        image.ScaleToFit(Math.Min(100, image.Width), Math.Min(100, image.Height));

                        var cell = new PdfPCell(image)
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER,
                            VerticalAlignment   = Element.ALIGN_MIDDLE,
                            Padding             = 5.0f
                        };

                        table.AddCell(cell);
                    }
                    catch
                    {
                        table.AddCell(new Phrase("BILDET " + fullName + " IKKE FUNNET!"));
                    }
                }
                else
                {
                    table.AddCell("");
                }

                table.AddCell(new Phrase(rel.Count.ToString(CultureInfo.InvariantCulture), PdfFonts.Normal));
                table.AddCell(new Phrase(rel.SpareParts.ToString(CultureInfo.InvariantCulture), PdfFonts.Normal));
                table.AddCell(new Phrase(rel.Info, PdfFonts.Normal));

                if (rel.Component.Vendor != null)
                {
                    vendors.Add(rel.Component.Vendor);
                }
            }

            vendors = vendors.Distinct().OrderBy(v => v.Name).ToList();

            foreach (var vendor in vendors)
            {
                var abbreviation = GetVendorAbbreviation(vendor);

                table.DefaultCell.Colspan             = 7;
                table.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
                table.AddCell(new Phrase(abbreviation + " = " + vendor.Name + "  " + Info, PdfFonts.SmallBold));

                table.DefaultCell.Colspan             = 1;
                table.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
                table.AddCell(GetVendorLink(vendor));
            }

            return(new List <DocumentTable> {
                new DocumentTable("", table)
            });
        }