public void BtnRemoveAnimation_OnClick(object sender, RoutedEventArgs e) { AnimationViewModel animationViewModel = (AnimationViewModel)((Button)sender).DataContext; Button dataContext = (Button)sender; ItemsControl itemsControl = VisualTreeHelpers.FindAncestor <ItemsControl>(dataContext); ((StageViewModel)itemsControl.DataContext).Animations.Remove(animationViewModel); }
public ActionResult AnimationDummy(int id) { var formType = algorithmRepository.retrieveFormType(id); AnimationViewModel vm = new AnimationViewModel(); vm.algoDetails = algorithmRepository.FindThis(id).SingleOrDefault(); return(View(vm)); }
private void LoadWif(string path) { var animationVM = new AnimationViewModel(); WifLoader.LoadInSeparateThread(path, animationVM.CreateReceiver()); var viewer = new AnimationWindow(animationVM); viewer.Show(); }
//CONSTRUCTOR PARA LA EDICION public AddAnimationPopUp(AnimationViewModel animationVm, List <AnimationConfigurationBase> dllConfigurations) //Mas problemas DLL...aca le puedellegar cualquier tipo de animationviewmodel, con mas propiedades a tocar...ver { this.Variables = animationVm.AnimationConfig.Variables; this.AnimationName = animationVm.AnimationName; this.CanExecute = animationVm.AnimationConfig.CanExecute; this.InitializeComponent(); this.DllConfigurations = dllConfigurations; this.FillCombos(); this.animationTypeCombo.SelectedIndex = ((List <string>)animationTypeCombo.ItemsSource).FindIndex(i => i.ToString() == animationVm.AnimationConfig.AnimationType); }
public void LoadAnimation(SkinElement element) { AnimationViewModel vm = DataContext as AnimationViewModel; vm.Animation.Clear(); vm.Animation.Add(element.GetAnimatedElements(), false); vm.CurrentFrame = 0; SkinningEntry details = element.ElementDetails as SkinningEntry; vm.FrameOrder = details.FrameOrder; }
private void StartStopAnimation_Click(object sender, RoutedEventArgs e) { AnimationViewModel vm = DataContext as AnimationViewModel; if (!vm.IsAnimationPlaying) { vm.StartAnimation(); } else { vm.StopAnimation(); } }
public void LoadAnimation(SkinElement element) { Logger.Instance.WriteLog("Loading animation of element \"{0}\"...", element.Name); AnimationViewModel vm = DataContext as AnimationViewModel; vm.Animation.Clear(); vm.Animation.Add(element.GetAnimatedElements(), false); vm.CurrentFrame = 0; SkinningEntry details = element.ElementDetails as SkinningEntry; vm.FrameOrder = details.FrameOrder; }
private void StartStopAnimation_Click(object sender, RoutedEventArgs e) { AnimationViewModel vm = DataContext as AnimationViewModel; if (!vm.IsAnimationPlaying) { vm.StartAnimation(); Logger.Instance.WriteLog("Animation started!"); } else { vm.StopAnimation(); Logger.Instance.WriteLog("Animation stopped!"); } }
public AnimationWindow(AnimationViewModel vm) { InitializeComponent(); this.DataContext = vm; vm.MaximumFrameIndex.ValueChanged += () => { if (vm.MaximumFrameIndex.Value == 0) { resultTab.Visibility = Visibility.Visible; tabControl.SelectedIndex = 0; } }; }
private void OnRenderScript() { if (HasFilename()) { Save(); } var animationVM = new AnimationViewModel(); var raytracer = new Renderer(); var receiver = animationVM.CreateReceiver(); raytracer.Render(this.Source.Text, receiver); var viewer = new AnimationWindow(animationVM); viewer.Show(); }
private void AddAnimationButton_Click(object sender, RoutedEventArgs e) { if (ViewModel == null) { throw new NullReferenceException("The ViewModel for this is invalid - set the DataContext on this view before showing it."); } string whyIsntValid = null; if (!string.IsNullOrEmpty(whyIsntValid)) { MessageBox.Show(whyIsntValid); } else { TextInputWindow tiw = new TextInputWindow(); tiw.Message = "Enter new animation name:"; var dialogResult = tiw.ShowDialog(); if (dialogResult == System.Windows.Forms.DialogResult.OK) { string whyInvalid; if (!NameValidator.IsAnimationNameValid(tiw.Result, this.ViewModel.Animations, out whyInvalid)) { MessageBox.Show(whyInvalid); } else { var newAnimation = new AnimationViewModel() { Name = tiw.Result }; this.ViewModel.Animations.Add(newAnimation); this.ViewModel.SelectedAnimation = newAnimation; } } } }
public void BtnEditAnimation_OnClick(object sender, RoutedEventArgs e) { AnimationViewModel animationViewModel = (AnimationViewModel)((Button)sender).DataContext; Button dataContext = (Button)sender; ItemsControl itemsControl = VisualTreeHelpers.FindAncestor <ItemsControl>(dataContext); var dllConfigurationsClone = new List <AnimationConfigurationBase>(); foreach (var config in ((StageViewModel)itemsControl.DataContext).DllConfigurations) { var newDllConfig = Activator.CreateInstance(config.GetType(), config.Variables) as AnimationConfigurationBase; dllConfigurationsClone.Add(newDllConfig); } try { var addAnimationPopUp = new AddAnimationPopUp(animationViewModel, dllConfigurationsClone); addAnimationPopUp.ShowDialog(); switch (addAnimationPopUp.Result) { case UI.SharedWPF.DialogResult.Accept: { var newAnimationFromDlls = ((StageViewModel)itemsControl.DataContext).DllAnimations.Where(x => x.ConfigurationType == addAnimationPopUp.ResultConfig.GetType().Name).First(); var newAnimation = Activator.CreateInstance(newAnimationFromDlls.GetType()) as AnimationViewModel; newAnimation.InitializeAnimation(addAnimationPopUp.ResultConfig); newAnimation.BindSimulationVariableValues(); newAnimation.X = animationViewModel.X; //NO funciona newAnimation.Y = animationViewModel.Y; //NO funciona ((StageViewModel)itemsControl.DataContext).Animations.Remove(animationViewModel); //borro y creo nueva ((StageViewModel)itemsControl.DataContext).Animations.Add(newAnimation); } break; } } catch (Exception ex) { var viewException = new AlertPopUp("Se produjo un error al editar una animacion. Para ver detalles, despliegue el control correspondiente."); viewException.ShowDialog(); } }
public ActionResult KnapsackAnimation(int id) { AnimationViewModel vm = new AnimationViewModel(); KnapsackAlgorithm knapsack = new KnapsackAlgorithm(); KnapsackItems items = new KnapsackItems(); int noOfInput = Int32.Parse(Request.Form["noOfKnapsackInput"]); List <KnapsackItems> itemWeightList = new List <KnapsackItems>(); for (int i = 1; i <= noOfInput; i++) { int val = Int32.Parse(Request.Form["itemWeight_" + i]); int benefit = Int32.Parse(Request.Form["itemBenefit_" + i]); itemWeightList.Add(new KnapsackItems { Weight = val, Benefit = benefit }); } knapsack.Capacity = Int32.Parse(Request.Form["capacityValue"]); knapsack.Items = itemWeightList; vm.knapsackAnimationData = knapsack; vm.algoNavBar = algorithmRepository.FindSameParadigmTypeAlgorithm(id).ToList(); vm.algoDetails = algorithmRepository.FindThis(id).SingleOrDefault(); vm.noOfIndex = noOfInput; /* * if (id == 1) * { * return PartialView("_FracKnapAnimationPartial", vm); * } * else * { * return PartialView("_KnapsackAnimationPartial", vm); * } */ return(View(vm)); }
public ActionResult SortAnimation(int id) { AnimationViewModel vm = new AnimationViewModel(); SortAlgorithm sort = new SortAlgorithm(); int noOfInput = Int32.Parse(Request.Form["noOfSortInput"]); List <int> indexValueList = new List <int>(); for (int i = 1; i <= noOfInput; i++) { int val = Int32.Parse(Request.Form["indexValue_" + i]); indexValueList.Add(val); } sort.IndexValues = indexValueList; vm.sortAnimationData = sort; vm.algoNavBar = algorithmRepository.FindSameParadigmTypeAlgorithm(id).ToList(); vm.algoDetails = algorithmRepository.FindThis(id).SingleOrDefault(); vm.noOfIndex = noOfInput; return(View(vm)); }
public StartPage() { InitializeComponent(); BindingContext = new AnimationViewModel(); }
public void BtnChangeOrientation_OnClick(object sender, RoutedEventArgs e) { AnimationViewModel animationViewModel = (AnimationViewModel)((Button)sender).DataContext; animationViewModel.AnimationOrientation = animationViewModel.AnimationOrientation == "Vertical" ? "Horizontal" : "Vertical"; }
public MainViewModel(UIElement element, Action relogin, Action refreshRoomList) { this._element = element; this._reLogin = relogin; this._refreshRoomList = refreshRoomList; Notification.Instance.NotificationLanguage += (obj, value, args) => { _element.Dispatcher.BeginInvoke(new Action(() => { SetCurrentName(); })); }; // 添加处理事件 this._element.AddHandler(PublicEvents.PopupEvent, new RoutedEventHandler(HandlePopop), true); _msg = new MsgViewModel(SetMsgCommand); _key = new KeyViewModel(SetKeyCommand); _animation = new AnimationViewModel(); // 设置语言 SetCurrentName(); // 定时检测 LoadingCheck(); // 更新检测 SetUpdate(); // 更新检测 SetUpdate(); // 注册睡眠唤醒(免得session失效) SystemEvents.PowerModeChanged -= this.SystemEvents_PowerModeChanged; SystemEvents.PowerModeChanged += this.SystemEvents_PowerModeChanged; (_element as Window).Loaded += (z, y) => { if (!_isLoaded) { _isLoaded = true; // 扫码,刷卡 // 扫条码处理 hookBarcode = new KeyboardHook(); var availbleScanners = hookBarcode.GetKeyboardDevices(); string first = availbleScanners.Where(x => String.Format("{0:X}", x.GetHashCode()) == Resources.GetRes().BarcodeReader).FirstOrDefault(); if (!string.IsNullOrWhiteSpace(first)) { hookBarcode.SetDeviceFilter(first); hookBarcode.KeyPressed += OnBarcodeKey; hookBarcode.AddHook(_element as Window); } hookCard = new KeyboardHook(); first = availbleScanners.Where(x => String.Format("{0:X}", x.GetHashCode()) == Resources.GetRes().CardReader).FirstOrDefault(); if (!string.IsNullOrWhiteSpace(first)) { hookCard.SetDeviceFilter(first); hookCard.KeyPressed += OnCardKey; hookCard.AddHook(_element as Window); } } }; }
// 實際使用 public AnimationViewUserControl(AnimationObject animationObject) { this.DataContext = AnimationViewModel = new AnimationViewModel(animationObject); InitializeComponent(); AnimationViewModel.GetAnimationInfoAndVodListCompleted += GetAnimationInfoAndVodListCompleted; }
public void HandleRename(AnimationViewModel animationViewModel, string oldAnimationName, IEnumerable <AnimationViewModel> animations, ElementSave element) { foreach (var keyframe in animations.SelectMany(item => item.Keyframes)) { if (keyframe.AnimationName == oldAnimationName) { keyframe.AnimationName = animationViewModel.Name; } } // Unfortunately we have to jump out of the view model and // look at any object where this is an instance, and see if // its animation is referenced. var elementsReferencingThis = ObjectFinder.Self.GetElementsReferencing(element); foreach (var elementReferencing in elementsReferencingThis) { var fileName = AnimationCollectionViewModelManager.Self.GetAbsoluteAnimationFileNameFor(elementReferencing); bool didChange = false; if (FileManager.FileExists(fileName)) { try { var animationSave = FileManager.XmlDeserialize <ElementAnimationsSave>(fileName); var potentialAnimations = animationSave.Animations .SelectMany(item => item.Animations) .Where(item => !string.IsNullOrEmpty(item.SourceObject) && item.RootName == oldAnimationName); foreach (var animationReference in potentialAnimations) { var instance = elementReferencing.GetInstance(animationReference.SourceObject); if (instance != null) { // Is the instance this? var instanceElement = ObjectFinder.Self.GetElementSave(instance); if (instanceElement == element) { didChange = true; animationReference.Name = animationReference.SourceObject + "." + animationViewModel.Name; } } } if (didChange) { FileManager.XmlSerialize(animationSave, fileName); } } catch (Exception e) { OutputManager.Self.AddError(e.ToString()); } } } }
private void AddAnimationButton_Click(object sender, RoutedEventArgs e) { if (ViewModel == null) { throw new NullReferenceException("The ViewModel for this is invalid - set the DataContext on this view before showing it."); } string whyIsntValid = null; if(!string.IsNullOrEmpty(whyIsntValid)) { MessageBox.Show(whyIsntValid); } else { TextInputWindow tiw = new TextInputWindow(); tiw.Message = "Enter new animation name:"; var dialogResult = tiw.ShowDialog(); if(dialogResult == System.Windows.Forms.DialogResult.OK) { string whyInvalid; if (!NameValidator.IsAnimationNameValid(tiw.Result, out whyInvalid)) { MessageBox.Show(whyInvalid); } else { var newAnimation = new AnimationViewModel() { Name = tiw.Result }; this.ViewModel.Animations.Add(newAnimation); this.ViewModel.SelectedAnimation = newAnimation; } } } }