Esempio n. 1
0
 private void Load()
 {
     ApplicationFilePath = persistentSettings.Load("Path", ApplicationFilePath);
     Arguments           = persistentSettings.Load("Arguments", Arguments);
     WorkingFolderPath   = persistentSettings.Load("Folder", WorkingFolderPath);
     RegFilePath         = persistentSettings.Load("RegFile", RegFilePath);
     ShortcutName        = persistentSettings.Load("Shortcut", ShortcutName);
     OneInstance         = persistentSettings.Load("OneInstance", OneInstance);
     DisableThemes       = persistentSettings.Load("DisableThemes", DisableThemes);
 }
Esempio n. 2
0
        public static void Main(string[] argsArray)
        {
            Thread.CurrentThread.SetInvariantCulture();

            // This is required to get all required build tools in path
            // See https://github.com/fusetools/Fuse/issues/4245 for details
            if (Platform.OperatingSystem == OS.Mac)
            {
                Environment.SetEnvironmentVariable("PATH", "/usr/local/bin:" + Environment.GetEnvironmentVariable("PATH"));
            }

            var argumentList = argsArray.ToList();
            var fuse         = FuseApi.Initialize("Designer", argumentList);
            var shell        = new Shell();
            var errors       = new ReplaySubject <Exception>(1);

            if (!Application.InitializeAsDocumentApp(argumentList, "Fusetools.Fuse"))
            {
                return;
            }

            // Initialize console redirection early to show output during startup in debug window
            ConsoleOutputWindow.InitializeConsoleRedirection();

            UserSettings.Settings = PersistentSettings.Load(
                usersettingsfile: fuse.UserDataDir / new FileName("designer-config.json"),
                onError: errors.OnNext);

            var daemon = fuse.ConnectOrSpawnAsync("Designer").ToObservable().Switch();

            //var previewPlatform = Platform.OperatingSystem == OS.Mac
            //	? (IPlatform)new MacPlatform(fuse.MonoExe.Value.NativePath)
            //	: (IPlatform)new WindowsPlatform();

            var previewService = new PreviewService();

            Application.Terminating += previewService.Dispose;

            var openProject = new OpenProject(
                previewService,
                shell, fuse, daemon,
                errors);

            var createProject = new CreateProject(fuse);
            var splashWindow  = new Dashboard(createProject, fuse);


            Application.CreateDocumentWindow = document => openProject.Execute(document, argumentList.ToArray());

            Application.LaunchedWithoutDocuments = splashWindow.Show;

            Application.Run();
        }
Esempio n. 3
0
        public Monitor()
        {
            AppendLog("--------------------Start Monitor-----------------");
            InitializeTerminalInfo();

            endPoint2PidMap = new Dictionary <String, Int32>();
            GetNetstat(null);

            pid2InfoMap = new Dictionary <Int32, ProcessDynamicInfo>();

            capDev = CaptureDeviceList.Instance[0];
            capDev.OnPacketArrival += new PacketArrivalEventHandler(capDev_OnPacketArrival);

            settings = new PersistentSettings();
            settings.Load(CONFIG_FILE_NAME);
            hardwareMonitor = new DynamicHardwareMonitor(settings, new UpdateVisitor());

            InitializeTimers();
            InitializeMonitorTriggers();
            StopBeeping();
        }
Esempio n. 4
0
    public static void Main()
    {
        if (!IsAdministrator())
        {
            // Restart and run as admin
            ProcessStartInfo startInfo = new ProcessStartInfo(Application.ExecutablePath);
            startInfo.Verb = "runas";
            Process.Start(startInfo);
            Application.Exit();
            return;
        }

        Directory.SetCurrentDirectory(Application.StartupPath);

        settings.Load(Path.ChangeExtension(Application.ExecutablePath, ".config"));
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        MyApplicationContext app = new MyApplicationContext(settings);

        Application.Run(app);
        Environment.Exit(0);
    }
Esempio n. 5
0
        public MainForm()
        {
            InitializeComponent();

            // check if the LibreHardwareMonitorLib assembly has the correct version
            if (Assembly.GetAssembly(typeof(Computer)).GetName().Version != Assembly.GetExecutingAssembly().GetName().Version)
            {
                MessageBox.Show("The version of the file LibreHardwareMonitorLib.dll is incompatible.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(0);
            }

            _settings = new PersistentSettings();
            _settings.Load(Path.ChangeExtension(Application.ExecutablePath, ".config"));

            _unitManager = new UnitManager(_settings);

            // make sure the buffers used for double buffering are not disposed
            // after each draw call
            BufferedGraphicsManager.Current.MaximumBuffer = Screen.PrimaryScreen.Bounds.Size;

            // set the DockStyle here, to avoid conflicts with the MainMenu
            splitContainer.Dock = DockStyle.Fill;

            Font          = SystemFonts.MessageBoxFont;
            treeView.Font = SystemFonts.MessageBoxFont;

            // Set the bounds immediately, so that our child components can be
            // properly placed.
            Bounds = new Rectangle
            {
                X      = _settings.GetValue("mainForm.Location.X", Location.X),
                Y      = _settings.GetValue("mainForm.Location.Y", Location.Y),
                Width  = _settings.GetValue("mainForm.Width", 470),
                Height = _settings.GetValue("mainForm.Height", 640)
            };

            _plotPanel = new PlotPanel(_settings, _unitManager)
            {
                Font = SystemFonts.MessageBoxFont, Dock = DockStyle.Fill
            };

            nodeCheckBox.IsVisibleValueNeeded += NodeCheckBox_IsVisibleValueNeeded;
            nodeTextBoxText.DrawText          += NodeTextBoxText_DrawText;
            nodeTextBoxValue.DrawText         += NodeTextBoxText_DrawText;
            nodeTextBoxMin.DrawText           += NodeTextBoxText_DrawText;
            nodeTextBoxMax.DrawText           += NodeTextBoxText_DrawText;
            nodeTextBoxText.EditorShowing     += NodeTextBoxText_EditorShowing;

            foreach (TreeColumn column in treeView.Columns)
            {
                column.Width = Math.Max(20, Math.Min(400, _settings.GetValue("treeView.Columns." + column.Header + ".Width", column.Width)));
            }

            TreeModel treeModel = new TreeModel();

            _root = new Node(Environment.MachineName)
            {
                Image = EmbeddedResources.GetImage("computer.png")
            };

            treeModel.Nodes.Add(_root);
            treeView.Model = treeModel;

            _computer = new Computer(_settings);

            _systemTray = new SystemTray(_computer, _settings, _unitManager);
            _systemTray.HideShowCommand += HideShowClick;
            _systemTray.ExitCommand     += ExitClick;

            int p = (int)Environment.OSVersion.Platform;

            if ((p == 4) || (p == 128))
            { // Unix
                treeView.RowHeight           = Math.Max(treeView.RowHeight, 18);
                splitContainer.BorderStyle   = BorderStyle.None;
                splitContainer.Border3DStyle = Border3DStyle.Adjust;
                splitContainer.SplitterWidth = 4;
                treeView.BorderStyle         = BorderStyle.Fixed3D;
                _plotPanel.BorderStyle       = BorderStyle.Fixed3D;
                gadgetMenuItem.Visible       = false;
                minCloseMenuItem.Visible     = false;
                minTrayMenuItem.Visible      = false;
                startMinMenuItem.Visible     = false;
            }
            else
            { // Windows
                treeView.RowHeight       = Math.Max(treeView.Font.Height + 1, 18);
                _gadget                  = new SensorGadget(_computer, _settings, _unitManager);
                _gadget.HideShowCommand += HideShowClick;
                _wmiProvider             = new WmiProvider(_computer);
            }

            _logger = new Logger(_computer);

            _plotColorPalette     = new Color[13];
            _plotColorPalette[0]  = Color.Blue;
            _plotColorPalette[1]  = Color.OrangeRed;
            _plotColorPalette[2]  = Color.Green;
            _plotColorPalette[3]  = Color.LightSeaGreen;
            _plotColorPalette[4]  = Color.Goldenrod;
            _plotColorPalette[5]  = Color.DarkViolet;
            _plotColorPalette[6]  = Color.YellowGreen;
            _plotColorPalette[7]  = Color.SaddleBrown;
            _plotColorPalette[8]  = Color.RoyalBlue;
            _plotColorPalette[9]  = Color.DeepPink;
            _plotColorPalette[10] = Color.MediumSeaGreen;
            _plotColorPalette[11] = Color.Olive;
            _plotColorPalette[12] = Color.Firebrick;

            _computer.HardwareAdded   += HardwareAdded;
            _computer.HardwareRemoved += HardwareRemoved;
            _computer.Open();

            timer.Enabled = true;

            UserOption showHiddenSensors = new UserOption("hiddenMenuItem", false, hiddenMenuItem, _settings);

            showHiddenSensors.Changed += delegate
            {
                treeModel.ForceVisible = showHiddenSensors.Value;
            };

            UserOption showValue = new UserOption("valueMenuItem", true, valueMenuItem, _settings);

            showValue.Changed += delegate
            {
                treeView.Columns[1].IsVisible = showValue.Value;
            };

            UserOption showMin = new UserOption("minMenuItem", false, minMenuItem, _settings);

            showMin.Changed += delegate
            {
                treeView.Columns[2].IsVisible = showMin.Value;
            };

            UserOption showMax = new UserOption("maxMenuItem", true, maxMenuItem, _settings);

            showMax.Changed += delegate
            {
                treeView.Columns[3].IsVisible = showMax.Value;
            };

            var _ = new UserOption("startMinMenuItem", false, startMinMenuItem, _settings);

            _minimizeToTray          = new UserOption("minTrayMenuItem", true, minTrayMenuItem, _settings);
            _minimizeToTray.Changed += delegate
            {
                _systemTray.IsMainIconEnabled = _minimizeToTray.Value;
            };

            _minimizeOnClose = new UserOption("minCloseMenuItem", false, minCloseMenuItem, _settings);

            _autoStart          = new UserOption(null, _startupManager.Startup, startupMenuItem, _settings);
            _autoStart.Changed += delegate
            {
                try
                {
                    _startupManager.Startup = _autoStart.Value;
                }
                catch (InvalidOperationException)
                {
                    MessageBox.Show("Updating the auto-startup option failed.", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    _autoStart.Value = _startupManager.Startup;
                }
            };

            _readMainboardSensors          = new UserOption("mainboardMenuItem", true, mainboardMenuItem, _settings);
            _readMainboardSensors.Changed += delegate
            {
                _computer.IsMotherboardEnabled = _readMainboardSensors.Value;
            };

            _readCpuSensors          = new UserOption("cpuMenuItem", true, cpuMenuItem, _settings);
            _readCpuSensors.Changed += delegate
            {
                _computer.IsCpuEnabled = _readCpuSensors.Value;
            };

            _readRamSensors          = new UserOption("ramMenuItem", true, ramMenuItem, _settings);
            _readRamSensors.Changed += delegate
            {
                _computer.IsMemoryEnabled = _readRamSensors.Value;
            };

            _readGpuSensors          = new UserOption("gpuMenuItem", true, gpuMenuItem, _settings);
            _readGpuSensors.Changed += delegate
            {
                _computer.IsGpuEnabled = _readGpuSensors.Value;
            };

            _readFanControllersSensors          = new UserOption("fanControllerMenuItem", true, fanControllerMenuItem, _settings);
            _readFanControllersSensors.Changed += delegate
            {
                _computer.IsControllerEnabled = _readFanControllersSensors.Value;
            };

            _readHddSensors          = new UserOption("hddMenuItem", true, hddMenuItem, _settings);
            _readHddSensors.Changed += delegate
            {
                _computer.IsStorageEnabled = _readHddSensors.Value;
            };

            _readNicSensors          = new UserOption("nicMenuItem", true, nicMenuItem, _settings);
            _readNicSensors.Changed += delegate
            {
                _computer.IsNetworkEnabled = _readNicSensors.Value;
            };

            _showGadget          = new UserOption("gadgetMenuItem", false, gadgetMenuItem, _settings);
            _showGadget.Changed += delegate
            {
                if (_gadget != null)
                {
                    _gadget.Visible = _showGadget.Value;
                }
            };

            celsiusMenuItem.Checked    = _unitManager.TemperatureUnit == TemperatureUnit.Celsius;
            fahrenheitMenuItem.Checked = !celsiusMenuItem.Checked;

            Server = new HttpServer(_root, _settings.GetValue("listenerPort", 8085));
            if (Server.PlatformNotSupported)
            {
                webMenuItemSeparator.Visible = false;
                webMenuItem.Visible          = false;
            }

            _runWebServer          = new UserOption("runWebServerMenuItem", false, runWebServerMenuItem, _settings);
            _runWebServer.Changed += delegate
            {
                if (_runWebServer.Value)
                {
                    Server.StartHttpListener();
                }
                else
                {
                    Server.StopHttpListener();
                }
            };

            _logSensors = new UserOption("logSensorsMenuItem", false, logSensorsMenuItem, _settings);

            _loggingInterval = new UserRadioGroup("loggingInterval", 0,
                                                  new[] { log1sMenuItem, log2sMenuItem, log5sMenuItem, log10sMenuItem,
                                                          log30sMenuItem, log1minMenuItem, log2minMenuItem, log5minMenuItem,
                                                          log10minMenuItem, log30minMenuItem, log1hMenuItem, log2hMenuItem,
                                                          log6hMenuItem }, _settings);
            _loggingInterval.Changed += (sender, e) =>
            {
                switch (_loggingInterval.Value)
                {
                case 0: _logger.LoggingInterval = new TimeSpan(0, 0, 1); break;

                case 1: _logger.LoggingInterval = new TimeSpan(0, 0, 2); break;

                case 2: _logger.LoggingInterval = new TimeSpan(0, 0, 5); break;

                case 3: _logger.LoggingInterval = new TimeSpan(0, 0, 10); break;

                case 4: _logger.LoggingInterval = new TimeSpan(0, 0, 30); break;

                case 5: _logger.LoggingInterval = new TimeSpan(0, 1, 0); break;

                case 6: _logger.LoggingInterval = new TimeSpan(0, 2, 0); break;

                case 7: _logger.LoggingInterval = new TimeSpan(0, 5, 0); break;

                case 8: _logger.LoggingInterval = new TimeSpan(0, 10, 0); break;

                case 9: _logger.LoggingInterval = new TimeSpan(0, 30, 0); break;

                case 10: _logger.LoggingInterval = new TimeSpan(1, 0, 0); break;

                case 11: _logger.LoggingInterval = new TimeSpan(2, 0, 0); break;

                case 12: _logger.LoggingInterval = new TimeSpan(6, 0, 0); break;
                }
            };

            _sensorValuesTimeWindow = new UserRadioGroup("sensorValuesTimeWindow", 10,
                                                         new[] { timeWindow30sMenuItem, timeWindow1minMenuItem, timeWindow2minMenuItem,
                                                                 timeWindow5minMenuItem, timeWindow10minMenuItem, timeWindow30minMenuItem,
                                                                 timeWindow1hMenuItem, timeWindow2hMenuItem, timeWindow6hMenuItem,
                                                                 timeWindow12hMenuItem, timeWindow24hMenuItem }, _settings);
            _sensorValuesTimeWindow.Changed += (sender, e) =>
            {
                TimeSpan timeWindow = TimeSpan.Zero;
                switch (_sensorValuesTimeWindow.Value)
                {
                case 0: timeWindow = new TimeSpan(0, 0, 30); break;

                case 1: timeWindow = new TimeSpan(0, 1, 0); break;

                case 2: timeWindow = new TimeSpan(0, 2, 0); break;

                case 3: timeWindow = new TimeSpan(0, 5, 0); break;

                case 4: timeWindow = new TimeSpan(0, 10, 0); break;

                case 5: timeWindow = new TimeSpan(0, 30, 0); break;

                case 6: timeWindow = new TimeSpan(1, 0, 0); break;

                case 7: timeWindow = new TimeSpan(2, 0, 0); break;

                case 8: timeWindow = new TimeSpan(6, 0, 0); break;

                case 9: timeWindow = new TimeSpan(12, 0, 0); break;

                case 10: timeWindow = new TimeSpan(24, 0, 0); break;
                }

                _computer.Accept(new SensorVisitor(delegate(ISensor sensor)
                {
                    sensor.ValuesTimeWindow = timeWindow;
                }));
            };

            InitializePlotForm();
            InitializeSplitter();

            startupMenuItem.Visible = _startupManager.IsAvailable;

            if (startMinMenuItem.Checked)
            {
                if (!minTrayMenuItem.Checked)
                {
                    WindowState = FormWindowState.Minimized;
                    Show();
                }
            }
            else
            {
                Show();
            }

            // Create a handle, otherwise calling Close() does not fire FormClosed

            // Make sure the settings are saved when the user logs off
            Microsoft.Win32.SystemEvents.SessionEnded += delegate
            {
                _computer.Close();
                SaveConfiguration();
                if (_runWebServer.Value)
                {
                    Server.Quit();
                }
            };
        }
Esempio n. 6
0
        public MainForm()
        {
            InitializeComponent();

            // check if the OpenHardwareMonitorLib assembly has the correct version
            if (Assembly.GetAssembly(typeof(Computer)).GetName().Version !=
                Assembly.GetExecutingAssembly().GetName().Version)
            {
                MessageBox.Show(
                    "The version of the file OpenHardwareMonitorLib.dll is incompatible.",
                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(0);
            }

            settings = new PersistentSettings();
            settings.Load(Path.ChangeExtension(
                              Application.ExecutablePath, ".config"));

            unitManager = new UnitManager(settings);

            // make sure the buffers used for double buffering are not disposed
            // after each draw call
            BufferedGraphicsManager.Current.MaximumBuffer =
                Screen.PrimaryScreen.Bounds.Size;

            // set the DockStyle here, to avoid conflicts with the MainMenu
            splitContainer.Dock = DockStyle.Fill;

            Font          = SystemFonts.MessageBoxFont;
            treeView.Font = SystemFonts.MessageBoxFont;

            plotPanel      = new PlotPanel(settings, unitManager);
            plotPanel.Font = SystemFonts.MessageBoxFont;
            plotPanel.Dock = DockStyle.Fill;

            nodeCheckBox.IsVisibleValueNeeded += nodeCheckBox_IsVisibleValueNeeded;
            nodeTextBoxText.DrawText          += nodeTextBoxText_DrawText;
            nodeTextBoxValue.DrawText         += nodeTextBoxText_DrawText;
            nodeTextBoxMin.DrawText           += nodeTextBoxText_DrawText;
            nodeTextBoxMax.DrawText           += nodeTextBoxText_DrawText;
            nodeTextBoxText.EditorShowing     += nodeTextBoxText_EditorShowing;

            foreach (var column in treeView.Columns)
            {
                column.Width = Math.Max(20, Math.Min(400,
                                                     settings.GetValue("treeView.Columns." + column.Header + ".Width",
                                                                       column.Width)));
            }

            treeModel  = new TreeModel();
            root       = new Node(Environment.MachineName);
            root.Image = EmbeddedResources.GetImage("computer.png");

            treeModel.Nodes.Add(root);
            treeView.Model = treeModel;

            computer = new Computer(settings);

            systemTray = new SystemTray(computer, settings, unitManager);
            systemTray.HideShowCommand += hideShowClick;
            systemTray.ExitCommand     += exitClick;

            var p = (int)Environment.OSVersion.Platform;

            if ((p == 4) || (p == 128))
            {
                // Unix
                treeView.RowHeight           = Math.Max(treeView.RowHeight, 18);
                splitContainer.BorderStyle   = BorderStyle.None;
                splitContainer.Border3DStyle = Border3DStyle.Adjust;
                splitContainer.SplitterWidth = 4;
                treeView.BorderStyle         = BorderStyle.Fixed3D;
                plotPanel.BorderStyle        = BorderStyle.Fixed3D;
                gadgetMenuItem.Visible       = false;
                minCloseMenuItem.Visible     = false;
                minTrayMenuItem.Visible      = false;
                startMinMenuItem.Visible     = false;
            }
            else
            {
                // Windows
                treeView.RowHeight = Math.Max(treeView.Font.Height + 1, 18);

                gadget = new SensorGadget(computer, settings, unitManager);
                gadget.HideShowCommand += hideShowClick;

                wmiProvider = new WmiProvider(computer);
            }

            logger = new Logger(computer);

            plotColorPalette     = new Color[13];
            plotColorPalette[0]  = Color.Blue;
            plotColorPalette[1]  = Color.OrangeRed;
            plotColorPalette[2]  = Color.Green;
            plotColorPalette[3]  = Color.LightSeaGreen;
            plotColorPalette[4]  = Color.Goldenrod;
            plotColorPalette[5]  = Color.DarkViolet;
            plotColorPalette[6]  = Color.YellowGreen;
            plotColorPalette[7]  = Color.SaddleBrown;
            plotColorPalette[8]  = Color.RoyalBlue;
            plotColorPalette[9]  = Color.DeepPink;
            plotColorPalette[10] = Color.MediumSeaGreen;
            plotColorPalette[11] = Color.Olive;
            plotColorPalette[12] = Color.Firebrick;

            computer.HardwareAdded   += HardwareAdded;
            computer.HardwareRemoved += HardwareRemoved;

            computer.Open();

            timer.Enabled = true;

            showHiddenSensors = new UserOption("hiddenMenuItem", false,
                                               hiddenMenuItem, settings);
            showHiddenSensors.Changed += delegate { treeModel.ForceVisible = showHiddenSensors.Value; };

            showValue = new UserOption("valueMenuItem", true, valueMenuItem,
                                       settings);
            showValue.Changed += delegate { treeView.Columns[1].IsVisible = showValue.Value; };

            showMin          = new UserOption("minMenuItem", false, minMenuItem, settings);
            showMin.Changed += delegate { treeView.Columns[2].IsVisible = showMin.Value; };

            showMax          = new UserOption("maxMenuItem", true, maxMenuItem, settings);
            showMax.Changed += delegate { treeView.Columns[3].IsVisible = showMax.Value; };

            startMinimized = new UserOption("startMinMenuItem", false,
                                            startMinMenuItem, settings);

            minimizeToTray = new UserOption("minTrayMenuItem", true,
                                            minTrayMenuItem, settings);
            minimizeToTray.Changed += delegate { systemTray.IsMainIconEnabled = minimizeToTray.Value; };

            minimizeOnClose = new UserOption("minCloseMenuItem", false,
                                             minCloseMenuItem, settings);

            autoStart = new UserOption(null, startupManager.Startup,
                                       startupMenuItem, settings);
            autoStart.Changed += delegate
            {
                try
                {
                    startupManager.Startup = autoStart.Value;
                }
                catch (InvalidOperationException)
                {
                    MessageBox.Show("Updating the auto-startup option failed.", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    autoStart.Value = startupManager.Startup;
                }
            };

            readMainboardSensors = new UserOption("mainboardMenuItem", true,
                                                  mainboardMenuItem, settings);
            readMainboardSensors.Changed += delegate { computer.MainboardEnabled = readMainboardSensors.Value; };

            readCpuSensors = new UserOption("cpuMenuItem", true,
                                            cpuMenuItem, settings);
            readCpuSensors.Changed += delegate { computer.CPUEnabled = readCpuSensors.Value; };

            readRamSensors = new UserOption("ramMenuItem", true,
                                            ramMenuItem, settings);
            readRamSensors.Changed += delegate { computer.RAMEnabled = readRamSensors.Value; };

            readGpuSensors = new UserOption("gpuMenuItem", true,
                                            gpuMenuItem, settings);
            readGpuSensors.Changed += delegate { computer.GPUEnabled = readGpuSensors.Value; };

            readFanControllersSensors = new UserOption("fanControllerMenuItem", true,
                                                       fanControllerMenuItem, settings);
            readFanControllersSensors.Changed +=
                delegate { computer.FanControllerEnabled = readFanControllersSensors.Value; };

            readHddSensors = new UserOption("hddMenuItem", true, hddMenuItem,
                                            settings);
            readHddSensors.Changed += delegate { computer.HDDEnabled = readHddSensors.Value; };

            showGadget = new UserOption("gadgetMenuItem", false, gadgetMenuItem,
                                        settings);
            showGadget.Changed += delegate
            {
                if (gadget != null)
                {
                    gadget.Visible = showGadget.Value;
                }
            };

            celsiusMenuItem.Checked =
                unitManager.TemperatureUnit == TemperatureUnit.Celsius;
            fahrenheitMenuItem.Checked = !celsiusMenuItem.Checked;

            Server = new HttpServer(root, settings.GetValue("listenerPort", 8085));
            if (Server.PlatformNotSupported)
            {
                webMenuItemSeparator.Visible = false;
                webMenuItem.Visible          = false;
            }

            runWebServer = new UserOption("runWebServerMenuItem", false,
                                          runWebServerMenuItem, settings);
            runWebServer.Changed += delegate
            {
                if (runWebServer.Value)
                {
                    Server.StartHTTPListener();
                }
                else
                {
                    Server.StopHTTPListener();
                }
            };

            logSensors = new UserOption("logSensorsMenuItem", false, logSensorsMenuItem,
                                        settings);

            loggingInterval = new UserRadioGroup("loggingInterval", 0,
                                                 new[]
            {
                log1sMenuItem, log2sMenuItem, log5sMenuItem, log10sMenuItem,
                log30sMenuItem, log1minMenuItem, log2minMenuItem, log5minMenuItem,
                log10minMenuItem, log30minMenuItem, log1hMenuItem, log2hMenuItem,
                log6hMenuItem
            },
                                                 settings);
            loggingInterval.Changed += (sender, e) =>
            {
                switch (loggingInterval.Value)
                {
                case 0:
                    logger.LoggingInterval = new TimeSpan(0, 0, 1);
                    break;

                case 1:
                    logger.LoggingInterval = new TimeSpan(0, 0, 2);
                    break;

                case 2:
                    logger.LoggingInterval = new TimeSpan(0, 0, 5);
                    break;

                case 3:
                    logger.LoggingInterval = new TimeSpan(0, 0, 10);
                    break;

                case 4:
                    logger.LoggingInterval = new TimeSpan(0, 0, 30);
                    break;

                case 5:
                    logger.LoggingInterval = new TimeSpan(0, 1, 0);
                    break;

                case 6:
                    logger.LoggingInterval = new TimeSpan(0, 2, 0);
                    break;

                case 7:
                    logger.LoggingInterval = new TimeSpan(0, 5, 0);
                    break;

                case 8:
                    logger.LoggingInterval = new TimeSpan(0, 10, 0);
                    break;

                case 9:
                    logger.LoggingInterval = new TimeSpan(0, 30, 0);
                    break;

                case 10:
                    logger.LoggingInterval = new TimeSpan(1, 0, 0);
                    break;

                case 11:
                    logger.LoggingInterval = new TimeSpan(2, 0, 0);
                    break;

                case 12:
                    logger.LoggingInterval = new TimeSpan(6, 0, 0);
                    break;
                }
            };

            InitializePlotForm();

            startupMenuItem.Visible = startupManager.IsAvailable;

            if (startMinMenuItem.Checked)
            {
                if (!minTrayMenuItem.Checked)
                {
                    WindowState = FormWindowState.Minimized;
                    Show();
                }
            }
            else
            {
                Show();
            }

            // Create a handle, otherwise calling Close() does not fire FormClosed
            var handle = Handle;

            // Make sure the settings are saved when the user logs off
            SystemEvents.SessionEnded += delegate
            {
                computer.Close();
                SaveConfiguration();
                if (runWebServer.Value)
                {
                    Server.Quit();
                }
            };
        }
Esempio n. 7
0
        private void Load()
        {
            ApplicationFilePath = persistentSettings.Load("Path", ApplicationFilePath);
            DateIndex           = persistentSettings.Load("DateIndex", DateIndex);
            DateTime dateTime = DateTime.Now;

            DateTime.TryParse(persistentSettings.Load("DateTime", dateTime.ToString("yyyy-MM-dd")), out dateTime);
            DateTime              = dateTime;
            SpanValue             = persistentSettings.Load("Span", SpanValue);
            SpanIndex             = persistentSettings.Load("SpanIndex", SpanIndex);
            Arguments             = persistentSettings.Load("Arguments", Arguments);
            WorkingFolderPath     = persistentSettings.Load("Folder", WorkingFolderPath);
            Interval              = persistentSettings.Load("Interval", Interval);
            ShortcutName          = persistentSettings.Load("Shortcut", ShortcutName);
            OneInstance           = persistentSettings.Load("OneInstance", OneInstance);
            WarningOk             = persistentSettings.Load("WarningOk", WarningOk);
            DisableTimeCorrection = persistentSettings.Load("DisableTimeCorr", DisableTimeCorrection);
            ForceTimeCorrection   = persistentSettings.Load("ForceTimeCorr", ForceTimeCorrection);
            DisableThemes         = persistentSettings.Load("DisableThemes", DisableThemes);
        }
		public static void Initialize(IScheduler mainThreadDispatcher, AbsoluteFilePath userData, dynamic reflection)
		{
			UserSettings.Settings = PersistentSettings.Load(usersettingsfile: userData);

			Axis2DExtensions.ShouldFlip = false;
			Application.MainThread = mainThreadDispatcher;
			_reflection = reflection;
			

			Pointer.Implementation.MakeHittable = (control, space, callbacks) =>
			{
				var o = control.NativeHandle;

				reflection.CallStatic("Outracks.UnoHost.FusionInterop", "OnPointerPressed", o, new Action<Float2>(pos =>
					callbacks.OnPressed(new Pointer.OnPressedArgs(new Point<Points>(pos.X, pos.Y), 1))));

				reflection.CallStatic("Outracks.UnoHost.FusionInterop", "OnPointerMoved", o, new Action<Float2>(pos =>
					callbacks.OnMoved(new Point<Points>(pos.X, pos.Y))));

				return control;
			};

			Layout.Implementation.LayerControls = (childFactory) =>
				Control.Create(self =>
				{
					var control = reflection.Instantiate("Fuse.Controls.Panel");

					BindNativeDefaults(self, control);

					var element = control as dynamic;

					self.BindList(
						list: childFactory(self).Select(Enumerable.Reverse),
						add: child =>
						{
							child.Mount(
								new MountLocation.Mutable
								{
									IsRooted = self.IsRooted,
									AvailableSize = self.AvailableSize,
									NativeFrame = ObservableMath.RectangleWithSize(self.NativeFrame.Size),
								});

							var nativeChild = child.NativeHandle as dynamic;
							if (nativeChild != null)
								element.Children.Add(nativeChild);
						},
						remove: child =>
						{
							var nativeChild = child.NativeHandle as dynamic;
							if (nativeChild != null)
								element.Children.Remove(nativeChild);

							child.Mount(MountLocation.Unmounted);
						});

					return control;
				});

			Shapes.Implementation.RectangleFactory = (stroke, brush, cornerRadius) =>
				Control.Create(self =>
				{
					var control = _reflection.Instantiate("Fuse.Controls.Rectangle");

					BindNativeDefaults(self, control);
					BindShapeProperties(self, control, brush, stroke);

					return control;
				});
		}
Esempio n. 9
0
 private void Load()
 {
     Caption              = persistentSettings.Load("Caption", Caption);
     Text                 = persistentSettings.Load("Text", Text);
     IconIndex            = persistentSettings.Load("IconIndex", IconIndex);
     ButtonsIndex         = persistentSettings.Load("ButtonsIndex", ButtonsIndex);
     DefaultButtonIndex   = persistentSettings.Load("DefaultButtonIndex", DefaultButtonIndex);
     BoxCenterScreen      = persistentSettings.Load("BoxCenterScreen", BoxCenterScreen);
     DisplayHelpButton    = persistentSettings.Load("DisplayHelpButton", DisplayHelpButton);
     SetMaximumWidth      = persistentSettings.Load("SetMaximumWidth", SetMaximumWidth);
     MaximumWidth         = persistentSettings.Load("MaximumWidth", MaximumWidth);
     SetNoWrap            = persistentSettings.Load("SetNoWrap", SetNoWrap);
     SetParentForm        = persistentSettings.Load("SetParentForm", SetParentForm);
     ShowMessageBox       = persistentSettings.Load("ShowMessageBox", ShowMessageBox);
     PrintSoftMargins     = persistentSettings.Load("PrintSoftMargins", PrintSoftMargins);
     MainFormCenterScreen = persistentSettings.Load("MainFormCenterScreen", MainFormCenterScreen);
     EscapeFunction       = persistentSettings.Load("EscapeFunction", EscapeFunction);
     DisableThemes        = persistentSettings.Load("DisableThemes", DisableThemes);
     LastExportDirectory  = persistentSettings.Load("LastExportDir", LastExportDirectory);
     ExtensionFilterIndex = persistentSettings.Load("ExtFilterIndex", ExtensionFilterIndex);
     CheckForUpdates      = persistentSettings.Load("CheckForUpdates", CheckForUpdates);
     StatusBarNotifOnly   = persistentSettings.Load("StatusBarNotifOnly", StatusBarNotifOnly);
 }
Esempio n. 10
0
        private void Application_Startup(object sender, StartupEventArgs sea)
        {
            Log.Info("- starting up pserv -");

            Settings           = new pserv4.Properties.Settings();
            PersistentSettings = new PersistentSettings(Settings, "p-nand-q.com\\pserv4");
            PersistentSettings.Load();

            MainViewType initialView = MainViewType.Modules;

            try
            {
                if (!string.IsNullOrEmpty(Settings.LastViewType))
                {
                    initialView = (MainViewType)Enum.Parse(typeof(MainViewType), Settings.LastViewType, true);
                }
            }
            catch (Exception)
            {
            }

            services.ServiceStateRequest ssr = null;
            bool          dumpXml            = false;
            bool          useClipboard       = false;
            string        dumpXmlFilename    = null;
            List <string> servicenames       = new List <string>();
            int           n = 0;

            foreach (string arg in sea.Args)
            {
                Log.InfoFormat("- arg[{0}]: {1}", n++, arg);
                if (arg.StartsWith("/"))
                {
                    string key = arg.Substring(1).ToUpper();
                    if (key.Equals("DEVICES"))
                    {
                        initialView = MainViewType.Devices;
                        Log.InfoFormat("=> set initialView to {0}", initialView);
                    }
                    else if (key.Equals("MODULES"))
                    {
                        initialView = MainViewType.Modules;
                        Log.InfoFormat("=> set initialView to {0}", initialView);
                    }
                    else if (key.Equals("PROCESSES"))
                    {
                        initialView = MainViewType.Processes;
                        Log.InfoFormat("=> set initialView to {0}", initialView);
                    }
                    else if (key.Equals("UNINSTALLER"))
                    {
                        initialView = MainViewType.Uninstaller;
                        Log.InfoFormat("=> set initialView to {0}", initialView);
                    }
                    else if (key.Equals("WINDOWS"))
                    {
                        initialView = MainViewType.Windows;
                        Log.InfoFormat("=> set initialView to {0}", initialView);
                    }
                    else if (key.Equals("DUMPXML"))
                    {
                        dumpXml = true;
                        Log.Info("=> set dumpXml to true");
                    }
                    else if (key.Equals("CLIPBOARD"))
                    {
                        dumpXml      = true;
                        useClipboard = true;
                        Log.Info("=> set dumpXml to true");
                        Log.Info("=> set useClipboard to true");
                    }
                    else if (key.Equals("START"))
                    {
                        ssr = new services.RequestServiceStart();
                        Log.InfoFormat("=> set ssr to {0}", ssr);
                    }
                    else if (key.Equals("STOP"))
                    {
                        ssr = new services.RequestServiceStop();
                        Log.InfoFormat("=> set ssr to {0}", ssr);
                    }
                    else if (key.Equals("RESTART"))
                    {
                        ssr = new services.RequestServiceRestart();
                        Log.InfoFormat("=> set ssr to {0}", ssr);
                    }
                    else if (key.Equals("PAUSE"))
                    {
                        ssr = new services.RequestServicePause();
                        Log.InfoFormat("=> set ssr to {0}", ssr);
                    }
                    else if (key.Equals("CONTINUE"))
                    {
                        ssr = new services.RequestServiceContinue();
                        Log.InfoFormat("=> set ssr to {0}", ssr);
                    }
                }
                else if (dumpXml && string.IsNullOrEmpty(dumpXmlFilename))
                {
                    dumpXmlFilename = arg;
                    Log.InfoFormat("=> set dumpXmlFilename to {0}", dumpXmlFilename);
                }
                else if (ssr != null)
                {
                    Log.InfoFormat("=> add service named '{0}'", arg);
                    servicenames.Add(arg);
                }
            }

            MainWindow wnd = new MainWindow(initialView);

            if (dumpXml)
            {
                wnd.SwitchController(initialView, false);
                if (useClipboard)
                {
                    wnd.CopyToClipboard(null, null);
                }
                else if (string.IsNullOrEmpty(dumpXmlFilename))
                {
                    wnd.SaveAsXML(null, null);
                }
                else
                {
                    wnd.SaveAsXML(dumpXmlFilename, null);
                }
                Shutdown();
            }
            else
            {
                if (ssr != null)
                {
                    wnd.SetInitialAction(ssr, servicenames);
                }
                wnd.Show();
            }
        }
Esempio n. 11
0
        public static void Main(string [] argv)
        {
            Thread.CurrentThread.SetInvariantCulture();

            Application.Initialize(argv);

            var log    = new Subject <string>();
            var shell  = new Shell();
            var writer = new ObservableStreamWriter();

            writer.Chunks.Subscribe(log);
            Console.SetOut(writer);

            var autoReloadFiles = new List <AbsoluteFilePath>();

            foreach (var arg in argv)
            {
                var path = (AbsoluteFilePath)shell.ResolveAbsolutePath(arg);
                if (path.Name.Extension == ".cs")
                {
                    autoReloadFiles.Add(AbsoluteFilePath.Parse(arg));
                }
                else
                {
                    throw new Exception("Invalid argument, expected filepaths which ends with '.cs'.");
                }
            }

            UserSettings.Settings = PersistentSettings.Load(
                usersettingsfile: AbsoluteDirectoryPath.Parse(Environment.CurrentDirectory) / new FileName("autoreload-config.json"));

            if (autoReloadFiles.Count == 0)
            {
                if (Platform.OperatingSystem == OS.Mac)
                {
                    autoReloadFiles.Add(AbsoluteFilePath.Parse(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/../../../AutoReloadContent.cs"));
                }
                else
                {
                    autoReloadFiles.Add(AbsoluteFilePath.Parse("../../AutoReloadContent.cs"));
                }
            }

            var createDebugWindow = new Action(() =>
                                               Application.Desktop.CreateSingletonWindow(
                                                   Observable.Return(true),
                                                   dialog =>
                                                   new Window()
            {
                Title      = Observable.Return("Debug"),
                Size       = Property.Create <Optional <Size <Points> > >(new Size <Points>(600, 500)).ToOptional(),
                Content    = Debugging.CreateDebugControl(),
                Background = Theme.Background,
                Border     = Stroke.Create(1, Color.White),
                Foreground = Color.White,
            }
                                                   ));

            Application.Desktop.CreateSingletonWindow(
                isVisible: Observable.Return(true),
                window: window =>
            {
                return(new Window
                {
                    Title = Observable.Return("Fuse - Autoreload"),
                    Menu = Menu.Item("Debug", createDebugWindow) +
                           Menu.Submenu("Themes",
                                        Menu.Option(
                                            value: Themes.OriginalLight,
                                            name: "Light theme",
                                            property: Theme.CurrentTheme) +
                                        Menu.Option(
                                            value: Themes.OriginalDark,
                                            name: "Dark theme",
                                            property: Theme.CurrentTheme)),
                    Content = Layout.Dock()
                              .Bottom(
                        LogView.Create(log.Select(s => s), Observable.Return(Color.Black))
                        .WithHeight(200)
                        .WithBackground(Color.White))
                              .Fill(AutoreloadControl(shell, autoReloadFiles, log.ToProgress()).Switch()),
                    Background = Theme.Background,
                    Border = Stroke.Create(1, Color.White),
                    Foreground = Color.White,
                });
            });

            Application.Run();
        }