Пример #1
0
        /// <summary>
        /// 执行加载命令
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void ExecuteLoad(object sender, ExecutedRoutedEventArgs e)
        {
            if (sender == null)
            {
                throw new ArgumentNullException("sender");
            }
            var owner = sender as RibbonView;

            if (owner != null)
            {
                //取消当前缩略图关联(防止加载图元一直刷新缩略图)
                owner.navigationPane.Diagram = null;

                #region 加载SVG图
                owner.diagram.Clear();
                var fileName = string.Empty;
#if DEBUG
                fileName = @"Config\TideView.svg";
#else
                var ofd = new OpenFileDialog {
                    Filter = @"SVG 图形 (*.svg)|*.svg|所有文件 (*.*)|*.*"
                };
                if (ofd.ShowDialog() == true)
                {
                    fileName = ofd.FileName;
                }
#endif
                if (!string.IsNullOrEmpty(fileName))
                {
                    var figures = SvgReader.LoadSvgFile(fileName);
                    foreach (var figure in figures)
                    {
                        owner.AddFigureToDiagram(figure);
                    }
                }
                #endregion

                //将缩略图重置关联
                owner.navigationPane.Diagram = owner.diagram;
            }
        }