private void DisposeControl(IContentWindow window)
        {
            _contents.RemoveByValue(window);

            window.Control.Dispose();

            if (window.Tag == null)
            {
                return;
            }

            var sender = window.Tag;

            var strategyContainer = window.Tag as StrategyContainer;

            if (strategyContainer != null)
            {
                sender = strategyContainer.Strategy;
            }

            var info = window.Tag as StrategyInfo;

            if (info != null)
            {
                sender = window.Control.GetKey();
            }

            ConfigManager
            .GetService <IStudioCommandService>()
            .UnBind(sender);
        }
Пример #2
0
 internal NavigationModel(IContentWindow contentWindow)
 {
     _contentWindow = contentWindow;
 }
 public NavigationModel(IContentWindow Content)
 {
     _content = Content;
 }
Пример #4
0
 public NavigationModel(IContentWindow contentWindow)
 {
     _contentWindow = contentWindow;
 }
		private void DisposeControl(IContentWindow window)
		{
			_contents.RemoveByValue(window);

			window.Control.Dispose();

			if (window.Tag == null)
				return;

			var sender = window.Tag;

			var strategyContainer = window.Tag as StrategyContainer;
			if (strategyContainer != null)
				sender = strategyContainer.Strategy;

			var info = window.Tag as StrategyInfo;
			if (info != null)
				sender = window.Control.GetKey();

			ConfigManager
				.GetService<IStudioCommandService>()
				.UnBind(sender);
		}
Пример #6
0
 public NavigationModel(IContentWindow contentWindow)
 {
     _contentWindow = contentWindow;
     _mainView      = new ProcessListView();
 }
Пример #7
0
        /// <summary>
        /// 生成和显示弹窗方法
        /// </summary>
        protected override void Invoke(object parameter)
        {
            if (Content == null)
            {
                throw new NotFiniteNumberException("Content is null");
            }

            if (Title == null)
            {
                throw new NotFiniteNumberException("Title is null");
            }

            object[] args = null;
            if (Args != null)
            {
                args = Args.ToArray();
            }

            // 调取有参构造失败后调取无参构造,待修改
            IContentWindow  win           = null;
            BaseUserControl content       = null;
            ContentWindow   contentWindow = null;   //当前打开的窗体

            try
            {
                content = Content.Assembly.CreateInstance(Content.FullName,
                                                          true,
                                                          BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public,
                                                          null,
                                                          args,
                                                          null,
                                                          null) as BaseUserControl;
            }
            catch (Exception)
            {
                content = Content.Assembly.CreateInstance(Content.FullName) as BaseUserControl;
            }

            // 根据弹窗类型反向生成对应的的窗口类
            switch (WindowType)
            {
            case ContentWindowType.ToolBox:
                contentWindow = HasOpenedWindow(Title);
                if (contentWindow != null)
                {
                    // 若已打开,则使当前窗口弹出至最上层
                    contentWindow.Topmost = true;
                    return;
                }
                else
                {
                    win = ToolBoxContentWindow.Create(content, Title)
                          .SetContentMargin(ContentMargin)
                          .SetHeight(Height)
                          .SetWidth(Width)
                          .SetTileBackground(TileBackground)
                          .SetIcon(Icon);
                }
                break;

            case ContentWindowType.Document:
                contentWindow = HasOpenedWindow(Title);
                if (contentWindow != null)
                {
                    // 若已打开,则使当前窗口弹出至最上层
                    contentWindow.Topmost = true;
                    return;
                }
                else
                {
                    win = ConfirmContentWindow.Create(content, Title)
                          .SetContentMargin(ContentMargin)
                          .SetHeight(Height)
                          .SetTileBackground(TileBackground)
                          .SetWidth(Width);
                }
                break;

            default:
                contentWindow = HasOpenedWindow(Title);
                if (contentWindow != null)
                {
                    // 若已打开,则使当前窗口弹出至最上层
                    contentWindow.Topmost = true;
                    return;
                }
                else
                {
                    if (Title == "麻醉评分")
                    {
                        win = ContentWindow.Create(content, Title, false)
                              .SetContentMargin(ContentMargin)
                              .SetResizeMode(ResizeMode)
                              .SetMinHeight(MinHeight)
                              .SetMinWidth(MinWidth)
                              .SetHeight(Height)
                              .SetWidth(Width)
                              .SetBorderMargin(BorderMargin)
                              .SetTileBackground(TileBackground)
                              .SetIcon(content.Icon);
                    }
                    else
                    {
                        win = ContentWindow.Create(content, Title)
                              .SetContentMargin(ContentMargin)
                              .SetResizeMode(ResizeMode)
                              .SetMinHeight(MinHeight)
                              .SetMinWidth(MinWidth)
                              .SetHeight(Height)
                              .SetWidth(Width)
                              .SetBorderMargin(BorderMargin)
                              .SetTileBackground(TileBackground)
                              .SetIcon(content.Icon);
                    }
                }
                break;
            }

            //设置内容控制窗体大小
            if (!(Height > 0 & Width > 0))
            {
                (win as Window).SizeToContent = SizeToContent.WidthAndHeight;
            }

            //边界控制
            if (PositionX > 0 || PositionY > 0)
            {
                win.SetStartupLocation(WindowStartupLocation.Manual);
                //防止窗体显示不全
                //获取屏幕的边界
                double maxWidth  = SystemParameters.PrimaryScreenWidth;  //得到屏幕整体宽度
                double maxHeight = SystemParameters.PrimaryScreenHeight; //得到屏幕整体高度
                if (PositionX + Width > maxWidth)
                {
                    PositionX = maxWidth - Width - 20;
                }
                if (PositionY + Height > maxHeight & PositionY - Height > 0)
                {
                    PositionY = PositionY - Height;
                }
                else
                {
                    if (ContentName.Equals("OperationInterfaceControl"))
                    {
                    }
                    else
                    {
                        PositionY = maxHeight - Height - 5;
                    }
                }

                win.SetX(PositionX);
                win.SetY(PositionY);
            }
            else
            {
                win.SetStartupLocation(WindowStartupLocation.CenterScreen);
            }

            content.CallBack = obj => { if (CallBackCommand != null)
                                        {
                                            CallBackCommand.Execute(obj);
                                        }
            };
            content.Close        = () => (win as Window).Close();
            content.ParentWindow = (win as Window);

            var vm = content.DataContext as BaseViewModel;

            if (vm != null)
            {
                vm.Args = args;
                vm.CloseContentWindowDelegate = () => (win as Window).Close();
            }

            (win as Window).Loaded += ShowContentWindowAction_Loaded;
            (win as Window).Closed += (s1, e1) =>
            {
                content.Dispose();
                object result = null;
                if (vm != null)
                {
                    if (vm.Result != null)
                    {
                        result = vm.Result;
                    }
                }
                else
                {
                    result = content.Result;
                }

                // 出发回调函数
                if (CallBackCommand != null)
                {
                    CallBackCommand.Execute(result);
                }

                // 设置返回值
                if (ContentMessage != null)
                {
                    ContentMessage.Result = result;
                }
                //content.DataContext = null;
                //content = null;
                //(win as Window).Content = null;
                //win = null;
            };

            if (win is ContentWindow)
            {
                ContentWindow contentWin = win as ContentWindow;
                contentWin.ClosingAction = (s1, e1) =>
                {
                    if (e1.Cancel)
                    {
                        return;
                    }
                    if (!contentWin.IsAnimationCloseWindow)
                    {
                        double durationTime = 0.2;
                        switch (WindowAnimation)
                        {
                        case ContentWindowAnimation.FadeIn:
                            e1.Cancel = true;
                            DoubleAnimation daShow = new DoubleAnimation();
                            daShow.From     = 1;
                            daShow.To       = 0.4;
                            daShow.Duration = TimeSpan.FromSeconds(durationTime);
                            contentWin.IsAnimationCloseWindow = true;
                            daShow.Completed += (sender, e) =>
                            {
                                (s1 as Window).Close();
                            };
                            (s1 as Window).BeginAnimation(Window.OpacityProperty, daShow);
                            break;

                        case ContentWindowAnimation.VerticalFloating:
                            TranslateTransform tt       = new TranslateTransform();
                            DoubleAnimation    da       = new DoubleAnimation();
                            Duration           duration = new Duration(TimeSpan.FromSeconds(durationTime));
                            (s1 as Window).RenderTransform = tt;
                            tt.Y        = 0;
                            da.To       = (s1 as Window).ActualHeight;
                            da.Duration = duration;
                            contentWin.IsAnimationCloseWindow = true;
                            da.Completed += (sender, e) => { (s1 as Window).Close(); };
                            tt.BeginAnimation(TranslateTransform.YProperty, da);
                            e1.Cancel = true;
                            break;

                        case ContentWindowAnimation.HorizontalFloating:
                            TranslateTransform ttHorizontal       = new TranslateTransform();
                            DoubleAnimation    daHorizontal       = new DoubleAnimation();
                            Duration           durationHorizontal = new Duration(TimeSpan.FromSeconds(durationTime));
                            (s1 as Window).RenderTransform = ttHorizontal;
                            daHorizontal.From                 = 0;
                            daHorizontal.To                   = -(s1 as Window).ActualWidth;
                            daHorizontal.Duration             = durationHorizontal;
                            contentWin.IsAnimationCloseWindow = true;
                            daHorizontal.Completed           += (sender, e) => { (s1 as Window).Close(); };
                            ttHorizontal.BeginAnimation(TranslateTransform.XProperty, daHorizontal);
                            e1.Cancel = true;
                            break;
                        }
                    }
                    else
                    {
                        e1.Cancel = false;
                    }
                };
            }

            if (this.Owner != null)
            {
                win.SetOwner(Owner);
            }

            if (IsModal)
            {
                win.ShowDialog();
            }
            else
            {
                win.Show();
            }
        }