Ejemplo n.º 1
0
        /// <summary>Handles the ItemAdded event of the <see cref="ExcelPool"/>.
        /// </summary>
        /// <param name="e">The <see cref="Dodoni.XLBasicComponents.ExcelPool.ItemAddedEventArgs"/> instance containing the event data.</param>
        private void ExcelPool_ItemAdded(ExcelPool.ItemAddedEventArgs e)
        {
            TreeNode excelPoolItemTypeTreeNode;

            if (m_ExcelPoolItemTypeRootNode.TryGetValue(e.Item.ObjectType.Identifier, out excelPoolItemTypeTreeNode) == true)
            {
                if (e.State == ItemAddedState.Added)
                {
                    excelPoolItemTypeTreeNode.Nodes.Add(GetExcelPoolItemNode(e.Item));  // add at the beginning, perhaps sorting later
                }
                else if (e.State == ItemAddedState.Replaced)
                {
                    /* search for the old TreeNode and replace it by a new one: */
                    for (int j = 0; j < excelPoolItemTypeTreeNode.Nodes.Count; j++)
                    {
                        ExcelPoolItem excelPoolItem = excelPoolItemTypeTreeNode.Nodes[j].Tag as ExcelPoolItem;
                        if ((excelPoolItem != null) && (excelPoolItem.ObjectType.Identifier == e.Item.ObjectType.Identifier))
                        {
                            if (excelPoolItem.ObjectName.IDString == e.Item.ObjectName.IDString)
                            {
                                TreeNode newTreeNode = GetExcelPoolItemNode(e.Item);
                                excelPoolItemTypeTreeNode.Nodes.RemoveAt(j);
                                excelPoolItemTypeTreeNode.Nodes.Insert(j, newTreeNode);

                                return; // exit the method
                            }
                        }
                    }
                    /* If the user replaces a ExcelPoolItem object with a ExcelPoolItem object of an other ExcelPoolItemType we remove all objects and add it again (fallback solution) */
                    ResetTree();
                    AddAllExcelPoolItems();
                }
            }
        }
        /// <summary>Initializes the current object with respect to a specific <see cref="ExcelPoolItem"/> object.
        /// </summary>
        /// <param name="excelPoolItem">The <see cref="ExcelPoolItem"/> object.</param>
        public void Initialize(ExcelPoolItem excelPoolItem)
        {
            if (excelPoolItem != null)
            {
                editName.Text = excelPoolItem.LongName.String;

                editType.Text = excelPoolItem.ObjectType.LongName.String;
                dateTimePickerCreationTime.Value = excelPoolItem.TimeStamp;

                var loggingObject = excelPoolItem.Value as ILoggedObject;
                if (loggingObject != null)
                {
                    var excelLogFile = loggingObject.Logging as ExcelObjectLogger;

                    logFileDataGridView.AutoGenerateColumns = false;
                    ColumnTime.DataPropertyName             = "TimeStamp";
                    ColumnClassification.DataPropertyName   = "MessageTypeClassificationAsString";
                    ColumnMessageType.DataPropertyName      = "MessageTypeName";
                    ColumnMessage.DataPropertyName          = "Message";

                    logFileDataGridView.DataSource = excelLogFile.GetAsBindingList();
                }
            }
            else
            {
                editName.Text = editType.Text = String.Empty;
                dateTimePickerCreationTime.Value = DateTime.MinValue;
                logFileDataGridView.DataSource   = null;
            }
        }
Ejemplo n.º 3
0
        /// <summary>Creates a specific <see cref="ExcelPoolItem"/> object.
        /// </summary>
        /// <param name="value">The value (output).</param>
        /// <param name="errorMessage">The error message or undefined if no error occurs (output).</param>
        /// <param name="calculationMethod">The calculation method.</param>
        /// <returns>A value indicating whether <paramref name="value"/> contains valid data; otherwise <paramref name="errorMessage"/> contains an error message.</returns>
        public bool TryCreateItem(out ExcelPoolItem value, out string errorMessage, TryCreateExcelPoolItemConcurrently calculationMethod)
        {
            IAsyncResult asyncResult = calculationMethod.BeginInvoke(out value, out errorMessage, callBack => { this.Close(); }, null);

            switch (m_Form.ShowDialog())
            {
            case DialogResult.Abort:
                calculationMethod.EndInvoke(out value, out errorMessage, asyncResult);
                errorMessage = "Error! Abort by the user";
                return(false);

            case DialogResult.OK:
                return(calculationMethod.EndInvoke(out value, out errorMessage, asyncResult));

            default:
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 4
0
        /// <summary>Handles the BeforeSelect event of the <see cref="TreeView"/> control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.TreeViewCancelEventArgs"/> instance containing the event data.</param>
        private void poolItemTree_BeforeSelect(object sender, TreeViewCancelEventArgs e)
        {
            mainGroupBox.Hide();
            mainGroupBox.Controls.Clear();

            if ((e == null) || (e.Node == null) || (e.Node.Tag == null))
            {
                mainGroupBox.Controls.Clear();
            }
            else
            {
                UserControl   userControl   = null;
                ExcelPoolItem excelPoolItem = null;

                object tag = e.Node.Tag;
                if (tag is ExcelPoolItem)
                {
                    excelPoolItem = tag as ExcelPoolItem;
                    if (excelPoolItem != null)
                    {
                        userControl = m_GeneralUserControl;
                        m_GeneralUserControl.Initialize(excelPoolItem);
                    }
                }
                else if (tag is Tuple <ExcelPoolItem, GuidedExcelDataQuery> )
                {
                    var inputTag = tag as Tuple <ExcelPoolItem, GuidedExcelDataQuery>;

                    if (inputTag != null)
                    {
                        excelPoolItem = inputTag.Item1;
                        userControl   = m_InputUserControl;
                        m_InputUserControl.Initialize(inputTag.Item2);
                    }
                }
                else if (tag is Tuple <ExcelPoolItem, IdentifierString, IIdentifierStringDictionary <InfoOutputProperty> > )
                {
                    var inputTag = tag as Tuple <ExcelPoolItem, IdentifierString, IIdentifierStringDictionary <InfoOutputProperty> >;
                    if (inputTag != null)
                    {
                        excelPoolItem = inputTag.Item1;
                        userControl   = m_OutputPropertyUserControl;
                        m_OutputPropertyUserControl.Initialize(inputTag.Item2.String, inputTag.Item3);
                    }
                }
                else if (tag is Tuple <ExcelPoolItem, IdentifierString, DataTable> )
                {
                    var inputTag = tag as Tuple <ExcelPoolItem, IdentifierString, DataTable>;
                    if (inputTag != null)
                    {
                        excelPoolItem = inputTag.Item1;
                        userControl   = m_OutputTableUserControl;
                        m_OutputTableUserControl.Initialize(inputTag.Item2.String, inputTag.Item3);
                    }
                }
                else if (tag is Tuple <ExcelPoolItem, IdentifierString, InfoOutputParentChildDataTable> )
                {
                    var inputTag = tag as Tuple <ExcelPoolItem, IdentifierString, InfoOutputParentChildDataTable>;
                    if (inputTag != null)
                    {
                        excelPoolItem = inputTag.Item1;
                        userControl   = m_OutputTableUserControl;
                        m_OutputParentChildTableUserControl.Initialize(inputTag.Item2.String, inputTag.Item3);
                    }
                }

                if ((userControl != null) && (excelPoolItem != null))
                {
                    mainGroupBox.Text = excelPoolItem.LongName.String;

                    userControl.Left   = 10;
                    userControl.Top    = 15;
                    userControl.Height = mainGroupBox.Height - 25;
                    userControl.Width  = mainGroupBox.Width - 15;
                    userControl.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
                    mainGroupBox.Controls.Add(userControl);
                }
                mainGroupBox.Show();
            }
        }
Ejemplo n.º 5
0
        /// <summary>Gets the <see cref="TreeNode"/> representation of an <see cref="ExcelPoolItem"/> object.
        /// </summary>
        /// <param name="excelPoolItem">The <see cref="ExcelPoolItem"/> object to convert.</param>
        protected TreeNode GetExcelPoolItemNode(ExcelPoolItem excelPoolItem)
        {
            TreeNode excelPoolItemNode = new TreeNode(excelPoolItem.LongName.String);

            excelPoolItemNode.Tag = excelPoolItem;

            /* add a 'General' node which represents the logfile, time of creation etc. */
            TreeNode generalNode = new TreeNode("General");

            generalNode.Tag = excelPoolItem;
            excelPoolItemNode.Nodes.Add(generalNode);

            /* add the 'input' nodes, where the sub-nodes contains the GuidedExcelDataQuery objects needed as input:  */
            TreeNode inputNode = new TreeNode("Input");

            excelPoolItemNode.Nodes.Add(inputNode);

            foreach (var inputDataQuery in excelPoolItem.GetDataQueryRepresentation())
            {
                TreeNode inputDataQueryNode = new TreeNode(inputDataQuery.LongName.String);

                inputDataQueryNode.Tag = Tuple.Create(excelPoolItem, inputDataQuery);
                if (inputNode.Tag == null)
                {
                    inputNode.Tag = inputDataQueryNode.Tag;
                }
                inputNode.Nodes.Add(inputDataQueryNode);
            }

            /* add the 'output' nodes, where the successor nodes contains the properties and data table of the InfoOutput object */
            TreeNode outputNode = new TreeNode("Output");

            excelPoolItemNode.Nodes.Add(outputNode);

            InfoOutput infoOutput = new InfoOutput();

            excelPoolItem.Value.FillInfoOutput(infoOutput);

            foreach (var infoOutputCollection in infoOutput)
            {
                TreeNode outputCategoryNode;
                if (infoOutput.Count > 1)
                {
                    outputCategoryNode = new TreeNode(infoOutputCollection.CategoryName.String);
                    outputNode.Nodes.Add(outputCategoryNode);
                }
                else
                {
                    outputCategoryNode = outputNode;
                }

                foreach (var propertyGroup in infoOutputCollection.Properties)
                {
                    TreeNode propertyGroupNode = new TreeNode(propertyGroup.Item1.String);
                    propertyGroupNode.Tag = Tuple.Create(excelPoolItem, propertyGroup.Item1, propertyGroup.Item2);

                    outputCategoryNode.Nodes.Add(propertyGroupNode);
                    if (outputNode.Tag == null)
                    {
                        outputNode.Tag = propertyGroupNode.Tag;
                    }
                }

                foreach (var table in infoOutputCollection.GetDataTables(InfoOutputPackage.DataTableType.Single))
                {
                    TreeNode tableNode = new TreeNode(table.Item1.String);
                    tableNode.Tag = Tuple.Create(excelPoolItem, table.Item1, table.Item2);

                    outputCategoryNode.Nodes.Add(tableNode);

                    if (outputNode.Tag == null)
                    {
                        outputNode.Tag = tableNode.Tag;
                    }
                }

                foreach (var parentChildTable in infoOutputCollection.ParentChildDataTables)
                {
                    TreeNode tableNode = new TreeNode(parentChildTable.Item1.String);
                    tableNode.Tag = Tuple.Create(excelPoolItem, parentChildTable.Item1, parentChildTable.Item2);

                    outputCategoryNode.Nodes.Add(tableNode);

                    if (outputNode.Tag == null)
                    {
                        outputNode.Tag = tableNode.Tag;
                    }
                }
            }
            return(excelPoolItemNode);
        }