Exemplo n.º 1
0
        private void lstLayers_KeyDown(object sender, KeyEventArgs e)
        {
            if (Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
            {
                if (e.Key == Key.C)
                {
                    Global.Clipboard = (this.lstLayers.SelectedItem as Layers.Layer)?.Clone();
                }
                else if (e.Key == Key.V && Global.Clipboard is Layers.Layer)
                {
                    Layers.Layer lyr = (Layers.Layer)((Layers.Layer)Global.Clipboard)?.Clone();

                    if (Global.LightingStateManager.DefaultLayerHandlers.Contains(lyr.Handler.ID) || FocusedApplication.Config.ExtraAvailableLayers.Contains(lyr.Handler.ID))
                    {
                        lyr.Name += " - Copy";
                        lyr.SetProfile(FocusedApplication);

                        if (this.FocusedApplication is Profiles.Generic_Application.GenericApplication && this.radiobtn_nighttime.IsChecked.Value)
                        {
                            ((FocusedApplication as Profiles.Generic_Application.GenericApplication)?.Profile as Profiles.Generic_Application.GenericApplicationProfile)?.Layers_NightTime?.Insert(0, lyr);
                        }
                        else
                        {
                            FocusedApplication.Profile.Layers.Insert(0, lyr);
                        }
                    }
                }
            }
            else if (e.Key == Key.Delete)
            {
                this.btnRemoveLayer_Click(null, null);
            }
        }
Exemplo n.º 2
0
        private void SetLayer(Layers.Layer layer)
        {
            isSettingNewLayer = true;

            DataContext = layer;

            cmbLayerType.ItemsSource   = layer.AssociatedApplication.AllowedLayers.OrderBy(l => l.Order).ThenBy(l => l.Name);
            cmbLayerType.SelectedValue = Layer.Handler.GetType();

            ctrlLayerTypeConfig.Content = layer.Control;
            chkLayerSmoothing.IsChecked = Layer.Handler.EnableSmoothing;
            chk_ExcludeMask.IsChecked   = Layer.Handler._EnableExclusionMask ?? false;
            keyseq_ExcludeMask.Sequence = Layer.Handler._ExclusionMask;
            sldr_Opacity.Value          = (int)(Layer.Handler._Opacity ?? 1f * 100.0f);
            lbl_Opacity_Text.Text       = $"{(int)sldr_Opacity.Value} %";

            grdLayerConfigs.Visibility        = Visibility.Hidden;
            overridesEditor.Visibility        = Visibility.Hidden;
            btnConfig.Visibility              = Visibility.Visible;
            btnOverrides.Visibility           = Visibility.Visible;
            grd_LayerControl.IsHitTestVisible = true;
            grd_LayerControl.Effect           = null;
            isSettingNewLayer = false;

            overridesEditor.Layer = layer;
        }
Exemplo n.º 3
0
        private void SetLayer(Layers.Layer layer)
        {
            isSettingNewLayer = true;

            DataContext = layer;

            cmbLayerType.Items.Clear();

            foreach (var layertype in Global.LightingStateManager.DefaultLayerHandlers.Concat(layer.AssociatedApplication.Config.ExtraAvailableLayers))
            {
                cmbLayerType.Items.Add(Global.LightingStateManager.LayerHandlers[layertype]);
            }

            cmbLayerType.SelectedItem   = Global.LightingStateManager.LayerHandlers[Layer.Handler.ID];
            ctrlLayerTypeConfig.Content = layer.Control;
            chkLayerSmoothing.IsChecked = Layer.Handler.EnableSmoothing;
            chk_ExcludeMask.IsChecked   = Layer.Handler.EnableExclusionMask;
            keyseq_ExcludeMask.Sequence = Layer.Handler.ExclusionMask;
            sldr_Opacity.Value          = (int)(Layer.Handler.Opacity * 100.0f);
            lbl_Opacity_Text.Text       = $"{(int)sldr_Opacity.Value} %";

            grdLayerConfigs.Visibility        = Visibility.Hidden;
            grd_LayerControl.IsHitTestVisible = true;
            grd_LayerControl.Effect           = null;
            isSettingNewLayer = false;
        }
Exemplo n.º 4
0
 public Control_LayerControlPresenter(Layers.Layer layer) : this()
 {
     Layer = layer;
     grdLayerConfigs.Visibility        = Visibility.Hidden;
     grd_LayerControl.IsHitTestVisible = true;
     grd_LayerControl.Effect           = null;
 }
Exemplo n.º 5
0
 public Control_LayerControlPresenter(Layers.Layer layer) : this()
 {
     Layer = layer;
     cmbLayerType.SelectedItem         = Layer.Handler.ID;
     grdLayerConfigs.Visibility        = Visibility.Hidden;
     grd_LayerControl.IsHitTestVisible = true;
     grd_LayerControl.Effect           = null;
 }
Exemplo n.º 6
0
        private void add_layer_button_Click(object sender, RoutedEventArgs e)
        {
            Layers.Layer lyr = new Layers.Layer("New layer " + Utils.Time.GetMilliSeconds());
            lyr.AnythingChanged += this.FocusedApplication.SaveProfilesEvent;

            lyr.SetProfile(FocusedApplication);

            if (this.FocusedApplication is Profiles.Generic_Application.GenericApplication && this.radiobtn_nighttime.IsChecked.Value)
            {
                ((FocusedApplication as Profiles.Generic_Application.GenericApplication)?.Profile as Profiles.Generic_Application.GenericApplicationProfile)?.Layers_NightTime?.Insert(0, lyr);
            }
            else
            {
                this.FocusedApplication?.Profile?.Layers.Insert(0, lyr);
            }

            this.lstLayers.SelectedItem = lyr;
        }
Exemplo n.º 7
0
        //Based on: http://stackoverflow.com/questions/3350187/wpf-c-rearrange-items-in-listbox-via-drag-and-drop
        private void stckLayer_Drop(object sender, DragEventArgs e)
        {
            Layers.Layer droppedData = e.Data.GetData(typeof(Layers.Layer)) as Layers.Layer;
            Layers.Layer target      = ((FrameworkElement)(sender)).DataContext as Layers.Layer;

            int removedIdx = lstLayers.Items.IndexOf(droppedData);
            int targetIdx  = lstLayers.Items.IndexOf(target);

            if (removedIdx < targetIdx)
            {
                if (this.FocusedApplication is Profiles.Generic_Application.GenericApplication && this.radiobtn_nighttime.IsChecked.Value)
                {
                    ((FocusedApplication as Profiles.Generic_Application.GenericApplication)?.Profile as Profiles.Generic_Application.GenericApplicationProfile)?.Layers_NightTime?.Insert(targetIdx + 1, droppedData);
                    ((FocusedApplication as Profiles.Generic_Application.GenericApplication)?.Profile as Profiles.Generic_Application.GenericApplicationProfile)?.Layers_NightTime?.RemoveAt(removedIdx);
                }
                else
                {
                    this.FocusedApplication?.Profile?.Layers.Insert(targetIdx + 1, droppedData);
                    this.FocusedApplication?.Profile?.Layers.RemoveAt(removedIdx);
                }
            }
            else
            {
                int remIdx = removedIdx + 1;

                if (this.FocusedApplication is Profiles.Generic_Application.GenericApplication && this.radiobtn_nighttime.IsChecked.Value)
                {
                    if (((FocusedApplication as Profiles.Generic_Application.GenericApplication)?.Profile as Profiles.Generic_Application.GenericApplicationProfile)?.Layers_NightTime?.Count + 1 > remIdx)
                    {
                        ((FocusedApplication as Profiles.Generic_Application.GenericApplication)?.Profile as Profiles.Generic_Application.GenericApplicationProfile)?.Layers_NightTime?.Insert(targetIdx, droppedData);
                        ((FocusedApplication as Profiles.Generic_Application.GenericApplication)?.Profile as Profiles.Generic_Application.GenericApplicationProfile)?.Layers_NightTime?.RemoveAt(remIdx);
                    }
                }
                else
                {
                    if (this.FocusedApplication?.Profile?.Layers.Count + 1 > remIdx)
                    {
                        this.FocusedApplication?.Profile?.Layers.Insert(targetIdx, droppedData);
                        this.FocusedApplication?.Profile?.Layers.RemoveAt(remIdx);
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void Layers_listbox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count == 1)
            {
                var hander = NewLayer;
                if (lstLayers.SelectedItem != null)
                {
                    if (!(lstLayers.SelectedItem is Layers.Layer))
                    {
                        throw new ArgumentException($"Items contained in the ListView must be of type 'Layer', not '{lstLayers.SelectedItem.GetType()}'");
                    }

                    Layers.Layer lyr = (Layers.Layer)lstLayers.SelectedItem;

                    lyr.SetProfile(FocusedApplication);

                    hander?.Invoke(lyr);
                }
            }
        }
 public Window_LayerLogicEditor(Layers.Layer layer)
 {
     InitializeComponent();
     this.DataContext = layer;
 }
Exemplo n.º 10
0
        private void Layer_manager_NewLayer(Settings.Layers.Layer layer)
        {
            layercontrol_presenter.Layer = layer;

            this.content_grid.Content = layercontrol_presenter;
        }