public AnimationPreviewWindow(DmiEXState state, int dirIndex = 0) { InitializeComponent(); _state = state; _dirIndex = dirIndex; RenderOptions.SetBitmapScalingMode(image_viewer, BitmapScalingMode.NearestNeighbor); RenderOptions.SetBitmapScalingMode(image_background, BitmapScalingMode.NearestNeighbor); foreach (Dir d in Enum.GetValues(typeof(Dir))) { if ((int)d == (int)_state.Dirs) { break; } dir_selector.Items.Add(d); } dir_selector.SelectedIndex = 0; dir_selector.SelectionChanged += (o, e) => { if (dir_selector.SelectedItem == null) { return; } _dirIndex = (int)dir_selector.SelectedItem; UpdateImage(); }; CreateBackground(); StartAnimation(); //todo attach CreateBackground to width/height change }
private void DuplicateState(object sender, EventArgs e) { try { DmiEXState state = (DmiEXState)_state.Clone(); state.Id = state.Id + "_duplicate"; MainWindow.Current.UndoManager.RegisterUndoItem(new StateNewUndoItem(_fileEditor.DmiEx, state)); _fileEditor.DmiEx.AddState(state); } catch (Exception ex) { ErrorPopupHelper.Create(ex); } }
public StateImageArraySizeChangeUndoItem(DmiEXState state) { _state = state; _dirCount = _state.Dirs; _frames = _state.Frames; _images = new DmiEXImage[(int)_dirCount, _frames]; for (int dir = 0; dir < _images.GetLength(0); dir++) { for (int frame = 0; frame < _images.GetLength(1); frame++) { _images[dir, frame] = (DmiEXImage)_state.GetImage(dir, frame).Clone(); } } }
public StateValueEditor(DmiEXState state) { State = state; InitializeComponent(); //stateID id_editor.Text = state.Id; id_editor.KeyDown += ChangeID; id_editor.LostFocus += IDChanged; state.IdChanged += IDChanged; //dir count foreach (DirCount dir in Enum.GetValues(typeof(DirCount))) { dir_editor.Items.Add(dir); } dir_editor.SelectedItem = state.Dirs; dir_editor.SelectionChanged += ChangeDirs; state.DirCountChanged += DirsChanged; //frame count frame_editor.Value = state.Frames; frame_editor.KeyDown += ChangeFrames; frame_editor.LostFocus += FramesChanged; state.FrameCountChanged += FramesChanged; //loop loop_editor.Value = state.Loop; loop_editor.KeyDown += ChangeLoop; loop_editor.LostFocus += LoopChanged; state.LoopCountChanged += LoopChanged; loop_infinite_indicator.Text = state.Loop == 0 ? "(Infinite)" : ""; //rewind rewind_editor.IsChecked = state.Rewind; rewind_editor.Click += ChangeRewind; state.RewindChanged += RewindChanged; //movement movement_editor.IsChecked = state.Movement; movement_editor.Click += ChangeMovement; state.MovementChanged += MovementChanged; }
private void NewState(object sender, KeyEventArgs e) { if (e.Key != Key.Enter) { return; } try { var id = new_state_editor.Text; DmiEXState state = (DmiEXState)_dmiEx.AddNewState(id); MainWindow.Current.UndoManager.RegisterUndoItem(new StateNewUndoItem(_dmiEx, state)); } catch (ArgumentException ex) { ErrorPopupHelper.Create(ex); } }
public StateButton(FileEditor fileEditor, int stateIndex, DmiEXState state) : base(BitmapUtils.Bitmap2BitmapImage(state.GetImage(0, 0).GetBitmap()), $"\"{state.Id}\"") { StateIndex = stateIndex; _state = state; _fileEditor = fileEditor; //register click event Click += Clicked; state.IdChanged += (sender, args) => { Label.Text = $"\"{state.Id}\""; }; state.GetImage(0, 0).ImageChanged += ImageChanged; Button close_button = new Button { Content = "Delete" }; close_button.Click += DeleteState; Button duplicate_button = new Button { Content = "Duplicate" }; duplicate_button.Click += DuplicateState; StackPanel button_panel = new StackPanel { Orientation = Orientation.Horizontal, Children = { duplicate_button, close_button } }; StackPanel sp = (StackPanel)Content; sp.Children.Add(button_panel); }
private void OnButtonClicked(object sender, RoutedEventArgs e) { if (dmi_selector.SelectedItem == null) { return; } try { ListItem listItem = (ListItem)dmi_selector.SelectedItem; DmiEXState state = _layer.ToDmiExState(listItem.DmiEx, id_editor.Text); MainWindow.Current.UndoManager.RegisterUndoItem(new StateNewUndoItem(listItem.DmiEx, state)); listItem.DmiEx.AddState(state); Close(); } catch (Exception ex) { Console.WriteLine(ex); } }
private void SelectOrOpenState(int stateIndex) { foreach (StateEditorTabItem item in stateTabControl.Items) { if (item.StateEditor.StateIndex == stateIndex) { item.IsSelected = true; UpdateStateUi(); return; } } DmiEXState state = (DmiEXState)DmiEx.States[stateIndex]; StateEditor stateEditor = new StateEditor(this, stateIndex, state); StateEditorTabItem tItem = new StateEditorTabItem(stateEditor); stateTabControl.Items.Add(tItem); StackPanel sp = new StackPanel(); TextBlock txt = new TextBlock { Text = $"\"{state.Id}\"", VerticalAlignment = VerticalAlignment.Center }; state.IdChanged += (o, e) => { txt.Text = $"\"{state.Id}\""; }; sp.Orientation = Orientation.Horizontal; sp.Children.Add(txt); TabCloseButton cBtn = new TabCloseButton(tItem); cBtn.Click += CloseState; sp.Children.Add(cBtn); tItem.Header = sp; tItem.IsSelected = true; UpdateStateUi(); }
public StateLoopChangeUndoItem(DmiEXState state) { _state = state; _previousLoop = state.Loop; }
public StateNewUndoItem(DmiEX dmiEx, DmiEXState state) { _dmiEx = dmiEx; _state = state; }
public StateRewindChangeUndoItem(DmiEXState state) { _state = state; _previousRewind = state.Rewind; }
public StateIdChangeUndoItem(DmiEXState state) { _state = state; _previousId = state.Id; }
public StateMovementChangeUndoItem(DmiEXState state) { _state = state; _previousMovement = state.Movement; }
public StateHotspotAddUndoItem(DmiEXState state, Hotspot hotspot) { _state = state; _hotspot = hotspot; }
public StateDeleteUndoItem(DmiEX dmiEx, DmiEXState state) { _dmiEx = dmiEx; _index = dmiEx.GetStateIndex(state); _state = state; }
public StateDelayChangeUndoItem(DmiEXState state, int frameIndex) { _state = state; _frameIndex = frameIndex; _previousDelay = _state.Delays[frameIndex]; }