Exemplo n.º 1
0
    public void GoNext()
    {
      if (_items.Any(i => i.HasChanges))
      {
        var prog = new ProgressStep<ExportProcessor>(_wizard.ExportProcessor);
        prog.MethodInvoke = e => {
          _wizard.InstallScript.Lines = (from i in _items
                                         where !i.HasChanges
                                         select i.Item).ToList();
          e.Export(_wizard.InstallScript,
            e.NormalizeRequest(from i in _items
                               where i.HasChanges
                               select i.Item.Reference));
        };
        prog.GoNextAction = () => _wizard.GoToStep(new ExportResolve());
        _wizard.GoToStep(prog);
      }
      else
      {
        if (_changes)
        {
          _wizard.InstallScript.Lines = _items.Select(i => i.Item).ToList();
        }

        _wizard.GoToStep(new ExportOptions());
      }
    }
        private void OnProgressChange(ProgressStep step)
        {
            switch (step)
            {
            case ProgressStep.ConnectingToMinecraft:
                ProgressMessage = "Connecting to the login server...";
                break;

            case ProgressStep.LoggingInToMinecraft:
                ProgressMessage = "Logging into Minecraft...";
                break;

            case ProgressStep.Connecting:
                ProgressMessage = "Connecting to the update server...";
                break;

            case ProgressStep.LoggingIn:
                ProgressMessage = "Logging in...";
                break;

            case ProgressStep.DownloadingModInformation:
                ProgressMessage = "Downloading mod information...";
                break;

            case ProgressStep.ConnectionFailed:
                ProgressMessage = "Connection failed.";
                break;

            case ProgressStep.LoginFailed:
                ProgressMessage = "Login failed.  Reason: {0}";
                break;
            }
        }
Exemplo n.º 3
0
 void c_ProgressChange(ProgressStep step)
 {
     if (InvokeRequired)
     {
         Invoke(new Connection.ProgressChangeEvent(c_ProgressChange), step); // Need to call this on the main thread.
         return;
     }
     if (step == ProgressStep.LoginFailed || step == ProgressStep.ConnectionFailed)
     {
         updaterProgressBar1.EndColor   = Color.FromArgb(225, 0, 0);
         updaterProgressBar1.StartColor = Color.FromArgb(225, 0, 0);
         lblStatus.Text     = string.Format(Connection.ProgressMessage, Connection.FailureMessage);
         btnConnect.Enabled = true;
     }
     else
     {
         updaterProgressBar1.PerformStep();
         lblStatus.Text = Connection.ProgressMessage;
     }
     if (step == ProgressStep.Connected)
     {
         DialogResult = System.Windows.Forms.DialogResult.OK;
         Close();
     }
 }
        /// <inheritdoc />
        public void OnStepChanged(ProgressStep step, string message)
        {
            this.ProgressBar?.Erase();

            if (step == ProgressStep.Done)
            {
                Console.WriteLine();
            }

            Console.WriteLine(message);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Converts a specified value (which must be a <see cref="ProgressStep"/>) into a given
        /// type un the specified context.
        /// </summary>
        /// <param name="context">The formatting context.</param>
        /// <param name="info">The culture under which the conversion should be performed.</param>
        /// <param name="value">Value to convert.</param>
        /// <param name="destType">The type the conversion should result into.</param>
        /// <returns>The converted value.</returns>
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo info, object value, Type destType)
        {
            if (destType == typeof(InstanceDescriptor))
            {
                ProgressStep step       = (ProgressStep)value;
                Type[]       ctorTypes  = new Type[] { typeof(Image), typeof(string), typeof(string), typeof(string) };
                object[]     ctorParams = new object[] { step.Image, step.Name, step.Text, step.Description };
                return(new InstanceDescriptor(typeof(ProgressStep).GetConstructor(ctorTypes), ctorParams, true));
            }

            return(base.ConvertTo(context, info, value, destType));
        }
Exemplo n.º 6
0
        private void ProgressBar(ProgressStep currentStep)
        {
            var yProgressBar = _yOffset + 32f * 4;
            var xProgressBar = _xOffset + Margin;

            var upperLeft   = new Vector2(xProgressBar, yProgressBar);
            var lowerRightY = yProgressBar + ProgressbarHeight;

            var lowerRightOutline = new Vector2(xProgressBar + ProgressbarWidth, lowerRightY);
            var lowerRightFilled  = new Vector2((float)(xProgressBar + ProgressbarWidth * currentStep.ProgressPercentage), lowerRightY);

            ImGui.GetWindowDrawList().AddRect(upperLeft, lowerRightOutline, ImGui.ColorConvertFloat4ToU32(new Vector4(0.2f, 0.4f, 1.0f, 1.0f)));
            ImGui.GetWindowDrawList().AddRectFilled(upperLeft, lowerRightFilled, ImGui.ColorConvertFloat4ToU32(new Vector4(0.6f, 0.2f, 1.0f, 1.0f)));
        }
Exemplo n.º 7
0
 public void GoNext()
 {
   if (_selectedRefs.Any())
   {
     var prog = new ProgressStep<ExportProcessor>(_wizard.ExportProcessor);
     prog.MethodInvoke = e => {
       _wizard.InstallScript = _existingScript ?? new InstallScript();
       _wizard.InstallScript.ExportUri = new Uri(_wizard.ConnectionInfo.First().Url);
       _wizard.InstallScript.ExportDb = _wizard.ConnectionInfo.First().Database;
       _wizard.InstallScript.Lines = Enumerable.Empty<InstallItem>();
       e.Export(_wizard.InstallScript, _selectedRefs, chkDependencies.Checked);
     };
     prog.GoNextAction = () => _wizard.GoToStep(new ExportResolve());
     _wizard.GoToStep(prog);
   }
   else
   {
     Dialog.MessageDialog.Show(resources.Messages.SelectItemsExport);
   }
 }
Exemplo n.º 8
0
        /// <summary>
        /// Return the total time in milliseconds for the
        /// current import step (e.g. textures, meshes).
        /// </summary>
        public long GetMillisecondsForCurrentImportStep()
        {
            ProgressStep progressStep = _progressSteps[_progressSteps.Count - 1];
            ImportStep   importStep   = progressStep.Step;

            long endTime   = progressStep.ElapsedMilliseconds;
            long startTime = 0;

            for (int i = _progressSteps.Count - 1; i >= 0; --i)
            {
                if (_progressSteps[i].Step != importStep)
                {
                    break;
                }

                startTime = _progressSteps[i].ElapsedMilliseconds;
            }

            return(endTime - startTime);
        }
Exemplo n.º 9
0
        private void btnCompare_Click(object sender, EventArgs e)
        {
            try
              {
            var currInstall = _wizard.InstallScript;
            var refs = (from i in _wizard.InstallScript.Lines
                    where i.Reference != null && i.Type == InstallType.Create
                    select i.Reference);

            var connStep = new ConnectionSelection();
            connStep.MultiSelect = false;
            connStep.GoNextAction = () =>
            {
              var prog = new ProgressStep<ExportProcessor>(_wizard.ExportProcessor);
              prog.MethodInvoke = p =>
              {
            _wizard.InstallScript = new InstallScript();
            _wizard.InstallScript.ExportUri = new Uri(_wizard.ConnectionInfo.First().Url);
            _wizard.InstallScript.ExportDb = _wizard.ConnectionInfo.First().Database;
            _wizard.InstallScript.Lines = Enumerable.Empty<InstallItem>();
            p.Export(_wizard.InstallScript, refs);
              };
              prog.GoNextAction = () => {
            var compare = new Compare();
            compare.BaseInstall = currInstall;
            _wizard.GoToStep(compare);
              };

              _wizard.GoToStep(prog);
            };
            _wizard.GoToStep(connStep);
            _wizard.NextLabel = "&Export Compare";
              }
              catch (Exception ex)
              {
            Utils.HandleError(ex);
              }
        }
Exemplo n.º 10
0
 public void GoNext()
 {
   var processor = new ProcessFiles();
   var prog = new ProgressStep<ProcessFiles>(processor);
   prog.MethodInvoke = e =>
   {
     e.Execute(_mergeData.Unfiltered, _mergeOp);
   };
   prog.GoNextAction = () => _wizard.GoToStep(this);
   _wizard.GoToStep(prog);
 }
 void c_ProgressChange(ProgressStep step)
 {
     if (InvokeRequired)
     {
         Invoke(new Connection.ProgressChangeEvent(c_ProgressChange), step); // Need to call this on the main thread.
         return;
     }
     if (step == ProgressStep.LoginFailed || step == ProgressStep.ConnectionFailed)
     {
         updaterProgressBar1.EndColor = Color.FromArgb(225, 0, 0);
         updaterProgressBar1.StartColor = Color.FromArgb(225, 0, 0);
         lblStatus.Text = string.Format(Connection.ProgressMessage, Connection.FailureMessage);
         btnConnect.Enabled = true;
     }
     else
     {
         updaterProgressBar1.PerformStep();
         lblStatus.Text = Connection.ProgressMessage;
     }
     if (step == ProgressStep.Connected)
     {
         DialogResult = System.Windows.Forms.DialogResult.OK;
         Close();
     }
 }
Exemplo n.º 12
0
 private void OnProgressChange(ProgressStep step)
 {
     switch (step)
     {
         case ProgressStep.ConnectingToMinecraft:
             ProgressMessage = "Connecting to the login server...";
             break;
         case ProgressStep.LoggingInToMinecraft:
             ProgressMessage = "Logging into Minecraft...";
             break;
         case ProgressStep.Connecting:
             ProgressMessage = "Connecting to the update server...";
             break;
         case ProgressStep.LoggingIn:
             ProgressMessage = "Logging in...";
             break;
         case ProgressStep.DownloadingModInformation:
             ProgressMessage = "Downloading mod information...";
             break;
         case ProgressStep.ConnectionFailed:
             ProgressMessage = "Connection failed.";
             break;
         case ProgressStep.LoginFailed:
             ProgressMessage = "Login failed.  Reason: {0}";
             break;
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// Generate a progress message for the most
        /// recent progress step.
        /// </summary>
        public string GetProgressMessage()
        {
            ProgressStep progressStep = _progressSteps[_progressSteps.Count - 1];

            int currentStep = Math.Min(
                progressStep.NumCompleted + 1, progressStep.NumTotal);

            string message;

            switch (progressStep.Step)
            {
            case ImportStep.Read:
            case ImportStep.Download:
                float kb      = progressStep.NumCompleted / 1024f;
                float totalKb = progressStep.NumTotal / 1024f;
                // Note: Total file size will be reported as zero
                // when file size could not be determined (e.g.
                // Android cotent URIs).
                if (progressStep.NumTotal > 0)
                {
                    message = string.Format(
                        "{0}ing {1:D}/{2:D} KB...",
                        progressStep.Step,
                        (int)Mathf.Round(kb),
                        (int)Mathf.Round(totalKb));
                }
                else
                {
                    message = string.Format("{0}ing file {1:D} KB...",
                                            progressStep.Step.ToString(),
                                            (int)Mathf.Round(kb));
                }
                break;

            case ImportStep.Parse:
                message = string.Format(
                    "Parsing json {0}/{1}...", currentStep,
                    progressStep.NumTotal);
                break;

            case ImportStep.MorphTarget:
                message = string.Format(
                    "Loading morph targets {0}/{1}...",
                    currentStep, progressStep.NumTotal);
                break;

            default:
                message = string.Format("Loading {0} {1}/{2}...",
                                        progressStep.Step.ToString().ToLower(),
                                        currentStep, progressStep.NumTotal);
                break;
            }

            if (progressStep.NumCompleted == progressStep.NumTotal)
            {
                message += string.Format(" done ({0} ms)",
                                         GetMillisecondsForCurrentImportStep());
            }

            return(message);
        }
Exemplo n.º 14
0
 public ProgressStep(ProgressStep copy)
 {
     mName          = copy.Name;
     mContextFrame  = (IGuiFrame)copy.ContextFrame.Clone();
     mProgressFrame = (IGuiFrame)copy.ProgressFrame.Clone();
 }
Exemplo n.º 15
0
        public void DisplayProgress(string description, CancellationTokenSource cancellationTokenSource, ProgressStep step, params ProgressStep[] moreSteps)
        {
            var progressOperation = new ProgressOperation(description, cancellationTokenSource, new[] { step }.Concat(moreSteps));

            progressOperation.OnFinished += (sender, args) => { _logger.LogInformation("Done with step"); };

            _progressOperationQueue.Enqueue(progressOperation);
            OnWantsToRender?.Invoke(this, EventArgs.Empty);
        }
        /// <summary>
        /// Creates a new instance for the collection.
        /// </summary>
        /// <param name="itemType">Type of the instance to be created.</param>
        /// <returns>A new instance with default values.</returns>
        protected override object CreateInstance(Type itemType)
        {
            ProgressStep result = (ProgressStep)base.CreateInstance(itemType);

            return(result);
        }