コード例 #1
0
        public void ShowDialogWin(string message, string caption, double width, double height, double left, double top, bool isManualStartupPosition)
        {
            XamDialogWindow commonDialogWin = new XamDialogWindow()
            {
                Width = width,
                Height = height,
                Header = caption,
                StartupPosition = isManualStartupPosition ? Infragistics.Controls.Interactions.StartupPosition.Manual : Infragistics.Controls.Interactions.StartupPosition.Center,
                Left = left,
                Top = top,
                IsModal = true,
                CloseButtonVisibility = Visibility.Collapsed,
                MinimizeButtonVisibility = Visibility.Collapsed,
                MaximizeButtonVisibility = Visibility.Collapsed,
                Name = "_CommonDialogWin"
            };

            TextBlock msgLabel = new TextBlock() { Foreground = new SolidColorBrush(Colors.Blue), Text = message, Margin = new Thickness(10), VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, TextWrapping = TextWrapping.Wrap };
            Button okBtn = new Button() { Content = "OK", Width = 80, Height = 25, VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(5), HorizontalAlignment = HorizontalAlignment.Center, Tag = commonDialogWin, TabIndex = 1 };
            okBtn.Click += new RoutedEventHandler(okBtn_Click);

            StackPanel msgPanel = new StackPanel();
            msgPanel.Margin = new Thickness(5);
            msgPanel.HorizontalAlignment = HorizontalAlignment.Center;
            msgPanel.VerticalAlignment = VerticalAlignment.Center;
            msgPanel.Children.Add(msgLabel);
            ScrollViewer scrollViewer = new ScrollViewer();
            scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            scrollViewer.VerticalContentAlignment = VerticalAlignment.Stretch;
            scrollViewer.Content = msgPanel;
            Grid.SetRow(scrollViewer, 0);

            StackPanel btnPanel = new StackPanel();
            btnPanel.Margin = new Thickness(5);
            btnPanel.HorizontalAlignment = HorizontalAlignment.Center;
            btnPanel.VerticalAlignment = VerticalAlignment.Bottom;
            btnPanel.Children.Add(okBtn);
            Grid.SetRow(btnPanel, 1);

            Grid layoutGrid = new Grid();
            layoutGrid.RowDefinitions.Add(new RowDefinition());
            layoutGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            layoutGrid.Children.Add(scrollViewer);
            layoutGrid.Children.Add(btnPanel);

            commonDialogWin.Content = layoutGrid;
            int columnSpan = this._LayoutContainer.ColumnDefinitions.Count;
            int rowSpan = this._LayoutContainer.RowDefinitions.Count;
            if (columnSpan > 0) Grid.SetColumnSpan(commonDialogWin, columnSpan);
            if (rowSpan > 0) Grid.SetRowSpan(commonDialogWin, rowSpan);

            if (!this._LayoutContainer.Children.Contains(commonDialogWin))
            {
                this._LayoutContainer.Children.Add(commonDialogWin);
            }
            this._CommonDialogWins.Add(commonDialogWin);
            commonDialogWin.Show();
        }
コード例 #2
0
        private void ClearEvents(XamDialogWindow dw)
        {
            if (dw.Tag != null)
            {
                Guid id;
                if (!Guid.TryParse(dw.Tag.ToString(), out id))
                {
                    return;
                }

                XamDialogWindow xw;
                DialogWindowsCollection.TryRemove(id, out xw);
            }

            dw.SizeChanged     -= OnDwSizeChanged;
            dw.Loaded          -= XamDialogWindow_Loaded;
            dw.Unloaded        -= XamDialogWindow_Unloaded;
            dw.IsActiveChanged -= xamDialogWindow_IsActiveChanged;
            dw.RemoveHandler(UIElement.KeyDownEvent, new KeyEventHandler(XamDialogWindow_KeyDown));

            var closable = (dw.Content as IClosebleContent);

            if (closable != null && closable.Close != null)
            {
                closable.Close.Invoke();
            }

            var children = dw.Content as ILocalChildren;

            if (children != null)
            {
                if (children.OnClose != null)
                {
                    children.OnClose.Invoke();
                }
            }

            var d = dw.Content as IDisposable;

            if (d != null)
            {
                d.Dispose();
            }

            dw.Content = null;

            if (object.Equals(dw, _messageWindow))
            {
                _messageWindow = null;
            }
            Children.Remove(dw);
        }
コード例 #3
0
        private void NavAppInfoDialogButton_Click(object sender, RoutedEventArgs e)
        {
            var winInfo = new About();
            var win     = new XamDialogWindow
            {
                Width           = winInfo.GetDesiredSize().Width,
                Height          = winInfo.GetDesiredSize().Height + 80,
                StartupPosition = StartupPosition.Center,
                Content         = winInfo,
                IsModal         = true,
                IsResizable     = false,
            };

            this.AppInfoContainer.Children.Add(win);
        }
コード例 #4
0
ファイル: MainWindow.xaml.cs プロジェクト: breeswish/molocker
        private XamDialogWindow CreateDialogWindow(String header, String content)
        {
            var dialog = new XamDialogWindow()
            {
                Width           = 350,
                Height          = 100,
                StartupPosition = StartupPosition.Center,
                //CloseButtonVisibility = Visibility.Collapsed,
                Header  = header,
                Content = content,
                IsModal = true
            };

            return(dialog);
        }
コード例 #5
0
        private void NavAppInfoDialogButton_Click(object sender, RoutedEventArgs e)
        {
            var winInfo = new AboutView();
            var win     = new XamDialogWindow
            {
                Width               = winInfo.GetDesiredSize().Width,
                Height              = winInfo.GetDesiredSize().Height + 80,
                StartupPosition     = StartupPosition.Center,
                Content             = winInfo,
                IsModal             = true,
                IsResizable         = false,
                RestrictInContainer = true,
                Style               = Application.Current.Resources["AppDialogWindowStyle"] as Style
            };

            this.AppInfoContainer.Children.Add(win);
        }
コード例 #6
0
        private void ToggleWindow(XamDialogWindow dialog)
        {
            if (dialog == null)
            {
                return;
            }
            switch (dialog.WindowState)
            {
            case WindowState.Maximized:
            case WindowState.Normal:
                dialog.WindowState = WindowState.Minimized;
                break;

            case WindowState.Minimized:
                dialog.WindowState = WindowState.Normal;
                break;
            }
        }
コード例 #7
0
        private void NavAppInfoDialogButton_Click(object sender, RoutedEventArgs e)
        {
            var winInfo = new AboutView();
            var win     = new XamDialogWindow
            {
                Width           = winInfo.GetDesiredSize().Width,
                Height          = winInfo.GetDesiredSize().Height + 80,
                StartupPosition = StartupPosition.Center,
                Content         = winInfo,
                IsModal         = true,
                ModalBackground = new SolidColorBrush(Colors.Black)
                {
                    Opacity = 0.75
                },
                IsResizable = false,
                Header      = AppStrings.AppView_About,
            };

            this.AppInfoContainer.Children.Add(win);
        }
コード例 #8
0
ファイル: MainWindow.xaml.cs プロジェクト: breeswish/molocker
        private void ShowDialog(String content, String header)
        {
            var blurEffect = new BlurEffect()
            {
                Radius = 5
            };

            containerContent.Opacity = 0.4;
            containerContent.Effect  = blurEffect;

            dialog = CreateDialogWindow(header, content);
            dialog.IsVisibleChanged += dialog_IsVisibleChanged;
            containerMain.Children.Add(dialog);

            dialogLabel                     = new Label();
            dialogLabel.Content             = content;
            dialogLabel.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            dialogLabel.VerticalAlignment   = System.Windows.VerticalAlignment.Center;

            dialog.Content = dialogLabel;
        }
コード例 #9
0
        private void NavAppInfoDialogButton_Click(object sender, RoutedEventArgs e)
        {
            var winInfo = new AboutView();
            var win     = new XamDialogWindow
            {
                Width           = winInfo.GetDesiredSize().Width,
                Height          = winInfo.GetDesiredSize().Height + 40,
                StartupPosition = StartupPosition.Center,
                Content         = winInfo,
                IsModal         = true,
                //MinimizeButtonVisibility = Visibility.Visible,
                CloseButtonVisibility = Visibility.Visible,
                HeaderIconVisibility  = Visibility.Collapsed,
                Header          = "  About",
                ModalBackground = new SolidColorBrush(Colors.White)
                {
                    Opacity = 0.8
                },
                IsResizable = false,
            };

            this.AppInfoContainer.Children.Add(win);
        }
コード例 #10
0
        private void HandleOnSettingTaskClickedEvent(object sender,Manager.Common.Settings.TaskScheduler taskScheduler)
        {
            RunSettingTaskDetail control = new RunSettingTaskDetail(taskScheduler);
            XamDialogWindow window = new XamDialogWindow();
            window.FontSize = 12;
            window.StartupPosition = StartupPosition.Center;
            window.IsModal = false;
            window.Header = "任务详细";
            window.Width = 455;
            window.Height = 345;
            window.Content = control;
            window.Show();

            this.MainFrame.Children.Add(window);
            window.BringToFront();

            control.OnExited += new RoutedEventHandler(delegate(object sender2, RoutedEventArgs e2)
            {
                window.Close();
            });
        }
コード例 #11
0
        //Reject Order DialogWin
        public void ShowRejectOrderWin(string rejectMessage, OrderTask orderTask, HandleAction action)
        {
            if (this._RejectOrderDialogWin == null)
            {
                this._RejectOrderDialogWin = new XamDialogWindow()
                {
                    Width = 300,
                    Height = 140,
                    Header = "Confirm",
                    StartupPosition = Infragistics.Controls.Interactions.StartupPosition.Center,
                    IsModal = true,
                    CloseButtonVisibility = Visibility.Collapsed,
                    MinimizeButtonVisibility = Visibility.Collapsed,
                    MaximizeButtonVisibility = Visibility.Collapsed,
                };
            }
            this._OrderTask = orderTask;
            this._HandleAction = action;
            TextBlock alertLable = new TextBlock()
            {
                Name = "AlertLable",
                Foreground = new SolidColorBrush(Colors.Blue),
                Text = "Are you sure?",
                Margin = new Thickness(5),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            TextBlock RejectOrderMessage = new TextBlock()
            {
                Name = "RejectOrderMessage",
                Foreground = new SolidColorBrush(Colors.Blue),
                Text = rejectMessage,
                Margin = new Thickness(5,15,0,0),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            StackPanel RejectOrderPanel = new StackPanel() { Name = "RejectOrderPanel", Orientation = Orientation.Vertical };
            RejectOrderPanel.Margin = new Thickness(15, 0, 0, 0);
            RejectOrderPanel.HorizontalAlignment = HorizontalAlignment.Left;
            RejectOrderPanel.VerticalAlignment = VerticalAlignment.Center;
            RejectOrderPanel.Children.Add(alertLable);
            RejectOrderPanel.Children.Add(RejectOrderMessage);

            Grid.SetRow(RejectOrderPanel, 0);

            //按钮
            Button RejectOrderOk = new Button() { Name = "RejectOrderOk", Content = "Yes", Width = 60, Height = 24, TabIndex = 1, Margin = new Thickness(25, 5, 0, 0) };
            Button RejectOrderCancel = new Button() { Name = "RejectOrderCancel", Content = "No", Width = 60, Height = 24, Margin = new Thickness(25, 5, 0, 0) };
            RejectOrderOk.Click += new RoutedEventHandler(RejectOrderOk_Click);
            RejectOrderCancel.Click += new RoutedEventHandler(RejectOrderCancel_Click);

            StackPanel panel = new StackPanel();
            panel.Orientation = Orientation.Horizontal;
            panel.Children.Add(RejectOrderOk);
            panel.Children.Add(RejectOrderCancel);
            panel.VerticalAlignment = VerticalAlignment.Bottom;
            panel.HorizontalAlignment = HorizontalAlignment.Center;
            panel.Margin = new Thickness(5);
            Grid.SetRow(panel, 1);

            Grid layoutGrid = new Grid();

            LinearGradientBrush brush = new LinearGradientBrush();
            brush.StartPoint = new Point(0.5, 0);
            brush.EndPoint = new Point(0.5, 1);
            GradientStop stop = new GradientStop();

            layoutGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50) });
            layoutGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50) });
            layoutGrid.Children.Add(RejectOrderPanel);
            layoutGrid.Children.Add(panel);

            this._RejectOrderDialogWin.Content = layoutGrid;
            int columnSpan = this._LayoutContainer.ColumnDefinitions.Count;
            int rowSpan = this._LayoutContainer.RowDefinitions.Count;
            if (columnSpan > 0) Grid.SetColumnSpan(this._RejectOrderDialogWin, columnSpan);
            if (rowSpan > 0) Grid.SetRowSpan(this._RejectOrderDialogWin, rowSpan);

            if (!this._LayoutContainer.Children.Contains(this._RejectOrderDialogWin))
            {
                this._LayoutContainer.Children.Add(this._RejectOrderDialogWin);
            }

            this._RejectOrderDialogWin.Show();
        }
コード例 #12
0
        //Account Information
        public void ShowDialogWin(AccountInfor accountInfor, string caption, OrderTask orderTask, HandleAction action)
        {
            if (this._ConfirmOrderDialogWin == null)
            {
                this._ConfirmOrderDialogWin = new XamDialogWindow()
                {
                    Width = 350,
                    Height = 450,
                    Header = caption,
                    StartupPosition = Infragistics.Controls.Interactions.StartupPosition.Center,
                    IsModal = true,
                    CloseButtonVisibility = Visibility.Collapsed,
                    MinimizeButtonVisibility = Visibility.Collapsed,
                    MaximizeButtonVisibility = Visibility.Collapsed,
                };
                this._OrderTask = orderTask;
                this._HandleAction = action;
            }
            else
            {
                this._ConfirmOrderDialogWin.Width = 350;
                this._ConfirmOrderDialogWin.Height = 450;
                this._ConfirmOrderDialogWin.Header = caption;
                this._ConfirmOrderDialogWin.Content = null;
            }
            TextBlock BLLable = new TextBlock()
            {
                Name = "BL",
                Foreground = new SolidColorBrush(Colors.White),
                Text = "BL",
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            TextBlock BalanceLable = new TextBlock()
            {
                Name = "Balance",
                Foreground = new SolidColorBrush(Colors.White),
                Text = "Balance",
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            TextBlock EquityLable = new TextBlock()
            {
                Name = "Equity",
                Foreground = new SolidColorBrush(Colors.White),
                Text = "Equity",
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            TextBlock NecessaryLable = new TextBlock()
            {
                Name = "Necessary",
                Foreground = new SolidColorBrush(Colors.White),
                Text = "Necessary",
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            TextBlock UsableLable = new TextBlock()
            {
                Name = "Usable",
                Foreground = new SolidColorBrush(Colors.White),
                Text = "Usable",
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            TextBlock TotalBuyLable = new TextBlock()
            {
                Name = "TotalBuy",
                Foreground = new SolidColorBrush(Colors.White),
                Text = "TotalBuy",
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            TextBlock TotalSellLable = new TextBlock()
            {
                Name = "TotalSell",
                Foreground = new SolidColorBrush(Colors.White),
                Text = "TotalSell",
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            TextBlock NetLable = new TextBlock()
            {
                Name = "Net",
                Foreground = new SolidColorBrush(Colors.Blue),
                Text = "Net",
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            TextBlock SetPriceLable = new TextBlock()
            {
                Name = "SetPrice",
                Foreground = new SolidColorBrush(Colors.White),
                Text = "SetPrice",
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            TextBlock ExecutePriceLable = new TextBlock()
            {
                Name = "ExecutePrice",
                Foreground = new SolidColorBrush(Colors.White),
                Text = "ExecutePrice",
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };
            TextBlock LotLable = new TextBlock()
            {
                Name = "Lot",
                Foreground = new SolidColorBrush(Colors.White),
                Text = "Lot",
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };

            StackPanel captionPanel = new StackPanel() { Name = "captionPanel", Orientation = Orientation.Vertical };
            captionPanel.Margin = new Thickness(0, 10, 0, 0);
            captionPanel.HorizontalAlignment = HorizontalAlignment.Center;
            captionPanel.VerticalAlignment = VerticalAlignment.Center;
            captionPanel.Children.Add(BLLable);
            captionPanel.Children.Add(BalanceLable);
            captionPanel.Children.Add(EquityLable);
            captionPanel.Children.Add(NecessaryLable);
            captionPanel.Children.Add(UsableLable);
            captionPanel.Children.Add(TotalBuyLable);
            captionPanel.Children.Add(TotalSellLable);
            captionPanel.Children.Add(NetLable);
            captionPanel.Children.Add(SetPriceLable);
            captionPanel.Children.Add(ExecutePriceLable);
            captionPanel.Children.Add(LotLable);

            Grid.SetRow(captionPanel, 0);
            Grid.SetColumn(captionPanel, 0);

            //Value Column
            CheckBox BLCheckBox = new CheckBox()
            {
                Name = "BLText",
                Foreground = new SolidColorBrush(Colors.White),
                IsChecked = true,
                Margin = new Thickness(8),
                IsEnabled = true,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right
            };
            TextBlock BalanceText = new TextBlock()
            {
                Name = "BalanceText",
                Foreground = new SolidColorBrush(Colors.White),
                Text = accountInfor.Balance.ToString(),
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right
            };
            TextBlock EquityText = new TextBlock()
            {
                Name = "EquityText",
                Foreground = new SolidColorBrush(Colors.White),
                Text = accountInfor.Equity.ToString(),
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right
            };
            TextBlock NecessaryText = new TextBlock()
            {
                Name = "NecessaryText",
                Foreground = new SolidColorBrush(Colors.White),
                Text = accountInfor.Necessary.ToString(),
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right
            };
            TextBlock UsableText = new TextBlock()
            {
                Name = "UsableText",
                Foreground = new SolidColorBrush(Colors.White),
                Text = accountInfor.Usable.ToString(),
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right
            };
            TextBlock TotalBuyText = new TextBlock()
            {
                Name = "TotalBuyText",
                Foreground = new SolidColorBrush(Colors.White),
                Text = accountInfor.BuyLotBalanceSum.ToString(),
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right
            };
            TextBlock TotalSellText = new TextBlock()
            {
                Name = "TotalSellText",
                Foreground = new SolidColorBrush(Colors.White),
                Text = accountInfor.SellLotBalanceSum.ToString(),
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right
            };
            TextBlock NetText = new TextBlock()
            {
                Name = "NetText",
                Foreground = new SolidColorBrush(Colors.White),
                Text = (accountInfor.BuyLotBalanceSum - accountInfor.SellLotBalanceSum).ToString(),
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right
            };
            TextBlock SetPriceText = new TextBlock()
            {
                Name = "SetPriceText",
                Foreground = new SolidColorBrush(Colors.White),
                Text = orderTask.SetPrice,
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right
            };
            TextBlock ExecutePriceText = new TextBlock()
            {
                Name = "ExecutePriceText",
                Foreground = new SolidColorBrush(Colors.White),
                Text = orderTask.SetPrice,
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right
            };
            TextBox LotText = new TextBox()
            {
                Name = "LotText",
                Width = 100,
                Foreground = new SolidColorBrush(Colors.Blue),
                Text = orderTask.Lot.ToString(),
                Margin = new Thickness(8),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right,
                TextAlignment = TextAlignment.Right
            };

            StackPanel valuePanel = new StackPanel() { Name = "valuePanel", Orientation = Orientation.Vertical };
            valuePanel.Margin = new Thickness(0, 10, 0, 0);
            valuePanel.HorizontalAlignment = HorizontalAlignment.Right;
            valuePanel.VerticalAlignment = VerticalAlignment.Center;
            valuePanel.Children.Add(BLCheckBox);
            valuePanel.Children.Add(BalanceText);
            valuePanel.Children.Add(EquityText);
            valuePanel.Children.Add(NecessaryText);
            valuePanel.Children.Add(UsableText);
            valuePanel.Children.Add(TotalBuyText);
            valuePanel.Children.Add(TotalSellText);
            valuePanel.Children.Add(NetText);
            valuePanel.Children.Add(SetPriceText);
            valuePanel.Children.Add(ExecutePriceText);
            valuePanel.Children.Add(LotText);

            Grid.SetRow(valuePanel, 0);
            Grid.SetColumn(valuePanel, 1);

            //按钮
            Button ok = new Button() { Name = "okBtn", Content = "Yes", Width = 60, Height = 25, TabIndex = 1, Margin = new Thickness(25, 0, 0, 0) };
            Button cancel = new Button() { Name = "cancelBtn", Content = "No", Width = 60, Height = 25, Margin = new Thickness(25, 0, 0, 0) };
            ok.Click += new RoutedEventHandler(ok_Click);
            cancel.Click += new RoutedEventHandler(cancel_Click);

            StackPanel panel = new StackPanel();
            panel.Orientation = Orientation.Horizontal;
            panel.Children.Add(ok);
            panel.Children.Add(cancel);
            panel.VerticalAlignment = VerticalAlignment.Bottom;
            panel.HorizontalAlignment = HorizontalAlignment.Center;
            panel.Margin = new Thickness(5);
            Grid.SetRow(panel, 1);
            Grid.SetColumnSpan(panel, 2);

            Grid layoutGrid = new Grid();

            LinearGradientBrush brush = new LinearGradientBrush();
            brush.StartPoint = new Point(0.5, 0);
            brush.EndPoint = new Point(0.5, 1);
            GradientStop stop = new GradientStop();

            stop = new GradientStop();
            stop.Color = Colors.LightGray;
            stop.Offset = 0.25;

            stop = new GradientStop();
            stop.Color = Color.FromArgb(0XFF, 0x4F, 0x4F, 0x4F);
            stop.Offset = 0.65;
            brush.GradientStops.Add(stop);

            layoutGrid.Background = brush;

            layoutGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(350) });
            layoutGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50) });
            layoutGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(160) });
            layoutGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(160) });
            layoutGrid.Children.Add(captionPanel);
            //layoutGrid.Children.Add(scrollViewer2);
            layoutGrid.Children.Add(valuePanel);
            layoutGrid.Children.Add(panel);

            this._ConfirmOrderDialogWin.Content = layoutGrid;
            int columnSpan = this._LayoutContainer.ColumnDefinitions.Count;
            int rowSpan = this._LayoutContainer.RowDefinitions.Count;
            if (columnSpan > 0) Grid.SetColumnSpan(this._ConfirmOrderDialogWin, columnSpan);
            if (rowSpan > 0) Grid.SetRowSpan(this._ConfirmOrderDialogWin, rowSpan);

            if (!this._LayoutContainer.Children.Contains(this._ConfirmOrderDialogWin))
            {
                this._LayoutContainer.Children.Add(this._ConfirmOrderDialogWin);
            }

            this._ConfirmOrderDialogWin.Show();
        }
コード例 #13
0
        public void ShowYesNoDialog(string message, Action yesMethod)
        {
            var currPage = WorkPage.CurrentPage;

            if (currPage == null)
            {
                return;
            }

            if (_messageWindow == null)
            {
                _messageWindow = new XamDialogWindow
                {
                    StartupPosition        = StartupPosition.Center,
                    ModalBackground        = System.Windows.Media.Brushes.LightSteelBlue,
                    ModalBackgroundOpacity = 0.3,
                    IsModal     = true,
                    IsResizable = true,
                };

                SetRowSpan(_messageWindow, 10);
                SetColumnSpan(_messageWindow, 10);

                Children.Add(_messageWindow);
                _messageWindow.WindowStateChanged += s_WindowStateChanged;
                //_messageWindow.IsActiveChanged += xamDialogWindow_IsActiveChanged;
            }

            var messagePanel = _messageWindow.Content as MessagePanel;

            if (messagePanel == null)
            {
                try
                {
                    messagePanel           = new MessagePanel(yesMethod, true);
                    _messageWindow.Content = messagePanel;
                }
                catch
                {
                }
            }

            if (messagePanel == null)
            {
                return;
            }

            messagePanel.AddOrUpdateMessage(message, false);

            if (_messageWindow.WindowState == WindowState.Hidden)
            {
                _messageWindow.Show();
                _messageWindow.CenterDialogWindow();
            }

            _messageWindow.BringToFront();
            _messageWindow.IsActive = true;

            _messageWindow.Dispatcher.BeginInvoke((Action)(() =>
            {
                var mp = _messageWindow.Content as MessagePanel;
                if (mp == null)
                {
                    return;
                }

                var lv = mp.FindName("lvMessages") as ListView;
                if (lv == null)
                {
                    return;
                }


                //Подогнать размер под содержимое
                _messageWindow.Height = lv.ActualHeight + 90;
                //_messageWindow.Width = lv.ActualWidth + 30;
                _messageWindow.UpdateLayout();
            }), DispatcherPriority.Background);
        }
コード例 #14
0
        private void buttonNewFile_Click(object sender, RoutedEventArgs e)
        {
            XamDialogWindow win = CreateDialogWindow(150);

            win.Header = "创建文件";

            StackPanel stack = new StackPanel();

            stack.VerticalAlignment = VerticalAlignment.Center;
            stack.Margin            = new Thickness(10);

            Label label = new Label();

            label.Content = "请输入文件名";
            stack.Children.Add(label);

            TextBox txtName = new TextBox();

            txtName.Text = "文本文件.txt";
            stack.Children.Add(txtName);

            StackPanel stackButton = new StackPanel();

            stackButton.Orientation         = Orientation.Horizontal;
            stackButton.HorizontalAlignment = HorizontalAlignment.Center;
            stack.Children.Add(stackButton);

            Button btnOK = new Button();

            btnOK.Content = "创建";
            btnOK.Padding = new Thickness(10, 0, 10, 0);
            btnOK.Margin  = new Thickness(10);
            stackButton.Children.Add(btnOK);
            Button btnCancel = new Button();

            btnCancel.Content = "取消";
            btnCancel.Padding = new Thickness(10, 0, 10, 0);
            btnCancel.Margin  = new Thickness(10);
            stackButton.Children.Add(btnCancel);

            FadeOutWindow();

            win.Content = stack;
            win.IsModal = true;
            windowContainer.Children.Add(win);

            txtName.Focus();

            btnOK.Click += delegate
            {
                VFS.Directory dir = vfs.NewDirectory(currentDirectory);
                if (dir.Contains(txtName.Text))
                {
                    System.Windows.Forms.MessageBox.Show("该文件或文件夹已存在", "创建失败", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    txtName.Focus();
                    return;
                }
                try
                {
                    VFS.File file = vfs.NewFile(currentDirectory + txtName.Text, VFS.FileMode.CreateNew);
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message, "创建失败", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    txtName.Focus();
                    return;
                }
                win.Close();
                windowContainer.Children.Remove(win);
                FadeInWindow();
                Reload();
            };

            btnCancel.Click += delegate
            {
                win.Close();
                windowContainer.Children.Remove(win);
                FadeInWindow();
            };
        }
コード例 #15
0
        public void ShowDialogWin(string message, string caption, double width, double height)
        {
            if (this._ConfirmDialogWin == null)
            {
                this._ConfirmDialogWin = new XamDialogWindow()
                {
                    Width = width,
                    Height = height,
                    Header = caption,
                    StartupPosition = Infragistics.Controls.Interactions.StartupPosition.Center,
                    IsModal = true,
                    CloseButtonVisibility = Visibility.Collapsed,
                    MinimizeButtonVisibility = Visibility.Collapsed,
                    MaximizeButtonVisibility = Visibility.Collapsed,
                };
            }
            else
            {
                this._ConfirmDialogWin.Width = width;
                this._ConfirmDialogWin.Height = height;
                this._ConfirmDialogWin.Header = caption;
                this._ConfirmDialogWin.Content = null;
            }
            TextBlock msgLabel = new TextBlock() { Name = "msgLabel", Foreground = new SolidColorBrush(Colors.Blue), Text = message, Margin = new Thickness(10), VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, TextWrapping = TextWrapping.Wrap };

            Button ok = new Button() { Name = "okBtn", Content = "Yes", Width = 80, Height = 25, TabIndex = 1, Margin = new Thickness(8) };
            Button cancel = new Button() { Name = "cancelBtn", Content = "No", Width = 80, Height = 25 };
            ok.Click += new RoutedEventHandler(ok_Click);
            cancel.Click += new RoutedEventHandler(cancel_Click);

            StackPanel msgPanel = new StackPanel() { Name = "msgPanel" };
            msgPanel.Margin = new Thickness(5);
            msgPanel.HorizontalAlignment = HorizontalAlignment.Center;
            msgPanel.VerticalAlignment = VerticalAlignment.Center;
            msgPanel.Children.Add(msgLabel);
            ScrollViewer scrollViewer = new ScrollViewer();
            scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            scrollViewer.VerticalContentAlignment = VerticalAlignment.Stretch;
            scrollViewer.Content = msgPanel;
            Grid.SetRow(scrollViewer, 0);

            StackPanel panel = new StackPanel();
            panel.Orientation = Orientation.Horizontal;
            panel.Children.Add(ok);
            panel.Children.Add(cancel);
            panel.VerticalAlignment = VerticalAlignment.Bottom;
            panel.HorizontalAlignment = HorizontalAlignment.Center;
            panel.Margin = new Thickness(5);

            Grid layoutGrid = new Grid();
            layoutGrid.RowDefinitions.Add(new RowDefinition());
            layoutGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            layoutGrid.Children.Add(scrollViewer);
            layoutGrid.Children.Add(panel);

            this._ConfirmDialogWin.Content = layoutGrid;
            int columnSpan = this._LayoutContainer.ColumnDefinitions.Count;
            int rowSpan = this._LayoutContainer.RowDefinitions.Count;
            if (columnSpan > 0) Grid.SetColumnSpan(this._ConfirmDialogWin, columnSpan);
            if (rowSpan > 0) Grid.SetRowSpan(this._ConfirmDialogWin, rowSpan);

            if (!this._LayoutContainer.Children.Contains(this._ConfirmDialogWin))
            {
                this._LayoutContainer.Children.Add(this._ConfirmDialogWin);
            }

            this._ConfirmDialogWin.Show();
        }
コード例 #16
0
 public void Close()
 {
     if (this._ConfirmDialogWin != null)
     {
         this._LayoutContainer.Children.Remove(this._ConfirmDialogWin);
         this._ConfirmDialogWin.Close();
         this._ConfirmDialogWin = null;
     }
 }
コード例 #17
0
 private void Close(XamDialogWindow commonDialogWin)
 {
     if (commonDialogWin != null)
     {
         commonDialogWin.WindowState = Infragistics.Controls.Interactions.WindowState.Hidden;
         commonDialogWin.Close();
         this._LayoutContainer.Children.Remove(commonDialogWin);
         commonDialogWin = null;
     }
 }
コード例 #18
0
        private void ButtonTool_Click(object sender, RoutedEventArgs e)
        {
            XamDialogWindow win = new XamDialogWindow()
            {
                Width                 = 350,
                Height                = 150,
                StartupPosition       = StartupPosition.Center,
                CloseButtonVisibility = Visibility.Collapsed
            };

            win.Header = "格式化";
            StackPanel stack = new StackPanel();

            stack.VerticalAlignment = VerticalAlignment.Center;
            stack.Margin            = new Thickness(10);

            Label label = new Label();

            label.Content = "您确认要格式化文件系统吗?";
            stack.Children.Add(label);

            StackPanel stackButton = new StackPanel();

            stackButton.Orientation         = Orientation.Horizontal;
            stackButton.HorizontalAlignment = HorizontalAlignment.Center;
            stack.Children.Add(stackButton);

            Button btnOK = new Button();

            btnOK.Content = "格式化";
            btnOK.Padding = new Thickness(10, 0, 10, 0);
            btnOK.Margin  = new Thickness(10);
            stackButton.Children.Add(btnOK);
            Button btnCancel = new Button();

            btnCancel.Content = "取消";
            btnCancel.Padding = new Thickness(10, 0, 10, 0);
            btnCancel.Margin  = new Thickness(10);
            stackButton.Children.Add(btnCancel);

            //FadeOutWindow();

            win.Content = stack;
            win.IsModal = true;
            grid.Children.Add(win);

            btnOK.Click += delegate {
                VFS.Format();
                currentDir = VFS.ROOT_DIR;
                recorder.Add(currentDir);
                listView.ItemsSource = VFS.ROOT_DIR.directoryData;
                url.Text             = currentDir.GetPath();
                win.Close();
                grid.Children.Remove(win);
            };

            btnCancel.Click += delegate
            {
                win.Close();
                grid.Children.Remove(win);
            };
        }
コード例 #19
0
        private void ButtonTool_Rename(object sender, RoutedEventArgs e)
        {
            Information inf = (Information)listView.SelectedItem;

            if (inf == null)
            {
                System.Windows.Forms.MessageBox.Show("请先选中文件或者文件夹", "选中失败", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return;
            }
            XamDialogWindow win = new XamDialogWindow()
            {
                Width                 = 350,
                Height                = 150,
                StartupPosition       = StartupPosition.Center,
                CloseButtonVisibility = Visibility.Collapsed
            };

            win.Header = "重命名";
            StackPanel stack = new StackPanel();

            stack.VerticalAlignment = VerticalAlignment.Center;
            stack.Margin            = new Thickness(10);

            Label label = new Label();

            label.Content = "请输入新的名称:";
            stack.Children.Add(label);

            TextBox txtName = new TextBox();

            txtName.Text = inf.name;
            stack.Children.Add(txtName);

            StackPanel stackButton = new StackPanel();

            stackButton.Orientation         = Orientation.Horizontal;
            stackButton.HorizontalAlignment = HorizontalAlignment.Center;
            stack.Children.Add(stackButton);

            Button btnOK = new Button();

            btnOK.Content = "确认";
            btnOK.Padding = new Thickness(10, 0, 10, 0);
            btnOK.Margin  = new Thickness(10);
            stackButton.Children.Add(btnOK);
            Button btnCancel = new Button();

            btnCancel.Content = "取消";
            btnCancel.Padding = new Thickness(10, 0, 10, 0);
            btnCancel.Margin  = new Thickness(10);
            stackButton.Children.Add(btnCancel);

            //FadeOutWindow();

            win.Content = stack;
            win.IsModal = true;
            grid.Children.Add(win);

            btnOK.Click += delegate {
                String name = Utils.GetLegalCopyName(txtName.Text, currentDir);
                inf.entry.SetName(name);
                foreach (var v in currentDir.directoryData)
                {
                    if (inf.name == v.name)
                    {
                        inf.name = name;
                        ICollectionView view = CollectionViewSource.GetDefaultView(listView.ItemsSource);
                        view.Refresh();
                        break;
                    }
                }
                win.Close();
                grid.Children.Remove(win);
            };

            btnCancel.Click += delegate
            {
                win.Close();
                grid.Children.Remove(win);
            };
        }
コード例 #20
0
        private void ButtonToolDelete(object sender, RoutedEventArgs e)
        {
            XamDialogWindow win = new XamDialogWindow()
            {
                Width                 = 350,
                Height                = 150,
                StartupPosition       = StartupPosition.Center,
                CloseButtonVisibility = Visibility.Collapsed
            };

            win.Header = "删除";
            StackPanel stack = new StackPanel();

            stack.VerticalAlignment = VerticalAlignment.Center;
            stack.Margin            = new Thickness(10);

            Label       label = new Label();
            Information inf   = (Information)listView.SelectedItem;

            if (inf == null)
            {
                System.Windows.Forms.MessageBox.Show("请先选中要删除文件或者文件夹", "删除失败", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return;
            }


            label.Content = "您确认要删除该" + (inf.extension == "文本文件" ? "文件" : "文件夹") + "吗?";
            stack.Children.Add(label);

            StackPanel stackButton = new StackPanel();

            stackButton.Orientation         = Orientation.Horizontal;
            stackButton.HorizontalAlignment = HorizontalAlignment.Center;
            stack.Children.Add(stackButton);

            Button btnOK = new Button();

            btnOK.Content = "删除";
            btnOK.Padding = new Thickness(10, 0, 10, 0);
            btnOK.Margin  = new Thickness(10);
            stackButton.Children.Add(btnOK);
            Button btnCancel = new Button();

            btnCancel.Content = "取消";
            btnCancel.Padding = new Thickness(10, 0, 10, 0);
            btnCancel.Margin  = new Thickness(10);
            stackButton.Children.Add(btnCancel);

            //FadeOutWindow();

            win.Content = stack;
            win.IsModal = true;
            grid.Children.Add(win);

            btnOK.Click += delegate {
                inf.entry.DeleteData();
                currentDir.directory.Remove(inf.entry);

                currentDir.directoryData.Remove(inf);
                win.Close();
                grid.Children.Remove(win);
            };

            btnCancel.Click += delegate
            {
                win.Close();
                grid.Children.Remove(win);
            };
        }
コード例 #21
0
        private void listView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            const int bufferSize = 4096;

            var item = (DirectoryItem)listView.SelectedItem;

            if (item == null)
            {
                return;
            }

            if (item.isDirectory)
            {
                if (item.name == ".")
                {
                    Reload();
                    return;
                }
                if (item.name == "..")
                {
                    GoUp();
                    return;
                }

                if (history.Count - historyNeedle - 1 > 0)
                {
                    history.RemoveRange(historyNeedle + 1, history.Count - historyNeedle - 1);
                }
                var newDir = currentDirectory + item.name + "/";
                if (LoadDirectory(newDir))
                {
                    history.Add(newDir);
                    historyNeedle++;
                    buttonForward.IsEnabled = (historyNeedle + 1 < history.Count);
                    buttonBack.IsEnabled    = (historyNeedle - 1 >= 0);
                }
            }
            else
            {
                // 读取文件内容到临时变量
                String tempFileName = System.IO.Path.GetTempFileName() + System.IO.Path.GetExtension(item.path);
                using (System.IO.BinaryWriter writer = new System.IO.BinaryWriter(new System.IO.FileStream(tempFileName, System.IO.FileMode.Create)))
                {
                    var    file   = vfs.NewFile(item.path, VFS.FileMode.Open);
                    byte[] buffer = new byte[bufferSize];
                    int    count;
                    while ((count = (int)file.Read(buffer, 0, (uint)buffer.Length)) != 0)
                    {
                        writer.Write(buffer, 0, count);
                    }
                }

                FadeOutWindow();

                XamDialogWindow win = CreateDialogWindow();
                win.Header = "VFS";

                Label label = new Label();
                label.Content = "正在等待应用程序关闭, 文件内容将在程序关闭后自动更新...";
                label.VerticalContentAlignment = VerticalAlignment.Center;
                label.HorizontalAlignment      = HorizontalAlignment.Center;

                win.Content = label;
                win.IsModal = true;
                windowContainer.Children.Add(win);

                Utils.ProcessUITasks();

                // 调用系统默认程序打开
                var process = new System.Diagnostics.Process();
                process.StartInfo           = new System.Diagnostics.ProcessStartInfo(tempFileName);
                process.EnableRaisingEvents = true;
                process.Start();

                try
                {
                    process.WaitForExit();
                }
                catch (Exception ex)
                {
                }

                // 在关闭后,读取内容写回文件系统
                using (System.IO.BinaryReader reader = new System.IO.BinaryReader(new System.IO.FileStream(tempFileName, System.IO.FileMode.Open)))
                {
                    var    file   = vfs.NewFile(item.path, VFS.FileMode.Create);
                    byte[] buffer = new byte[bufferSize];
                    int    count;
                    while ((count = reader.Read(buffer, 0, buffer.Length)) != 0)
                    {
                        file.Write(buffer, 0, (uint)count);
                    }
                }

                win.Close();
                windowContainer.Children.Remove(win);
                FadeInWindow();

                Reload();
                UpdateInfo();
            }
        }
コード例 #22
0
        //Modify SetPrice
        public void ShowDialogWin(string caption, OrderTask orderTask,string origin, HandleAction action)
        {
            if (this._ModifyPriceDialogWin == null)
            {
                this._ModifyPriceDialogWin = new XamDialogWindow()
                {
                    Width = 250,
                    Height = 150,
                    Header = caption,
                    StartupPosition = Infragistics.Controls.Interactions.StartupPosition.Center,
                    IsModal = true,
                    CloseButtonVisibility = Visibility.Collapsed,
                    MinimizeButtonVisibility = Visibility.Collapsed,
                    MaximizeButtonVisibility = Visibility.Collapsed,
                };
            }
            this._HandleAction = action;
            this._OrderTask = orderTask;
            this._Origin = origin;
            TextBlock ModifyPriceLable = new TextBlock()
            {
                Name = "ModifyPriceLable",
                Foreground = new SolidColorBrush(Colors.Blue),
                Text = "Input new Price:",
                Margin = new Thickness(5),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left
            };

            TextBox NewPriceText = new TextBox()
            {
                Name = "NewPriceText",
                Width = 100,
                Foreground = new SolidColorBrush(Colors.Blue),
                Text = orderTask.SetPrice,
                Margin = new Thickness(5),
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Left,
                TextAlignment = TextAlignment.Right
            };
            this._NewPriceElement = NewPriceText;

            StackPanel ModifyPricePanle = new StackPanel() { Name = "captionPanel", Orientation = Orientation.Horizontal };
            ModifyPricePanle.Margin = new Thickness(15, 0, 0, 0);
            ModifyPricePanle.HorizontalAlignment = HorizontalAlignment.Left;
            ModifyPricePanle.VerticalAlignment = VerticalAlignment.Center;
            ModifyPricePanle.Children.Add(ModifyPriceLable);
            ModifyPricePanle.Children.Add(NewPriceText);

            Grid.SetRow(ModifyPricePanle, 0);

            //按钮
            Button ModifyPriceOk = new Button() { Name = "ModifyPriceOkBtn", Content = "OK", Width = 60, Height = 24, TabIndex = 1, Margin = new Thickness(25, 0, 0, 0) };
            Button ModifyPriceCancel = new Button() { Name = "ModifyPriceCancelBtn", Content = "Cancel", Width = 60, Height = 24, Margin = new Thickness(25, 0, 0, 0) };
            ModifyPriceOk.Click += new RoutedEventHandler(ModifyPriceOkBtn_Click);
            ModifyPriceCancel.Click += new RoutedEventHandler(ModifyPriceCancelBtn_Click);

            StackPanel panel = new StackPanel();
            panel.Orientation = Orientation.Horizontal;
            panel.Children.Add(ModifyPriceOk);
            panel.Children.Add(ModifyPriceCancel);
            panel.VerticalAlignment = VerticalAlignment.Bottom;
            panel.HorizontalAlignment = HorizontalAlignment.Center;
            panel.Margin = new Thickness(5);
            Grid.SetRow(panel, 1);

            Grid layoutGrid = new Grid();

            LinearGradientBrush brush = new LinearGradientBrush();
            brush.StartPoint = new Point(0.5, 0);
            brush.EndPoint = new Point(0.5, 1);
            GradientStop stop = new GradientStop();

            layoutGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(40) });
            layoutGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(40) });
            layoutGrid.Children.Add(ModifyPricePanle);
            layoutGrid.Children.Add(panel);

            this._ModifyPriceDialogWin.Content = layoutGrid;
            int columnSpan = this._LayoutContainer.ColumnDefinitions.Count;
            int rowSpan = this._LayoutContainer.RowDefinitions.Count;
            if (columnSpan > 0) Grid.SetColumnSpan(this._ModifyPriceDialogWin, columnSpan);
            if (rowSpan > 0) Grid.SetRowSpan(this._ModifyPriceDialogWin, rowSpan);

            if (!this._LayoutContainer.Children.Contains(this._ModifyPriceDialogWin))
            {
                this._LayoutContainer.Children.Add(this._ModifyPriceDialogWin);
            }

            this._ModifyPriceDialogWin.Show();
        }
コード例 #23
0
        private void buttonRename_Click(object sender, RoutedEventArgs e)
        {
            var item = (DirectoryItem)listView.SelectedItem;

            if (item == null)
            {
                return;
            }

            XamDialogWindow win = CreateDialogWindow(150);

            win.Header = "重命名";

            StackPanel stack = new StackPanel();

            stack.VerticalAlignment = VerticalAlignment.Center;
            stack.Margin            = new Thickness(10);

            Label label = new Label();

            label.Content = "请输入新文件" + (item.isDirectory ? "夹" : "") + "名";
            stack.Children.Add(label);

            TextBox txtName = new TextBox();

            txtName.Text = item.name;
            stack.Children.Add(txtName);

            StackPanel stackButton = new StackPanel();

            stackButton.Orientation         = Orientation.Horizontal;
            stackButton.HorizontalAlignment = HorizontalAlignment.Center;
            stack.Children.Add(stackButton);

            Button btnOK = new Button();

            btnOK.Content = "重命名";
            btnOK.Padding = new Thickness(10, 0, 10, 0);
            btnOK.Margin  = new Thickness(10);
            stackButton.Children.Add(btnOK);
            Button btnCancel = new Button();

            btnCancel.Content = "取消";
            btnCancel.Padding = new Thickness(10, 0, 10, 0);
            btnCancel.Margin  = new Thickness(10);
            stackButton.Children.Add(btnCancel);

            FadeOutWindow();

            win.Content = stack;
            win.IsModal = true;
            windowContainer.Children.Add(win);

            txtName.Focus();

            btnOK.Click += delegate
            {
                VFS.Directory dir = vfs.NewDirectory(currentDirectory);
                if (dir.Contains(txtName.Text))
                {
                    System.Windows.Forms.MessageBox.Show("新文件或文件夹名已存在", "重命名失败", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    txtName.Focus();
                    return;
                }
                try
                {
                    dir.Rename(item.name, txtName.Text);
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message, "重命名失败", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    txtName.Focus();
                    return;
                }
                win.Close();
                windowContainer.Children.Remove(win);
                FadeInWindow();
                Reload();
            };

            btnCancel.Click += delegate
            {
                win.Close();
                windowContainer.Children.Remove(win);
                FadeInWindow();
            };
        }
コード例 #24
0
        public void ShowLocalModal(FrameworkElement content, object title, bool isResizable = true, bool isSpan = false, bool isNotCloseOnEscapeButton = false, bool allowCloseWindow = true)
        {
            var children = content as ILocalChildren;

            System.Windows.Media.Brush modalBackground = null;
            _isNotCloseOnEscapeButton = isNotCloseOnEscapeButton;
            var isTrueModal = false;
            var id          = Guid.Empty;

            if (children != null)
            {
                if (children.Id == Guid.Empty)
                {
                    children.Id = Guid.NewGuid();
                }
                id = children.Id;

                if (children.LocalModalType != EnumLocalModalType.None)
                {
                    //Проверка открыто ли окно с таким содержимым
                    if (children.LocalModalType == EnumLocalModalType.UniqueById)
                    {
                        XamDialogWindow dw;
                        if (DialogWindowsCollection.TryGetValue(id, out dw) && dw != null && dw.WindowState != WindowState.Hidden)
                        {
                            return;
                        }
                        //Изменен тип коллекции, но логика сохранена
                        //if (dw.WindowState == WindowState.Hidden) return false;
                        //if (ch == null) return false;
                        //return ch.LocalModalType == EnumLocalModalType.UniqueById && ch.Id == children.Id;
                    }

                    if (children.LocalModalType == EnumLocalModalType.TrueModal)
                    {
                        modalBackground = System.Windows.Media.Brushes.LightSteelBlue;
                        isTrueModal     = true;
                    }
                }
            }

            if (id == Guid.Empty)
            {
                id = Guid.NewGuid();
            }

            var xamDialogWindow = new XamDialogWindow
            {
                StartupPosition       = StartupPosition.Center,
                ModalBackground       = modalBackground,
                Header                = title,
                IsModal               = true,
                IsResizable           = isResizable,
                Content               = content,
                Tag                   = id,
                CloseButtonVisibility = allowCloseWindow? Visibility.Visible: Visibility.Collapsed
            };

            if (isSpan)
            {
                if (RowDefinitions.Count > 0)
                {
                    SetRowSpan(xamDialogWindow, RowDefinitions.Count);
                }
                if (ColumnDefinitions.Count > 0)
                {
                    SetColumnSpan(xamDialogWindow, ColumnDefinitions.Count);
                }
            }

            Children.Add(xamDialogWindow);

            xamDialogWindow.WindowStateChanged += s_WindowStateChanged;
            if (isTrueModal)
            {
                xamDialogWindow.IsActiveChanged += xamDialogWindow_IsActiveChanged;
            }

            xamDialogWindow.Loaded   += XamDialogWindow_Loaded;
            xamDialogWindow.Unloaded += XamDialogWindow_Unloaded;

            xamDialogWindow.Show();

            if (!DialogWindowsCollection.IsEmpty)
            {
                var prevWindow = DialogWindowsCollection.Values.Last();
                if (prevWindow != null && prevWindow.WindowState != WindowState.Hidden)
                {
                    xamDialogWindow.Margin = new Thickness(prevWindow.Margin.Left + 6, prevWindow.Margin.Top + 12, 0, 0);
                }
            }

            if (isResizable)
            {
                xamDialogWindow.SizeChanged += OnDwSizeChanged;
            }
            else if (DialogWindowsCollection.IsEmpty)
            {
                SizeChanged += OnParentSizeChanged;
            }

            DialogWindowsCollection.TryAdd(id, xamDialogWindow);

            xamDialogWindow.Dispatcher.BeginInvoke((Action)(() => { xamDialogWindow.CenterDialogWindow(); }),
                                                   DispatcherPriority.Background);
        }
コード例 #25
0
 public void Close()
 {
     if (this._ConfirmOrderDialogWin != null)
     {
         this._LayoutContainer.Children.Remove(this._ConfirmOrderDialogWin);
         this._ConfirmOrderDialogWin.Close();
         this._ConfirmOrderDialogWin = null;
     }
     if (this._ModifyPriceDialogWin != null)
     {
         this._LayoutContainer.Children.Remove(this._ModifyPriceDialogWin);
         this._ModifyPriceDialogWin.Close();
         this._ModifyPriceDialogWin = null;
     }
     if (this._RejectOrderDialogWin != null)
     {
         this._LayoutContainer.Children.Remove(this._RejectOrderDialogWin);
         this._RejectOrderDialogWin.Close();
         this._RejectOrderDialogWin = null;
     }
 }
コード例 #26
0
        public void ShowOrUpdateMessage(string message, string title, Action onClose, bool isShowDateTime)
        {
            var currPage = WorkPage.CurrentPage;

            if (currPage == null)
            {
                return;
            }

            if (_messageWindow == null)
            {
                _messageWindow = new XamDialogWindow
                {
                    StartupPosition        = StartupPosition.Center,
                    ModalBackground        = System.Windows.Media.Brushes.LightSteelBlue,
                    ModalBackgroundOpacity = 0.5,
                    Header = title,
                    HeaderIconVisibility = Visibility.Collapsed,
                    IsModal     = true,
                    IsResizable = false,
                };

                SetRowSpan(_messageWindow, 10);
                SetColumnSpan(_messageWindow, 10);

                if (Children != null)
                {
                    Children.Add(_messageWindow);
                }
                _messageWindow.WindowStateChanged += s_WindowStateChanged;
            }

            var messagePanel = _messageWindow.Content as MessagePanel;

            if (messagePanel == null)
            {
                messagePanel           = new MessagePanel(onClose);
                _messageWindow.Content = messagePanel;
            }

            messagePanel.AddOrUpdateMessage(message, isShowDateTime);

            if (_messageWindow.WindowState == WindowState.Hidden)
            {
                _messageWindow.Show();
            }

            _messageWindow.BringToFront();
            _messageWindow.IsActive = true;

            if (_messageWindow.Dispatcher == null)
            {
                return;
            }

            _messageWindow.Dispatcher.BeginInvoke((Action)(() =>
            {
                if (_messageWindow == null)
                {
                    return;
                }

                var mp = _messageWindow.Content as MessagePanel;
                if (mp == null)
                {
                    return;
                }

                var lv = mp.FindName("lvMessages") as ListView;
                if (lv == null)
                {
                    return;
                }


                //Подогнать размер под содержимое
                //lv.UpdateLayout();
                //messagePanel.UpdateLayout();
                //_messageWindow.Height = lv.ActualHeight + 90;
                //_messageWindow.Width = lv.ActualWidth + 30;
                _messageWindow.UpdateLayout();

                _messageWindow.CenterDialogWindow();
            }), DispatcherPriority.Background);
        }