Ejemplo n.º 1
0
        public void RemoveFullDetailsItem(TreeItem ti)
        {
            if (IsSelectedProfileWritable)
            {
                // Prompt the user for confirmation in the cases where we are removing a group, or
                // the property also appears in the preview details, and so will be removed there too
                MessageBoxResult ans = MessageBoxResult.Yes;
                if ((PropType)ti.Item == PropType.Group)
                {
                    ans = MessageBox.Show(String.Format(LocalizedMessages.RemovePropertyGroupQuestion, ti.Name),
                                          LocalizedMessages.RemovePropertyGroupHeader, MessageBoxButton.YesNo);
                }
                else if (SelectedProfile.HasPropertyInPreviewDetails(ti.Name) || SelectedProfile.HasPropertyInInfoTip(ti.Name))
                {
                    ans = MessageBox.Show(String.Format(LocalizedMessages.RemovePropertyQuestion, ti.Name),
                                          LocalizedMessages.RemovePropertyHeader, MessageBoxButton.YesNo);
                }

                if (ans == MessageBoxResult.Yes)
                {
                    SelectedProfile.RemoveFullDetailsItem(ti);
                    IsDirty = true;
                }
            }
        }
Ejemplo n.º 2
0
        private void UpdateLayerList(LayerModel selectModel)
        {
            // Update the UI
            Layers.Clear();
            SelectedLayer = null;

            if (SelectedProfile != null)
            {
                foreach (var selectedProfileLayer in SelectedProfile.Layers)
                {
                    Layers.Add(selectedProfileLayer);
                }
            }

            if (selectModel == null)
            {
                return;
            }

            // A small delay to allow the profile list to rebuild
            Task.Factory.StartNew(() =>
            {
                Thread.Sleep(100);
                SelectedLayer = selectModel;
                SelectedProfile?.OnOnProfileUpdatedEvent();
            });
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Second handler for clicking, selects a the layer the user clicked on
        ///     if the used clicked on an empty spot, deselects the current layer
        /// </summary>
        /// <param name="e"></param>
        public void MouseUpKeyboardPreview(MouseButtonEventArgs e)
        {
            if (SelectedProfile == null || SelectedProfile.IsDefault)
            {
                return;
            }

            var timeSinceDown = DateTime.Now - _downTime;

            if (!(timeSinceDown.TotalMilliseconds < 500))
            {
                return;
            }
            if (_draggingLayer != null)
            {
                return;
            }

            var keyboard = _deviceManager.ActiveKeyboard;
            var pos      = e.GetPosition((Image)e.OriginalSource);
            var x        = pos.X / ((double)keyboard.PreviewSettings.Width / keyboard.Width);
            var y        = pos.Y / ((double)keyboard.PreviewSettings.Height / keyboard.Height);

            var hoverLayer = SelectedProfile.GetLayers()
                             .Where(l => l.MustDraw())
                             .FirstOrDefault(l => ((KeyboardPropertiesModel)l.Properties)
                                             .GetRect(1)
                                             .Contains(x, y));

            SelectedLayer = hoverLayer;
        }
Ejemplo n.º 4
0
 public ProfileSettingsViewModel(SettingsController controller)
     : base("PROFILES", controller)
 {
     RemoveProfileCommand = new ReactiveCommand(SelectedProfile.Select(i => i != null), false);
     RemoveProfileCommand.Subscribe(OnRemoveProfile);
     AddProfileCommand.Subscribe(OnAddProfile);
 }
        public List <LayerModel> GetRenderLayers()
        {
            // Get the layers that must be drawn
            List <LayerModel> drawLayers;

            if (ShowAll)
            {
                return(SelectedProfile.GetRenderLayers(null, false, true));
            }

            if (SelectedLayer == null || !SelectedLayer.Enabled)
            {
                return(new EditableList <LayerModel>());
            }

            if (SelectedLayer.LayerType is FolderType)
            {
                drawLayers = SelectedLayer.GetRenderLayers(null, false, true);
            }
            else
            {
                drawLayers = new List <LayerModel> {
                    SelectedLayer
                }
            };

            return(drawLayers);
        }
Ejemplo n.º 6
0
        private List <LayerModel> GetLayers()
        {
            if (SelectedLayer == null)
            {
                return(new List <LayerModel>());
            }

            lock (SelectedLayer)
            {
                // Get the layers that must be drawn
                List <LayerModel> drawLayers;
                if (ShowAll)
                {
                    drawLayers = SelectedProfile.GetLayers();
                }
                else if (SelectedLayer.LayerType is FolderType)
                {
                    drawLayers = SelectedLayer.GetLayers().ToList();
                }
                else
                {
                    drawLayers = new List <LayerModel> {
                        SelectedLayer
                    }
                };

                return(drawLayers);
            }
        }

        #endregion
    }
Ejemplo n.º 7
0
 public void OnProfileDeleted(SelectedProfile selectedProfile)
 {
     Debug.Log($"Profile {selectedProfile.fullProfileName} was deleted!");
     // Clears the old UI Elements and loads the new ones
     ClearProfilesUIScrollView();
     Start();
 }
Ejemplo n.º 8
0
 public void RemoveInfoTipItem(PropertyListEntry property)
 {
     if (IsSelectedProfileWritable)
     {
         SelectedProfile.RemoveInfoTipProperty(property);
         IsDirty = true;
     }
 }
Ejemplo n.º 9
0
 public void RemovePreviewDetailsItem(PropertyListEntry property)
 {
     if (IsSelectedProfileWritable)
     {
         SelectedProfile.RemovePreviewDetailsProperty(property);
         IsDirty = true;
     }
 }
Ejemplo n.º 10
0
 public void ToggleAsteriskFullDetailsItem(TreeItem ti)
 {
     if (IsSelectedProfileWritable)
     {
         SelectedProfile.ToggleAsteriskFullDetailsItem(ti);
         IsDirty = true;
     }
 }
Ejemplo n.º 11
0
    // Used to easily create an SelectedProfile object
    public SelectedProfile CreateSelectedProfileObject(string selectedProfileId, string selectedProfile, string selectedFullProfileName, string selectedCompany, string selectedProfileImage)
    {
        SelectedProfile SelectedProfile = new SelectedProfile
        {
            profileId       = selectedProfileId,
            profileName     = selectedProfile,
            fullProfileName = selectedFullProfileName,
            companyName     = selectedCompany,
            profileImage    = selectedProfileImage
        };

        return(SelectedProfile);
    }
Ejemplo n.º 12
0
        public LayerModel AddLayer()
        {
            if (SelectedProfile == null)
            {
                return(null);
            }

            var layer = SelectedProfile.AddLayer(SelectedLayer);

            UpdateLayerList(layer);

            return(layer);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Removes selected profile from the list
        /// </summary>
        private void RemoveProfileAction()
        {
            if (SelectedProfile != null)
            {
                if (MainWindowVm.Instance.SelectedWorkingProfile != null &&
                    SelectedProfile.Name == MainWindowVm.Instance.SelectedWorkingProfile.Name)
                {
                    FilesActionVm.Instance.WorkingItemsList.Clear();
                    FilesActionVm.Instance.StopMonitoringDirectory();
                    MainWindowVm.Instance.SelectedWorkingProfile = null;
                }

                SelectedProfile.RemoveProfile();
                ProfileList.Remove(SelectedProfile);
                MainWindowVm.Instance.UpdateProfileListFromProfilesWindow(ProfileList);
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Calls save method on Profile's VM class
        /// </summary>
        private void SaveProfileAction()
        {
            if (SelectedProfile != null)
            {
                if (SelectedProfile.IsDefault)
                {
                    foreach (var profile in ProfileList.Where(x => x.Name != SelectedProfile.Name))
                    {
                        profile.IsDefault = false;
                        profile.SaveProfile(false);
                    }

                    Properties.Settings.Default.DefaultProfile = SelectedProfile.Name;
                }

                SelectedProfile.SaveProfile();
                MainWindowVm.Instance.UpdateProfileListFromProfilesWindow(ProfileList);
            }
        }
Ejemplo n.º 15
0
        private async void AddGoogleAccountDetailsToApplication(string accountName)
        {
            var account = new GoogleAccount {
                Name = accountName
            };

            if (GoogleAccounts == null)
            {
                GoogleAccounts = new ObservableCollection <GoogleAccount>();
            }
            GoogleAccounts.Add(account);
            SelectedProfile.SelectedGoogleAccount = account;
            SelectedProfile.GoogleCalendars       = null;
            SelectedProfile.GetGoogleCalendar();

            Settings.GoogleAccounts = GoogleAccounts;

            await SettingsSerializationService.SerializeSettingsAsync(Settings);
        }
        public void Reload(SelectedProfile selectedProfile = SelectedProfile.Current)
        {
            base.Reload();

            switch (selectedProfile)
            {
            case SelectedProfile.Current:
                SelectedProfileIndex = SelectedProfileIndex;
                break;

            case SelectedProfile.First:
                SelectedProfileIndex = this.Any() ? 0 : SelectedProfileIndex;
                break;

            case SelectedProfile.Last:
                SelectedProfileIndex = this.Any() ? this.Count() - 1 : SelectedProfileIndex;
                break;
            }
        }
        public async Task ReloadAsync(SelectedProfile selectedProfile = SelectedProfile.Current)
        {
            await base.ReloadAsync();

            switch (selectedProfile)
            {
            case SelectedProfile.Current:
                SelectedProfileIndex = SelectedProfileIndex;
                break;

            case SelectedProfile.First:
                SelectedProfileIndex = this.Any() ? 0 : SelectedProfileIndex;
                break;

            case SelectedProfile.Last:
                SelectedProfileIndex = this.Any() ? this.Count() - 1 : SelectedProfileIndex;
                break;
            }
        }
Ejemplo n.º 18
0
        public void ClipboardToLayer()
        {
            if (!ActiveWindowHelper.MainWindowActive || !IsActive)
            {
                return;
            }

            try
            {
                GeneralHelpers.ExecuteSta(() =>
                {
                    var data = (string)Clipboard.GetData("layer");
                    if (data == null)
                    {
                        return;
                    }

                    var layerModel = JsonConvert.DeserializeObject <LayerModel>(data);
                    if (layerModel == null)
                    {
                        return;
                    }

                    if (SelectedLayer != null)
                    {
                        SelectedLayer.InsertAfter(layerModel);
                    }
                    else
                    {
                        SelectedProfile.Layers.Add(layerModel);
                        SelectedProfile.FixOrder();
                    }
                    Execute.OnUIThread(() => UpdateLayerList(layerModel));
                });
            }
            catch (Exception)
            {
                // ignored
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        ///     Adds a new layer to the profile and selects it
        /// </summary>
        public void AddLayer()
        {
            if (SelectedProfile == null)
            {
                return;
            }

            // Create a new layer
            var layer = LayerModel.CreateLayer();

            if (ProfileViewModel.SelectedLayer != null)
            {
                ProfileViewModel.SelectedLayer.InsertAfter(layer);
            }
            else
            {
                SelectedProfile.Layers.Add(layer);
                SelectedProfile.FixOrder();
            }

            UpdateLayerList(layer);
        }
Ejemplo n.º 20
0
        /// <summary>
        ///     Handler for resizing and moving the currently selected layer
        /// </summary>
        /// <param name="e"></param>
        public void MouseMoveKeyboardPreview(MouseEventArgs e)
        {
            if (SelectedProfile == null)
            {
                return;
            }

            var pos        = e.GetPosition((Image)e.OriginalSource);
            var keyboard   = _deviceManager.ActiveKeyboard;
            var x          = pos.X / ((double)keyboard.PreviewSettings.Width / keyboard.Width);
            var y          = pos.Y / ((double)keyboard.PreviewSettings.Height / keyboard.Height);
            var hoverLayer = SelectedProfile.GetLayers()
                             .Where(l => l.MustDraw())
                             .FirstOrDefault(l => ((KeyboardPropertiesModel)l.Properties)
                                             .GetRect(1).Contains(x, y));

            HandleDragging(e, x, y, hoverLayer);

            if (hoverLayer == null)
            {
                KeyboardPreviewCursor = Cursors.Arrow;
                return;
            }


            // Turn the mouse pointer into a hand if hovering over an active layer
            if (hoverLayer == SelectedLayer)
            {
                var rect = ((KeyboardPropertiesModel)hoverLayer.Properties).GetRect(1);
                KeyboardPreviewCursor =
                    Math.Sqrt(Math.Pow(x - rect.BottomRight.X, 2) + Math.Pow(y - rect.BottomRight.Y, 2)) < 0.6
                        ? Cursors.SizeNWSE
                        : Cursors.SizeAll;
            }
            else
            {
                KeyboardPreviewCursor = Cursors.Hand;
            }
        }
Ejemplo n.º 21
0
        private List <LayerModel> GetLayers()
        {
            if (ShowAll)
            {
                return(SelectedProfile.GetLayers());
            }
            if (SelectedLayer == null)
            {
                return(new List <LayerModel>());
            }

            lock (SelectedLayer)
            {
                // Get the layers that must be drawn
                if (SelectedLayer.LayerType is FolderType)
                {
                    return(SelectedLayer.GetLayers().ToList());
                }
                return(new List <LayerModel> {
                    SelectedLayer
                });
            }
        }
Ejemplo n.º 22
0
 public MainWindowView()
 {
     SaveCommand = new RelayCommand(o => SelectedProfile.SaveProfile());
     LoadCommand = new RelayCommand(LoadProfile, CanLoadProfile);
 }
Ejemplo n.º 23
0
        // This is invoked whenever and item is dragged over one of our drop targets.
        // The main job is to determine whether this is a viable drop.
        // If we say nothing, the default answer is no.
        public void DragOver(IDropInfo dropInfo)
        {
            // Drops are only valid on to writable profiles
            if (IsSelectedProfileWritable)
            {
                var Source = window.IdentifyControl(dropInfo.DragInfo.VisualSource);
                var Target = window.IdentifyControl(dropInfo.VisualTarget);

                // Dropping a group onto Full Details
                if (Source == ProfileControls.Groups && Target == ProfileControls.FullDetails)
                {
                    // Check group is not already there
                    string group = dropInfo.Data as string;

                    if (group != null && !SelectedProfile.HasGroupInFullDetails(group))
                    {
                        dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
                        dropInfo.Effects           = DragDropEffects.Copy;
                    }
                }

                // Dropping a property onto Full Details
                else if (Source == ProfileControls.Properties && Target == ProfileControls.FullDetails)
                {
                    //System.Diagnostics.Trace.WriteLine(String.Format("DragOver {0} at {1}", ((TreeItem)dropInfo.Data).Name,
                    //                                   dropInfo.TargetItem == null ? "null" : ((TreeItem)dropInfo.TargetItem).Name));

                    // Check at least one group is present
                    if (SelectedProfile.FullDetails.Count > 0)
                    {
                        // Check property is not already there
                        var    ti       = dropInfo.Data as TreeItem;
                        string property = state.GetSystemPropertyName(ti);

                        if (property != null && !SelectedProfile.HasPropertyInFullDetails(property))
                        {
                            dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
                            dropInfo.Effects           = DragDropEffects.Copy;
                        }
                    }
                }

                // Reordering within Full Details
                else if (Source == ProfileControls.FullDetails && Target == ProfileControls.FullDetails)
                {
                    //System.Diagnostics.Trace.WriteLine(String.Format("DragOver {0} at {1}", ((TreeItem)dropInfo.Data).Name,
                    //               dropInfo.TargetItem == null ? "null" : ((TreeItem)dropInfo.TargetItem).Name));

                    var ti = dropInfo.Data as TreeItem;

                    if (ti != null)
                    {
                        dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
                        dropInfo.Effects           = DragDropEffects.Move;
                    }
                }

                // Dragging from Full Details to Preview Details
                else if (Source == ProfileControls.FullDetails && Target == ProfileControls.PreviewDetails)
                {
                    var ti = dropInfo.Data as TreeItem;

                    // Can only drag properties, not groups, and only if they are not already present
                    if (ti != null &&
                        (PropType)ti.Item == PropType.Normal &&
                        !SelectedProfile.HasPropertyInPreviewDetails(ti.Name))
                    {
                        dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
                        dropInfo.Effects           = DragDropEffects.Copy;
                    }
                }

                // Reordering within Preview Details
                else if (Source == ProfileControls.PreviewDetails && Target == ProfileControls.PreviewDetails)
                {
                    var property = dropInfo.Data as PropertyListEntry;

                    if (property != null)
                    {
                        dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
                        dropInfo.Effects           = DragDropEffects.Move;
                    }
                }

                // Dragging from Full Details to InfoTip
                else if (Source == ProfileControls.FullDetails && Target == ProfileControls.InfoTip)
                {
                    var ti = dropInfo.Data as TreeItem;

                    // Can only drag properties, not groups, and only if they are not already present
                    if (ti != null &&
                        (PropType)ti.Item == PropType.Normal &&
                        !SelectedProfile.HasPropertyInInfoTip(ti.Name))
                    {
                        dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
                        dropInfo.Effects           = DragDropEffects.Copy;
                    }
                }

                // Reordering within InfoTip
                else if (Source == ProfileControls.InfoTip && Target == ProfileControls.InfoTip)
                {
                    var property = dropInfo.Data as PropertyListEntry;

                    if (property != null)
                    {
                        dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
                        dropInfo.Effects           = DragDropEffects.Move;
                    }
                }
            }
        }
Ejemplo n.º 24
0
        // Handle an actual drop.
        // We don't have to do so many checks here, because we have already validated the drop in DragOver
        public void Drop(IDropInfo dropInfo)
        {
            var Source = window.IdentifyControl(dropInfo.DragInfo.VisualSource);
            var Target = window.IdentifyControl(dropInfo.VisualTarget);

            if (Target == ProfileControls.FullDetails)
            {
                TreeItem target = dropInfo.TargetItem as TreeItem;
                bool     before = (dropInfo.InsertPosition & ~RelativeInsertPosition.TargetItemCenter) == RelativeInsertPosition.BeforeTargetItem;

                if (Source == ProfileControls.Groups)
                {
                    string group = dropInfo.Data as string;

                    SelectedProfile.AddFullDetailsGroup(group, target, before);
                    IsDirty = true;
                }
                else if (Source == ProfileControls.Properties)
                {
                    //System.Diagnostics.Trace.WriteLine(String.Format("Drop {0} {1} {2}", ((TreeItem)dropInfo.Data).Name,
                    //                                   dropInfo.InsertPosition & ~RelativeInsertPosition.TargetItemCenter,
                    //                                   dropInfo.TargetItem == null ? "null" : ((TreeItem)dropInfo.TargetItem).Name));

                    string property = state.GetSystemPropertyName((TreeItem)dropInfo.Data);

                    SelectedProfile.AddFullDetailsProperty(property, target, before);
                    IsDirty = true;
                }
                else if (Source == ProfileControls.FullDetails)
                {
                    //System.Diagnostics.Trace.WriteLine(String.Format("Drop {0} {1} {2}", ((TreeItem)dropInfo.Data).Name,
                    //                                   dropInfo.InsertPosition & ~RelativeInsertPosition.TargetItemCenter,
                    //                                   dropInfo.TargetItem == null ? "null" : ((TreeItem)dropInfo.TargetItem).Name));

                    TreeItem toMove = (TreeItem)dropInfo.Data;

                    // Group items are distinguishable from property items by means of the PropType value stored on them
                    if ((PropType)toMove.Item == PropType.Group)
                    {
                        SelectedProfile.MoveFullDetailsGroup(toMove, target, before);
                    }
                    else
                    {
                        SelectedProfile.MoveFullDetailsProperty(toMove, target, before);
                    }

                    IsDirty           = true;
                    toMove.IsSelected = true;  //todo make work
                }
            }
            else if (Target == ProfileControls.PreviewDetails)
            {
                PropertyListEntry target = dropInfo.TargetItem as PropertyListEntry;
                bool before = (dropInfo.InsertPosition & ~RelativeInsertPosition.TargetItemCenter) == RelativeInsertPosition.BeforeTargetItem;

                if (Source == ProfileControls.FullDetails)
                {
                    string property = ((TreeItem)dropInfo.Data).Name;
                    SelectedProfile.AddPreviewDetailsProperty(property, target, before);
                }
                else if (Source == ProfileControls.PreviewDetails)
                {
                    PropertyListEntry property = (PropertyListEntry)dropInfo.Data;
                    SelectedProfile.MovePreviewDetailsProperty(property, target, before);
                }
                IsDirty = true;
            }
            else if (Target == ProfileControls.InfoTip)
            {
                PropertyListEntry target = dropInfo.TargetItem as PropertyListEntry;
                bool before = (dropInfo.InsertPosition & ~RelativeInsertPosition.TargetItemCenter) == RelativeInsertPosition.BeforeTargetItem;

                if (Source == ProfileControls.FullDetails)
                {
                    string property = ((TreeItem)dropInfo.Data).Name;
                    SelectedProfile.AddInfoTipProperty(property, target, before);
                }
                else if (Source == ProfileControls.InfoTip)
                {
                    PropertyListEntry property = (PropertyListEntry)dropInfo.Data;
                    SelectedProfile.MoveInfoTipProperty(property, target, before);
                }
                IsDirty = true;
            }
        }
Ejemplo n.º 25
0
        private void InvokeUpdateKeyboardPreview(object sender, ElapsedEventArgs e)
        {
            if (_blurProgress > 2)
            {
                _blurProgress = 0;
            }
            _blurProgress = _blurProgress + 0.025;
            BlurRadius    = (Math.Sin(_blurProgress * Math.PI) + 1) * 10 + 10;

            if (SelectedProfile == null || _deviceManager.ActiveKeyboard == null)
            {
                var preview = new DrawingImage();
                preview.Freeze();
                KeyboardPreview = preview;
                return;
            }

            var keyboardRect = _deviceManager.ActiveKeyboard.KeyboardRectangle(4);
            var visual       = new DrawingVisual();

            using (var drawingContext = visual.RenderOpen())
            {
                // Setup the DrawingVisual's size
                drawingContext.PushClip(new RectangleGeometry(keyboardRect));
                drawingContext.DrawRectangle(new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)), null, keyboardRect);

                // Draw the layers
                var drawLayers = SelectedProfile.GetRenderLayers <ProfilePreviewDataModel>(
                    new ProfilePreviewDataModel(), false, false, true);
                foreach (var layer in drawLayers)
                {
                    layer.Draw(null, drawingContext, true, false);
                }

                // Get the selection color
                var accentColor = ThemeManager.DetectAppStyle(Application.Current)?.Item2?.Resources["AccentColor"];
                if (accentColor == null)
                {
                    return;
                }

                var pen = new Pen(new SolidColorBrush((Color)accentColor), 0.4);

                // Draw the selection outline and resize indicator
                if (SelectedLayer != null && SelectedLayer.MustDraw())
                {
                    var layerRect = ((KeyboardPropertiesModel)SelectedLayer.Properties).GetRect();
                    // Deflate the rect so that the border is drawn on the inside
                    layerRect.Inflate(-0.2, -0.2);

                    // Draw an outline around the selected layer
                    drawingContext.DrawRectangle(null, pen, layerRect);
                    // Draw a resize indicator in the bottom-right
                    drawingContext.DrawLine(pen,
                                            new Point(layerRect.BottomRight.X - 1, layerRect.BottomRight.Y - 0.5),
                                            new Point(layerRect.BottomRight.X - 1.2, layerRect.BottomRight.Y - 0.7));
                    drawingContext.DrawLine(pen,
                                            new Point(layerRect.BottomRight.X - 0.5, layerRect.BottomRight.Y - 1),
                                            new Point(layerRect.BottomRight.X - 0.7, layerRect.BottomRight.Y - 1.2));
                    drawingContext.DrawLine(pen,
                                            new Point(layerRect.BottomRight.X - 0.5, layerRect.BottomRight.Y - 0.5),
                                            new Point(layerRect.BottomRight.X - 0.7, layerRect.BottomRight.Y - 0.7));
                }

                // Remove the clip
                drawingContext.Pop();
            }
            var drawnPreview = new DrawingImage(visual.Drawing);

            drawnPreview.Freeze();
            KeyboardPreview = drawnPreview;
        }
Ejemplo n.º 26
0
 public void SaveOptions(GameSettings gameSettings, SelectedProfile selectedProfile)
 {
     OnSaveOptions?.Invoke(gameSettings, selectedProfile);
 }
Ejemplo n.º 27
0
        private DrawingImage RenderLayers()
        {
            var renderLayers = GetRenderLayers();
            // Draw the current frame to the preview
            var keyboardRect = _deviceManager.ActiveKeyboard.KeyboardRectangle();
            var visual       = new DrawingVisual();

            using (var drawingContext = visual.RenderOpen())
            {
                // Setup the DrawingVisual's size
                drawingContext.PushClip(new RectangleGeometry(keyboardRect));
                drawingContext.DrawRectangle(new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)), null, keyboardRect);

                // Draw the layers
                foreach (var layer in renderLayers)
                {
                    layer.Update(null, true, false);
                    if (layer.LayerType.ShowInEdtor)
                    {
                        layer.Draw(null, drawingContext, true, false);
                    }
                }

                // Get the selection color
                var accentColor = ThemeManager.DetectAppStyle(Application.Current)?.Item2?.Resources["AccentColor"];
                if (accentColor == null)
                {
                    var preview = new DrawingImage();
                    preview.Freeze();
                    KeyboardPreview = preview;
                    return(new DrawingImage());
                }

                var pen = new Pen(new SolidColorBrush((Color)accentColor), 0.4);

                // Draw the selection outline and resize indicator
                if (SelectedLayer != null && SelectedLayer.MustDraw())
                {
                    var layerRect = SelectedLayer.Properties.PropertiesRect();
                    // Deflate the rect so that the border is drawn on the inside
                    layerRect.Inflate(-0.2, -0.2);

                    // Draw an outline around the selected layer
                    drawingContext.DrawRectangle(null, pen, layerRect);
                    // Draw a resize indicator in the bottom-right
                    drawingContext.DrawLine(pen,
                                            new Point(layerRect.BottomRight.X - 1, layerRect.BottomRight.Y - 0.5),
                                            new Point(layerRect.BottomRight.X - 1.2, layerRect.BottomRight.Y - 0.7));
                    drawingContext.DrawLine(pen,
                                            new Point(layerRect.BottomRight.X - 0.5, layerRect.BottomRight.Y - 1),
                                            new Point(layerRect.BottomRight.X - 0.7, layerRect.BottomRight.Y - 1.2));
                    drawingContext.DrawLine(pen,
                                            new Point(layerRect.BottomRight.X - 0.5, layerRect.BottomRight.Y - 0.5),
                                            new Point(layerRect.BottomRight.X - 0.7, layerRect.BottomRight.Y - 0.7));
                }

                SelectedProfile?.RaiseDeviceDrawnEvent(new ProfileDeviceEventsArg(DrawType.Preview, null, true,
                                                                                  drawingContext));

                // Remove the clip
                drawingContext.Pop();
            }
            var drawnPreview = new DrawingImage(visual.Drawing);

            drawnPreview.Freeze();

            // Setup layers for the next frame
            if (_moduleModel.IsInitialized && ActiveWindowHelper.MainWindowActive)
            {
                _moduleModel.PreviewLayers = renderLayers;
            }

            return(drawnPreview);
        }
Ejemplo n.º 28
0
 private void OnLoadGame(GameData gameData, SelectedProfile selectedProfile)
 {
     Debug.Log($"Successfully Loaded Game for: {selectedProfile.profileName}");
 }
Ejemplo n.º 29
0
        protected override void CompileLayout(SuperGumpLayout layout)
        {
            layout.Add(
                "background",
                () =>
            {
                AddBackground(0, 40, 775, 553, 2600);
                AddImage(269, 18, 1419);
                AddImage(346, 0, 1417);
                AddImage(355, 9, 9012, 60);
                AddBackground(35, 100, 703, 444, 9270);
                AddBackground(49, 112, 676, 420, 9200);
                AddBackground(56, 119, 362, 409, 9260);
                AddBackground(423, 119, 296, 409, 9260);

                AddLabel(47, 80, 60, @"Zombieland!!");
                AddItem(146, 58, 9685);

                AddLabel(528, 55, 2049, @"Current Participants:");
                AddLabel(670, 55, 60, ZombieEvent.GetParticipantCount().ToString());

                AddLabel(528, 75, 2049, @"Zombieland Rewards");
                AddButton(660, 75, 247, 248, b =>
                {
                    if (Avatar == null)
                    {
                        new ZombieEventRewardsUI(User, UserProfile).Send();
                    }
                    else
                    {
                        Avatar.SendMessage(61, "You cannot view rewards while participating in the event.  Please log back into your normal character first.");
                    }
                });

                AddItem(351, 130, 4476);
                AddItem(324, 156, 7397, 1270);
                AddItem(333, 154, 7393, 1270);
                AddItem(329, 162, 3795);

                var zinstance = ZombieEvent.GetInstance();

                if (User.AccessLevel >= AccessLevel.GameMaster)
                {
                    if (zinstance == null)
                    {
                        AddLabel(77, 551, 1270, "Start Event?");
                        AddButton(173, 549, 247, 248, b =>
                        {
                            var instance = new ZombieInstance();
                            ZombieEvent.ZombieEvents.Add(instance.Uid, instance);
                            instance.init();
                        });
                    }
                    else
                    {
                        AddLabel(77, 551, 1270, "Stop Event?");
                        AddButton(173, 549, 247, 248, b =>
                        {
                            zinstance.Stop();
                        });
                    }
                }

                if (zinstance != null && !UserProfile.Active)
                {
                    AddLabel(529, 551, 1270, "Join the Event?");
                    AddButton(638, 549, 247, 248, b =>
                    {
                        if (User.Alive)
                        {
                            zinstance.JoinZombieInstance(User);
                        }
                        else
                        {
                            User.SendMessage(54, "You must be alive to join the event!");
                        }
                    });
                }
                else if (zinstance != null && UserProfile.Active)
                {
                    AddLabel(529, 551, 1270, "Leave the Event?");
                    AddButton(638, 549, 247, 248, b =>
                    {
                        zinstance.LeaveZombieInstance(UserProfile);

                        /*if (UserProfile.LeaveEventTimer == null || !UserProfile.LeaveEventTimer.Running)
                         *  ZombieEvent.LeaveEvent(User);
                         * else
                         * {
                         *  new DialogGump(User, this, 0, 0, null, null, 7004, a =>
                         *  {
                         *      if (User.Map == Map.ZombieLand)
                         *      {
                         *          if (ZombieEvent.GetInstance() != null)
                         *          {
                         *              var zevent = ZombieEvent.GetInstance();
                         *              if (zevent != null && UserProfile.LeaveEventTimer != null && UserProfile.LeaveEventTimer.Running)
                         *              {
                         *                  User.SendMessage(54, "You have succesfully left the event.");
                         *                  UserProfile.LeaveEventTimer.Stop();
                         *                  zevent.HandlePlayerDeathLeave(User, null);
                         *              }
                         *          }
                         *      }
                         *  })
                         *  {
                         *      Title = "Leave Event?",
                         *      Html = "Are you sure you wish to leave the event before the leave timer finishes?  You will lose all your items and your current location will not be saved.",
                         *      HtmlColor = DefaultHtmlColor
                         *  }.Send();*/
                    });
                }
            });

            layout.Add(
                "Search",
                () =>
            {
                AddLabel(72, 128, 2049, @"Search");
                AddLabel(72, 146, 1258, @"Enter Character Name");
                AddBackground(70, 164, 139, 29, 3000);

                AddTextEntryLimited(73, 170, 161, 24, TextHue, String.Empty, 20, (b, t) => SearchEmail = t);

                AddButton(213, 168, 4023, 4025, b =>
                {
                    SearchText = SearchEmail;
                    Page       = 0;
                    Refresh(true);
                });
            });

            layout.Add(
                "Profiles",
                () =>
            {
                AddLabel(73, 203, 1258, @"Zombieland Profiles");
                AddLabel(219, 203, 1258, @"Rank");
                AddLabel(270, 203, 1258, @"Score");
                AddLabel(326, 203, 1258, @"View Profile");

                AddBackground(71, 222, 335, 259, 3000);

                if (PageCount - 1 > Page)
                {
                    AddButton(384, 491, 5601, 5605, NextPage);
                }

                if (Page > 0)
                {
                    AddButton(75, 491, 5603, 5607, PreviousPage);
                }
            });

            layout.Add(
                "SelectedProfile",
                () =>
            {
                if (SelectedProfile != null && ZEvent != null)
                {
                    AddLabel(440, 131, 1258, @"Character Name");
                    AddLabel(445, 150, 2049, SelectedProfile.Owner.RawName);

                    AddLabel(570, 131, 1258, @"Murders");
                    AddHtml(569, 151, 46, 22, ("<p align=\"center\">" + SelectedProfile.Kills).WrapUOHtmlColor(KnownColor.White), false, false);

                    AddLabel(654, 131, 1258, @"Deaths");
                    AddHtml(651, 151, 46, 22, ("<p align=\"center\">" + SelectedProfile.Deaths).WrapUOHtmlColor(KnownColor.White), false, false);

                    AddLabel(440, 179, 1258, @"Creature Kills");

                    AddLabel(460, 278, 1258, @"Tentacle");
                    AddHtml(463, 293, 46, 22, ("<p align=\"left\">" + SelectedProfile.GetTentacleKills(ZEvent.Uid)).WrapUOHtmlColor(KnownColor.White), false, false);
                    AddItem(445, 240, 9672);

                    AddLabel(439, 360, 1258, @"Zombie");
                    AddHtml(440, 375, 46, 22, ("<p align=\"left\">" + SelectedProfile.GetZombieKills(ZEvent.Uid)).WrapUOHtmlColor(KnownColor.White), false, false);
                    AddItem(450, 315, 9685);

                    AddLabel(630, 440, 1258, @"Dk. Creeper");
                    AddHtml(650, 455, 46, 22, ("<p align=\"right\">" + SelectedProfile.GetGoreFiendKills(ZEvent.Uid)).WrapUOHtmlColor(KnownColor.White), false, false);
                    AddItem(639, 394, 9773);

                    AddHtml(548, 497, 46, 22, ("<p align=\"center\">" + SelectedProfile.GetVitriolKills(ZEvent.Uid)).WrapUOHtmlColor(KnownColor.White), false, false);
                    AddItem(528, 431, 11650);
                    AddLabel(545, 482, 1258, @"Abomination");

                    AddLabel(529, 360, 137, @"Chaos Dragon");
                    AddHtml(548, 375, 46, 22, ("<p align=\"center\">" + SelectedProfile.DragonBossDamage).WrapUOHtmlColor(KnownColor.White), false, false);
                    AddItem(545, 302, 9780);

                    AddLabel(630, 281, 1258, @"Treefellow");
                    AddHtml(643, 294, 46, 22, ("<p align=\"right\">" + SelectedProfile.GetTreefellowKills(ZEvent.Uid)).WrapUOHtmlColor(KnownColor.White), false, false);
                    AddItem(639, 243, 9761);

                    AddLabel(661, 360, 1258, @"Daemon");
                    AddHtml(658, 374, 46, 22, ("<p align=\"right\">" + SelectedProfile.GetDaemonKills(ZEvent.Uid)).WrapUOHtmlColor(KnownColor.White), false, false);
                    AddItem(669, 315, 8403);

                    AddLabel(455, 440, 1258, @"Fey Warrior");
                    AddHtml(456, 455, 46, 22, ("<p align=\"left\">" + SelectedProfile.GetFeyKills(ZEvent.Uid)).WrapUOHtmlColor(KnownColor.White), false, false);
                    AddItem(454, 397, 9609);

                    AddLabel(528, 234, 1258, @"Zombie Spider");
                    AddHtml(548, 250, 46, 22, ("<p align=\"center\">" + SelectedProfile.GetSpiderKills(ZEvent.Uid)).WrapUOHtmlColor(KnownColor.White), false, false);
                    AddItem(536, 196, 9668);
                }
            });

            Dictionary <int, PlayerZombieProfile> range = GetListRange();

            if (range.Count > 0 && ZEvent != null)
            {
                CompileEntryLayout(layout, range);
            }
        }
Ejemplo n.º 30
0
 public void SaveGame(GameData gameData, SelectedProfile selectedProfile)
 {
     OnSaveGame?.Invoke(gameData, selectedProfile);
 }