Esempio n. 1
0
 public void updateObject(WriteOffConfiguration writeOffConfiguration)
 {
     if (writeOffConfiguration == null || writeOffConfiguration.fieldListChangeHandler == null)
     {
         return;
     }
     foreach (WriteOffField writeofffield in writeOffConfiguration.fieldListChangeHandler.Items)
     {
         if (writeofffield == null)
         {
             continue;
         }
         foreach (UIElement writeoff in this.configPanel.Children)
         {
             if (writeoff is WriteOffFieldPanel)
             {
                 WriteOffFieldPanel writeoffPanel = (WriteOffFieldPanel)writeoff;
                 if (writeoffPanel.writeOffField == null)
                 {
                     continue;
                 }
                 if (writeoffPanel.writeOffField.position == writeofffield.position)
                 {
                     writeoffPanel.UpdateObject(writeofffield);
                     writeoffPanel.UpdateValues(writeofffield);
                     break;
                 }
             }
         }
     }
 }
Esempio n. 2
0
        private void DeleteAction(WriteOffFieldPanel item)
        {
            if (item is WriteOffFieldPanel)
            {
                WriteOffFieldPanel panel = (WriteOffFieldPanel)item;
                int lastIndex            = panel.Index;
                this.configPanel.Children.Remove(panel);
                nbreLigne = 0;
                foreach (UIElement writeoff in this.configPanel.Children)
                {
                    if (writeoff is WriteOffFieldPanel)
                    {
                        ((WriteOffFieldPanel)writeoff).Index = nbreLigne;
                        ((WriteOffFieldPanel)writeoff).showRowLabel(nbreLigne == 0);
                        nbreLigne++;
                    }
                }

                if (panel.writeOffField != null)
                {
                    this.EditedObject.SynchronizeDeleteWriteOffField(panel.writeOffField);
                }

                if (this.configPanel.Children.Count == 0)
                {
                    AddAction(null);
                    return;
                }

                if (lastIndex == 0)
                {
                    ((WriteOffFieldPanel)this.configPanel.Children[0]).showRowLabel(true);
                }
            }
        }
Esempio n. 3
0
        public void SetTarget(Target target)
        {
            UIElement apanel = getActivePanel();

            if (apanel is WriteOffFieldPanel)
            {
                if (target is Kernel.Domain.Attribute)
                {
                    Kernel.Domain.Attribute attribute  = (Kernel.Domain.Attribute)target;
                    WriteOffFieldPanel      fieldPanel = (WriteOffFieldPanel)apanel;
                    bool isDuplicate = IsDuplicateLine(fieldPanel, SubjectType.ATTRIBUTE, attribute.name, fieldPanel.Index);
                    if (isDuplicate && ItemPresent != null)
                    {
                        ItemPresent(new object[] { SubjectType.ATTRIBUTE, attribute.name });
                    }
                    else
                    {
                        fieldPanel.setAttribute(attribute);
                    }
                }
            }
            else if (apanel is WriteOffFieldValuePanel)
            {
                if (target is Kernel.Domain.Attribute)
                {
                    ((WriteOffFieldValuePanel)apanel).setAttribute((Kernel.Domain.Attribute)target);
                }
                else if (target is Kernel.Domain.AttributeValue)
                {
                    ((WriteOffFieldValuePanel)apanel).setAttributeValue((Kernel.Domain.AttributeValue)target);
                }
            }
        }
Esempio n. 4
0
        private bool IsDuplicateLine(WriteOffFieldPanel fieldPanel, SubjectType subjectType, string name, int index, bool remove = false)
        {
            if (itemDictionnary == null && remove)
            {
                return(false);
            }
            if (itemDictionnary == null)
            {
                itemDictionnary = new Dictionary <string, Dictionary <string, int> >();
            }

            bool containsSubject = itemDictionnary.ContainsKey(subjectType.label);

            if (!containsSubject && remove)
            {
                return(false);
            }
            if (!containsSubject)
            {
                itemDictionnary.Add(subjectType.label, new Dictionary <string, int>());
            }

            Dictionary <string, int> dicolist = null;

            itemDictionnary.TryGetValue(subjectType.label, out dicolist);

            bool containsElement = dicolist.ContainsKey(name);

            if (!containsElement && remove)
            {
                return(false);
            }
            if (remove)
            {
                dicolist.Remove(name);
                return(false);
            }

            if (!containsElement)
            {
                int  position      = dicolist.Count;
                bool shouldReplace = dicolist.ContainsValue(index);
                if (shouldReplace)
                {
                    int    ind     = dicolist.Values.ToList().IndexOf(index);
                    string oldname = dicolist.Keys.ToList()[ind];
                    dicolist.Remove(oldname);
                }
                dicolist.Add(name, index);
                return(false);
            }
            return(true);
        }
Esempio n. 5
0
        private WriteOffFieldPanel getFieldPanel()
        {
            WriteOffFieldPanel wpanel = new WriteOffFieldPanel();

            wpanel.GotFocus           += OnActivate;
            wpanel.ActivateFieldPanel += OnActivateFields;
            wpanel.OnAddFieldValue    += OnAddFielddValue;
            wpanel.OnDeleteFieldValue += OnDeleteFieldsValue;
            wpanel.OnAddField         += OnAddFields;
            wpanel.OnDeleteField      += OnDeleteFields;
            wpanel.ItemChanged        += OnWriteOffConfigChanged;
            return(wpanel);
        }
Esempio n. 6
0
        private void OnDeleteFields(object item)
        {
            if (!(item is WriteOffFieldPanel))
            {
                return;
            }
            WriteOffFieldPanel wPanel = (WriteOffFieldPanel)item;

            if (wPanel.writeOffField != null)
            {
                IsDuplicateLine(wPanel, wPanel.writeOffField.getSubjectType(), wPanel.writeOffField.getName(), wPanel.writeOffField.position, true);
            }
            DeleteAction(wPanel);
            if (ItemChanged != null && wPanel.writeOffField != null)
            {
                ItemChanged(null);
            }
        }
Esempio n. 7
0
        public void setPeriodName(PeriodName periodName)
        {
            UIElement apanel = getActivePanel();

            if (apanel is WriteOffFieldPanel)
            {
                WriteOffFieldPanel fieldPanel = (WriteOffFieldPanel)apanel;
                bool isDuplicate = IsDuplicateLine(fieldPanel, SubjectType.PERIOD, periodName.name, fieldPanel.Index);
                if (isDuplicate && ItemPresent != null)
                {
                    ItemPresent(new object[] { SubjectType.PERIOD, periodName.name });
                }
                else
                {
                    fieldPanel.setPeriodName(periodName);
                }
            }
        }
Esempio n. 8
0
        private void RemoveFromDico(WriteOffFieldPanel fieldPanel, SubjectType subjectType, string name)
        {
            if (itemDictionnary == null)
            {
                return;
            }
            if (!itemDictionnary.ContainsKey(subjectType.label))
            {
                return;
            }
            Dictionary <string, int> dicolist = null;

            itemDictionnary.TryGetValue(subjectType.label, out dicolist);
            if (!dicolist.ContainsKey(name))
            {
                return;
            }
            dicolist.Remove(name);
        }
Esempio n. 9
0
        private void AddAction(WriteOffField writeofffield)
        {
            WriteOffFieldPanel wpanel = getFieldPanel();

            wpanel.parent        = this;
            wpanel.Index         = nbreLigne;
            wpanel.writeOffField = writeofffield;
            wpanel.showRowLabel(nbreLigne == 0);
            if (writeofffield != null)
            {
                string name = writeofffield.isAttribute() ? writeofffield.attributeField.name : writeofffield.isPeriod() ? writeofffield.periodField.name : "";
                if (!string.IsNullOrWhiteSpace(name))
                {
                    IsDuplicateLine(wpanel, writeofffield.isAttribute() ? SubjectType.ATTRIBUTE : SubjectType.PERIOD, name, wpanel.Index);
                }
            }
            wpanel.display();
            nbreLigne++;
            this.setActiveFieldPanel(wpanel);
            this.configPanel.Children.Add(wpanel);
        }