Beispiel #1
0
        public virtual FormIndex incrementIndex(FormIndex index, bool descend)
        {
            System.Collections.ArrayList indexes        = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
            System.Collections.ArrayList multiplicities = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
            System.Collections.ArrayList elements       = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));

            if (index.EndOfFormIndex)
            {
                return(index);
            }
            else if (index.BeginningOfFormIndex)
            {
                if (form.getChildren() == null || form.getChildren().size() == 0)
                {
                    return(FormIndex.createEndOfFormIndex());
                }
            }
            else
            {
                form.collapseIndex(index, indexes, multiplicities, elements);
            }

            incrementHelper(indexes, multiplicities, elements, descend);

            if (indexes.Count == 0)
            {
                return(FormIndex.createEndOfFormIndex());
            }
            else
            {
                return(form.buildIndex(indexes, multiplicities, elements));
            }
        }
Beispiel #2
0
        /// <summary> Returns a hierarchical list of FormEntryCaption objects for the given
        /// FormIndex
        ///
        /// </summary>
        /// <param name="index">
        /// </param>
        /// <returns> list of FormEntryCaptions in hierarchical order
        /// </returns>
        public virtual FormEntryCaption[] getCaptionHierarchy(FormIndex index)
        {
            List <FormEntryCaption> captions = new List <FormEntryCaption>();
            FormIndex remaining = index;

            while (remaining != null)
            {
                remaining = remaining.NextLevel;
                FormIndex    localIndex = index.diff(remaining);
                IFormElement element    = form.getChild(localIndex);
                if (element != null)
                {
                    FormEntryCaption caption = null;
                    if (element is GroupDef)
                    {
                        caption = new FormEntryCaption(Form, localIndex);
                    }
                    else if (element is QuestionDef)
                    {
                        caption = new FormEntryPrompt(Form, localIndex);
                    }

                    if (caption != null)
                    {
                        captions.addElement(caption);
                    }
                }
            }
            FormEntryCaption[] captionArray = new FormEntryCaption[captions.size()];
            captions.copyInto(captionArray);
            return(captionArray);
        }
Beispiel #3
0
 /**
  * Creates a FormEntryCaption for the element at the given index in the form.
  *
  * @param form
  * @param index
  */
 public FormEntryCaption(FormDef form, FormIndex index)
 {
     this.form       = form;
     this.index      = index;
     this.element    = form.getChild(index);
     this.viewWidget = null;
     this.textID     = this.element.TextID;
 }
Beispiel #4
0
 /**
  * Creates a FormEntryPrompt for the element at the given index in the form.
  *
  * @param form
  * @param index
  */
 public FormEntryPrompt(FormDef form, FormIndex index)
     : base(form, index)
 {
     if (!(element is QuestionDef))
     {
         throw new ArgumentException("FormEntryPrompt can only be created for QuestionDef elements");
     }
     this.mTreeElement = form.Instance.resolveReference(index.getReference());
 }
        private void pbClassement_Click(object sender, EventArgs e)
        {
            FormIndex FI = (FormIndex)this.MdiParent;

            FormStatsMorpion FP = new FormStatsMorpion(this);

            FP.MdiParent = FI;

            FP.Show();
        }
Beispiel #6
0
        /**
         * saveAnswer attempts to save the current answer into the data model
         * without doing any constraint checking. Only use this if you know what
         * you're doing. For normal form filling you should always use
         * answerQuestion or answerCurrentQuestion.
         *
         * @param index
         * @param data
         * @return true if saved successfully, false otherwise.
         */
        public Boolean saveAnswer(FormIndex index, IAnswerData data)
        {
            if (model.getEvent(index) != FormEntryController.EVENT_QUESTION)
            {
                throw new SystemException("Non-Question object at the form index.");
            }
            TreeElement element = model.getTreeElement(index);

            return(commitAnswer(element, index, data));
        }
Beispiel #7
0
 /**
  * Set the FormIndex for the current question.
  *
  * @param index
  */
 public void setQuestionIndex(FormIndex index)
 {
     if (!currentFormIndex.Equals(index))
     {
         // See if a hint exists that says we should have a model for this
         // already
         createModelIfNecessary(index);
         currentFormIndex = index;
     }
 }
Beispiel #8
0
 /// <summary> </summary>
 /// <param name="index">
 /// </param>
 /// <returns> Returns the FormEntryPrompt for the specified FormIndex if the
 /// index represents a question.
 /// </returns>
 public virtual FormEntryPrompt getQuestionPrompt(FormIndex index)
 {
     if (form.getChild(index) is QuestionDef)
     {
         return(new FormEntryPrompt(form, index));
     }
     else
     {
         throw new System.SystemException("Invalid query for Question prompt. Non-Question object at the form index");
     }
 }
Beispiel #9
0
 /**
  * Creates a new repeated instance of the group referenced by the specified
  * FormIndex.
  *
  * @param questionIndex
  */
 public void newRepeat(FormIndex questionIndex)
 {
     try
     {
         model.getForm().createNewRepeat(questionIndex);
     }
     catch (InvalidReferenceException ire)
     {
         throw new SystemException("Invalid reference while copying itemset answer: " + ire.Message);
     }
 }
Beispiel #10
0
 /**
  * commitAnswer actually saves the data into the datamodel.
  *
  * @param element
  * @param index
  * @param data
  * @return true if saved successfully, false otherwise
  */
 private Boolean commitAnswer(TreeElement element, FormIndex index, IAnswerData data)
 {
     if (data != null || element.getValue() != null)
     {
         // we should check if the data to be saved is already the same as
         // the data in the model, but we can't (no IAnswerData.equals())
         model.getForm().setValue(data, index.getReference(), element);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #11
0
        private async void buttonLogin_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                try
                {
                    APIService.Username = textBoxUsername.Text;
                    APIService.Password = textBoxLozinka.Text;
                    var korisnik = await _service.Get <List <Model.Korisnik> >(new KorisniciSearchRequest
                    {
                        Username = APIService.Username
                    });

                    Model.Korisnik       provjera = korisnik[0];
                    List <KorisnikUloga> uloge    = provjera.KorisnikUloge.ToList();
                    bool nadjen = false;
                    foreach (var uloga in uloge)
                    {
                        if (uloga.Uloga.Naziv == "Administrator")
                        {
                            nadjen = true;
                        }
                    }
                    if (!nadjen)
                    {
                        MessageBox.Show("Neka se na admin panel loguje samo admninistrator");
                        return;
                    }
                    FormIndex frm = new FormIndex();
                    Dispose(false);
                    frm.Show();
                    MessageBox.Show("Uspjesan login!");
                }
                catch (FlurlHttpException er)
                {
                    if (er.Call.Response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
                    {
                        MessageBox.Show("Pogrešan password ili lozinka!", "Authentication", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show("Server error!", "Authentication", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error", "Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #12
0
        /**
         * Determine if the current FormIndex is relevant. Only relevant indexes
         * should be returned when filling out a form.
         *
         * @param index
         * @return true if current element at FormIndex is relevant
         */
        public Boolean isIndexRelevant(FormIndex index)
        {
            TreeReference ref_             = form.getChildInstanceRef(index);
            Boolean       isAskNewRepeat   = (getEvent(index) == FormEntryController.EVENT_PROMPT_NEW_REPEAT);
            Boolean       isRepeatJuncture = (getEvent(index) == FormEntryController.EVENT_REPEAT_JUNCTURE);

            Boolean relevant;

            if (isAskNewRepeat)
            {
                relevant = form.isRepeatRelevant(ref_) && form.canCreateRepeat(ref_, index);
                //repeat junctures are still relevant if no new repeat can be created; that option
                //is simply missing from the menu
            }
            else if (isRepeatJuncture)
            {
                relevant = form.isRepeatRelevant(ref_);
            }
            else
            {
                TreeElement node = form.Instance.resolveReference(ref_);
                relevant = node.isRelevant(); // check instance flag first
            }

            if (relevant)
            { // if instance flag/condition says relevant, we still
              // have to check the <group>/<repeat> hierarchy

                FormIndex ancestorIndex = index;
                while (!ancestorIndex.isTerminal())
                {
                    // This should be safe now that the TreeReference is contained
                    // in the ancestor index itself
                    TreeElement ancestorNode =
                        form.Instance.resolveReference(ancestorIndex.getLocalReference());

                    if (!ancestorNode.isRelevant())
                    {
                        relevant = false;
                        break;
                    }
                    ancestorIndex = ancestorIndex.getNextLevel();
                }
            }

            return(relevant);
        }
Beispiel #13
0
        /**
         * Given a FormIndex, returns the event this FormIndex represents.
         *
         * @see FormEntryController
         */
        public int getEvent(FormIndex index)
        {
            if (index.isBeginningOfFormIndex())
            {
                return(FormEntryController.EVENT_BEGINNING_OF_FORM);
            }
            else if (index.isEndOfFormIndex())
            {
                return(FormEntryController.EVENT_END_OF_FORM);
            }

            // This came from chatterbox, and is unclear how correct it is,
            // commented out for now.
            // DELETEME: If things work fine
            // Vector defs = form.explodeIndex(index);
            // IFormElement last = (defs.size() == 0 ? null : (IFormElement)
            // defs.lastElement());
            IFormElement element = form.getChild(index);

            if (element is GroupDef)
            {
                if (((GroupDef)element).Repeat)
                {
                    if (repeatStructure != REPEAT_STRUCTURE_NON_LINEAR && form.Instance.resolveReference(form.getChildInstanceRef(index)) == null)
                    {
                        return(FormEntryController.EVENT_PROMPT_NEW_REPEAT);
                    }
                    else if (repeatStructure == REPEAT_STRUCTURE_NON_LINEAR && index.getElementMultiplicity() == TreeReference.INDEX_REPEAT_JUNCTURE)
                    {
                        return(FormEntryController.EVENT_REPEAT_JUNCTURE);
                    }
                    else
                    {
                        return(FormEntryController.EVENT_REPEAT);
                    }
                }
                else
                {
                    return(FormEntryController.EVENT_GROUP);
                }
            }
            else
            {
                return(FormEntryController.EVENT_QUESTION);
            }
        }
Beispiel #14
0
        /**
         * Attempts to save the answer at the specified FormIndex into the
         * datamodel.
         *
         * @param index
         * @param data
         * @return OK if save was successful, error if a constraint was violated.
         */
        public int answerQuestion(FormIndex index, IAnswerData data)
        {
            QuestionDef q = model.getQuestionPrompt(index).getQuestion();

            if (model.getEvent(index) != FormEntryController.EVENT_QUESTION)
            {
                throw new SystemException("Non-Question object at the form index.");
            }
            TreeElement element         = model.getTreeElement(index);
            Boolean     complexQuestion = q.isComplex();

            Boolean hasConstraints = false;

            if (element.required && data == null)
            {
                return(ANSWER_REQUIRED_BUT_EMPTY);
            }
            else if (!complexQuestion && !model.getForm().evaluateConstraint(index.getReference(), data))
            {
                return(ANSWER_CONSTRAINT_VIOLATED);
            }
            else if (!complexQuestion)
            {
                commitAnswer(element, index, data);
                return(ANSWER_OK);
            }
            else if (complexQuestion && hasConstraints)
            {
                //TODO: itemsets: don't currently evaluate constraints for itemset/copy -- haven't figured out how handle it yet
                throw new SystemException("Itemsets do not currently evaluate constraints. Your constraint will not work, please remove it before proceeding.");
            }
            else
            {
                try
                {
                    model.getForm().copyItemsetAnswer(q, element, data);
                }
                catch (InvalidReferenceException ire)
                {
                    Console.WriteLine(ire.StackTrace);
                    throw new SystemException("Invalid reference while copying itemset answer: " + ire.Message);
                }
                return(ANSWER_OK);
            }
        }
Beispiel #15
0
 /**
  * Creates a new entry model for the form with the appropriate
  * repeat structure
  *
  * @param form
  * @param repeatStructure The structure of repeats (the repeat signals which should
  * be sent during form entry)
  * @throws IllegalArgumentException If repeatStructure is not valid
  */
 public FormEntryModel(FormDef form, int repeatStructure)
 {
     this.form = form;
     if (repeatStructure != REPEAT_STRUCTURE_LINEAR && repeatStructure != REPEAT_STRUCTURE_NON_LINEAR)
     {
         throw new ArgumentException(repeatStructure + ": does not correspond to a valid repeat structure");
     }
     //We need to see if there are any guessed repeat counts in the form, which prevents
     //us from being able to use the new repeat style
     //Unfortunately this is probably (A) slow and (B) might overflow the stack. It's not the only
     //recursive walk of the form, though, so (B) isn't really relevant
     if (repeatStructure == REPEAT_STRUCTURE_NON_LINEAR && containsRepeatGuesses(form))
     {
         repeatStructure = REPEAT_STRUCTURE_LINEAR;
     }
     this.repeatStructure  = repeatStructure;
     this.currentFormIndex = FormIndex.createBeginningOfFormIndex();
 }
Beispiel #16
0
        /**
         * Moves the current FormIndex to the next/previous relevant position.
         *
         * @param forward
         * @return
         */
        private int stepEvent(Boolean forward)
        {
            FormIndex index = model.getFormIndex();

            do
            {
                if (forward)
                {
                    index = model.incrementIndex(index);
                }
                else
                {
                    index = model.decrementIndex(index);
                }
            } while (index.isInForm() && !model.isIndexRelevant(index));

            return(jumpToIndex(index));
        }
Beispiel #17
0
        public Boolean isIndexCompoundElement(FormIndex index)
        {
            //Can't be a subquestion if it's not even a question!
            if (getEvent(index) != FormEntryController.EVENT_QUESTION)
            {
                return(false);
            }

            //get the set of nested groups that this question is in.
            FormEntryCaption[] captions = getCaptionHierarchy(index);
            foreach (FormEntryCaption caption in captions)
            {
                //If one of this question's parents is a group, this question is inside of it.
                if (isIndexCompoundContainer(caption.getIndex()))
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #18
0
        /// <param name="index">
        /// </param>
        /// <returns> true if the element at the specified index is read only
        /// </returns>
        public virtual bool isIndexReadonly(FormIndex index)
        {
            if (index.BeginningOfFormIndex || index.EndOfFormIndex)
            {
                return(true);
            }

            TreeReference ref_Renamed    = form.getChildInstanceRef(index);
            bool          isAskNewRepeat = (getEvent(index) == FormEntryController.EVENT_PROMPT_NEW_REPEAT || getEvent(index) == FormEntryController.EVENT_REPEAT_JUNCTURE);

            if (isAskNewRepeat)
            {
                return(false);
            }
            else
            {
                TreeElement node = form.MainInstance.resolveReference(ref_Renamed);
                return(!node.isEnabled());
            }
        }
Beispiel #19
0
        private System.String getRepetitionText(System.String type, FormIndex index, bool newrep)
        {
            if (element is GroupDef && ((GroupDef)element).Repeat && index.ElementMultiplicity >= 0)
            {
                GroupDef g = (GroupDef)element;

                System.String title = LongText;
                int           ix    = index.ElementMultiplicity + 1;
                int           count = NumRepetitions;

                System.String caption = null;
                if ("header".Equals(type))
                {
                    caption = g.entryHeader;
                }
                else if ("choose".Equals(type))
                {
                    caption = g.chooseCaption;
                    if (caption == null)
                    {
                        caption = g.entryHeader;
                    }
                }
                if (caption == null)
                {
                    return(title + " " + ix + "/" + count);
                }


                HashMap <String, Object> vars = new HashMap <String, Object>();
                vars.put("name", title);
                vars.put("i", (System.Int32)ix);
                vars.put("n", (System.Int32)count);
                vars.put("new", newrep);
                return(form.fillTemplateString(caption, index.Reference, vars));
            }
            else
            {
                return(null);
            }
        }
Beispiel #20
0
        public FormIndex[] getCompoundIndices(FormIndex container)
        {
            //ArrayLists are a no-go for J2ME
            List <FormIndex> indices = new List <FormIndex>();
            FormIndex        walker  = incrementIndex(container);

            while (FormIndex.isSubElement(container, walker))
            {
                if (isIndexRelevant(walker))
                {
                    indices.Add(walker);
                }
                walker = incrementIndex(walker);
            }
            FormIndex[] array = new FormIndex[indices.Count];
            for (int i = 0; i < indices.Count; ++i)
            {
                array[i] = indices[i];
            }
            return(array);
        }
Beispiel #21
0
        private String getRepetitionText(String type, FormIndex index, Boolean newrep)
        {
            if (element is GroupDef && ((GroupDef)element).Repeat && index.getElementMultiplicity() >= 0)
            {
                GroupDef g = (GroupDef)element;

                String title = getLongText();
                int    ix    = index.getElementMultiplicity() + 1;
                int    count = getNumRepetitions();

                String caption = null;
                if ("header".Equals(type))
                {
                    caption = g.entryHeader;
                }
                else if ("choose".Equals(type))
                {
                    caption = g.chooseCaption;
                    if (caption == null)
                    {
                        caption = g.entryHeader;
                    }
                }
                if (caption == null)
                {
                    return(title + " " + ix + "/" + count);
                }

                IDictionary <String, Object> vars = new Dictionary <String, Object>();
                vars.Add("name", title);
                vars.Add("i", ix);
                vars.Add("n", count);
                vars.Add("new", newrep);
                return(form.fillTemplateString(caption, index.getReference(), vars));
            }
            else
            {
                return(null);
            }
        }
Beispiel #22
0
 /// <summary> For the current index: Checks whether the index represents a node which
 /// should exist given a non-interactive repeat, along with a count for that
 /// repeat which is beneath the dynamic level specified.
 ///
 /// If this index does represent such a node, the new model for the repeat is
 /// created behind the scenes and the index for the initial question is
 /// returned.
 ///
 /// Note: This method will not prevent the addition of new repeat elements in
 /// the interface, it will merely use the xforms repeat hint to create new
 /// nodes that are assumed to exist
 ///
 /// </summary>
 /// <param name="index">The index to be evaluated as to whether the underlying model is
 /// hinted to exist
 /// </param>
 private void  createModelIfNecessary(FormIndex index)
 {
     if (index.InForm)
     {
         IFormElement e = Form.getChild(index);
         if (e is GroupDef)
         {
             GroupDef g = (GroupDef)e;
             if (g.Repeat && g.CountReference != null)
             {
                 // Lu Gram: repeat count XPath needs to be contextualized for nested repeat groups
                 TreeReference countRef       = FormInstance.unpackReference(g.CountReference);
                 TreeReference contextualized = countRef.contextualize(index.Reference);
                 IAnswerData   count          = Form.MainInstance.resolveReference(contextualized).getValue();
                 if (count != null)
                 {
                     long          fullcount   = ((System.Int32)count.Value);
                     TreeReference ref_Renamed = Form.getChildInstanceRef(index);
                     TreeElement   element     = Form.MainInstance.resolveReference(ref_Renamed);
                     if (element == null)
                     {
                         if (index.getTerminal().InstanceIndex < fullcount)
                         {
                             try
                             {
                                 Form.createNewRepeat(index);
                             }
                             catch (InvalidReferenceException ire)
                             {
                                 SupportClass.WriteStackTrace(ire, Console.Error);
                                 //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                                 throw new System.SystemException("Invalid Reference while creting new repeat!" + ire.Message);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
        private void pbRetour_Click(object sender, EventArgs e)
        {
            FormIndex FI = (FormIndex)this.MdiParent;

            if (arrivage == "index")
            {
                FI.PictureBox1.Visible = true;
                var pos = FI.PointToScreen(FI.LblCreateur.Location);
                pos = FI.PictureBox1.PointToClient(pos);
                FI.LblCreateur.Parent    = FI.PictureBox1;
                FI.LblCreateur.Location  = pos;
                FI.LblCreateur.BackColor = Color.Transparent;
            }

            if (arrivage == "liste")
            {
                FormListe FS = new FormListe();
                FS.MdiParent = FI;

                FS.Show();
            }

            if (arrivage == "miniature")
            {
                FormMiniature FS = new FormMiniature();
                FS.MdiParent = FI;

                FS.Show();
            }

            if (arrivage == "arborescence")
            {
                FormArborescence FS = new FormArborescence();
                FS.MdiParent = FI;

                FS.Show();
            }

            this.Close();
        }
Beispiel #24
0
 /**
  * For the current index: Checks whether the index represents a node which
  * should exist given a non-interactive repeat, along with a count for that
  * repeat which is beneath the dynamic level specified.
  *
  * If this index does represent such a node, the new model for the repeat is
  * created behind the scenes and the index for the initial question is
  * returned.
  *
  * Note: This method will not prevent the addition of new repeat elements in
  * the interface, it will merely use the xforms repeat hint to create new
  * nodes that are assumed to exist
  *
  * @param The index to be evaluated as to whether the underlying model is
  *        hinted to exist
  */
 private void createModelIfNecessary(FormIndex index)
 {
     if (index.isInForm())
     {
         IFormElement e = getForm().getChild(index);
         if (e is GroupDef)
         {
             GroupDef g = (GroupDef)e;
             if (g.Repeat && g.CountReference != null)
             {
                 IAnswerData count = getForm().Instance.getDataValue(g.CountReference);
                 if (count != null)
                 {
                     long          fullcount = ((int)count.Value);
                     TreeReference ref_      = getForm().getChildInstanceRef(index);
                     TreeElement   element   = getForm().Instance.resolveReference(ref_);
                     if (element == null)
                     {
                         if (index.getInstanceIndex() < fullcount)
                         {
                             try
                             {
                                 getForm().createNewRepeat(index);
                             }
                             catch (InvalidReferenceException ire)
                             {
                                 Console.WriteLine(ire.StackTrace);
                                 throw new SystemException("Invalid Reference while creting new repeat!" + ire.Message);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #25
0
        private void toolStripMenuItemTreeViewAdd_Click(object sender, EventArgs e)
        {
            Refresh();
            treeList.BeginUpdate();

            Node treeListNode = treeList.SelectedNode;

            Type type = treeListNode.Tag.GetType();

            if (type == typeof (Table[]) ||
                type == typeof (View[]) ||
                type == typeof (StoredProcedure[]))
            {
                Model.Database parent = (Model.Database) treeListNode.Parent.Tag;
                FormScriptObject form = new FormScriptObject((ScriptObject[]) treeListNode.Tag, parent);

                if (form.ShowDialog(ParentForm) == DialogResult.OK)
                {
                    Interfaces.Events.SetCursor(Cursors.WaitCursor);
                    parent.AddScriptObject(form.ScriptObject);

                    Node newTreeListNode = AddNode(treeListNode, "", form.ScriptObject, Images.GreenBullet, true,
                                                                         form.ScriptObject.Enabled);
                    GetTreeListNodeText(form.ScriptObject, newTreeListNode);
                    SetupNewTreeListNode(newTreeListNode, form.ScriptObject);

                    if (type == typeof (Table[]))
                    {
                        treeListNode.Tag = parent.Tables;
                    }
                    if (type == typeof (View[]))
                    {
                        treeListNode.Tag = parent.Views;
                    }
                    if (type == typeof (StoredProcedure[]))
                    {
                        treeListNode.Tag = parent.StoredProcedures;
                    }
                    ProcessTreeValidity(treeList.Nodes);
                    Interfaces.Events.SetCursor(Cursors.Default);
                }
            }
            else if (type == typeof (Column[]))
            {
                ScriptObject parent = (ScriptObject) treeListNode.Parent.Tag;
                FormColumn form = new FormColumn(parent);

                if (form.ShowDialog(ParentForm) == DialogResult.OK)
                {
                    Interfaces.Events.SetCursor(Cursors.WaitCursor);
                    parent.AddColumn(form.Column);

                    Node newTreeListNode = AddNode(treeListNode, "", form.Column, Images.GreenBullet, true,
                                                                         form.Column.Enabled);
                    GetTreeListNodeText(form.Column, newTreeListNode);

                    treeListNode.Tag = parent.Columns;
                    ProcessTreeValidity(treeList.Nodes);
                    Interfaces.Events.SetCursor(Cursors.Default);
                }
            }
            else if (type == typeof(Lookup[]))
            {
                Model.Database database = (Model.Database)treeListNode.Parent.Tag;
                FormLookup form = new FormLookup(database);

                if (form.ShowDialog(ParentForm) == DialogResult.OK)
                {
                    Interfaces.Events.SetCursor(Cursors.WaitCursor);
                    Node newTreeListNode = AddLookupNode(treeListNode, form.Lookup, Images.GreenBullet);
                    treeListNode.Tag = database.Lookups;
                    Interfaces.Events.SetCursor(Cursors.Default);
                    treeList.SelectNode(newTreeListNode, eTreeAction.Code);
                }
            }
            else if (type == typeof (OneToOneRelationship[]) ||
                     type == typeof (OneToManyRelationship[]) ||
                     type == typeof (ManyToOneRelationship[]) ||
                     type == typeof (ManyToManyRelationship[]))
            {
                ScriptObject parent = (ScriptObject) treeListNode.Parent.Parent.Tag;

                Type relationshipType = null;
                if (type == typeof (OneToOneRelationship[]))
                {
                    relationshipType = typeof (OneToOneRelationship);
                }

                if (type == typeof (ManyToOneRelationship[]))
                {
                    relationshipType = typeof (ManyToOneRelationship);
                }

                if (type == typeof (OneToManyRelationship[]))
                {
                    relationshipType = typeof (OneToManyRelationship);
                }

                if (type == typeof (ManyToManyRelationship[]))
                {
                    relationshipType = typeof (ManyToManyRelationship);
                }
                FormRelationship form = new FormRelationship(relationshipType, (ScriptObject) treeListNode.Parent.Parent.Tag,
                                                             ProviderInfo.TheBllDatabase.EnabledScriptObjects);

                if (form.ShowDialog(ParentForm) == DialogResult.OK)
                {
                    Interfaces.Events.SetCursor(Cursors.WaitCursor);
                    ScriptObject primaryScriptObject = form.PrimaryRelationship.Parent;
                    primaryScriptObject.AddRelationship(form.PrimaryRelationship);

                    ScriptObject foreignScriptObject = form.ForeignRelationship.Parent;
                    foreignScriptObject.AddRelationship(form.ForeignRelationship);

                    Node newTreeListNode = AddNode(treeListNode, "", form.PrimaryRelationship, Images.GreenBullet,
                                                                         true, form.PrimaryRelationship.Enabled);
                    GetTreeListNodeText(form.PrimaryRelationship, newTreeListNode);

                    if (type == typeof (OneToOneRelationship[]))
                    {
                        treeListNode.Tag = parent.OneToOneRelationships;
                    }

                    if (type == typeof (ManyToOneRelationship[]))
                    {
                        treeListNode.Tag = parent.ManyToOneRelationships;
                    }

                    if (type == typeof (OneToManyRelationship[]))
                    {
                        treeListNode.Tag = parent.OneToManyRelationships;
                    }

                    if (type == typeof (ManyToManyRelationship[]))
                    {
                        treeListNode.Tag = parent.ManyToManyRelationships;
                    }

                    LoadTreeListNode(foreignScriptObject);
                    ProcessTreeValidity(treeList.Nodes);
                    Interfaces.Events.SetCursor(Cursors.Default);
                }
                if (form.FilterWasCreated)
                {
                    LoadTreeView();
                }
            }
            else if (type == typeof (Filter[]))
            {
                Model.Database database = (Model.Database) treeListNode.Parent.Parent.Parent.Tag;
                ScriptObject parent = (ScriptObject) treeListNode.Parent.Tag;

                FormFilter2 form;

                // Stored Procedure Filters can only be created from other Stored Procedures (Enabled or Disabled)
                if (parent.GetType() == typeof (StoredProcedure))
                {
                    form = new FormFilter2(ParentForm, parent);
                }
                else
                {
                    form = new FormFilter2(ParentForm, parent);
                }
                if (form.ShowDialog(ParentForm) == DialogResult.OK)
                {
                    Interfaces.Events.SetCursor(Cursors.WaitCursor);
                    parent.AddFilter(form.TheFilter);

                    Node newTreeListNode = AddNode(treeListNode, "", form.TheFilter, Images.GreenBullet, true,
                                                                         form.TheFilter.Enabled);
                    GetTreeListNodeText(form.TheFilter, newTreeListNode);

                    treeListNode.Tag = parent.Filters;

                    ProcessTreeValidity(treeList.Nodes);
                    Interfaces.Events.SetCursor(Cursors.Default);
                }
            }
            else if (type == typeof (Index[]))
            {
                Table parent = (Table) treeListNode.Parent.Tag;
                FormIndex form = new FormIndex((Table) treeListNode.Parent.Tag);

                if (form.ShowDialog(ParentForm) == DialogResult.OK)
                {
                    Interfaces.Events.SetCursor(Cursors.WaitCursor);
                    parent.AddIndex(form.Index);

                    Node newTreeListNode = AddNode(treeListNode, "", form.Index, Images.GreenBullet, true,
                                                                         form.Index.Enabled);
                    GetTreeListNodeText(form.Index, newTreeListNode);

                    treeListNode.Tag = parent.Indexes;

                    ProcessTreeValidity(treeList.Nodes);
                    Interfaces.Events.SetCursor(Cursors.Default);
                }
            }
            else if (type == typeof (Key[]))
            {
                Table parent = (Table) treeListNode.Parent.Tag;
                FormKey form = new FormKey((Table) treeListNode.Parent.Tag);

                if (form.ShowDialog(ParentForm) == DialogResult.OK)
                {
                    Interfaces.Events.SetCursor(Cursors.WaitCursor);
                    parent.AddKey(form.Key);

                    Node newTreeListNode = AddNode(treeListNode, "", form.Key, Images.GreenBullet, true,
                                                                         form.Key.Enabled);
                    GetTreeListNodeText(form.Key, newTreeListNode);

                    treeListNode.Tag = parent.Keys;

                    ProcessTreeValidity(treeList.Nodes);
                    Interfaces.Events.SetCursor(Cursors.Default);
                }
            }
            else if (type == typeof (List<Association>))
            {
                ScriptObject parent = (ScriptObject) treeListNode.Parent.Tag;

                frmAssociationWizard.Association = new Association((ScriptObject) treeListNode.Parent.Tag);
                frmAssociationWizard.Association.Enabled = true;
                frmAssociationWizard form = new frmAssociationWizard();

                if (form.ShowDialog(ParentForm) == DialogResult.OK)
                {
                    Interfaces.Events.SetCursor(Cursors.WaitCursor);
                    parent.AddAssociation(frmAssociationWizard.Association);

                    Node newTreeListNode = AddNode(treeListNode,
                                                                         frmAssociationWizard.Association.Name,
                                                                         frmAssociationWizard.Association,
                                                                         Images.GreenBullet, true,
                                                                         frmAssociationWizard.Association.Enabled);
                    treeListNode.Tag = parent.Associations;

                    ProcessTreeValidity(treeList.Nodes);
                    Interfaces.Events.SetCursor(Cursors.Default);
                    treeListNode.Expanded = true;
                    treeList.SelectedNode = newTreeListNode;
                }
            }
            treeList.EndUpdate();
        }
        private void FormProjetMorpion_Enter(object sender, EventArgs e)
        {
            FormIndex form = (FormIndex)this.MdiParent;

            this.WindowState = FormWindowState.Maximized;
        }
        private void FormStatsMorpion_Load(object sender, EventArgs e)
        {
            FormIndex form = (FormIndex)this.MdiParent;

            LangueElement   = Fonction.LangageAppli();
            this.Text       = LangueElement[161];
            lblStats.Text   = LangueElement[161];
            lblInfoVDR.Text = LangueElement[162];

            var pos = this.PointToScreen(pbClassement.Location);

            pos = this.PointToClient(pos);
            pbClassement.Parent    = this;
            pbClassement.Location  = pos;
            pbClassement.BackColor = Color.Transparent;

            List <string> ListeStats = new List <string>();

            ListeStats = Fonction.LireStatsProjetJeu(@"..\..\FormsCompetence\Morpion\StatsMorpion.txt"); // J | V | D | R

            int i = 0;
            int l = 0;

            foreach (var item in ListeStats)
            {
                l++;
            }

            List <string> ListeTrieUnique = new List <string>();

            foreach (var item in ListeStats)
            {
                string[] result = Regex.Split(item, @"\|");

                ListeTrieUnique.Add(result[3]);
            }

            ListeTrieUnique.Sort((a, b) => - 1 * a.CompareTo(b)); // descending sort

            List <string> ListeTrieFini = new List <string>();

            foreach (var item in ListeTrieUnique)
            {
                foreach (var item2 in ListeStats)
                {
                    string[] result = Regex.Split(item2, @"\|");

                    if (item == result[3])
                    {
                        ListeTrieFini.Add(result[0] + "|" + result[1] + "|" + result[2] + "|" + result[3]);
                        ListeStats.Remove(result[0] + "|" + result[1] + "|" + result[2] + "|" + result[3]);
                        break;
                    }
                }
            }


            foreach (var item in ListeTrieFini)
            {
                string[] result = Regex.Split(item, @"\|");

                if (i <= 9)
                {
                    Label lblJoueur      = new Label();
                    Label lblStatsJoueur = new Label();
                    lblJoueur.Text      = result[0];
                    lblStatsJoueur.Text = "V : " + result[1] + " | D : " + result[2] + " | R : " + result[3];
                    lblJoueur.Font      = new Font("Palatino Linotype", lblJ1.Font.SizeInPoints, FontStyle.Bold);
                    lblStatsJoueur.Font = new Font("Palatino Linotype", lblJ1bis.Font.SizeInPoints);
                    lblJoueur.BackColor = Color.Transparent;
                    lblJoueur.AutoSize  = true;
                    lblJoueur.Visible   = true;

                    if (i == 0)
                    {
                        lblJoueur.SetBounds(445, 87, 200, 10);
                        lblStatsJoueur.SetBounds(415, 105, 200, 10);
                        this.Controls.Add(lblJoueur);
                        this.Controls.Add(lblStatsJoueur);
                    }
                    else if (i == 1)
                    {
                        lblJoueur.SetBounds(298, 130, 200, 10);
                        lblStatsJoueur.SetBounds(268, 148, 200, 10);
                        this.Controls.Add(lblJoueur);
                        this.Controls.Add(lblStatsJoueur);
                    }
                    else if (i == 2)
                    {
                        lblJoueur.SetBounds(589, 138, 200, 10);
                        lblStatsJoueur.SetBounds(559, 156, 200, 10);
                        this.Controls.Add(lblJoueur);
                        this.Controls.Add(lblStatsJoueur);
                    }
                    else if (i == 3)
                    {
                        if (l == 6 || l == 5 || l == 4)
                        {
                            lblJoueur.SetBounds(130, 0, 200, 10);
                            lblStatsJoueur.SetBounds(130, 20, 200, 10);
                            label1.SetBounds(110, 0, 200, 10);
                            panel1.Controls.Add(label1);
                            panel1.Controls.Add(lblJoueur);
                            panel1.Controls.Add(lblStatsJoueur);
                        }
                        else
                        {
                            lblJoueur.SetBounds(0, 0, 200, 10);
                            lblStatsJoueur.SetBounds(0, 20, 200, 10);
                            panel1.Controls.Add(lblJoueur);
                            panel1.Controls.Add(lblStatsJoueur);
                        }
                    }
                    else if (i == 4)
                    {
                        if (l == 6 || l == 5 || l == 4)
                        {
                            lblJoueur.SetBounds(130, 60, 200, 10);
                            lblStatsJoueur.SetBounds(130, 80, 200, 10);
                            label2.SetBounds(110, 60, 200, 10);
                            panel1.Controls.Add(label2);
                            panel1.Controls.Add(lblJoueur);
                            panel1.Controls.Add(lblStatsJoueur);
                        }
                        else
                        {
                            lblJoueur.SetBounds(0, 60, 200, 10);
                            lblStatsJoueur.SetBounds(0, 80, 200, 10);
                            panel1.Controls.Add(lblJoueur);
                            panel1.Controls.Add(lblStatsJoueur);
                        }
                    }
                    else if (i == 5)
                    {
                        if (l == 6 || l == 5 || l == 4)
                        {
                            lblJoueur.SetBounds(130, 120, 200, 10);
                            lblStatsJoueur.SetBounds(130, 140, 200, 10);
                            label3.SetBounds(110, 120, 200, 10);
                            panel1.Controls.Add(label3);
                            panel1.Controls.Add(lblJoueur);
                            panel1.Controls.Add(lblStatsJoueur);
                        }
                        else
                        {
                            lblJoueur.SetBounds(0, 120, 200, 10);
                            lblStatsJoueur.SetBounds(0, 140, 200, 10);
                            panel1.Controls.Add(lblJoueur);
                            panel1.Controls.Add(lblStatsJoueur);
                        }
                    }
                    else if (i == 6)
                    {
                        lblJoueur.SetBounds(235, 0, 200, 10);
                        lblStatsJoueur.SetBounds(235, 20, 200, 10);
                        label6.SetBounds(215, 0, 200, 10);
                        panel1.Controls.Add(label6);
                        panel1.Controls.Add(lblJoueur);
                        panel1.Controls.Add(lblStatsJoueur);
                    }

                    else if (i == 7)
                    {
                        lblJoueur.SetBounds(235, 60, 200, 10);
                        lblStatsJoueur.SetBounds(235, 80, 200, 10);
                        label5.SetBounds(215, 60, 200, 10);
                        panel1.Controls.Add(label5);
                        panel1.Controls.Add(lblJoueur);
                        panel1.Controls.Add(lblStatsJoueur);
                    }
                    else if (i == 8)
                    {
                        lblJoueur.SetBounds(235, 120, 200, 10);
                        lblStatsJoueur.SetBounds(235, 140, 200, 10);
                        label4.SetBounds(215, 120, 200, 10);
                        panel1.Controls.Add(label4);
                        panel1.Controls.Add(lblJoueur);
                        panel1.Controls.Add(lblStatsJoueur);
                    }


                    lblJoueur.BringToFront();
                    lblStatsJoueur.BackColor = Color.Transparent;
                    lblStatsJoueur.AutoSize  = true;
                    lblStatsJoueur.Visible   = true;

                    lblStatsJoueur.BringToFront();


                    if (i == 0 || i == 1 || i == 2)
                    {
                        var pos4 = this.PointToScreen(lblJoueur.Location);
                        pos4                = pbClassement.PointToClient(pos4);
                        lblJoueur.Parent    = pbClassement;
                        lblJoueur.Location  = pos4;
                        lblJoueur.BackColor = Color.Transparent;

                        var pos5 = this.PointToScreen(lblStatsJoueur.Location);
                        pos5 = pbClassement.PointToClient(pos5);
                        lblStatsJoueur.Parent    = pbClassement;
                        lblStatsJoueur.Location  = pos5;
                        lblStatsJoueur.BackColor = Color.Transparent;
                    }
                }

                i++;
            }

            if (i == 8)
            {
                label1.Visible = true;
                label2.Visible = true;
                label3.Visible = true;
                label6.Visible = true;
                label5.Visible = true;
                label4.Visible = true;
            }

            if (i == 8)
            {
                label1.Visible = true;
                label2.Visible = true;
                label3.Visible = true;
                label6.Visible = true;
                label5.Visible = true;
                label4.Visible = false;
            }

            if (i == 7)
            {
                label1.Visible = true;
                label2.Visible = true;
                label3.Visible = true;
                label6.Visible = true;
                label5.Visible = false;
                label4.Visible = false;
            }

            if (i == 6)
            {
                label1.Visible = true;
                label2.Visible = true;
                label3.Visible = true;
                label6.Visible = false;
                label5.Visible = false;
                label4.Visible = false;
            }

            if (i == 5)
            {
                label1.Visible = true;
                label2.Visible = true;
                label3.Visible = false;
                label6.Visible = false;
                label5.Visible = false;
                label4.Visible = false;
            }

            if (i == 4)
            {
                label1.Visible = true;
                label2.Visible = false;
                label3.Visible = false;
                label6.Visible = false;
                label5.Visible = false;
                label4.Visible = false;
            }

            if (i == 3 || i == 2 || i == 1 || i == 0)
            {
                label1.Visible = false;
                label2.Visible = false;
                label3.Visible = false;
                label6.Visible = false;
                label5.Visible = false;
                label4.Visible = false;
            }

            Fonction.policeTexte(this); // Gestion police
        }
Beispiel #28
0
 /**
  *
  * @param index
  * @return
  */
 public TreeElement getTreeElement(FormIndex index)
 {
     return(form.Instance.resolveReference(index.getReference()));
 }
Beispiel #29
0
 /**
  * When you have a non-question event, a CaptionPrompt will have all the
  * information needed to display to the user.
  *
  * @param index
  * @return Returns the FormEntryCaption for the given FormIndex if is not a
  *         question.
  */
 public FormEntryCaption getCaptionPrompt(FormIndex index)
 {
     return(new FormEntryCaption(form, index));
 }
Beispiel #30
0
        private void toolStripMenuItemTreeViewEdit_Click(object sender, EventArgs e)
        {
            Refresh();
            Node treeListNode = treeList.SelectedNode;
            Type type = treeListNode.Tag.GetType();

            if (type == typeof(Lookup))
            {
                try
                {
                    Interfaces.Events.SetCursor(Cursors.WaitCursor);
                    this.Refresh();
                    FormLookup form = new FormLookup((Lookup)treeListNode.Tag);

                    if (form.ShowDialog(ParentForm) == DialogResult.OK)
                    {
                        treeList.BeginUpdate();
                        treeListNode.Text = form.Lookup.Alias;
                        treeListNode.Tag = form.Lookup;
                        treeList.EndUpdate();
                        return;
                    }
                }
                finally
                {
                    Interfaces.Events.UnShadeMainForm();
                    Interfaces.Events.RaiseRefreshApplicationEvent();
                    Interfaces.Events.SetCursor(Cursors.Default);
                    this.Refresh();
                }
            }
            else if (type == typeof (Option))
            {
                IOption option = (IOption) treeListNode.Tag;
                IUserOption userOption;
                object parentObject = treeListNode.Parent.Parent.Tag;
                Type parentType = parentObject.GetType();

                Type scriptBaseInterface = typeof (IScriptBaseObject);

                if (scriptBaseInterface.IsInstanceOfType(parentObject))
                {
                    IScriptBaseObject parentScriptObject = (IScriptBaseObject) parentObject;

                    for (int i = 0; i < parentScriptObject.Ex.Count; i++)
                    {
                        if (parentScriptObject.Ex[i].Name == option.VariableName)
                        {
                            userOption = parentScriptObject.Ex[i];
                            FormVirtualPropertyEdit form = new FormVirtualPropertyEdit(userOption,
                                                                                                                               parentScriptObject);

                            if (form.ShowDialog(ParentForm) == DialogResult.OK)
                            {
                                Interfaces.Events.UnShadeMainForm();
                                Interfaces.Events.RaiseRefreshApplicationEvent();
                                Interfaces.Events.SetCursor(Cursors.WaitCursor);
                                treeList.BeginUpdate();
                                ProcessTreeValidity(treeList.Nodes);
                                treeList.EndUpdate();
                                Interfaces.Events.SetCursor(Cursors.Default);
                            }
                            break;
                        }
                    }
                    return;
                }
                if (parentType == typeof (Column))
                {
                    Column parentColumn = (Column) parentObject;

                    for (int i = 0; i < parentColumn.Ex.Count; i++)
                    {
                        if (parentColumn.Ex[i].Name == option.VariableName)
                        {
                            userOption = parentColumn.Ex[i];
                            FormVirtualPropertyEdit form = new FormVirtualPropertyEdit(userOption,
                                                                                                                               parentColumn);

                            if (form.ShowDialog(ParentForm) == DialogResult.OK)
                            {
                                Interfaces.Events.UnShadeMainForm();
                                Interfaces.Events.RaiseRefreshApplicationEvent();
                                Interfaces.Events.SetCursor(Cursors.WaitCursor);
                                treeList.BeginUpdate();
                                parentColumn.Ex[i].Value = form.VirtualProperty.Value;
                                treeList.SelectedNode.Cells[1].Text = form.VirtualProperty.Value.ToString();
                                ProcessTreeValidity(treeList.Nodes);
                                treeList.EndUpdate();
                                Interfaces.Events.SetCursor(Cursors.Default);
                            }
                            break;
                        }
                    }
                    return;
                }
            }
            if (type == typeof (Association))
            {
                frmAssociationWizard.Association = (Association) treeListNode.Tag;
                frmAssociationWizard form = new frmAssociationWizard();

                if (form.ShowDialog(ParentForm) == DialogResult.OK)
                {
                    Interfaces.Events.UnShadeMainForm();
                    Interfaces.Events.RaiseRefreshApplicationEvent();
                    Interfaces.Events.SetCursor(Cursors.WaitCursor);
                    treeList.BeginUpdate();
                    treeListNode.Cells[1].Text = frmAssociationWizard.Association.Name;
                    treeListNode.Tag = frmAssociationWizard.Association;
                    SetNodeImage(treeListNode, Images.GreenBullet);

                    foreach (Model.Database database in ProviderInfo.TheBllDatabase.Databases)
                    {
                        database.SnapshotMode = true;
                    }
                    ProcessTreeValidity(treeList.Nodes);
                    treeList.EndUpdate();

                    foreach (Model.Database database in ProviderInfo.TheBllDatabase.Databases)
                    {
                        database.SnapshotMode = false;
                    }
                    Interfaces.Events.RaiseIsDirtyEvent();
                    Interfaces.Events.SetCursor(Cursors.Default);
                    return;
                }
                return;
            }
            ScriptBase scriptBase = (ScriptBase) treeListNode.Tag;

            if (type == typeof (Table) ||
                type == typeof (View) ||
                type == typeof (StoredProcedure))
            {
                FormScriptObject form = new FormScriptObject((ScriptObject) scriptBase, (ScriptObject[]) treeListNode.Parent.Tag);

                if (form.ShowDialog(ParentForm) == DialogResult.OK)
                {
                    Interfaces.Events.UnShadeMainForm();
                    Interfaces.Events.RaiseRefreshApplicationEvent();
                    Interfaces.Events.SetCursor(Cursors.WaitCursor);
                    treeList.BeginUpdate();
                    UpdateTreeListNodeText(treeListNode, form.ScriptObject);

                    foreach (Model.Database database in ProviderInfo.TheBllDatabase.Databases)
                    {
                        database.SnapshotMode = true;
                    }
                    ProcessTreeValidity(treeList.Nodes);
                    treeList.EndUpdate();

                    foreach (Model.Database database in ProviderInfo.TheBllDatabase.Databases)
                    {
                        database.SnapshotMode = false;
                    }
                    Interfaces.Events.SetCursor(Cursors.Default);
                    return;
                }
            }
            else if (type == typeof (Column))
            {
                FormColumn form = new FormColumn((Column) scriptBase);

                if (form.ShowDialog(ParentForm) == DialogResult.OK)
                {
                    Interfaces.Events.UnShadeMainForm();
                    Interfaces.Events.RaiseRefreshApplicationEvent();
                    Interfaces.Events.SetCursor(Cursors.WaitCursor);
                    treeList.BeginUpdate();
                    UpdateTreeListNodeText(treeListNode, form.Column);
                    ProcessTreeValidity(treeList.Nodes);
                    treeList.EndUpdate();
                    Interfaces.Events.SetCursor(Cursors.Default);
                    return;
                }
            }
            else if (ModelTypes.MapColumn == type)
            {
                FormMapColumn form = new FormMapColumn((ScriptObject) treeListNode.Parent.Parent.Tag, (MapColumn) scriptBase);

                if (form.ShowDialog(ParentForm) == DialogResult.OK)
                {
                    Interfaces.Events.UnShadeMainForm();
                    Interfaces.Events.RaiseRefreshApplicationEvent();
                    Interfaces.Events.SetCursor(Cursors.WaitCursor);
                    treeList.BeginUpdate();

                    UpdateTreeListNodeText(treeListNode, form.MapColumn);
                    ProcessTreeValidity(treeList.Nodes);
                    treeList.EndUpdate();
                    Interfaces.Events.SetCursor(Cursors.Default);
                    return;
                }
            }
            else if (type.BaseType == typeof (Relationship))
            {
                FormRelationship form = new FormRelationship((Relationship) scriptBase, ProviderInfo.TheBllDatabase.AllScriptObjects);

                if (form.ShowDialog(ParentForm) == DialogResult.OK)
                {
                    Interfaces.Events.UnShadeMainForm();
                    Interfaces.Events.RaiseRefreshApplicationEvent();
                    Interfaces.Events.SetCursor(Cursors.WaitCursor);
                    treeList.BeginUpdate();
                    UpdateTreeListNodeText(treeListNode, form.PrimaryRelationship);
                    ProcessTreeValidity(treeList.Nodes);
                    treeList.EndUpdate();
                    Interfaces.Events.SetCursor(Cursors.Default);
                    return;
                }
            }
            else if (type == typeof (Filter))
            {
                Model.Database database = (Model.Database) treeListNode.Parent.Parent.Parent.Parent.Tag;
                Filter filter = (Filter) scriptBase;

                FormFilter2 form;
                // Stored Procedure Filters can only be created from other Stored Procedures (Enabled or Disabled)
                if (filter.Parent.GetType() == typeof (StoredProcedure))
                {
                    form = new FormFilter2(ParentForm, filter);
                }
                else
                {
                    form = new FormFilter2(ParentForm, filter);
                }
                if (form.ShowDialog(ParentForm) == DialogResult.OK)
                {
                    Interfaces.Events.UnShadeMainForm();
                    Interfaces.Events.RaiseRefreshApplicationEvent();
                    Interfaces.Events.SetCursor(Cursors.WaitCursor);
                    treeList.BeginUpdate();
                    UpdateTreeListNodeText(treeListNode, form.TheFilter);
                    ProcessTreeValidity(treeList.Nodes);
                    treeList.EndUpdate();
                    Interfaces.Events.SetCursor(Cursors.Default);
                    return;
                }
            }
            else if (type == typeof (Index))
            {
                FormIndex form = new FormIndex((Index) scriptBase);

                if (form.ShowDialog(ParentForm) == DialogResult.OK)
                {
                    Interfaces.Events.UnShadeMainForm();
                    Interfaces.Events.RaiseRefreshApplicationEvent();
                    Interfaces.Events.SetCursor(Cursors.WaitCursor);
                    treeList.BeginUpdate();
                    UpdateTreeListNodeText(treeListNode, form.Index);
                    ProcessTreeValidity(treeList.Nodes);
                    treeList.EndUpdate();
                    Interfaces.Events.SetCursor(Cursors.Default);
                    return;
                }
            }
            else if (type == typeof (Key))
            {
                FormKey form = new FormKey((Key) scriptBase);

                if (form.ShowDialog(ParentForm) == DialogResult.OK)
                {
                    Interfaces.Events.UnShadeMainForm();
                    Interfaces.Events.RaiseRefreshApplicationEvent();
                    Interfaces.Events.SetCursor(Cursors.WaitCursor);
                    treeList.BeginUpdate();
                    UpdateTreeListNodeText(treeListNode, form.Key);
                    ProcessTreeValidity(treeList.Nodes);
                    treeList.EndUpdate();
                    Interfaces.Events.SetCursor(Cursors.Default);
                    return;
                }
            }
        }
Beispiel #31
0
        private void toolStripMenuItemTreeViewEdit_Click(object sender, EventArgs e)
        {
            TreeListNode treeListNode = treeList.FocusedNode;
            Type type = treeListNode.Tag.GetType();

            if (type == typeof(Slyce.TemplateInfo.Option))
            {
                Slyce.ITemplate.IOption option = (Slyce.ITemplate.IOption)treeListNode.Tag;
                Slyce.ITemplate.IUserOption userOption = null;
                object parentObject = treeListNode.ParentNode.ParentNode.Tag;
                Type parentType = parentObject.GetType();

                if (parentType == typeof(ArchAngel.Providers.Database.Model.Table) ||
                parentType == typeof(ArchAngel.Providers.Database.Model.View) ||
                parentType == typeof(ArchAngel.Providers.Database.Model.StoredProcedure))
                {
                    ArchAngel.Providers.Database.Model.ScriptObject parentScriptObject = (ArchAngel.Providers.Database.Model.ScriptObject)parentObject;

                    for (int i = 0; i < parentScriptObject.UserOptions.Count; i++)
                    {
                        if (parentScriptObject.UserOptions[i].Name == option.VariableName)
                        {
                            userOption = parentScriptObject.UserOptions[i];
                            FormObjectOptionEdit form = new FormObjectOptionEdit(option, userOption, parentScriptObject);

                            if (form.ShowDialog(this.ParentForm) == DialogResult.OK)
                            {
                                Controller.MainForm.Cursor = Cursors.WaitCursor;
                                parentScriptObject.UserOptions[i].Value = form.UserOption.Value;
                                treeList.Selection[0].Tag = form.CurrentOption;
                                treeList.Selection[0].SetValue(1, form.UserOption.Value);
                                ProcessTreeValidity(treeList.Nodes);
                                Controller.MainForm.Cursor = Cursors.Default;
                            }

                            //((ArchAngel.Providers.Database.Model.ScriptObject)treeList.Selection[0].ParentNode.ParentNode.Tag).UserOptions[i].Value = Convert.ChangeType(form.CurrentOption.DefaultValue, form.CurrentOption.VarType);
                            //parentScriptObject.UserOptions[i].Value = Convert.ChangeType(form.CurrentOption.DefaultValue, form.CurrentOption.VarType);
                            break;
                        }
                    }
                    return;
                }
                else if (parentType == typeof(ArchAngel.Providers.Database.Model.Column))
                {
                    ArchAngel.Providers.Database.Model.Column parentColumn = (ArchAngel.Providers.Database.Model.Column)parentObject;

                    for (int i = 0; i < parentColumn.UserOptions.Count; i++)
                    {
                        if (parentColumn.UserOptions[i].Name == option.VariableName)
                        {
                            userOption = parentColumn.UserOptions[i];
                            FormObjectOptionEdit form = new FormObjectOptionEdit(option, userOption, parentColumn);

                            if (form.ShowDialog(this.ParentForm) == DialogResult.OK)
                            {
                                Controller.MainForm.Cursor = Cursors.WaitCursor;
                                parentColumn.UserOptions[i].Value = form.UserOption.Value;
                                treeList.Selection[0].Tag = form.CurrentOption;
                                treeList.Selection[0].SetValue(1, form.UserOption.Value);
                                ProcessTreeValidity(treeList.Nodes);
                                Controller.MainForm.Cursor = Cursors.Default;
                            }
                            break;
                        }
                    }
                    return;
                }
            }
            ScriptBase scriptBase = (ScriptBase)treeListNode.Tag;

            if (type == typeof(ArchAngel.Providers.Database.Model.Table) ||
                type == typeof(ArchAngel.Providers.Database.Model.View) ||
                type == typeof(ArchAngel.Providers.Database.Model.StoredProcedure))
            {
                FormScriptObject form = new FormScriptObject((ScriptObject)scriptBase, (ScriptObject[])treeListNode.ParentNode.Tag);

                if (form.ShowDialog(this.ParentForm) == DialogResult.OK)
                {
                    Controller.MainForm.Cursor = Cursors.WaitCursor;
                    UpdateTreeListNodeText(treeListNode, form.ScriptObject);

                    //TreeListHelper.TreeListNodeValidate(treeListNode);
                    foreach (ArchAngel.Providers.Database.Model.Database database in Controller.Instance.BllDatabase.Databases)
                    {
                        database.SnapshotMode = true;
                    }
                    treeList.BeginUpdate();
                    //ValidateNode(treeListNode);
                    ProcessTreeValidity(treeList.Nodes);
                    treeList.EndUpdate();

                    foreach (ArchAngel.Providers.Database.Model.Database database in Controller.Instance.BllDatabase.Databases)
                    {
                        database.SnapshotMode = false;
                    }
                    Controller.MainForm.Cursor = Cursors.Default;
                    return;
                }
            }
            else if (type == typeof(Column))
            {
                FormColumn form = new FormColumn((Column)scriptBase);

                if (form.ShowDialog(this.ParentForm) == DialogResult.OK)
                {
                    Controller.MainForm.Cursor = Cursors.WaitCursor;
                    UpdateTreeListNodeText(treeListNode, form.Column);

                    //TreeListHelper.TreeListNodeValidate(treeListNode.ParentNode);
                    ProcessTreeValidity(treeList.Nodes);
                    Controller.MainForm.Cursor = Cursors.Default;
                    return;
                }
            }
            else if (type == typeof(MapColumn))
            {
                FormMapColumn form = new FormMapColumn((ScriptObject)treeListNode.ParentNode.ParentNode.Tag, (MapColumn)scriptBase);

                if (form.ShowDialog(this.ParentForm) == DialogResult.OK)
                {
                    Controller.MainForm.Cursor = Cursors.WaitCursor;
                    MapColumn mapColumn = (MapColumn)scriptBase;

                    UpdateTreeListNodeText(treeListNode, form.MapColumn);

                    //TreeListHelper.TreeListNodeValidate(treeListNode.ParentNode);
                    ProcessTreeValidity(treeList.Nodes);
                    Controller.MainForm.Cursor = Cursors.Default;
                    return;
                }
            }
            else if (type.BaseType == typeof(Relationship))
            {
                ArchAngel.Providers.Database.Model.Database database = (ArchAngel.Providers.Database.Model.Database)treeListNode.ParentNode.ParentNode.ParentNode.ParentNode.ParentNode.Tag;
                FormRelationship form = new FormRelationship((Relationship)scriptBase, Controller.Instance.BllDatabase.ScriptObjects);

                if (form.ShowDialog(this.ParentForm) == DialogResult.OK)
                {
                    Controller.MainForm.Cursor = Cursors.WaitCursor;
                    UpdateTreeListNodeText(treeListNode, form.PrimaryRelationship);

                    //TreeListHelper.TreeListNodeValidate(treeListNode.ParentNode.ParentNode);
                    ProcessTreeValidity(treeList.Nodes);
                    Controller.MainForm.Cursor = Cursors.Default;
                    return;
                }
            }
            else if (type == typeof(Filter))
            {
                ArchAngel.Providers.Database.Model.Database database = (ArchAngel.Providers.Database.Model.Database)treeListNode.ParentNode.ParentNode.ParentNode.ParentNode.Tag;
                Filter filter = (Filter)scriptBase;

                FormFilter2 form;
                // Stored Procedure Filters can only be created from other Stored Procedures (Enabled or Disabled)
                if (filter.Parent.GetType() == typeof(ArchAngel.Providers.Database.Model.StoredProcedure))
                {
                    form = new FormFilter2(this.ParentForm, filter, database.StoredProcedures);
                }
                else
                {
                    form = new FormFilter2(this.ParentForm, filter, database.EnabledScriptObjects);
                }
                if (form.ShowDialog(this.ParentForm) == DialogResult.OK)
                {
                    Controller.MainForm.Cursor = Cursors.WaitCursor;
                    UpdateTreeListNodeText(treeListNode, form.Filter);

                    //TreeListHelper.TreeListNodeValidate(treeListNode.ParentNode);
                    ProcessTreeValidity(treeList.Nodes);
                    Controller.MainForm.Cursor = Cursors.Default;
                    return;
                }
            }
            else if (type == typeof(Index))
            {
                FormIndex form = new FormIndex((Index)scriptBase);

                if (form.ShowDialog(this.ParentForm) == DialogResult.OK)
                {
                    Controller.MainForm.Cursor = Cursors.WaitCursor;
                    UpdateTreeListNodeText(treeListNode, form.Index);

                    //TreeListHelper.TreeListNodeValidate(treeListNode.ParentNode);
                    ProcessTreeValidity(treeList.Nodes);
                    Controller.MainForm.Cursor = Cursors.Default;
                    return;
                }
            }
            else if (type == typeof(Key))
            {
                FormKey form = new FormKey((Key)scriptBase);

                if (form.ShowDialog(this.ParentForm) == DialogResult.OK)
                {
                    Controller.MainForm.Cursor = Cursors.WaitCursor;
                    UpdateTreeListNodeText(treeListNode, form.Key);

                    //TreeListHelper.TreeListNodeValidate(treeListNode.ParentNode);
                    ProcessTreeValidity(treeList.Nodes);
                    Controller.MainForm.Cursor = Cursors.Default;
                    return;
                }
            }
        }
Beispiel #32
0
        private void toolStripMenuItemTreeViewAdd_Click(object sender, EventArgs e)
        {
            treeList.InvalidateNodes();

            treeList.BeginUpdate();

            TreeListNode treeListNode = treeList.FocusedNode;

            Type type = treeListNode.Tag.GetType();

            if (type == typeof(ArchAngel.Providers.Database.Model.Table[]) ||
                type == typeof(ArchAngel.Providers.Database.Model.View[]) ||
                type == typeof(ArchAngel.Providers.Database.Model.StoredProcedure[]))
            {
                ArchAngel.Providers.Database.Model.Database parent = (ArchAngel.Providers.Database.Model.Database)treeListNode.ParentNode.Tag;
                FormScriptObject form = new FormScriptObject((ScriptObject[])treeListNode.Tag, parent);

                if (form.ShowDialog(this.ParentForm) == DialogResult.OK)
                {
                    Controller.MainForm.Cursor = Cursors.WaitCursor;
                    parent.AddScriptObject(form.ScriptObject);

                    TreeListNode newTreeListNode = treeList.AppendNode(GetTreeListNodeText(form.ScriptObject), treeListNode);
                    newTreeListNode.Tag = form.ScriptObject;
                    newTreeListNode.ImageIndex = newTreeListNode.SelectImageIndex = (int)Images.GreenBullet;

                    SetupNewTreeListNode(newTreeListNode, form.ScriptObject);

                    if (type == typeof(ArchAngel.Providers.Database.Model.Table[]))
                    {
                        treeListNode.Tag = parent.Tables;
                    }

                    if (type == typeof(ArchAngel.Providers.Database.Model.View[]))
                    {
                        treeListNode.Tag = parent.Views;
                    }

                    if (type == typeof(ArchAngel.Providers.Database.Model.StoredProcedure[]))
                    {
                        treeListNode.Tag = parent.StoredProcedures;
                    }
                    //TreeListHelper.TreeListNodeValidate(newTreeListNode);
                    ProcessTreeValidity(treeList.Nodes);
                    Controller.MainForm.Cursor = Cursors.Default;
                }
            }
            else if (type == typeof(Column[]))
            {
                ScriptObject parent = (ScriptObject)treeListNode.ParentNode.Tag;
                FormColumn form = new FormColumn(parent);

                if (form.ShowDialog(this.ParentForm) == DialogResult.OK)
                {
                    Controller.MainForm.Cursor = Cursors.WaitCursor;
                    parent.AddColumn(form.Column);

                    TreeListNode newTreeListNode = treeList.AppendNode(GetTreeListNodeText(form.Column), treeListNode);
                    newTreeListNode.Tag = form.Column;
                    newTreeListNode.ImageIndex = newTreeListNode.SelectImageIndex = (int)Images.GreenBullet;

                    treeListNode.Tag = parent.Columns;

                    //TreeListHelper.TreeListNodeValidate(treeListNode.ParentNode);
                    ProcessTreeValidity(treeList.Nodes);
                    Controller.MainForm.Cursor = Cursors.Default;
                }
            }
            else if (type == typeof(OneToOneRelationship[]) ||
                type == typeof(OneToManyRelationship[]) ||
                type == typeof(ManyToOneRelationship[]) ||
                type == typeof(ManyToManyRelationship[]))
            {
                ScriptObject parent = (ScriptObject)treeListNode.ParentNode.ParentNode.Tag;

                Type relationshipType = null;
                if (type == typeof(OneToOneRelationship[]))
                {
                    relationshipType = typeof(OneToOneRelationship);
                }

                if (type == typeof(ManyToOneRelationship[]))
                {
                    relationshipType = typeof(ManyToOneRelationship);
                }

                if (type == typeof(OneToManyRelationship[]))
                {
                    relationshipType = typeof(OneToManyRelationship);
                }

                if (type == typeof(ManyToManyRelationship[]))
                {
                    relationshipType = typeof(ManyToManyRelationship);
                }

                ArchAngel.Providers.Database.Model.Database database = (ArchAngel.Providers.Database.Model.Database)treeListNode.ParentNode.ParentNode.ParentNode.ParentNode.Tag;

                FormRelationship form = new FormRelationship(relationshipType, (ScriptObject)treeListNode.ParentNode.ParentNode.Tag, Controller.Instance.BllDatabase.EnabledScriptObjects);

                if (form.ShowDialog(this.ParentForm) == DialogResult.OK)
                {
                    Controller.MainForm.Cursor = Cursors.WaitCursor;
                    ScriptObject primaryScriptObject = form.PrimaryRelationship.Parent;
                    primaryScriptObject.AddRelationship(form.PrimaryRelationship);

                    ScriptObject foreignScriptObject = form.ForeignRelationship.Parent;
                    foreignScriptObject.AddRelationship(form.ForeignRelationship);

                    TreeListNode newTreeListNode = treeList.AppendNode(GetTreeListNodeText(form.PrimaryRelationship), treeListNode);
                    newTreeListNode.Tag = form.PrimaryRelationship;
                    newTreeListNode.ImageIndex = newTreeListNode.SelectImageIndex = (int)Images.GreenBullet;

                    if (type == typeof(OneToOneRelationship[]))
                    {
                        treeListNode.Tag = parent.OneToOneRelationships;
                    }

                    if (type == typeof(ManyToOneRelationship[]))
                    {
                        treeListNode.Tag = parent.ManyToOneRelationships;
                    }

                    if (type == typeof(OneToManyRelationship[]))
                    {
                        treeListNode.Tag = parent.OneToManyRelationships;
                    }

                    if (type == typeof(ManyToManyRelationship[]))
                    {
                        treeListNode.Tag = parent.ManyToManyRelationships;
                    }

                    LoadTreeListNode(foreignScriptObject);
                    //TreeListHelper.TreeListNodeValidate(treeListNode.ParentNode.ParentNode);
                    ProcessTreeValidity(treeList.Nodes);
                    Controller.MainForm.Cursor = Cursors.Default;
                }
            }
            else if (type == typeof(Filter[]))
            {
                ArchAngel.Providers.Database.Model.Database database = (ArchAngel.Providers.Database.Model.Database)treeListNode.ParentNode.ParentNode.ParentNode.Tag;
                ScriptObject parent = (ScriptObject)treeListNode.ParentNode.Tag;

                FormFilter2 form;
                // Stored Procedure Filters can only be created from other Stored Procedures (Enabled or Disabled)
                if (parent.GetType() == typeof(ArchAngel.Providers.Database.Model.StoredProcedure))
                {
                    form = new FormFilter2(this.ParentForm, parent, database.StoredProcedures);
                }
                else
                {
                    form = new FormFilter2(this.ParentForm, parent, database.EnabledScriptObjects);
                }
                if (form.ShowDialog(this.ParentForm) == DialogResult.OK)
                {
                    Controller.MainForm.Cursor = Cursors.WaitCursor;
                    parent.AddFilter(form.Filter);

                    TreeListNode newTreeListNode = treeList.AppendNode(GetTreeListNodeText(form.Filter), treeListNode);
                    newTreeListNode.Tag = form.Filter;
                    newTreeListNode.ImageIndex = newTreeListNode.SelectImageIndex = (int)Images.GreenBullet;

                    treeListNode.Tag = parent.Filters;

                    //TreeListHelper.TreeListNodeValidate(treeListNode.ParentNode);
                    ProcessTreeValidity(treeList.Nodes);
                    Controller.MainForm.Cursor = Cursors.Default;
                }
            }
            else if (type == typeof(Index[]))
            {
                ArchAngel.Providers.Database.Model.Table parent = (ArchAngel.Providers.Database.Model.Table)treeListNode.ParentNode.Tag;
                FormIndex form = new FormIndex((ArchAngel.Providers.Database.Model.Table)treeListNode.ParentNode.Tag);

                if (form.ShowDialog(this.ParentForm) == DialogResult.OK)
                {
                    Controller.MainForm.Cursor = Cursors.WaitCursor;
                    parent.AddIndex(form.Index);

                    TreeListNode newTreeListNode = treeList.AppendNode(GetTreeListNodeText(form.Index), treeListNode);
                    newTreeListNode.Tag = form.Index;
                    newTreeListNode.ImageIndex = newTreeListNode.SelectImageIndex = (int)Images.GreenBullet;

                    treeListNode.Tag = parent.Indexes;

                    //TreeListHelper.TreeListNodeValidate(treeListNode.ParentNode);
                    ProcessTreeValidity(treeList.Nodes);
                    Controller.MainForm.Cursor = Cursors.Default;
                }
            }
            else if (type == typeof(Key[]))
            {
                ArchAngel.Providers.Database.Model.Table parent = (ArchAngel.Providers.Database.Model.Table)treeListNode.ParentNode.Tag;
                FormKey form = new FormKey((ArchAngel.Providers.Database.Model.Table)treeListNode.ParentNode.Tag);

                if (form.ShowDialog(this.ParentForm) == DialogResult.OK)
                {
                    Controller.MainForm.Cursor = Cursors.WaitCursor;
                    parent.AddKey(form.Key);

                    TreeListNode newTreeListNode = treeList.AppendNode(GetTreeListNodeText(form.Key), treeListNode);
                    newTreeListNode.Tag = form.Key;
                    newTreeListNode.ImageIndex = newTreeListNode.SelectImageIndex = (int)Images.GreenBullet;

                    treeListNode.Tag = parent.Keys;

                    //TreeListHelper.TreeListNodeValidate(treeListNode.ParentNode);
                    ProcessTreeValidity(treeList.Nodes);
                    Controller.MainForm.Cursor = Cursors.Default;
                }
            }
            treeList.EndUpdate();
        }
Beispiel #33
0
        public Boolean isIndexCompoundContainer(FormIndex index)
        {
            FormEntryCaption caption = getCaptionPrompt(index);

            return(getEvent(index) == FormEntryController.EVENT_GROUP && caption.getAppearanceHint() != null && caption.getAppearanceHint().ToLower().Equals("full"));
        }
Beispiel #34
0
 public FormIndex incrementIndex(FormIndex index)
 {
     return(incrementIndex(index, true));
 }