/// <summary>
        /// Binary saves the diagram
        /// </summary>
        /// <param name="fileName">the file-path</param>
        /// <param name="site">the graph-control instance to be serialized</param>
        /// <returns></returns>
        public static bool SaveAs(string fileName, GraphControl site)
        {
            FileStream fs = new FileStream(fileName, FileMode.Create);

            BinaryFormatter f = new BinaryFormatter();

            try
            {
                BinaryCapsule capsule = new BinaryCapsule();
                capsule.Ambiance = GetControlAmbiance(site);
                capsule.Abstract = site.extract;

                capsule.Thumbnail = site.GetControlThumbnail(150, 150);


                //Warning!: cleaning up, you need to unhook all events since unserializable classes hooked to events will give problems
                f.Serialize(fs, capsule);
                return(true);
            }
            catch (Exception exc)
            {
                site.OutputInfo("The graph was not saved, because some graph events were attached to non-serializable classes.\r\n This is a known issue and will be resolved in a later stadium.", OutputInfoLevels.Exception);
                Trace.WriteLine(exc.Message, "BinarySerializer.SaveAs");

                //DumpInfo();
            }
            catch
            {
                Trace.WriteLine("Non-CLS exception caught.", "BinarySerializer.SaveAs");
            }
            finally
            {
                fs.Close();
            }
            return(false);
        }
        /// <summary>
        /// Opens the binary-saved diagram
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="site"></param>
        public static void Open(string fileName, GraphControl site)
        {
            FileStream fs = null;

            try
            {
                fs = File.OpenRead(fileName);
            }
            catch (System.IO.DirectoryNotFoundException exc)
            {
                System.Windows.Forms.MessageBox.Show(exc.Message);
            }
            catch (System.IO.FileLoadException exc)
            {
                System.Windows.Forms.MessageBox.Show(exc.Message);
            }
            catch (System.IO.FileNotFoundException exc)
            {
                System.Windows.Forms.MessageBox.Show(exc.Message);
            }
            catch
            {
                site.OutputInfo("Non-CLS exception caught.", "BinarySerializer.SaveAs", OutputInfoLevels.Exception);
            }
            //donnot open anything if filestream is not there
            if (fs == null)
            {
                return;
            }
            try
            {
                BinaryFormatter f = new BinaryFormatter();

                //this added for temporarily solving the open file issue
                //of different namespace of customed shapes: SequenceShape, IfShape etc.
                //if save flowchart data file using one version, open with another version,
                //exception raised: "无法找到程序集..."
                //TODO: remove below statement for release version
                f.Binder = new UBinder();

                BinaryCapsule capsule = (BinaryCapsule)f.Deserialize(fs);  //so simple, so powerful

                GraphAbstract tmp = capsule.Abstract;

                SetControlAmbiance(site, capsule.Ambiance);

                tmp.Site = site;
                //site.extract = new GraphAbstract();
                site.extract = tmp;


                //the paintables are not serialized and need to be filled
                site.extract.paintables.AddRange(site.extract.Shapes);
                site.extract.paintables.AddRange(site.extract.Connections);
                site.extract.SortPaintables();


                UnwrapBundle(tmp, site);
            }
            catch (SerializationException exc)
            {
                System.Windows.Forms.MessageBox.Show(exc.Message);
            }
            catch (System.Reflection.TargetInvocationException exc)
            {
                site.OutputInfo(exc.Message, "BinarySerializer.Open", OutputInfoLevels.Exception);
            }
            catch (Exception exc)
            {
                site.OutputInfo(exc.Message, "BinarySerializer.Open", OutputInfoLevels.Exception);
            }
            catch
            {
                site.OutputInfo("Non-CLS exception caught.", "BinarySerializer.Open", OutputInfoLevels.Exception);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }
        }
        /// <summary>
        /// Opens the binary-saved diagram
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="site"></param>
        public static void Open(string fileName, GraphControl site)
        {
            FileStream fs = null;

            try
            {
                fs = File.OpenRead(fileName);
            }
            catch (System.IO.DirectoryNotFoundException exc)
            {
                System.Windows.Forms.MessageBox.Show(exc.Message);
            }
            catch (System.IO.FileLoadException exc)
            {
                System.Windows.Forms.MessageBox.Show(exc.Message);
            }
            catch (System.IO.FileNotFoundException exc)
            {
                System.Windows.Forms.MessageBox.Show(exc.Message);
            }
            catch
            {
                site.OutputInfo("Non-CLS exception caught.", "BinarySerializer.SaveAs", OutputInfoLevels.Exception);
            }
            //donnot open anything if filestream is not there
            if (fs == null)
            {
                return;
            }
            try
            {
                BinaryFormatter f = new BinaryFormatter();

                BinaryCapsule capsule = (BinaryCapsule)f.Deserialize(fs);                  //so simple, so powerful

                GraphAbstract tmp = capsule.Abstract;

                SetControlAmbiance(site, capsule.Ambiance);

                tmp.Site = site;
                //site.extract = new GraphAbstract();
                site.extract = tmp;


                //the paintables are not serialized and need to be filled
                site.extract.paintables.AddRange(site.extract.Shapes);
                site.extract.paintables.AddRange(site.extract.Connections);
                site.extract.SortPaintables();


                UnwrapBundle(tmp, site);
            }
            catch (SerializationException exc)
            {
                System.Windows.Forms.MessageBox.Show(exc.Message);
            }
            catch (System.Reflection.TargetInvocationException exc)
            {
                site.OutputInfo(exc.Message, "BinarySerializer.Open", OutputInfoLevels.Exception);
            }
            catch (Exception exc)
            {
                site.OutputInfo(exc.Message, "BinarySerializer.Open", OutputInfoLevels.Exception);
            }
            catch
            {
                site.OutputInfo("Non-CLS exception caught.", "BinarySerializer.Open", OutputInfoLevels.Exception);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }
        }