Esempio n. 1
0
        private void OnPresetItemChanged(object sender, EventArgs e)
        {
            if (PresetItemList.SelectedItems.Count != 1)
            {
                return;
            }

            PresetItem item = PresetItemList.SelectedItems.First().item;

            CollapseAll();
            if (item is TweakPreset)
            {
                this.tweakItem.Visibility = Visibility.Visible;
                this.tweakItem.SetItem(item as TweakPreset);
            }
            else if (item is FirewallPreset)
            {
                this.ruleItem.Visibility = Visibility.Visible;
                this.ruleItem.SetItem(item as FirewallPreset);
            }
            else if (item is CustomPreset)
            {
                this.customItem.Visibility = Visibility.Visible;
                this.customItem.SetItem(item as CustomPreset);
            }
        }
Esempio n. 2
0
        public void SetDataProvider(object dataProvider)
        {
            PresetItem item = (PresetItem)dataProvider;

            this.name.text = item.Name;
            object[] objArray1 = new object[] { item.hullName, " <sprite name=\"", item.hullId, "\"> ", item.turretName, "<sprite name=\"", item.weaponId, "\"> " };
            this.level.text = string.Concat(objArray1);
        }
Esempio n. 3
0
        private void BtnSyncItems_Click(object sender, RoutedEventArgs e)
        {
            if (PresetItemList.SelectedItems.Count > 0)
            {
                PresetItem item = PresetItemList.SelectedItems.First().item;
                item.Sync(true);

                OnPresetItemChanged(null, null);
            }
        }
Esempio n. 4
0
        private void activation_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (preventchanges || colorpresets.SelectedItem == null || activation.SelectedItem == null)
            {
                return;
            }
            PresetItem item = (PresetItem)colorpresets.SelectedItem;

            item.Preset.Activation = ((LinedefActivateInfo)activation.SelectedItem).Index;
            ValidatePreset(item);
        }
Esempio n. 5
0
        private bool AllowSelectPresetItem(PresetItem item, PresetItem selected)
        {
            if (selected == null)
            {
                return(true);
            }
            long key = selected.presetEntity.GetComponent <UserGroupComponent>().Key;
            long id  = SelfUserComponent.SelfUser.Id;

            return((item.presetEntity.GetComponent <UserGroupComponent>().Key == id) ? (key == id) : (SelfUserComponent.SelfUser.HasComponent <UserUseItemsPrototypeComponent>() && (SelfUserComponent.SelfUser.GetComponent <UserUseItemsPrototypeComponent>().Preset.Id == item.presetEntity.Id)));
        }
        public override void Deserialize(ICustomDataInput reader)
        {
            this.presetId = reader.ReadSByte();

            if (this.presetId < 0)
            {
                throw new Exception("Forbidden value on presetId = " + this.presetId + ", it doesn't respect the following condition : presetId < 0");
            }
            this.presetItem = new PresetItem();
            this.presetItem.Deserialize(reader);
        }
Esempio n. 7
0
        private void action_ValueChanges(object sender, EventArgs e)
        {
            if (preventchanges || colorpresets.SelectedItem == null)
            {
                return;
            }
            PresetItem item = (PresetItem)colorpresets.SelectedItem;

            item.Preset.Action = (action.Enabled ? action.Value : 0);
            ValidatePreset(item);
        }
Esempio n. 8
0
        private void useflags_CheckedChanged(object sender, EventArgs e)
        {
            if (preventchanges || colorpresets.SelectedItem == null)
            {
                return;
            }
            flags.Enabled = useflags.Checked;
            PresetItem item = (PresetItem)colorpresets.SelectedItem;

            ApplyFlagsToPreset(flags, item.Preset);
            ValidatePreset(item);
        }
Esempio n. 9
0
        private void flags_OnCheckStateChanged(object sender, EventArgs eventArgs)
        {
            if (preventchanges || colorpresets.SelectedItem == null)
            {
                return;
            }
            CheckBox   cb   = (CheckBox)sender;
            PresetItem item = (PresetItem)colorpresets.SelectedItem;

            ApplyFlagToPreset(cb.Tag.ToString(), item.Preset, cb.CheckState);
            ValidatePreset(item);
        }
Esempio n. 10
0
        private void movedown_Click(object sender, EventArgs e)
        {
            if (colorpresets.SelectedItem == null)
            {
                return;
            }

            PresetItem item = (PresetItem)colorpresets.SelectedItem;

            colorpresets.Items[colorpresets.SelectedIndex]     = colorpresets.Items[colorpresets.SelectedIndex + 1];
            colorpresets.Items[colorpresets.SelectedIndex + 1] = item;

            colorpresets.SelectedIndex++;
        }
Esempio n. 11
0
        private void addpreset_Click(object sender, EventArgs e)
        {
            // Add new item
            PresetItem item  = new PresetItem();
            int        index = Math.Max(0, colorpresets.SelectedIndex);

            colorpresets.Items.Insert(index, item);
            colorpresets.SetItemChecked(index, true);

            // Select it
            colorpresets.SelectedItem = item;

            // Update controls
            UpdatePresetsListControls();
        }
Esempio n. 12
0
        protected virtual bool GetArgumentValue(string expressionString, ISearchExpressionContext context, out IPresetItem value)
        {
            IPresetItem validItem;
            var         presetArgumentLength = GetPresetArgumentLength(expressionString, context, out validItem);

            if (presetArgumentLength > 0)
            {
                value = validItem;
                return(true);
            }

            value = new PresetItem(null, expressionString.Substring(0, GetArgumentLegth(expressionString, AllowCustomValues)));

            return(AllowCustomValues);
        }
Esempio n. 13
0
        public void UpdateList(List <PresetItem> items)
        {
            base.dataProvider.ClearItems();
            PresetItem selected = null;

            foreach (PresetItem item2 in items)
            {
                if (item2.isSelected && this.AllowSelectPresetItem(item2, selected))
                {
                    selected = item2;
                }
            }
            base.dataProvider.Init <PresetItem>(items, selected);
            base.listTitle.text = selected.Name;
        }
Esempio n. 14
0
        void BeginDeletePreset()
        {
            PresetItem preset = (PresetItem)presetBox.SelectedItem;

            if (preset == null ||
                preset.BuiltIn)
            {
                return;
            }

            if (MessageBox.Show(this,
                                String.Format("Are you sure you want to delete the preset named \"{0}\"?", preset.Name),
                                "Confirm Delete Preset",
                                MessageBoxButtons.OKCancel, MessageBoxIcon.Question)
                != DialogResult.OK)
            {
                return;
            }

            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += (sender, e) =>
                             File.Delete(preset.FilePath);

            worker.RunWorkerCompleted += (sender, e) =>
            {
                if (e.Error != null)
                {
                    MessageBox.Show(this,
                                    String.Format("Could not delete \"{0}\".", preset.FilePath),
                                    "Preset Delete Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                int oldIndex = presetBox.SelectedIndex;
                presetBox.BeginUpdate();
                presetBox.Items.Remove(preset);
                presetBox.SelectedIndex = Math.Min(oldIndex, presetBox.Items.Count - 1);
                presetBox.EndUpdate();

                BeginLoadPreset(false);
            };

            worker.RunWorkerAsync();
        }
Esempio n. 15
0
        private void useactivation_CheckedChanged(object sender, EventArgs e)
        {
            if (preventchanges || colorpresets.SelectedItem == null)
            {
                return;
            }
            activation.Enabled    = useactivation.Checked;
            udmfactivates.Enabled = useactivation.Checked;
            PresetItem item = (PresetItem)colorpresets.SelectedItem;

            if (General.Map.UDMF)
            {
                ApplyFlagsToPreset(udmfactivates, item.Preset);
            }
            else
            {
                item.Preset.Activation = (activation.Enabled ? ((LinedefActivateInfo)activation.SelectedItem).Index : 0);
            }

            ValidatePreset(item);
        }
        private void ApplyPreset(PresetItem pi)
        {
            // access
            if (pi == null)
            {
                return;
            }

            // apply
            if (pi.Location != null)
            {
                TextBoxStartLocation.Text = pi.Location;
            }
            if (pi.Username != null)
            {
                TextBoxUsername.Text = pi.Username;
            }
            if (pi.Password != null)
            {
                TextBoxPassword.Text = pi.Password;
            }
            CheckBoxStayAutoClose.IsChecked = pi.AutoClose;
            CheckBoxStayConnected.IsChecked = pi.StayConnected;
        }
Esempio n. 17
0
        private void BtnAddPresetItem_Click(object sender, RoutedEventArgs e)
        {
            if (CurrentPreset == null)
            {
                return;
            }

            List <string> Categories = new List <string>();

            Categories.Add(PresetType.Tweak.ToString());
            Categories.Add(PresetType.Firewall.ToString());
            //Categories.Add(PresetType.Custom.ToString()); // todo:

            InputWnd wnd = new InputWnd(Translate.fmt("msg_preset_item"), Categories, "", false, App.Title);

            if (wnd.ShowDialog() != true || wnd.Value.Length == 0)
            {
                return;
            }

            PresetItem newItem = null;

            if (wnd.Value == PresetType.Tweak.ToString())
            {
                List <string> TweakNames = new List <string>();
                var           tweaks     = App.tweaks.GetAllGroups().ToList();
                foreach (var tweakGroup in tweaks)
                {
                    TweakNames.Add(tweakGroup.Name);
                }

                InputWnd wnd2 = new InputWnd(Translate.fmt("msg_preset_tweak"), TweakNames, "", true, App.Title);
                if (wnd2.ShowDialog() != true || wnd2.Value.Length == 0)
                {
                    return;
                }

                var tweak = tweaks.Find(x => x.Name.Equals(wnd2.Value));
                if (tweak == null)
                {
                    return;
                }

                TweakPreset item = new TweakPreset();
                item.Name       = tweak.Name;
                item.TweakGroup = tweak.Name;
                newItem         = item;
            }
            else if (wnd.Value == PresetType.Firewall.ToString())
            {
                List <string> ProgNames = new List <string>();
                var           progSets  = App.client.GetPrograms();
                foreach (var progSet in progSets)
                {
                    ProgNames.Add(progSet.config.Name);
                }

                InputWnd wnd2 = new InputWnd(Translate.fmt("msg_preset_progset"), ProgNames, "", true, App.Title);
                if (wnd2.ShowDialog() != true || wnd2.Value.Length == 0)
                {
                    return;
                }

                ProgramSet prog = progSets.Find(x => x.config.Name.Equals(wnd2.Value));
                if (prog == null)
                {
                    return;
                }

                FirewallPreset item = new FirewallPreset();
                item.Name      = prog.config.Name;
                item.ProgSetId = prog.guid;
                newItem        = item;
            }
            else if (wnd.Value == PresetType.Custom.ToString())
            {
                InputWnd wnd2 = new InputWnd(Translate.fmt("msg_preset_item_name"), "", App.Title);
                if (wnd2.ShowDialog() != true || wnd2.Value.Length == 0)
                {
                    return;
                }

                CustomPreset item = new CustomPreset();
                item.Name = wnd2.Value;
                newItem   = item;
            }

            if (newItem != null)
            {
                if (!newItem.Sync())
                {
                    MessageBox.Show(Translate.fmt("msg_preset_item_failed"), App.Title, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return;
                }

                CurrentPreset.Items.Add(newItem.guid, newItem);

                PresetItemList.UpdateItems(CurrentPreset.Items.Values.ToList());
                CollapseAll();
            }
        }
Esempio n. 18
0
 public InventoryPresetItemUpdateMessage(uint presetId = 0, PresetItem presetItem = null)
 {
     PresetId   = presetId;
     PresetItem = presetItem;
 }
Esempio n. 19
0
        private void colorpresets_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (preventchanges)
            {
                return;
            }

            // Disable controls
            if (colorpresets.SelectedIndex == -1)
            {
                curpresetgroup.Enabled = false;
                return;
            }

            preventchanges         = true;
            curpresetgroup.Enabled = true;

            PresetItem item = (PresetItem)colorpresets.SelectedItem;

            // Update name
            presetname.Text = item.ToString();

            // Update color
            presetcolor.Color = item.Preset.Color;

            // Update flags
            ApplyFlagsToControl(item.Preset, flags, useflags);

            // Update action
            action.Value      = item.Preset.Action;
            useaction.Checked = (item.Preset.Action != 0);
            action.Enabled    = (item.Preset.Action != 0);

            // Update activation
            if (General.Map.UDMF)
            {
                ApplyFlagsToControl(item.Preset, udmfactivates, useactivation);
            }
            else if (presetsettings.TabPages.Contains(tabActivation))
            {
                if (item.Preset.Activation == 0)
                {
                    activation.SelectedIndex = 1;
                    useactivation.Checked    = false;
                    activation.Enabled       = false;
                }
                else
                {
                    for (int i = 0; i < activation.Items.Count; i++)
                    {
                        if (((LinedefActivateInfo)activation.Items[i]).Index == item.Preset.Activation)
                        {
                            activation.SelectedIndex = i;
                            useactivation.Checked    = true;
                            activation.Enabled       = true;
                            break;
                        }
                    }
                }
            }

            preventchanges = false;

            // Update warning description
            ValidatePreset(item);

            // Update controls
            UpdatePresetsListControls();
        }
        bool BeginSavePreset(string name)
        {
            if (String.IsNullOrWhiteSpace(name) ||
                name.ContainsAny(Path.GetInvalidFileNameChars()))
            {
                MessageBox.Show(this,
                    "The preset name is not valid.",
                    "Invalid Preset Name",
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }

            PresetItem[] nameConflicts = presetBox.Items
                .OfType<PresetItem>()
                .Where(item => String.Equals(item.Name, name, StringComparison.OrdinalIgnoreCase))
                .ToArray();

            if (nameConflicts.Any(item => item.BuiltIn))
            {
                MessageBox.Show(this,
                    "The preset name is already in use by a built-in preset.",
                    "Invalid Preset Name",
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return false;
            }

            if (nameConflicts.Any() &&
                MessageBox.Show(this,
                    String.Format(
                        "Are you sure you want to overwrite the existing preset named \"{0}\"?",
                        nameConflicts[0].Name),
                    "Confirm Overwrite Preset",
                    MessageBoxButtons.OKCancel, MessageBoxIcon.Question)
                != DialogResult.OK)
                return false;

            statusLabel.Text = "Saving...";

            PresetItem preset = new PresetItem(
                Settings.UserPresetsDirectory +
                Path.DirectorySeparatorChar +
                name + ".xml",
                false);

            XmlDocument document = new XmlDocument();
            XmlElement presetElement = document.AppendNewChildElement("YaffmiPreset");

            presetElement.AppendNewChildElement("GlobalParams", globalParamsBox.Text);
            presetElement.AppendNewChildElement("InputParams", inputParamsBox.Text);
            presetElement.AppendNewChildElement("OutputParams", outputParamsBox.Text);

            presetElement.AppendNewChildElement("FileFormat", fileFormatBox.Text);
            presetElement.AppendNewChildElement("FilenameExtension", fileExtBox.Text);

            presetElement.AppendNewChildElement("IncludeVideo",
                includeVideoCheck.Checked.ToString().ToLower());
            if (includeVideoCheck.Checked)
            {
                presetElement.AppendNewChildElement("VideoStreams", videoStreamsBox.Text);
                presetElement.AppendNewChildElement("VideoCodec", videoCodecBox.Text);
                presetElement.AppendNewChildElement("Width", widthBox.Text);
                presetElement.AppendNewChildElement("Height", heightBox.Text);
                presetElement.AppendNewChildElement("VideoBitrate", videoBitrateBox.Text);
                presetElement.AppendNewChildElement("DisplayAspectRatio", darBox.Text);
                presetElement.AppendNewChildElement("FrameRate", frameRateBox.Text);
                presetElement.AppendNewChildElement("CropTop", topBox.Text);
                presetElement.AppendNewChildElement("CropLeft", leftBox.Text);
                presetElement.AppendNewChildElement("CropRight", rightBox.Text);
                presetElement.AppendNewChildElement("CropBottom", bottomBox.Text);
                presetElement.AppendNewChildElement("VideoFilters", videoFiltersBox.Text);
            }

            presetElement.AppendNewChildElement("IncludeAudio",
                includeAudioCheck.Checked.ToString().ToLower());
            if (includeAudioCheck.Checked)
            {
                presetElement.AppendNewChildElement("AudioStreams", audioStreamsBox.Text);
                presetElement.AppendNewChildElement("AudioCodec", audioCodecBox.Text);
                presetElement.AppendNewChildElement("AudioBitrate", audioBitrateBox.Text);
                presetElement.AppendNewChildElement("ChannelCount", channelCountBox.Text);
                presetElement.AppendNewChildElement("SampleRate", sampleRateBox.Text);
                presetElement.AppendNewChildElement("Volume", volumeBox.Text);
                presetElement.AppendNewChildElement("AudioFilters", audioFiltersBox.Text);
            }

            presetElement.AppendNewChildElement("IncludeSubtitles",
                includeSubtitlesCheck.Checked.ToString().ToLower());
            if (includeSubtitlesCheck.Checked)
                presetElement.AppendNewChildElement("SubtitlesStreams", subtitlesStreamsBox.Text);

            XmlWriterSettings settings = new XmlWriterSettings
            {
                Indent = true,
                CloseOutput = true,
            };

            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += (sender, e) =>
            {
                foreach (PresetItem item in nameConflicts)
                    File.Delete(item.FilePath);

                using (XmlWriter writer = XmlWriter.Create(preset.FilePath, settings))
                    document.WriteTo(writer);
            };

            worker.RunWorkerCompleted += (sender, e) =>
            {
                if (e.Error != null)
                {
                    statusLabel.Text = "Save error.";

                    MessageBox.Show(this,
                        String.Format("Could not save \"{0}\".", preset.FilePath),
                        "Preset Save Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;
                }

                presetBox.BeginUpdate();
                foreach (PresetItem item in nameConflicts)
                    presetBox.Items.Remove(item);
                presetBox.Items.Add(preset);
                presetBox.SelectedItem = preset;
                presetBox.EndUpdate();

                saveButton.Enabled = true;
                deleteButton.Enabled = true;

                statusLabel.Text = "";
                unsavedChanges = false;
            };

            worker.RunWorkerAsync();

            return true;
        }
 public override void Deserialize(IDataReader reader)
 {
     PresetId   = reader.ReadByte();
     PresetItem = new PresetItem();
     PresetItem.Deserialize(reader);
 }
Esempio n. 22
0
        bool BeginSavePreset(string name)
        {
            if (String.IsNullOrWhiteSpace(name) ||
                name.ContainsAny(Path.GetInvalidFileNameChars()))
            {
                MessageBox.Show(this,
                                "The preset name is not valid.",
                                "Invalid Preset Name",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }

            PresetItem[] nameConflicts = presetBox.Items
                                         .OfType <PresetItem>()
                                         .Where(item => String.Equals(item.Name, name, StringComparison.OrdinalIgnoreCase))
                                         .ToArray();

            if (nameConflicts.Any(item => item.BuiltIn))
            {
                MessageBox.Show(this,
                                "The preset name is already in use by a built-in preset.",
                                "Invalid Preset Name",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }

            if (nameConflicts.Any() &&
                MessageBox.Show(this,
                                String.Format(
                                    "Are you sure you want to overwrite the existing preset named \"{0}\"?",
                                    nameConflicts[0].Name),
                                "Confirm Overwrite Preset",
                                MessageBoxButtons.OKCancel, MessageBoxIcon.Question)
                != DialogResult.OK)
            {
                return(false);
            }

            statusLabel.Text = "Saving...";

            PresetItem preset = new PresetItem(
                Settings.UserPresetsDirectory +
                Path.DirectorySeparatorChar +
                name + ".xml",
                false);

            XmlDocument document      = new XmlDocument();
            XmlElement  presetElement = document.AppendNewChildElement("YaffmiPreset");

            presetElement.AppendNewChildElement("GlobalParams", globalParamsBox.Text);
            presetElement.AppendNewChildElement("InputParams", inputParamsBox.Text);
            presetElement.AppendNewChildElement("OutputParams", outputParamsBox.Text);

            presetElement.AppendNewChildElement("FileFormat", fileFormatBox.Text);
            presetElement.AppendNewChildElement("FilenameExtension", fileExtBox.Text);

            presetElement.AppendNewChildElement("IncludeVideo",
                                                includeVideoCheck.Checked.ToString().ToLower());
            if (includeVideoCheck.Checked)
            {
                presetElement.AppendNewChildElement("VideoStreams", videoStreamsBox.Text);
                presetElement.AppendNewChildElement("VideoCodec", videoCodecBox.Text);
                presetElement.AppendNewChildElement("Width", widthBox.Text);
                presetElement.AppendNewChildElement("Height", heightBox.Text);
                presetElement.AppendNewChildElement("VideoBitrate", videoBitrateBox.Text);
                presetElement.AppendNewChildElement("DisplayAspectRatio", darBox.Text);
                presetElement.AppendNewChildElement("FrameRate", frameRateBox.Text);
                presetElement.AppendNewChildElement("CropTop", topBox.Text);
                presetElement.AppendNewChildElement("CropLeft", leftBox.Text);
                presetElement.AppendNewChildElement("CropRight", rightBox.Text);
                presetElement.AppendNewChildElement("CropBottom", bottomBox.Text);
                presetElement.AppendNewChildElement("VideoFilters", videoFiltersBox.Text);
            }

            presetElement.AppendNewChildElement("IncludeAudio",
                                                includeAudioCheck.Checked.ToString().ToLower());
            if (includeAudioCheck.Checked)
            {
                presetElement.AppendNewChildElement("AudioStreams", audioStreamsBox.Text);
                presetElement.AppendNewChildElement("AudioCodec", audioCodecBox.Text);
                presetElement.AppendNewChildElement("AudioBitrate", audioBitrateBox.Text);
                presetElement.AppendNewChildElement("ChannelCount", channelCountBox.Text);
                presetElement.AppendNewChildElement("SampleRate", sampleRateBox.Text);
                presetElement.AppendNewChildElement("Volume", volumeBox.Text);
                presetElement.AppendNewChildElement("AudioFilters", audioFiltersBox.Text);
            }

            presetElement.AppendNewChildElement("IncludeSubtitles",
                                                includeSubtitlesCheck.Checked.ToString().ToLower());
            if (includeSubtitlesCheck.Checked)
            {
                presetElement.AppendNewChildElement("SubtitlesStreams", subtitlesStreamsBox.Text);
            }

            XmlWriterSettings settings = new XmlWriterSettings
            {
                Indent      = true,
                CloseOutput = true,
            };

            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += (sender, e) =>
            {
                foreach (PresetItem item in nameConflicts)
                {
                    File.Delete(item.FilePath);
                }

                using (XmlWriter writer = XmlWriter.Create(preset.FilePath, settings))
                    document.WriteTo(writer);
            };

            worker.RunWorkerCompleted += (sender, e) =>
            {
                if (e.Error != null)
                {
                    statusLabel.Text = "Save error.";

                    MessageBox.Show(this,
                                    String.Format("Could not save \"{0}\".", preset.FilePath),
                                    "Preset Save Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;
                }

                presetBox.BeginUpdate();
                foreach (PresetItem item in nameConflicts)
                {
                    presetBox.Items.Remove(item);
                }
                presetBox.Items.Add(preset);
                presetBox.SelectedItem = preset;
                presetBox.EndUpdate();

                saveButton.Enabled   = true;
                deleteButton.Enabled = true;

                statusLabel.Text = "";
                unsavedChanges   = false;
            };

            worker.RunWorkerAsync();

            return(true);
        }
Esempio n. 23
0
        public void OnPresetSelected(ListItem item)
        {
            PresetItem data = (PresetItem)item.Data;

            this.Mount(data.presetEntity);
        }
 public InventoryPresetItemUpdateMessage(byte presetId, PresetItem presetItem)
 {
     PresetId   = presetId;
     PresetItem = presetItem;
 }
Esempio n. 25
0
 public void RemoveObject(PresetItem presetItem)
 {
     Objects.Remove(presetItem);
     IsDirty = true;
 }
Esempio n. 26
0
        bool BeginLoadPreset(bool prompt)
        {
            PresetItem preset = (PresetItem)presetBox.SelectedItem;

            if (preset == null)
            {
                return(false);
            }

            if (prompt &&
                unsavedChanges &&
                MessageBox.Show(this,
                                "Loading a preset will overwrite your current options. Continue?",
                                "Confirm Load Preset",
                                MessageBoxButtons.OKCancel, MessageBoxIcon.Question)
                != DialogResult.OK)
            {
                return(false);
            }

            saveButton.Enabled   = !preset.BuiltIn;
            deleteButton.Enabled = !preset.BuiltIn;

            statusLabel.Text = "Loading...";

            XmlDocument document = new XmlDocument();

            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += (sender, e) => document.Load(preset.FilePath);

            worker.RunWorkerCompleted += (sender, e) =>
            {
                if (e.Error != null ||
                    document.DocumentElement == null)
                {
                    statusLabel.Text = "Load error.";
                    unsavedChanges   = false;

                    MessageBox.Show(this,
                                    String.Format("Could not load \"{0}\".", preset.FilePath),
                                    "Preset Load Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;
                }

                XmlElement presetElement = document.DocumentElement;

                globalParamsBox.Text = presetElement.GetChildText("GlobalParams") ?? "";
                inputParamsBox.Text  = presetElement.GetChildText("InputParams") ?? "";
                outputParamsBox.Text = presetElement.GetChildText("OutputParams") ?? "";

                fileFormatBox.Text = presetElement.GetChildText("FileFormat") ?? "";
                fileExtBox.Text    = presetElement.GetChildText("FilenameExtension") ?? "";

                includeVideoCheck.Checked = Helpers.ToBool(presetElement.GetChildText("IncludeVideo"));
                videoStreamsBox.Text      = presetElement.GetChildText("VideoStreams") ?? "";
                videoCodecBox.Text        = presetElement.GetChildText("VideoCodec") ?? "";
                widthBox.Text             = presetElement.GetChildText("Width") ?? "";
                heightBox.Text            = presetElement.GetChildText("Height") ?? "";
                videoBitrateBox.Text      = presetElement.GetChildText("VideoBitrate") ?? "";
                darBox.Text          = presetElement.GetChildText("DisplayAspectRatio") ?? "";
                frameRateBox.Text    = presetElement.GetChildText("FrameRate") ?? "";
                topBox.Text          = presetElement.GetChildText("CropTop") ?? "";
                leftBox.Text         = presetElement.GetChildText("CropLeft") ?? "";
                rightBox.Text        = presetElement.GetChildText("CropRight") ?? "";
                bottomBox.Text       = presetElement.GetChildText("CropBottom") ?? "";
                videoFiltersBox.Text = presetElement.GetChildText("VideoFilters") ?? "";

                includeAudioCheck.Checked = Helpers.ToBool(presetElement.GetChildText("IncludeAudio"));
                audioStreamsBox.Text      = presetElement.GetChildText("AudioStreams") ?? "";
                audioCodecBox.Text        = presetElement.GetChildText("AudioCodec") ?? "";
                audioBitrateBox.Text      = presetElement.GetChildText("AudioBitrate") ?? "";
                channelCountBox.Text      = presetElement.GetChildText("ChannelCount") ?? "";
                sampleRateBox.Text        = presetElement.GetChildText("SampleRate") ?? "";
                volumeBox.Text            = presetElement.GetChildText("Volume") ?? "";
                audioFiltersBox.Text      = presetElement.GetChildText("AudioFilters") ?? "";

                includeSubtitlesCheck.Checked = Helpers.ToBool(presetElement.GetChildText("IncludeSubtitles"));
                subtitlesStreamsBox.Text      = presetElement.GetChildText("SubtitlesStreams") ?? "";

                statusLabel.Text = "";
                unsavedChanges   = false;
            };

            worker.RunWorkerAsync();

            return(true);
        }
Esempio n. 27
0
 public void AddObject(PresetItem presetItem)
 {
     Objects.Add(presetItem);
     IsDirty = true;
 }
 public override void Deserialize(ICustomDataInput reader)
 {
     m_presetItem = new PresetItem();
     m_presetItem.Deserialize(reader);
     m_presetId = reader.ReadByte();
 }
 public InventoryPresetItemUpdateMessage(PresetItem presetItem, byte presetId)
 {
     m_presetItem = presetItem;
     m_presetId   = presetId;
 }
Esempio n. 30
0
        public LinedefColorPresetsForm()
        {
            preventchanges = true;

            InitializeComponent();

            // Fill filters list
            foreach (LinedefColorPreset preset in General.Map.ConfigSettings.LinedefColorPresets)
            {
                PresetItem pi = new PresetItem(preset);
                ValidatePreset(pi);
                int index = colorpresets.Items.Add(pi);
                if (preset.Enabled)
                {
                    colorpresets.SetItemChecked(index, true);
                }
            }

            // Setup preset controls
            // Add flags
            foreach (KeyValuePair <string, string> lf in General.Map.Config.LinedefFlags)
            {
                CheckBox box = flags.Add(lf.Value, lf.Key);
                box.ThreeState         = true;
                box.CheckStateChanged += flags_OnCheckStateChanged;
            }

            // Fill actions list
            action.GeneralizedCategories = General.Map.Config.GenActionCategories;

            List <LinedefActionInfo> infos = new List <LinedefActionInfo> {
                new LinedefActionInfo(-1, "Any action", true, false)
            };

            infos.AddRange(General.Map.Config.SortedLinedefActions);

            action.AddInfo(infos.ToArray());
            action.Value = -1;

            //activations
            udmfactivates.Visible = General.Map.UDMF;
            activation.Visible    = !General.Map.UDMF;

            //get activates
            List <LinedefActivateInfo> activations = new List <LinedefActivateInfo>(General.Map.Config.LinedefActivates);

            if (activations.Count > 0)
            {
                activations.Insert(0, new LinedefActivateInfo("-1", "Any activation"));

                if (General.Map.UDMF)
                {
                    foreach (LinedefActivateInfo ai in General.Map.Config.LinedefActivates)
                    {
                        CheckBox box = udmfactivates.Add(ai.Title, ai.Key);
                        box.ThreeState         = true;
                        box.CheckStateChanged += flags_OnCheckStateChanged;
                    }
                }
                else
                {
                    activation.Items.AddRange(activations.ToArray());
                }
            }
            else
            {
                presetsettings.TabPages.Remove(tabActivation);
            }

            UpdatePresetsListControls();
            preventchanges = false;

            // Select first preset or disable controls
            if (colorpresets.Items.Count > 0)
            {
                colorpresets.SelectedIndex = 0;
            }
            else
            {
                curpresetgroup.Enabled = false;
            }
        }
Esempio n. 31
0
 public InventoryPresetItemUpdateMessage(sbyte presetId, PresetItem presetItem)
 {
     this.presetId   = presetId;
     this.presetItem = presetItem;
 }