コード例 #1
0
        static void Main(string[] args)
        {
            ViewX.Application a = new ViewX.Application();
            a.Logon("Local", "s", "s");
            a.Mimics.OpenFromServer(false, "Local", "");
            a.Visible = true;
            ViewX.Mimic     oMimic  = (Mimic)a.Mimics.OpenFromServer(false, "Local", "New Mimic");
            ViewX.DrwLayers oLayers = oMimic.Layers;
            oLayers.Add("Extra");
            var oSquareRef = oLayers["Extra"].AddRectangle(100000, 150000, 500000, 650000);

            oLayers["Extra"].SelectObject((DrwObject)oSquareRef);
            oMimic.ActiveLayer = oLayers["Extra"];
            oMimic.DeleteSelected();
            oMimic.Save();
            oMimic.Close();
        }
コード例 #2
0
        private static void ProcessMimic(Application vwx, string SystemName, ScxV6DbClient.IScxV6Object mimic, ScxV6DbClient.ScxV6Server db)
        {
            Console.WriteLine("Mimic, " + mimic.FullName.Replace("\"", "\"\""));
            try
            {
                // Open in ViewX
                ViewX.Mimic mim = (Mimic)vwx.Mimics.OpenFromServer(true, SystemName, mimic.FullName);

                // List animations
                foreach (ViewX.DrwGroup Layer in mim.Layers)
                {
                    mim.ActiveLayer = Layer;
                    foreach (ViewX.DrwObject Item in Layer)
                    {
                        if (Item.Type == DrwType.DrwEmbeddedList)
                        {
                            ViewX.DrwEmbeddedList List = (ViewX.DrwEmbeddedList)Item;
                            Console.WriteLine("\"" + mim.FullName.Replace("\"", "\"\"") + "\",\"" + Layer.Name.Replace("\"", "\"\"") + "\",\"" + Item.Name.Replace("\"", "\"\"") + "\",\"" + List.Sql.Replace("\"", "\"\"") + "\"");
                        }
                        foreach (ViewX.DrwAnimation Ani in Item.Animations)
                        {
                            Console.WriteLine("\"" + mim.FullName.Replace("\"", "\"\"") + "\",\"" + Layer.Name.Replace("\"", "\"\"") + "\",\"" + Item.Name.Replace("\"", "\"\"") + "\",\"" + Ani.Property.Replace("\"", "\"\"") + "\",\"" + Ani.Expression.Replace("\"", "\"\"") + "\"");
                        }
                        // Process embedded objects
                        if (Item.Type == DrwType.DrwEmbeddedMimic)
                        {
                            ViewX.DrwEmbeddedMimic mimic1 = (ViewX.DrwEmbeddedMimic)Item;
                            Console.WriteLine("\"" + mim.FullName.Replace("\"", "\"\"") + "\",Embeds,\"" + Layer.Name.Replace("\"", "\"\"") + "\",\"" + Item.Name.Replace("\"", "\"\"") + "\",\"" + mimic1.Shared + "\",\"" + mimic1.Definition.Replace("\"", "\"\"") + "\"");
                            string MimicName = mimic1.Definition;                             // Starts SCX:////CMimic/
                            int    NameStart = MimicName.IndexOf("/CMimic/") + 8;
                            MimicName = MimicName.Substring(NameStart);
                            if (MimicName.StartsWith("."))
                            {
                                //'need to convert relative to absolute, using path of mimicName
                                //'get # of dots to left of mName e.g. ..A.B -> ,,A,B
                                //'e.g. if .A then i=1, if ..A.B then i = 2
                                string[] mNameArr = MimicName.Split('.');
                                int      j        = 0;
                                for (int i = 0; i < mNameArr.Count(); i++)
                                {
                                    if (mNameArr[i] != "")
                                    {
                                        j = i;
                                        break;
                                    }
                                }
                                //'now split parent mimic path, e.g. a.b.c -> a,b,c
                                string[] mParentPath = mimic.FullName.Split('.');
                                MimicName = "";
                                //'Path folder names but not mimic name (-1), remove 1 more for each .
                                for (int i = 0; i < mParentPath.Count() - j - 1; i++)
                                {
                                    MimicName = MimicName + mParentPath[i] + ".";
                                }
                                //'now append non-blank names from relative path
                                for (int i = 0; i < mNameArr.Count(); i++)
                                {
                                    if (mNameArr[i] != "")
                                    {
                                        MimicName = MimicName + mNameArr[i] + ".";
                                    }
                                }
                                //'remove extra .
                                MimicName = MimicName.Substring(0, MimicName.Length - 1);
                            }

                            var embeddedmimic = db.FindObject(MimicName);
                            if (embeddedmimic != null)
                            {
                                ProcessMimic(vwx, SystemName, embeddedmimic, db);
                            }
                            else
                            {
                                Console.WriteLine("Error, cannot open embedded");
                            }
                        }
                    }
                }

                // Close
                mim.Close();
                Console.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error, " + e.Message.Replace("\"", "\"\""));
            }
        }