Beispiel #1
0
        public override void Write(ModelDoc2 md)
        {
            if (md != null)
            {
                Configuration cf = md.ConfigurationManager.ActiveConfiguration;

                CustomPropertyManager gcpm = md.Extension.get_CustomPropertyManager(string.Empty);
                CustomPropertyManager scpm = md.Extension.get_CustomPropertyManager(string.Empty);

                if (SWCustPropMgr != null)
                {
                    scpm = SWCustPropMgr;
                }

                // Null reference on drawings. Not good. Let's just make everything global if there's no config.
                if (cf != null)
                {
                    scpm = md.Extension.get_CustomPropertyManager(cf.Name);
                }

                // Rather than changing values, we'll just completely overwrite them.
                swCustomPropertyAddOption_e ao = swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd;
                int    res;
                string v = ID;
                res = gcpm.Add3(this.Name, (int)swCustomInfoType_e.swCustomInfoNumber, v, (int)ao);
            }
            //base.Write(md);
        }
        public void Write2(ModelDoc2 md)
        {
            if (md != null &&
                (!Old ^ (Properties.Settings.Default.Testing && Old)))
            {
                Configuration cf = md.ConfigurationManager.ActiveConfiguration;

                CustomPropertyManager gcpm = md.Extension.get_CustomPropertyManager(string.Empty);
                CustomPropertyManager scpm = md.Extension.get_CustomPropertyManager(string.Empty);

                if (SWCustPropMgr != null)
                {
                    scpm = SWCustPropMgr;
                }

                // Null reference on drawings. Not good. Let's just make everything global if there's no config.
                if (cf != null)
                {
                    scpm = md.Extension.get_CustomPropertyManager(cf.Name);
                }

                // Rather than changing values, we'll just completely overwrite them.
                swCustomPropertyAddOption_e ao = swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd;

                // This is for checking if the writing actually happened. It usually does. Don't know what I'd do if it didn't.
                int res;
                switch (Type)
                {
                case swCustomInfoType_e.swCustomInfoDate:
                    res = gcpm.Add3(Name, (int)Type, Value, (int)ao);
                    break;

                case swCustomInfoType_e.swCustomInfoDouble:
                    res = gcpm.Add3(Name, (int)Type, Value, (int)ao);
                    break;

                case swCustomInfoType_e.swCustomInfoNumber:
                    if (Global)
                    {
                        if (Name.ToUpper().Contains("BLANK") || Name.ToUpper().Contains("CRC"))
                        {
                            res = gcpm.Add3(Name, (int)this.Type, Value, (int)ao);
                        }
                        else
                        {
                            res = gcpm.Add3(Name, (int)Type, ID, (int)ao);
                        }
                    }
                    else
                    {
                        scpm.Add3(Name, (int)Type, ID, (int)ao);
                    }
                    break;

                case swCustomInfoType_e.swCustomInfoText:
                    if (!Name.ToUpper().StartsWith("STUB"))
                    {
                        if (Global)
                        {
                            if (Name.ToUpper().EndsWith("ID"))
                            {
                                res = gcpm.Add3(Name, (int)swCustomInfoType_e.swCustomInfoNumber, ID, (int)ao);
                            }
                            else if (Name.ToUpper().StartsWith("OP"))// && !Name.ToUpper().EndsWith("ID"))
                            {
                                res = gcpm.Add3(Name, (int)Type, Descr, (int)ao);
                            }
                            else if (Name.ToUpper().Contains("UPDATE"))
                            {
                                res = gcpm.Add3(Name, (int)swCustomInfoType_e.swCustomInfoYesOrNo, (ID == "True" ? "Yes" : "N"), (int)ao);
                            }
                            else
                            {
                                res = gcpm.Add3(Name, (int)Type, Value, (int)ao);
                            }
                        }
                        else
                        {
                            res = scpm.Add3(Name, (int)Type, Value, (int)ao);
                        }
                    }
                    break;

                case swCustomInfoType_e.swCustomInfoUnknown:
                    break;

                case swCustomInfoType_e.swCustomInfoYesOrNo:
                    if (Ctl != null)
                    {
                        if ((Ctl as System.Windows.Forms.CheckBox).Checked)
                        {
                            res = gcpm.Add3(Name, (int)Type, "Yes", (int)ao);
                        }
                        else
                        {
                            res = gcpm.Add3(Name, (int)Type, "N", (int)ao);
                        }
                    }
                    else
                    {
                        res = gcpm.Add3(Name, (int)Type, Value, (int)ao);
                    }
                    break;

                default: // we never get here, of course.
                    break;
                }
            }
        }
        /// <summary>
        /// Writes data using the custom property managers of a selected ModelDoc2.
        /// </summary>
        /// <param name="md">A ModelDoc2 object</param>
        public virtual void Write(ModelDoc2 md)
        {
            if (md != null)
            {
                Configuration cf = md.ConfigurationManager.ActiveConfiguration;

                CustomPropertyManager gcpm = md.Extension.get_CustomPropertyManager(string.Empty);
                CustomPropertyManager scpm = md.Extension.get_CustomPropertyManager(string.Empty);

                if (SWCustPropMgr != null)
                {
                    scpm = SWCustPropMgr;
                }

                // Null reference on drawings. Not good. Let's just make everything global if there's no config.
                if (cf != null)
                {
                    scpm = md.Extension.get_CustomPropertyManager(cf.Name);
                }

                // Rather than changing values, we'll just completely overwrite them.
                swCustomPropertyAddOption_e ao = swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd;

                // This is for checking if the writing actually happened. It usually does. Don't know what I'd do if it didn't.
                int res;
                if (Global)
                {
                    // This is a global prop that gets a db ID #, so instead of an actual description, we get the # from the datarow in the combobox.
                    if ((
                            ((Name.ToUpper().StartsWith("OP") && !Name.ToUpper().EndsWith("ID"))) ||
                            Name.ToUpper().Contains("DEPARTMENT")) &&
                        Ctl != null &&
                        Properties.Settings.Default.Testing)
                    {
                        System.Data.DataRowView drv = ((Ctl as System.Windows.Forms.ComboBox).SelectedItem as System.Data.DataRowView);
                        string v = Descr;
                        res = gcpm.Add3(Name, (int)swCustomInfoType_e.swCustomInfoText, v, (int)ao);
                    }

                    if (((Name.ToUpper().EndsWith("ID")) ||
                         Name.ToUpper().Contains("DEPT")) && Ctl != null)
                    {
                        string v = ID;
                        res = gcpm.Add3(this.Name, (int)swCustomInfoType_e.swCustomInfoNumber, v, (int)ao);
                    }
                    else if (this.Name.ToUpper().Contains("UPDATE"))
                    {
                        this.Type = swCustomInfoType_e.swCustomInfoYesOrNo;
                        if ((Ctl as System.Windows.Forms.CheckBox).Checked)
                        {
                            res = gcpm.Add3(Name, (int)Type, "Yes", (int)ao);
                        }
                        else
                        {
                            res = gcpm.Add3(Name, (int)Type, "NO", (int)ao);
                        }
                    }
                    else // Regular text, double, and date type global props can just be written.
                    {
                        res = gcpm.Add3(Name, (int)Type, Value, (int)ao);
                    }
                }
                else
                {
                    // Configuration specific props.
                    if (Name.Contains("CUTLIST MATERIAL") && Properties.Settings.Default.Testing)
                    {
                        string v = Descr;
                        res = scpm.Add3(Name, (int)swCustomInfoType_e.swCustomInfoText, v, (int)ao);
                    }

                    if (Name.Contains("EDGE") && Properties.Settings.Default.Testing)
                    {
                        string v = Descr;
                        res = scpm.Add3(Name, (int)swCustomInfoType_e.swCustomInfoText, v, (int)ao);
                    }
                }
            }
            else
            {
            }
        }