private void OnBeginDragging(object sender, MouseButtonEventArgs e)
        {
            ListBox container = null;

            if (AllFunctions.SelectedItems.Count > 0)
            {
                container = AllFunctions;
            }
            if (FavoriteFunctions.SelectedItems.Count > 0)
            {
                container = FavoriteFunctions;
            }
            if (container == null)
            {
                return;
            }

            IList selecteds = container.SelectedItems;

            BatchFunction[] arr = new BatchFunction[selecteds.Count];
            selecteds.CopyTo(arr, 0);
            DataObject data = new DataObject(typeof(BatchFunction[]), arr);

            DragDrop.DoDragDrop(container, data, DragDropEffects.Link);
        }
        private void OnEditing(object sender, MouseButtonEventArgs e)
        {
            ListBox       control  = e.Source as ListBox;
            BatchFunction selected = control.SelectedItem as BatchFunction;

            ViewModel.EditFunction(Application.Current.MainWindow, selected);
        }
        /*
         * Other events
         */
        private void OnButtonChangeFavorite(object sender, System.Windows.RoutedEventArgs e)
        {
            Button        button = sender as Button;
            BatchFunction item   = button.DataContext as BatchFunction;

            item.IsFavorite = !item.IsFavorite;
        }
        public void EditFunction(Window owner, BatchFunction function)
        {
            Editor window = new Editor()
            {
                Owner = owner
            };

            window.SetDisplayFunction(function);
            window.ShowDialog();
            EditorViewModel context = window.DataContext as EditorViewModel;

            if (context.GeneratedFunction != null)
            {
                if (function.GetType() != context.GeneratedFunction.GetType())
                {
                    Functions.Add(context.GeneratedFunction);
                }
                else
                {
                    int i = Functions.IndexOf(function);
                    Functions.RemoveAt(i);
                    if (i >= Functions.Count)
                    {
                        Functions.Add(context.GeneratedFunction);
                    }
                    else
                    {
                        Functions.Insert(i, context.GeneratedFunction);
                    }
                }
            }
        }
示例#5
0
 public Control CreateControl(BatchFunction function)
 {
     if (function is FunctionReplace replace)
     {
         return(new ReplaceControl(replace.Clone() as FunctionReplace));
     }
     else if (function is FunctionMove move)
     {
         return(new MoveControl(move.Clone() as FunctionMove));
     }
     else if (function is FunctionChangeFormat format)
     {
         return(new ChangeFormatControl(format.Clone() as FunctionChangeFormat));
     }
     return(null);
 }
        public void CreateFunction(Window owner, BatchFunction function)
        {
            Editor window = new Editor()
            {
                Owner = owner
            };

            window.SetDisplayFunction(function);
            window.ShowDialog();
            EditorViewModel context = window.DataContext as EditorViewModel;

            if (context.GeneratedFunction != null)
            {
                Functions.Add(context.GeneratedFunction);
            }
        }
示例#7
0
 /*
  * Public Methods
  */
 public void SetDisplayFunction(BatchFunction function)
 {
     FunctionDisplayer.Child = ViewModel.CreateControl(function);
 }