public void Preview(PackageClass packageClass, SectionItem sectionItem)
 {
   Mode = ShowModeEnum.Preview;
   Section = sectionItem;
   Package = packageClass;
   SetValues();
   timer1.Enabled = true;
   ShowDialog();
 }
 public SectionResponseEnum Execute(PackageClass packageClass, SectionItem sectionItem)
 {
   Mode = ShowModeEnum.Real;
   Package = packageClass;
   Section = sectionItem;
   base.DisableX_Click();
   SetValues();
   Base.ActionExecute(Package, Section, ActionExecuteLocationEnum.BeforPanelShow);
   ShowDialog();
   Base.ActionExecute(Package, Section, ActionExecuteLocationEnum.AfterPanelHide);
   return base.Resp;
 }
 public SectionItem Add(string name)
 {
   SectionItem item = new SectionItem();
   ISectionPanel panel = MpeInstaller.SectionPanels[name];
   if (panel == null)
     return null;
   item.Name = panel.DisplayName;
   item.PanelName = panel.DisplayName;
   item.Params = panel.GetDefaultParams();
   Add(item);
   return item;
 }
 /// <summary>
 /// Previews the section form, but no change made.
 /// </summary>
 /// <param name="packageClass">The package class.</param>
 /// <param name="sectionItem">The param collection.</param>
 public void Preview(PackageClass packageClass, SectionItem sectionItem)
 {
   MessageBox.Show("This is a non visual Section. Nothing to show");
   bool state = false;
   try
   {
     Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
     AsmHelper script =
       new AsmHelper(CSScript.LoadCode(sectionItem.Params[Const_script].Value,
                                       Path.GetTempFileName(), true));
     state = (bool)script.Invoke("Script.GetState", packageClass, sectionItem);
     MessageBox.Show("Result of script : " + state.ToString());
   }
   catch (Exception ex)
   {
     MessageBox.Show("Eror in script : " + ex.Message);
   }
 }
    public SectionResponseEnum Execute(PackageClass packageClass, SectionItem sectionItem)
    {
      Base.ActionExecute(packageClass, sectionItem, ActionExecuteLocationEnum.BeforPanelShow);
      Base.ActionExecute(packageClass, sectionItem, ActionExecuteLocationEnum.AfterPanelShow);
      Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
      bool state = false;
      try
      {
        AsmHelper script =
          new AsmHelper(CSScript.LoadCode(sectionItem.Params[Const_script].Value,
                                          Path.GetTempFileName(), true));
        state = (bool)script.Invoke("Script.GetState", packageClass, sectionItem);
      }
      catch (Exception ex)
      {
        if (!packageClass.Silent)
          MessageBox.Show("Eror in script : " + ex.Message);
        state = false;
      }

      foreach (string includedGroup in sectionItem.IncludedGroups)
      {
        packageClass.Groups[includedGroup].Checked = state;
      }
      Base.ActionExecute(packageClass, sectionItem, ActionExecuteLocationEnum.AfterPanelHide);
      return SectionResponseEnum.Ok;
    }
 private void mnu_remove_Click(object sender, EventArgs e)
 {
   if (SelectedSection == null)
     return;
   if (MessageBox.Show("Do you want to Delete section " + SelectedSection.Name, "", MessageBoxButtons.YesNo) !=
       DialogResult.Yes)
     return;
   Package.Sections.Items.Remove(SelectedSection);
   if (Package.Sections.Items.Count > 0)
     SelectedSection = Package.Sections.Items[0];
   else
     SelectedSection = null;
   listBox_sections.Items.Clear();
   PopulateList();
 }
    private void listBox_sections_SelectedIndexChanged(object sender, EventArgs e)
    {
      if (listBox_sections.SelectedItems.Count > 0)
      {
        SelectedSection = null;
        var param = listBox_sections.SelectedItem as SectionItem;
        txt_guid.Text = param.Guid;
        txt_name.Text = param.Name;
        cmb_sectiontype.Text = param.PanelName;
        cmb_grupvisibility.Text = param.ConditionGroup;
        list_groups.Items.Clear();
        list_actions.Items.Clear();
        cmb_buttons.SelectedIndex = (int)param.WizardButtonsEnum;
        foreach (var s in Package.Groups.Items)
        {
          if (param.IncludedGroups.Contains(s.Name))
            list_groups.Items.Add(s.Name);
        }

        foreach (var acton in param.Actions.Items)
        {
          list_actions.Items.Add(acton);
        }

        SelectedSection = param;
      }
    }
 private void TestToolStripMenuItemClick(object sender, EventArgs e)
 {
   ToolStripMenuItem menu = sender as ToolStripMenuItem;
   SectionItem item = new SectionItem();
   ISectionPanel panel = menu.Tag as ISectionPanel;
   if (panel == null)
     return;
   SelectedSection = null;
   item.Name = panel.DisplayName;
   item.PanelName = panel.DisplayName;
   item.Params = panel.GetDefaultParams();
   Package.Sections.Add(item);
   AddSection(item);
   cmb_sectiontype.SelectedItem = item;
 }
 private void AddSection(SectionItem item)
 {
   listBox_sections.Items.Add(item);
 }
 public void Add(SectionItem sectionItem)
 {
     Items.Add(sectionItem);
 }
        public SectionResponseEnum Navigate()
        {
            int pos = 0;

            while (pos < Package.Sections.Items.Count)
            {
                SectionItem currentItem = Package.Sections.Items[pos];
                if (!string.IsNullOrEmpty(currentItem.ConditionGroup))
                {
                    if (!Package.Groups[currentItem.ConditionGroup].Checked)
                    {
                        pos++;
                        continue;
                    }
                }
                Response = MpeInstaller.SectionPanels[currentItem.PanelName].Execute(Package,
                                                                                     currentItem);
                switch (Response)
                {
                case SectionResponseEnum.Back:
                    pos = stack.Pop();
                    break;

                case SectionResponseEnum.Next:
                    stack.Push(pos);
                    pos++;
                    break;

                case SectionResponseEnum.Cancel:
                    if (
                        MessageBox.Show(
                            "Are you sure you want to abort setup of " + Package.GeneralInfo.Name + " - " + Package.GeneralInfo.Version + " ? ", "Install extension", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) !=
                        DialogResult.Yes)
                    {
                        continue;
                    }
                    bool sil = Package.Silent;
                    Package.Silent = true;
                    Package.UnInstall();
                    Package.Silent = sil;
                    return(SectionResponseEnum.Cancel);

                case SectionResponseEnum.Ok:
                    break;

                case SectionResponseEnum.Error:
                    //if (!Package.Silent)
                    //  MessageBox.Show("Error on installation. Installation aborted !");
                    bool sil_ = Package.Silent;
                    Package.Silent = true;
                    Package.UnInstall();
                    Package.Silent = sil_;
                    return(SectionResponseEnum.Error);
                }
                if (Response != SectionResponseEnum.Back && Response != SectionResponseEnum.Next)
                {
                    break;
                }
            }

            return(SectionResponseEnum.Ok);
        }
 public SectionResponseEnum Execute(PackageClass packageClass, SectionItem sectionItem)
 {
   Mode = ShowModeEnum.Real;
   Package = packageClass;
   Section = sectionItem;
   SetValues();
   Base.ActionExecute(Package, Section, ActionExecuteLocationEnum.BeforPanelShow);
   Base.ActionExecute(Package, Section, ActionExecuteLocationEnum.AfterPanelShow);
   if (!packageClass.Silent)
     ShowDialog();
   else
     base.Resp = SectionResponseEnum.Next;
   Base.ActionExecute(Package, Section, ActionExecuteLocationEnum.AfterPanelHide);
   return base.Resp;
 }
 public void Add(SectionItem sectionItem)
 {
   Items.Add(sectionItem);
 }