コード例 #1
0
        /// <summary>
        /// Loads a visualization layout from the specified file.
        /// </summary>
        /// <param name="filename">File to load visualization layout.</param>
        /// <returns>The new visualization container.</returns>
        public static VisualizationContainer Load(string filename)
        {
            var serializer = JsonSerializer.Create(
                new JsonSerializerSettings()
            {
                Formatting                     = Formatting.Indented,
                NullValueHandling              = NullValueHandling.Ignore,
                ReferenceLoopHandling          = ReferenceLoopHandling.Ignore,
                TypeNameHandling               = TypeNameHandling.Auto,
                TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple,
            });

            StreamReader jsonFile = null;

            try
            {
                jsonFile = File.OpenText(filename);
                using (var jsonReader = new JsonTextReader(jsonFile))
                {
                    jsonFile = null;
                    VisualizationContainer container = serializer.Deserialize <VisualizationContainer>(jsonReader);
                    return(container);
                }
            }
            finally
            {
                jsonFile?.Dispose();
            }
        }
コード例 #2
0
        /// <summary>
        /// Called internally by the VisualizationPanel to connect the parent chain.
        /// </summary>
        /// <param name="panel">Panel to connect this visualization object to.</param>
        internal void SetParentPanel(VisualizationPanel panel)
        {
            if (this.panel != null)
            {
                this.OnDisconnect();
                this.navigator.CursorChanged -= this.OnCursorChanged;
                this.panel     = null;
                this.container = null;
                this.navigator = null;
            }

            if (panel != null)
            {
                this.panel     = panel;
                this.container = this.panel.Container;
                this.navigator = this.container.Navigator;
                this.navigator.CursorChanged += this.OnCursorChanged;
                this.OnConnect();
            }
        }