private void Grid_SplitSettings_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (e.RowIndex < splitToEventList.Count)
     {
         if (e.ColumnIndex == COLUMNINDEX_SEGMENTNAME)
         {
             e.Value = splitToEventList[e.RowIndex].SegmentName;
         }
         else if (e.ColumnIndex == COLUMNINDEX_EVENT)
         {
             e.Value = SplitsToEvents.GetEnumDescription(splitToEventList[e.RowIndex].EventType);
         }
         else if (e.ColumnIndex == COLUMNINDEX_DELAY)
         {
             var comparisonValue = splitToEventList[e.RowIndex].Delay;
             e.Value             = TimeFormatter.Format(TimeSpan.FromSeconds(comparisonValue));
             e.FormattingApplied = true;
         }
         else if (e.ColumnIndex == COLUMNINDEX_ACTION)
         {
             bool eventUsed = splitToEventList[e.RowIndex].Action.isUsed && splitToEventList[e.RowIndex].EventType == SplitEventType.StartPredictionOnSplitStart;
             e.Value = eventUsed ? "!" : "";
             e.CellStyle.BackColor = eventUsed ? Color.Red : Color.Transparent;
         }
     }
 }
        private void B_EditSplitEvents_Click(object sender, EventArgs e)
        {
            SplitEventsEditorForm splitEventsEditor = new SplitEventsEditorForm(splitStates, (SplitsToEvents)SplitsToEventsInstance.Clone());

            if (splitEventsEditor.ShowDialog() == DialogResult.OK)
            {
                SplitsToEventsInstance = splitEventsEditor.splitToEvents;
            }
        }
예제 #3
0
        public object Clone()
        {
            var clone = new SplitsToEvents();

            clone.UsePBPrediction       = UsePBPrediction;
            clone.NotifyOfErrorsInChat  = NotifyOfErrorsInChat;
            clone.EventList             = EventList.Select(x => (SplitEvent)x.Clone()).ToList();
            clone.OnTimerResetBehaviour = OnTimerResetBehaviour;
            clone.OnRunCompletion       = OnRunCompletion;
            clone.OnRunCompletionDelay  = OnRunCompletionDelay;
            clone.Filename             = Filename;
            clone.RequiresManualFixing = RequiresManualFixing;
            return(clone);
        }
        internal void GetNewSplits()
        {
            if (!Directory.Exists(SubDir))
            {
                Directory.CreateDirectory(SubDir);
            }

            var Filename = ReplaceIncorrectCharacters(splitStates != null && splitStates.Run != null ? splitStates.Run.GameName + "##" + splitStates.Run.CategoryName : "Unknown");

            var fullPath = Path.Combine(SubDir, Filename + ".xml");

            if (File.Exists(fullPath))
            {
                SplitsToEventsInstance = XmlSerialiationDeserilation.ReadFromXMLFile <SplitsToEvents>(fullPath);
            }
            else
            {
                SplitsToEventsInstance = new SplitsToEvents();
            }

            SplitsToEventsInstance.Filename = fullPath;
        }
        public SplitEventsEditorForm(LiveSplitState splitStates, SplitsToEvents splitToEvents)
        {
            this.splitStates   = splitStates;
            this.splitToEvents = splitToEvents;
            InitializeComponent();
            this.DialogResult = DialogResult.Cancel;
            var verficationResult = splitToEvents.Verify(splitStates);

            if (verficationResult != "")
            {
                //MessageBox.Show("Verification found following issues:\n" + verficationResult, "Notification", MessageBoxButtons.OK);
            }

            #region Setting up grid
            TimeFormatter = new ShortTimeFormatter();

            splitToEventList = new BindingList <ISplitEvent>(splitToEvents.EventList.Cast <ISplitEvent>().ToList())
            {
                AllowNew = false, AllowRemove = false
            };
            grid_SplitSettings.AutoGenerateColumns = false;
            grid_SplitSettings.AutoSize            = true;
            grid_SplitSettings.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False;
            grid_SplitSettings.DataSource        = splitToEventList;
            grid_SplitSettings.CellClick        += Grid_SplitSettings_CellClick;
            grid_SplitSettings.CellFormatting   += Grid_SplitSettings_CellFormatting;
            grid_SplitSettings.CellParsing      += Grid_SplitSettings_CellParsing;
            grid_SplitSettings.CellValidating   += Grid_SplitSettings_CellValidating;
            grid_SplitSettings.CellEndEdit      += Grid_SplitSettings_CellEndEdit;
            grid_SplitSettings.SelectionChanged += Grid_SplitSettings_SelectionChanged;

            var segmentNameColumn = new DataGridViewTextBoxColumn();
            segmentNameColumn.Name         = "Segment Name";
            segmentNameColumn.Width        = 350;
            segmentNameColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
            segmentNameColumn.SortMode     = DataGridViewColumnSortMode.NotSortable;
            grid_SplitSettings.Columns.Add(segmentNameColumn);

            var eventTypeColumn = new DataGridViewComboBoxColumn();

            //Hide your children
            eventTypeColumn.Items.AddRange(Enum.GetValues(typeof(SplitEventType)).Cast <Enum>().Select(value => new
            {
                (Attribute.GetCustomAttribute(value.GetType().GetField(value.ToString()), typeof(DescriptionAttribute)) as DescriptionAttribute).Description
            }.Description).ToArray());
            eventTypeColumn.Name  = "Event Type";
            eventTypeColumn.Width = 200;
            eventTypeColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            eventTypeColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
            eventTypeColumn.SortMode     = DataGridViewColumnSortMode.NotSortable;
            grid_SplitSettings.Columns.Add(eventTypeColumn);

            var eventDelayColumn = new DataGridViewTextBoxColumn();
            eventDelayColumn.Name  = "Event delay";
            eventDelayColumn.Width = 80;
            eventDelayColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            eventDelayColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
            eventDelayColumn.SortMode     = DataGridViewColumnSortMode.NotSortable;
            grid_SplitSettings.Columns.Add(eventDelayColumn);

            var eventActionColumn = new DataGridViewButtonColumn();
            eventActionColumn.Name  = "Action";
            eventActionColumn.Width = 50;
            eventActionColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            eventActionColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
            eventActionColumn.SortMode     = DataGridViewColumnSortMode.NotSortable;
            grid_SplitSettings.Columns.Add(eventActionColumn);

            grid_SplitSettings.EditingControlShowing += Grid_SplitSettings_EditingControlShowing;
            #endregion

            AddComboboxDataSources();
            CBox_OnRunReset.DataBindings.Add("SelectedValue", this.splitToEvents, "OnTimerResetBehaviour", false, DataSourceUpdateMode.OnPropertyChanged);
            CBox_RunCompletion.DataBindings.Add("SelectedValue", this.splitToEvents, "OnRunCompletion", false, DataSourceUpdateMode.OnPropertyChanged);
            CB_UsePBPrediction.DataBindings.Add("Checked", this.splitToEvents, "UsePBPrediction", false, DataSourceUpdateMode.OnPropertyChanged);
            CB_NotifyOfErrorsInChat.DataBindings.Add("Checked", this.splitToEvents, "NotifyOfErrorsInChat", false, DataSourceUpdateMode.OnPropertyChanged);
            TB_OnCompletionDelay.DataBindings.Add("Text", this, "EndSplitOffset");
        }