Пример #1
0
        /// <summary>
        /// Adds a blank item after the current point in the time line.
        /// </summary>
        /// <param name="timeLineItemViewModel"></param>
        public void AddTimeLineItem(TimeLineItemViewModel timeLineItemViewModel)
        {
            TimeLineItems.Insert(TimeLineItems.IndexOf(SelectedTimeLineItem) + 1, timeLineItemViewModel);

            SelectedTimeLineItem = timeLineItemViewModel;

            NotifyOfPropertyChange(() => CanRemoveItem);
            NotifyOfPropertyChange(() => TimeLineItems);
        }
Пример #2
0
        private void Add(TimeLineItemViewModel timeLineItem)
        {
            // Add to list
            TimeLineItems.Add(timeLineItem);

            // Serialize added item
            timeLineItem.SerializationDirectory = _serializationDir;
            timeLineItem.ShouldAutoSerialize    = true;
            timeLineItem.SerializeConfigurations(null, null);
        }
Пример #3
0
        /// <summary>
        /// Clears the time line.
        /// </summary>
        public void ClearTimeLine()
        {
            TimeLineItems.Clear();
            TimeLineItemViewModel newItem = new TimeLineItemViewModel(this);

            AddTimeLineItem(newItem);

            NotifyOfPropertyChange(() => CanRemoveItem);
            NotifyOfPropertyChange(() => TimeLineItems);
        }
Пример #4
0
        /// <summary>
        /// Opens a new time line from file.
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="append"></param>
        public void OpenTimeLine(string filePath, bool append = false)
        {
            if (string.IsNullOrWhiteSpace(filePath))
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();

                openFileDialog.Filter           = "SF4 Combo|*.cmb";
                openFileDialog.RestoreDirectory = true;
                openFileDialog.ShowDialog();
                if (openFileDialog.FileName == "")
                {
                    return;
                }
                filePath = openFileDialog.FileName;
            }

            List <string> lines = File.ReadAllLines(filePath).ToList();

            if (!append)
            {
                ClearTimeLine();
            }

            if (lines.First().StartsWith("FTComboFile"))
            {
                lines.RemoveAt(0);
                foreach (String line in lines)
                {
                    TimeLineItemViewModel timeLineItemViewModel = new TimeLineItemViewModel(this);
                    InputItemViewModel    inputItem             = InputItemViewModel.Deserialize(line);

                    timeLineItemViewModel.PlaySound  = inputItem.PlaySound;
                    timeLineItemViewModel.WaitFrames = inputItem.WaitFrames;
                    timeLineItemViewModel.Direction  = inputItem.Direction;

                    timeLineItemViewModel.Light_Punch  = inputItem.Light_Punch;
                    timeLineItemViewModel.Medium_Punch = inputItem.Medium_Punch;
                    timeLineItemViewModel.Hard_Punch   = inputItem.Hard_Punch;

                    timeLineItemViewModel.Light_Kick  = inputItem.Light_Kick;
                    timeLineItemViewModel.Medium_Kick = inputItem.Medium_Kick;
                    timeLineItemViewModel.Hard_Kick   = inputItem.Hard_Kick;

                    TimeLineItems.Add(timeLineItemViewModel);
                }
            }
            else
            {
                OldDeserialize(lines);
            }

            NotifyOfPropertyChange(() => CanRemoveItem);
        }
Пример #5
0
        private void Delete(TimeLineItemViewModel timeLineItem)
        {
            // Remove from memory
            TimeLineItems.Remove(timeLineItem);

            // Remove from disk
            var pathToRemove = Path.Combine(_serializationDir,
                                            timeLineItem.Name + ".xml");

            if (File.Exists(pathToRemove))
            {
                File.Delete(pathToRemove);
            }
        }
Пример #6
0
        /// <summary>
        /// Removes the time line item at the end or after the current selection.
        /// </summary>
        public void RemoveTimeLineItem()
        {
            if (CanRemoveItem)
            {
                int index = TimeLineItems.IndexOf(SelectedTimeLineItem);
                TimeLineItemViewModel toRemove = SelectedTimeLineItem;

                // If not last item, select next, otherwise select last
                SelectedTimeLineItem = SelectedTimeLineItem != TimeLineItems.Last()
                    ? TimeLineItems[index + 1]
                    : TimeLineItems[TimeLineItems.Count() - 2];

                TimeLineItems.Remove(toRemove);

                NotifyOfPropertyChange(() => CanRemoveItem);
                NotifyOfPropertyChange(() => TimeLineItems);
            }
        }
Пример #7
0
        /// <summary>
        /// Removes the time line item at the end or after the current selection.
        /// </summary>
        public void RemoveTimeLineItem()
        {
            if (CanRemoveItem)
            {
                int index = TimeLineItems.IndexOf(SelectedTimeLineItem);

                TimeLineItems.Remove(SelectedTimeLineItem);
                if (index != TimeLineItems.Count)
                {
                    SelectedTimeLineItem = TimeLineItems[index];
                }
                else
                {
                    SelectedTimeLineItem = TimeLineItems.Last();
                }
                NotifyOfPropertyChange(() => CanRemoveItem);
                NotifyOfPropertyChange(() => TimeLineItems);
            }
        }
Пример #8
0
        public void OldDeserialize(List <string> lines)
        {
            foreach (String line in lines)
            {
                List <Input> inputsOnHold = new List <Input>();
                String[]     tokens       = line.Split('#');

                InputItemModel item = new InputItemModel();
                int            numInputs;
                Input[]        inputs;

                string inputType = tokens[0].ToString().ToUpper();
                switch (inputType)
                {
                case "WAIT":
                    // Only hold inputs needed
                    item        = new InputItemModel();
                    item.Inputs = inputsOnHold.ToArray();
                    break;

                case "PRESS":

                    // Add hold inputs to given inputs
                    numInputs = int.Parse(tokens[2]);
                    inputs    = new Input[numInputs];
                    for (int i = 0; i < numInputs; i++)
                    {
                        inputs[i] = InputItemModel.ParseInput(tokens[3 + i]);
                    }

                    item        = new InputItemModel();
                    item.Inputs = inputsOnHold.Concat(inputs.ToList()).Distinct().ToArray();
                    break;

                case "HOLD":

                    numInputs = int.Parse(tokens[2]);
                    for (int i = 0; i < numInputs; i++)
                    {
                        inputsOnHold.Add(InputItemModel.ParseInput(tokens[3 + i]));
                    }

                    item        = new InputItemModel();
                    item.Inputs = inputsOnHold.Distinct().ToArray();
                    break;

                case "RELEASE":

                    // First remove released inputs from on hold list
                    numInputs = int.Parse(tokens[2]);
                    inputs    = new Input[numInputs];
                    for (int i = 0; i < numInputs; i++)
                    {
                        inputsOnHold.RemoveAll((x) => x == InputItemModel.ParseInput(tokens[3 + i]));
                    }

                    // Add remaining holds
                    item        = new InputItemModel();
                    item.Inputs = inputsOnHold.ToArray();
                    break;

                default:
                    throw new FormatException("Failed to deserialize TimelineItem, wrong string format: " + line);
                }

                item.PlaySound = Boolean.Parse(tokens[1]);
                item.Frames    = int.Parse(tokens[2].ToString());

                //Setup TimeLineItemViewModel
                InputItemViewModel result = new InputItemViewModel();
                result.InputItem = item;
                result.Index     = -1;

                TimeLineItemViewModel timeLineItemViewModel = new TimeLineItemViewModel(this);

                timeLineItemViewModel.PlaySound  = result.PlaySound;
                timeLineItemViewModel.WaitFrames = result.WaitFrames;
                timeLineItemViewModel.Direction  = result.Direction;

                timeLineItemViewModel.Light_Punch  = result.Light_Punch;
                timeLineItemViewModel.Medium_Punch = result.Medium_Punch;
                timeLineItemViewModel.Hard_Punch   = result.Hard_Punch;

                timeLineItemViewModel.Light_Kick  = result.Light_Kick;
                timeLineItemViewModel.Medium_Kick = result.Medium_Kick;
                timeLineItemViewModel.Hard_Kick   = result.Hard_Kick;

                TimeLineItems.Add(timeLineItemViewModel);
            }
        }
Пример #9
0
 /// <summary>
 /// Clears the time line.
 /// </summary>
 public void ClearTimeLine()
 {
     TimeLineItems.Clear();
 }