Exemplo n.º 1
0
        public Main()
        {
            InitializeComponent();

            if (!DesignerProperties.GetIsInDesignMode(this))
            {
                var directories = new Directories();

                Logging.LogDirectory = directories.Logs;

                var config = Persistence.LoadModel <Configuration>(Path.Combine(directories.AppData, "config.json"));

                //supplying custom directories
                config.Directories      = directories;
                config.PropertyChanged += Config_PropertyChanged;

                server = new AresServer(config);
                server.PropertyChanged += Server_PropertyChanged;

                DataContext = server;

                JumpList list = new JumpList {
                    ShowRecentCategory   = false,
                    ShowFrequentCategory = false
                };

                list.JumpItems.Add(new JumpTask()
                {
                    Title            = "Start server",
                    Arguments        = "-start_server",
                    ApplicationPath  = App.Filename,
                    WorkingDirectory = Directories.BaseDirectory,
                });

                list.JumpItems.Add(new JumpTask()
                {
                    Title            = "Stop server",
                    Arguments        = "-stop_server",
                    ApplicationPath  = App.Filename,
                    WorkingDirectory = Directories.BaseDirectory,
                });

                list.JumpItems.Add(new JumpTask()
                {
                    Title           = "Logs",
                    ApplicationPath = config.Directories.Logs,
                    CustomCategory  = "Places"
                });

                list.JumpItems.Add(new JumpTask()
                {
                    Title           = "Plugins",
                    ApplicationPath = config.Directories.Plugins,
                    CustomCategory  = "Places"
                });

                JumpList.SetJumpList(Application.Current, list);
            }
        }
Exemplo n.º 2
0
        public Settings(AresServer server)
        {
            InitializeComponent();
            DataContext = server;

            Loaded   += Options_Loaded;
            Unloaded += Options_Unloaded;
        }
Exemplo n.º 3
0
        public Main()
        {
            InitializeComponent();

            if (!DesignerProperties.GetIsInDesignMode(this))
            {
                server = new AresServer(Config.Load(Directories.AppData, "Config.xml"));
                server.PropertyChanged += new PropertyChangedEventHandler(Server_PropertyChanged);

                DataContext = server;
            }
        }
Exemplo n.º 4
0
        private void Options_Loaded(object sender, RoutedEventArgs e)
        {
            AresServer server = (AresServer)DataContext;

            foreach (var plugin in ((PluginHost)server.PluginHost).Plugins)
            {
                TreeViewItem newitem = new TreeViewItem();

                newitem.Header = plugin.Name;
                newitem.Tag    = plugin;

                FrameworkElement root = null;

                if (plugin.Plugin is IWPFPlugin)
                {
                    var iface = (IWPFPlugin)plugin.Plugin;
                    if (iface.GUI == null)
                    {
                        continue;
                    }

                    root = iface.GUI;
                }
                else if (plugin.Plugin is IWinFormsPlugin)
                {
                    var iface = (IWinFormsPlugin)plugin.Plugin;
                    if (iface.GUI == null)
                    {
                        continue;
                    }

                    root = new WindowsFormsHost()
                    {
                        Child = iface.GUI
                    };
                }
                else
                {
                    continue;
                }

                root.SetBinding(VisibilityProperty, new Binding("IsSelected")
                {
                    Source    = newitem,
                    Converter = (BooleanToVisibilityConverter)TryFindResource("BooleanToVisibility")
                });

                Grid.SetColumn(root, 1);

                optPlugins.Items.Add(newitem);
                LayoutRoot.Children.Add(root);
            }
        }
Exemplo n.º 5
0
        private void Options_Unloaded(object sender, RoutedEventArgs e)
        {
            AresServer server = (AresServer)DataContext;

            foreach (var plugin in ((PluginHost)server.PluginHost).Plugins)
            {
                if (plugin.Plugin is IWPFPlugin)
                {
                    var iface = (IWPFPlugin)plugin.Plugin;
                    if (iface.GUI == null)
                    {
                        continue;
                    }

                    LayoutRoot.Children.Remove(iface.GUI);
                }
                else if (plugin.Plugin is IWinFormsPlugin)
                {
                    var iface = (IWinFormsPlugin)plugin.Plugin;
                    if (iface.GUI == null)
                    {
                        continue;
                    }

                    foreach (var child in LayoutRoot.Children)
                    {
                        if (child is WindowsFormsHost)
                        {
                            var host = (WindowsFormsHost)child;
                            if (host.Child == iface.GUI)
                            {
                                LayoutRoot.Children.Remove(host);
                                host.Child.Dispose();
                                host.Child = null;
                                host.Dispose();
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        public Main()
        {
            InitializeComponent();

            if (!DesignerProperties.GetIsInDesignMode(this))
            {
                var directories = new Directories()
                {
                    //AppData = "Custom Data Location"
                };

                directories.EnsureExists();
                Logging.LogDirectory = directories.Logs;

                var config = Persistence.LoadModel <Configuration>(Path.Combine(directories.AppData, "config.json"));

                config.Directories      = directories;
                config.PropertyChanged += Config_PropertyChanged;

                server = new AresServer(config);

                server.PluginHost       = new ServerPluginHostCore(server);
                server.PropertyChanged += Server_PropertyChanged;

                DataContext = server;

                JumpList list = new JumpList {
                    ShowRecentCategory   = false,
                    ShowFrequentCategory = false
                };

                /*
                 * list.JumpItems.Add(new JumpTask() {
                 *  Title = AppStrings.LabelStartServer,
                 *  Arguments = "-start_server",
                 *  ApplicationPath = App.Filename,
                 *  WorkingDirectory = Directories.BaseDirectory,
                 * });
                 *
                 * list.JumpItems.Add(new JumpTask() {
                 *  Title = AppStrings.LabelStopServer,
                 *  Arguments = "-stop_server",
                 *  ApplicationPath = App.Filename,
                 *  WorkingDirectory = Directories.BaseDirectory,
                 * });
                 */
                list.JumpItems.Add(new JumpTask()
                {
                    Title           = AppStrings.LabelLogs,
                    ApplicationPath = config.Directories.Logs,
                    CustomCategory  = AppStrings.JumpCategory
                });

                list.JumpItems.Add(new JumpTask()
                {
                    Title           = AppStrings.LabelPlugins,
                    ApplicationPath = config.Directories.Plugins,
                    CustomCategory  = AppStrings.JumpCategory
                });

                JumpList.SetJumpList(System.Windows.Application.Current, list);
            }
        }