Exemple #1
0
        public DockLayoutViewModel(ILayoutViewModel parent, IConstants constants, IEventAggregator eventAggregator)
        {
            this.eventAggregator = eventAggregator ?? throw new ArgumentNullException("eventAggregator");
            this.layoutParent    = parent;

            this.layoutFilename = constants.LayoutFileName;
        }
Exemple #2
0
        public MainViewModel(ApplicationSettings application_settings, IEventAggregator event_aggregator)
        {
            this.application_settings = application_settings;
            this.event_aggregator     = event_aggregator;

            CaptureCommands = new List <CaptureCommand>
            {
                new CaptureCommand {
                    Kind = CaptureCommand.CaptureKind.Windows
                },
                new CaptureCommand {
                    Kind = CaptureCommand.CaptureKind.Icons
                }
            };

            Layouts = application_settings.Layouts.CreateDerivedCollection(l =>
            {
                ILayoutViewModel vm = null;
                if (l is Layout <Program> )
                {
                    vm = new ProgramLayoutViewModel(l as Layout <Program>);
                }
                if (l is Layout <Icon> )
                {
                    vm = new IconLayoutViewModel(l as Layout <Icon>);
                }
                return(vm);
            });

            var obs = this.WhenAny(x => x.CurrentLayout, x => x.Value != null);

            _CanApply  = obs.ToProperty(this, x => x.CanApply);
            _CanEdit   = obs.ToProperty(this, x => x.CanEdit);
            _CanDelete = obs.ToProperty(this, x => x.CanDelete);
        }
        public LayoutVisualViewModel(VisualOptions visualOptions, ILayoutViewModel element)
        {
            VisualOptions = visualOptions;
            PixelPerUnit = VisualOptions.PixelPerUnit;
            Element = element;

            Element
                .SetPropertyChanged(nameof(Element.Width),
                    () =>
                    {
                        OnPropertyChanged(nameof(Width));
                        OnPropertyChanged(nameof(Rect));
                    })
                .SetPropertyChanged(nameof(Element.Height),
                    () =>
                    {
                        OnPropertyChanged(nameof(Height));
                        OnPropertyChanged(nameof(Rect));
                    })
                .SetPropertyChanged(nameof(Element.Top),
                    () =>
                    {
                        OnPropertyChanged(nameof(Top));
                        OnPropertyChanged(nameof(Rect));
                    })
                .SetPropertyChanged(nameof(Element.Left),
                    () =>
                    {
                        OnPropertyChanged(nameof(Left));
                        OnPropertyChanged(nameof(Rect));
                    })
                .SetPropertyChanged(nameof(Element.OpacityMask), () => OnPropertyChanged(nameof(OpacityMask)))
                .SetPropertyChanged(nameof(Element.Rect), () => OnPropertyChanged(nameof(Rect)));
        }
Exemple #4
0
        public static IViewModel Edit(ILayoutViewModel layout)
        {
            var application_settings = IoC.Get <ApplicationSettings>();

            if (layout is ProgramLayoutViewModel)
            {
                var temp = layout as ProgramLayoutViewModel;
                var vm   = new CaptureViewModel <Program, ProgramViewModel>(temp.AssociatedObject)
                {
                    Title         = "Edit Windows Layout",
                    ItemsTitle    = "Windows",
                    AcceptAction  = (l1, l2) => application_settings.Update(l1, l2),
                    CaptureAction = () => WindowManager.GetPrograms()
                };
                return(vm);
            }

            if (layout is IconLayoutViewModel)
            {
                var temp = layout as IconLayoutViewModel;
                var vm   = new CaptureViewModel <Icon, IconViewModel>(temp.AssociatedObject)
                {
                    Title         = "Edit Icons Layout",
                    ItemsTitle    = "Icons",
                    AcceptAction  = (l1, l2) => application_settings.Update(l1, l2),
                    CaptureAction = () => IconManagerWrapper.GetIcons()
                };
                return(vm);
            }

            throw new Exception();
        }
 /// <summary>
 /// Default ctor
 /// </summary>
 public XmlLayoutDesignerControl(IIde ide, IServiceProvider serviceProvider, ILayoutViewModel viewModel)
 {
     if (ide != null)
     {
         selectionContainer = ide.CreateSelectionContainer(serviceProvider);
     }
     if (viewModel != null)
     {
         DataContext = viewModel;
     }
     InitializeComponent();
     // wait until we're initialized to handle events
     if (viewModel != null)
     {
         viewModel.PropertyChanged += OnViewModelPropertyChanged;
     }
     ViewModelChanged(this, EventArgs.Empty);
 }
 /// <summary>
 /// Default ctor
 /// </summary>
 public XmlLayoutDesignerControl(IIde ide, IServiceProvider serviceProvider, ILayoutViewModel viewModel)
 {
     if (ide != null)
     {
         selectionContainer = ide.CreateSelectionContainer(serviceProvider);
     }
     if (viewModel != null)
     {
         DataContext = viewModel;
     }
     InitializeComponent();
     // wait until we're initialized to handle events
     if (viewModel != null)
     {
         viewModel.PropertyChanged += OnViewModelPropertyChanged;
     }
     ViewModelChanged(this, EventArgs.Empty);
 }
 public Point[] GetPoints(Point[] points, ILayoutViewModel layout)
 {
     return _reflection.GetPoints(points, new Size(layout.Width, layout.Height));
 }
        /// <summary>
        /// Loads process-dependent settings.
        /// </summary>
        /// <param name="settings">The settings.</param>
        protected override void LoadProcessDependentSettings(IDictionary<string, string> settings)
        {
            base.LoadProcessDependentSettings(settings);

            using (new AutoSaveSuppressor(this))
            {
                var filterMode = settings.ReadValue(SelectedFilterModeKey, string.Empty);
                FilterType selectedFilterMode;
                SelectedFilterMode = Enum.TryParse(filterMode, out selectedFilterMode) ? selectedFilterMode : FilterType.NoFilter;

                var filterDefinition = settings.ReadValue(ProcessedFilterKey, string.Empty);
                if (!string.IsNullOrWhiteSpace(filterDefinition))
                    _processedFilter = FilterDescriptor.FromJSON(filterDefinition);

                var filter = settings.ReadValue(ChosenFilterKey, string.Empty);
                if (CommonFilterList != null)
                    ChosenFilter = CommonFilterList.FirstOrDefault(x => x.Name == filter);

                bool useDefaultLayout;
                if (Boolean.TryParse(settings.ReadValue(UseDefaultLayoutKey, string.Empty), out useDefaultLayout))
                {
                    UseDefaultLayout = useDefaultLayout;
                }

                if (!ShouldUseDefaultLayout() && LayoutList != null)
                {
                    int layoutId;
                    if (Int32.TryParse(settings.ReadValue(SelectedLayoutKey, string.Empty), out layoutId))
                    {
                        SetSelectedLayout(LayoutList.FirstOrDefault(x => x.Id == layoutId));
                    }

                    int origLayoutId;
                    if (Int32.TryParse(settings.ReadValue(OriginalSelectedLayoutKey, string.Empty), out origLayoutId))
                    {
                        _originalSelectedLayout = LayoutList.FirstOrDefault(x => x.Id == origLayoutId);
                    }
                }

                if (SelectedLayout == null)
                        SetDefaultLayout();

                SetupSubTitle();

                if (SelectedTab != null)
                    SelectedTab.RefreshView();
            }
        }
        private void SetSelectedLayout(ILayoutViewModel layout, bool updateOriginalLayout = false)
        {
            if (updateOriginalLayout && layout != null)
                _originalSelectedLayout = layout;

            if (_selectedLayout == layout)
                return;

            _selectedLayout = layout;
            RaisePropertyChanged(() => SelectedLayout);
        }
        /// <summary>
        /// Initializes from base.
        /// </summary>
        /// <param name="baseGadget">The base gadget.</param>
        protected override void InitFromBase(IGadgetViewModel baseGadget)
        {
            try
            {
                RefreshTimer.Stop();

                base.InitFromBase(baseGadget);

                SuppressSetup = true;

                var oldGadget = baseGadget as ProcessSearchGridGadgetViewModel;

                if (oldGadget == null)
                    return;

                if (SelectedProcess == null)
                    SelectedProcess = oldGadget.ProcessInfo.SystemName;

                AdminFilterList = oldGadget.AdminFilterList;
                UserFilterList = oldGadget.UserFilterList;

                SelectedFilterMode = oldGadget.SelectedFilterMode;

                _processedFilter = oldGadget._processedFilter;
                if (ChosenFilter == null)
                    ChosenFilter = oldGadget.ChosenFilter;

                LayoutList = oldGadget.LayoutList;

                if (SelectedLayout == null)
                    SetSelectedLayout(oldGadget.SelectedLayout, true);

                _originalSelectedLayout = oldGadget._originalSelectedLayout;

                UseDefaultLayout = oldGadget.UseDefaultLayout;

                SuppressSetup = false;
            }
            finally
            {
                RefreshTimer.Start();
            }
        }