Пример #1
0
        /// <summary>
        /// The contructor function of frmProgress
        /// </summary>
        /// <param name="title">The title of the form</param>
        /// <param name="automation">The automation component to use</param>
        /// <param name="tp">The type of output</param>
        public frmProgress(string title, IAutomation automation, OfficePlate.OutputModeType tp)
        {
            InitializeComponent();

            modetype = tp;
            ia = automation;
            td = new Thread(new ThreadStart(Begin));
        }
Пример #2
0
        private bool SaveDataSource()
        {
            int rowcount = dataGridViewDataSource.Rows.Count;
            OfficePlate platenew = new OfficePlate();
            for (int i = 0; i < rowcount - 1; i++)
            {
                DataSourceItem di = new DataSourceItem();
                object objcaption = dataGridViewDataSource.Rows[i].Cells["ColumnCaption"].Value;
                if (objcaption == null || objcaption.ToString().Trim().Length == 0)
                {
                    MessageBox.Show("Caption can not be empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return false;
                }
                di.Caption = objcaption.ToString();
                object objdatasource = dataGridViewDataSource.Rows[i].Cells["ColumnDataSource"].Value;
                if (objdatasource == null || objdatasource.ToString().Trim().Length == 0)
                {
                    MessageBox.Show("DataSource can not be empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return false;
                }
                di.DataSource = DesignerHost.Container.Components[objdatasource.ToString()];
                object objdatamember = dataGridViewDataSource.Rows[i].Cells["ColumnDataMember"].Value;
                if (objdatamember == null || objdatamember.ToString().Trim().Length == 0)
                {
                    MessageBox.Show("DataMember can not be empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return false;
                }
                di.DataMember = objdatamember.ToString();
                DataSourceImageColumnCollections dc = dataGridViewDataSource.Rows[i].Cells["ColumnImageColumns"].Tag as DataSourceImageColumnCollections;
                for (int j = 0; j < dc.Count; j++)
                {
                    di.ImageColumns.Add(dc[j]);
                }
                platenew.DataSource.Add(di);
            }

            IComponentChangeService ComponentChangeService =
               this.DesignerHost.GetService(typeof(IComponentChangeService)) as IComponentChangeService;

            object oldValue = null;
            object newValue = null;

            PropertyDescriptor desDataSource = TypeDescriptor.GetProperties(plate)["DataSource"];
            ComponentChangeService.OnComponentChanging(this.plate, desDataSource);
            oldValue = plate.DataSource;
            plate.DataSource = platenew.DataSource;
            newValue = plate.DataSource;
            ComponentChangeService.OnComponentChanged(plate, desDataSource, oldValue, newValue);

            tabPageDataSource.Text = "DataSource Defination";
            btnSaveDataSource.Enabled = false;
            btnUndoDataSource.Enabled = false;
            return true;
        }
Пример #3
0
 /// <summary>
 /// The function used to analyze tag
 /// </summary>
 /// <param name="op">The plate to design</param>
 /// <param name="stag">The name of tag</param>
 /// <returns></returns>
 public object[] DebugDetail(OfficePlate op, string stag)
 {
     object[] objvalue =  Automation.AnalyzeTag(op, stag);
     switch ((Automation.TagType)objvalue[0])
     {
         case Automation.TagType.Constant:
             {
                 foreach (TagItem ti in op.Tags)
                 {
                     if (ti.DataField == ((object[])objvalue[1])[0].ToString())
                     {
                         return new object[]{0};
                     }
                 }
                 return new object[]{1, "Constant Tag not defined in Plate","error"};
             }
         case Automation.TagType.DataSource:
             {
                 return new object[]{0};
             }
         case Automation.TagType.Function:
             {
                 string name = ((object[])objvalue[1])[0].ToString();
                 string param = ((object[])objvalue[1])[1].ToString();
                 foreach (TagItem ti in op.Tags)
                 {
                     if (ti.DataField.StartsWith(name) && ti.DataField.Length > name.Length)
                     {
                         string defparam = ti.DataField.Substring(name.Length).Trim();
                         if (defparam[0] == '(' && defparam[defparam.Length - 1] == ')')
                         {
                             string[] arrparam = param.Split(',');
                             string[] arrdefparm = defparam.Split(',');
                             if (arrparam.Length == arrdefparm.Length)
                             {
                                 return new object[] { 0 };
                             }
                         }
                     }
                 }
                 return new object[] { 1, "Function Tag not defined in Plate, if you have defined it in the form, then ignore this message", "warning" };
             }
         default:
             {
                 string message = ((object[])objvalue[1])[0].ToString();
                 return new object[] {1, message, "error" };
             }
     }
 }
Пример #4
0
 /// <summary>
 /// Create a new instance of frmDesigner
 /// </summary>
 /// <param name="op">The plate to design</param>
 /// <param name="host">The designer host</param>
 public frmDesigner(OfficePlate op, IDesignerHost host)
 {
     InitializeComponent();
     plate = op;
     DesignerHost = host;
 }
Пример #5
0
        private bool SaveTag()
        {
            int rowcount = dataGridViewTag.Rows.Count;
            OfficePlate platenew = new OfficePlate();
            for (int i = 0; i < rowcount - 1; i++)
            {
                TagItem ti = new TagItem();
                object objdatafield = dataGridViewTag.Rows[i].Cells["ColumnDataField"].Value;
                if (objdatafield == null || objdatafield.ToString().Trim().Length == 0)
                {
                    MessageBox.Show("DataField can not be empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return false;
                }
                ti.DataField = objdatafield.ToString();
                object objexpression = dataGridViewTag.Rows[i].Cells["ColumnExpression"].Value;
                if (objexpression == null || objexpression.ToString().Trim().Length == 0)
                {
                    MessageBox.Show("Expression can not be empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return false;
                }
                ti.Exp = objexpression.ToString();
                object objformat = dataGridViewTag.Rows[i].Cells["ColumnFormat"].Value;
                if (objformat == null)
                {
                    objformat = string.Empty;
                }
                ti.Format = objformat.ToString();
                platenew.Tags.Add(ti);
            }

            IComponentChangeService ComponentChangeService =
               this.DesignerHost.GetService(typeof(IComponentChangeService)) as IComponentChangeService;

            object oldValue = null;
            object newValue = null;

            PropertyDescriptor desTags = TypeDescriptor.GetProperties(plate)["Tags"];
            ComponentChangeService.OnComponentChanging(this.plate, desTags);
            oldValue = plate.Tags;
            plate.Tags = platenew.Tags;
            newValue = plate.Tags;
            ComponentChangeService.OnComponentChanged(plate, desTags, oldValue, newValue);

            tabPageTag.Text = "Tag Defination";
            btnSaveTag.Enabled = false;
            btnUndoTag.Enabled = false;
            return true;
        }