예제 #1
0
        private bool parseEntryAndProfile(ParameterDic pm, string key, string profileKey,
                                          out string[] entryPath, out IProfile profile)
        {
            object value = pm.GetValue(key);

            if (value is string)
            {
                value = new string[] { value as string }
            }
            ;
            if (value is string[])
            {
                entryPath = value as string[];
                profile   = pm.GetValue <IProfile>(profileKey);
                return(true);
            }

            if (value is IEntryModel)
            {
                value = new IEntryModel[] { value as IEntryModel }
            }
            ;

            if (value is IEntryModel[])
            {
                IEntryModel[] ems = value as IEntryModel[];
                entryPath = ems.Select(em => em.FullPath).ToArray();
                profile   = ems.First().Profile;
                return(true);
            }

            entryPath = null;
            profile   = null;
            return(false);
        }
예제 #2
0
        public override IScriptCommand Execute(ParameterDic pm)
        {
            IProfile[] rootProfiles = pm.GetValue <IProfile[]>(ProfilesKey);
            if (rootProfiles == null || rootProfiles.Length == 0)
            {
                return(ResultCommand.Error(new ArgumentException(ProfilesKey)));
            }

            if (rootProfiles.Length == 1)
            {
                pm.SetValue(DestinationKey, rootProfiles[0]);
                return(NextCommand);
            }
            else
            {
                IWindowManager wm = pm.GetValue <IWindowManager>(WindowManagerKey) ?? new WindowManager();
                logger.Debug("Showing");
                SelectProfileViewModel spvm = new SelectProfileViewModel(rootProfiles);
                if (wm.ShowDialog(spvm).Value)
                {
                    logger.Info(String.Format("Selected {0}", spvm.SelectedRootProfile));
                    pm.SetValue(DestinationKey, spvm.SelectedRootProfile);
                    return(NextCommand);
                }
                else
                {
                    logger.Debug("Cancelled");
                    return(CancelCommand);
                }
            }
        }
예제 #3
0
        private bool dragStart(ParameterDic pm, IUIInput input, string mode)
        {
            ISupportDrag isd = pm.GetValue <ISupportDrag>(DragSourceKey);

            if (pm.GetValue <string>(DragDropModeKey) == null && isd != null)
            {
                var         draggables = isd.GetDraggables();
                IDataObject dataObj    = isd is ISupportShellDrag ?
                                         (isd as ISupportShellDrag).GetDataObject(draggables) : null;
                DragDropEffectsEx effect = isd.QueryDrag(draggables);

                pm.SetValue(DragDropModeKey, mode);
                pm.SetValue(DragDropDeviceKey, input.InputType);
                pm.SetValue(DragDropDraggingItemsKey, draggables);
                pm.SetValue(DragDropEffectsKey, effect);
                pm.SetValue(DragDropDragSourceKey, isd);
                pm.SetValue(ParameterDic.CombineVariable(DragDropDragSourceKey, ".IsDraggingFrom", false), true);
                pm.SetValue(DragDropStartPositionKey, pm.GetValue <Point>(CurrentPositionAdjustedKey));
                pm.SetValue(InputKey, new DragInput(input, dataObj, DragDropEffectsEx.Copy, (eff) => { }));

                return(true);
            }

            return(false);
        }
예제 #4
0
        public override async Task <IScriptCommand> ExecuteAsync(ParameterDic pm)
        {
            var evm = pm.GetValue <IExplorerViewModel>(ExplorerKey);
            var dm  = DirectoryEntryKey == null ? null :
                      (await pm.GetValueAsEntryModelArrayAsync(DirectoryEntryKey)).FirstOrDefault();

            if (evm == null)
            {
                var events = pm.GetValue <IEventAggregator>(EventsKey);
                if (events != null)
                {
                    events.PublishOnUIThread(new DirectoryChangedEvent(this, dm, null));
                }
                else
                {
                    return(ResultCommand.Error(new ArgumentNullException(ExplorerKey)));
                }
            }
            else
            {
                await evm.GoAsync(dm);
            }

            logger.Info("Path = " + dm.FullPath);
            return(NextCommand);
        }
        public override IScriptCommand Execute(ParameterDic pm)
        {
            IExplorerViewModel evm = pm.GetValue <IExplorerViewModel>(ExplorerKey);

            if (evm == null)
            {
                return(ResultCommand.Error(new KeyNotFoundException(ExplorerKey)));
            }

            ParameterDic startupParameters = new ParameterDic();

            foreach (var key in VariableKeys.Split(','))
            {
                var val = pm.GetValue(key);
                startupParameters.SetValue(key, val);
            }

            addStartupParameters(evm.Commands, startupParameters);
            addStartupParameters(evm.FileList.Commands, startupParameters);
            addStartupParameters(evm.DirectoryTree.Commands, startupParameters);
            addStartupParameters(evm.Navigation.Commands, startupParameters);
            addStartupParameters(evm.Breadcrumb.Commands, startupParameters);

            return(NextCommand);
        }
예제 #6
0
        public override IScriptCommand Execute(ParameterDic pm)
        {
            object source = pm.GetValue <object>(SourceVariableKey);

            if (source == null)
            {
                logger.Error("Source not found.");
            }

            if (ValueConverterKey != null)
            {
                object valueConverter = pm.GetValue <object>(ValueConverterKey);

                if (valueConverter is Func <object, object> ) //GetProperty, ExecuteMethod, GetArrayItem
                {
                    Func <object, object> valueConverterFunc = valueConverter as Func <object, object>;
                    object value = valueConverterFunc(source);
                    pm.SetValue(DestinationVariableKey, value, SkipIfExists);
                }
                else
                if (valueConverter is Action <object, object> )   //SetProperty
                {
                    Action <object, object> valueConverterAct = valueConverter as Action <object, object>;
                    object value = pm.GetValue <object>(DestinationVariableKey);
                    valueConverterAct(source, value);
                }
            }

            return(NextCommand);
        }
예제 #7
0
        public override async Task <IScriptCommand> ExecuteAsync(ParameterDic pm)
        {
            IWindowManager   wm     = pm.GetValue <IWindowManager>(WindowManagerKey) ?? new WindowManager();
            IEventAggregator events = pm.GetValue <IEventAggregator>(EventAggregatorKey) ?? new EventAggregator();


            TabbedExplorerViewModel tevm = new TabbedExplorerViewModel(wm, events);

            pm.SetValue(DestinationKey, tevm);
            tevm.Initializer = new ScriptCommandInitializer()
            {
                StartupParameters = pm,
                WindowManager     = wm,
                Events            = events,
                OnModelCreated    = ScriptCommands.Run(OnModelCreatedKey),
                OnViewAttached    = ScriptCommands.Run(OnViewAttachedKey)
            };

            if (pm.HasValue(OnTabExplorerCreatedKey))
            {
                await tevm.Commands.ExecuteAsync(pm.GetValue <IScriptCommand>(OnTabExplorerCreatedKey));
            }
            tevm.OnTabExplorerAttachedKey = OnTabExplorerAttachedKey;

            object enableTabsWhenOneTab = pm.GetValue("{EnableTabsWhenOneTab}");

            tevm.EnableTabsWhenOneTab = !(enableTabsWhenOneTab is bool) || (bool)enableTabsWhenOneTab;
            logger.Info(String.Format("Showing {0}", tevm));
            wm.ShowWindow(tevm);


            return(NextCommand);
        }
예제 #8
0
        protected override IScriptCommand executeInner(ParameterDic pm, UIElement sender, RoutedEventArgs evnt, IUIInput input, IList <IUIInputProcessor> inpProcs)
        {
            DragEventArgs            devnt          = evnt as DragEventArgs;
            ISupportDrop             dropTarget     = pm.GetValue <ISupportDrop>(DropTargetKey);
            IEnumerable <IDraggable> draggables     = pm.GetValue <IEnumerable <IDraggable> >(DraggablesKey);
            DragDropEffectsEx        allowedEffects = pm.HasValue(AllowedEffectsKey) ? pm.GetValue <DragDropEffectsEx>(AllowedEffectsKey)
                : devnt != null ? (DragDropEffectsEx)devnt.AllowedEffects : DragDropEffectsEx.All;

            if (dropTarget != null && draggables != null)
            {
                QueryDropEffects queryDropEffect = QueryDropEffects.None;
                if (devnt != null)
                {
                    queryDropEffect = dropTarget.QueryDrop(draggables, allowedEffects);
                    devnt.Effects   = (DragDropEffects)queryDropEffect.SupportedEffects;
                }
                else
                {
                    queryDropEffect = dropTarget.QueryDrop(draggables, allowedEffects);
                }

                pm.SetValue(DestinationKey, queryDropEffect, SkipIfExists);
            }
            return(NextCommand);
        }
        public override IScriptCommand Execute(ParameterDic pm)
        {
            if (SkipIfExists && pm.HasValue(DestinationKey))
            {
                return(NextCommand);
            }

            IEnumerable <IDraggable> value = new List <IDraggable>();

            ISupportShellDrop issd    = pm.GetValue <ISupportShellDrop>(ISupportDropKey);
            IDataObject       dataObj = pm.GetValue <IDataObject>(DataObjectKey);

            if (dataObj.GetDataPresent(typeof(ISupportDrag)))
            {
                ISupportDrag isd = (ISupportDrag)dataObj.GetData(typeof(ISupportDrag));
                value = isd.GetDraggables();
            }
            else
            if (issd != null && dataObj != null)
            {
                value = (issd.QueryDropDraggables(dataObj) ?? new List <IDraggable>());
            }

            pm.SetValue(DestinationKey, value, SkipIfExists);
            return(NextCommand);
        }
예제 #10
0
        public override async Task <IScriptCommand> ExecuteAsync(ParameterDic pm)
        {
            var    pdv = pm.GetValue <IProgress <TransferProgress> >("{Progress}", NullTransferProgress.Instance);
            string url = pm.GetValue <string>(UrlKey);

            if (url == null)
            {
                return(ResultCommand.Error(new ArgumentException("Unspecified Url.")));
            }

            try
            {
                using (var httpClient =
                           pm.ContainsKey(HttpClientKey) && pm[HttpClientKey] is Func <HttpClient>?((Func <HttpClient>)pm[HttpClientKey])() :
                               new HttpClient())
                {
                    var response = await httpClient.GetAsync(url, HttpCompletionOption.ResponseHeadersRead, pm.CancellationToken);

                    if (!response.IsSuccessStatusCode)
                    {
                        throw new WebException(String.Format("{0} when downloading {1}", response.StatusCode, url));
                    }

                    MemoryStream destStream = new MemoryStream();
                    logger.Info(String.Format("{0} = Stream of {1}", DestinationKey, url));
                    using (Stream srcStream = await response.Content.ReadAsStreamAsync())
                    {
                        pdv.Report(TransferProgress.From(url));
                        byte[] buffer         = new byte[1024];
                        ulong  totalBytesRead = 0;
                        ulong  totalBytes     = 0;
                        try { totalBytes = (ulong)srcStream.Length; }
                        catch (NotSupportedException) { }

                        int byteRead = await srcStream.ReadAsync(buffer, 0, buffer.Length, pm.CancellationToken);

                        while (byteRead > 0)
                        {
                            await destStream.WriteAsync(buffer, 0, byteRead, pm.CancellationToken);

                            totalBytesRead = totalBytesRead + (uint)byteRead;
                            short percentCompleted = (short)((float)totalBytesRead / (float)totalBytes * 100.0f);
                            pdv.Report(TransferProgress.UpdateCurrentProgress(percentCompleted));

                            byteRead = await srcStream.ReadAsync(buffer, 0, buffer.Length, pm.CancellationToken);
                        }
                        await destStream.FlushAsync();
                    }

                    pm.SetValue(DestinationKey, destStream.ToByteArray());
                    return(NextCommand);
                }
            }
            catch (Exception ex)
            {
                return(ResultCommand.Error(ex));
            }
        }
예제 #11
0
        public override async Task <IScriptCommand> ExecuteAsync(ParameterDic pm)
        {
            IWindowManager   wm     = pm.GetValue <IWindowManager>(WindowManagerKey) ?? new WindowManager();
            IEventAggregator events = pm.GetValue <IEventAggregator>(EventAggregatorKey) ?? new EventAggregator();

            IExplorerInitializer initializer = new ScriptCommandInitializer()
            {
                StartupParameters = pm,
                WindowManager     = wm,
                Events            = events,
                OnModelCreated    = ScriptCommands.Run(OnModelCreatedKey),
                OnViewAttached    = ScriptCommands.Run(OnViewAttachedKey)
            };

            ExplorerViewModel evm = null;

            switch (ExplorerMode)
            {
            case Script.ExplorerMode.Normal:
                evm = new ExplorerViewModel(wm, events)
                {
                    Initializer = initializer
                };
                break;

            case Script.ExplorerMode.FileOpen:
                evm = new FilePickerViewModel(wm, events)
                {
                    Initializer = initializer,
                    PickerMode  = FilePickerMode.Open
                };
                break;

            case Script.ExplorerMode.FileSave:
                evm = new FilePickerViewModel(wm, events)
                {
                    Initializer = initializer,
                    PickerMode  = FilePickerMode.Save
                };
                break;

            case Script.ExplorerMode.DirectoryOpen:
                evm = new DirectoryPickerViewModel(wm, events)
                {
                    Initializer = initializer
                };
                break;

            default:
                return(ResultCommand.Error(new NotSupportedException(ExplorerMode.ToString())));
            }

            logger.Info(String.Format("Creating {0}", evm));
            pm.SetValue(DestinationKey, evm, false);

            return(NextCommand);
        }
예제 #12
0
        public override IScriptCommand Execute(ParameterDic pm)
        {
            Point pos       = pm.GetValue <Point>(PositionKey);
            Point offsetpos = pm.GetValue <Point>(OffsetKey);

            pm.SetValue(DestinationKey, new Point(pos.X + offsetpos.X, pos.Y + offsetpos.Y));

            return(NextCommand);
        }
예제 #13
0
        private bool compare(ParameterDic pm)
        {
            try
            {
                object value1 = pm.GetValue <Object>(Variable1Key);
                object value2 = pm.GetValue <Object>(Variable2Key);

                if (value1 != null && value2 != null)
                {
                    var        left  = Expression.Constant(value1);
                    var        right = Expression.Constant(value2);
                    Expression expression;

                    switch (Operator)
                    {
                    case ComparsionOperator.Equals: expression = Expression.Equal(left, right); break;

                    case ComparsionOperator.GreaterThan: expression = Expression.GreaterThan(left, right); break;

                    case ComparsionOperator.GreaterThanOrEqual: expression = Expression.GreaterThanOrEqual(left, right); break;

                    case ComparsionOperator.LessThan: expression = Expression.LessThan(left, right); break;

                    case ComparsionOperator.LessThanOrEqual: expression = Expression.LessThanOrEqual(left, right); break;

                    case ComparsionOperator.StartWith:
                    case ComparsionOperator.StartWithIgnoreCase:
                        return(value1.ToString().StartsWith(value2.ToString(),
                                                            Operator == ComparsionOperator.StartWith ? StringComparison.CurrentCulture :
                                                            StringComparison.CurrentCultureIgnoreCase));

                    case ComparsionOperator.EndsWith:
                    case ComparsionOperator.EndsWithIgnoreCase:
                        return(value1.ToString().EndsWith(value2.ToString(),
                                                          Operator == ComparsionOperator.EndsWith ? StringComparison.CurrentCulture :
                                                          StringComparison.CurrentCultureIgnoreCase));

                    default:
                        throw new NotSupportedException(Operator.ToString());
                    }

                    return(Expression.Lambda <Func <bool> >(expression).Compile().Invoke());
                }
                else
                {
                    return(Operator == ComparsionOperator.Equals && value1 == null && value2 == null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #14
0
        public override async Task <IScriptCommand> ExecuteAsync(ParameterDic pm)
        {
            IWindowManager     wm  = pm.GetValue <IWindowManager>(WindowManagerKey) ?? new WindowManager();
            IExplorerViewModel evm = pm.GetValue <IExplorerViewModel>(ExplorerKey);

            if (evm == null)
            {
                return(ResultCommand.Error(new KeyNotFoundException(ExplorerKey)));
            }
            logger.Info(String.Format("Showing {0}", evm));

            if (evm is DirectoryPickerViewModel)
            {
                DirectoryPickerViewModel dpvm = evm as DirectoryPickerViewModel;
                bool result = wm.ShowDialog(dpvm).Value;
                pm.SetValue(DialogResultKey, result);

                if (result)
                {
                    pm.SetValue(SelectionPathsKey, dpvm.SelectedDirectory.FullPath);
                    pm.SetValue(SelectionEntriesKey, dpvm.SelectedDirectory);
                }
            }
            else if (evm is FilePickerViewModel)
            {
                FilePickerViewModel fpvm = evm as FilePickerViewModel;
                bool result = wm.ShowDialog(fpvm).Value;
                pm.SetValue(DialogResultKey, result);
                if (result)
                {
                    switch (fpvm.PickerMode)
                    {
                    case FilePickerMode.Save:
                        pm.SetValue(SelectionPathsKey, fpvm.FileName);
                        break;

                    case FilePickerMode.Open:
                        pm.SetValue(SelectionPathsKey, fpvm.SelectedFiles.Select(m => m.FullPath).ToArray());
                        pm.SetValue(SelectionEntriesKey, fpvm.SelectedFiles);
                        break;
                    }
                }
            }
            else
            {
                wm.ShowWindow(evm);
            }

            return(NextCommand);
        }
예제 #15
0
        public override IScriptCommand Execute(ParameterDic pm)
        {
            var vm    = pm.GetValue <ISupportCommandManager>(ControlKey);
            var vmDic = vm.Commands.CommandDictionary as DynamicDictionary <IScriptCommand>;

            IScriptCommand cmd = pm.GetValue <IScriptCommand>(ValueKey);

            if (cmd != null)
            {
                logger.Debug(String.Format("Set {0}.{1} to {2} ({3})", ControlKey, Target, ValueKey, cmd));
                vmDic.Dictionary[Target] = cmd;
            }

            return(NextCommand);
        }
예제 #16
0
        private FrameworkElement findLogicalAncestor(ParameterDic pm, FrameworkElement sender)
        {
            switch (FindMethod)
            {
            case UIEventHub.FindMethodType.Name:
                string name = pm.ReplaceVariableInsideBracketed(FindParameterKey) ?? "";
                return(UITools.FindLogicalAncestor <FrameworkElement>(sender, ele => name.Equals(ele.Name)));

            case UIEventHub.FindMethodType.Type:
                string type = pm.ReplaceVariableInsideBracketed(FindParameterKey) ?? "";
                return(UITools.FindLogicalAncestor <FrameworkElement>(sender, ele => ele.GetType().Name.Equals(type, StringComparison.CurrentCultureIgnoreCase)));

            case UIEventHub.FindMethodType.Level:
                int level = pm.GetValue <int>(FindParameterKey, -1);
                if (level == -1)
                {
                    return(null);
                }
                FrameworkElement current = sender;
                for (int i = 0; i < level; i++)
                {
                    if (current != null)
                    {
                        current = LogicalTreeHelper.GetParent(current) as FrameworkElement;
                    }
                }
                return(current);

            default: throw new NotSupportedException(FindMethod.ToString());
            }
        }
예제 #17
0
 public static T RunScript <T>(string resultVariable = "{Result}", ParameterDic initialParameters = null,
                               params IScriptCommand[] commands)
 {
     initialParameters = initialParameters ?? new ParameterDic();
     RunScript(initialParameters, false, commands);
     return(initialParameters.GetValue(resultVariable, default(T)));
 }
예제 #18
0
        public override IScriptCommand Execute(ParameterDic pm)
        {
            object value = Value;

            if (ValueFunc != null)
            {
                value = ValueFunc();
            }
            if (value is string)
            {
                string valueString = (string)value;
                if (valueString.StartsWith("{") && valueString.EndsWith("}"))
                {
                    value = pm.GetValue(valueString);
                }
            }

            if (pm.SetValue <Object>(VariableKey, value, SkipIfExists))
            {
                logger.Debug(String.Format("{0} = {1}", VariableKey, value));
            }
            // else logger.Debug(String.Format("Skipped {0}, already exists.", VariableKey));

            return(NextCommand);
        }
예제 #19
0
        public override async Task <IScriptCommand> ExecuteAsync(ParameterDic pm)
        {
            DestinationKey = DestinationKey ?? "{Explorer}";
            var tevm = pm.GetValue <ITabbedExplorerViewModel>(TabbedExplorerKey);

            if (tevm == null)
            {
                return(ResultCommand.Error(new ArgumentNullException(TabbedExplorerKey)));
            }

            var dm = DirectoryEntryKey == null ? null :
                     (await pm.GetValueAsEntryModelArrayAsync(DirectoryEntryKey)).FirstOrDefault();

            if (dm != null && !dm.IsDirectory)
            {
                dm = null;
            }

            var destTab = tevm.OpenTab(dm);

            logger.Info(String.Format("New Tab #{0}", tevm.GetTabIndex(destTab)));
            logger.Debug(String.Format("{0} = {1}", DestinationKey, destTab));
            pm.SetValue(DestinationKey, destTab);
            return(NextCommand);
        }
예제 #20
0
        private T getVMProperty <T>(ExplorerParameterType property)
        {
            ParameterDic pd = new ParameterDic();

            _evm.Commands.Execute(UIScriptCommands.ExplorerGetParameter(property, "{OutputValue}"), pd);
            return(pd.GetValue <T>("{OutputValue}"));
        }
예제 #21
0
        public override async Task <IScriptCommand> ExecuteAsync(ParameterDic pm)
        {
            IEntryModel entryModel = pm.GetValue <IEntryModel>(EntryKey);

            if (entryModel == null)
            {
                return(ResultCommand.Error(new ArgumentException(EntryKey + " is not found or not IEntryModel")));
            }

            IDiskProfile profile = entryModel.Profile as IDiskProfile;

            if (profile == null)
            {
                return(ResultCommand.Error(new NotSupportedException(EntryKey + "'s Profile is not IDiskProfile")));
            }

            using (var stream = await profile.DiskIO.OpenStreamAsync(entryModel, Access, pm.CancellationToken))
            {
                ParameterDic pmClone = pm.Clone();
                pmClone.SetValue(StreamKey, stream);
                logger.Debug(String.Format("{0} = Stream of {1}", StreamKey, EntryKey));
                await ScriptRunner.RunScriptAsync(pmClone, NextCommand);
            }

            if (Access == FileAccess.ReadWrite || Access == FileAccess.Write)
            {
                return(CoreScriptCommands.NotifyEntryChangedProfile(ChangeType.Changed, null, EntryKey, ThenCommand));
            }
            else
            {
                return(ThenCommand);
            }
        }
        protected override IScriptCommand executeInner(ParameterDic pm, ItemsControl ic, RoutedEventArgs evnt, IUIInput input, IList <IUIInputProcessor> inpProcs)
        {
            var        scp    = ControlUtils.GetScrollContentPresenter(ic);
            IChildInfo icInfo = UITools.FindVisualChild <Panel>(scp) as IChildInfo;

            if (icInfo == null)
            {
                return(ResultCommand.Error(new NotSupportedException()));
            }

            Rect          selectionBound = pm.GetValue <Rect>(SelectionBoundAdjustedKey);
            List <object> selectedList   = new List <object>();
            List <int>    selectedIdList = new List <int>();

            for (int i = 0; i < ic.Items.Count; i++)
            {
                if (icInfo.GetChildRect(i).IntersectsWith(selectionBound))
                {
                    selectedList.Add(ic.Items[i]);
                    selectedIdList.Add(i);
                }
            }

            pm.SetValue(SelectedListKey, selectedList);
            pm.SetValue(SelectedIdListKey, selectedIdList);
            logger.Debug(String.Format("Selected = {0}", selectedIdList.Count()));

            return(NextCommand);
        }
예제 #23
0
        public override async Task <IScriptCommand> ExecuteAsync(ParameterDic pm)
        {
            var flValue             = pm.GetValue(FileListKey);
            IFileListViewModel flvm = flValue is IExplorerViewModel ?
                                      (flValue as IExplorerViewModel).FileList :
                                      flValue as IFileListViewModel;

            if (flvm == null)
            {
                return(ResultCommand.Error(new KeyNotFoundException(FileListKey)));
            }

            IEntryModel[] value = new IEntryModel[] { };
            switch (AssignType)
            {
            case FileListAssignType.All:
                value = flvm.ProcessedEntries.EntriesHelper.AllNonBindable
                        .Select(evm => evm.EntryModel).ToArray();
                break;

            case FileListAssignType.Selected:
                value = flvm.Selection.SelectedItems.Select(evm => evm.EntryModel).ToArray();
                break;

            default:
                return(ResultCommand.Error(new NotSupportedException("AssignType")));
            }

            return(ScriptCommands.Assign(DestinationKey, value, false, NextCommand));
        }
예제 #24
0
        public override Script.IScriptCommand Execute(ParameterDic pm)
        {
            IList <IUIInputProcessor> inpProcs = pm.GetValue <IList <IUIInputProcessor> >(InputProcessorsKey);
            var      processor = inpProcs.First(p => p is TouchDragMoveCountInputProcessor) as TouchDragMoveCountInputProcessor;
            IUIInput input     = pm.GetValue <IUIInput>(InputKey);

            if (input.InputType != Defines.UIInputType.Touch || processor.DragMoveCount % Divider == 0)
            {
                return(NextCommand);
            }

            else
            {
                return(OtherwiseCommand);
            }
        }
예제 #25
0
        public override IScriptCommand Execute(ParameterDic pm)
        {
            KeyEventArgs keyEvent = pm.GetValue <KeyEventArgs>(RoutedEventArgsKey);

            if (keyEvent == null)
            {
                return(OtherwiseCommand);
            }

            object     keygestureObject = !KeyGestureKey.StartsWith("{") ? KeyGestureKey : pm.GetValue(KeyGestureKey);
            KeyGesture gesture          = null;

            if (keygestureObject is KeyGesture)
            {
                gesture = (KeyGesture)keygestureObject;
            }

            if (keygestureObject is string)
            {
                gesture = (KeyGesture)converter.ConvertFrom(keygestureObject);
            }


            return(gesture != null &&
                   keyEvent.Key == gesture.Key &&
                   keyEvent.KeyboardDevice.Modifiers == gesture.Modifiers ?
                   NextCommand : OtherwiseCommand);
        }
예제 #26
0
        public override IScriptCommand Execute(ParameterDic pm)
        {
            Func <object, object> checkParameters = p =>
            {
                if (p is string)
                {
                    string pString = p as string;
                    if (pString.StartsWith("{") && pString.EndsWith("}"))
                    {
                        return(pm.GetValue(pString));
                    }
                }
                return(p);
            };

            object        firstValue      = pm.GetValue(Value1Key);
            object        secondValue     = pm.GetValue(Value2Key);
            List <object> secondArrayList = secondValue is Array ? (secondValue as Array).Cast <object>().ToList() :
                                            new List <object>()
            {
                secondValue
            };

            object value      = firstValue;
            string methodName = OperatorType.ToString();


            var mInfo = typeof(FileExplorer.Utils.ExpressionUtils)
                        .GetRuntimeMethods().First(m => m.Name == methodName)
                        .MakeGenericMethod(value.GetType());

            foreach (var addItem in secondArrayList.Select(p => checkParameters(p)).ToArray())
            {
                switch (mInfo.GetParameters().Length)
                {
                case 1: value = mInfo.Invoke(null, new object[] { value }); break;

                case 2: value = mInfo.Invoke(null, new object[] { value, addItem }); break;

                default: throw new NotSupportedException();
                }
            }

            Value = value;

            return(base.Execute(pm));
        }
예제 #27
0
        public override IScriptCommand Execute(ParameterDic pm)
        {
            AdornerLayer adornerLayer = pm.GetValue <AdornerLayer>(AdornerLayerKey);
            Adorner      adorner      = pm.GetValue <Adorner>(AdornerKey);

            if (adornerLayer != null && adorner != null)
            {
                switch (Mode)
                {
                case AdornerCommandMode.Attach: adornerLayer.Add(adorner); break;

                case AdornerCommandMode.Detach: adornerLayer.Remove(adorner); break;
                }
            }

            return(NextCommand);
        }
예제 #28
0
        public override IScriptCommand Execute(ParameterDic pm)
        {
            Point pos1 = pm.GetValue <Point>(Position1Key);

            if (pm.HasValue(Position2Key))
            {
                Point pos2 = pm.GetValue <Point>(Position2Key);
                Value = new Rect(pos1, pos2);
            }
            else
            {
                Size size = pm.GetValue <Size>(SizeKey);
                Value = new Rect(pos1, size);
            }

            return(base.Execute(pm));
        }
예제 #29
0
        public override IScriptCommand Execute(ParameterDic pm)
        {
            TouchEventArgs TouchEvent   = pm.GetValue <TouchEventArgs>(RoutedEventArgsKey);
            IUIInput       input        = pm.GetValue <IUIInput>(InputKey);
            TouchGesture   inputGesture = input.GetTouchGesture();
            TouchGesture   gesture      = pm.GetValue <TouchGesture>(TouchGestureKey);

            if (inputGesture == null || gesture == null || inputGesture.TouchDevice == UIInputState.NotApplied)
            {
                return(OtherwiseCommand);
            }

            bool match = (gesture.TouchAction == UITouchGesture.NotApplied || inputGesture.TouchAction == gesture.TouchAction) &&
                         (gesture.TouchDevice == UIInputState.NotApplied || inputGesture.TouchDevice == gesture.TouchDevice);

            return(match ? NextCommand : OtherwiseCommand);
        }
예제 #30
0
        public override IScriptCommand Execute(ParameterDic pm)
        {
            Point pos = pm.GetValue <Point>(PositionKey);

            pm.SetValue(DestinationKey, Point.Multiply(pos, new System.Windows.Media.Matrix(-1, 0, 0, -1, 0, 0)));

            return(NextCommand);
        }