public string Design(string labelDefinition, IEnumerable <Object> data, string parentEntity, string printerName)
        {
            using (var listLabel = new ListLabel())
            {
                listLabel.LicensingInfo = ListLabelLicenseString;
                listLabel.Core.LlSetOption(LlOption.Metric, 1);
                listLabel.Core.LlSetOption(LlOption.Wizard_FileNew, 0);
                listLabel.Core.LlSetOption(LlOption.RibbonDefaultEnabledState, 1);
                listLabel.Core.LlSetOption(LlOption.NoFileVersionUpgradeWarning, 1);

                // Set up the dataset
                listLabel.DataSource = new ObjectDataProvider(data)
                {
                    FlattenStructure = true,
                };
                listLabel.DataMember     = parentEntity;
                listLabel.AutoMasterMode = LlAutoMasterMode.AsVariables;


                // If we have a default printer then set it here
                if (printerName != null)
                {
                    listLabel.Core.LlSetOptionString(71, printerName);
                }

                // Launch the designer
                listLabel.Design(LlProject.List);

                return(String.Empty);
            }
        }
        private void SetUpListAndLabel(ListLabel ll, List <FlipDataSource> data, int startPosition = 0)
        {
            //get license
            var llKey = GetKeyFromConfig();

            ll.LicensingInfo = llKey;

            List <FlipDataSource> flips = new List <FlipDataSource>();

            if (startPosition > 1)
            {
                for (int i = 0; i < startPosition - 1; i++)
                {
                    flips.Add(new FlipDataSource {
                    });
                }
            }

            flips.AddRange(data);

            ll.SetDataBinding(flips, string.Empty);

            ll.AutoShowSelectFile   = false;
            ll.AutoDesignerPreview  = true;
            ll.AutoShowPrintOptions = false;
        }
Example #3
0
        public static void ExportAsPdf(string labelDefinition, IEnumerable <Object> data, string parentEntity, string targetFilePath)
        {
            using (var listLabel = new ListLabel())
            {
                listLabel.LicensingInfo = ListLabelLicenseString;

                // Set up the dataset
                listLabel.DataSource = new ObjectDataProvider(data)
                {
                    FlattenStructure = true,
                };
                listLabel.DataMember     = parentEntity;
                listLabel.AutoMasterMode = LlAutoMasterMode.AsVariables;

                // Configure the designer to read the report design from a memoryStream
                var memoryStream = new MemoryStream();
                if (labelDefinition != null)
                {
                    var stringBytes = Encoding.Unicode.GetBytes(labelDefinition);
                    memoryStream.Write(stringBytes, 0, stringBytes.Length);
                }

                // Launch the designer
                var exportConfiguration = new ExportConfiguration(
                    LlExportTarget.Pdf,
                    targetFilePath,
                    memoryStream)
                {
                    ShowResult = false,
                };
                listLabel.Export(exportConfiguration);
            }
        }
Example #4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.BackColor = System.Drawing.Color.FromArgb(245, 246, 247);
            this.GetMainWindowsPos();
            try
            {
                if (RedmineReportsConfigDataHelper.ConnectionStringEncrypted(connString))
                {
                    _dataAccess = new RedmineMySqlDataAccess();
                }
                else
                {
                    if (RedmineReportsConfigDataHelper.ConnectionStringIsPlain(connString))
                    {
                        _dataAccess = new RedmineMySqlDataAccess(null, RedmineReportsConfigDataHelper.ConnectionStringIsPlain(connString));
                    }
                    else
                    {
                        //open config form for sql data
                        ConfigureMySqlDataBaseConnection();
                    }
                }

                _lL = new ListLabel();
                // Add your License Key
                _lL.LicensingInfo = "Insert license key here";

                // fill project listbox
                if (_dataAccess != null)
                {
                    lstbProjects.DataSource = _dataAccess.GetRedmineProjects(Convert.ToBoolean(ConfigurationManager.AppSettings["UseAllProjects"]));
                }
                lstbProjects.DisplayMember = "display_name";
                lstbProjects.ValueMember   = "id";

                // check or uncheck checkbox for subprojects
                cbAllProjects.Checked = Convert.ToBoolean(ConfigurationManager.AppSettings["UseAllProjects"]);

                DesignerFunction fct = new DesignerFunction();
                fct.FunctionName      = "GetStatusNameFromId";
                fct.GroupName         = "RedmineFunctions";
                fct.ResultType        = LlParamType.String;
                fct.MinimalParameters = 1;
                fct.MaximumParameters = 1;
                fct.Parameter1.Type   = LlParamType.Double;
                fct.EvaluateFunction += new EvaluateFunctionHandler(fct_EvaluateFunction);
                _lL.DesignerFunctions.Add(fct);

                lstbTrackers.Enabled        = !AllLstBoxItemsSelected(lstbTrackers);
                chkBox_All_Trackers.Checked = AllLstBoxItemsSelected(lstbTrackers);
            }
            catch (NullReferenceException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #5
0
        /// <summary>
        /// Sanitize the fields of a <see cref="ListLabel"/> in-place.
        /// </summary>
        /// <param name="label">A reference to the <see cref="ListLabel"/> to check.</param>
        private void CheckLabel(ref ListLabel label, bool normalMode)
        {
            void CheckString(ref string s) => s = s ?? "";

            CheckString(ref label.FirstCol);

            if (label.LastCol != null)
            {
                for (int i = 0; i < label.LastCol.Count; i++)
                {
                    var LastCol = label.LastCol[i];
                    CheckString(ref LastCol);
                    label.LastCol[i] = LastCol;
                }
            }

            if (label.SymbolCol != null)
            {
                for (int i = 0; i < label.SymbolCol.Count; i++)
                {
                    var symbolCol = label.SymbolCol[i];
                    CheckString(ref symbolCol);
                    label.SymbolCol[i] = symbolCol;
                }
            }
            CheckString(ref label.KeyPressed);

            UpdateColsWidth(label, normalMode);
        }
Example #6
0
 private void initLabelText(int containItemCount, List <ListItem> pendingItems)
 {
     for (int index = 0; index < containItemCount; ++index)
     {
         ListLabel listLabel = new ListLabel();
         listLabel.LabelText = "this is label:" + index;
         pendingItems.Add(listLabel);
     }
 }
        protected override void ImplementLabelLocalization()
        {
            base.ImplementLabelLocalization();

            if (!ListLabel.TrimHasValue())
            {
                lblTitle.Text = Localize("Common.UserControls.SuperGridView.lblTitle", "Data Preview: ");
            }
            lblExport.Text = Localize("Common.UserControls.SuperGridView.lblExport", "Export");
        }
Example #8
0
 public void Dispose()
 {
     _defaultFont?.Dispose();
     _boldFont?.Dispose();
     List?.Dispose();
     ListLabel?.Dispose();
     Tree?.Dispose();
     TreeLabel?.Dispose();
     Form?.Dispose();
 }
Example #9
0
        /// <summary>
        /// Display info according to the full text window or the slim text window
        /// </summary>
        /// <param name="firstkeyactivated"></param>
        /// <param name="firstcol"></param>
        /// <param name="lastcol"></param>
        /// <param name="symbolcol"></param>
        /// <param name="changecolwidth"></param>
        /// <param name="lastkeyactivated"></param>
        ///
        private void UpdateColsWidth(ListLabel label)
        {
            if (!UpdateDataEnded)
            {
                var firstColWidth  = 0;
                var lastColWidth   = 0;
                var firstCol       = label.FirstCol;
                var lastCol        = label.LastCol;
                var symbolCol      = label.SymbolCol;
                var keyPressed     = label.KeyPressed;
                var changeColwidth = label.ChangeColWidth;

                if (!firstCol.Contains("Sprtr"))
                {
                    firstColWidth = FontToBold ? Owner.TextFontDefaultBold.MeasureString(firstCol.TrimEnd())
                        : Owner.TextFontDefault.MeasureString(firstCol.TrimEnd());

                    if (firstCol.ToUpper().Contains("TIME"))
                    {
                        lastColWidth = FontToBold ? Owner.TextFontDefaultBold.MeasureString(lastCol.TrimEnd())
                        : Owner.TextFontDefault.MeasureString(lastCol.TrimEnd());
                    }
                    //Set a minimum value for LastColWidth to avoid overlap between time value
                    if (labels.Count == 1)
                    {
                        lastColWidth = labels.First().LastColWidth + 15;// time value +  symbol
                    }
                }

                labels.Add(new ListLabel
                {
                    FirstCol       = firstCol,
                    FirstColWidth  = firstColWidth,
                    LastCol        = lastCol,
                    LastColWidth   = lastColWidth,
                    SymbolCol      = symbolCol,
                    ChangeColWidth = changeColwidth,
                    KeyPressed     = keyPressed
                });

                //ResizeWindow, when the string spans over the right boundary of the window
                if (!ResizeWindow)
                {
                    if (maxFirstColWidth < firstColWidth)
                    {
                        FirstColOverFlow = maxFirstColWidth;
                    }
                    if (maxLastColWidth < lastColWidth)
                    {
                        LastColOverFlow = maxLastColWidth;
                    }
                    ResizeWindow = true;
                }
            }
        }
Example #10
0
        /// <summary>
        /// Sanitize the fields of a <see cref="ListLabel"/> in-place.
        /// </summary>
        /// <param name="label">A reference to the <see cref="ListLabel"/> to check.</param>
        private void CheckLabel(ref ListLabel label)
        {
            void CheckString(ref string s) => s = s ?? "";

            CheckString(ref label.FirstCol);
            CheckString(ref label.LastCol);
            CheckString(ref label.SymbolCol);
            CheckString(ref label.KeyPressed);

            UpdateColsWidth(label);
        }
Example #11
0
        private void Form1_Activated(object sender, EventArgs e)
        {
            var addnewlist = new AddNewList();

            listBox1.Show();
            ListLabel.Show();
            listBox1.Items.Clear();
            var vs = WordList.GetLists();

            foreach (var v in vs)
            {
                listBox1.Items.Add(v);
            }
        }
        public void PrintListAndLabel(List <FlipDataSource> data,
                                      string labelFilePath,
                                      string labelFile,
                                      string printerName,
                                      int startPosition = 0
                                      )
        {
            using (ListLabel ll = new ListLabel())
            {
                FlipPrintDataToLaserFlips(data);
                SetUpListAndLabel(ll, data, startPosition);

                ll.Print(printerName, LlProject.Label, GetFullLabelFilePath(labelFilePath, labelFile));
            }
        }
        protected void btnExport_Click(object sender, ImageClickEventArgs e)
        {
            gvList.ExportSettings.ExportOnlyData  = true;
            gvList.ExportSettings.OpenInNewWindow = true;
            gvList.ExportSettings.IgnorePaging    = true;
            if (ListLabel.TrimHasValue())
            {
                gvList.ExportSettings.FileName = ListLabel;
            }
            else
            {
                gvList.ExportSettings.FileName = "List";
            }

            gvList.MasterTableView.ExportToExcel();
        }
        public void DesignListAndLabel(List <FlipDataSource> data, string labelFilePath, string labelFile, string printerName, int startPosition = 0)
        {
            using (ListLabel ll = new ListLabel())
            {
                FlipPrintDataToLaserFlips(data);
                SetUpListAndLabel(ll, data, startPosition);

                if (!string.IsNullOrEmpty(labelFile))
                {
                    ll.Design("", LlProject.Label, GetFullLabelFilePath(labelFilePath, labelFile), false);
                }
                else
                {
                    ll.Design(LlProject.Label);
                }
            }
        }
Example #15
0
        private void MainForm_Activated(object sender, EventArgs e)
        {
            listBox1.Show();
            listBox1.Enabled = true;
            ListLabel.Show();
            listBox1.Items.Clear();
            TranslationGrid.Hide();
            var listsOnComputer = WordList.GetLists();

            foreach (var lists in listsOnComputer)
            {
                var wordList = WordList.LoadList(lists);
                if (wordList != null && wordList.Languages.Length > 1)
                {
                    listBox1.Items.Add(lists);
                }
            }
        }
Example #16
0
        /// <summary>
        /// Sanitize the fields of a <see cref="ListLabel"/> in-place.
        /// </summary>
        /// <param name="label">A reference to the <see cref="ListLabel"/> to check.</param>
        private static void CheckLabel(ref ListLabel label, bool normalMode)
        {
            void CheckString(ref string s) => s = s ?? "";

            CheckString(ref label.FirstCol);

            if (label.LastCol != null)
            {
                for (int i = 0; i < label.LastCol.Count; i++)
                {
                    var LastCol = label.LastCol[i];
                    CheckString(ref LastCol);
                    label.LastCol[i] = LastCol;
                }
            }

            if (label.SymbolCol != null)
            {
                for (int i = 0; i < label.SymbolCol.Count; i++)
                {
                    var symbolCol = label.SymbolCol[i];
                    CheckString(ref symbolCol);
                    label.SymbolCol[i] = symbolCol;
                }
            }

            if (!normalMode)
            {
                foreach (KeyValuePair <string, string> mapping in FirstColToAbbreviated)
                {
                    label.FirstCol = label.FirstCol.Replace(mapping.Key, mapping.Value);
                }
                foreach (KeyValuePair <string, string> mapping in LastColToAbbreviated)
                {
                    if (label.LastCol != null)
                    {
                        for (int i = 0; i < label.LastCol.Count; i++)
                        {
                            label.LastCol[i] = label.LastCol[i].Replace(mapping.Key, mapping.Value);
                        }
                    }
                }
            }
        }
        public bool Print(string labelDefinition, IEnumerable <Object> data, string parentEntity, string printerName)
        {
            try
            {
                using (var listLabel = new ListLabel())
                {
                    listLabel.LicensingInfo = ListLabelLicenseString;

                    // Set up the dataset
                    listLabel.DataSource = new ObjectDataProvider(data)
                    {
                        FlattenStructure = true,
                    };
                    listLabel.DataMember     = parentEntity;
                    listLabel.AutoMasterMode = LlAutoMasterMode.AsVariables;

                    // Configure the designer to read the report design from a memoryStream
                    var memoryStream = new MemoryStream();
                    if (labelDefinition != null)
                    {
                        var stringBytes = Encoding.Unicode.GetBytes(labelDefinition);
                        memoryStream.Write(stringBytes, 0, stringBytes.Length);
                    }

                    // If we have a default printer then set it here
                    if (printerName != null)
                    {
                        listLabel.Core.LlSetOptionString(71, printerName);
                    }

                    // Launch the designer
                    listLabel.Print(LlProject.List, memoryStream);

                    return(true);
                }
            }
            catch (LL_User_Aborted_Exception)
            {
                // Ignore user abort
            }

            return(false);
        }
Example #18
0
        public void GetListLabels()
        {
            //ExStart
            //ExFor:Document.UpdateListLabels()
            //ExFor:Node.ToString(SaveFormat)
            //ExFor:ListLabel
            //ExFor:Paragraph.ListLabel
            //ExFor:ListLabel.LabelValue
            //ExFor:ListLabel.LabelString
            //ExSummary:Shows how to extract the label of each paragraph in a list as a value or a String.
            Document doc = new Document(MyDir + "Lists.PrintOutAllLists.doc");

            doc.UpdateListLabels();
            int listParaCount = 1;

            foreach (Paragraph paragraph in doc.GetChildNodes(NodeType.Paragraph, true).OfType <Paragraph>())
            {
                // Find if we have the paragraph list. In our document our list uses plain arabic numbers,
                // which start at three and ends at six.
                if (paragraph.ListFormat.IsListItem)
                {
                    Console.WriteLine("Paragraph #{0}", listParaCount);

                    // This is the text we get when actually getting when we output this node to text format.
                    // The list labels are not included in this text output. Trim any paragraph formatting characters.
                    String paragraphText = paragraph.ToString(SaveFormat.Text).Trim();
                    Console.WriteLine("Exported Text: " + paragraphText);

                    ListLabel label = paragraph.ListLabel;
                    // This gets the position of the paragraph in current level of the list. If we have a list with multiple level then this
                    // will tell us what position it is on that particular level.
                    Console.WriteLine("Numerical Id: " + label.LabelValue);

                    // Combine them together to include the list label with the text in the output.
                    Console.WriteLine("List label combined with text: " + label.LabelString + " " + paragraphText);

                    listParaCount++;
                }
            }

            //ExEnd
        }
Example #19
0
        private void LLAction(string action)
        {
            if (ensureService())
            {
                ListLabel            LL       = new ListLabel();
                OpenEdgeDataProvider Provider = new OpenEdgeDataProvider();

                Provider.ServiceAdapter = OpenEdgeServiceAdapter;
                Provider.ServiceName    = Config.ServiceName;
                Provider.Initialize();
                LL.DataSource = Provider;

                try
                {
                    if (action == "Design")
                    {
                        if (Config.DesignerPreviewMaxRows > 0)
                        {
                            Provider.MaxRows = Config.DesignerPreviewMaxRows;
                        }
                        LL.Design();
                    }
                    else
                    {
                        LL.Print();
                    }
                }
                catch (ListLabelException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    Provider.Dispose();
                    LL.Dispose();
                }
            }
            else
            {
                MessageBox.Show("No connection available");
            }
        }
Example #20
0
        private void LLAction(string action)
        {
            var param = new RestConnectionParameter();

            param.RestURL  = Properties.Settings.Default.RestURL;
            param.Userid   = Properties.Settings.Default.Userid;
            param.Password = Properties.Settings.Default.Password;

            var ll = new ListLabel();
            var dp = new OpenEdgeDataProvider();

            dp.ServiceAdapter = new RestServiceAdapter(param);
            dp.ServiceName    = Properties.Settings.Default.ServiceName;
            dp.Initialize();
            ll.DataSource = dp;
            try
            {
                if (action == "DESIGN")
                {
                    if (Properties.Settings.Default.DesignerPreviewMaxRows > 0)
                    {
                        dp.MaxRows = Properties.Settings.Default.DesignerPreviewMaxRows;
                    }
                    ll.Design();
                }
                else if (action == "PRINT")
                {
                    ll.Print();
                }
                else
                {
                }
            }
            catch (ListLabelException e)
            {
                MessageBox.Show(e.Message);
            }
            ll.Dispose();

            dp.Dispose();
        }
        /// <summary>
        /// Sanitize the fields of a <see cref="ListLabel"/> in-place.
        /// </summary>
        /// <param name="label">A reference to the <see cref="ListLabel"/> to check.</param>
        private static void CheckLabel(ref ListLabel label, bool normalMode)
        {
            void CheckString(ref string s) => s = s ?? "";

            CheckString(ref label.FirstCol);
            CheckString(ref label.LastCol);
            CheckString(ref label.SymbolCol);
            CheckString(ref label.KeyPressed);

            if (!normalMode)
            {
                foreach (KeyValuePair <string, string> mapping in FirstColToAbbreviated)
                {
                    label.FirstCol = label.FirstCol.Replace(mapping.Key, mapping.Value);
                }
                foreach (KeyValuePair <string, string> mapping in LastColToAbbreviated)
                {
                    label.LastCol = label.LastCol.Replace(mapping.Key, mapping.Value);
                }
            }
        }
Example #22
0
        public void GetListLabels()
        {
            //ExStart
            //ExFor:Document.UpdateListLabels()
            //ExFor:Node.ToString(SaveFormat)
            //ExFor:ListLabel
            //ExFor:Paragraph.ListLabel
            //ExFor:ListLabel.LabelValue
            //ExFor:ListLabel.LabelString
            //ExSummary:Shows how to extract the label of each paragraph in a list as a value or a String.
            Document doc = new Document(MyDir + "Rendering.docx");

            doc.UpdateListLabels();

            NodeCollection paras = doc.GetChildNodes(NodeType.Paragraph, true);

            // Find if we have the paragraph list. In our document our list uses plain Arabic numbers,
            // which start at three and ends at six
            foreach (Paragraph paragraph in paras.OfType <Paragraph>().Where(p => p.ListFormat.IsListItem))
            {
                Console.WriteLine($"List item paragraph #{paras.IndexOf(paragraph)}");

                // This is the text we get when actually getting when we output this node to text format
                // The list labels are not included in this text output. Trim any paragraph formatting characters
                string paragraphText = paragraph.ToString(SaveFormat.Text).Trim();
                Console.WriteLine($"\tExported Text: {paragraphText}");

                ListLabel label = paragraph.ListLabel;

                // This gets the position of the paragraph in current level of the list. If we have a list with multiple levels,
                // this will tell us what position it is on that level
                Console.WriteLine($"\tNumerical Id: {label.LabelValue}");

                // Combine them together to include the list label with the text in the output
                Console.WriteLine($"\tList label combined with text: {label.LabelString} {paragraphText}");
            }
            //ExEnd

            Assert.AreEqual(10, paras.OfType <Paragraph>().Count(p => p.ListFormat.IsListItem));
        }
Example #23
0
 private void WriteAttributes(ListLabel listLabel)
 {
     if (listLabel != null)
     {
         PdfObject obj = parent.GetAttribute(PdfName.STARTINDENT);
         if (obj is PdfNumber)
         {
             float startIndent = ((PdfNumber)obj).FloatValue;
             if (startIndent != listLabel.Indentation)
             {
                 this.SetAttribute(PdfName.STARTINDENT, new PdfNumber(listLabel.Indentation));
             }
         }
         else
         {
             if (Math.Abs(listLabel.Indentation) > float.Epsilon)
             {
                 this.SetAttribute(PdfName.STARTINDENT, new PdfNumber(listLabel.Indentation));
             }
         }
     }
 }
Example #24
0
        private void button1_Click(object sender, EventArgs e)
        {
            ListLabel            LL = new ListLabel();
            OpenEdgeDataProvider dp = new OpenEdgeDataProvider();
            ServiceAdapter       s  = new ServiceAdapter(_schema);

            try
            {
                dp.ServiceName    = TextServiceName.Text;
                dp.ServiceAdapter = s;
                dp.Initialize();

                if (TableCombo.Text != "<none>")
                {
                    LL.DataMember = TableCombo.Text;
                    if (AutoMasterModeNone.Checked)
                    {
                        LL.AutoMasterMode = LlAutoMasterMode.None;
                    }
                    if (AutomasterModeAsVariables.Checked)
                    {
                        LL.AutoMasterMode = LlAutoMasterMode.AsVariables;
                    }
                    if (AutoMasterModeAsFields.Checked)
                    {
                        LL.AutoMasterMode = LlAutoMasterMode.AsFields;
                    }
                }

                LL.DataSource = dp;
                LL.Design();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
            LL.Dispose();
        }
Example #25
0
        public static string Design(string labelDefinition, IEnumerable <object> data, string parentEntity)
        {
            using (var listLabel = new ListLabel())
            {
                listLabel.LicensingInfo = ListLabelLicenseString;
                listLabel.Core.LlSetOption(LlOption.Metric, 1);
                listLabel.Core.LlSetOption(LlOption.Wizard_FileNew, 0);
                listLabel.Core.LlSetOption(LlOption.RibbonDefaultEnabledState, 1);
                listLabel.Core.LlSetOption(LlOption.NoFileVersionUpgradeWarning, 1);

                // Set up the dataset
                listLabel.DataSource = new ObjectDataProvider(data)
                {
                    FlattenStructure = true,
                };
                listLabel.DataMember     = parentEntity;
                listLabel.AutoMasterMode = LlAutoMasterMode.AsVariables;

                // Configure the designer to read the report design from a memoryStream
                var memoryStream = new MemoryStream();
                if (labelDefinition != null)
                {
                    var stringBytes = Encoding.Unicode.GetBytes(labelDefinition);
                    memoryStream.Write(stringBytes, 0, stringBytes.Length);
                }

                // Launch the designer
                listLabel.Design(LlProject.List, memoryStream);

                // Now convert the resulting report stream into a string
                var streamReader           = new StreamReader(memoryStream);
                var updatedLabelDefinition = streamReader.ReadToEnd();

                return(updatedLabelDefinition);
            }
        }
 public ListLabelManager()
 {
     _llGlobal = new ListLabel();
 }
Example #27
0
        /// <summary>
        /// Display info according to the full text window or the slim text window
        /// </summary>
        /// <param name="firstkeyactivated"></param>
        /// <param name="firstcol"></param>
        /// <param name="lastcol"></param>
        /// <param name="symbolcol"></param>
        /// <param name="changecolwidth"></param>
        /// <param name="lastkeyactivated"></param>

        private void UpdateColsWidth(ListLabel label, bool normalmode)
        {
            if (!UpdateDataEnded)
            {
                if (!normalTextMode)
                {
                    foreach (KeyValuePair <string, string> mapping in FirstColToAbbreviated)
                    {
                        label.FirstCol = label.FirstCol.Replace(mapping.Key, mapping.Value);
                    }
                    foreach (KeyValuePair <string, string> mapping in LastColToAbbreviated)
                    {
                        if (label.LastCol != null)
                        {
                            for (int i = 0; i < label.LastCol.Count; i++)
                            {
                                label.LastCol[i] = label.LastCol[i].Replace(mapping.Key, mapping.Value);
                            }
                        }
                    }
                }
                var        firstCol       = label.FirstCol;
                var        firstColWidth  = 0;
                var        lastCol        = label.LastCol;
                List <int> lastColWidth   = new List <int>();
                var        symbolCol      = label.SymbolCol;
                var        keyPressed     = label.KeyPressed;
                var        changeColwidth = label.ChangeColWidth;

                if (!firstCol.Contains("Sprtr"))
                {
                    if (ColorCodeCtrl.Keys.Any(firstCol.EndsWith))
                    {
                        var tempFirstCol = firstCol.Substring(0, firstCol.Length - 3);
                        firstColWidth = FontToBold ? Owner.TextFontDefaultBold.MeasureString(tempFirstCol.TrimEnd())
                            : !normalTextMode?Owner.TextFontMonoSpacedBold.MeasureString(tempFirstCol.TrimEnd())
                                            : Owner.TextFontDefault.MeasureString(tempFirstCol.TrimEnd());
                    }
                    else
                    {
                        firstColWidth = FontToBold ? Owner.TextFontDefaultBold.MeasureString(firstCol.TrimEnd())
                            : !normalTextMode?Owner.TextFontMonoSpacedBold.MeasureString(firstCol.TrimEnd())
                                            : Owner.TextFontDefault.MeasureString(firstCol.TrimEnd());
                    }

                    if (label.LastCol != null)
                    {
                        foreach (string data in label.LastCol)
                        {
                            if (data != null)
                            {
                                data.Replace("|", "");
                                if (ColorCodeCtrl.Keys.Any(data.EndsWith))
                                {
                                    var tempLastCol = data.Substring(0, data.Length - 3);
                                    lastColWidth.Add(FontToBold ? Owner.TextFontDefaultBold.MeasureString(tempLastCol.TrimEnd())
                                        : Owner.TextFontDefault.MeasureString(tempLastCol.TrimEnd()));
                                }
                                else
                                {
                                    lastColWidth.Add(FontToBold ? Owner.TextFontDefaultBold.MeasureString(data.TrimEnd())
                                        : Owner.TextFontDefault.MeasureString(data.TrimEnd()));
                                }
                            }
                        }
                    }
                }

                //Set a minimum value for LastColWidth to avoid overlap between time value and clickable symbol
                if (labels.Count == 1)                                                             //&& lastColWidth.Count > 0)
                {
                    lastColWidth.Add(labels[0].LastColWidth[0] + (TextSize * 3) + dpiOffset * 10); // time value + clickable symbol
                }

                labels.Add(new ListLabel
                {
                    FirstCol       = firstCol,
                    FirstColWidth  = firstColWidth,
                    LastCol        = lastCol,
                    LastColWidth   = lastColWidth,
                    SymbolCol      = symbolCol,
                    ChangeColWidth = changeColwidth,
                    KeyPressed     = keyPressed
                });

                //ResizeWindow, when the string spans over the right boundary of the window
                if (!ResizeWindow)
                {
                    if (maxFirstColWidth < firstColWidth)
                    {
                        FirstColOverFlow = maxFirstColWidth;
                    }

                    if (label.LastColWidth != null)
                    {
                        for (int i = 0; i < label.LastColWidth.Count; i++)
                        {
                            if (maxLastColWidth < lastColWidth[i])
                            {
                                LastColOverFlow = maxLastColWidth;
                            }
                        }
                    }
                    ResizeWindow = true;
                }
            }
            else
            {
                if (this.Visible)
                {
                    // Detect Autopilot is on to avoid flickering when slim window is displayed
                    var AutopilotOn = Owner.Viewer.PlayerLocomotive.Train.TrainType == Train.TRAINTYPE.AI_PLAYERHOSTING ? true : false;

                    //ResizeWindow, when the string spans over the right boundary of the window
                    maxFirstColWidth = labels.Max(x => x.FirstColWidth);
                    maxLastColWidth  = labels.Max(x => x.LastColWidth[0]);

                    if (!ResizeWindow & (FirstColOverFlow != maxFirstColWidth || (!AutopilotOn && LastColOverFlow != maxLastColWidth)))
                    {
                        LastColOverFlow  = maxLastColWidth;
                        FirstColOverFlow = maxFirstColWidth;
                        ResizeWindow     = true;
                    }
                }
            }
        }
 /// <summary>
 /// Sanitize the fields of a <see cref="ListLabel"/> in-place.
 /// </summary>
 /// <param name="label">A reference to the <see cref="ListLabel"/> to check.</param>
 private static void CheckLabel(ref ListLabel label, bool normalMode)
 {
Example #29
0
 private void WriteAttributes(ListLabel listLabel)
 {
     if (listLabel != null)
     {
     }
 }