public override Visual GetControl()
        {
            var selectButton = new Button {
                Content = "Select", Padding = new Thickness(8, 0, 8, 0), Margin = new Thickness(8, 0, 0, 0)
            };

            selectButton.Click += (sender, e) => {
                var wnd = new Window_ProcessSelection {
                    ButtonLabel = "Select", Title = "Pick process"
                };
                if (wnd.ShowDialog() == true && !string.IsNullOrWhiteSpace(wnd.ChosenExecutableName))
                {
                    ProcessName = wnd.ChosenExecutableName;
                }
            };

            return(new StackPanel {
                Orientation = Orientation.Horizontal
            }
                   .WithChild(new Label {
                Content = "Is process"
            })
                   .WithChild(new TextBox {
                MinWidth = 80, VerticalAlignment = VerticalAlignment.Center, Padding = new Thickness(3)
            }
                              .WithBinding(TextBox.TextProperty, this, nameof(ProcessName), BindingMode.TwoWay, updateSourceTrigger: UpdateSourceTrigger.PropertyChanged))
                   .WithChild(selectButton)
                   .WithChild(new Label {
                Content = "running"
            }));
        }
Example #2
0
        public override Visual GetControl()
        {
            var selectButton = new Button {
                Content = "Select", Padding = new System.Windows.Thickness(8, 0, 8, 0), Margin = new System.Windows.Thickness(8, 0, 0, 0)
            };

            selectButton.Click += (sender, e) => {
                var wnd = new Window_ProcessSelection {
                    ButtonLabel = "Select"
                };
                if (wnd.ShowDialog() == true && !string.IsNullOrWhiteSpace(wnd.ChosenExecutableName))
                {
                    ProcessName = wnd.ChosenExecutableName;
                }
            };

            return(new StackPanel {
                Orientation = Orientation.Horizontal
            }
                   .WithChild(new Label {
                Content = "Is process"
            })
                   .WithChild(new TextBox {
                MinWidth = 80
            }
                              .WithBinding(TextBox.TextProperty, this, "ProcessName", BindingMode.TwoWay))
                   .WithChild(selectButton)
                   .WithChild(new Label {
                Content = "running"
            }));
        }
Example #3
0
        private void AddProfile_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Window_ProcessSelection dialog = new Window_ProcessSelection {
                CheckCustomPathExists = true, ButtonLabel = "Add Profile", Title = "Add Profile"
            };

            if (dialog.ShowDialog() == true && !string.IsNullOrWhiteSpace(dialog.ChosenExecutablePath))   // do not need to check if dialog is already in excluded_programs since it is a Set and only contains unique items by definition

            {
                string filename = Path.GetFileName(dialog.ChosenExecutablePath.ToLowerInvariant());

                if (Global.LightingStateManager.Events.ContainsKey(filename))
                {
                    if (Global.LightingStateManager.Events[filename] is GameEvent_Aurora_Wrapper)
                    {
                        Global.LightingStateManager.Events.Remove(filename);
                    }
                    else
                    {
                        MessageBox.Show("Profile for this application already exists.");
                        return;
                    }
                }

                GenericApplication gen_app_pm = new GenericApplication(filename);
                gen_app_pm.Initialize();
                ((GenericApplicationSettings)gen_app_pm.Settings).ApplicationName = Path.GetFileNameWithoutExtension(filename);

                System.Drawing.Icon ico = System.Drawing.Icon.ExtractAssociatedIcon(dialog.ChosenExecutablePath.ToLowerInvariant());

                if (!Directory.Exists(gen_app_pm.GetProfileFolderPath()))
                {
                    Directory.CreateDirectory(gen_app_pm.GetProfileFolderPath());
                }

                using (var icon_asbitmap = ico.ToBitmap())
                {
                    icon_asbitmap.Save(Path.Combine(gen_app_pm.GetProfileFolderPath(), "icon.png"), System.Drawing.Imaging.ImageFormat.Png);
                }
                ico.Dispose();

                Global.LightingStateManager.RegisterEvent(gen_app_pm);
                ConfigManager.Save(Global.Configuration);
                GenerateProfileStack(filename);
            }
        }