Exemplo n.º 1
0
        private void on_timerTick(object sender, EventArgs e)
        {
            timer1.Stop();
            var str = (string)null;

            ++TEMPORARY_run_count;
            try
            {
                str = "on_timerTick::views.Process";
                if (TEMPORARY_run_count <= 3)
                {
                    Form1.debugLogger.Add(nameof(on_timerTick), str + TEMPORARY_run_count, DebugLogger.LogType.Primary);
                }

                str = "on_timerTick::Refresh";
                if (!contextMenuStrip1.Visible)
                {
                    Refresh();
                }

                if (TEMPORARY_run_count <= 3)
                {
                    Form1.debugLogger.Add(nameof(on_timerTick), str + TEMPORARY_run_count, DebugLogger.LogType.Primary);
                }

                str = "on_timerTick::RefreshViews";
                if (m_gui_host != null)
                {
                    if (resized)
                    {
                        m_gui_host.RefreshViews();
                        resized = false;
                    }
                    str = "on_timerTick::m_gui_host.OnUpdate()";
                    m_gui_host.OnUpdate();
                }
                if (TEMPORARY_run_count <= 3)
                {
                    Form1.debugLogger.Add(nameof(on_timerTick), str + TEMPORARY_run_count, DebugLogger.LogType.Primary);
                }
            }
            catch (Exception ex)
            {
                var extra_info = str;
                ExceptionForm.ShowExceptionForm(ex, extra_info);
            }
            lock (mainThreadTaskQueue)
            {
                while (mainThreadTaskQueue.Count > 0)
                {
                    Form1.MainThreadTask mainThreadTask = mainThreadTaskQueue.Dequeue();
                    mainThreadTask.the_task(mainThreadTask.data);
                }
            }
            timer1.Start();
        }
Exemplo n.º 2
0
        private void glControl1_Paint(object sender, PaintEventArgs e)
        {
            try
            {
                if (!fps_lock_watch.IsRunning)
                {
                    fps_lock_watch.Start();
                }
                else
                {
                    elapsed = fps_lock_watch.ElapsedTicks / (double)Stopwatch.Frequency;
                    if (elapsed + elapsed_frame >= 1.0 / 60.0)
                    {
                        fps_lock_watch.Reset();
                        fps_lock_watch.Start();
                        fps_frame_counter.Reset();
                        fps_frame_counter.Start();
                        OpenGLConnection.OnPaint(() =>
                        {
                            if (resized)
                            {
                                return;
                            }

                            m_gui_host.Render();
                        });
                        fps_frame_counter.Stop();
                        elapsed_frame = fps_frame_counter.ElapsedTicks / (double)Stopwatch.Frequency;
                    }
                    else
                    {
                        Thread.Sleep(5);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionForm.ShowExceptionForm(ex);
            }
        }
Exemplo n.º 3
0
        public Form1(SplashForm splashForm, string[] args)
        {
            var str = (string)null;

            try
            {
                str = "InitializePlatformSpecificObjects";
                InitializePlatformSpecificObjects();
                this.args           = args;
                AllowDrop           = true;
                DragEnter          += new DragEventHandler(Form1_DragEnter);
                DragDrop           += new DragEventHandler(Form1_DragDrop);
                mainThreadTaskQueue = new Queue <Form1.MainThreadTask>();
                Form1.debugLogger.Add("Form1() Constructor", "Constructor for the main Form.", DebugLogger.LogType.Secondary);
                ExceptionForm.form1 = this;
                str             = "splashForm.Show";
                this.splashForm = splashForm;
                splashForm.Show();
                str = "InitializeComponent";
                InitializeComponent();
                settingsManager = new SettingsManager(FileAssociations);
                Form1.debugLogger.Add("Form1() Constructor", "SettingsManager created.", DebugLogger.LogType.Secondary);
                timer1 = new System.Windows.Forms.Timer
                {
                    Interval = 16
                };
                timer1.Tick += new EventHandler(on_timerTick);
                timer1.Start();
                MouseWheel       += new MouseEventHandler(Form1_MouseWheel);
                fps_lock_watch    = new Stopwatch();
                fps_frame_counter = new Stopwatch();
            }
            catch (Exception ex)
            {
                var extra_info = str;
                ExceptionForm.ShowExceptionForm(ex, extra_info);
            }
        }
Exemplo n.º 4
0
        private void OnNewInstanceEvent(string[] args)
        {
            try
            {
                if (printerView.IsModelLoaded() && !settingsManager.CurrentAppearanceSettings.UseMultipleModels && !settingsManager.CurrentAppearanceSettings.ShowRemoveModelWarning)
                {
                    if (new LoadNewModelForm().ShowDialog() != DialogResult.Yes || args.Length == 0)
                    {
                        return;
                    }

                    model_loading_manager.LoadModelIntoPrinter(args[0]);
                }
                else
                {
                    model_loading_manager.LoadModelIntoPrinter(args[0]);
                }
            }
            catch (Exception ex)
            {
                ExceptionForm.ShowExceptionForm(ex);
            }
        }
Exemplo n.º 5
0
        protected override void OnLoad(EventArgs e)
        {
            debugFile = Paths.DebugLogPath(DateTime.Now.Ticks / 10000L);
            Form1.debugLogger.Print(debugFile);
            var str = ExceptionForm.ToMessageAndCompleteStacktrace(the_exception);

            if (!string.IsNullOrEmpty(extra_info))
            {
                str = "DEBUG STRING = " + extra_info + "\r\n\r\n" + str;
            }

            textBox1.Text     = str;
            labelVersion.Text = M3D.Spooling.Version.VersionText;
            StreamWriter streamWriter = File.AppendText(debugFile);

            streamWriter.WriteLine();
            streamWriter.WriteLine("--------------------------------------------------");
            streamWriter.WriteLine("Exception Text: ");
            streamWriter.WriteLine("--------------------------------------------------");
            streamWriter.WriteLine();
            streamWriter.WriteLine(str);
            streamWriter.Close();
            base.OnLoad(e);
        }
Exemplo n.º 6
0
 public static void ShowExceptionForm(Exception e)
 {
     ExceptionForm.ShowExceptionForm(e, null);
 }
Exemplo n.º 7
0
        private void glControl1_Load(object sender, EventArgs e)
        {
            OpenGLConnection = new OpenGLConnection();
            try
            {
                splashForm.Hide();
                splashForm.Show();
                splashForm.TopMost = true;
                OpenGLConnection.OnLoad(glControl1, Form1.debugLogger);
                InitGUI();
                var slicer_connection = (SlicerConnectionBase) new M3D.Slicer.Cura15_04.SlicerConnectionCura(Paths.WorkingFolder, Paths.ResourceFolder);
                model_loading_manager = new ModelLoadingManager();
                spooler_connection    = new SpoolerConnection(messagebox, informationbox, settingsManager);
                SoftwareUpdater       = new Updater(this, messagebox, spooler_connection, settingsManager);
                controlbar            = new ControlBar(this, m_gui_host, settingsManager, messagebox, informationbox, spooler_connection, model_loading_manager, SoftwareUpdater);
                var frame = new Frame(24680);
                frame.SetPosition(0, 0);
                frame.RelativeWidth  = 1f;
                frame.RelativeHeight = 1f;
                frame.BGColor        = new Color4(0.913725f, 0.905882f, 0.9098f, 1f);
                m_gui_host.AddElement(frame);
                libraryview = new LibraryView(10001, frame, glControl1, m_gui_host, informationbox, model_loading_manager);
                m_gui_host.SetFocus(1001);
                m_gui_host.Refresh();
                Form1.debugLogger.Add("glControl1_Load()", "LibraryView created.", DebugLogger.LogType.Secondary);
                printerView = new PrinterView(this, m_gui_host, OpenGLConnection, spooler_connection, slicer_connection, model_loading_manager, messagebox, informationbox, settingsManager, libraryview);
                printerView.SetViewPointPos(0.0f, 100f, 400f);
                Form1.debugLogger.Add("glControl1_Load()", "GLPrinterView created.", DebugLogger.LogType.Secondary);
                frame.AddChildElement(printerView);
                frame.AddChildElement(libraryview);
                Form1.debugLogger.Add("glControl1_Load()", "Views added to background view.", DebugLogger.LogType.Secondary);
                model_loading_manager.Init(settingsManager, libraryview, printerView, messagebox, informationbox);
                Form1.debugLogger.Add("glControl1_Load()", "Model Loading Manager Initialized.", DebugLogger.LogType.Secondary);
                printer_status_dialog_organizer = new PrinterStatusDialogOrganizer(spooler_connection, model_loading_manager, settingsManager, this, m_gui_host, printerView, messagebox);
                Form1.debugLogger.Add("glControl1_Load()", "PrinterStatusDialogOrganizer Initialized.", DebugLogger.LogType.Secondary);
                spooler_connection.SpoolerStartUp(Form1.debugLogger);
                Form1.debugLogger.Add("glControl1_Load()", "spooler_connection.SpoolerStartUp() completed.", DebugLogger.LogType.Secondary);
                controlbar.UpdateSettings();
                Form1.debugLogger.Add("glControl1_Load()", "controlbar.UpdateSettings() completed.", DebugLogger.LogType.Secondary);
                if (settingsManager.CurrentAppearanceSettings.StartFullScreen)
                {
                    WindowState = FormWindowState.Maximized;
                }
                else
                {
                    WindowState = FormWindowState.Normal;
                }

                splashForm.Close();
                Form1.debugLogger.Add("glControl1_Load()", "splash form closed.", DebugLogger.LogType.Secondary);
                glControl1.MakeCurrent();
                glControl1.VSync = false;
                Form1.debugLogger.Add("glControl1_Load()", "glcontrol sync", DebugLogger.LogType.Secondary);
                if (SplashFormFirstRun.WasRunForTheFirstTime)
                {
                    var welcomeDialog = new WelcomeDialog(1209, messagebox);
                    welcomeDialog.Init(m_gui_host);
                    m_gui_host.GlobalChildDialog += welcomeDialog;
                }
                else
                {
                    messagebox.AllowMessages = true;
                }

                Form1.debugLogger.Add("glControl1_Load()", "Welcome Initialized", DebugLogger.LogType.Secondary);
                CheckFileAssociations();
                Form1.debugLogger.Add("glControl1_Load()", "File Associations Checked", DebugLogger.LogType.Secondary);
                var num = spooler_connection.PrintSpoolerClient.IsPrinting ? 0 : (!Program.runfirst_start ? 1 : 0);
                SoftwareUpdater.CheckForUpdate(false);
                Form1.debugLogger.Add("glControl1_Load()", "Checked for updates", DebugLogger.LogType.Secondary);
            }
            catch (Exception ex)
            {
                ExceptionForm.ShowExceptionForm(ex);
            }
            if (args.Length != 0)
            {
                model_loading_manager.LoadModelIntoPrinter(args[0]);
            }

            FileAssociationSingleInstance.OnNewInstance += new NewInstanceEvent(OnNewInstanceEvent);
        }