Example #1
0
 public ArbilUtils(ArchivingDlgViewModel model)
 {
     _archivingDlgViewModel = model;
 }
Example #2
0
        /// ------------------------------------------------------------------------------------
        /// <param name="model">View model</param>
        /// <param name="localizationManagerId">The ID of the localization manager for the
        /// calling application.</param>
        /// <param name="programDialogFont">Application can set this to ensure a consistent look
        /// in the UI (especially useful for when a localization requires a particular font).</param>
        /// <param name="settings">Location, size, and state where the client would like the
        /// dialog box to appear (can be null)</param>
        /// ------------------------------------------------------------------------------------
        public ArchivingDlg(ArchivingDlgViewModel model, string localizationManagerId,
                            Font programDialogFont, FormSettings settings)
        {
            _settings = settings ?? FormSettings.Create(this);

            _viewModel = model;

            InitializeComponent();

            if (!string.IsNullOrEmpty(localizationManagerId))
            {
                locExtender.LocalizationManagerId = localizationManagerId;
            }

            Text = string.Format(Text, model.AppName, model.ArchiveType);
            _progressBar.Visible = false;

            // remember this because we will need it later in a derived class
            _launchButtonTextFormat = _buttonLaunchRamp.Text;

            UpdateLaunchButtonText();
            _buttonLaunchRamp.Enabled = false;             //!string.IsNullOrEmpty(model.PathToProgramToLaunch);

            _linkOverview.Text = model.InformativeText;
            _linkOverview.Links.Clear();

            if (!string.IsNullOrEmpty(model.ArchiveInfoUrl) && !string.IsNullOrEmpty(model.ArchiveInfoHyperlinkText))
            {
                int i = _linkOverview.Text.IndexOf(model.ArchiveInfoHyperlinkText, StringComparison.InvariantCulture);
                if (i >= 0)
                {
                    _linkOverview.Links.Add(i, model.ArchiveInfoHyperlinkText.Length, model.ArchiveInfoUrl);
                }
            }

            // this is for a display problem in mono
            _linkOverview.SizeToContents();
            _logBox.Tag = false;

            model.OnDisplayMessage += DisplayMessage;
            model.OnDisplayError   += new ArchivingDlgViewModel.DisplayErrorEventHandler(model_DisplayError);

            if (programDialogFont != null)
            {
                _linkOverview.Font        = programDialogFont;
                _logBox.Font              = FontHelper.MakeFont(programDialogFont, FontStyle.Bold);
                _buttonCancel.Font        = programDialogFont;
                _buttonCreatePackage.Font = programDialogFont;
                _buttonLaunchRamp.Font    = programDialogFont;
                Font = programDialogFont;
            }

            _buttonLaunchRamp.Click += (s, e) => model.LaunchArchivingProgram();

            _buttonCancel.MouseLeave += delegate
            {
                if (model.IsBusy)
                {
                    WaitCursor.Show();
                }
            };

            _buttonCancel.MouseEnter += delegate
            {
                if (model.IsBusy)
                {
                    WaitCursor.Hide();
                }
            };

            _buttonCancel.Click += delegate
            {
                model.Cancel();
                WaitCursor.Hide();
            };

            _buttonCreatePackage.Click += delegate
            {
                Focus();
                _buttonCreatePackage.Enabled = false;
                _progressBar.Visible         = true;
                WaitCursor.Show();
                _logBox.Clear();
                _buttonLaunchRamp.Enabled    = model.CreatePackage();
                _buttonCreatePackage.Enabled = false;
                _progressBar.Visible         = false;
                WaitCursor.Hide();
            };
        }
Example #3
0
		/// ------------------------------------------------------------------------------------
		/// <param name="model">View model</param>
		/// <param name="localizationManagerId">The ID of the localization manager for the
		/// calling application.</param>
		/// <param name="programDialogFont">Application can set this to ensure a consistent look
		/// in the UI (especially useful for when a localization requires a particular font).</param>
		/// <param name="settings">Location, size, and state where the client would like the
		/// dialog box to appear (can be null)</param>
		/// ------------------------------------------------------------------------------------
		public ArchivingDlg(ArchivingDlgViewModel model, string localizationManagerId,
			Font programDialogFont, FormSettings settings)
		{
			_settings = settings ?? FormSettings.Create(this);

			_viewModel = model;

			InitializeComponent();

			if (!string.IsNullOrEmpty(localizationManagerId))
				locExtender.LocalizationManagerId = localizationManagerId;

			Text = string.Format(Text, model.AppName, model.ArchiveType);
			_progressBar.Visible = false;

			// remember this because we will need it later in a derived class
			_launchButtonTextFormat = _buttonLaunchRamp.Text;

			UpdateLaunchButtonText();
			_buttonLaunchRamp.Enabled = false; //!string.IsNullOrEmpty(model.PathToProgramToLaunch);

			_linkOverview.Text = model.InformativeText;
			_linkOverview.Links.Clear();

			if (!string.IsNullOrEmpty(model.ArchiveInfoUrl) && !string.IsNullOrEmpty(model.ArchiveInfoHyperlinkText))
			{
				int i = _linkOverview.Text.IndexOf(model.ArchiveInfoHyperlinkText, StringComparison.InvariantCulture);
				if (i >= 0)
					_linkOverview.Links.Add(i, model.ArchiveInfoHyperlinkText.Length, model.ArchiveInfoUrl);
			}

			// this is for a display problem in mono
			_linkOverview.SizeToContents();
			_logBox.Tag = false;

			model.OnDisplayMessage += DisplayMessage;
			model.OnDisplayError += new ArchivingDlgViewModel.DisplayErrorEventHandler(model_DisplayError);

			if (programDialogFont != null)
			{
				_linkOverview.Font = programDialogFont;
				_logBox.Font = FontHelper.MakeFont(programDialogFont, FontStyle.Bold);
				_buttonCancel.Font = programDialogFont;
				_buttonCreatePackage.Font = programDialogFont;
				_buttonLaunchRamp.Font = programDialogFont;
				Font = programDialogFont;
			}

			_buttonLaunchRamp.Click += (s, e) => model.LaunchArchivingProgram();

			_buttonCancel.MouseLeave += delegate
			{
				if (model.IsBusy)
					WaitCursor.Show();
			};

			_buttonCancel.MouseEnter += delegate
			{
				if (model.IsBusy)
					WaitCursor.Hide();
			};

			_buttonCancel.Click += delegate
			{
				model.Cancel();
				WaitCursor.Hide();
			};

			_buttonCreatePackage.Click += delegate
			{
				Focus();
				_buttonCreatePackage.Enabled = false;
				_progressBar.Visible = true;
				WaitCursor.Show();
				_logBox.Clear();
				_buttonLaunchRamp.Enabled = model.CreatePackage();
				_buttonCreatePackage.Enabled = false;
				_progressBar.Visible = false;
				WaitCursor.Hide();
			};
		}
Example #4
0
		public ArbilUtils(ArchivingDlgViewModel model)
		{
			_archivingDlgViewModel = model;
		}
Example #5
0
		/// ------------------------------------------------------------------------------------
		void DisplayMessage(string msg, ArchivingDlgViewModel.MessageType type)
		{
			if ((bool) _logBox.Tag)
			{
				_logBox.Clear();
				_logBox.Tag = false;
			}
			switch (type)
			{
				case ArchivingDlgViewModel.MessageType.Normal:
					_logBox.WriteMessage(msg);
					break;
				case ArchivingDlgViewModel.MessageType.Indented:
					_logBox.WriteMessage(Environment.NewLine + "	" + msg);
					break;
				case ArchivingDlgViewModel.MessageType.Detail:
					_logBox.WriteMessageWithFontStyle(FontStyle.Regular, "\t" + msg);
					break;
				case ArchivingDlgViewModel.MessageType.Bullet:
					_logBox.WriteMessageWithFontStyle(FontStyle.Regular, "		  \u00B7 {0}", msg);
					break;
				case ArchivingDlgViewModel.MessageType.Progress:
					_logBox.WriteMessage(Environment.NewLine + msg);
					break;
				case ArchivingDlgViewModel.MessageType.Warning:
					_logBox.WriteWarning(msg);
					break;
				case ArchivingDlgViewModel.MessageType.Error:
					_logBox.WriteMessageWithColor("Red", msg + Environment.NewLine);
					break;
				case ArchivingDlgViewModel.MessageType.Success:
					_logBox.WriteMessageWithColor(Color.DarkGreen, Environment.NewLine + msg);
					break;
				case ArchivingDlgViewModel.MessageType.Volatile:
					_logBox.WriteMessage(msg);
					_logBox.Tag = true;
					break;
			}
		}