Example #1
0
        private void OnClosing(object sender, CancelEventArgs e)
        {
            // Find the schematics that have pending edits.
            IEnumerable <SchematicEditor> save = EditorListDialog.Show(
                this,
                "Save the following schematics?",
                MessageBoxButton.YesNoCancel,
                Editors.Where(i => i.Edits.Dirty));

            if (save != null)
            {
                foreach (SchematicEditor i in save)
                {
                    if (!i.Save())
                    {
                        e.Cancel = true;
                        return;
                    }
                }
            }
            else
            {
                e.Cancel = true;
            }
        }
Example #2
0
        private void OnActivated(object sender, EventArgs e)
        {
            if (activating)
            {
                return;
            }
            activating = true;

            // Find the schematics that have been modified outside the editor.
            IEnumerable <SchematicEditor> modified = EditorListDialog.Show(
                this,
                "The following schematics were modified outside LiveSPICE, do you want to reload them?",
                MessageBoxButton.YesNo,
                Editors.Where(i => i.CheckForModifications()).ToList());

            if (modified != null)
            {
                foreach (SchematicEditor i in modified)
                {
                    i.Touch();
                }
                foreach (SchematicEditor i in modified)
                {
                    Open(i.FilePath, true);
                }
            }
            activating = false;
        }
Example #3
0
 /// <summary>
 ///     Removes all occurances of the path
 /// </summary>
 /// <param name="path">Path to remove</param>
 private void RemoveFilePath(string path)
 {
     // if there are multiple occurrences
     while (Editors.Select(x => x.FilePath).Contains(path))
     {
         Editors = Editors.Where(x => x.FilePath != path).ToArray();
     }
 }
        public void Initialize()
        {
            // drawing layer
            var scope = _scopes.LastOrDefault();

            Editors  = scope.Resolve <IList <IEditor> >();
            Files    = scope.Resolve <IList <IFile> >();
            Creators = scope.Resolve <IList <ICreator> >();

            // default editor
            Editors.Where(e => e.Name == "Line")
            .FirstOrDefault()
            .IsEnabled = true;
        }
Example #5
0
        public void Update(double delta)
        {
            var groupedEditors = Editors.GroupBy(e => e.Category);

            foreach (var editor in Editors.Where(e => e.HotKey.HasValue))
            {
                if (ImGui.IsKeyDown((int)Veldrid.Key.ShiftLeft) &&
                    ImGui.IsKeyDown((int)Veldrid.Key.ControlLeft) &&
                    ImGui.IsKeyPressed((int)Enum.Parse(typeof(Veldrid.Key), editor.HotKey.Value.ToString().ToUpper())))
                {
                    editor.IsActive = !editor.IsActive;
                }
            }

            if (ImGui.BeginMainMenuBar())
            {
                foreach (var group in groupedEditors)
                {
                    if (ImGui.BeginMenu(group.Key))
                    {
                        foreach (var editor in group)
                        {
                            bool active      = editor.IsActive;
                            var  shortcutStr = editor.HotKey.HasValue ? "Ctrl+Shft+" + editor.HotKey.Value : "";
                            ImGui.MenuItem(editor.Name, shortcutStr, ref active, true);
                            editor.IsActive = active;
                        }
                        ImGui.EndMenu();
                    }
                }
                ImGui.EndMainMenuBar();
            }

            foreach (var editor in Editors.Where(e => e.IsActive))
            {
                editor.DrawWindow(delta);
            }
        }
Example #6
0
 public void RemoveInvalidFilePaths()
 {
     Editors = Editors.Where(x => File.Exists(x.FilePath)).ToArray();
 }
Example #7
0
        private void UpdateGui()
        {
            this.InvokeIfRequired(() =>
            {
                if (!IsDeviceConnected)
                {
                    _receivingData = false;
                }

                pictureBoxStatus.Image = IsDeviceConnected ? Resources.connected : Resources.disconnected;

                if (_sending)
                {
                    labelStatusSubtitle.Text = String.IsNullOrEmpty(_sendingStatus)
                        ? Resources.StatusSending
                        : _sendingStatus;
                }
                else
                {
                    labelStatusSubtitle.Text = IsDeviceConnected
                        ? Resources.StatusConnected +
                                               (_receivingData ? Environment.NewLine + Environment.NewLine +
                                                (_receivedData.Count > 0
                                    ? String.Format(Resources.StatusReceived, GetKilobytes(_receivedData.Count), 1)
                                    : Resources.StatusWaiting)
                              : "")
                        : Resources.StatusNotConnected;
                }

                if (!IsBusy)
                {
                    IsBusy = _receivedData.Count > 0;
                }

                buttonReceive.Enabled                  = IsDeviceConnected && !IsBusy;
                buttonReceive.Text                     = _receivingData? "&Cancel" : "&Receive";
                receiveToolStripMenuItem.Enabled       = buttonReceive.Enabled && !_receivingData;
                cancelReceiveToolStripMenuItem.Enabled = _receivingData;

                var canSend = IsDeviceConnected && !IsBusy;

                buttonSend.Text  = canSend ? "&Send..." : "&Open...";
                buttonSend.Image = canSend ? Resources.editor_send_to_device : Resources.editor_open;
                sendFileToolStripMenuItemopenToolStripMenuItemContextual.Visible = canSend;
                sendFileToolStripSeparator.Visible               = canSend;
                sendFilesToolStripMenuItem.Enabled               = canSend;
                sendClipboardToolStripMenuItem.Enabled           = canSend;
                sendClipboardToolStripMenuItemContextual.Visible = canSend;

                buttonCaptureScreen.Enabled            = IsDeviceConnected && !IsBusy;
                captureScreenToolStripMenuItem.Enabled = buttonCaptureScreen.Enabled;

                if (Editors != null)
                {
                    foreach (var n in Editors.Where(ed => !ed.IsDisposed))
                    {
                        n.UpdateGui();
                    }
                }

                if (_receivingData == false)
                {
                    if (_receivedFile != null && _receivedFile.IsComplete)
                    {
                        saveFileDialogProgram.FileName = _receivedFile.Name + ".hpprgm";
                        if (saveFileDialogProgram.ShowDialog() == DialogResult.OK)
                        {
                            _receivedFile.Save(saveFileDialogProgram.FileName);
                        }

                        ResetProgram();
                    }
                }
            });
        }