Пример #1
0
        private void AddMaskedEdits(DesignerForm newDialog, XmlNodeList maskedEdits)
        {
            foreach (XmlNode edit in maskedEdits)
            {
                try
                {
                    TextBox newEdit = new TextBox();
                    SetControlAttributes(newEdit, edit);
                    SetText(newEdit, edit);

                    newEdit.BorderStyle = BorderStyle.Fixed3D;

                    newDialog.AddControl(edit, newEdit);
                }
                catch
                {
                }
            }
        }
Пример #2
0
        private void AddLines(DesignerForm newDialog, XmlNodeList lines)
        {
            foreach (XmlNode line in lines)
            {
                try
                {
                    Label label = new Label();
                    SetControlAttributes(label, line);

                    label.Height = 2;
                    label.BorderStyle = BorderStyle.Fixed3D;

                    newDialog.AddControl(line, label);
                }
                catch
                {
                }
            }
        }
Пример #3
0
        private void AddListBoxes(DesignerForm newDialog, XmlNodeList listBoxes)
        {
            foreach (XmlNode list in listBoxes)
            {
                try
                {
                    ListBox listCtrl = new ListBox();
                    SetControlAttributes(listCtrl, list);

                    listCtrl.Items.Add(GetFromXmlElement(list, "Property"));

                    newDialog.AddControl(list, listCtrl);
                }
                catch
                {
                }
            }
        }
Пример #4
0
        private void AddVolumeComboBoxes(DesignerForm newDialog, XmlNodeList volumeCombos)
        {
            foreach (XmlNode volumeCombo in volumeCombos)
            {
                try
                {
                    ComboBox comboCtrl = new ComboBox();
                    comboCtrl.Items.Add("VolumeCombo");
                    comboCtrl.SelectedIndex = 0;

                    SetControlAttributes(comboCtrl, volumeCombo);

                    newDialog.AddControl(volumeCombo, comboCtrl);
                }
                catch
                {
                }
            }
        }
Пример #5
0
        private void ShowWixDialog(XmlNode dialog)
        {
            DesignerForm prevDialog = null;
            int prevTop = 0;
            int prevLeft = 0;

            if (currentDialog != null)
            {
                prevTop = currentDialog.Top;
                prevLeft = currentDialog.Left;
                prevDialog = currentDialog;
            }
            else
            {
                if (TopLevelControl != null)
                {
                    prevTop = TopLevelControl.Top;
                    prevLeft = TopLevelControl.Right;

                    if (prevLeft >= Screen.PrimaryScreen.WorkingArea.Width)
                    {
                        prevLeft = prevLeft / 3;
                    }
                    if (prevTop >= Screen.PrimaryScreen.WorkingArea.Height)
                    {
                        prevTop = prevTop / 3;
                    }
                }
            }

            if (dialog != null)
            {
                DialogGenerator generator = new DialogGenerator(WixFiles, TopLevelControl);
                currentDialog = generator.GenerateDialog(dialog, this);

                if (currentDialog != null)
                {
                    currentDialog.ItemChanged += new DesignerFormItemHandler(OnDialogItemChanged);
                    currentDialog.ItemDeleted += new DesignerFormItemHandler(OnDialogItemDeleted);
                    currentDialog.SelectionChanged += new DesignerFormItemHandler(OnDialogSelectionChanged);

                    currentDialog.Left = prevLeft;
                    currentDialog.Top = prevTop;

                    currentDialog.Opacity = GetOpacity();
                    currentDialog.TopMost = AlwaysOnTop.Checked;

                    currentDialog.NewControl += new DesignerFormNewItemHandler(EditDialog_NewControl);
                    currentDialog.NewControls = controlTypes;

                    currentDialog.Show();
                }
            }

            if (prevDialog != null)
            {
                prevDialog.Close();
                prevDialog.Dispose();
            }

            wxsDialogs.Focus();
        }
Пример #6
0
        private void AddRadioButtonGroups(DesignerForm newDialog, XmlNodeList radioButtonGroups)
        {
            foreach (XmlNode radioButtonGroup in radioButtonGroups)
            {
                try
                {
                    string radioGroupName = radioButtonGroup.Attributes["Property"].Value;
                    string defaultValue = ExpandWixProperties(String.Format("[{0}]", radioGroupName));

                    XmlNode radioGroup = wixFiles.WxsDocument.SelectSingleNode(String.Format("//wix:RadioGroup[@Property='{0}']", radioGroupName), wixFiles.WxsNsmgr);
                    if (radioGroup == null)
                    {
                        radioGroup = wixFiles.WxsDocument.SelectSingleNode(String.Format("//wix:RadioButtonGroup[@Property='{0}']", radioGroupName), wixFiles.WxsNsmgr);
                    }

                    Panel panel = new Panel();
                    SetControlAttributes(panel, radioButtonGroup);

                    foreach (XmlNode radioElement in radioGroup.ChildNodes)
                    {
                        RadioButton radioCtrl = new RadioButton();
                        SetText(radioCtrl, radioElement);
                        SetTag(radioCtrl, radioElement);

                        SetControlAttributes(radioCtrl, radioElement);

                        panel.Controls.Add(radioCtrl);

                        if (((string)radioCtrl.Tag).ToLower() == defaultValue.ToLower())
                        {
                            radioCtrl.Checked = true;
                        }
                    }

                    newDialog.AddControl(radioButtonGroup, panel);
                }
                catch
                {
                }
            }
        }
Пример #7
0
        private void AddSelectionTrees(DesignerForm newDialog, XmlNodeList selectionTrees)
        {
            foreach (XmlNode selectionTree in selectionTrees)
            {
                try
                {
                    TreeView treeView = new TreeView();
                    treeView.Scrollable = false;
                    treeView.Nodes.Add(new TreeNode("Selection tree"));

                    SetControlAttributes(treeView, selectionTree);

                    newDialog.AddControl(selectionTree, treeView);
                }
                catch
                {
                }
            }
        }
Пример #8
0
        private void AddComboBoxes(DesignerForm newDialog, XmlNodeList comboBoxes)
        {
            foreach (XmlNode comboBox in comboBoxes)
            {
                try
                {
                    ComboBox comboCtrl = new ComboBox();
                    SetControlAttributes(comboCtrl, comboBox);

                    comboCtrl.Items.Add("ComboBox");
                    comboCtrl.SelectedIndex = 0;

                    newDialog.AddControl(comboBox, comboCtrl);
                }
                catch
                {
                }
            }
        }
Пример #9
0
        private void AddDirectoryCombos(DesignerForm newDialog, XmlNodeList directoryCombos)
        {
            foreach (XmlNode directoryCombo in directoryCombos)
            {
                try
                {
                    ComboBox comboCtrl = new ComboBox();
                    comboCtrl.Items.Add("Directories");
                    comboCtrl.SelectedIndex = 0;

                    SetControlAttributes(comboCtrl, directoryCombo);

                    newDialog.AddControl(directoryCombo, comboCtrl);
                }
                catch
                {
                }
            }
        }
Пример #10
0
        private void AddButtons(DesignerForm newDialog, XmlNodeList buttons)
        {
            foreach (XmlNode button in buttons)
            {
                try
                {
                    Button newButton = new Button();
                    SetControlAttributes(newButton, button);

                    if (button.Attributes["Icon"] != null &&
                        button.Attributes["Icon"].Value.ToLower() == "yes")
                    {
                        string binaryId = GetTextFromXmlElement(button);
                        try
                        {
                            using (Stream imageStream = GetBinaryStream(binaryId))
                            {
                                Bitmap bmp = new Icon(imageStream).ToBitmap();
                                Bitmap dest = new Bitmap((int)Math.Round(bmp.Width * scale), (int)Math.Round(bmp.Height * scale));

                                Graphics g = Graphics.FromImage(dest);
                                g.InterpolationMode = InterpolationMode.HighQualityBicubic;

                                g.DrawImage(bmp,
                                    new Rectangle(0, 0, dest.Width, dest.Height),
                                    new Rectangle(0, 0, bmp.Width, bmp.Height),
                                    GraphicsUnit.Pixel);

                                g.Dispose();
                                bmp.Dispose();

                                newButton.Image = dest;
                            }
                        }
                        catch
                        {
                            SetText(newButton, button);
                        }
                    }
                    else
                    {
                        newButton.FlatStyle = FlatStyle.System;
                        SetText(newButton, button);
                    }

                    newDialog.AddControl(button, newButton);
                }
                catch
                {
                }
            }
        }
Пример #11
0
        private void AddCheckBoxes(DesignerForm newDialog, XmlNodeList checkboxes)
        {
            foreach (XmlNode check in checkboxes)
            {
                try
                {
                    CheckBox checkBox = new CheckBox();
                    SetControlAttributes(checkBox, check);
                    SetText(checkBox, check);

                    newDialog.AddControl(check, checkBox);
                }
                catch
                {
                }
            }
        }
Пример #12
0
        private void AddBackgroundBitmaps(DesignerForm newDialog, XmlNodeList bitmaps)
        {
            PictureControl pictureCtrl = null;
            ArrayList allPictureControls = new ArrayList();

            foreach (XmlNode bitmap in bitmaps)
            {
                try
                {
                    string binaryId = GetTextFromXmlElement(bitmap);

                    Bitmap bmp = null;
                    try
                    {
                        using (Stream imageStream = GetBinaryStream(binaryId))
                        {
                            bmp = new Bitmap(imageStream);
                        }
                    }
                    catch
                    {
                    }

                    pictureCtrl = new PictureControl(bmp, allPictureControls);
                    allPictureControls.Add(pictureCtrl);

                    SetControlAttributes(pictureCtrl, bitmap);

                    newDialog.AddControl(bitmap, pictureCtrl);
                }
                catch
                {
                }
            }

            if (pictureCtrl != null)
            {
                pictureCtrl.Draw();
            }
        }
Пример #13
0
        public DesignerForm GenerateDialog(XmlNode dialog, Control parent)
        {
            DesignerForm newDialog = new DesignerForm(wixFiles, dialog);

            parentHwnd = (int)parent.Handle;

            newDialog.Font = new Font("Tahoma", (float)(scale * 8.00F), FontStyle.Regular, GraphicsUnit.Point, ((System.Byte)(0)));
            newDialog.ShowInTaskbar = true;
            // newDialog.TopMost = true;
            // newDialog.Opacity = 0.75;

            newDialog.Icon = new Icon(WixFiles.GetResourceStream("dialog.msi.ico"));

            newDialog.StartPosition = FormStartPosition.Manual;

            newDialog.MinimizeBox = false;
            newDialog.MaximizeBox = false;
            newDialog.FormBorderStyle = FormBorderStyle.FixedDialog;

            if (dialog.Attributes["Width"] == null ||
                dialog.Attributes["Width"].Value.Trim().Length == 0 ||
                dialog.Attributes["Height"] == null ||
                dialog.Attributes["Height"].Value.Trim().Length == 0)
            {
                return null;
            }

            newDialog.ClientSize = new Size(DialogUnitsToPixelsWidth(XmlConvert.ToInt32(dialog.Attributes["Width"].Value.Trim())), DialogUnitsToPixelsHeight(XmlConvert.ToInt32(dialog.Attributes["Height"].Value.Trim())));

            // Background Images should be added first, these controls should be used as parent
            // to get correct transparancy. For now only 1 bitmap is supported per Dialog.
            // - Is this the correct way to handle the transparancy?
            // - How does MSI handle transparant labels when having 2 bitmaps as background?

            XmlNodeList buttons = dialog.SelectNodes("wix:Control[@Type='PushButton']", wixFiles.WxsNsmgr);
            AddButtons(newDialog, buttons);

            XmlNodeList edits = dialog.SelectNodes("wix:Control[@Type='Edit']", wixFiles.WxsNsmgr);
            AddEditBoxes(newDialog, edits);

            XmlNodeList checks = dialog.SelectNodes("wix:Control[@Type='CheckBox']", wixFiles.WxsNsmgr);
            AddCheckBoxes(newDialog, checks);

            XmlNodeList pathEdits = dialog.SelectNodes("wix:Control[@Type='PathEdit']", wixFiles.WxsNsmgr);
            AddPathEditBoxes(newDialog, pathEdits);

            XmlNodeList lines = dialog.SelectNodes("wix:Control[@Type='Line']", wixFiles.WxsNsmgr);
            AddLines(newDialog, lines);

            XmlNodeList texts = dialog.SelectNodes("wix:Control[@Type='Text']", wixFiles.WxsNsmgr);
            AddTexts(newDialog, texts);

            XmlNodeList rtfTexts = dialog.SelectNodes("wix:Control[@Type='ScrollableText']", wixFiles.WxsNsmgr);
            AddRftTextBoxes(newDialog, rtfTexts);

            XmlNodeList groupBoxes = dialog.SelectNodes("wix:Control[@Type='GroupBox']", wixFiles.WxsNsmgr);
            AddGroupBoxes(newDialog, groupBoxes);

            XmlNodeList icons = dialog.SelectNodes("wix:Control[@Type='Icon']", wixFiles.WxsNsmgr);
            AddIcons(newDialog, icons);

            XmlNodeList listBoxes = dialog.SelectNodes("wix:Control[@Type='ListBox']", wixFiles.WxsNsmgr);
            AddListBoxes(newDialog, listBoxes);

            XmlNodeList comboBoxes = dialog.SelectNodes("wix:Control[@Type='ComboBox']", wixFiles.WxsNsmgr);
            AddComboBoxes(newDialog, comboBoxes);

            XmlNodeList progressBars = dialog.SelectNodes("wix:Control[@Type='ProgressBar']", wixFiles.WxsNsmgr);
            AddProgressBars(newDialog, progressBars);

            XmlNodeList radioButtonGroups = dialog.SelectNodes("wix:Control[@Type='RadioButtonGroup']", wixFiles.WxsNsmgr);
            AddRadioButtonGroups(newDialog, radioButtonGroups);

            XmlNodeList maskedEdits = dialog.SelectNodes("wix:Control[@Type='MaskedEdit']", wixFiles.WxsNsmgr);
            AddMaskedEdits(newDialog, maskedEdits);

            XmlNodeList volumeCostLists = dialog.SelectNodes("wix:Control[@Type='VolumeCostList']", wixFiles.WxsNsmgr);
            AddVolumeCostLists(newDialog, volumeCostLists);

            XmlNodeList volumeComboBoxes = dialog.SelectNodes("wix:Control[@Type='VolumeSelectCombo']", wixFiles.WxsNsmgr);
            AddVolumeComboBoxes(newDialog, volumeComboBoxes);

            // Skipping tooltips
            /*
                        XmlNodeList tooltips = dialog.SelectNodes("wix:Control[@Type='Tooltips']", wixFiles.WxsNsmgr);
                        AddTooltips(newDialog, tooltips);
            */
            XmlNodeList directoryCombos = dialog.SelectNodes("wix:Control[@Type='DirectoryCombo']", wixFiles.WxsNsmgr);
            AddDirectoryCombos(newDialog, directoryCombos);

            XmlNodeList directoryLists = dialog.SelectNodes("wix:Control[@Type='DirectoryList']", wixFiles.WxsNsmgr);
            AddDirectoryLists(newDialog, directoryLists);

            XmlNodeList selectionTrees = dialog.SelectNodes("wix:Control[@Type='SelectionTree']", wixFiles.WxsNsmgr);
            AddSelectionTrees(newDialog, selectionTrees);

            XmlNodeList bitmaps = dialog.SelectNodes("wix:Control[@Type='Bitmap']", wixFiles.WxsNsmgr);
            AddBackgroundBitmaps(newDialog, bitmaps);

            if (dialog.Attributes["Title"] != null)
            {
                newDialog.Text = ExpandWixProperties(dialog.Attributes["Title"].Value);
            }

            if (dialog.Attributes["NoMinimize"] == null)
            {
                newDialog.MinimizeBox = true;
            }
            else
            {
                newDialog.MinimizeBox = (dialog.Attributes["NoMinimize"].Value.ToLower() != "yes");
            }

            return newDialog;
        }
Пример #14
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (currentDialog != null)
                {
                    currentDialog.Close();
                    currentDialog.Dispose();
                    currentDialog = null;
                }
            }

            base.Dispose(disposing);
        }
Пример #15
0
        private void AddPathEditBoxes(DesignerForm newDialog, XmlNodeList patheditboxes)
        {
            foreach (XmlNode pathEdit in patheditboxes)
            {
                try
                {
                    TextBox newPathEdit = new TextBox();
                    SetControlAttributes(newPathEdit, pathEdit);
                    SetText(newPathEdit, pathEdit);

                    newDialog.AddControl(pathEdit, newPathEdit);
                }
                catch
                {
                }
            }
        }
Пример #16
0
        private void AddDirectoryLists(DesignerForm newDialog, XmlNodeList directoryLists)
        {
            foreach (XmlNode directoryList in directoryLists)
            {
                try
                {
                    ListBox listBox = new ListBox();
                    listBox.Items.Add("Director content");
                    listBox.SelectedIndex = 0;

                    SetControlAttributes(listBox, directoryList);

                    newDialog.AddControl(directoryList, listBox);
                }
                catch
                {
                }
            }
        }
Пример #17
0
        private void AddProgressBars(DesignerForm newDialog, XmlNodeList progressBars)
        {
            foreach (XmlNode progressbar in progressBars)
            {
                try
                {
                    ProgressBar progressCtrl = new ProgressBar();
                    SetControlAttributes(progressCtrl, progressbar);

                    progressCtrl.Maximum = 100;
                    progressCtrl.Value = 33;

                    newDialog.AddControl(progressbar, progressCtrl);
                }
                catch
                {
                }
            }
        }
Пример #18
0
        private void AddGroupBoxes(DesignerForm newDialog, XmlNodeList groupBoxes)
        {
            foreach (XmlNode group in groupBoxes)
            {
                try
                {
                    GroupBox groupCtrl = new GroupBox();

                    // The FlatStyle.System makes the control look weird.
                    // groupCtrl.FlatStyle = FlatStyle.System;

                    SetControlAttributes(groupCtrl, group);
                    SetText(groupCtrl, group);

                    newDialog.AddControl(group, groupCtrl);
                }
                catch
                {
                }
            }
        }
Пример #19
0
        private void AddRftTextBoxes(DesignerForm newDialog, XmlNodeList rtfTexts)
        {
            foreach (XmlNode text in rtfTexts)
            {
                try
                {
                    RichTextBox rtfCtrl = new RichTextBox();
                    SetControlAttributes(rtfCtrl, text);

                    string elementText = GetTextFromXmlElement(text);

                    rtfCtrl.Rtf = elementText;

                    newDialog.AddControl(text, rtfCtrl);
                }
                catch
                {
                }
            }
        }
Пример #20
0
        private void AddHyperlinks(DesignerForm newDialog, XmlNodeList hyperlinks)
        {
            foreach (XmlNode hyperlink in hyperlinks)
            {
                try
                {
                    Label label = new Label();
                    SetControlAttributes(label, hyperlink);
                    SetText(label, hyperlink);

                    label.BackColor = Color.Transparent;
                    label.ForeColor = Color.Blue;
                    label.Font = new Font(label.Font, FontStyle.Underline);

                    newDialog.AddControl(hyperlink, label);
                }
                catch
                {
                }
            }
        }
Пример #21
0
        private void AddTexts(DesignerForm newDialog, XmlNodeList texts)
        {
            foreach (XmlNode text in texts)
            {
                try
                {
                    Label label = new Label();
                    SetControlAttributes(label, text);
                    SetText(label, text);

                    label.BackColor = Color.Transparent;

                    newDialog.AddControl(text, label);
                }
                catch
                {
                }
            }
        }
Пример #22
0
        private void AddIcons(DesignerForm newDialog, XmlNodeList icons)
        {
            foreach (XmlNode icon in icons)
            {
                try
                {
                    PictureBox picCtrl = new PictureBox();
                    SetControlAttributes(picCtrl, icon);

                    picCtrl.SizeMode = PictureBoxSizeMode.StretchImage;

                    string binaryId = GetTextFromXmlElement(icon);
                    try
                    {
                        using (Stream imageStream = GetBinaryStream(binaryId))
                        {
                            picCtrl.Image = new Icon(imageStream).ToBitmap();
                        }
                    }
                    catch
                    {
                    }

                    newDialog.AddControl(icon, picCtrl);
                }
                catch
                {
                }
            }
        }
Пример #23
0
        private void AddVolumeCostLists(DesignerForm newDialog, XmlNodeList volumeCostLists)
        {
            foreach (XmlNode volumeCostList in volumeCostLists)
            {
                try
                {
                    ListView listView = new ListView();
                    ColumnHeader columnHeader1 = new ColumnHeader();
                    ColumnHeader columnHeader2 = new ColumnHeader();
                    ColumnHeader columnHeader3 = new ColumnHeader();
                    ColumnHeader columnHeader4 = new ColumnHeader();
                    ColumnHeader columnHeader5 = new ColumnHeader();

                    columnHeader1.Text = "Volume";
                    columnHeader2.Text = "Disk Size";
                    columnHeader3.Text = "Available";
                    columnHeader4.Text = "Required";
                    columnHeader5.Text = "Difference";

                    columnHeader1.TextAlign = HorizontalAlignment.Left;
                    columnHeader2.TextAlign = HorizontalAlignment.Right;
                    columnHeader3.TextAlign = HorizontalAlignment.Right;
                    columnHeader4.TextAlign = HorizontalAlignment.Right;
                    columnHeader5.TextAlign = HorizontalAlignment.Right;

                    listView.Columns.AddRange(new ColumnHeader[] { columnHeader1,
                                                                     columnHeader2,
                                                                     columnHeader3,
                                                                     columnHeader4,
                                                                     columnHeader5});

                    listView.Items.Add(new ListViewItem(new string[] { "C:", "30GB", "3200MB", "1MB", "3189MB" }));
                    listView.View = System.Windows.Forms.View.Details;

                    SetControlAttributes(listView, volumeCostList);

                    newDialog.AddControl(volumeCostList, listView);
                }
                catch
                {
                }
            }
        }
Пример #24
0
 public void CloseCurrentDialog()
 {
     if (currentDialog != null)
     {
         currentDialog.Close();
         currentDialog.Dispose();
         currentDialog = null;
     }
 }