Example #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="theLabel">The arrow label</param>
        public ArrowPanel(IArrowLabel theLabel)
        {
            PictureBox box = new PictureBox();

            box.Left = 5;
            box.Top  = y + 5;
            Image im = NamedComponent.GetImage(theLabel);

            box.Width  = im.Width;
            box.Height = im.Height;
            box.Image  = im;
            Controls.Add(box);
            Label label = new Label();

            label.Top  = box.Top;
            label.Left = box.Left + box.Width + 5;
            label.Text = theLabel.RootName;            //NamedComponent.GetText(theLabel);
            Controls.Add(label);
            objects    = new IObjectLabel[2];
            objects[0] = theLabel.Source;
            objects[1] = theLabel.Target;
            y          = box.Top + box.Height;
            Name       = theLabel.RootName;      //NamedComponent.GetText(theLabel) + "";
            initialize();
        }
Example #2
0
        /// <summary>
        /// Initialization
        /// </summary>
        private void Initialize()
        {
            int ho = Height;
            int ph = pictureBoxObject.Height;

            try
            {
                Image im = NamedComponent.GetImage(theObject);
                pictureBoxObject.Width  = im.Width;
                pictureBoxObject.Height = im.Height;
                pictureBoxObject.Image  = im;
            }
            catch (Exception ex)
            {
                ex.ShowError(10);
            }
            if (theBase != null)
            {
                labelObject.Text = theBase.GetRelativeName(theObject);
            }
            else
            {
                labelObject.Text = theObject.RootName;
            }
            int dh = pictureBoxObject.Height - ph;

            panelTop.Height = panelTop.Height + dh;
            Height          = Height + dh;
        }
Example #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="component">Linked component</param>
 /// <param name="fullName">The "show full" name sign</param>
 public NamedNode(INamedComponent component, bool fullName)
 {
     this.component = component;
     if (component is NamedComponent)
     {
         NamedComponent comp = component as NamedComponent;
         comp.AddNode(this);
         Text = component.Name;
     }
     else
     {
         INamedComponent nc   = component;
         IDesktop        root = component.Root.Desktop;
         if (fullName)
         {
             Text = component.RootName;
         }
         else
         {
             Text = component.GetName(nc.Desktop);
         }
     }
     ImageIndex         = NamedComponent.GetImageNumber(component);
     SelectedImageIndex = ImageIndex;
 }
Example #4
0
 /// <summary>
 /// Initialization
 /// </summary>
 private void initialize()
 {
     Width  = 300;
     Height = 100;
     for (int i = 0; i < 2; i++)
     {
         Label label = new Label();
         label.Top  = y + 5;
         label.Left = 5;
         label.Text = texts[i];
         int yy = label.Top + label.Height;
         Controls.Add(label);
         PictureBox box = new PictureBox();
         Image      im  = NamedComponent.GetImage(objects[i]);
         box.Width  = im.Width;
         box.Height = im.Height;
         box.Left   = 5;
         box.Top    = yy + 5;
         box.Image  = im;
         Controls.Add(box);
         Label labelObj = new Label();
         labelObj.Top  = box.Top;
         labelObj.Left = box.Left + box.Width + 5;
         string text = objects[i].RootName;                //NamedComponent.GetText(objects[i]) + "";
         labelObj.Text = text;
         Controls.Add(labelObj);
         y = 5 + box.Top + box.Height;
     }
     Height = y;
 }
Example #5
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="operation">Operation</param>
        /// <param name="w">Width</param>
        public PanelUnary(IObjectOperation operation, int w)
        {
            Width          = w;
            this.operation = operation;
            ICategoryObject o = operation as ICategoryObject;

            label = o.Object as IObjectLabel;
            PictureBox p = new PictureBox();

            p.Image = NamedComponent.GetImage(label);
            int y = 10;
            int x = 10;

            p.Left = x;
            p.Top  = y;
            Controls.Add(p);
            y += p.Height + 10;
            Label lab = new Label();

            lab.Text = label.RootName;            //NamedComponent.GetText(label) + "";
            lab.Left = x;
            lab.Top  = y;
            Controls.Add(lab);
            y      += lab.Height + 10;
            cb.Top  = y;
            cb.Left = x;
            Controls.Add(cb);
            y     += cb.Height + 10;
            Height = y;
        }
Example #6
0
 private void buttonShowComponent_Click(object sender, System.EventArgs e)
 {
     try
     {
         NamedComponent nc = exception.Component as NamedComponent;
         nc.ShowDialog(this);
     }
     catch (Exception)
     {
         WindowsExtensions.ControlExtensions.ShowMessageBoxModal(this, ResourceService.Resources.GetControlResource("Unable to open properties editor",
                                                                                                                    ControlUtilites.Resources));
     }
 }
Example #7
0
 /// <summary>
 /// Sets new name
 /// </summary>
 /// <param name="name">The name</param>
 public void SetName(string name)
 {
     if (component is NamedComponent)
     {
         NamedComponent comp = component as NamedComponent;
         comp.SetName(name);
     }
     else if (component is IObjectLabelUI)
     {
         IObjectLabelUI olui = component as IObjectLabelUI;
         olui.ComponentName = name;
     }
     else if (component is IArrowLabelUI)
     {
         IArrowLabelUI alui = component as IArrowLabelUI;
         alui.ComponentName = name;
     }
 }
Example #8
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="component">Corresponding component</param>
        public DefaultForm(INamedComponent component)
        {
            InitializeComponent();
            this.component = component;
            this.LoadControlResources(ControlUtilites.Resources);            //, Resources);
            UpdateFormUI();
            pictureBoxObject.Image = NamedComponent.GetImage(component);
            labelH.Text            = NamedComponent.GetToolTip(component);
            object o = null;

            if (component is IObjectLabel)
            {
                IObjectLabel l = component as IObjectLabel;
                o = l.Object;
            }
            if (component is IArrowLabel)
            {
                IArrowLabel l = component as IArrowLabel;
                o = l.Arrow;
            }
            if (!(o is IUpdatableObject))
            {
                checkBoxUpdatable.Visible = false;
            }
            else
            {
                IUpdatableObject upd = o as IUpdatableObject;
                if (upd.ShouldUpdate)
                {
                    checkBoxUpdatable.Checked = true;
                }
            }

            if (!(component is IArrowLabel))
            {
                this.labelSourceH.Visible = false;
                this.labelTargetH.Visible = false;
                return;
            }
            IArrowLabel label = component as IArrowLabel;

            pictureBoxSource.Image = NamedComponent.GetImage(label.Source);
            pictureBoxTarget.Image = NamedComponent.GetImage(label.Target);
        }
Example #9
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="label">Arrow label</param>
        public FormAggregateLink(IArrowLabel label)
            : this()
        {
            this.label = label;
            UpdateFormUI();
            link = label.Arrow as MechanicalAggregateLink;
            try
            {
                pictureBoxParent.Image = NamedComponent.GetImage(label.Target);
                pictureBoxChild.Image  = NamedComponent.GetImage(label.Source);
            }
            catch (Exception ex)
            {
                ex.ShowError(10);
            }
            source = link.SourceObject;
            target = link.TargetObject;
            int nt = target.NumberOfConnections;
            int ns = source.NumberOfConnections;

            if (nt == 0)
            {
                numericUpDownChild.Enabled = false;
            }
            else
            {
                numericUpDownChild.Minimum = 1;
                numericUpDownChild.Maximum = source.NumberOfConnections;
                numericUpDownChild.Value   = link.SourceConnection + 1;
            }
            if (nt == 0)
            {
                numericUpDownParent.Enabled = false;
            }
            else
            {
                numericUpDownParent.Minimum = 1;
                numericUpDownParent.Maximum = target.NumberOfConnections;
                numericUpDownParent.Value   = link.TargetConnection + 1;
            }
            first = false;
        }
        void fill()
        {
            if (field == null)
            {
                return;
            }
            if (field.Field == null)
            {
                return;
            }
            Image im = NamedComponent.GetImage(field.Field as ICategoryObject);

            pictureBoxGrav.Image = im;
            string name =
                data.GetRelativeName(field.Field as ICategoryObject);

            labelName.Text = name;
            int[] n = field.Numbers;
            foreach (int i in n)
            {
                comboBoxNum.Items.Add(i + "");
            }
            int k = field.Number;

            if (k < 0)
            {
                return;
            }
            string sk = k + "";

            for (int i = 0; i < comboBoxNum.Items.Count; i++)
            {
                string s = comboBoxNum.Items[i] + "";
                if (s.Equals(sk))
                {
                    comboBoxNum.SelectedIndex = i;
                    break;
                }
            }
        }
        internal static string GetQueryDefinition(Database d, NamedComponent nc, Microsoft.AnalysisServices.Binding b, List <DataItem> columnsNeeded)
        {
            StringBuilder sQuery = new StringBuilder();

            if (b is DsvTableBinding)
            {
                DsvTableBinding oDsvTableBinding = (DsvTableBinding)b;
                DataSourceView  oDSV             = d.DataSourceViews[oDsvTableBinding.DataSourceViewID];
                DataTable       oTable           = oDSV.Schema.Tables[oDsvTableBinding.TableID];

                if (oTable == null)
                {
                    throw new Exception("DSV table " + oDsvTableBinding.TableID + " not found");
                }
                else if (!oTable.ExtendedProperties.ContainsKey("QueryDefinition") && oTable.ExtendedProperties.ContainsKey("DbTableName"))
                {
                    foreach (DataColumn oColumn in oTable.Columns)
                    {
                        bool bFoundColumn = false;
                        if (columnsNeeded == null)
                        {
                            bFoundColumn = true;
                        }
                        else
                        {
                            foreach (DataItem di in columnsNeeded)
                            {
                                if (GetColumnBindingForDataItem(di).TableID == oTable.TableName && GetColumnBindingForDataItem(di).ColumnID == oColumn.ColumnName)
                                {
                                    bFoundColumn = true;
                                }
                            }
                        }
                        if (bFoundColumn)
                        {
                            if (sQuery.Length == 0)
                            {
                                sQuery.Append("select ");
                            }
                            else
                            {
                                sQuery.Append(",");
                            }
                            if (!oColumn.ExtendedProperties.ContainsKey("ComputedColumnExpression"))
                            {
                                sQuery.Append(sq).Append((oColumn.ExtendedProperties["DbColumnName"] ?? oColumn.ColumnName).ToString()).AppendLine(fq);
                            }
                            else
                            {
                                sQuery.Append(oColumn.ExtendedProperties["ComputedColumnExpression"].ToString()).Append(" as ").Append(sq).Append((oColumn.ExtendedProperties["DbColumnName"] ?? oColumn.ColumnName).ToString()).AppendLine(fq);
                            }
                        }
                    }
                    if (sQuery.Length == 0)
                    {
                        throw new Exception("There was a problem constructing the query.");
                    }
                    sQuery.Append("from ");
                    if (oTable.ExtendedProperties.ContainsKey("DbSchemaName"))
                    {
                        sQuery.Append(sq).Append(oTable.ExtendedProperties["DbSchemaName"].ToString()).Append(fq).Append(".");
                    }
                    sQuery.Append(sq).Append(oTable.ExtendedProperties["DbTableName"].ToString());
                    sQuery.Append(fq).Append(" ").Append(sq).Append(oTable.ExtendedProperties["FriendlyName"].ToString()).AppendLine(fq);
                }
                else if (oTable.ExtendedProperties.ContainsKey("QueryDefinition"))
                {
                    sQuery.AppendLine("select *");
                    sQuery.AppendLine("from (");
                    sQuery.AppendLine(oTable.ExtendedProperties["QueryDefinition"].ToString());
                    sQuery.AppendLine(") x");
                }
                else
                {
                    throw new Exception("Current the code does not support this type of query.");
                }
            }
            else if (b is QueryBinding)
            {
                QueryBinding oQueryBinding = (QueryBinding)b;
                sQuery.Append(oQueryBinding.QueryDefinition);
            }
            else if (b is ColumnBinding)
            {
                ColumnBinding cb     = (ColumnBinding)b;
                object        parent = cb.Parent;
                DataTable     dt     = d.DataSourceViews[0].Schema.Tables[cb.TableID];
                if (nc is DimensionAttribute)
                {
                    DimensionAttribute da = (DimensionAttribute)nc;

                    if (da.Parent.KeyAttribute.KeyColumns.Count != 1)
                    {
                        throw new Exception("Attribute " + da.Parent.KeyAttribute.Name + " has a composite key. This is not supported for a key attribute of a dimension.");
                    }

                    string sDsvID = ((DimensionAttribute)nc).Parent.DataSourceView.ID;
                    columnsNeeded.Add(new DataItem(cb.Clone()));
                    columnsNeeded.Add(da.Parent.KeyAttribute.KeyColumns[0]);
                    return(GetQueryDefinition(d, nc, new DsvTableBinding(sDsvID, cb.TableID), columnsNeeded));
                }
                else
                {
                    throw new Exception("GetQueryDefinition does not currently support a ColumnBinding on a object of type " + nc.GetType().Name);
                }
            }
            else
            {
                throw new Exception("Not a supported query binding type: " + b.GetType().FullName);
            }

            return(sQuery.ToString());
        }
        internal static string GetQueryDefinition(Database d, NamedComponent nc, Microsoft.AnalysisServices.Binding b, List<DataItem> columnsNeeded)
        {
            StringBuilder sQuery = new StringBuilder();
            if (b is DsvTableBinding)
            {
                DsvTableBinding oDsvTableBinding = (DsvTableBinding)b;
                DataSourceView oDSV = d.DataSourceViews[oDsvTableBinding.DataSourceViewID];
                DataTable oTable = oDSV.Schema.Tables[oDsvTableBinding.TableID];

                if (oTable == null)
                {
                    throw new Exception("DSV table " + oDsvTableBinding.TableID + " not found");
                }
                else if (!oTable.ExtendedProperties.ContainsKey("QueryDefinition") && oTable.ExtendedProperties.ContainsKey("DbTableName"))
                {
                    foreach (DataColumn oColumn in oTable.Columns)
                    {
                        bool bFoundColumn = false;
                        if (columnsNeeded == null)
                        {
                            bFoundColumn = true;
                        }
                        else
                        {
                            foreach (DataItem di in columnsNeeded)
                            {
                                if (GetColumnBindingForDataItem(di).TableID == oTable.TableName && GetColumnBindingForDataItem(di).ColumnID == oColumn.ColumnName)
                                {
                                    bFoundColumn = true;
                                }
                            }
                        }
                        if (bFoundColumn)
                        {
                            if (sQuery.Length == 0)
                            {
                                sQuery.Append("select ");
                            }
                            else
                            {
                                sQuery.Append(",");
                            }
                            if (!oColumn.ExtendedProperties.ContainsKey("ComputedColumnExpression"))
                            {
                                sQuery.Append(sq).Append((oColumn.ExtendedProperties["DbColumnName"] ?? oColumn.ColumnName).ToString()).AppendLine(fq);
                            }
                            else
                            {
                                sQuery.Append(oColumn.ExtendedProperties["ComputedColumnExpression"].ToString()).Append(" as ").Append(sq).Append((oColumn.ExtendedProperties["DbColumnName"] ?? oColumn.ColumnName).ToString()).AppendLine(fq);
                            }
                        }
                    }
                    if (sQuery.Length == 0)
                    {
                        throw new Exception("There was a problem constructing the query.");
                    }
                    sQuery.Append("from ");
                    if (oTable.ExtendedProperties.ContainsKey("DbSchemaName")) sQuery.Append(sq).Append(oTable.ExtendedProperties["DbSchemaName"].ToString()).Append(fq).Append(".");
                    sQuery.Append(sq).Append(oTable.ExtendedProperties["DbTableName"].ToString());
                    sQuery.Append(fq).Append(" ").Append(sq).Append(oTable.ExtendedProperties["FriendlyName"].ToString()).AppendLine(fq);
                }
                else if (oTable.ExtendedProperties.ContainsKey("QueryDefinition"))
                {
                    sQuery.AppendLine("select *");
                    sQuery.AppendLine("from (");
                    sQuery.AppendLine(oTable.ExtendedProperties["QueryDefinition"].ToString());
                    sQuery.AppendLine(") x");
                }
                else
                {
                    throw new Exception("Current the code does not support this type of query.");
                }
            }
            else if (b is QueryBinding)
            {
                QueryBinding oQueryBinding = (QueryBinding)b;
                sQuery.Append(oQueryBinding.QueryDefinition);
            }
            else if (b is ColumnBinding)
            {
                ColumnBinding cb = (ColumnBinding)b;
                object parent = cb.Parent;
                DataTable dt = d.DataSourceViews[0].Schema.Tables[cb.TableID];
                if (nc is DimensionAttribute)
                {
                    DimensionAttribute da = (DimensionAttribute)nc;

                    if (da.Parent.KeyAttribute.KeyColumns.Count != 1)
                    {
                        throw new Exception("Attribute " + da.Parent.KeyAttribute.Name + " has a composite key. This is not supported for a key attribute of a dimension.");
                    }

                    string sDsvID = ((DimensionAttribute)nc).Parent.DataSourceView.ID;
                    columnsNeeded.Add(new DataItem(cb.Clone()));
                    columnsNeeded.Add(da.Parent.KeyAttribute.KeyColumns[0]);
                    return GetQueryDefinition(d, nc, new DsvTableBinding(sDsvID, cb.TableID), columnsNeeded);
                }
                else
                {
                    throw new Exception("GetQueryDefinition does not currently support a ColumnBinding on a object of type " + nc.GetType().Name);
                }
            }
            else
            {
                throw new Exception("Not a supported query binding type: " + b.GetType().FullName);
            }

            return sQuery.ToString();
        }