示例#1
0
        public static void ScreenVariablesUpdatedExtracted(int maxDisplayLengthTM1638, string format, int param, List <ComboBox> scvIn, DisplayUnitConfiguration temp, Label spaceUsedLabel, bool firstLoadIn)
        {
            int count = 0;
            int i     = 0;
            int stop  = 0;

            while (count < maxDisplayLengthTM1638 && i < scvIn.Count)
            {
                stop = i + 1;
                if (scvIn[i].SelectedIndex >= 0)
                {
                    count += temp.HostApp.DisplayMngr.Dictionarys.DisplayVariables.Where(item => item.Value.Name == scvIn[i].SelectedItem.ToString()).Sum(item => item.Value.Length);
                    spaceUsedLabel.Content = String.Format(format, count);
                    if (count > maxDisplayLengthTM1638)
                    {
                        stop = i;
                        i    = scvIn.Count;
                    }
                    i++;
                }
                else
                {
                    scvIn[i].IsEnabled = true;
                    scvIn[i].Items.Clear();
                    foreach (var variable in temp.HostApp.DisplayMngr.Dictionarys.DisplayVariables)
                    {
                        if (variable.Value.Length <= maxDisplayLengthTM1638 - count)
                        {
                            scvIn[i].Items.Add(variable.Value.Name);
                        }
                    }
                    i = scvIn.Count;
                }
            }
            for (int j = stop; j < scvIn.Count; j++)
            {
                scvIn[j].Items.Clear();
                scvIn[j].SelectedIndex = -1;
                scvIn[j].IsEnabled     = false;
            }
            //save to config
            if (!firstLoadIn)
            {
                for (int p = 0; p < param; p++)
                {
                    if (scvIn[p].SelectedValue != null)
                    {
                        string tempV = scvIn[p].SelectedValue.ToString();
                        var    temp2 = new DisplayVarsEnum();
                        bool   found = false;
                        foreach (var disVar in temp.HostApp.DisplayMngr.Dictionarys.DisplayVariables)
                        {
                            if (disVar.Value.Name == tempV)
                            {
                                temp2 = disVar.Key;
                                found = true;
                            }
                        }
                        if (found)
                        {
                            if (temp.Screens[temp.ScreenToEdit].Variables.Count - 1 < p)
                            {
                                temp.Screens[temp.ScreenToEdit].Variables.Add("");
                            }
                            temp.Screens[temp.ScreenToEdit].Variables[p] = temp2.ToString();
                        }
                    }
                }
            }
        }
示例#2
0
 public static void ScreenVariablesUpdatedExtracted(int maxDisplayLengthTM1638, string format, int param, List<ComboBox> scvIn, DisplayUnitConfiguration temp, Label spaceUsedLabel, bool firstLoadIn)
 {
     int count = 0;
     int i = 0;
     int stop = 0;
     while (count < maxDisplayLengthTM1638 && i < scvIn.Count)
     {
         stop = i + 1;
         if (scvIn[i].SelectedIndex >= 0)
         {
             count += temp.HostApp.DisplayMngr.Dictionarys.DisplayVariables.Where(item => item.Value.Name == scvIn[i].SelectedItem.ToString()).Sum(item => item.Value.Length);
             spaceUsedLabel.Content = String.Format(format, count);
             if (count > maxDisplayLengthTM1638)
             {
                 stop = i;
                 i = scvIn.Count;
             }
             i++;
         }
         else
         {
             scvIn[i].IsEnabled = true;
             scvIn[i].Items.Clear();
             foreach (var variable in temp.HostApp.DisplayMngr.Dictionarys.DisplayVariables)
             {
                 if (variable.Value.Length <= maxDisplayLengthTM1638 - count)
                 {
                     scvIn[i].Items.Add(variable.Value.Name);
                 }
             }
             i = scvIn.Count;
         }
     }
     for (int j = stop; j < scvIn.Count; j++)
     {
         scvIn[j].Items.Clear();
         scvIn[j].SelectedIndex = -1;
         scvIn[j].IsEnabled = false;
     }
     //save to config
     if (!firstLoadIn)
     {
         for (int p = 0; p < param; p++)
         {
             if (scvIn[p].SelectedValue != null)
             {
                 string tempV = scvIn[p].SelectedValue.ToString();
                 var temp2 = new DisplayVarsEnum();
                 bool found = false;
                 foreach (var disVar in temp.HostApp.DisplayMngr.Dictionarys.DisplayVariables)
                 {
                     if (disVar.Value.Name == tempV)
                     {
                         temp2 = disVar.Key;
                         found = true;
                     }
                 }
                 if (found)
                 {
                     if (temp.Screens[temp.ScreenToEdit].Variables.Count - 1 < p)
                     {
                         temp.Screens[temp.ScreenToEdit].Variables.Add("");
                     }
                     temp.Screens[temp.ScreenToEdit].Variables[p] = temp2.ToString();
                 }
             }
         }
     }
 }