Example #1
0
        private void DoTabs(List <PathEntry> pathCollection)
        {
            PathTabControl.Visible = false;
            PathTabControl.TabPages.Clear();

            // Separate by system
            var systems = Global.Config.PathEntries
                          .Select(s => s.SystemDisplayName)
                          .Distinct()
                          .ToList();

            systems.Sort();

            // Hacky way to put global first
            var global = systems.FirstOrDefault(s => s == "Global");

            systems.Remove(global);
            systems.Insert(0, global);

            var tabPages = new List <TabPage>(systems.Count);

            int x             = UIHelper.ScaleX(6);
            int textboxWidth  = UIHelper.ScaleX(70);
            int padding       = UIHelper.ScaleX(5);
            int buttonWidth   = UIHelper.ScaleX(26);
            int buttonHeight  = UIHelper.ScaleY(23);
            int buttonOffsetY = -1;             // To align the top with the textbox I guess? Always 1 pixel regardless of scaling.
            int widgetOffset  = UIHelper.ScaleX(85);
            int rowHeight     = UIHelper.ScaleY(30);

            foreach (var systemDisplayName in systems)
            {
                var systemId = Global.Config.PathEntries.First(p => p.SystemDisplayName == systemDisplayName).System;
                var t        = new TabPage
                {
                    Text       = systemDisplayName,
                    Name       = systemId,
                    Width      = UIHelper.ScaleX(200),                // Initial Left/Width of child controls are based on this size.
                    AutoScroll = true
                };
                var paths = pathCollection
                            .Where(p => p.System == systemId)
                            .OrderBy(p => p.Ordinal)
                            .ThenBy(p => p.Type)
                            .ToList();

                var y = UIHelper.ScaleY(14);
                foreach (var path in paths)
                {
                    var box = new TextBox
                    {
                        Text                     = path.Path,
                        Location                 = new Point(x, y),
                        Width                    = textboxWidth,
                        Name                     = path.Type,
                        Anchor                   = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
                        MinimumSize              = new Size(UIHelper.ScaleX(26), UIHelper.ScaleY(23)),
                        AutoCompleteMode         = AutoCompleteMode.SuggestAppend,
                        AutoCompleteCustomSource = AutoCompleteOptions,
                        AutoCompleteSource       = AutoCompleteSource.CustomSource,
                    };

                    var btn = new Button
                    {
                        Text     = "",
                        Image    = Properties.Resources.OpenFile,
                        Location = new Point(widgetOffset, y + buttonOffsetY),
                        Size     = new Size(buttonWidth, buttonHeight),
                        Name     = path.Type,
                        Anchor   = AnchorStyles.Top | AnchorStyles.Right,
                    };

                    var tempBox    = box;
                    var tempPath   = path.Type;
                    var tempSystem = path.System;
                    btn.Click += delegate
                    {
                        BrowseFolder(tempBox, tempPath, tempSystem);
                    };

                    int infoPadding = UIHelper.ScaleX(0);
                    if (t.Name.Contains("Global") && path.Type == "Firmware")
                    {
                        infoPadding = UIHelper.ScaleX(26);

                        var firmwareButton = new Button
                        {
                            Name     = "Global",
                            Text     = "",
                            Image    = Properties.Resources.Help,
                            Location = new Point(UIHelper.ScaleX(115), y + buttonOffsetY),
                            Size     = new Size(buttonWidth, buttonHeight),
                            Anchor   = AnchorStyles.Top | AnchorStyles.Right
                        };

                        firmwareButton.Click += delegate
                        {
                            if (Owner is FirmwaresConfig)
                            {
                                MessageBox.Show("C-C-C-Combo Breaker!", "Nice try, but");
                                return;
                            }

                            var f = new FirmwaresConfig {
                                TargetSystem = "Global"
                            };
                            f.ShowDialog(this);
                        };

                        t.Controls.Add(firmwareButton);
                    }

                    var label = new Label
                    {
                        Text     = path.Type,
                        Location = new Point(widgetOffset + buttonWidth + padding + infoPadding, y + UIHelper.ScaleY(4)),
                        Size     = new Size(UIHelper.ScaleX(100), UIHelper.ScaleY(15)),
                        Name     = path.Type,
                        Anchor   = AnchorStyles.Top | AnchorStyles.Right,
                    };

                    t.Controls.Add(label);
                    t.Controls.Add(btn);
                    t.Controls.Add(box);

                    y += rowHeight;
                }

                var sys = systemDisplayName;
                if (systemDisplayName == "PCE")                 // Hack
                {
                    sys = "PCECD";
                }

                tabPages.Add(t);
            }

            PathTabControl.TabPages.AddRange(tabPages.ToArray());
            PathTabControl.Visible = true;
        }
Example #2
0
        private void DoTabs(List<PathEntry> pathCollection)
        {
            PathTabControl.Visible = false;
            PathTabControl.TabPages.Clear();

            // Separate by system
            var systems = Global.Config.PathEntries.Select(x => x.SystemDisplayName).Distinct().ToList();
            systems.Sort();

            // Hacky way to put global first
            var global = systems.FirstOrDefault(x => x == "Global");
            systems.Remove(global);
            systems.Insert(0, global);

            var tabPages = new List<TabPage>(systems.Count);

            int _x = UIHelper.ScaleX(6);
            int textboxWidth = UIHelper.ScaleX(70);
            int padding = UIHelper.ScaleX(5);
            int buttonWidth = UIHelper.ScaleX(26);
            int buttonHeight = UIHelper.ScaleY(23);
            int buttonOffsetY = -1; // To align the top with the textbox I guess? Always 1 pixel regardless of scaling.
            int widgetOffset = UIHelper.ScaleX(85);
            int rowHeight = UIHelper.ScaleY(30);

            foreach (var systemDisplayName in systems)
            {
                var systemId = Global.Config.PathEntries.FirstOrDefault(x => x.SystemDisplayName == systemDisplayName).System;
                var t = new TabPage
                {
                    Text = systemDisplayName,
                    Name = systemId,
                    Width = UIHelper.ScaleX(200), // Initial Left/Width of child controls are based on this size.
                    AutoScroll = true
                };
                var paths = pathCollection.Where(x => x.System == systemId).OrderBy(x => x.Ordinal).ThenBy(x => x.Type).ToList();

                var _y = UIHelper.ScaleY(14);
                foreach (var path in paths)
                {
                    var box = new TextBox
                    {
                        Text = path.Path,
                        Location = new Point(_x, _y),
                        Width = textboxWidth,
                        Name = path.Type,
                        Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
                        MinimumSize = new Size(UIHelper.ScaleX(26), UIHelper.ScaleY(23)),
                        AutoCompleteMode = AutoCompleteMode.SuggestAppend,
                        AutoCompleteCustomSource = AutoCompleteOptions,
                        AutoCompleteSource = AutoCompleteSource.CustomSource,
                    };

                    var btn = new Button
                    {
                        Text = string.Empty,
                        Image = Properties.Resources.OpenFile,
                        Location = new Point(widgetOffset, _y + buttonOffsetY),
                        Size = new Size(buttonWidth, buttonHeight),
                        Name = path.Type,
                        Anchor = AnchorStyles.Top | AnchorStyles.Right,
                    };

                    var tempBox = box;
                    var tempPath = path.Type;
                    var tempSystem = path.System;
                    btn.Click += delegate
                    {
                        BrowseFolder(tempBox, tempPath, tempSystem);
                    };

                    int infoPadding = UIHelper.ScaleX(0);
                    if (t.Name.Contains("Global") && path.Type == "Firmware")
                    {
                        infoPadding = UIHelper.ScaleX(26);

                        var firmwareButton = new Button
                        {
                            Name = "Global",
                            Text = String.Empty,
                            Image = Properties.Resources.Help,
                            Location = new Point(UIHelper.ScaleX(115), _y + buttonOffsetY),
                            Size = new Size(buttonWidth, buttonHeight),
                            Anchor = AnchorStyles.Top | AnchorStyles.Right
                        };

                        firmwareButton.Click += delegate
                        {
                            if (Owner is FirmwaresConfig)
                            {
                                MessageBox.Show("C-C-C-Combo Breaker!", "Nice try, but");
                                return;
                            }

                            var f = new FirmwaresConfig { TargetSystem = "Global" };
                            f.ShowDialog(this);
                        };

                        t.Controls.Add(firmwareButton);
                    }

                    var label = new Label
                        {
                        Text = path.Type,
                        Location = new Point(widgetOffset + buttonWidth + padding + infoPadding, _y + UIHelper.ScaleY(4)),
                        Size = new Size(UIHelper.ScaleX(100), UIHelper.ScaleY(15)),
                        Name = path.Type,
                        Anchor = AnchorStyles.Top | AnchorStyles.Right,
                    };

                    t.Controls.Add(label);
                    t.Controls.Add(btn);
                    t.Controls.Add(box);

                    _y += rowHeight;
                }

                var sys = systemDisplayName;
                if (systemDisplayName == "PCE") // Hack
                {
                    sys = "PCECD";
                }

                tabPages.Add(t);
            }

            PathTabControl.TabPages.AddRange(tabPages.ToArray());
            PathTabControl.Visible = true;
        }
Example #3
0
		private void DoTabs(List<PathEntry> pathCollection)
		{
			PathTabControl.Visible = false;
			PathTabControl.TabPages.Clear();

			// Separate by system
			var systems = Global.Config.PathEntries.Select(x => x.SystemDisplayName).Distinct().ToList();
			systems.Sort();

			// Hacky way to put global first
			var global = systems.FirstOrDefault(x => x == "Global");
			systems.Remove(global);
			systems.Insert(0, global);

			var tabPages = new List<TabPage>(systems.Count);

			const int _x = 6;
			const int textboxWidth = 70;
			const int padding = 5;
			const int buttonWidth = 26;
			const int widgetOffset = 85;
			const int rowHeight = 30;

			foreach (var systemDisplayName in systems)
			{
				var systemId = Global.Config.PathEntries.FirstOrDefault(x => x.SystemDisplayName == systemDisplayName).System;
				var t = new TabPage
				{
					Text = systemDisplayName,
					Name = systemId,
				};
				var paths = pathCollection.Where(x => x.System == systemId).OrderBy(x => x.Ordinal).ThenBy(x => x.Type).ToList();

				var _y = 14;
				foreach (var path in paths)
				{
					var box = new TextBox
					{
						Text = path.Path,
						Location = new Point(_x, _y),
						Width = textboxWidth,
						Name = path.Type,
						Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
						MinimumSize = new Size(26, 23),
						AutoCompleteMode = AutoCompleteMode.SuggestAppend,
						AutoCompleteCustomSource = AutoCompleteOptions,
						AutoCompleteSource = AutoCompleteSource.CustomSource,
					};

					var btn = new Button
					{
						Text = string.Empty,
						Image = Properties.Resources.OpenFile,
						Location = new Point(widgetOffset, _y - 1),
						Width = buttonWidth,
						Name = path.Type,
						Anchor = AnchorStyles.Top | AnchorStyles.Right,
					};

					var tempBox = box;
					var tempPath = path.Type;
					var tempSystem = path.System;
					btn.Click += delegate
					{
						BrowseFolder(tempBox, tempPath, tempSystem);
					};

					int infoPadding = 0;
					if (t.Name.Contains("Global") && path.Type == "Firmware")
					{
						infoPadding = 26;

						var firmwareButton = new Button
						{
							Name = "Global",
							Text = String.Empty,
							Image = Properties.Resources.Help,
							Location = new Point(115, _y - 1),
							Width = 26,
							Anchor = AnchorStyles.Top | AnchorStyles.Right
						};

						firmwareButton.Click += delegate
						{
							if (Owner is FirmwaresConfig)
							{
								MessageBox.Show("C-C-C-Combo Breaker!", "Nice try, but");
								return;
							}

							var f = new FirmwaresConfig { TargetSystem = "Global" };
							f.ShowDialog(this);
						};

						t.Controls.Add(firmwareButton);
					}

					var label = new Label
						{
						Text = path.Type,
						Location = new Point(widgetOffset + buttonWidth + padding + infoPadding, _y + 4),
						Width = 100,
						Name = path.Type,
						Anchor = AnchorStyles.Top | AnchorStyles.Right,
					};

					t.Controls.Add(label);
					t.Controls.Add(btn);
					t.Controls.Add(box);

					_y += rowHeight;
				}

				var sys = systemDisplayName;
				if (systemDisplayName == "PCE") // Hack
				{
					sys = "PCECD";
				}

				tabPages.Add(t);
			}

			PathTabControl.TabPages.AddRange(tabPages.ToArray());
			PathTabControl.Visible = true;
		}
Example #4
0
        private void DoTabs(List <PathEntry> pathCollection)
        {
            PathTabControl.Visible = false;
            PathTabControl.TabPages.Clear();

            // Separate by system
            var systems = Global.Config.PathEntries.Select(x => x.SystemDisplayName).Distinct().ToList();

            systems.Sort();

            // Hacky way to put global first
            var global = systems.FirstOrDefault(x => x == "Global");

            systems.Remove(global);
            systems.Insert(0, global);

            var tabPages = new List <TabPage>(systems.Count);

            const int _x           = 6;
            const int textboxWidth = 70;
            const int padding      = 5;
            const int buttonWidth  = 26;
            const int widgetOffset = 85;
            const int rowHeight    = 30;

            foreach (var systemDisplayName in systems)
            {
                var systemId = Global.Config.PathEntries.FirstOrDefault(x => x.SystemDisplayName == systemDisplayName).System;
                var t        = new TabPage
                {
                    Text = systemDisplayName,
                    Name = systemId,
                };
                var paths = pathCollection.Where(x => x.System == systemId).OrderBy(x => x.Ordinal).ThenBy(x => x.Type).ToList();

                var _y = 14;
                foreach (var path in paths)
                {
                    var box = new TextBox
                    {
                        Text                     = path.Path,
                        Location                 = new Point(_x, _y),
                        Width                    = textboxWidth,
                        Name                     = path.Type,
                        Anchor                   = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
                        MinimumSize              = new Size(26, 23),
                        AutoCompleteMode         = AutoCompleteMode.SuggestAppend,
                        AutoCompleteCustomSource = AutoCompleteOptions,
                        AutoCompleteSource       = AutoCompleteSource.CustomSource,
                    };

                    var btn = new Button
                    {
                        Text     = string.Empty,
                        Image    = Properties.Resources.OpenFile,
                        Location = new Point(widgetOffset, _y - 1),
                        Width    = buttonWidth,
                        Name     = path.Type,
                        Anchor   = AnchorStyles.Top | AnchorStyles.Right,
                    };

                    var tempBox    = box;
                    var tempPath   = path.Type;
                    var tempSystem = path.System;
                    btn.Click += delegate
                    {
                        BrowseFolder(tempBox, tempPath, tempSystem);
                    };

                    int infoPadding = 0;
                    if (t.Name.Contains("Global") && path.Type == "Firmware")
                    {
                        infoPadding = 26;

                        var firmwareButton = new Button
                        {
                            Name     = "Global",
                            Text     = String.Empty,
                            Image    = Properties.Resources.Help,
                            Location = new Point(115, _y - 1),
                            Width    = 26,
                            Anchor   = AnchorStyles.Top | AnchorStyles.Right
                        };

                        firmwareButton.Click += delegate
                        {
                            if (Owner is FirmwaresConfig)
                            {
                                MessageBox.Show("C-C-C-Combo Breaker!", "Nice try, but");
                                return;
                            }

                            var f = new FirmwaresConfig {
                                TargetSystem = "Global"
                            };
                            f.ShowDialog(this);
                        };

                        t.Controls.Add(firmwareButton);
                    }

                    var label = new Label
                    {
                        Text     = path.Type,
                        Location = new Point(widgetOffset + buttonWidth + padding + infoPadding, _y + 4),
                        Width    = 100,
                        Name     = path.Type,
                        Anchor   = AnchorStyles.Top | AnchorStyles.Right,
                    };

                    t.Controls.Add(label);
                    t.Controls.Add(btn);
                    t.Controls.Add(box);

                    _y += rowHeight;
                }

                var sys = systemDisplayName;
                if (systemDisplayName == "PCE")                 // Hack
                {
                    sys = "PCECD";
                }

                tabPages.Add(t);
            }

            PathTabControl.TabPages.AddRange(tabPages.ToArray());
            PathTabControl.Visible = true;
        }