コード例 #1
0
ファイル: AlertDialogBackend.cs プロジェクト: garuma/xwt
 public AlertDialogBackend()
 {
     this.buttons = MessageBoxButton.OKCancel;
     this.icon = MessageBoxImage.None;
     this.options = MessageBoxOptions.None;
     this.defaultResult = MessageBoxResult.Cancel;
 }
コード例 #2
0
        private void authorizationButton_Click(object sender, RoutedEventArgs e)
        {
            string login = loginComboBox.SelectedValue.ToString();
            string password = passwordTextBox.Password;          

            if (AuthorizationDefend.EntranceToSystem(login, password) == false)
            {
                MessageBoxResult result = new MessageBoxResult();
                result=MessageBox.Show("Ошибка авторизации! Неверный ввод пароля.", "Ошибка авторизации", MessageBoxButton.OK, MessageBoxImage.Error);

                if (result == MessageBoxResult.OK)
                {
                    loginComboBox.SelectedIndex = 0;
                    passwordTextBox.Clear();
                }
            }
            else
            {
                mainMenuWindow mainMenuWindow = new mainMenuWindow();

                if (loginComboBox.SelectedIndex == 0)
                {
                    mainMenuWindow.Title = "Администратор: Главное меню";
                }
                else
                {
                    mainMenuWindow.Title = "Пользователь: Главное меню";
                }
                
                mainMenuWindow.Show();
                this.Close();
            }
            
        }
コード例 #3
0
ファイル: ModernDialog.cs プロジェクト: gro-ove/actools
        protected void CloseWithResult(MessageBoxResult? result) {
            if (result.HasValue) {
                MessageBoxResult = result.Value;

                try {
                    // sets the Window.DialogResult as well
                    // ReSharper disable once SwitchStatementMissingSomeCases
                    switch (result.Value) {
                        case MessageBoxResult.OK:
                        case MessageBoxResult.Yes:
                            DialogResult = true;
                            break;
                        case MessageBoxResult.Cancel:
                        case MessageBoxResult.No:
                            DialogResult = false;
                            break;
                        default:
                            DialogResult = null;
                            break;
                    }
                } catch (InvalidOperationException) {
                    // TODO: Maybe there is a better way?
                }
            }

            Close();
        }
コード例 #4
0
ファイル: ModernDialog.cs プロジェクト: 3A9C/ITstep
        /// <summary>
        /// Initializes a new instance of the <see cref="ModernDialog"/> class.
        /// </summary>
        public ModernDialog()
        {
            this.DefaultStyleKey = typeof(ModernDialog);
            this.WindowStartupLocation = WindowStartupLocation.CenterOwner;

            this.closeCommand = new RelayCommand(o => {
                var result = o as MessageBoxResult?;
                if (result.HasValue) {
                    this.messageBoxResult = result.Value;

                    // sets the Window.DialogResult as well
                    if (result.Value == MessageBoxResult.OK || result.Value == MessageBoxResult.Yes) {
                        this.DialogResult = true;
                    }
                    else if (result.Value == MessageBoxResult.Cancel || result.Value == MessageBoxResult.No){
                        this.DialogResult = false;
                    }
                    else{
                        this.DialogResult = null;
                    }
                }
                Close();
            });

            this.Buttons = new Button[] { this.CloseButton };

            // set the default owner to the app main window (if possible)
            if (Application.Current != null && Application.Current.MainWindow != this) {
                this.Owner = Application.Current.MainWindow;
            }
        }
コード例 #5
0
        public static MessageBoxResult Show(
            Action<Window> setOwner,
            CultureInfo culture,
            string messageBoxText,
            string caption,
            WPFMessageBoxButton button,
            MessageBoxImage icon,
            MessageBoxResult defaultResult,
            MessageBoxOptions options)
        {
            if ((options & MessageBoxOptions.DefaultDesktopOnly) == MessageBoxOptions.DefaultDesktopOnly)
            {
                throw new NotImplementedException();
            }

            if ((options & MessageBoxOptions.ServiceNotification) == MessageBoxOptions.ServiceNotification)
            {
                throw new NotImplementedException();
            }
            //LocalizeDictionary.Instance.Culture = CultureInfo.GetCultureInfo("de");
            _messageBoxWindow = new WPFMessageBoxWindow();

            setOwner(_messageBoxWindow);

            PlayMessageBeep(icon);
            //FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(
            //            XmlLanguage.GetLanguage(culture.IetfLanguageTag)));
            _messageBoxWindow._viewModel = new MessageBoxViewModel(_messageBoxWindow, culture, caption, messageBoxText, button, icon, defaultResult, options);
            _messageBoxWindow.DataContext = _messageBoxWindow._viewModel;
            _messageBoxWindow.ShowDialog();
            return _messageBoxWindow._viewModel.Result;
        }
        public static MessageBoxResult Show(
            Action<Window> setOwner,
            string messageBoxText, 
            string caption, 
            MessageBoxButton button, 
            MessageBoxImage icon, 
            MessageBoxResult defaultResult, 
            MessageBoxOptions options)
        {
            if ((options & MessageBoxOptions.DefaultDesktopOnly) == MessageBoxOptions.DefaultDesktopOnly)
            {
                throw new NotImplementedException();
            }

            if ((options & MessageBoxOptions.ServiceNotification) == MessageBoxOptions.ServiceNotification)
            {
                throw new NotImplementedException();
            }

            _messageBoxWindow = new WpfMessageBoxWindow();

            setOwner(_messageBoxWindow);

            PlayMessageBeep(icon);

            _messageBoxWindow._viewModel = new MessageBoxViewModel(_messageBoxWindow, caption, messageBoxText, button, icon, defaultResult, options);
            _messageBoxWindow.DataContext = _messageBoxWindow._viewModel;
            _messageBoxWindow.ShowDialog();
            return _messageBoxWindow._viewModel.Result;
        }
コード例 #7
0
 public static void ShowAsync(string text, MessageBoxButton button = MessageBoxButton.OK,
     MessageBoxImage image = MessageBoxImage.Information, MessageBoxResult defaultButton = MessageBoxResult.OK)
 {
     new Thread(
         new ThreadStart(delegate { MessageBox.Show(text, Resources.AppName, button, image, defaultButton); }))
         .Start();
 }
コード例 #8
0
ファイル: MessageDialog.cs プロジェクト: Orange637/WpfStudy
        private static MessageBoxResult ShowCore(
            string messageBoxText,
            string caption,
            MessageBoxButton button,
            MessageDialogImage icon,
            MessageBoxResult defaultResult)
        {
            if (!IsValidMessageBoxButton(button))
            {
                throw new InvalidEnumArgumentException("button", (int)button, typeof(MessageBoxButton));
            }

            if (!IsValidMessageDialogImage(icon))
            {
                throw new InvalidEnumArgumentException("icon", (int)icon, typeof(MessageBoxImage));
            }

            if (!IsValidMessageBoxResult(defaultResult))
            {
                throw new InvalidEnumArgumentException("defaultResult", (int)defaultResult, typeof(MessageBoxResult));
            }

            var dialog = new Dialog(messageBoxText, caption, button, icon, defaultResult);
            var flag = dialog.ShowDialog();
            return flag == true ? MessageBoxResult.No : MessageBoxResult.None;
        }
コード例 #9
0
ファイル: DialogService.cs プロジェクト: modulexcite/AlphaVSX
      private static OLEMSGDEFBUTTON ToOleDefault(MessageBoxResult defaultResult, MessageBoxButton button)
      {
         switch (button)
         {
            case MessageBoxButton.OK:
               return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;

            case MessageBoxButton.OKCancel:
               if (defaultResult == MessageBoxResult.Cancel)
                  return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND;

               return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;

            case MessageBoxButton.YesNoCancel:
               if (defaultResult == MessageBoxResult.No)
                  return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND;
               if (defaultResult == MessageBoxResult.Cancel)
                  return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_THIRD;

               return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;

            case MessageBoxButton.YesNo:
               if (defaultResult == MessageBoxResult.No)
                  return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND;

               return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;
         }

         return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;
      }
コード例 #10
0
ファイル: MessageBox.cs プロジェクト: jonnylin/TimeTracking
        public static async Task<MessageBoxResult> ShowAsyncModified(string msg, string cap, string optionOne, string optionTwo)
        {
            MessageBoxResult i = new MessageBoxResult();

            // Create the message dialog and set its content and title
            var messageDialog = new MessageDialog("New updates have been found for this program. Would you like to install the new updates?", "Updates available");

            // Add commands and set their callbacks
            messageDialog.Commands.Add(new UICommand(optionOne, (command) =>
            {
                i = MessageBoxResult.Working;
            }));

            messageDialog.Commands.Add(new UICommand(optionTwo, (command) =>
            {
                i = MessageBoxResult.NonWorking;
            }));

            messageDialog.Commands.Add(new UICommand("Cancel", (command) =>
            {
                i = MessageBoxResult.Cancel;
            }));

            // Set the command that will be invoked by default
            messageDialog.DefaultCommandIndex = (uint)MessageBoxResult.Cancel;

            // Show the message dialog
            await messageDialog.ShowAsync();

            return i;
        }
コード例 #11
0
    /// <summary>
    /// Called when the dialog completes.
    /// </summary>
    /// <param name="result">The result of the message box.</param>
    public void DialogComplete(MessageBoxResult result)
    {
      if (CompleteCallback == null)
        return;

      CompleteCallback(result);
    }
コード例 #12
0
 public MessageBoxButtonViewModel(string text, MessageBoxResult result, Action<MessageBoxResult> returnAction, bool hasInitFocus = false)
 {
     m_text = text;
       m_result = result;
       m_hasInitFocus = hasInitFocus;
       m_command = new GenericManualCommand<MessageBoxResult>(returnAction);
 }
コード例 #13
0
 public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult)
 {
     if (_provider != null)
         return _provider.Show(messageBoxText, caption, button, icon, defaultResult);
     else
         return MessageBox.Show(messageBoxText, caption, button, icon, defaultResult);
 }
コード例 #14
0
ファイル: AlertDialogBackend.cs プロジェクト: m13253/xwt
		public Command Run (WindowFrame transientFor, MessageDescription message)
		{
			this.icon = GetIcon (message.Icon);
			if (ConvertButtons (message.Buttons, out buttons)) {
				// Use a system message box
				if (message.SecondaryText == null)
					message.SecondaryText = String.Empty;
				else {
					message.Text = message.Text + "\r\n\r\n" + message.SecondaryText;
					message.SecondaryText = String.Empty;
				}
				var wb = (WindowFrameBackend)Toolkit.GetBackend (transientFor);
				if (wb != null) {
					this.dialogResult = MessageBox.Show (wb.Window, message.Text, message.SecondaryText,
														this.buttons, this.icon, this.defaultResult, this.options);
				}
				else {
					this.dialogResult = MessageBox.Show (message.Text, message.SecondaryText, this.buttons,
														this.icon, this.defaultResult, this.options);
				}
				return ConvertResultToCommand (this.dialogResult);
			}
			else {
				// Custom message box required
				Dialog dlg = new Dialog ();
				dlg.Resizable = false;
				dlg.Padding = 0;
				HBox mainBox = new HBox { Margin = 25 };

				if (message.Icon != null) {
					var image = new ImageView (message.Icon.WithSize (32,32));
					mainBox.PackStart (image, vpos: WidgetPlacement.Start);
				}
				VBox box = new VBox () { Margin = 3, MarginLeft = 8, Spacing = 15 };
				mainBox.PackStart (box, true);
				var text = new Label {
					Text = message.Text ?? ""
				};
				Label stext = null;
				box.PackStart (text);
				if (!string.IsNullOrEmpty (message.SecondaryText)) {
					stext = new Label {
						Text = message.SecondaryText
					};
					box.PackStart (stext);
				}
				dlg.Buttons.Add (message.Buttons.ToArray ());
				if (mainBox.Surface.GetPreferredSize (true).Width > 480) {
					text.Wrap = WrapMode.Word;
					if (stext != null)
						stext.Wrap = WrapMode.Word;
					mainBox.WidthRequest = 480;
				}
				var s = mainBox.Surface.GetPreferredSize (true);

				dlg.Content = mainBox;
				return dlg.Run ();
			}
		}
コード例 #15
0
ファイル: MessageDialog.cs プロジェクト: Orange637/WpfStudy
 private static bool IsValidMessageBoxResult(MessageBoxResult value)
 {
     return value == MessageBoxResult.Cancel
         || value == MessageBoxResult.No
         || value == MessageBoxResult.None
         || value == MessageBoxResult.OK
         || value == MessageBoxResult.Yes;
 }
コード例 #16
0
 /// <summary>
 /// Prepares the message box to be displayed.
 /// </summary>
 /// <param name="text">The message box's text.</param>
 /// <param name="caption">The message box's caption.</param>
 /// <param name="button">A <see cref="MessageBoxButton"/> value that specifies the set of buttons to display.</param>
 /// <param name="image">A <see cref="MessageBoxImage"/> value that specifies the image to display.</param>
 /// <param name="defaultResult">A <see cref="MessageBoxResult"/> value that specifies the message box's default option.</param>
 internal void Prepare(String text, String caption, MessageBoxButton button, MessageBoxImage image, MessageBoxResult defaultResult)
 {
     var vm = screen.View.GetViewModel<MessageBoxViewModel>();
     if (vm != null)
     {
         vm.Prepare(text, caption, button, image, defaultResult);
     }
 }
コード例 #17
0
ファイル: Warning.cs プロジェクト: xigolle/MapEditorcSharp
 public Warning(string text, string title, MessageBoxButton button, MessageBoxImage image)
 {
     messageTitle = title;
     messageText = text;
     messageImage = image;
     messageButton = button;
     result = MessageBox.Show(messageText, messageTitle, messageButton, messageImage);
 }
コード例 #18
0
 public bool? Show(string message,
     string title = DefaultTitle,
     MessageBoxButton button = DefaultButton,
     MessageBoxImage icon = DefaultIcon,
     MessageBoxResult defaultResult = DefaultResult)
 {
     return this.uiShell.ShowMessageBox(message, title, button, icon, defaultResult);
 }
コード例 #19
0
 public MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxResult defaultResult) {
     MessageBoxTest = messageBoxText;
     Caption = caption;
     Button = button;
     DefaultResult = defaultResult;
     ShowCount++;
     return Result;
 }
コード例 #20
0
 public MessageBoxResult Prompt(string message,
     string title = DefaultTitle,
     MessageBoxButton button = DefaultButton,
     MessageBoxImage icon = MessageBoxImage.Question,
     MessageBoxResult defaultResult = DefaultResult)
 {
     return this.uiShell.Prompt(message, title, button, icon, defaultResult);
 }
コード例 #21
0
ファイル: MessageBox.cs プロジェクト: prshreshtha/ultraviolet
        /// <summary>
        /// Displays the specified message box as a modal dialog.
        /// </summary>
        /// <param name="mb">The message box to display.</param>
        /// <param name="text">The text to display.</param>
        /// <param name="caption">The caption to display.</param>
        /// <param name="button">A <see cref="MessageBoxButton"/> value that specifies the set of buttons to display.</param>
        /// <param name="image">A <see cref="MessageBoxImage"/> value that specifies the image to display.</param>
        /// <param name="defaultResult">A <see cref="MessageBoxResult"/> value that specifies the message box's default option.</param>
        public static void Show(MessageBoxModal mb, String text, String caption, MessageBoxButton button, MessageBoxImage image, MessageBoxResult defaultResult)
        {
            Contract.Require(mb, "mb");
            
            mb.Prepare(text, caption, button, image, defaultResult);

            Modal.ShowDialog(mb);
        }
コード例 #22
0
ファイル: MessageBoxNotifier.cs プロジェクト: dirv/ServerMap
 public MessageBoxResult Notify(
     string message,
     string caption,
     MessageBoxButton buttons,
     MessageBoxImage image,
     MessageBoxResult defaultResult)
 {
     return MessageBox.Show(message, caption, buttons, image, defaultResult);
 }
コード例 #23
0
 //Button Exit Click
 private void DatabaseSettingButtonExitClick(object sender, System.Windows.RoutedEventArgs e)
 {
     MessageBoxResult messBoxResult = new MessageBoxResult();
     messBoxResult = Microsoft.Windows.Controls.MessageBox.Show(Variables.ERROR_MESSAGES[1, 1], Variables.ERROR_MESSAGES[0, 0], MessageBoxButton.YesNo, MessageBoxImage.Question);
     if (messBoxResult.Equals(MessageBoxResult.Yes))
     {
         Application.Current.Shutdown();
     }
 }
コード例 #24
0
        public static MessageBoxResult ShowMessage(string text, string caption, MessageBoxButton buttons, MessageBoxImage icon)
        {
            Action action = new Action(() =>
            lastResult = MessageBox.Show(_Window, text, caption, buttons, icon));

            Invoke(action);

            return lastResult;
        }
コード例 #25
0
ファイル: MessageDialog.cs プロジェクト: Orange637/WpfStudy
 public static MessageBoxResult Show(
     string messageBoxText,
     string caption,
     MessageBoxButton button,
     MessageDialogImage icon,
     MessageBoxResult defaultResult)
 {
     return ShowCore(messageBoxText, caption, button, icon, defaultResult);
 }
コード例 #26
0
        public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxResult defaultResult, bool showDoNotAsk, out bool doNotAskAgain)
        {
            doNotAskAgain = false;

            if (_provider != null)
                return _provider.Show(messageBoxText, caption, button, defaultResult, showDoNotAsk, out doNotAskAgain);
            else
                return Show(messageBoxText, caption, button, defaultResult);
        }
コード例 #27
0
ファイル: UserDialogService.cs プロジェクト: divyang4481/REM
        private static UserDialogServiceResult GetMessageBoxResult( MessageBoxResult result )
        {
            var dialogResult = UserDialogServiceResult.Ok;
            if ( result != MessageBoxResult.OK )
            {
                dialogResult = UserDialogServiceResult.Cancel;
            }

            return dialogResult;
        }
コード例 #28
0
 public MessageBoxResult InvokeShow(Window owner, string messageBoxText, string caption, MessageBoxButton button, MessageBoxResult defaultResult)
 {
     MessageBoxResult retval = MessageBoxResult.None;
       Application.Current.Dispatcher.Invoke((Action) (() =>
       {
     Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object) Visibility.Visible), (object) ViewModelMessages.OverlayVisible);
     retval = MessageBoxView.Show(owner, messageBoxText, caption, button, defaultResult);
     Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object) Visibility.Collapsed), (object) ViewModelMessages.OverlayVisible);
       }));
       return retval;
 }
コード例 #29
0
        public static MessageBoxResult ShowDialogOkCancel ( this ModernDialog modernDialog )
        {
            _result = MessageBoxResult.Cancel;

            modernDialog.OkButton.Click += OkButton_Click;
            modernDialog.Buttons = new[] { modernDialog.OkButton, modernDialog.CloseButton };

            modernDialog.ShowDialog ();

            return _result;
        }
コード例 #30
0
 public Dev2MessageBoxViewModel(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon,
                                MessageBoxResult defaultResult, string dontShowAgainKey)
 {
     _messageBoxText = messageBoxText;
     _caption = caption;
     _button = button;
     _icon = icon;
     _result = defaultResult;
     _defaultResult = defaultResult;
     _messageBoxText = messageBoxText;
     _dontShowAgainKey = dontShowAgainKey;
 }
コード例 #31
0
 private void Button_No_Click(object sender, RoutedEventArgs e)
 {
     Result = MessageBoxResult.No;
     Close();
 }
コード例 #32
0
        private void BtnSubmit_Click(object sender, RoutedEventArgs e)
        {
            int        result = 0;
            WorkPeriod period = (WorkPeriod)this.DataContext;

            if (period.UserId == 0)
            {
                MessageBox.Show("Select a user", "Notice");
                return;
            }

            if (period.Start == null)
            {
                MessageBox.Show("Select a start date", "Notice");
                return;
            }

            period.Start = period.Start.AddHours(period.StartHour).AddMinutes(period.StartMinute);

            if (Convert.ToBoolean(ChkClockedIn.IsChecked))
            {
                period.End = null;
            }
            else
            {
                if (period.End == null)
                {
                    MessageBox.Show("Select an end date", "Notice");
                    return;
                }

                if (period.Start.Date > Convert.ToDateTime(period.End).Date)
                {
                    // start date is later than the end date
                    MessageBox.Show("Start date is set after the end date. Please make sure the start date begins before end date", "Notice");
                    return;
                }

                if (period.Start.Date.Day != Convert.ToDateTime(period.End).Date.Day)
                {
                    MessageBox.Show("Unable to create a work period that exceeds one day. Please change the start and end date", "Notice");
                    return;
                }

                if (period.EndMeridiem == 1)
                {
                    period.EndHour += 12;
                }

                try
                {
                    period.End = Convert.ToDateTime(period.End).AddHours(period.EndHour).AddMinutes(period.EndMinute);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error");
                    return;
                }
            }

            if (period.StartMeridiem == 1)
            {
                period.StartHour += 12;
            }


            // check if selected user is clocked in
            // if clocked in, clock him out of that current period, using the current time
            // then, clock him in to the current period by creating a new period
            // show dialouge saying that youre clocking him out and clocking him in to a new time period

            int  selectedUserId = (int)CbUserId.SelectedValue;
            User currentUser    = new UserCRUD().Read(selectedUserId);

            if (currentUser.Working && currentUser.WorkPeriodId > 0)
            {
                // this current user is working
                // do you want to clock them out and create new work period?
                MessageBoxResult messageBoxResult = MessageBox.Show("This user is currently clocked in. Creating this work period will clock them out of their current work period and create a new work period. Are you sure?", "Notice", MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (messageBoxResult == MessageBoxResult.No)
                {
                    return;
                }
                else
                {
                    // current work period end is now
                    WorkPeriod workPeriod = new WorkPeriodCRUD().Read(currentUser.WorkPeriodId);
                    workPeriod.End = DateTime.Now;
                    new WorkPeriodCRUD().Update(workPeriod);

                    // clock the user out
                    currentUser.WorkPeriodId = 0;
                    currentUser.Working      = false;
                    int removeUserCurrentWorkPeriodId = new UserCRUD().Update(currentUser);
                }
            }

            result = new WorkPeriodCRUD().Create(period);

            if (period.End == null)
            {
                // update user to be clocked in to current period

                if (selectedUserId > 0 && result > 0)
                {
                    currentUser.WorkPeriodId = result;
                    currentUser.Working      = true;

                    new UserCRUD().Update(currentUser);
                }
            }

            if (result > 0)
            {
                MessageBox.Show("Work period for user was created", "Success");
                this.Close();
            }
            else
            {
                MessageBox.Show("Unable to create work period for user", "Success");
            }
        }
コード例 #33
0
        public void ReceiveMessage(MyDataGram mdg)
        {
            var msg = new ChattingMessage();

            msg.SrcID  = mdg.SrcID;
            msg.DstID  = mdg.DstID;
            msg.CMType = (MessageType)(uint)mdg.Type;

            //文件处理
            if (msg.CMType == MessageType.File || msg.CMType == MessageType.Image)
            {
                //if (mdg.GroupID[0]==' ')
                if (mdg.GroupID != "")
                {
                    if (MatchP2PFile(mdg))
                    {
                        //same file
                    }
                    else
                    {
                        P2PFileBuffer     = null;
                        P2PFileIDList     = null;
                        P2PFileIndexPool  = null;
                        ActualFileLength  = 0;
                        P2pMyOriginalPart = null;
                    }
                    if (mdg.GroupFileIndex == MyP2PIndex)
                    {
                        //ask!
                        if (P2PFileIndexPool == null)
                        {
                            MessageBox.Show("Fatal!");
                            return;
                        }
                        //向请求方给予你的部分
                        MyDataGram Askdg = new MyDataGram();
                        Askdg.DstID          = mdg.SrcID;
                        Askdg.SrcID          = mdg.DstID;
                        Askdg.GroupFileID    = mdg.GroupFileID;
                        Askdg.GroupID        = mdg.GroupID;
                        Askdg.Text           = mdg.Text;
                        Askdg.GroupFileIndex = MyP2PIndex;
                        Askdg.Type           = MessageType.File;
                        Askdg.FileContent    = P2pMyOriginalPart;
                        P2PCore_instance.SendData(MyDataGram.EncodeMessage(Askdg), friendIP, SendDataPort);
                    }
                    else
                    {
                        //receive!
                        var arr = mdg.GroupFileID.Split(' ');

                        if (P2PFileIDList == null)
                        {
                            P2PFileIDList = new List <string>();
                            MyP2PIndex    = mdg.GroupFileIndex;
                        }


                        foreach (var id in arr)
                        {
                            if (id != "" && id != mdg.SrcID)
                            {
                                P2PFileIDList.Add(id);
                            }
                        }
                        int Totalnum = P2PFileIDList.Count;
                        //MessageBox.Show("Get P2P file part: " + mdg.GroupFileIndex + "in Total " + P2PFileIDList.Count().ToString() + "Parts");
                        if (P2PFileIndexPool == null)
                        {
                            P2PFileIndexPool = new int[Totalnum];
                        }

                        int filecutter = mdg.FileContent.Length;
                        if (P2PFileBuffer == null)
                        {
                            //larger than actual.
                            P2PFileBuffer     = new byte[filecutter * (Totalnum + 1)];
                            ActualFileLength  = 0;
                            P2pMyOriginalPart = new byte[filecutter];
                            Buffer.BlockCopy(mdg.FileContent, 0, P2pMyOriginalPart, 0, filecutter);
                        }
                        //put in
                        P2PFileIndexPool[mdg.GroupFileIndex - 1] = 1;
                        Buffer.BlockCopy(mdg.FileContent, 0, P2PFileBuffer, (mdg.GroupFileIndex - 1) * filecutter, filecutter);
                        ActualFileLength += filecutter;
                        int flag = 0;
                        foreach (int i in P2PFileIndexPool)
                        {
                            if (i != 1)
                            {
                                flag = 1;
                            }
                        }
                        byte[] FinalFile = null;
                        if (flag == 0)
                        {
                            //finish
                            FinalFile = new byte[ActualFileLength];
                            Buffer.BlockCopy(P2PFileBuffer, 0, FinalFile, 0, ActualFileLength);
                        }
                        if (FinalFile != null)
                        {
                            var question         = "收到P2P的完整文件: " + mdg.GroupID + ",确定接受嘛?";
                            MessageBoxResult rst = MessageBox.Show(question, "Get File!", MessageBoxButton.YesNo);
                            if (rst == MessageBoxResult.Yes)
                            {
                                //MessageBox.Show(msg.Content);
                                var folder_dir = "./" + msg.SrcID + "/";
                                if (!Directory.Exists(folder_dir))
                                {
                                    Directory.CreateDirectory(folder_dir);
                                }
                                var        FileFullName = folder_dir + mdg.Text;
                                FileStream fs           = File.OpenWrite(FileFullName);
                                fs.Write(FinalFile, 0, ActualFileLength);
                                fs.Close();
                                MessageBox.Show("接收文件成功,储存在: " + FileFullName);
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            //not enough file: Ask file from others
                            for (int i = 0; i < P2PFileIndexPool.Length; i++)
                            {
                                if (P2PFileIndexPool[i] == 0)
                                {
                                    //没有此部分文件
                                    MyDataGram Askdg = new MyDataGram();
                                    Askdg.DstID          = P2PFileIDList[i];
                                    Askdg.SrcID          = MyID;
                                    Askdg.GroupFileID    = mdg.GroupFileID;
                                    Askdg.GroupID        = mdg.GroupID;
                                    Askdg.Text           = mdg.Text;
                                    Askdg.GroupFileIndex = i + 1;
                                    Askdg.Type           = MessageType.File;
                                    Askdg.FileContent    = P2pMyOriginalPart;
                                    P2PCore_instance.SendData(MyDataGram.EncodeMessage(Askdg), friendIP, SendDataPort);
                                }
                            }
                        }
                    }
                }
                else
                {
                    var question         = "你收到来自: " + msg.SrcID + "的文件,确定接受嘛?";
                    MessageBoxResult rst = MessageBox.Show(question, "Get File!", MessageBoxButton.YesNo);
                    if (rst == MessageBoxResult.Yes)
                    {
                        //MessageBox.Show(msg.Content);
                        var folder_dir = "./" + msg.SrcID + "/";
                        if (!Directory.Exists(folder_dir))
                        {
                            Directory.CreateDirectory(folder_dir);
                        }
                        var        FileFullName = folder_dir + mdg.Text;
                        FileStream fs           = File.OpenWrite(FileFullName);
                        fs.Write(mdg.FileContent, 0, mdg.FileContent.Length);
                        fs.Close();
                        MessageBox.Show("接收文件成功,储存在: " + FileFullName);
                        if (mdg.Type == MessageType.Image)
                        {
                            mdg.Text = FileFullName;
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }
            //询问
            if (mdg.GroupID != null)
            {
                msg.Content = msg.SrcID + ": " + mdg.Text;
            }
            else
            {
                msg.Content = friendAlias + ": " + mdg.Text;
            }
            if (mdg.Type == MessageType.Image)
            {
                msg.Content = mdg.Text;
                string fullpath = Path.GetFullPath(msg.Content);
                msg.BitMapSource = new BitmapImage(new Uri(fullpath, UriKind.Absolute));
            }
            msg.SendTime = DateTime.Now.ToString();
            ChattingMessageList.Add(msg);
            ChattingWindowListBox.ScrollIntoView(msg);
        }
コード例 #34
0
 private void Window_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Up)
     {
         if (textBox2.IsFocused || textBox3.IsFocused || textBox4.IsFocused || textBox5.IsFocused || textBox6.IsFocused || textBox7.IsFocused)
         {
             textBox1.Focus();
         }
         else if (textBox8.IsFocused)
         {
             textBox2.Focus();
         }
         else if (textBox9.IsFocused)
         {
             textBox3.Focus();
         }
         else if (textBox10.IsFocused)
         {
             textBox4.Focus();
         }
         else if (textBox11.IsFocused)
         {
             textBox5.Focus();
         }
         else if (textBox12.IsFocused)
         {
             textBox6.Focus();
         }
         else if (textBox13.IsFocused)
         {
             textBox7.Focus();
         }
         else if (textBox14.IsFocused && !gridView.Focused)
         {
             textBox8.Focus();
         }
         else if (textBox15.IsFocused && !gridView.Focused)
         {
             textBox11.Focus();
         }
         else if (textBox18.IsFocused)
         {
             gridView.Focus();
         }
         else if (textBox16.IsFocused || textBox17.IsFocused)
         {
             textBox18.Focus();
         }
         else if (richTextBox1.IsFocused)
         {
             textBox16.Focus();
         }
         else if (txt_Moarefino.IsFocused)
         {
             checkBox14.Focus();
         }
         else if (back_button.IsFocused || insert_button.IsFocused)
         {
             richTextBox1.Focus();
         }
     }
     else if (e.Key == Key.Down)
     {
         if (textBox1.IsFocused)
         {
             textBox2.Focus();
         }
         else if (textBox2.IsFocused)
         {
             textBox8.Focus();
         }
         else if (textBox3.IsFocused)
         {
             textBox9.Focus();
         }
         else if (textBox4.IsFocused)
         {
             textBox10.Focus();
         }
         else if (textBox5.IsFocused)
         {
             textBox11.Focus();
         }
         else if (textBox6.IsFocused)
         {
             textBox12.Focus();
         }
         else if (textBox7.IsFocused)
         {
             textBox13.Focus();
         }
         else if (textBox8.IsFocused || textBox9.IsFocused)
         {
             textBox14.Focus();
         }
         else if (textBox10.IsFocused || textBox11.IsFocused || textBox12.IsFocused)
         {
             textBox15.Focus();
         }
         else if (textBox13.IsFocused)
         {
             checkBox1.Focus();
         }
         else if (textBox14.IsFocused || textBox15.IsFocused)
         {
             gridView.Focus();
         }
         else if (textBox18.IsFocused)
         {
             textBox16.Focus();
         }
         else if (textBox16.IsFocused || textBox17.IsFocused)
         {
             richTextBox1.Focus();
         }
         else if (txt_Moarefino.IsFocused || richTextBox1.IsFocused)
         {
             insert_button.Focus();
         }
     }
     else if (e.Key == Key.Left)
     {
         if (textBox2.IsFocused)
         {
             textBox3.Focus();
         }
         else if (textBox3.IsFocused)
         {
             textBox4.Focus();
         }
         else if (textBox4.IsFocused)
         {
             textBox5.Focus();
         }
         else if (textBox5.IsFocused)
         {
             textBox6.Focus();
         }
         else if (textBox6.IsFocused)
         {
             textBox7.Focus();
         }
         else if (textBox8.IsFocused)
         {
             textBox9.Focus();
         }
         else if (textBox9.IsFocused)
         {
             textBox10.Focus();
         }
         else if (textBox10.IsFocused)
         {
             textBox11.Focus();
         }
         else if (textBox11.IsFocused)
         {
             textBox12.Focus();
         }
         else if (textBox12.IsFocused)
         {
             textBox13.Focus();
         }
         else if (textBox14.IsFocused && !gridView.Focused)
         {
             textBox15.Focus();
         }
         else if (textBox16.IsFocused)
         {
             textBox17.Focus();
         }
         else if (richTextBox1.IsFocused)
         {
             txt_Moarefino.Focus();
         }
         else if (textBox17.IsFocused || textBox18.IsFocused)
         {
             checkBox1.Focus();
         }
     }
     else if (e.Key == Key.Right)
     {
         if (textBox3.IsFocused)
         {
             textBox2.Focus();
         }
         else if (textBox4.IsFocused)
         {
             textBox3.Focus();
         }
         else if (textBox5.IsFocused)
         {
             textBox4.Focus();
         }
         else if (textBox6.IsFocused)
         {
             textBox5.Focus();
         }
         else if (textBox7.IsFocused)
         {
             textBox6.Focus();
         }
         else if (textBox9.IsFocused)
         {
             textBox8.Focus();
         }
         else if (textBox10.IsFocused)
         {
             textBox9.Focus();
         }
         else if (textBox11.IsFocused)
         {
             textBox10.Focus();
         }
         else if (textBox12.IsFocused)
         {
             textBox11.Focus();
         }
         else if (textBox13.IsFocused)
         {
             textBox12.Focus();
         }
         else if (textBox15.IsFocused && !gridView.Focused)
         {
             textBox14.Focus();
         }
         else if (textBox17.IsFocused)
         {
             textBox16.Focus();
         }
         else if (txt_Moarefino.IsFocused)
         {
             richTextBox1.Focus();
         }
     }
     else if (e.Key == Key.RightCtrl)
     {
         textBox18.Focus();
     }
     else if (e.Key == Key.Escape)
     {
         TextRange _text = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd);
         if (_text.Text.Trim() == "" && textBox1.Text.Trim() == "" && textBox2.Text.Trim() == "" && textBox3.Text.Trim() == "" && textBox4.Text.Trim() == "" && textBox5.Text.Trim() == "" && textBox6.Text.Trim() == "" && textBox7.Text.Trim() == "" && textBox8.Text.Trim() == "" && textBox9.Text.Trim() == "" && textBox10.Text.Trim() == "" && textBox11.Text.Trim() == "" && textBox12.Text.Trim() == "" && textBox13.Text.Trim() == "" && textBox14.Text.Trim() == "" && textBox15.Text.Trim() == "" && textBox16.Text.Trim() == "" && textBox17.Text.Trim() == "" && textBox18.Text.Trim() == "" && txt_Moarefino.Text.Trim() == "")
         {
             Close();
             return;
         }
         MessageBoxResult res = MessageBox.Show("آیا می خواهید صفحه ی ثبت را ببندید ؟", "ثبت", MessageBoxButton.YesNo, MessageBoxImage.Question);
         if (res == MessageBoxResult.Yes)
         {
             Close();
         }
     }
 }
コード例 #35
0
 public void Yes()
 {
     _result = MessageBoxResult.Yes;
     TryClose(true);
 }
コード例 #36
0
 public static MessageBoxResult Show(Window owner, string messageText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult)
 {
     return(Show(owner, messageText, caption, button, icon, defaultResult, (Style)null));
 }
コード例 #37
0
        public static void InstallUpdateSyncWithInfo()
        {
            UpdateCheckInfo info = null;

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;

                try
                {
                    info = ad.CheckForDetailedUpdate();

                }
                catch (DeploymentDownloadException dde)
                {
                    MessageBox.Show("The new version of the application cannot be downloaded at this time. \n\nPlease check your network connection, or try again later. Error: " + dde.Message);
                    return;
                }
                catch (InvalidDeploymentException ide)
                {
                    MessageBox.Show("Cannot check for a new version of the application. The ClickOnce deployment is corrupt. Please redeploy the application and try again. Error: " + ide.Message);
                    return;
                }
                catch (InvalidOperationException ioe)
                {
                    MessageBox.Show("This application cannot be updated. It is likely not a ClickOnce application. Error: " + ioe.Message);
                    return;
                }

                if (info.UpdateAvailable)
                {
                    Boolean doUpdate = true;

                    if (!info.IsUpdateRequired)
                    {
                        MessageBoxResult dr = MessageBox.Show("An update is available. Would you like to update the application now?", "Update Available", MessageBoxButton.OKCancel);
                        if (MessageBoxResult.OK != dr)
                        {
                            doUpdate = false;
                        }
                    }
                    else
                    {
                        // Display a message that the app MUST reboot. Display the minimum required version.
                        MessageBox.Show("This application has detected a mandatory update from your current " +
                            "version to version " + info.MinimumRequiredVersion.ToString() +
                            ". The application will now install the update and restart.",
                            "Update Available", MessageBoxButton.OK);
                    }

                    if (doUpdate)
                    {
                        try
                        {
                            ad.Update();
                            MessageBox.Show("The application has been upgraded, and will now restart.");
                            Application.Restart();
                        }
                        catch (DeploymentDownloadException dde)
                        {
                            MessageBox.Show("Cannot install the latest version of the application. \n\nPlease check your network connection, or try again later. Error: " + dde);
                            return;
                        }
                    }
                }
            }
        }
コード例 #38
0
        /// <summary>
        /// Shows the MessageBox.
        /// </summary>
        /// <param name="messageText">The message text.</param>
        /// <param name="caption">The caption.</param>
        /// <param name="button">The button.</param>
        /// <param name="icon">The icon.</param>
        /// <param name="defaultResult">The default result.</param>
        /// <returns></returns>
        private static MessageBoxResult ShowCore(Window owner, IntPtr ownerHandle, string messageText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult, Style messageBoxStyle)
        {
            if (System.Windows.Interop.BrowserInteropHelper.IsBrowserHosted)
            {
                throw new InvalidOperationException("Static methods for MessageBoxes are not available in XBAP. Use the instance ShowMessageBox methods instead.");
            }

            if ((owner != null) && (ownerHandle != IntPtr.Zero))
            {
                throw new NotSupportedException("The owner of a MessageBox can't be both a Window and a WindowHandle.");
            }

            var msgBox = new MessageBox();

            msgBox.InitializeMessageBox(owner, ownerHandle, messageText, caption, button, icon, defaultResult);

            // Setting the style to null will inhibit any implicit styles
            if (messageBoxStyle != null)
            {
                msgBox.Style = messageBoxStyle;
            }

            msgBox.ShowDialog();
            return(msgBox.MessageBoxResult);
        }
コード例 #39
0
ファイル: AddPresetViewModel.cs プロジェクト: zoyag/HandBrake
        /// <summary>
        /// Add a Preset
        /// </summary>
        public void Add()
        {
            if (string.IsNullOrEmpty(this.Preset.Name))
            {
                this.errorService.ShowMessageBox(Resources.AddPresetViewModel_PresetMustProvideName, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (this.presetService.CheckIfPresetExists(this.Preset.Name))
            {
                Preset currentPreset = this.presetService.GetPreset(this.Preset.Name);
                if (currentPreset != null && currentPreset.IsBuildIn)
                {
                    this.errorService.ShowMessageBox(Resources.Main_NoUpdateOfBuiltInPresets, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                MessageBoxResult result = this.errorService.ShowMessageBox(Resources.AddPresetViewModel_PresetWithSameNameOverwriteWarning, Resources.Question, MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (result == MessageBoxResult.No)
                {
                    return;
                }
            }

            if (this.SelectedPictureSettingMode == PresetPictureSettingsMode.SourceMaximum && this.selectedTitle == null)
            {
                this.errorService.ShowMessageBox(Resources.AddPresetViewModel_YouMustFirstScanSource, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (this.CustomWidth == null && this.CustomHeight == null && this.SelectedPictureSettingMode == PresetPictureSettingsMode.Custom)
            {
                this.errorService.ShowMessageBox(Resources.AddPresetViewModel_CustomWidthHeightFieldsRequired, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            this.Preset.PictureSettingsMode = this.SelectedPictureSettingMode;

            // Setting W, H, MW and MH
            if (this.SelectedPictureSettingMode == PresetPictureSettingsMode.None)
            {
                this.Preset.Task.MaxHeight = null;
                this.Preset.Task.MaxWidth  = null;
            }

            if (this.SelectedPictureSettingMode == PresetPictureSettingsMode.Custom)
            {
                this.Preset.Task.MaxWidth  = this.CustomWidth;
                this.Preset.Task.MaxHeight = this.CustomHeight;
                this.Preset.Task.Width     = null;
                this.Preset.Task.Height    = null;
            }

            if (this.SelectedPictureSettingMode == PresetPictureSettingsMode.SourceMaximum)
            {
                this.Preset.Task.MaxHeight = null;
                this.Preset.Task.MaxWidth  = null;
            }

            // Add the Preset
            bool added = this.presetService.Add(this.Preset);

            if (!added)
            {
                this.errorService.ShowMessageBox(
                    Resources.AddPresetViewModel_UnableToAddPreset,
                    Resources.UnknownError,
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
            }
            else
            {
                this.Close();
            }
        }
コード例 #40
0
 public static MessageBoxResult Show(IntPtr ownerWindowHandle, string messageText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult, Style messageBoxStyle)
 {
     return(ShowCore(null, ownerWindowHandle, messageText, caption, button, icon, defaultResult, messageBoxStyle));
 }
コード例 #41
0
 public void No()
 {
     _result = MessageBoxResult.No;
     TryClose(false);
 }
コード例 #42
0
ファイル: Configure.xaml.cs プロジェクト: preej/Stellar
        /// <summary>
        ///    Import Config
        /// </summary>
        public static void ImportConfig(MainWindow mainwindow, /* MainViewModel vm,*/ string configFile)
        {
            try
            {
                List <string> listFailedImports = new List <string>();

                // Start INI File Read
                INIFile inif = null;
                if (File.Exists(configFile) == true)
                {
                    inif = new INIFile(configFile);
                }

                // -------------------------
                // Main Window
                // -------------------------
                // Window Position Top
                double?top = Double.Parse(inif.Read("Main Window", "Position_Top"));
                if (top != null)
                {
                    mainwindow.Top = Convert.ToDouble(inif.Read("Main Window", "Position_Top"));
                }

                // Window Position Left
                double?left = Double.Parse(inif.Read("Main Window", "Position_Left"));
                if (left != null)
                {
                    mainwindow.Left = Convert.ToDouble(inif.Read("Main Window", "Position_Left"));
                }

                // RetroArch Path
                VM.MainView.RetroArchPath_Text = inif.Read("Main Window", "RetroArchPath_Text");

                // Server
                string server = inif.Read("Main Window", "Server_SelectedItem");
                if (VM.MainView.Server_Items.Contains(server))
                {
                    VM.MainView.Server_SelectedItem = server;
                }
                else
                {
                    listFailedImports.Add("Main Window: Server");
                }

                // Download
                string download = inif.Read("Main Window", "Download_SelectedItem");
                if (VM.MainView.Download_Items.Contains(download))
                {
                    VM.MainView.Download_SelectedItem = download;
                }
                else
                {
                    listFailedImports.Add("Main Window: Download");
                }

                // Architecture
                string architecture = inif.Read("Main Window", "Architecture_SelectedItem");
                if (VM.MainView.Architecture_Items.Contains(architecture))
                {
                    VM.MainView.Architecture_SelectedItem = architecture;
                }
                else
                {
                    listFailedImports.Add("Main Window: Architecture");
                }

                // -------------------------
                // Configure Window
                // -------------------------
                // 7-Zip Path
                VM.MainView.SevenZipPath_Text = inif.Read("Configure Window", "SevenZipPath_Text");

                // WinRAR Path
                VM.MainView.WinRARPath_Text = inif.Read("Configure Window", "WinRARPath_Text");

                // Logh Path
                VM.MainView.LogPath_IsChecked = Convert.ToBoolean(inif.Read("Configure Window", "LogPath_IsChecked").ToLower());

                // Log Path CheckBox
                VM.MainView.LogPath_Text = inif.Read("Configure Window", "LogPath_Text");

                // Theme
                string theme = inif.Read("Configure Window", "Theme_SelectedItem");
                if (VM.MainView.Theme_Items.Contains(theme))
                {
                    VM.MainView.Theme_SelectedItem = theme;
                }
                else
                {
                    listFailedImports.Add("Configure Window: Theme");
                }

                // Update Auto Check
                VM.MainView.UpdateAutoCheck_IsChecked = Convert.ToBoolean(inif.Read("Configure Window", "UpdateAutoCheck_IsChecked").ToLower());


                // --------------------------------------------------
                // Failed Imports
                // --------------------------------------------------
                if (listFailedImports.Count > 0 && listFailedImports != null)
                {
                    failedImportMessage = string.Join(Environment.NewLine, listFailedImports);

                    // Detect which screen we're on
                    var allScreens = System.Windows.Forms.Screen.AllScreens.ToList();
                    var thisScreen = allScreens.SingleOrDefault(s => mainwindow.Left >= s.WorkingArea.Left && mainwindow.Left < s.WorkingArea.Right);

                    // Start Window
                    FailedImportWindow failedimportwindow = new FailedImportWindow();

                    // Position Relative to MainWindow
                    failedimportwindow.Left = Math.Max((mainwindow.Left + (mainwindow.Width - failedimportwindow.Width) / 2), thisScreen.WorkingArea.Left);
                    failedimportwindow.Top  = Math.Max((mainwindow.Top + (mainwindow.Height - failedimportwindow.Height) / 2), thisScreen.WorkingArea.Top);

                    // Open Window
                    failedimportwindow.Show();
                }
            }

            // Error Loading config.ini
            //
            catch
            {
                // Delete config.ini and Restart
                // Check if config.ini Exists
                if (File.Exists(Paths.configFile))
                {
                    // Yes/No Dialog Confirmation
                    //
                    MessageBoxResult result = MessageBox.Show(
                        "Could not load config.ini. \n\nDelete config and reload defaults?",
                        "Error",
                        MessageBoxButton.YesNo,
                        MessageBoxImage.Error);
                    switch (result)
                    {
                    // Create
                    case MessageBoxResult.Yes:
                        File.Delete(Paths.configFile);

                        // Reload Control Defaults
                        LoadDefaults(mainwindow);

                        // Restart Program
                        Process.Start(Application.ResourceAssembly.Location);
                        Application.Current.Shutdown();
                        break;

                    // Use Default
                    case MessageBoxResult.No:
                        // Force Shutdown
                        System.Windows.Forms.Application.ExitThread();
                        Environment.Exit(0);
                        return;
                    }
                }
                // If config.ini Not Found
                else
                {
                    MessageBox.Show("No Previous Config File Found.",
                                    "Notice",
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Information);

                    return;
                }
            }
        }
コード例 #43
0
ファイル: Configure.xaml.cs プロジェクト: preej/Stellar
        /// <summary>
        ///    Export Config
        /// </summary>
        public static void ExportConfig(MainWindow mainwindow, /*MainViewModel vm,*/ string configFile)
        {
            // Check if Profiles Directory exists
            //bool exists = Directory.Exists(Paths.configDir);

            // Check if Directory Exists
            if (!Directory.Exists(Paths.configDir))
            {
                // Yes/No Dialog Confirmation
                //
                MessageBoxResult resultExport = MessageBox.Show("Config Folder does not exist. Automatically create it?",
                                                                "Directory Not Found",
                                                                MessageBoxButton.YesNo,
                                                                MessageBoxImage.Information);
                switch (resultExport)
                {
                // Create
                case MessageBoxResult.Yes:
                    try
                    {
                        Directory.CreateDirectory(Paths.configDir);
                    }
                    catch
                    {
                        MessageBox.Show("Could not create Config folder. May require Administrator privileges.",
                                        "Error",
                                        MessageBoxButton.OK,
                                        MessageBoxImage.Error);
                    }
                    break;

                // Use Default
                case MessageBoxResult.No:
                    break;
                }
            }

            // If Dir Exists, Save config file
            else if (Directory.Exists(Paths.configDir))
            {
                // Start INI File Write
                INIFile inif = new INIFile(configFile);

                // -------------------------
                // Main Window
                // -------------------------
                // Window Position Top
                inif.Write("Main Window", "Position_Top", Convert.ToString(mainwindow.Top));

                // Window Position Left
                inif.Write("Main Window", "Position_Left", Convert.ToString(mainwindow.Left));

                // RetroArch Path
                inif.Write("Main Window", "RetroArchPath_Text", VM.MainView.RetroArchPath_Text);

                // Server
                inif.Write("Main Window", "Server_SelectedItem", VM.MainView.Server_SelectedItem);

                // Download
                inif.Write("Main Window", "Download_SelectedItem", VM.MainView.Download_SelectedItem);

                // Architecture
                inif.Write("Main Window", "Architecture_SelectedItem", VM.MainView.Architecture_SelectedItem);


                // -------------------------
                // Configure Window
                // -------------------------
                // 7-Zip Path
                inif.Write("Configure Window", "SevenZipPath_Text", VM.MainView.SevenZipPath_Text);

                // WinRAR Path
                inif.Write("Configure Window", "WinRARPath_Text", VM.MainView.WinRARPath_Text);

                // Log Path CheckBox
                inif.Write("Configure Window", "LogPath_IsChecked", Convert.ToString(VM.MainView.LogPath_IsChecked).ToLower());

                // Log Path
                inif.Write("Configure Window", "LogPath_Text", VM.MainView.LogPath_Text);

                // Theme
                inif.Write("Configure Window", "Theme_SelectedItem", VM.MainView.Theme_SelectedItem);

                // Update Auto Check
                inif.Write("Configure Window", "UpdateAutoCheck_IsChecked", Convert.ToString(VM.MainView.UpdateAutoCheck_IsChecked).ToLower());
            }
        }
コード例 #44
0
ファイル: MessageBoxEx.cs プロジェクト: x-strong/DaxStudio
 public static MessageBoxResult Show(Window owner, string text, string caption, MessageBoxButton buttons, MessageBoxImage icon, MessageBoxResult defResult, MessageBoxOptions options)
 {
     _owner = new WindowInteropHelper(owner).Handle;
     Initialize();
     return(MessageBox.Show(owner, text, caption, buttons, icon,
                            defResult, options));
 }
コード例 #45
0
        private void ExecuteBackup()
        {
            using (var unitofWork = new UnitOfWork(new MahalluDBContext())) {
                MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure to Backup", "Backup", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                if (messageBoxResult == MessageBoxResult.Yes)
                {
                    List <String> backupData    = new List <string>();
                    DirectoryInfo directoryInfo = Directory.CreateDirectory(BackupAndRestoreLocation + @"\MMBackup");
                    backupData.Add("House Number,Name,Area");
                    foreach (var item in unitofWork.Residences.GetAll())
                    {
                        backupData.Add(item.Number + "," + item.Name + "," + item.Area);
                    }
                    File.WriteAllLines(directoryInfo.FullName + @"\Residences.csv", backupData);
                    backupData.Clear();

                    backupData.Add("House Number,Member Name,DOB,Job,Mobile,Is Abroad,Country,Is Guardian,Gender,Marriage Status,Qualification,Remarks");
                    foreach (var item in unitofWork.ResidenceMembers.GetAll())
                    {
                        //Add house number in backup of members as id
                        Residence residence = unitofWork.Residences.Get(item.Residence_Id);
                        backupData.Add(residence.Number + "," + item.MemberName + "," + item.DOB + "," + item.Job + "," +
                                       item.Mobile + "," + item.Abroad + "," + item.Country + "," + item.IsGuardian + "," +
                                       item.Gender + "," + item.MarriageStatus + "," + item.Qualification + "," + item.Remarks);
                    }
                    File.WriteAllLines(directoryInfo.FullName + @"\ResidenceMembers.csv", backupData);
                    backupData.Clear();

                    backupData.Add("Name,Is Details Required");
                    foreach (var item in unitofWork.ExpenseCategories.GetAll())
                    {
                        backupData.Add(item.Name + "," + item.DetailsRequired);
                    }
                    File.WriteAllLines(directoryInfo.FullName + @"\ExpenseCategories.csv", backupData);
                    backupData.Clear();

                    backupData.Add("Name,Is Details Required");
                    foreach (var item in unitofWork.IncomeCategories.GetAll())
                    {
                        backupData.Add(item.Name + "," + item.DetailsRequired);
                    }
                    File.WriteAllLines(directoryInfo.FullName + @"\IncomeCategories.csv", backupData);
                    backupData.Clear();

                    backupData.Add("Name");
                    foreach (var item in unitofWork.Areas.GetAll())
                    {
                        backupData.Add(item.Name);
                    }
                    File.WriteAllLines(directoryInfo.FullName + @"\Areas.csv", backupData);
                    backupData.Clear();

                    backupData.Add("Source Name,Amount");
                    foreach (var item in unitofWork.CashSources.GetAll())
                    {
                        backupData.Add(item.SourceName + "," + item.Amount);
                    }
                    File.WriteAllLines(directoryInfo.FullName + @"\CashSources.csv", backupData);
                    backupData.Clear();

                    backupData.Add("Category Name,Toatal Amount,Created On,ReceiptNo");
                    foreach (var item in unitofWork.Contributions.GetAll())
                    {
                        backupData.Add(item.CategoryName + "," + item.ToatalAmount + "," + item.CreatedOn + "," + item.ReceiptNo);
                    }
                    File.WriteAllLines(directoryInfo.FullName + @"\Contributions.csv", backupData);
                    backupData.Clear();

                    backupData.Add("House  Number,House Name,Member Name,Amount,Created On,Receipt No,Care Of");
                    foreach (var item in unitofWork.ContributionDetails.GetAll())
                    {
                        backupData.Add(item.HouserNumber + "," + item.HouserName + "," + item.MemberName + "," + item.Amount
                                       + "," + item.CreatedOn + "," + item.ReceiptNo + "," + item.CareOf);
                    }
                    File.WriteAllLines(directoryInfo.FullName + @"\ContributionDetail.csv", backupData);
                    backupData.Clear();


                    backupData.Add("Category Name,Created On,Toatal Amount,BillNo");
                    foreach (var item in unitofWork.Expenses.GetAll())
                    {
                        backupData.Add(item.CategoryName + "," + item.CreatedOn + "," + item.ToatalAmount + "," + item.BillNo);
                    }
                    File.WriteAllLines(directoryInfo.FullName + @"\Expenses.csv", backupData);
                    backupData.Clear();

                    backupData.Add("Name,Amount,Created On,Bill No,Care Of");
                    foreach (var item in unitofWork.ExpenseDetails.GetAll())
                    {
                        backupData.Add(item.Name + "," + item.Amount + "," + item.CreatedOn + "," + item.BillNo + "," + item.CareOf);
                    }
                    File.WriteAllLines(directoryInfo.FullName + @"\ExpenseDetails.csv", backupData);
                    backupData.Clear();

                    backupData.Add("Bride Name,Bride Photo String,Bride DOB,Bride Father Name,Bride House Name," +
                                   "Bride Area,Bride Pincode,Bride Post Office,Bride District,Bride State," +
                                   "Bride Country,Groom Name,Groom Photo String,Groom DOB,Groom Father Name,Groom House Name," +
                                   "Groom Area,GroomPincode,Groom Post Office,Groom District,Groom State" +
                                   "GroomCountry,MarriageDate,MarriagePlace"
                                   );
                    foreach (var item in unitofWork.MarriageCertificates.GetAll())
                    {
                        string bridePhotoString = item.BridePhoto != null?BitConverter.ToString(item.BridePhoto) : "NULL";

                        string groomPhotoString = item.GroomPhoto != null?BitConverter.ToString(item.GroomPhoto) : "NULL";

                        backupData.Add(item.BrideName + "," + bridePhotoString + "," + item.BrideDOB + "," + item.BrideFatherName + "," + item.BrideHouseName +
                                       "," + item.BrideArea + "," + item.BridePincode + "," + item.BridePostOffice + "," + item.BrideDistrict + "," + item.BrideState +
                                       "," + item.BrideCountry + "," + item.GroomName + "," + groomPhotoString + "," + item.GroomDOB + "," + item.GroomFatherName + "," + item.GroomHouseName +
                                       "," + item.GroomArea + "," + item.GroomPincode + "," + item.GroomPostOffice + "," + item.GroomDistrict + "," + item.GroomState +
                                       "," + item.GroomCountry + "," + item.MarriageDate + "," + item.MarriagePlace
                                       );
                    }
                    File.WriteAllLines(directoryInfo.FullName + @"\MarriageCertificates.csv", backupData);
                    backupData.Clear();

                    MessageBox.Show("Backup is completed successfully..!");
                }
            }
        }
コード例 #46
0
 private void btnNo_Click(object sender, RoutedEventArgs e)
 {
     this.Result = MessageBoxResult.Cancel;
     this.Close();
 }
コード例 #47
0
 public static MessageBoxResult Show(Window owner, string messageText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult, Style messageBoxStyle)
 {
     return(ShowCore(owner, IntPtr.Zero, messageText, caption, button, icon, defaultResult, messageBoxStyle));
 }
コード例 #48
0
        public void btnSaveQuota_Click(object sender, RoutedEventArgs e)
        {
            //7. Initalize variables that must be prefaced before further validation
            DatePicker dtStartDate = dtStart;

            //8. Validate that a combobox item was selected
            if (cboMembershipType.SelectedIndex == -1)
            {
                MessageBox.Show("Please select a Membership Plan.");
                return;
            }

            //9. Grab the boolean to see if a date has been selected
            bool isDateNull = isStartDateSelect(dtStartDate);

            //10. Check if a date has been select
            if (isDateNull == false)
            {
                MessageBox.Show("Please select a valid start date.");
                return;
            }

            //11. Once date is selected, declare variables that will calculate the end date
            DateTime dtToday            = DateTime.Today;
            DateTime dtConvertStartDate = ConvertPickerToDate(dtStartDate);
            DateTime dtConvertedEndDate = dtToday;

            //12. Determine if a user picked an date in the past
            if (dtConvertStartDate < dtToday)
            {
                MessageBox.Show("Please select a valid start date.");
                return;
            }

            //13. Determine the end date based on the drop down selected
            if ((cboMembershipType.SelectedIndex == 1 || cboMembershipType.SelectedIndex == 3 || cboMembershipType.SelectedIndex == 5))
            {
                dtConvertedEndDate = dtConvertStartDate.AddYears(1);
            }
            else
            {
                dtConvertedEndDate = dtConvertStartDate.AddMonths(1);
            }

            //14. Set selected item to string for query
            string strMembershipSelection = cboMembershipType.SelectedItem.ToString();

            //15. Query corresponding price from drop down menu
            var priceQuery =
                from p in priceList
                where (p.Membership.Trim() == strMembershipSelection.Trim())
                select p.Price;

            //16. Convert list to string
            string strMembershipPrice = String.Join(",", priceQuery);

            //17. Convert price to double for subtotal calculation
            double dblMembershipPrice = Convert.ToDouble(strMembershipPrice);
            double dblSubCost         = GetAdditionalFeatureCost(lstFeatures, cboMembershipType);
            double dblTotalCost       = dblSubCost + dblMembershipPrice;

            //18. String formula for output text box
            string strOutput = Environment.NewLine + "Membership Price:".PadRight(30) + dblMembershipPrice.ToString("C2") + Environment.NewLine + Environment.NewLine + "Addtional Feature Costs:".PadRight(30) + dblSubCost.ToString("C2") + Environment.NewLine + "________________________________________" + Environment.NewLine + "Total Cost:".PadRight(30) + dblTotalCost.ToString("C2");

            //19. Split datetime for enddate
            string strConvertedEndDate    = dtConvertedEndDate.ToString();
            int    strSpace               = strConvertedEndDate.IndexOf(" ");
            string strSubConvertedEndDate = strConvertedEndDate.Substring(0, strSpace);

            //20. Set additional features to string
            StringBuilder strFeatures = new StringBuilder();

            foreach (ListBoxItem selectedItem in lstFeatures.SelectedItems)
            {
                strFeatures.AppendLine(selectedItem.Content.ToString());
            }

            //21. Set output to corresponding text boxes
            txtFeatures.Text          = strFeatures.ToString();
            txtPrice.Text             = dblMembershipPrice.ToString("C2");
            txtMemberQuotaOutput.Text = strOutput;
            txtEndDate.Text           = strSubConvertedEndDate;
            txtMemberQuotaOutput.Text = strOutput;
            txtTotalPrice.Text        = dblTotalCost.ToString("C2");

            //22. create some info to send to the next window
            CustomerPaymentInfo info = new CustomerPaymentInfo(cboMembershipType.Text.Trim(), dtStart.Text.Trim(), txtEndDate.Text.Trim(), txtFeatures.Text.Trim(), txtPrice.Text.Trim(), txtTotalPrice.Text.Trim());

            MessageBoxResult messageBoxResult = MessageBox.Show("Create new member?"
                                                                + Environment.NewLine + Environment.NewLine + info
                                                                , "Membership Quote"
                                                                , MessageBoxButton.YesNo);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
                //instantiate the next window and use the overridden constructor that allows sending information in as an argument
                MembershipSignUp next = new MembershipSignUp(info);
                next.Show();
                this.Close();
            }
        }
コード例 #49
0
        private void ExecuteRestore()
        {
            MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure to Restore", "Restore", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
                using (var unitofWork = new UnitOfWork(new MahalluDBContext())) {
                    unitofWork.Residences.RemoveRange(unitofWork.Residences.GetAll());
                    unitofWork.ResidenceMembers.RemoveRange(unitofWork.ResidenceMembers.GetAll());
                    unitofWork.Areas.RemoveRange(unitofWork.Areas.GetAll());
                    unitofWork.ExpenseCategories.RemoveRange(unitofWork.ExpenseCategories.GetAll());
                    unitofWork.IncomeCategories.RemoveRange(unitofWork.IncomeCategories.GetAll());
                    unitofWork.CashSources.RemoveRange(unitofWork.CashSources.GetAll());
                    //unitofWork.Expenses.RemoveRange(unitofWork.Expenses.GetAll());
                    //unitofWork.ExpenseDetails.RemoveRange(unitofWork.ExpenseDetails.GetAll());
                    //unitofWork.Contributions.RemoveRange(unitofWork.Contributions.GetAll());
                    //unitofWork.ContributionDetails.RemoveRange(unitofWork.ContributionDetails.GetAll());
                    //unitofWork.MarriageCertificates.RemoveRange(unitofWork.MarriageCertificates.GetAll());
                    unitofWork.Complete();

                    string[] directories   = Directory.GetDirectories(BackupAndRestoreLocation);
                    string   directoryPath = backupAndRestoreLocation + @"\MMBackup";
                    if (Directory.Exists(directoryPath))
                    {
                        string filePath = directoryPath + @"\Residences.csv";
                        if (File.Exists(filePath))
                        {
                            String[] backupData = File.ReadAllLines(filePath);
                            for (int i = 1; i < backupData.Length; i++)
                            {
                                string[]  fields    = backupData[i].Split(new char[] { ',' });
                                Residence residence = new Residence();
                                residence.Number = fields[0];
                                residence.Name   = fields[1];
                                residence.Area   = fields[2];
                                unitofWork.Residences.Add(residence);
                            }
                        }
                        unitofWork.Complete();

                        filePath = directoryPath + @"\ResidenceMembers.csv";
                        if (File.Exists(filePath))
                        {
                            String[] backupData = File.ReadAllLines(filePath);
                            for (int i = 1; i < backupData.Length; i++)
                            {
                                string[]        fields          = backupData[i].Split(new char[] { ',' });
                                Residence       residence       = unitofWork.Residences.GetAll().Where(x => x.Number == fields[0]).FirstOrDefault();
                                ResidenceMember residenceMember = new ResidenceMember();
                                residenceMember.Residence_Id   = residence.Id;
                                residenceMember.MemberName     = fields[1];
                                residenceMember.DOB            = Convert.ToDateTime(fields[2]);
                                residenceMember.Job            = fields[3];
                                residenceMember.Mobile         = fields[4];
                                residenceMember.Abroad         = Convert.ToBoolean(fields[5]);
                                residenceMember.Country        = fields[6];
                                residenceMember.IsGuardian     = Convert.ToBoolean(fields[7]);
                                residenceMember.Gender         = fields[8];
                                residenceMember.MarriageStatus = fields[9];
                                residenceMember.Qualification  = fields[10];
                                residenceMember.Remarks        = fields[11];
                                unitofWork.ResidenceMembers.Add(residenceMember);
                            }
                        }
                        unitofWork.Complete();

                        filePath = directoryPath + @"\Areas.csv";
                        if (File.Exists(filePath))
                        {
                            String[] backupData = File.ReadAllLines(filePath);
                            for (int i = 1; i < backupData.Length; i++)
                            {
                                string[] fields = backupData[i].Split(new char[] { ',' });
                                Area     area   = new Area();
                                area.Name = fields[0];
                                unitofWork.Areas.Add(area);
                            }
                        }
                        unitofWork.Complete();

                        filePath = directoryPath + @"\ContributionDetail.csv";
                        if (File.Exists(filePath))
                        {
                            String[] backupData = File.ReadAllLines(filePath);
                            for (int i = 1; i < backupData.Length; i++)
                            {
                                string[]           fields             = backupData[i].Split(new char[] { ',' });
                                ContributionDetail contributionDetail = new ContributionDetail();

                                unitofWork.ContributionDetails.Add(contributionDetail);
                            }
                        }
                        unitofWork.Complete();

                        filePath = directoryPath + @"\CashSources.csv";
                        if (File.Exists(filePath))
                        {
                            String[] backupData = File.ReadAllLines(filePath);
                            for (int i = 1; i < backupData.Length; i++)
                            {
                                string[]   fields     = backupData[i].Split(new char[] { ',' });
                                CashSource cashSource = new CashSource();
                                cashSource.SourceName = fields[0];
                                cashSource.Amount     = Convert.ToDecimal(fields[1]);
                                unitofWork.CashSources.Add(cashSource);
                            }
                        }
                        unitofWork.Complete();

                        filePath = directoryPath + @"\ExpenseCategories.csv";
                        if (File.Exists(filePath))
                        {
                            String[] backupData = File.ReadAllLines(filePath);
                            for (int i = 1; i < backupData.Length; i++)
                            {
                                string[]        fields          = backupData[i].Split(new char[] { ',' });
                                ExpenseCategory expenseCategory = new ExpenseCategory();
                                expenseCategory.Name            = fields[0];
                                expenseCategory.DetailsRequired = Convert.ToBoolean(fields[1]);
                                unitofWork.ExpenseCategories.Add(expenseCategory);
                            }
                        }
                        unitofWork.Complete();

                        filePath = directoryPath + @"\IncomeCategories.csv";
                        if (File.Exists(filePath))
                        {
                            String[] backupData = File.ReadAllLines(filePath);
                            for (int i = 1; i < backupData.Length; i++)
                            {
                                string[]       fields         = backupData[i].Split(new char[] { ',' });
                                IncomeCategory incomeCategory = new IncomeCategory();
                                incomeCategory.Name            = fields[0];
                                incomeCategory.DetailsRequired = Convert.ToBoolean(fields[1]);
                                unitofWork.IncomeCategories.Add(incomeCategory);
                            }
                        }
                        unitofWork.Complete();

                        MessageBox.Show("Restore is completed successfully..!");
                    }
                    else
                    {
                        MessageBox.Show(backupAndRestoreLocation + " doesn't contain back up directory as MMBackup");
                    }
                }
            }
        }
コード例 #50
0
ファイル: OpenCarInfo.xaml.cs プロジェクト: Lvyuan13/new
        //调取记录
        private void CatchRecord_Click(object sender, RoutedEventArgs e)
        {
            DateTime dt  = DateTime.Now;
            string   dir = "D:\\MyData\\";

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            OpenFileDialog openDialog = new OpenFileDialog()
            {
                Title            = "打开\"汽车空调压缩机\"测试数据",
                Filter           = "\"汽车空调压缩机\"数据文件(*.mdb)|*.mdb",
                InitialDirectory = dir,
                AddExtension     = true,
            };

            if (openDialog.ShowDialog() == true)
            {
                //确实调用之前的,为了确定,一个分支而定,20150906
                GlobelVar.IsGetBeforeInfo_Car = true;
                //获取包括文件名在内的路径
                GlobelVar.DirBefore_Glo = openDialog.FileName;
                //获取路径信息20150917:这个路径是用来给数据库每次扫描操作用的,所以最重要!
                BackPanel.InformationGlo.DBPath = openDialog.FileName;


                //20151222报表
                Report.DBPath_ForReport.DBPath_ForReportChild = BackPanel.InformationGlo.DBPath;

                //把数据库的东西读上来
                BackPanel.DBOperate.GetLastInfoRecordFromDateBase(GlobelVar.DirBefore_Glo, GlobelVar.TestInfoDefGlo.TestInfo);

                #region 20151020添加如果用了Chiller的数据库要提示,并且返回
                if (GlobelVar.TestInfoDefGlo.TestInfo[2] == "Chiller")
                {
                    MessageBoxResult mbr = MessageBox.Show("您选择的是冷水机组的数据库,请更换为压缩机数据库!", "选择数据库错误", MessageBoxButton.OK);
                    if (mbr == MessageBoxResult.OK)
                    {
                        //this.Close();
                        //Car car = new Car();
                        //car.Show();
                        return;
                    }
                }
                #endregion 20151020添加如果用了Chiller的数据库要提示,并且返回


                //GlobelVar.TestInfoDefGlo.TestInfo[0] = DateTime.Now.Year.ToString() + DateTime.Now.ToString("MM/dd");
                //GlobelVar.TestInfoDefGlo.TestInfo[1] = DateTime.Now.ToString("HH:mm:ss");
                //GlobelVar.TestInfoDefGlo.TestInfo[2] = "Car";
                textBox1.Text = GlobelVar.TestInfoDefGlo.TestInfo[3];
                textBox2.Text = GlobelVar.TestInfoDefGlo.TestInfo[4];
                textBox3.Text = GlobelVar.TestInfoDefGlo.TestInfo[5];
                textBox4.Text = GlobelVar.TestInfoDefGlo.TestInfo[6];
                textBox5.Text = GlobelVar.TestInfoDefGlo.TestInfo[7];
                textBox6.Text = GlobelVar.TestInfoDefGlo.TestInfo[8];
                textBox7.Text = GlobelVar.TestInfoDefGlo.TestInfo[9];
                //GlobelVar.TestInfoDefGlo.TestInfo[10] = "--";l



                #region 20151020添加读取制冷剂名称
                //制冷剂名称20151020
                GlobelVar.RefName = GlobelVar.TestInfoDefGlo.TestInfo[12];

                //制冷剂选择后前台的响应,以及动作
                if (GlobelVar.RefName == "R22")
                {
                    RBR22.IsChecked = true;

                    UtilityMod_Header.RefNistProp.RefInUsing = UtilityMod_Header.RefNistProp.R22;
                }
                else
                {
                    RBR134a.IsChecked = true;

                    UtilityMod_Header.RefNistProp.RefInUsing = UtilityMod_Header.RefNistProp.R134a;
                }
                //锁定在下面
                #endregion 20151020添加各个信息


                #region 20151108添加读取压缩机离合器电压读取
                GlobelVar.CarCompressorClutchVoltage = GlobelVar.TestInfoDefGlo.TestInfo[13];
                if (GlobelVar.CarCompressorClutchVoltage == "24V")
                {
                    RB24V.IsChecked = true;
                }
                else
                {
                    RB12V.IsChecked = true;
                }

                #endregion
                #region 调取记录后锁定前三项20150921
                this.textBox1.IsEnabled = false;
                this.textBox2.IsEnabled = false;
                this.textBox3.IsEnabled = false;

                //新添加的两个框架的锁定
                this.RBR22.IsEnabled   = false;
                this.RBR134a.IsEnabled = false;

                //新添加锁定
                this.RB12V.IsEnabled = false;
                this.RB24V.IsEnabled = false;
                #endregion 调取记录后锁定前三项20150921
            }
            else
            {
                return;
            }
        }
コード例 #51
0
ファイル: Utils.cs プロジェクト: x97124/SAM
        public static string CheckSteamPath()
        {
            var settingsFile = new IniFile(SAMSettings.FILE_NAME);

            string steamPath = settingsFile.Read(SAMSettings.STEAM_PATH, SAMSettings.SECTION_STEAM);

            int tryCount = 0;

            // If Steam's filepath was not specified in settings or is invalid, attempt to find it and save it.
            while (steamPath == null || !File.Exists(steamPath + "\\steam.exe"))
            {
                // Check registry keys first.
                string regPath   = GetSteamPathFromRegistry();
                string localPath = System.Windows.Forms.Application.StartupPath;

                if (Directory.Exists(regPath))
                {
                    steamPath = regPath;
                }

                // Check if SAM is isntalled in Steam directory.
                // Useful for users in portable mode.
                else if (File.Exists(localPath + "\\steam.exe"))
                {
                    steamPath = localPath;
                }

                // Prompt user for manual selection.
                else
                {
                    if (tryCount == 0)
                    {
                        MessageBox.Show("Could not find Steam path automatically.\n\nPlease select Steam manually.");
                    }

                    // Create OpenFileDialog
                    OpenFileDialog dlg = new OpenFileDialog
                    {
                        DefaultExt = ".exe",
                        Filter     = "Steam (*.exe)|*.exe"
                    };

                    // Display OpenFileDialog by calling ShowDialog method
                    Nullable <bool> result = dlg.ShowDialog();

                    // Get the selected file path
                    if (result == true)
                    {
                        steamPath = Path.GetDirectoryName(dlg.FileName) + "\\";
                    }
                }

                if (steamPath == null || steamPath == string.Empty)
                {
                    MessageBoxResult messageBoxResult = MessageBox.Show("Steam path required!\n\nTry again?", "Confirm", MessageBoxButton.YesNo);

                    if (messageBoxResult.Equals(MessageBoxResult.No))
                    {
                        Environment.Exit(0);
                    }
                }

                tryCount++;
            }

            // Save path to settings file.
            settingsFile.Write(SAMSettings.STEAM_PATH, steamPath, SAMSettings.SECTION_STEAM);

            return(steamPath);
        }
コード例 #52
0
        public string ReadNWNLogAndInvokeParser(Settings _run_settings)
        {
            string   result;
            DateTime _dateTime         = CurrentDateTime_Get();
            string   filepath          = FilePath_Get(_run_settings);
            string   filename          = FileNameGenerator_Get(_dateTime);
            bool     ActorThresholdMet = true;


            FileStream fs;

            try
            {
                fs = new FileStream(_run_settings.PathToLog, FileMode.Open);
            }
            catch
            {
                MessageBox.Show("NWNLogRotator could not read the Log at PathToLog specified!",
                                "Invalid Log Location",
                                MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return("");
            }

            LogParser instance = new LogParser();

            result = instance.ParseLog(fs, _run_settings.CombatText, _run_settings.EventText, _run_settings.ServerName, _run_settings.ServerNameColor);
            fs.Close();

            // maintain minimum row lines requirement
            ActorThresholdMet = instance.ActorOccurences_Get(result, _run_settings.MinimumRowsCount);
            if (ActorThresholdMet == false)
            {
                MessageBox.Show("This NWN Log did not meet the 'Minimum Rows' requirement. The specified log file was not saved!",
                                "Minimum Rows Information",
                                MessageBoxButton.OK,
                                MessageBoxImage.Information);
                return("");
            }


            try
            {
                File.WriteAllText(filepath + filename, result);
                return(filepath + filename);
            }
            catch
            {
                MessageBoxResult _messageBoxResult = MessageBox.Show("The destination file " + filepath + filename + " is unable to be written to this folder. Would you like NNWNLogRotator to try and create the destination folder?",
                                                                     "Output Directory Invalid",
                                                                     MessageBoxButton.YesNo,
                                                                     MessageBoxImage.Question);
                if (_messageBoxResult == MessageBoxResult.Yes)
                {
                    // create folder
                    if (!Directory.Exists(filepath))
                    {
                        try
                        {
                            Directory.CreateDirectory(filepath);
                        }
                        catch
                        {
                            MessageBox.Show("NWNLogRotator was not able create a folder or verify the folder structure of the Output Directory.",
                                            "Invalid Output Directory",
                                            MessageBoxButton.OK,
                                            MessageBoxImage.Error);
                            return("");
                        }
                        try
                        {
                            File.WriteAllText(filepath + filename, result);
                            return(filepath + filename);
                        }
                        catch
                        {
                            MessageBox.Show("NWNLogRotator was not able to write to the entered Output Directory. Please ensure the file structure exists.",
                                            "Output Directory Error",
                                            MessageBoxButton.OK,
                                            MessageBoxImage.Error);
                        }
                    }
                }
            }
            return("");
        }
コード例 #53
0
 /// <summary>
 /// Initializes the MessageBox.
 /// </summary>
 /// <param name="owner">The Window owner.</param>
 /// <param name="ownerHandle">The Window Handle owner.</param>
 /// <param name="text">The text.</param>
 /// <param name="caption">The caption.</param>
 /// <param name="button">The button.</param>
 /// <param name="image">The image.</param>
 /// <param name="defaultResult">The MessageBox result as default.</param>
 public void InitializeMessageBox(Window owner, IntPtr ownerHandle, string text, string caption, MessageBoxButton button, MessageBoxImage image, MessageBoxResult defaultResult)
 {
     Text           = text;
     Caption        = caption;
     _button        = button;
     _defaultResult = defaultResult;
     _owner         = owner;
     _ownerHandle   = ownerHandle;
     SetImageSource(image);
 }
コード例 #54
0
 public void Cancel()
 {
     _result = MessageBoxResult.Cancel;
     TryClose(false);
 }
コード例 #55
0
        public void Install(string path)
        {
            if (File.Exists(path))
            {
                string tempFoler = System.IO.Path.GetTempPath() + "\\wox\\plugins";
                if (Directory.Exists(tempFoler))
                {
                    Directory.Delete(tempFoler, true);
                }
                UnZip(path, tempFoler, true);

                string iniPath = tempFoler + "\\plugin.json";
                if (!File.Exists(iniPath))
                {
                    MessageBox.Show("Install failed: config is missing");
                    return;
                }

                PluginMetadata plugin = GetMetadataFromJson(tempFoler);
                if (plugin == null || plugin.Name == null)
                {
                    MessageBox.Show("Install failed: config of this plugin is invalid");
                    return;
                }

                string pluginFolerPath = AppDomain.CurrentDomain.BaseDirectory + "Plugins";
                if (!Directory.Exists(pluginFolerPath))
                {
                    MessageBox.Show("Install failed: cound't find plugin directory");
                    return;
                }

                string newPluginPath = pluginFolerPath + "\\" + plugin.Name;
                string content       = string.Format(
                    "Do you want to install following plugin?\r\nName: {0}\r\nVersion: {1}\r\nAuthor: {2}",
                    plugin.Name, plugin.Version, plugin.Author);
                if (Directory.Exists(newPluginPath))
                {
                    PluginMetadata existingPlugin = GetMetadataFromJson(newPluginPath);
                    if (existingPlugin == null || existingPlugin.Name == null)
                    {
                        //maybe broken plugin, just delete it
                        Directory.Delete(newPluginPath, true);
                    }
                    else
                    {
                        content = string.Format(
                            "Do you want to update following plugin?\r\nName: {0}\r\nOld Version: {1}\r\nNew Version: {2}\r\nAuthor: {3}",
                            plugin.Name, existingPlugin.Version, plugin.Version, plugin.Author);
                    }
                }

                MessageBoxResult result = MessageBox.Show(content, "Install plugin",
                                                          MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (result == MessageBoxResult.Yes)
                {
                    if (Directory.Exists(newPluginPath))
                    {
                        Directory.Delete(newPluginPath, true);
                    }
                    UnZip(path, newPluginPath, true);
                    Directory.Delete(tempFoler, true);


                    string wox = AppDomain.CurrentDomain.BaseDirectory + "Wox.exe";
                    if (File.Exists(wox))
                    {
                        ProcessStartInfo info = new ProcessStartInfo(wox, "reloadplugin")
                        {
                            UseShellExecute = true
                        };
                        Process.Start(info);
                        MessageBox.Show("You have installed plugin " + plugin.Name + " successfully.");
                    }
                    else
                    {
                        MessageBox.Show("You have installed plugin " + plugin.Name + " successfully. Please restart your wox to use new plugin.");
                    }
                }
            }
        }
コード例 #56
0
 private void ShowMessageBoxCore(string messageText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult)
 {
     this.InitializeMessageBox(null, IntPtr.Zero, messageText, caption, button, icon, defaultResult);
     this.ShowMessageBox();
 }
コード例 #57
0
        public static void AttemptImportMod(string path)
        {
            if (Path.GetExtension(path) == ArchiveExtension)
            {
                string modsFullDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ModsDirectory);
                Console.WriteLine(modsFullDirectory);

                // Check if a mod already exists
                string modFolderName     = Path.GetFileNameWithoutExtension(path);
                string destinationFolder = Path.Combine(modsFullDirectory, modFolderName);
                if (Directory.Exists(destinationFolder))
                {
                    MessageBoxResult overwriteResult = MessageBox.Show($"'{modFolderName}' already exists in your mods folder.\n\nDo you wish to overwrite it?", "Overwrite Mod?", MessageBoxButton.YesNo);
                    if (overwriteResult == MessageBoxResult.Yes)
                    {
                        Directory.Delete(destinationFolder, true);
                    }
                    else
                    {
                        if (OnFinishedImportingMod != null)
                        {
                            OnFinishedImportingMod(false, ModImportType.Invalid, $"A mod already exists in folder '{modFolderName}'!");
                        }
                        return;
                    }
                }

                try
                {
                    bool foundModDefinition = false;
                    bool foundSaveFile      = false;

                    ZipArchive zip = ZipFile.OpenRead(path);
                    foreach (var entry in zip.Entries)
                    {
                        string[] parts = entry.Name.Split('.');
                        if (parts.Length > 2 && entry.Name.EndsWith(".txt"))
                        {
                            foundSaveFile = true;
                        }

                        if (entry.Name == TitanfallMod.ModDocumentFile)
                        {
                            foundModDefinition = true;
                        }
                    }

                    if (foundModDefinition)
                    {
                        // Extract mod to the mods folder
                        ZipFile.ExtractToDirectory(path, destinationFolder);

                        if (File.Exists(Path.Combine(destinationFolder, DisabledFileName)))
                        {
                            File.Delete(Path.Combine(destinationFolder, DisabledFileName));
                        }

                        if (OnFinishedImportingMod != null)
                        {
                            OnFinishedImportingMod(true, ModImportType.Mod, $"{modFolderName} imported successfully!");
                        }
                    }
                    else if (foundSaveFile)
                    {
                        // Extract saves to the saves folder
                        destinationFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, SavesDirectory);
                        ZipFile.ExtractToDirectory(path, destinationFolder);

                        if (OnFinishedImportingMod != null)
                        {
                            OnFinishedImportingMod(true, ModImportType.Save, $"{modFolderName} imported to saves successfully!");
                        }
                    }
                    else
                    {
                        throw new Exception("Mod was not a valid mod, nor a save file.");
                    }
                }
                catch (Exception e)
                {
                    if (OnFinishedImportingMod != null)
                    {
                        OnFinishedImportingMod(false, ModImportType.Invalid, $"An exception occurred while importing mod '{modFolderName}', {e.Message}");
                    }
                    return;
                }
            }
        }
コード例 #58
0
 /// <summary>
 /// Displays this message box when embedded in a WindowContainer parent.
 /// Note that this call is not blocking and that you must register to the Closed event in order to handle the dialog result, if any.
 /// </summary>
 public void ShowMessageBox(string messageText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult)
 {
     this.ShowMessageBoxCore(messageText, caption, button, icon, defaultResult);
 }
コード例 #59
0
 public void Ok()
 {
     _result = MessageBoxResult.OK;
     TryClose(true);
 }
コード例 #60
0
ファイル: MessageBoxEx.cs プロジェクト: x-strong/DaxStudio
 public static MessageBoxResult Show(string text, string caption, MessageBoxButton buttons, MessageBoxImage icon, MessageBoxResult defResult, MessageBoxOptions options)
 {
     Initialize();
     return(MessageBox.Show(text, caption, buttons, icon, defResult, options));
 }