public InputBoxPage(string windowTitle, string label, string initialValue, string emptyText, string actionButtonTitle, Action <string> action) { this.WindowTitle = windowTitle; this.HeaderText = windowTitle; this.WindowSize = new Vector2(500, 200); GuiWidget actionButton = null; contentRow.AddChild(new TextWidget(label, pointSize: 12) { TextColor = theme.TextColor, Margin = new BorderDouble(5), HAnchor = HAnchor.Left }); //Adds text box and check box to the above container textEditWidget = new MHTextEditWidget(initialValue, theme, pixelWidth: 300, messageWhenEmptyAndNotSelected: emptyText); textEditWidget.Name = "InputBoxPage TextEditWidget"; textEditWidget.HAnchor = HAnchor.Stretch; textEditWidget.Margin = new BorderDouble(5); textEditWidget.ActualTextEditWidget.EnterPressed += (s, e) => { actionButton.InvokeClick(); }; contentRow.AddChild(textEditWidget); actionButton = theme.CreateDialogButton(actionButtonTitle); actionButton.Name = "InputBoxPage Action Button"; actionButton.Cursor = Cursors.Hand; actionButton.Click += (s, e) => { string newName = textEditWidget.ActualTextEditWidget.Text; if (!string.IsNullOrEmpty(newName)) { action.Invoke(newName); this.DialogWindow.CloseOnIdle(); } }; this.AddPageAction(actionButton); }
private FlowLayoutWidget CreateMacroCommandContainer() { FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom); container.Margin = new BorderDouble(0, 5); BorderDouble elementMargin = new BorderDouble(top: 3); string macroCommandLabelTxt = "Macro Commands".Localize(); string macroCommandLabelTxtFull = string.Format("{0}:", macroCommandLabelTxt); TextWidget macroCommandLabel = new TextWidget(macroCommandLabelTxtFull, 0, 0, 12); macroCommandLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; macroCommandLabel.HAnchor = HAnchor.ParentLeftRight; macroCommandLabel.Margin = new BorderDouble(0, 0, 0, 1); macroCommandInput = new MHTextEditWidget(windowController.ActiveMacro.GCode, pixelHeight: 120, multiLine: true, typeFace: ApplicationController.MonoSpacedTypeFace); macroCommandInput.DrawFromHintedCache(); macroCommandInput.HAnchor = HAnchor.ParentLeftRight; macroCommandInput.VAnchor = VAnchor.ParentBottomTop; macroCommandInput.ActualTextEditWidget.VAnchor = VAnchor.ParentBottomTop; string shouldBeGCodeLabel = "This should be in 'G-Code'".Localize(); string shouldBeGCodeLabelFull = string.Format("{0}.", shouldBeGCodeLabel); macroCommandError = new TextWidget(shouldBeGCodeLabelFull, 0, 0, 10); macroCommandError.TextColor = ActiveTheme.Instance.PrimaryTextColor; macroCommandError.HAnchor = HAnchor.ParentLeftRight; macroCommandError.Margin = elementMargin; container.AddChild(macroCommandLabel); container.AddChild(macroCommandInput); container.AddChild(macroCommandError); container.HAnchor = HAnchor.ParentLeftRight; container.VAnchor = VAnchor.ParentBottomTop; return(container); }
public TerminalWidget(PrinterConfig printer, ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.printer = printer; this.Name = "TerminalWidget"; this.Padding = new BorderDouble(5, 0); // Header var headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight) { HAnchor = HAnchor.Left | HAnchor.Stretch, Padding = new BorderDouble(0, 8) }; this.AddChild(headerRow); headerRow.AddChild(CreateVisibilityOptions(theme)); autoUppercase = new CheckBox("Auto Uppercase".Localize(), textSize: theme.DefaultFontSize) { Margin = new BorderDouble(left: 25), Checked = UserSettings.Instance.Fields.GetBool(UserSettingsKey.TerminalAutoUppercase, true), TextColor = theme.TextColor, VAnchor = VAnchor.Center }; autoUppercase.CheckedStateChanged += (s, e) => { UserSettings.Instance.Fields.SetBool(UserSettingsKey.TerminalAutoUppercase, autoUppercase.Checked); }; headerRow.AddChild(autoUppercase); // Body var bodyRow = new FlowLayoutWidget() { Margin = new BorderDouble(bottom: 4), HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch }; this.AddChild(bodyRow); textScrollWidget = new TextScrollWidget(printer, printer.Connection.TerminalLog) { BackgroundColor = theme.MinimalShade, TextColor = theme.TextColor, HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, Margin = 0, Padding = new BorderDouble(3, 0) }; bodyRow.AddChild(textScrollWidget); bodyRow.AddChild(new TextScrollBar(textScrollWidget, 15) { ThumbColor = theme.AccentMimimalOverlay, BackgroundColor = theme.SlightShade, Margin = 0 }); textScrollWidget.LineFilterFunction = lineData => { var line = lineData.Line; var output = lineData.Direction == TerminalLine.MessageDirection.ToPrinter; var outputLine = line; var lineWithoutChecksum = GCodeFile.GetLineWithoutChecksum(line); // and set this as the output if desired if (output && !UserSettings.Instance.Fields.GetBool(UserSettingsKey.TerminalShowChecksum, true)) { outputLine = lineWithoutChecksum; } if (!output && lineWithoutChecksum == "ok" && !UserSettings.Instance.Fields.GetBool(UserSettingsKey.TerminalShowOks, true)) { return(null); } else if (output && lineWithoutChecksum.StartsWith("M105") && !UserSettings.Instance.Fields.GetBool(UserSettingsKey.TerminalShowTempRequests, true)) { return(null); } else if (output && (lineWithoutChecksum.StartsWith("G0 ") || lineWithoutChecksum.StartsWith("G1 ")) && !UserSettings.Instance.Fields.GetBool(UserSettingsKey.TerminalShowMovementRequests, true)) { return(null); } else if (!output && (lineWithoutChecksum.StartsWith("T") || lineWithoutChecksum.StartsWith("ok T")) && !UserSettings.Instance.Fields.GetBool(UserSettingsKey.TerminalShowTempResponse, true)) { return(null); } else if (!output && lineWithoutChecksum == "wait" && !UserSettings.Instance.Fields.GetBool(UserSettingsKey.TerminalShowWaitResponse, false)) { return(null); } if (UserSettings.Instance.Fields.GetBool(UserSettingsKey.TerminalShowInputOutputMarks, true)) { switch (lineData.Direction) { case TerminalLine.MessageDirection.FromPrinter: outputLine = "→ " + outputLine; break; case TerminalLine.MessageDirection.ToPrinter: outputLine = "← " + outputLine; break; case TerminalLine.MessageDirection.ToTerminal: outputLine = "* " + outputLine; break; } } return(outputLine); }; // Input Row var inputRow = new FlowLayoutWidget(FlowDirection.LeftToRight) { BackgroundColor = this.BackgroundColor, HAnchor = HAnchor.Stretch, Margin = new BorderDouble(bottom: 2) }; this.AddChild(inputRow); manualCommandTextEdit = new MHTextEditWidget("", theme, typeFace: ApplicationController.GetTypeFace(NamedTypeFace.Liberation_Mono)) { Margin = new BorderDouble(right: 3), HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Bottom }; manualCommandTextEdit.ActualTextEditWidget.EnterPressed += (s, e) => { SendManualCommand(); }; manualCommandTextEdit.ActualTextEditWidget.KeyDown += (s, keyEvent) => { bool changeToHistory = false; if (keyEvent.KeyCode == Keys.Up) { commandHistoryIndex--; if (commandHistoryIndex < 0) { commandHistoryIndex = 0; } changeToHistory = true; } else if (keyEvent.KeyCode == Keys.Down) { commandHistoryIndex++; if (commandHistoryIndex > commandHistory.Count - 1) { commandHistoryIndex = commandHistory.Count - 1; } else { changeToHistory = true; } } else if (keyEvent.KeyCode == Keys.Escape) { manualCommandTextEdit.Text = ""; } if (changeToHistory && commandHistory.Count > 0) { manualCommandTextEdit.Text = commandHistory[commandHistoryIndex]; } }; inputRow.AddChild(manualCommandTextEdit); // Footer var toolbarPadding = theme.ToolbarPadding; var footerRow = new FlowLayoutWidget { HAnchor = HAnchor.Stretch, Padding = new BorderDouble(0, toolbarPadding.Bottom, toolbarPadding.Right, toolbarPadding.Top) }; this.AddChild(footerRow); var sendButton = theme.CreateDialogButton("Send".Localize()); sendButton.Margin = theme.ButtonSpacing; sendButton.Click += (s, e) => { SendManualCommand(); }; footerRow.AddChild(sendButton); var clearButton = theme.CreateDialogButton("Clear".Localize()); clearButton.Margin = theme.ButtonSpacing; clearButton.Click += (s, e) => { printer.Connection.TerminalLog.Clear(); }; footerRow.AddChild(clearButton); var exportButton = theme.CreateDialogButton("Export".Localize()); exportButton.Margin = theme.ButtonSpacing; exportButton.Click += (s, e) => { UiThread.RunOnIdle(() => { AggContext.FileDialogs.SaveFileDialog( new SaveFileDialogParams("Save as Text|*.txt") { Title = "MatterControl: Terminal Log", ActionButtonLabel = "Export", FileName = "print_log.txt" }, (saveParams) => { if (!string.IsNullOrEmpty(saveParams.FileName)) { string filePathToSave = saveParams.FileName; if (filePathToSave != null && filePathToSave != "") { try { textScrollWidget.WriteToFile(filePathToSave); } catch (UnauthorizedAccessException ex) { Debug.Print(ex.Message); printer.Connection.TerminalLog.WriteLine(""); printer.Connection.TerminalLog.WriteLine("WARNING: Write Failed!".Localize()); printer.Connection.TerminalLog.WriteLine("Can't access".Localize() + " " + filePathToSave); printer.Connection.TerminalLog.WriteLine(""); UiThread.RunOnIdle(() => { StyledMessageBox.ShowMessageBox(ex.Message, "Couldn't save file".Localize()); }); } } } }); }); }; footerRow.AddChild(exportButton); footerRow.AddChild(new HorizontalSpacer()); this.AnchorAll(); }
private GuiWidget CreateSettingInfoUIControls(OrganizerSettingsData settingData, double minSettingNameWidth) { FlowLayoutWidget leftToRightLayout = new FlowLayoutWidget(); if (ActiveSliceSettings.Instance.Contains(settingData.SlicerConfigName)) { int intEditWidth = 60; int doubleEditWidth = 60; int vectorXYEditWidth = 60; int multiLineEditHeight = 60; string sliceSettingValue = ActiveSliceSettings.Instance.GetActiveValue(settingData.SlicerConfigName); leftToRightLayout.Margin = new BorderDouble(0, 5); leftToRightLayout.HAnchor |= Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; if (settingData.DataEditType != OrganizerSettingsData.DataEditTypes.MULTI_LINE_TEXT) { string convertedNewLines = settingData.PresentationName.Replace("\\n ", "\n"); convertedNewLines = convertedNewLines.Replace("\\n", "\n"); convertedNewLines = new LocalizedString(convertedNewLines).Translated; TextWidget settingName = new TextWidget(convertedNewLines); settingName.TextColor = ActiveTheme.Instance.PrimaryTextColor; settingName.Width = minSettingNameWidth; //settingName.MinimumSize = new Vector2(minSettingNameWidth, settingName.MinimumSize.y); leftToRightLayout.AddChild(settingName); } switch (settingData.DataEditType) { case OrganizerSettingsData.DataEditTypes.INT: { int currentValue = 0; int.TryParse(sliceSettingValue, out currentValue); MHNumberEdit intEditWidget = new MHNumberEdit(currentValue, pixelWidth: intEditWidth, tabIndex: tabIndexForItem++); intEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); }; leftToRightLayout.AddChild(intEditWidget); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.DOUBLE: { double currentValue = 0; double.TryParse(sliceSettingValue, out currentValue); MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowNegatives: true, allowDecimals: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++); doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); }; leftToRightLayout.AddChild(doubleEditWidget); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.POSITVE_DOUBLE: { double currentValue = 0; double.TryParse(sliceSettingValue, out currentValue); MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowDecimals: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++); doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); }; leftToRightLayout.AddChild(doubleEditWidget); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.OFFSET: { double currentValue = 0; double.TryParse(sliceSettingValue, out currentValue); MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowDecimals: true, allowNegatives: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++); doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); }; leftToRightLayout.AddChild(doubleEditWidget); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.DOUBLE_OR_PERCENT: { MHTextEditWidget stringEdit = new MHTextEditWidget(sliceSettingValue, pixelWidth: 60, tabIndex: tabIndexForItem++); stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { TextEditWidget textEditWidget = (TextEditWidget)sender; string text = textEditWidget.Text; text = text.Trim(); bool isPercent = text.Contains("%"); if (isPercent) { text = text.Substring(0, text.IndexOf("%")); } double result; double.TryParse(text, out result); text = result.ToString(); if (isPercent) { text += "%"; } textEditWidget.Text = text; SaveSetting(settingData.SlicerConfigName, textEditWidget.Text); }; leftToRightLayout.AddChild(stringEdit); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.CHECK_BOX: { CheckBox checkBoxWidget = new CheckBox(""); checkBoxWidget.VAnchor = Agg.UI.VAnchor.ParentBottom; checkBoxWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor; checkBoxWidget.Checked = (sliceSettingValue == "1"); checkBoxWidget.CheckedStateChanged += (sender, e) => { if (((CheckBox)sender).Checked) { SaveSetting(settingData.SlicerConfigName, "1"); } else { SaveSetting(settingData.SlicerConfigName, "0"); } }; leftToRightLayout.AddChild(checkBoxWidget); } break; case OrganizerSettingsData.DataEditTypes.STRING: { MHTextEditWidget stringEdit = new MHTextEditWidget(sliceSettingValue, pixelWidth: 120, tabIndex: tabIndexForItem++); stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((TextEditWidget)sender).Text); }; leftToRightLayout.AddChild(stringEdit); } break; case OrganizerSettingsData.DataEditTypes.MULTI_LINE_TEXT: { string convertedNewLines = sliceSettingValue.Replace("\\n", "\n"); MHTextEditWidget stringEdit = new MHTextEditWidget(convertedNewLines, pixelWidth: 320, pixelHeight: multiLineEditHeight, multiLine: true, tabIndex: tabIndexForItem++); stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((TextEditWidget)sender).Text.Replace("\n", "\\n")); }; leftToRightLayout.AddChild(stringEdit); } break; case OrganizerSettingsData.DataEditTypes.LIST: { StyledDropDownList selectableOptions = new StyledDropDownList("None", Direction.Up); selectableOptions.Margin = new BorderDouble(); string[] listItems = settingData.ExtraSettings.Split(','); foreach (string listItem in listItems) { MenuItem newItem = selectableOptions.AddItem(listItem); if (newItem.Text == sliceSettingValue) { selectableOptions.SelectedValue = sliceSettingValue; } newItem.Selected += (sender, e) => { MenuItem menuItem = ((MenuItem)sender); SaveSetting(settingData.SlicerConfigName, menuItem.Text); }; } leftToRightLayout.AddChild(selectableOptions); } break; case OrganizerSettingsData.DataEditTypes.VECTOR2: { string[] xyValueStrings = sliceSettingValue.Split(','); if (xyValueStrings.Length != 2) { xyValueStrings = new string[] { "0", "0" }; } double currentXValue = 0; double.TryParse(xyValueStrings[0], out currentXValue); MHNumberEdit xEditWidget = new MHNumberEdit(currentXValue, allowDecimals: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); double currentYValue = 0; double.TryParse(xyValueStrings[1], out currentYValue); MHNumberEdit yEditWidget = new MHNumberEdit(currentYValue, allowDecimals: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); { xEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "," + yEditWidget.ActuallNumberEdit.Value.ToString()); }; leftToRightLayout.AddChild(xEditWidget); TextWidget xText = new TextWidget("x"); xText.TextColor = ActiveTheme.Instance.PrimaryTextColor; xText.Margin = new BorderDouble(5, 0); leftToRightLayout.AddChild(xText); } { yEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "," + yEditWidget.ActuallNumberEdit.Value.ToString()); }; leftToRightLayout.AddChild(yEditWidget); TextWidget yText = new TextWidget("y"); yText.TextColor = ActiveTheme.Instance.PrimaryTextColor; yText.Margin = new BorderDouble(5, 0); leftToRightLayout.AddChild(yText); } } break; case OrganizerSettingsData.DataEditTypes.OFFSET2: { string[] xyValueStrings = sliceSettingValue.Split('x'); if (xyValueStrings.Length != 2) { xyValueStrings = new string[] { "0", "0" }; } double currentXValue = 0; double.TryParse(xyValueStrings[0], out currentXValue); MHNumberEdit xEditWidget = new MHNumberEdit(currentXValue, allowDecimals: true, allowNegatives: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); double currentYValue = 0; double.TryParse(xyValueStrings[1], out currentYValue); MHNumberEdit yEditWidget = new MHNumberEdit(currentYValue, allowDecimals: true, allowNegatives: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); { xEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "x" + yEditWidget.ActuallNumberEdit.Value.ToString()); }; leftToRightLayout.AddChild(xEditWidget); TextWidget xText = new TextWidget("x"); xText.TextColor = ActiveTheme.Instance.PrimaryTextColor; xText.Margin = new BorderDouble(5, 0); leftToRightLayout.AddChild(xText); } { yEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "x" + yEditWidget.ActuallNumberEdit.Value.ToString()); }; leftToRightLayout.AddChild(yEditWidget); TextWidget yText = new TextWidget("y"); yText.TextColor = ActiveTheme.Instance.PrimaryTextColor; yText.Margin = new BorderDouble(5, 0); leftToRightLayout.AddChild(yText); } } break; default: TextWidget missingSetting = new TextWidget(String.Format("Missing the setting for '{0}'.", settingData.DataEditType.ToString())); missingSetting.TextColor = ActiveTheme.Instance.PrimaryTextColor; missingSetting.BackgroundColor = RGBA_Bytes.Red; leftToRightLayout.AddChild(missingSetting); break; } } else // the setting we think we are adding is not in the config.ini it may have been depricated { TextWidget settingName = new TextWidget(String.Format("Setting '{0}' not found in config.ini", settingData.SlicerConfigName)); settingName.TextColor = ActiveTheme.Instance.PrimaryTextColor; settingName.MinimumSize = new Vector2(minSettingNameWidth, settingName.MinimumSize.y); leftToRightLayout.AddChild(settingName); leftToRightLayout.BackgroundColor = RGBA_Bytes.Red; } return(leftToRightLayout); }
public MacroDetailPage(GCodeMacro gcodeMacro, PrinterSettings printerSettings) { // Form validation fields MHTextEditWidget macroNameInput; MHTextEditWidget macroCommandInput; TextWidget macroCommandError; TextWidget macroNameError; this.HeaderText = "Edit Macro".Localize(); this.printerSettings = printerSettings; var elementMargin = new BorderDouble(top: 3); contentRow.Padding += 3; contentRow.AddChild(new TextWidget("Macro Name".Localize() + ":", 0, 0, 12) { TextColor = theme.Colors.PrimaryTextColor, HAnchor = HAnchor.Stretch, Margin = new BorderDouble(0, 0, 0, 1) }); contentRow.AddChild(macroNameInput = new MHTextEditWidget(GCodeMacro.FixMacroName(gcodeMacro.Name)) { HAnchor = HAnchor.Stretch }); contentRow.AddChild(macroNameError = new TextWidget("Give the macro a name".Localize() + ".", 0, 0, 10) { TextColor = theme.Colors.PrimaryTextColor, HAnchor = HAnchor.Stretch, Margin = elementMargin }); contentRow.AddChild(new TextWidget("Macro Commands".Localize() + ":", 0, 0, 12) { TextColor = theme.Colors.PrimaryTextColor, HAnchor = HAnchor.Stretch, Margin = new BorderDouble(0, 0, 0, 1) }); macroCommandInput = new MHTextEditWidget(gcodeMacro.GCode, pixelHeight: 120, multiLine: true, typeFace: ApplicationController.GetTypeFace(NamedTypeFace.Liberation_Mono)) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch }; macroCommandInput.ActualTextEditWidget.VAnchor = VAnchor.Stretch; macroCommandInput.DrawFromHintedCache(); contentRow.AddChild(macroCommandInput); contentRow.AddChild(macroCommandError = new TextWidget("This should be in 'G-Code'".Localize() + ".", 0, 0, 10) { TextColor = theme.Colors.PrimaryTextColor, HAnchor = HAnchor.Stretch, Margin = elementMargin }); var container = new FlowLayoutWidget { Margin = new BorderDouble(0, 5), HAnchor = HAnchor.Stretch }; contentRow.AddChild(container); var addMacroButton = theme.CreateDialogButton("Save".Localize()); addMacroButton.Click += (s, e) => { UiThread.RunOnIdle(() => { if (ValidateMacroForm()) { // SaveActiveMacro gcodeMacro.Name = macroNameInput.Text; gcodeMacro.GCode = macroCommandInput.Text; if (!printerSettings.Macros.Contains(gcodeMacro)) { printerSettings.Macros.Add(gcodeMacro); printerSettings.Save(); } this.DialogWindow.ChangeToPage(new MacroListPage(printerSettings)); } }); }; this.AddPageAction(addMacroButton); // Define field validation var validationMethods = new ValidationMethods(); var stringValidationHandlers = new FormField.ValidationHandler[] { validationMethods.StringIsNotEmpty }; formFields = new List <FormField> { new FormField(macroNameInput, macroNameError, stringValidationHandlers), new FormField(macroCommandInput, macroCommandError, stringValidationHandlers) }; }
// private as you can't make one private OutputScrollWindow() : base(400, 300) { this.BackgroundColor = backgroundColor; this.Padding = new BorderDouble(5, 0); FlowLayoutWidget topLeftToRightLayout = new FlowLayoutWidget(); topLeftToRightLayout.AnchorAll(); { FlowLayoutWidget manualEntryTopToBottomLayout = new FlowLayoutWidget(FlowDirection.TopToBottom); manualEntryTopToBottomLayout.VAnchor |= Agg.UI.VAnchor.ParentTop; manualEntryTopToBottomLayout.Padding = new BorderDouble(top:8); { FlowLayoutWidget topBarControls = new FlowLayoutWidget(FlowDirection.LeftToRight); topBarControls.HAnchor |= HAnchor.ParentLeft; string filterOutputChkTxt = LocalizedString.Get("Filter Output"); filterOutput = new CheckBox(filterOutputChkTxt); filterOutput.Margin = new BorderDouble(5, 5, 5, 2); filterOutput.Checked = false; filterOutput.TextColor = this.textColor; filterOutput.CheckedStateChanged += new CheckBox.CheckedStateChangedEventHandler(SetCorrectFilterOutputBehavior); filterOutput.VAnchor = Agg.UI.VAnchor.ParentBottom; topBarControls.AddChild(filterOutput); string autoUpperCaseChkTxt = LocalizedString.Get("Auto Uppercase"); autoUppercase = new CheckBox(autoUpperCaseChkTxt); autoUppercase.Margin = new BorderDouble(5, 5, 5, 2); autoUppercase.Checked = true; autoUppercase.TextColor = this.textColor; autoUppercase.VAnchor = Agg.UI.VAnchor.ParentBottom; topBarControls.AddChild(autoUppercase); manualEntryTopToBottomLayout.AddChild(topBarControls); } { outputScrollWidget = new OutputScroll(); //outputScrollWidget.Height = 100; outputScrollWidget.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; outputScrollWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor; outputScrollWidget.HAnchor = HAnchor.ParentLeftRight; outputScrollWidget.VAnchor = VAnchor.ParentBottomTop; outputScrollWidget.Margin = new BorderDouble(0,5); outputScrollWidget.Padding = new BorderDouble(3, 0); manualEntryTopToBottomLayout.AddChild(outputScrollWidget); } FlowLayoutWidget manualEntryLayout = new FlowLayoutWidget(FlowDirection.LeftToRight); manualEntryLayout.BackgroundColor = this.backgroundColor; manualEntryLayout.HAnchor = HAnchor.ParentLeftRight; { manualCommandTextEdit = new MHTextEditWidget(""); //manualCommandTextEdit.BackgroundColor = RGBA_Bytes.White; manualCommandTextEdit.Margin = new BorderDouble(right: 3); manualCommandTextEdit.HAnchor = HAnchor.ParentLeftRight; manualCommandTextEdit.VAnchor = VAnchor.ParentBottom; manualCommandTextEdit.ActualTextEditWidget.EnterPressed += new KeyEventHandler(manualCommandTextEdit_EnterPressed); manualCommandTextEdit.ActualTextEditWidget.KeyDown += new KeyEventHandler(manualCommandTextEdit_KeyDown); manualEntryLayout.AddChild(manualCommandTextEdit); } manualEntryTopToBottomLayout.AddChild(manualEntryLayout); Button clearConsoleButton = controlButtonFactory.Generate(LocalizedString.Get("Clear")); clearConsoleButton.Margin = new BorderDouble(0); clearConsoleButton.Click += (sender, e) => { outputScrollWidget.Clear(); }; Button closeButton = controlButtonFactory.Generate(LocalizedString.Get("Close")); closeButton.Click += (sender, e) => { UiThread.RunOnIdle(CloseWindow); }; sendCommand = controlButtonFactory.Generate(LocalizedString.Get("Send")); sendCommand.Click += new ButtonBase.ButtonEventHandler(sendManualCommandToPrinter_Click); FlowLayoutWidget bottomRowContainer = new FlowLayoutWidget(); bottomRowContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; bottomRowContainer.Margin = new BorderDouble(0, 3); bottomRowContainer.AddChild(sendCommand); bottomRowContainer.AddChild(clearConsoleButton); bottomRowContainer.AddChild(new HorizontalSpacer()); bottomRowContainer.AddChild(closeButton); manualEntryTopToBottomLayout.AddChild(bottomRowContainer); manualEntryTopToBottomLayout.AnchorAll(); topLeftToRightLayout.AddChild(manualEntryTopToBottomLayout); } AddHandlers(); AddChild(topLeftToRightLayout); SetCorrectFilterOutputBehavior(this, null); this.AnchorAll(); Title = LocalizedString.Get("MatterControl - Terminal"); this.ShowAsSystemWindow(); MinimumSize = new Vector2(Width, Height); }
public TerminalWidget(bool showInWindow) { this.BackgroundColor = backgroundColor; this.Padding = new BorderDouble(5, 0); FlowLayoutWidget topLeftToRightLayout = new FlowLayoutWidget(); topLeftToRightLayout.AnchorAll(); { FlowLayoutWidget manualEntryTopToBottomLayout = new FlowLayoutWidget(FlowDirection.TopToBottom); manualEntryTopToBottomLayout.VAnchor |= Agg.UI.VAnchor.ParentTop; manualEntryTopToBottomLayout.Padding = new BorderDouble(top: 8); { FlowLayoutWidget topBarControls = new FlowLayoutWidget(FlowDirection.LeftToRight); topBarControls.HAnchor |= HAnchor.ParentLeft; string autoUpperCaseChkTxt = LocalizedString.Get("Auto Uppercase"); autoUppercase = new CheckBox(autoUpperCaseChkTxt); autoUppercase.Margin = new BorderDouble(5, 5, 5, 2); autoUppercase.Checked = true; autoUppercase.TextColor = this.textColor; autoUppercase.VAnchor = Agg.UI.VAnchor.ParentBottom; topBarControls.AddChild(autoUppercase); manualEntryTopToBottomLayout.AddChild(topBarControls); } { FlowLayoutWidget leftToRight = new FlowLayoutWidget(); leftToRight.AnchorAll(); textScrollWidget = new TextScrollWidget(PrinterOutputCache.Instance.PrinterLines); //outputScrollWidget.Height = 100; textScrollWidget.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; textScrollWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor; textScrollWidget.HAnchor = HAnchor.ParentLeftRight; textScrollWidget.VAnchor = VAnchor.ParentBottomTop; textScrollWidget.Margin = new BorderDouble(0, 5); textScrollWidget.Padding = new BorderDouble(3, 0); leftToRight.AddChild(textScrollWidget); TextScrollBar textScrollBar = new TextScrollBar(textScrollWidget, 15); leftToRight.AddChild(textScrollBar); manualEntryTopToBottomLayout.AddChild(leftToRight); } FlowLayoutWidget manualEntryLayout = new FlowLayoutWidget(FlowDirection.LeftToRight); manualEntryLayout.BackgroundColor = this.backgroundColor; manualEntryLayout.HAnchor = HAnchor.ParentLeftRight; { manualCommandTextEdit = new MHTextEditWidget(""); //manualCommandTextEdit.BackgroundColor = RGBA_Bytes.White; manualCommandTextEdit.Margin = new BorderDouble(right: 3); manualCommandTextEdit.HAnchor = HAnchor.ParentLeftRight; manualCommandTextEdit.VAnchor = VAnchor.ParentBottom; manualCommandTextEdit.ActualTextEditWidget.EnterPressed += new KeyEventHandler(manualCommandTextEdit_EnterPressed); manualCommandTextEdit.ActualTextEditWidget.KeyDown += new KeyEventHandler(manualCommandTextEdit_KeyDown); manualEntryLayout.AddChild(manualCommandTextEdit); } manualEntryTopToBottomLayout.AddChild(manualEntryLayout); Button clearConsoleButton = controlButtonFactory.Generate(LocalizedString.Get("Clear")); clearConsoleButton.Margin = new BorderDouble(0); clearConsoleButton.Click += (sender, e) => { PrinterOutputCache.Instance.Clear(); }; //Output Console text to screen Button exportConsoleTextButton = controlButtonFactory.Generate(LocalizedString.Get("Export...")); exportConsoleTextButton.Click += (sender, mouseEvent) => { UiThread.RunOnIdle(DoExportExportLog_Click); }; Button closeButton = controlButtonFactory.Generate(LocalizedString.Get("Close")); closeButton.Click += (sender, e) => { UiThread.RunOnIdle(CloseWindow); }; sendCommand = controlButtonFactory.Generate(LocalizedString.Get("Send")); sendCommand.Click += new EventHandler(sendManualCommandToPrinter_Click); FlowLayoutWidget bottomRowContainer = new FlowLayoutWidget(); bottomRowContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; bottomRowContainer.Margin = new BorderDouble(0, 3); bottomRowContainer.AddChild(sendCommand); bottomRowContainer.AddChild(clearConsoleButton); bottomRowContainer.AddChild(exportConsoleTextButton); bottomRowContainer.AddChild(new HorizontalSpacer()); if (showInWindow) { bottomRowContainer.AddChild(closeButton); } manualEntryTopToBottomLayout.AddChild(bottomRowContainer); manualEntryTopToBottomLayout.AnchorAll(); topLeftToRightLayout.AddChild(manualEntryTopToBottomLayout); } AddChild(topLeftToRightLayout); this.AnchorAll(); }
public EditTemperaturePresetsWindow(string windowTitle, string temperatureSettings, EventHandler functionToCallOnSave) : base(360, 300) { Title = new LocalizedString(windowTitle).Translated; FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.AnchorAll(); topToBottom.Padding = new BorderDouble(3, 0, 3, 5); FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight); headerRow.HAnchor = HAnchor.ParentLeftRight; headerRow.Margin = new BorderDouble(0, 3, 0, 0); headerRow.Padding = new BorderDouble(0, 3, 0, 3); { string tempShortcutPresetLbl = new LocalizedString("Temperature Shortcut Presets").Translated; string tempShortcutPresetLblFull = string.Format("{0}:", tempShortcutPresetLbl); TextWidget elementHeader = new TextWidget(tempShortcutPresetLblFull, pointSize: 14); elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; elementHeader.HAnchor = HAnchor.ParentLeftRight; elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom; headerRow.AddChild(elementHeader); } topToBottom.AddChild(headerRow); FlowLayoutWidget presetsFormContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); //ListBox printerListContainer = new ListBox(); { presetsFormContainer.HAnchor = HAnchor.ParentLeftRight; presetsFormContainer.VAnchor = VAnchor.ParentBottomTop; presetsFormContainer.Padding = new BorderDouble(3); presetsFormContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; } topToBottom.AddChild(presetsFormContainer); this.functionToCallOnSave = functionToCallOnSave; BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; int oldHeight = textImageButtonFactory.FixedHeight; textImageButtonFactory.FixedHeight = 30; TextWidget tempTypeLabel = new TextWidget(windowTitle, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10); tempTypeLabel.Margin = new BorderDouble(3); tempTypeLabel.HAnchor = HAnchor.ParentLeft; presetsFormContainer.AddChild(tempTypeLabel); FlowLayoutWidget leftRightLabels = new FlowLayoutWidget(); leftRightLabels.Padding = new BorderDouble(3, 6); leftRightLabels.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; GuiWidget hLabelSpacer = new GuiWidget(); hLabelSpacer.HAnchor = HAnchor.ParentLeftRight; GuiWidget labelLabelContainer = new GuiWidget(); labelLabelContainer.Width = 66; labelLabelContainer.Height = 16; labelLabelContainer.Margin = new BorderDouble(3, 0); string labelLabelTxt = new LocalizedString("Label").Translated; TextWidget labelLabel = new TextWidget(string.Format(labelLabelTxt), textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10); labelLabel.HAnchor = HAnchor.ParentLeft; labelLabel.VAnchor = VAnchor.ParentCenter; labelLabelContainer.AddChild(labelLabel); GuiWidget tempLabelContainer = new GuiWidget(); tempLabelContainer.Width = 66; tempLabelContainer.Height = 16; tempLabelContainer.Margin = new BorderDouble(3, 0); TextWidget tempLabel = new TextWidget(string.Format("Temp (C)"), textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10); tempLabel.HAnchor = HAnchor.ParentLeft; tempLabel.VAnchor = VAnchor.ParentCenter; tempLabelContainer.AddChild(tempLabel); leftRightLabels.AddChild(hLabelSpacer); leftRightLabels.AddChild(labelLabelContainer); leftRightLabels.AddChild(tempLabelContainer); presetsFormContainer.AddChild(leftRightLabels); // put in the temperature edit controls string[] settingsArray = temperatureSettings.Split(','); int preset_count = 1; int tab_index = 0; for (int i = 0; i < settingsArray.Count() - 1; i += 2) { FlowLayoutWidget leftRightEdit = new FlowLayoutWidget(); leftRightEdit.Padding = new BorderDouble(3); leftRightEdit.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; string presetLabelTxt = new LocalizedString("Preset").Translated; TextWidget label = new TextWidget(string.Format("{1} {0}.", preset_count, presetLabelTxt), textColor: ActiveTheme.Instance.PrimaryTextColor); label.VAnchor = VAnchor.ParentCenter; leftRightEdit.AddChild(label); GuiWidget hSpacer = new GuiWidget(); hSpacer.HAnchor = HAnchor.ParentLeftRight; leftRightEdit.AddChild(hSpacer); MHTextEditWidget typeEdit = new MHTextEditWidget(settingsArray[i], pixelWidth: 60, tabIndex: tab_index++); typeEdit.Margin = new BorderDouble(3); leftRightEdit.AddChild(typeEdit); listWithValues.Add(typeEdit); double temperatureValue = 0; double.TryParse(settingsArray[i + 1], out temperatureValue); MHNumberEdit valueEdit = new MHNumberEdit(temperatureValue, minValue: 0, pixelWidth: 60, tabIndex: tab_index++); valueEdit.Margin = new BorderDouble(3); leftRightEdit.AddChild(valueEdit); listWithValues.Add(valueEdit); //leftRightEdit.AddChild(textImageButtonFactory.Generate("Delete")); presetsFormContainer.AddChild(leftRightEdit); preset_count += 1; } { FlowLayoutWidget leftRightEdit = new FlowLayoutWidget(); leftRightEdit.Padding = new BorderDouble(3); leftRightEdit.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; GuiWidget hSpacer = new GuiWidget(); hSpacer.HAnchor = HAnchor.ParentLeftRight; TextWidget maxWidgetLabel = new TextWidget(new LocalizedString("Max Temp.").Translated, textColor: ActiveTheme.Instance.PrimaryTextColor); maxWidgetLabel.VAnchor = VAnchor.ParentCenter; leftRightEdit.AddChild(maxWidgetLabel); leftRightEdit.AddChild(hSpacer); double maxTemperature = 0; double.TryParse(settingsArray[settingsArray.Count() - 1], out maxTemperature); MHNumberEdit valueEdit = new MHNumberEdit(maxTemperature, minValue: 0, pixelWidth: 60, tabIndex: tab_index); valueEdit.Margin = new BorderDouble(3); leftRightEdit.AddChild(valueEdit); listWithValues.Add(valueEdit); presetsFormContainer.AddChild(leftRightEdit); } textImageButtonFactory.FixedHeight = oldHeight; ShowAsSystemWindow(); Button savePresetsButton = textImageButtonFactory.Generate(new LocalizedString("Save").Translated); savePresetsButton.Click += new ButtonBase.ButtonEventHandler(save_Click); Button cancelPresetsButton = textImageButtonFactory.Generate(new LocalizedString("Cancel").Translated); cancelPresetsButton.Click += (sender, e) => { CloseOnIdle(); }; FlowLayoutWidget buttonRow = new FlowLayoutWidget(); buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Padding = new BorderDouble(0, 3); GuiWidget hButtonSpacer = new GuiWidget(); hButtonSpacer.HAnchor = HAnchor.ParentLeftRight; buttonRow.AddChild(savePresetsButton); buttonRow.AddChild(hButtonSpacer); buttonRow.AddChild(cancelPresetsButton); topToBottom.AddChild(buttonRow); AddChild(topToBottom); }
public CreateFolderWindow(Action<CreateFolderReturnInfo> functionToCallToCreateNamedFolder) : base(480, 180) { Title = "MatterControl - Create Folder"; AlwaysOnTopOfMain = true; this.functionToCallToCreateNamedFolder = functionToCallToCreateNamedFolder; FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.AnchorAll(); topToBottom.Padding = new BorderDouble(3, 0, 3, 5); // Creates Header FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight); headerRow.HAnchor = HAnchor.ParentLeftRight; headerRow.Margin = new BorderDouble(0, 3, 0, 0); headerRow.Padding = new BorderDouble(0, 3, 0, 3); BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; //Creates Text and adds into header { string createFolderLabel = "Create New Folder:".Localize(); TextWidget elementHeader = new TextWidget(createFolderLabel, pointSize: 14); elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; elementHeader.HAnchor = HAnchor.ParentLeftRight; elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom; headerRow.AddChild(elementHeader); topToBottom.AddChild(headerRow); this.AddChild(topToBottom); } //Creates container in the middle of window FlowLayoutWidget middleRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); { middleRowContainer.HAnchor = HAnchor.ParentLeftRight; middleRowContainer.VAnchor = VAnchor.ParentBottomTop; middleRowContainer.Padding = new BorderDouble(5); middleRowContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; } string fileNameLabel = "Folder Name".Localize(); TextWidget textBoxHeader = new TextWidget(fileNameLabel, pointSize: 12); textBoxHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; textBoxHeader.Margin = new BorderDouble(5); textBoxHeader.HAnchor = HAnchor.ParentLeft; //Adds text box and check box to the above container folderNameWidget = new MHTextEditWidget("", pixelWidth: 300, messageWhenEmptyAndNotSelected: "Enter a Folder Name Here".Localize()); folderNameWidget.Name = "Create Folder - Text Input"; folderNameWidget.HAnchor = HAnchor.ParentLeftRight; folderNameWidget.Margin = new BorderDouble(5); middleRowContainer.AddChild(textBoxHeader); middleRowContainer.AddChild(folderNameWidget); middleRowContainer.AddChild(new HorizontalSpacer()); topToBottom.AddChild(middleRowContainer); //Creates button container on the bottom of window FlowLayoutWidget buttonRow = new FlowLayoutWidget(FlowDirection.LeftToRight); { BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Padding = new BorderDouble(0, 3); } Button createFolderButton = textImageButtonFactory.Generate("Create".Localize(), centerText: true); createFolderButton.Visible = true; createFolderButton.Cursor = Cursors.Hand; buttonRow.AddChild(createFolderButton); createFolderButton.Click += new EventHandler(createFolderButton_Click); folderNameWidget.ActualTextEditWidget.EnterPressed += new KeyEventHandler(ActualTextEditWidget_EnterPressed); //Adds Create and Close Button to button container buttonRow.AddChild(new HorizontalSpacer()); Button cancelButton = textImageButtonFactory.Generate("Cancel".Localize(), centerText: true); cancelButton.Visible = true; cancelButton.Cursor = Cursors.Hand; buttonRow.AddChild(cancelButton); cancelButton.Click += (sender, e) => { CloseOnIdle(); }; topToBottom.AddChild(buttonRow); ShowAsSystemWindow(); }
public SaveAsWindow(SetPrintItemWrapperAndSave functionToCallOnSaveAs) : base(480, 250) { Title = "MatterControl - Save As"; FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.AnchorAll(); topToBottom.Padding = new BorderDouble(3, 0, 3, 5); // Creates Header FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight); headerRow.HAnchor = HAnchor.ParentLeftRight; headerRow.Margin = new BorderDouble(0, 3, 0, 0); headerRow.Padding = new BorderDouble(0, 3, 0, 3); BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; //Creates Text and adds into header { string saveAsLabel = "Save New Design to Queue:"; TextWidget elementHeader = new TextWidget(saveAsLabel, pointSize: 14); elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; elementHeader.HAnchor = HAnchor.ParentLeftRight; elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom; headerRow.AddChild(elementHeader); topToBottom.AddChild(headerRow); this.AddChild(topToBottom); } //Creates container in the middle of window FlowLayoutWidget presetsFormContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); { presetsFormContainer.HAnchor = HAnchor.ParentLeftRight; presetsFormContainer.VAnchor = VAnchor.ParentBottomTop; presetsFormContainer.Padding = new BorderDouble(5); presetsFormContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; } string fileNameLabel = "Design Name"; TextWidget textBoxHeader = new TextWidget(fileNameLabel, pointSize: 12); textBoxHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; textBoxHeader.Margin = new BorderDouble(5); textBoxHeader.HAnchor = HAnchor.ParentLeft; string fileNameLabelFull = "Enter the name of your design."; TextWidget textBoxHeaderFull = new TextWidget(fileNameLabelFull, pointSize: 9); textBoxHeaderFull.TextColor = ActiveTheme.Instance.PrimaryTextColor; textBoxHeaderFull.Margin = new BorderDouble(5); textBoxHeaderFull.HAnchor = HAnchor.ParentLeftRight; //Adds text box and check box to the above container MHTextEditWidget textToAddWidget = new MHTextEditWidget("", pixelWidth: 300, messageWhenEmptyAndNotSelected: "Enter a Design Name Here"); textToAddWidget.HAnchor = HAnchor.ParentLeftRight; textToAddWidget.Margin = new BorderDouble(5); GuiWidget cTSpacer = new GuiWidget(); cTSpacer.HAnchor = HAnchor.ParentLeftRight; CheckBox addToLibraryOption = new CheckBox("Also save to Library", ActiveTheme.Instance.PrimaryTextColor); addToLibraryOption.Margin = new BorderDouble(5); addToLibraryOption.HAnchor = HAnchor.ParentLeftRight; presetsFormContainer.AddChild(textBoxHeader); presetsFormContainer.AddChild(textBoxHeaderFull); presetsFormContainer.AddChild(textToAddWidget); presetsFormContainer.AddChild(cTSpacer); presetsFormContainer.AddChild(addToLibraryOption); topToBottom.AddChild(presetsFormContainer); //Creates button container on the bottom of window FlowLayoutWidget buttonRow = new FlowLayoutWidget(FlowDirection.LeftToRight); { BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Padding = new BorderDouble(0, 3); } Button saveAsButton = textImageButtonFactory.Generate("Save As".Localize(), centerText: true); saveAsButton.Visible = true; saveAsButton.Cursor = Cursors.Hand; buttonRow.AddChild(saveAsButton); saveAsButton.Click += (sender, e) => { string newName = textToAddWidget.ActualTextEditWidget.Text; if (newName != "") { string fileName = "{0}.stl".FormatWith(Path.GetRandomFileName()); string fileNameAndPath = Path.Combine(ApplicationDataStorage.Instance.ApplicationLibraryDataPath, fileName); PrintItem printItem = new PrintItem(); printItem.Name = newName; printItem.FileLocation = Path.GetFullPath(fileNameAndPath); printItem.PrintItemCollectionID = LibraryData.Instance.LibraryCollection.Id; printItem.Commit(); PrintItemWrapper printItemWrapper = new PrintItemWrapper(printItem); QueueData.Instance.AddItem(printItemWrapper); if (addToLibraryOption.Checked) { LibraryData.Instance.AddItem(printItemWrapper); } functionToCallOnSaveAs(printItemWrapper); CloseOnIdle(); } }; //Adds SaveAs and Close Button to button container GuiWidget hButtonSpacer = new GuiWidget(); hButtonSpacer.HAnchor = HAnchor.ParentLeftRight; buttonRow.AddChild(hButtonSpacer); Button cancelButton = textImageButtonFactory.Generate("Cancel", centerText: true); cancelButton.Visible = true; cancelButton.Cursor = Cursors.Hand; buttonRow.AddChild(cancelButton); cancelButton.Click += (sender, e) => { CloseOnIdle(); }; topToBottom.AddChild(buttonRow); ShowAsSystemWindow(); }
public SaveAsWindow(SetPrintItemWrapperAndSave functionToCallOnSaveAs) : base(480, 250) { Title = "MatterControl - Save As"; this.functionToCallOnSaveAs = functionToCallOnSaveAs; FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.AnchorAll(); topToBottom.Padding = new BorderDouble(3, 0, 3, 5); // Creates Header FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight); headerRow.HAnchor = HAnchor.ParentLeftRight; headerRow.Margin = new BorderDouble(0, 3, 0, 0); headerRow.Padding = new BorderDouble(0, 3, 0, 3); BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; //Creates Text and adds into header { string saveAsLabel = "Save New Design to Queue:"; TextWidget elementHeader = new TextWidget(saveAsLabel, pointSize: 14); elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; elementHeader.HAnchor = HAnchor.ParentLeftRight; elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom; headerRow.AddChild(elementHeader); topToBottom.AddChild(headerRow); this.AddChild(topToBottom); } //Creates container in the middle of window FlowLayoutWidget middleRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); { middleRowContainer.HAnchor = HAnchor.ParentLeftRight; middleRowContainer.VAnchor = VAnchor.ParentBottomTop; middleRowContainer.Padding = new BorderDouble(5); middleRowContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; } string fileNameLabel = "Design Name"; TextWidget textBoxHeader = new TextWidget(fileNameLabel, pointSize: 12); textBoxHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; textBoxHeader.Margin = new BorderDouble(5); textBoxHeader.HAnchor = HAnchor.ParentLeft; string fileNameLabelFull = "Enter the name of your design."; TextWidget textBoxHeaderFull = new TextWidget(fileNameLabelFull, pointSize: 9); textBoxHeaderFull.TextColor = ActiveTheme.Instance.PrimaryTextColor; textBoxHeaderFull.Margin = new BorderDouble(5); textBoxHeaderFull.HAnchor = HAnchor.ParentLeftRight; //Adds text box and check box to the above container textToAddWidget = new MHTextEditWidget("", pixelWidth: 300, messageWhenEmptyAndNotSelected: "Enter a Design Name Here"); textToAddWidget.HAnchor = HAnchor.ParentLeftRight; textToAddWidget.Margin = new BorderDouble(5); addToLibraryOption = new CheckBox("Also save to Library", ActiveTheme.Instance.PrimaryTextColor); addToLibraryOption.Margin = new BorderDouble(5); addToLibraryOption.HAnchor = HAnchor.ParentLeftRight; middleRowContainer.AddChild(textBoxHeader); middleRowContainer.AddChild(textBoxHeaderFull); middleRowContainer.AddChild(textToAddWidget); middleRowContainer.AddChild(new HorizontalSpacer()); middleRowContainer.AddChild(addToLibraryOption); topToBottom.AddChild(middleRowContainer); //Creates button container on the bottom of window FlowLayoutWidget buttonRow = new FlowLayoutWidget(FlowDirection.LeftToRight); { BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Padding = new BorderDouble(0, 3); } Button saveAsButton = textImageButtonFactory.Generate("Save As".Localize(), centerText: true); saveAsButton.Visible = true; saveAsButton.Cursor = Cursors.Hand; buttonRow.AddChild(saveAsButton); saveAsButton.Click += new EventHandler(saveAsButton_Click); textToAddWidget.ActualTextEditWidget.EnterPressed += new KeyEventHandler(ActualTextEditWidget_EnterPressed); //Adds SaveAs and Close Button to button container buttonRow.AddChild(new HorizontalSpacer()); Button cancelButton = textImageButtonFactory.Generate("Cancel", centerText: true); cancelButton.Visible = true; cancelButton.Cursor = Cursors.Hand; buttonRow.AddChild(cancelButton); cancelButton.Click += (sender, e) => { CloseOnIdle(); }; topToBottom.AddChild(buttonRow); ShowAsSystemWindow(); }
public MarkdownEditPage(UIField uiField) { this.WindowTitle = "MatterControl - " + "Markdown Edit".Localize(); this.HeaderText = "Edit Page".Localize() + ":"; var tabControl = new SimpleTabs(theme, new GuiWidget()) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, }; tabControl.TabBar.BackgroundColor = theme.TabBarBackground; tabControl.TabBar.Padding = 0; contentRow.AddChild(tabControl); contentRow.Padding = 0; var editContainer = new GuiWidget() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, Padding = theme.DefaultContainerPadding, BackgroundColor = theme.BackgroundColor }; editWidget = new MHTextEditWidget("", theme, multiLine: true, typeFace: ApplicationController.GetTypeFace(NamedTypeFace.Liberation_Mono)) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, Name = this.Name }; editWidget.DrawFromHintedCache(); editWidget.ActualTextEditWidget.VAnchor = VAnchor.Stretch; editContainer.AddChild(editWidget); markdownWidget = new MarkdownWidget(theme, true) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, Margin = 0, Padding = 0, }; var previewTab = new ToolTab("Preview", "Preview".Localize(), tabControl, markdownWidget, theme, hasClose: false) { Name = "Preview Tab" }; tabControl.AddTab(previewTab); var editTab = new ToolTab("Edit", "Edit".Localize(), tabControl, editContainer, theme, hasClose: false) { Name = "Edit Tab" }; tabControl.AddTab(editTab); tabControl.ActiveTabChanged += (s, e) => { if (tabControl.SelectedTabIndex == 1) { markdownWidget.Markdown = editWidget.Text; } }; tabControl.SelectedTabIndex = 0; var saveButton = theme.CreateDialogButton("Save".Localize()); saveButton.Click += (s, e) => { uiField.SetValue( editWidget.Text.Replace("\n", "\\n"), userInitiated: true); this.DialogWindow.CloseOnIdle(); }; this.AddPageAction(saveButton); var link = new LinkLabel("Markdown Help", theme) { Margin = new BorderDouble(right: 20), VAnchor = VAnchor.Center }; link.Click += (s, e) => { ApplicationController.Instance.LaunchBrowser("https://guides.github.com/features/mastering-markdown/"); }; footerRow.AddChild(link, 0); }
public TerminalWidget(PrinterConfig printer, ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.printer = printer; this.Name = "TerminalWidget"; this.Padding = new BorderDouble(5, 0); // Header var headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight) { HAnchor = HAnchor.Left | HAnchor.Stretch, Padding = new BorderDouble(0, 8) }; this.AddChild(headerRow); filterOutput = new CheckBox("Filter Output".Localize(), textSize: theme.DefaultFontSize) { TextColor = theme.TextColor, VAnchor = VAnchor.Bottom, }; filterOutput.CheckedStateChanged += (s, e) => { if (filterOutput.Checked) { textScrollWidget.SetLineStartFilter(new string[] { "<-wait", "<-ok", "<-T" }); } else { textScrollWidget.SetLineStartFilter(null); } UserSettings.Instance.Fields.SetBool(UserSettingsKey.TerminalFilterOutput, filterOutput.Checked); }; headerRow.AddChild(filterOutput); autoUppercase = new CheckBox("Auto Uppercase".Localize(), textSize: theme.DefaultFontSize) { Margin = new BorderDouble(left: 25), Checked = UserSettings.Instance.Fields.GetBool(UserSettingsKey.TerminalAutoUppercase, true), TextColor = theme.TextColor, VAnchor = VAnchor.Bottom }; autoUppercase.CheckedStateChanged += (s, e) => { UserSettings.Instance.Fields.SetBool(UserSettingsKey.TerminalAutoUppercase, autoUppercase.Checked); }; headerRow.AddChild(autoUppercase); // Body var bodyRow = new FlowLayoutWidget() { Margin = new BorderDouble(bottom: 4), HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch }; this.AddChild(bodyRow); textScrollWidget = new TextScrollWidget(printer, printer.Connection.TerminalLog.PrinterLines) { BackgroundColor = theme.MinimalShade, TextColor = theme.TextColor, HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, Margin = 0, Padding = new BorderDouble(3, 0) }; bodyRow.AddChild(textScrollWidget); bodyRow.AddChild(new TextScrollBar(textScrollWidget, 15) { ThumbColor = theme.AccentMimimalOverlay, BackgroundColor = theme.SlightShade, Margin = 0 }); // Input Row var inputRow = new FlowLayoutWidget(FlowDirection.LeftToRight) { BackgroundColor = this.BackgroundColor, HAnchor = HAnchor.Stretch, Margin = new BorderDouble(bottom: 2) }; this.AddChild(inputRow); manualCommandTextEdit = new MHTextEditWidget("", theme, typeFace: ApplicationController.GetTypeFace(NamedTypeFace.Liberation_Mono)) { Margin = new BorderDouble(right: 3), HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Bottom }; manualCommandTextEdit.ActualTextEditWidget.EnterPressed += (s, e) => { SendManualCommand(); }; manualCommandTextEdit.ActualTextEditWidget.KeyDown += (s, keyEvent) => { bool changeToHistory = false; if (keyEvent.KeyCode == Keys.Up) { commandHistoryIndex--; if (commandHistoryIndex < 0) { commandHistoryIndex = 0; } changeToHistory = true; } else if (keyEvent.KeyCode == Keys.Down) { commandHistoryIndex++; if (commandHistoryIndex > commandHistory.Count - 1) { commandHistoryIndex = commandHistory.Count - 1; } else { changeToHistory = true; } } else if (keyEvent.KeyCode == Keys.Escape) { manualCommandTextEdit.Text = ""; } if (changeToHistory && commandHistory.Count > 0) { manualCommandTextEdit.Text = commandHistory[commandHistoryIndex]; } }; inputRow.AddChild(manualCommandTextEdit); // Footer var toolbarPadding = theme.ToolbarPadding; var footerRow = new FlowLayoutWidget { HAnchor = HAnchor.Stretch, Padding = new BorderDouble(0, toolbarPadding.Bottom, toolbarPadding.Right, toolbarPadding.Top) }; this.AddChild(footerRow); var sendButton = theme.CreateDialogButton("Send".Localize()); sendButton.Margin = theme.ButtonSpacing; sendButton.Click += (s, e) => { SendManualCommand(); }; footerRow.AddChild(sendButton); var clearButton = theme.CreateDialogButton("Clear".Localize()); clearButton.Margin = theme.ButtonSpacing; clearButton.Click += (s, e) => { printer.Connection.TerminalLog.Clear(); }; footerRow.AddChild(clearButton); var exportButton = theme.CreateDialogButton("Export".Localize()); exportButton.Margin = theme.ButtonSpacing; exportButton.Click += (s, e) => { UiThread.RunOnIdle(() => { AggContext.FileDialogs.SaveFileDialog( new SaveFileDialogParams("Save as Text|*.txt") { Title = "MatterControl: Terminal Log", ActionButtonLabel = "Export", FileName = "print_log.txt" }, (saveParams) => { if (!string.IsNullOrEmpty(saveParams.FileName)) { string filePathToSave = saveParams.FileName; if (filePathToSave != null && filePathToSave != "") { try { textScrollWidget.WriteToFile(filePathToSave); } catch (UnauthorizedAccessException ex) { Debug.Print(ex.Message); printer.Connection.TerminalLog.PrinterLines.Add(""); printer.Connection.TerminalLog.PrinterLines.Add(writeFaildeWaring); printer.Connection.TerminalLog.PrinterLines.Add(cantAccessPath.FormatWith(filePathToSave)); printer.Connection.TerminalLog.PrinterLines.Add(""); UiThread.RunOnIdle(() => { StyledMessageBox.ShowMessageBox(ex.Message, "Couldn't save file".Localize()); }); } } } }); }); }; footerRow.AddChild(exportButton); footerRow.AddChild(new HorizontalSpacer()); this.AnchorAll(); }
// private as you can't make one private OutputScrollWindow() : base(400, 300) { this.BackgroundColor = backgroundColor; this.Padding = new BorderDouble(5); FlowLayoutWidget topLeftToRightLayout = new FlowLayoutWidget(); topLeftToRightLayout.AnchorAll(); { FlowLayoutWidget manualEntryTopToBottomLayout = new FlowLayoutWidget(FlowDirection.TopToBottom); manualEntryTopToBottomLayout.VAnchor |= Agg.UI.VAnchor.ParentTop; manualEntryTopToBottomLayout.Padding = new BorderDouble(5); { FlowLayoutWidget OutputWindowsLayout = new FlowLayoutWidget(FlowDirection.LeftToRight); OutputWindowsLayout.HAnchor |= HAnchor.ParentLeft; string filterOutputChkTxt = new LocalizedString("Filter Output").Translated; filterOutput = new CheckBox(filterOutputChkTxt); filterOutput.Margin = new BorderDouble(5, 5, 5, 2); filterOutput.Checked = false; filterOutput.TextColor = this.textColor; filterOutput.CheckedStateChanged += new CheckBox.CheckedStateChangedEventHandler(SetCorrectFilterOutputBehavior); OutputWindowsLayout.AddChild(filterOutput); string autoUpperCaseChkTxt = new LocalizedString("Auto Uppercase").Translated; autoUppercase = new CheckBox(autoUpperCaseChkTxt); autoUppercase.Margin = new BorderDouble(5, 5, 5, 2); autoUppercase.Checked = true; autoUppercase.TextColor = this.textColor; OutputWindowsLayout.AddChild(autoUppercase); monitorPrinterTemperature = new CheckBox("Monitor Temperature"); monitorPrinterTemperature.Margin = new BorderDouble(5, 5, 5, 2); monitorPrinterTemperature.Checked = PrinterCommunication.Instance.MonitorPrinterTemperature; monitorPrinterTemperature.TextColor = this.textColor; monitorPrinterTemperature.CheckedStateChanged += new CheckBox.CheckedStateChangedEventHandler(monitorPrinterTemperature_CheckedStateChanged); manualEntryTopToBottomLayout.AddChild(OutputWindowsLayout); } { FlowLayoutWidget OutputWindowsLayout = new FlowLayoutWidget(FlowDirection.LeftToRight); OutputWindowsLayout.VAnchor = VAnchor.ParentBottomTop; outputScrollWidget = new OutputScroll(); outputScrollWidget.Height = 100; outputScrollWidget.BackgroundColor = RGBA_Bytes.White; outputScrollWidget.HAnchor = HAnchor.ParentLeftRight; outputScrollWidget.VAnchor = VAnchor.ParentBottomTop; outputScrollWidget.Margin = new BorderDouble(0, 5); OutputWindowsLayout.AddChild(outputScrollWidget); manualEntryTopToBottomLayout.AddChild(outputScrollWidget); } FlowLayoutWidget manualEntryLayout = new FlowLayoutWidget(FlowDirection.LeftToRight); manualEntryLayout.BackgroundColor = this.backgroundColor; manualEntryLayout.HAnchor = HAnchor.ParentLeftRight; { manualCommandTextEdit = new MHTextEditWidget(""); manualCommandTextEdit.BackgroundColor = RGBA_Bytes.White; manualCommandTextEdit.HAnchor = HAnchor.ParentLeftRight; manualCommandTextEdit.VAnchor = VAnchor.ParentCenter; manualCommandTextEdit.ActualTextEditWidget.EnterPressed += new KeyEventHandler(manualCommandTextEdit_EnterPressed); manualCommandTextEdit.ActualTextEditWidget.KeyDown += new KeyEventHandler(manualCommandTextEdit_KeyDown); manualEntryLayout.AddChild(manualCommandTextEdit); sendCommand = controlButtonFactory.Generate(new LocalizedString("Send").Translated); sendCommand.Margin = new BorderDouble(5, 0); sendCommand.Click += new ButtonBase.ButtonEventHandler(sendManualCommandToPrinter_Click); manualEntryLayout.AddChild(sendCommand); } manualEntryTopToBottomLayout.AddChild(manualEntryLayout); manualEntryTopToBottomLayout.AnchorAll(); topLeftToRightLayout.AddChild(manualEntryTopToBottomLayout); } AddHandlers(); AddChild(topLeftToRightLayout); SetCorrectFilterOutputBehavior(this, null); this.AnchorAll(); Title = new LocalizedString("MatterControl - Terminal").Translated; this.ShowAsSystemWindow(); MinimumSize = new Vector2(Width, Height); }
private FlowLayoutWidget GetManualMoveBar() { FlowLayoutWidget manualMoveBar = new FlowLayoutWidget(); manualMoveBar.HAnchor = HAnchor.ParentLeftRight; manualMoveBar.Margin = new BorderDouble(3, 0, 3, 6); manualMoveBar.Padding = new BorderDouble(0); TextWidget xMoveLabel = new TextWidget("X:"); xMoveLabel.Margin = new BorderDouble(0, 0, 6, 0); xMoveLabel.VAnchor = VAnchor.ParentCenter; MHTextEditWidget xMoveEdit = new MHTextEditWidget("0"); xMoveEdit.Margin = new BorderDouble(0, 0, 6, 0); xMoveEdit.VAnchor = VAnchor.ParentCenter; TextWidget yMoveLabel = new TextWidget("Y:"); yMoveLabel.Margin = new BorderDouble(0, 0, 6, 0); yMoveLabel.VAnchor = VAnchor.ParentCenter; MHTextEditWidget yMoveEdit = new MHTextEditWidget("0"); yMoveEdit.Margin = new BorderDouble(0, 0, 6, 0); yMoveEdit.VAnchor = VAnchor.ParentCenter; TextWidget zMoveLabel = new TextWidget("Z:"); zMoveLabel.Margin = new BorderDouble(0, 0, 6, 0); zMoveLabel.VAnchor = VAnchor.ParentCenter; MHTextEditWidget zMoveEdit = new MHTextEditWidget("0"); zMoveEdit.Margin = new BorderDouble(0, 0, 6, 0); zMoveEdit.VAnchor = VAnchor.ParentCenter; manualMove = textImageButtonFactory.Generate("MOVE TO"); manualMove.Margin = new BorderDouble(0, 0, 6, 0); manualMove.Click += new ButtonBase.ButtonEventHandler(disableMotors_Click); GuiWidget spacer = new GuiWidget(); spacer.HAnchor = HAnchor.ParentLeftRight; manualMoveBar.AddChild(xMoveLabel); manualMoveBar.AddChild(xMoveEdit); manualMoveBar.AddChild(yMoveLabel); manualMoveBar.AddChild(yMoveEdit); manualMoveBar.AddChild(zMoveLabel); manualMoveBar.AddChild(zMoveEdit); manualMoveBar.AddChild(manualMove); manualMoveBar.AddChild(spacer); return(manualMoveBar); }
private FlowLayoutWidget createMacroNameContainer() { FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom); container.Margin = new BorderDouble(0, 5); BorderDouble elementMargin = new BorderDouble(top: 3); string macroNameLabelTxt = LocalizedString.Get("Macro Name"); string macroNameLabelTxtFull = string.Format("{0}:", macroNameLabelTxt); TextWidget macroNameLabel = new TextWidget(macroNameLabelTxtFull, 0, 0, 12); macroNameLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; macroNameLabel.HAnchor = HAnchor.ParentLeftRight; macroNameLabel.Margin = new BorderDouble(0, 0, 0, 1); macroNameInput = new MHTextEditWidget(windowController.ActiveMacro.Name); macroNameInput.HAnchor = HAnchor.ParentLeftRight; string giveMacroANameLabel = LocalizedString.Get("Give the macro a name"); string giveMacroANameLabelFull = string.Format("{0}.", giveMacroANameLabel); macroNameError = new TextWidget(giveMacroANameLabelFull, 0, 0, 10); macroNameError.TextColor = ActiveTheme.Instance.PrimaryTextColor; macroNameError.HAnchor = HAnchor.ParentLeftRight; macroNameError.Margin = elementMargin; container.AddChild(macroNameLabel); container.AddChild(macroNameInput); container.AddChild(macroNameError); container.HAnchor = HAnchor.ParentLeftRight; return container; }
private FlowLayoutWidget createMacroCommandContainer() { FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom); container.Margin = new BorderDouble(0, 5); BorderDouble elementMargin = new BorderDouble(top: 3); string macroCommandLabelTxt = LocalizedString.Get("Macro Commands"); string macroCommandLabelTxtFull = string.Format("{0}:", macroCommandLabelTxt); TextWidget macroCommandLabel = new TextWidget(macroCommandLabelTxtFull, 0, 0, 12); macroCommandLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; macroCommandLabel.HAnchor = HAnchor.ParentLeftRight; macroCommandLabel.Margin = new BorderDouble(0, 0, 0, 1); macroCommandInput = new MHTextEditWidget(windowController.ActiveMacro.Value, pixelHeight: 120, multiLine: true); macroCommandInput.HAnchor = HAnchor.ParentLeftRight; macroCommandInput.VAnchor = VAnchor.ParentBottomTop; macroCommandInput.ActualTextEditWidget.VAnchor = VAnchor.ParentBottomTop; string shouldBeGCodeLabel = LocalizedString.Get("This should be in 'G-Code'"); string shouldBeGCodeLabelFull = string.Format("{0}.", shouldBeGCodeLabel); macroCommandError = new TextWidget(shouldBeGCodeLabelFull, 0, 0, 10); macroCommandError.TextColor = ActiveTheme.Instance.PrimaryTextColor; macroCommandError.HAnchor = HAnchor.ParentLeftRight; macroCommandError.Margin = elementMargin; container.AddChild(macroCommandLabel); container.AddChild(macroCommandInput); container.AddChild(macroCommandError); container.HAnchor = HAnchor.ParentLeftRight; container.VAnchor = VAnchor.ParentBottomTop; return container; }
public SaveAsWindow(Action <SaveAsReturnInfo> functionToCallOnSaveAs, List <ProviderLocatorNode> providerLocator, bool showQueue, bool getNewName) : base(480, 500) { textImageButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.TabLabelUnselected; textImageButtonFactory.disabledFillColor = new RGBA_Bytes(); Title = "MatterControl - " + "Save As".Localize(); AlwaysOnTopOfMain = true; this.Name = "Save As Window"; this.functionToCallOnSaveAs = functionToCallOnSaveAs; FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.AnchorAll(); topToBottom.Padding = new BorderDouble(3, 0, 3, 5); // Creates Header FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight); headerRow.HAnchor = HAnchor.ParentLeftRight; headerRow.Margin = new BorderDouble(0, 3, 0, 0); headerRow.Padding = new BorderDouble(0, 3, 0, 3); BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; //Creates Text and adds into header { string saveAsLabel = "Save New Design".Localize() + ":"; TextWidget elementHeader = new TextWidget(saveAsLabel, pointSize: 14); elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; elementHeader.HAnchor = HAnchor.ParentLeftRight; elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom; headerRow.AddChild(elementHeader); topToBottom.AddChild(headerRow); } //Creates container in the middle of window FlowLayoutWidget middleRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); { middleRowContainer.HAnchor = HAnchor.ParentLeftRight; middleRowContainer.VAnchor = VAnchor.ParentBottomTop; middleRowContainer.Padding = new BorderDouble(5); middleRowContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; } librarySelectorWidget = new LibrarySelectorWidget(showQueue); // put in the bread crumb widget FolderBreadCrumbWidget breadCrumbWidget = new FolderBreadCrumbWidget(librarySelectorWidget.SetCurrentLibraryProvider, librarySelectorWidget.CurrentLibraryProvider); middleRowContainer.AddChild(breadCrumbWidget); librarySelectorWidget.ChangedCurrentLibraryProvider += breadCrumbWidget.SetBreadCrumbs; // put in the area to pick the provider to save to { //Adds text box and check box to the above container GuiWidget chooseWindow = new GuiWidget(10, 30); chooseWindow.HAnchor = HAnchor.ParentLeftRight; chooseWindow.VAnchor = VAnchor.ParentBottomTop; chooseWindow.Margin = new BorderDouble(5); chooseWindow.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; chooseWindow.Padding = new BorderDouble(3); chooseWindow.AddChild(librarySelectorWidget); middleRowContainer.AddChild(chooseWindow); } // put in the area to type in the new name if (getNewName) { string fileNameLabel = "Design Name".Localize(); TextWidget fileNameHeader = new TextWidget(fileNameLabel, pointSize: 12); fileNameHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; fileNameHeader.Margin = new BorderDouble(5); fileNameHeader.HAnchor = HAnchor.ParentLeft; //Adds text box and check box to the above container textToAddWidget = new MHTextEditWidget("", pixelWidth: 300, messageWhenEmptyAndNotSelected: "Enter a Design Name Here".Localize()); textToAddWidget.HAnchor = HAnchor.ParentLeftRight; textToAddWidget.Margin = new BorderDouble(5); textToAddWidget.ActualTextEditWidget.EnterPressed += new KeyEventHandler(ActualTextEditWidget_EnterPressed); middleRowContainer.AddChild(fileNameHeader); middleRowContainer.AddChild(textToAddWidget); } middleRowContainer.AddChild(new HorizontalSpacer()); topToBottom.AddChild(middleRowContainer); //Creates button container on the bottom of window FlowLayoutWidget buttonRow = new FlowLayoutWidget(FlowDirection.LeftToRight); { BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Padding = new BorderDouble(0, 3); } saveAsButton = textImageButtonFactory.Generate("Save".Localize(), centerText: true); saveAsButton.Name = "Save As Save Button"; // Disable the save as button until the user actually selects a provider saveAsButton.Enabled = false; saveAsButton.Cursor = Cursors.Hand; buttonRow.AddChild(saveAsButton); librarySelectorWidget.ChangedCurrentLibraryProvider += EnableSaveAsButtonOnChangedLibraryProvider; saveAsButton.Click += new EventHandler(saveAsButton_Click); //Adds SaveAs and Close Button to button container buttonRow.AddChild(new HorizontalSpacer()); Button cancelButton = textImageButtonFactory.Generate("Cancel".Localize(), centerText: true); cancelButton.Visible = true; cancelButton.Cursor = Cursors.Hand; buttonRow.AddChild(cancelButton); cancelButton.Click += (sender, e) => { CloseOnIdle(); }; topToBottom.AddChild(buttonRow); #if __ANDROID__ this.AddChild(new SoftKeyboardContentOffset(topToBottom)); #else this.AddChild(topToBottom); #endif ShowAsSystemWindow(); }
public EditTemperaturePresetsWindow(string windowTitle, string temperatureSettings, EventHandler functionToCallOnSave) : base(360, 300) { AlwaysOnTopOfMain = true; Title = LocalizedString.Get(windowTitle); FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.AnchorAll(); topToBottom.Padding = new BorderDouble(3, 0, 3, 5); FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight); headerRow.HAnchor = HAnchor.ParentLeftRight; headerRow.Margin = new BorderDouble(0, 3, 0, 0); headerRow.Padding = new BorderDouble(0, 3, 0, 3); { string tempShortcutPresetLabel = LocalizedString.Get("Temperature Shortcut Presets"); string tempShortcutPresetLabelFull = string.Format("{0}:", tempShortcutPresetLabel); TextWidget elementHeader = new TextWidget(tempShortcutPresetLabelFull, pointSize: 14); elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; elementHeader.HAnchor = HAnchor.ParentLeftRight; elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom; headerRow.AddChild(elementHeader); } topToBottom.AddChild(headerRow); FlowLayoutWidget presetsFormContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); //ListBox printerListContainer = new ListBox(); { presetsFormContainer.HAnchor = HAnchor.ParentLeftRight; presetsFormContainer.VAnchor = VAnchor.ParentBottomTop; presetsFormContainer.Padding = new BorderDouble(3); presetsFormContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; } topToBottom.AddChild(presetsFormContainer); this.functionToCallOnSave = functionToCallOnSave; BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; double oldHeight = textImageButtonFactory.FixedHeight; textImageButtonFactory.FixedHeight = 30 * GuiWidget.DeviceScale; TextWidget tempTypeLabel = new TextWidget(windowTitle, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10); tempTypeLabel.Margin = new BorderDouble(3); tempTypeLabel.HAnchor = HAnchor.ParentLeft; presetsFormContainer.AddChild(tempTypeLabel); FlowLayoutWidget leftRightLabels = new FlowLayoutWidget(); leftRightLabels.Padding = new BorderDouble(3, 6); leftRightLabels.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; GuiWidget hLabelSpacer = new GuiWidget(); hLabelSpacer.HAnchor = HAnchor.ParentLeftRight; GuiWidget labelLabelContainer = new GuiWidget(); labelLabelContainer.Width = 66; labelLabelContainer.Height = 16; labelLabelContainer.Margin = new BorderDouble(3, 0); string labelLabelTxt = LocalizedString.Get("Label"); TextWidget labelLabel = new TextWidget(string.Format(labelLabelTxt), textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10); labelLabel.HAnchor = HAnchor.ParentLeft; labelLabel.VAnchor = VAnchor.ParentCenter; labelLabelContainer.AddChild(labelLabel); GuiWidget tempLabelContainer = new GuiWidget(); tempLabelContainer.Width = 66; tempLabelContainer.Height = 16; tempLabelContainer.Margin = new BorderDouble(3, 0); TextWidget tempLabel = new TextWidget(string.Format("Temp (C)"), textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10); tempLabel.HAnchor = HAnchor.ParentLeft; tempLabel.VAnchor = VAnchor.ParentCenter; tempLabelContainer.AddChild(tempLabel); leftRightLabels.AddChild(hLabelSpacer); leftRightLabels.AddChild(labelLabelContainer); leftRightLabels.AddChild(tempLabelContainer); presetsFormContainer.AddChild(leftRightLabels); // put in the temperature edit controls string[] settingsArray = temperatureSettings.Split(','); int preset_count = 1; int tab_index = 0; for (int i = 0; i < settingsArray.Count() - 1; i += 2) { FlowLayoutWidget leftRightEdit = new FlowLayoutWidget(); leftRightEdit.Padding = new BorderDouble(3); leftRightEdit.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; string presetLabelTxt = LocalizedString.Get("Preset"); TextWidget label = new TextWidget(string.Format("{1} {0}", preset_count, presetLabelTxt), textColor: ActiveTheme.Instance.PrimaryTextColor); label.VAnchor = VAnchor.ParentCenter; leftRightEdit.AddChild(label); leftRightEdit.AddChild(new HorizontalSpacer()); MHTextEditWidget typeEdit = new MHTextEditWidget(settingsArray[i], pixelWidth: 60, tabIndex: tab_index++); typeEdit.Margin = new BorderDouble(3); leftRightEdit.AddChild(typeEdit); listWithValues.Add(typeEdit); double temperatureValue = 0; double.TryParse(settingsArray[i + 1], out temperatureValue); MHNumberEdit valueEdit = new MHNumberEdit(temperatureValue, minValue: 0, pixelWidth: 60, tabIndex: tab_index++); valueEdit.Margin = new BorderDouble(3); leftRightEdit.AddChild(valueEdit); listWithValues.Add(valueEdit); //leftRightEdit.AddChild(textImageButtonFactory.Generate("Delete")); presetsFormContainer.AddChild(leftRightEdit); preset_count += 1; } { FlowLayoutWidget leftRightEdit = new FlowLayoutWidget(); leftRightEdit.Padding = new BorderDouble(3); leftRightEdit.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; TextWidget maxWidgetLabel = new TextWidget(LocalizedString.Get("Max Temp"), textColor: ActiveTheme.Instance.PrimaryTextColor); maxWidgetLabel.VAnchor = VAnchor.ParentCenter; leftRightEdit.AddChild(maxWidgetLabel); leftRightEdit.AddChild(new HorizontalSpacer()); double maxTemperature = 0; double.TryParse(settingsArray[settingsArray.Count() - 1], out maxTemperature); MHNumberEdit valueEdit = new MHNumberEdit(maxTemperature, minValue: 0, pixelWidth: 60, tabIndex: tab_index); valueEdit.Margin = new BorderDouble(3); leftRightEdit.AddChild(valueEdit); listWithValues.Add(valueEdit); presetsFormContainer.AddChild(leftRightEdit); } textImageButtonFactory.FixedHeight = oldHeight; ShowAsSystemWindow(); MinimumSize = new Vector2(360, 300); Button savePresetsButton = textImageButtonFactory.Generate(LocalizedString.Get("Save")); savePresetsButton.Click += new EventHandler(save_Click); Button cancelPresetsButton = textImageButtonFactory.Generate(LocalizedString.Get("Cancel")); cancelPresetsButton.Click += (sender, e) => { CloseOnIdle(); }; FlowLayoutWidget buttonRow = new FlowLayoutWidget(); buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Padding = new BorderDouble(0, 3); GuiWidget hButtonSpacer = new GuiWidget(); hButtonSpacer.HAnchor = HAnchor.ParentLeftRight; buttonRow.AddChild(savePresetsButton); buttonRow.AddChild(hButtonSpacer); buttonRow.AddChild(cancelPresetsButton); topToBottom.AddChild(buttonRow); AddChild(topToBottom); }
private void AddAdvancedPannel(GuiWidget settingsColumn) { var advancedPanel = new FlowLayoutWidget(FlowDirection.TopToBottom); var advancedSection = new SectionWidget("Advanced".Localize(), advancedPanel, theme, serializationKey: "ApplicationSettings-Advanced", expanded: false) { Name = "Advanced Section", HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Margin = 0 }; settingsColumn.AddChild(advancedSection); theme.ApplyBoxStyle(advancedSection); // Touch Screen Mode this.AddSettingsRow( new SettingsItem( "Touch Screen Mode".Localize(), theme, new SettingsItem.ToggleSwitchConfig() { Checked = UserSettings.Instance.get(UserSettingsKey.ApplicationDisplayMode) == "touchscreen", ToggleAction = (itemChecked) => { string displayMode = itemChecked ? "touchscreen" : "responsive"; if (displayMode != UserSettings.Instance.get(UserSettingsKey.ApplicationDisplayMode)) { UserSettings.Instance.set(UserSettingsKey.ApplicationDisplayMode, displayMode); UiThread.RunOnIdle(() => ApplicationController.Instance.ReloadAll().ConfigureAwait(false)); } } }), advancedPanel); AddUserBoolToggle(advancedPanel, "Enable Socketeer Client".Localize(), UserSettingsKey.ApplicationUseSocketeer, true, false); AddUserBoolToggle(advancedPanel, "Utilize High Res Monitors".Localize(), UserSettingsKey.ApplicationUseHeigResDisplays, true, false); var openCacheButton = new IconButton(StaticData.Instance.LoadIcon("fa-link_16.png", 16, 16).SetToColor(theme.TextColor), theme) { ToolTipText = "Open Folder".Localize(), }; openCacheButton.Click += (s, e) => UiThread.RunOnIdle(() => { Process.Start(ApplicationDataStorage.ApplicationUserDataPath); }); this.AddSettingsRow( new SettingsItem( "Application Storage".Localize(), openCacheButton, theme), advancedPanel); var clearCacheButton = new HoverIconButton(StaticData.Instance.LoadIcon("remove.png", 16, 16).SetToColor(theme.TextColor), theme) { ToolTipText = "Clear Cache".Localize(), }; clearCacheButton.Click += (s, e) => UiThread.RunOnIdle(() => { CacheDirectory.DeleteCacheData(); }); this.AddSettingsRow( new SettingsItem( "Application Cache".Localize(), clearCacheButton, theme), advancedPanel); #if DEBUG var configureIcon = StaticData.Instance.LoadIcon("fa-cog_16.png", 16, 16).SetToColor(theme.TextColor); var configurePluginsButton = new IconButton(configureIcon, theme) { ToolTipText = "Configure Plugins".Localize(), Margin = 0 }; configurePluginsButton.Click += (s, e) => { UiThread.RunOnIdle(() => { DialogWindow.Show <PluginsPage>(); }); }; this.AddSettingsRow( new SettingsItem( "Plugins".Localize(), configurePluginsButton, theme), advancedPanel); #endif var gitHubPat = UserSettings.Instance.get("GitHubPat"); if (gitHubPat == null) { gitHubPat = ""; } var accessToken = new MHTextEditWidget(gitHubPat, theme, pixelWidth: 350, messageWhenEmptyAndNotSelected: "Enter Person Access Token".Localize()) { HAnchor = HAnchor.Absolute, Margin = new BorderDouble(5), Name = "GitHubPat Edit Field" }; accessToken.ActualTextEditWidget.EnterPressed += (s, e) => { UserSettings.Instance.set("GitHubPat", accessToken.ActualTextEditWidget.Text); }; accessToken.Closed += (s, e) => { UserSettings.Instance.set("GitHubPat", accessToken.ActualTextEditWidget.Text); }; this.AddSettingsRow( new SettingsItem( "GitHub Personal Access Token".Localize(), accessToken, theme) { ToolTipText = "This is used to increase the number of downloads allowed when browsing GitHub repositories".Localize(), }, advancedPanel); advancedPanel.Children <SettingsItem>().First().Border = new BorderDouble(0, 1); }
public TerminalWidget(bool showInWindow) { this.BackgroundColor = backgroundColor; this.Padding = new BorderDouble(5, 0); FlowLayoutWidget topLeftToRightLayout = new FlowLayoutWidget(); topLeftToRightLayout.AnchorAll(); { FlowLayoutWidget manualEntryTopToBottomLayout = new FlowLayoutWidget(FlowDirection.TopToBottom); manualEntryTopToBottomLayout.VAnchor |= Agg.UI.VAnchor.ParentTop; manualEntryTopToBottomLayout.Padding = new BorderDouble(top: 8); { FlowLayoutWidget topBarControls = new FlowLayoutWidget(FlowDirection.LeftToRight); topBarControls.HAnchor |= HAnchor.ParentLeft; { string filterOutputChkTxt = LocalizedString.Get("Filter Output"); filterOutput = new CheckBox(filterOutputChkTxt); filterOutput.Margin = new BorderDouble(5, 5, 5, 2); filterOutput.TextColor = this.textColor; filterOutput.CheckedStateChanged += (object sender, EventArgs e) => { if (filterOutput.Checked) { textScrollWidget.SetLineStartFilter(new string[] { "<-wait", "<-ok", "->M105", "<-T" }); } else { textScrollWidget.SetLineStartFilter(null); } UserSettings.Instance.Fields.SetBool(TerminalFilterOutputKey, filterOutput.Checked); }; filterOutput.VAnchor = Agg.UI.VAnchor.ParentBottom; topBarControls.AddChild(filterOutput); } { string autoUpperCaseChkTxt = LocalizedString.Get("Auto Uppercase"); autoUppercase = new CheckBox(autoUpperCaseChkTxt); autoUppercase.Margin = new BorderDouble(5, 5, 5, 2); autoUppercase.Checked = UserSettings.Instance.Fields.GetBool(TerminalAutoUppercaseKey, true); autoUppercase.TextColor = this.textColor; autoUppercase.VAnchor = Agg.UI.VAnchor.ParentBottom; topBarControls.AddChild(autoUppercase); autoUppercase.CheckedStateChanged += (sender, e) => { UserSettings.Instance.Fields.SetBool(TerminalAutoUppercaseKey, autoUppercase.Checked); }; manualEntryTopToBottomLayout.AddChild(topBarControls); } } { FlowLayoutWidget leftToRight = new FlowLayoutWidget(); leftToRight.AnchorAll(); textScrollWidget = new TextScrollWidget(PrinterOutputCache.Instance.PrinterLines); //outputScrollWidget.Height = 100; textScrollWidget.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; textScrollWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor; textScrollWidget.HAnchor = HAnchor.ParentLeftRight; textScrollWidget.VAnchor = VAnchor.ParentBottomTop; textScrollWidget.Margin = new BorderDouble(0, 5); textScrollWidget.Padding = new BorderDouble(3, 0); leftToRight.AddChild(textScrollWidget); TextScrollBar textScrollBar = new TextScrollBar(textScrollWidget, 15); leftToRight.AddChild(textScrollBar); manualEntryTopToBottomLayout.AddChild(leftToRight); } FlowLayoutWidget manualEntryLayout = new FlowLayoutWidget(FlowDirection.LeftToRight); manualEntryLayout.BackgroundColor = this.backgroundColor; manualEntryLayout.HAnchor = HAnchor.ParentLeftRight; { manualCommandTextEdit = new MHTextEditWidget(""); //manualCommandTextEdit.BackgroundColor = RGBA_Bytes.White; manualCommandTextEdit.Margin = new BorderDouble(right: 3); manualCommandTextEdit.HAnchor = HAnchor.ParentLeftRight; manualCommandTextEdit.VAnchor = VAnchor.ParentBottom; manualCommandTextEdit.ActualTextEditWidget.EnterPressed += new KeyEventHandler(manualCommandTextEdit_EnterPressed); manualCommandTextEdit.ActualTextEditWidget.KeyDown += new KeyEventHandler(manualCommandTextEdit_KeyDown); manualEntryLayout.AddChild(manualCommandTextEdit); } manualEntryTopToBottomLayout.AddChild(manualEntryLayout); Button clearConsoleButton = controlButtonFactory.Generate(LocalizedString.Get("Clear")); clearConsoleButton.Margin = new BorderDouble(0); clearConsoleButton.Click += (sender, e) => { PrinterOutputCache.Instance.Clear(); }; //Output Console text to screen Button exportConsoleTextButton = controlButtonFactory.Generate(LocalizedString.Get("Export...")); exportConsoleTextButton.Click += (sender, mouseEvent) => { UiThread.RunOnIdle(DoExportExportLog_Click); }; Button closeButton = controlButtonFactory.Generate(LocalizedString.Get("Close")); closeButton.Click += (sender, e) => { UiThread.RunOnIdle(CloseWindow); }; sendCommand = controlButtonFactory.Generate(LocalizedString.Get("Send")); sendCommand.Click += new EventHandler(sendManualCommandToPrinter_Click); FlowLayoutWidget bottomRowContainer = new FlowLayoutWidget(); bottomRowContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; bottomRowContainer.Margin = new BorderDouble(0, 3); bottomRowContainer.AddChild(sendCommand); bottomRowContainer.AddChild(clearConsoleButton); bottomRowContainer.AddChild(exportConsoleTextButton); bottomRowContainer.AddChild(new HorizontalSpacer()); if (showInWindow) { bottomRowContainer.AddChild(closeButton); } manualEntryTopToBottomLayout.AddChild(bottomRowContainer); manualEntryTopToBottomLayout.AnchorAll(); topLeftToRightLayout.AddChild(manualEntryTopToBottomLayout); } AddChild(topLeftToRightLayout); this.AnchorAll(); }
public SaveAsWindow(Action<SaveAsReturnInfo> functionToCallOnSaveAs, List<ProviderLocatorNode> providerLocator) : base(480, 450) { Title = "MatterControl - " + "Save As".Localize(); AlwaysOnTopOfMain = true; this.functionToCallOnSaveAs = functionToCallOnSaveAs; FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.AnchorAll(); topToBottom.Padding = new BorderDouble(3, 0, 3, 5); // Creates Header FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight); headerRow.HAnchor = HAnchor.ParentLeftRight; headerRow.Margin = new BorderDouble(0, 3, 0, 0); headerRow.Padding = new BorderDouble(0, 3, 0, 3); BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; //Creates Text and adds into header { string saveAsLabel = "Save New Design".Localize() + ":"; TextWidget elementHeader = new TextWidget(saveAsLabel, pointSize: 14); elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; elementHeader.HAnchor = HAnchor.ParentLeftRight; elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom; headerRow.AddChild(elementHeader); topToBottom.AddChild(headerRow); this.AddChild(topToBottom); } //Creates container in the middle of window FlowLayoutWidget middleRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); { middleRowContainer.HAnchor = HAnchor.ParentLeftRight; middleRowContainer.VAnchor = VAnchor.ParentBottomTop; middleRowContainer.Padding = new BorderDouble(5); middleRowContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; } librarySelectorWidget = new LibrarySelectorWidget(); // put in the bread crumb widget FolderBreadCrumbWidget breadCrumbWidget = new FolderBreadCrumbWidget(librarySelectorWidget.SetCurrentLibraryProvider, librarySelectorWidget.CurrentLibraryProvider); middleRowContainer.AddChild(breadCrumbWidget); librarySelectorWidget.ChangedCurrentLibraryProvider += breadCrumbWidget.SetBreadCrumbs; // put in the area to pick the provider to save to { //Adds text box and check box to the above container GuiWidget chooseWindow = new GuiWidget(10, 30); chooseWindow.HAnchor = HAnchor.ParentLeftRight; chooseWindow.VAnchor = VAnchor.ParentBottomTop; chooseWindow.Margin = new BorderDouble(5); chooseWindow.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; chooseWindow.Padding = new BorderDouble(3); chooseWindow.AddChild(librarySelectorWidget); middleRowContainer.AddChild(chooseWindow); } // put in the area to type in the new name { string fileNameLabel = "Design Name".Localize(); TextWidget textBoxHeader = new TextWidget(fileNameLabel, pointSize: 12); textBoxHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; textBoxHeader.Margin = new BorderDouble(5); textBoxHeader.HAnchor = HAnchor.ParentLeft; //Adds text box and check box to the above container textToAddWidget = new MHTextEditWidget("", pixelWidth: 300, messageWhenEmptyAndNotSelected: "Enter a Design Name Here".Localize()); textToAddWidget.HAnchor = HAnchor.ParentLeftRight; textToAddWidget.Margin = new BorderDouble(5); textToAddWidget.ActualTextEditWidget.EnterPressed += new KeyEventHandler(ActualTextEditWidget_EnterPressed); middleRowContainer.AddChild(textBoxHeader); middleRowContainer.AddChild(textToAddWidget); } middleRowContainer.AddChild(new HorizontalSpacer()); topToBottom.AddChild(middleRowContainer); //Creates button container on the bottom of window FlowLayoutWidget buttonRow = new FlowLayoutWidget(FlowDirection.LeftToRight); { BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Padding = new BorderDouble(0, 3); } Button saveAsButton = textImageButtonFactory.Generate("Save".Localize(), centerText: true); saveAsButton.Visible = true; saveAsButton.Cursor = Cursors.Hand; buttonRow.AddChild(saveAsButton); saveAsButton.Click += new EventHandler(saveAsButton_Click); //Adds SaveAs and Close Button to button container buttonRow.AddChild(new HorizontalSpacer()); Button cancelButton = textImageButtonFactory.Generate("Cancel".Localize(), centerText: true); cancelButton.Visible = true; cancelButton.Cursor = Cursors.Hand; buttonRow.AddChild(cancelButton); cancelButton.Click += (sender, e) => { CloseOnIdle(); }; topToBottom.AddChild(buttonRow); ShowAsSystemWindow(); }
public SaveAsWindow(Action <SaveAsReturnInfo> functionToCallOnSaveAs) : base(480, 250) { Title = "MatterControl - Save As"; AlwaysOnTopOfMain = true; this.functionToCallOnSaveAs = functionToCallOnSaveAs; FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.AnchorAll(); topToBottom.Padding = new BorderDouble(3, 0, 3, 5); // Creates Header FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight); headerRow.HAnchor = HAnchor.ParentLeftRight; headerRow.Margin = new BorderDouble(0, 3, 0, 0); headerRow.Padding = new BorderDouble(0, 3, 0, 3); BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; //Creates Text and adds into header { string saveAsLabel = "Save New Design to Queue".Localize() + ":"; TextWidget elementHeader = new TextWidget(saveAsLabel, pointSize: 14); elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; elementHeader.HAnchor = HAnchor.ParentLeftRight; elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom; headerRow.AddChild(elementHeader); topToBottom.AddChild(headerRow); this.AddChild(topToBottom); } //Creates container in the middle of window FlowLayoutWidget middleRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); { middleRowContainer.HAnchor = HAnchor.ParentLeftRight; middleRowContainer.VAnchor = VAnchor.ParentBottomTop; middleRowContainer.Padding = new BorderDouble(5); middleRowContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; } string fileNameLabel = "Design Name".Localize(); TextWidget textBoxHeader = new TextWidget(fileNameLabel, pointSize: 12); textBoxHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; textBoxHeader.Margin = new BorderDouble(5); textBoxHeader.HAnchor = HAnchor.ParentLeft; string fileNameLabelFull = "Enter the name of your design.".Localize();; TextWidget textBoxHeaderFull = new TextWidget(fileNameLabelFull, pointSize: 9); textBoxHeaderFull.TextColor = ActiveTheme.Instance.PrimaryTextColor; textBoxHeaderFull.Margin = new BorderDouble(5); textBoxHeaderFull.HAnchor = HAnchor.ParentLeftRight; //Adds text box and check box to the above container textToAddWidget = new MHTextEditWidget("", pixelWidth: 300, messageWhenEmptyAndNotSelected: "Enter a Design Name Here".Localize()); textToAddWidget.HAnchor = HAnchor.ParentLeftRight; textToAddWidget.Margin = new BorderDouble(5); addToLibraryOption = new CheckBox("Also save to Library".Localize(), ActiveTheme.Instance.PrimaryTextColor); addToLibraryOption.Margin = new BorderDouble(5); addToLibraryOption.HAnchor = HAnchor.ParentLeftRight; middleRowContainer.AddChild(textBoxHeader); middleRowContainer.AddChild(textBoxHeaderFull); middleRowContainer.AddChild(textToAddWidget); middleRowContainer.AddChild(new HorizontalSpacer()); middleRowContainer.AddChild(addToLibraryOption); topToBottom.AddChild(middleRowContainer); //Creates button container on the bottom of window FlowLayoutWidget buttonRow = new FlowLayoutWidget(FlowDirection.LeftToRight); { BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Padding = new BorderDouble(0, 3); } Button saveAsButton = textImageButtonFactory.Generate("Save As".Localize(), centerText: true); saveAsButton.Visible = true; saveAsButton.Cursor = Cursors.Hand; buttonRow.AddChild(saveAsButton); saveAsButton.Click += new EventHandler(saveAsButton_Click); textToAddWidget.ActualTextEditWidget.EnterPressed += new KeyEventHandler(ActualTextEditWidget_EnterPressed); //Adds SaveAs and Close Button to button container buttonRow.AddChild(new HorizontalSpacer()); Button cancelButton = textImageButtonFactory.Generate("Cancel".Localize(), centerText: true); cancelButton.Visible = true; cancelButton.Cursor = Cursors.Hand; buttonRow.AddChild(cancelButton); cancelButton.Click += (sender, e) => { CloseOnIdle(); }; topToBottom.AddChild(buttonRow); ShowAsSystemWindow(); }
public SaveAsPage(Action <string, ILibraryContainer> itemSaver) : base(itemSaver, "Save".Localize()) { this.WindowTitle = "MatterControl - " + "Save As".Localize(); this.Name = "Save As Window"; this.WindowSize = new Vector2(480 * GuiWidget.DeviceScale, 500 * GuiWidget.DeviceScale); this.HeaderText = "Save New Design".Localize() + ":"; // put in the area to type in the new name var fileNameHeader = new TextWidget("Design Name".Localize(), pointSize: 12) { TextColor = theme.TextColor, Margin = new BorderDouble(5), HAnchor = HAnchor.Left }; contentRow.AddChild(fileNameHeader); // Adds text box and check box to the above container itemNameWidget = new MHTextEditWidget("", theme, pixelWidth: 300, messageWhenEmptyAndNotSelected: "Enter a Design Name Here".Localize()) { HAnchor = HAnchor.Stretch, Margin = new BorderDouble(5), Name = "Design Name Edit Field" }; itemNameWidget.ActualTextEditWidget.EnterPressed += (s, e) => { if (librarySelectorWidget.ActiveContainer is ILibraryWritableContainer) { acceptButton.InvokeClick(); } }; contentRow.AddChild(itemNameWidget); var icon = StaticData.Instance.LoadIcon("fa-folder-new_16.png", 16, 16).SetToColor(ApplicationController.Instance.MenuTheme.TextColor); var isEnabled = false; if (librarySelectorWidget.ActiveContainer is ILibraryWritableContainer writableContainer) { isEnabled = writableContainer?.AllowAction(ContainerActions.AddContainers) == true; } var folderButtonRow = new FlowLayoutWidget() { HAnchor = HAnchor.Left | HAnchor.Fit, }; contentRow.AddChild(folderButtonRow); // add a create folder button var createFolderButton = new TextIconButton("Create Folder".Localize(), icon, theme) { Enabled = isEnabled, VAnchor = VAnchor.Absolute, DrawIconOverlayOnDisabled = true }; createFolderButton.Name = "Create Folder In Button"; folderButtonRow.AddChild(createFolderButton); var refreshButton = new IconButton(StaticData.Instance.LoadIcon("fa-refresh_14.png", 16, 16).SetToColor(theme.TextColor), theme) { ToolTipText = "Refresh Folder".Localize(), Enabled = isEnabled, }; refreshButton.Click += (s, e) => { librarySelectorWidget.ActiveContainer.Load(); }; // folderButtonRow.AddChild(refreshButton); createFolderButton.Click += CreateFolder_Click; // add a message to navigate to a writable folder var writableMessage = new TextWidget("Please select a writable folder".Localize(), pointSize: theme.DefaultFontSize) { TextColor = theme.TextColor, Margin = new BorderDouble(5, 0), VAnchor = VAnchor.Center }; footerRow.AddChild(writableMessage, 0); footerRow.AddChild(new HorizontalSpacer(), 1); // change footer in this context footerRow.HAnchor = HAnchor.Stretch; footerRow.Margin = 0; libraryNavContext.ContainerChanged += (s, e) => { var writable = libraryNavContext.ActiveContainer is ILibraryWritableContainer; createFolderButton.Enabled = writable; refreshButton.Enabled = writable; writableMessage.Visible = !writable; }; }
public TerminalWidget(bool showInWindow) { this.Name = "TerminalWidget"; this.BackgroundColor = backgroundColor; this.Padding = new BorderDouble(5, 0); FlowLayoutWidget topLeftToRightLayout = new FlowLayoutWidget(); topLeftToRightLayout.AnchorAll(); { FlowLayoutWidget manualEntryTopToBottomLayout = new FlowLayoutWidget(FlowDirection.TopToBottom); manualEntryTopToBottomLayout.VAnchor |= Agg.UI.VAnchor.ParentTop; manualEntryTopToBottomLayout.Padding = new BorderDouble(top: 8); { FlowLayoutWidget topBarControls = new FlowLayoutWidget(FlowDirection.LeftToRight); topBarControls.HAnchor |= HAnchor.ParentLeft; { string filterOutputChkTxt = LocalizedString.Get("Filter Output"); filterOutput = new CheckBox(filterOutputChkTxt); filterOutput.Margin = new BorderDouble(5, 5, 5, 2); filterOutput.TextColor = this.textColor; filterOutput.CheckedStateChanged += (object sender, EventArgs e) => { if (filterOutput.Checked) { textScrollWidget.SetLineStartFilter(new string[] { "<-wait", "<-ok", "->M105", "<-T" }); } else { textScrollWidget.SetLineStartFilter(null); } UserSettings.Instance.Fields.SetBool(TerminalFilterOutputKey, filterOutput.Checked); }; filterOutput.VAnchor = Agg.UI.VAnchor.ParentBottom; topBarControls.AddChild(filterOutput); } { string autoUpperCaseChkTxt = LocalizedString.Get("Auto Uppercase"); autoUppercase = new CheckBox(autoUpperCaseChkTxt); autoUppercase.Margin = new BorderDouble(5, 5, 5, 2); autoUppercase.Checked = UserSettings.Instance.Fields.GetBool(TerminalAutoUppercaseKey, true); autoUppercase.TextColor = this.textColor; autoUppercase.VAnchor = Agg.UI.VAnchor.ParentBottom; topBarControls.AddChild(autoUppercase); autoUppercase.CheckedStateChanged += (sender, e) => { UserSettings.Instance.Fields.SetBool(TerminalAutoUppercaseKey, autoUppercase.Checked); }; manualEntryTopToBottomLayout.AddChild(topBarControls); } } { FlowLayoutWidget leftToRight = new FlowLayoutWidget(); leftToRight.AnchorAll(); textScrollWidget = new TextScrollWidget(PrinterOutputCache.Instance.PrinterLines); //outputScrollWidget.Height = 100; Debug.WriteLine(PrinterOutputCache.Instance.PrinterLines); textScrollWidget.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; textScrollWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor; textScrollWidget.HAnchor = HAnchor.ParentLeftRight; textScrollWidget.VAnchor = VAnchor.ParentBottomTop; textScrollWidget.Margin = new BorderDouble(0, 5); textScrollWidget.Padding = new BorderDouble(3, 0); leftToRight.AddChild(textScrollWidget); TextScrollBar textScrollBar = new TextScrollBar(textScrollWidget, 15); leftToRight.AddChild(textScrollBar); manualEntryTopToBottomLayout.AddChild(leftToRight); } FlowLayoutWidget manualEntryLayout = new FlowLayoutWidget(FlowDirection.LeftToRight); manualEntryLayout.BackgroundColor = this.backgroundColor; manualEntryLayout.HAnchor = HAnchor.ParentLeftRight; { manualCommandTextEdit = new MHTextEditWidget("", typeFace: ApplicationController.MonoSpacedTypeFace); //manualCommandTextEdit.BackgroundColor = RGBA_Bytes.White; manualCommandTextEdit.Margin = new BorderDouble(right: 3); manualCommandTextEdit.HAnchor = HAnchor.ParentLeftRight; manualCommandTextEdit.VAnchor = VAnchor.ParentBottom; manualCommandTextEdit.ActualTextEditWidget.EnterPressed += new KeyEventHandler(manualCommandTextEdit_EnterPressed); manualCommandTextEdit.ActualTextEditWidget.KeyDown += new KeyEventHandler(manualCommandTextEdit_KeyDown); manualEntryLayout.AddChild(manualCommandTextEdit); } manualEntryTopToBottomLayout.AddChild(manualEntryLayout); Button clearConsoleButton = controlButtonFactory.Generate(LocalizedString.Get("Clear")); clearConsoleButton.Margin = new BorderDouble(0); clearConsoleButton.Click += (sender, e) => { PrinterOutputCache.Instance.Clear(); }; //Output Console text to screen Button exportConsoleTextButton = controlButtonFactory.Generate(LocalizedString.Get("Export...")); exportConsoleTextButton.Click += (sender, mouseEvent) => { UiThread.RunOnIdle(DoExportExportLog_Click); }; Button closeButton = controlButtonFactory.Generate(LocalizedString.Get("Close")); closeButton.Click += (sender, e) => { UiThread.RunOnIdle(CloseWindow); }; sendCommand = controlButtonFactory.Generate(LocalizedString.Get("Send")); sendCommand.Click += new EventHandler(sendManualCommandToPrinter_Click); FlowLayoutWidget bottomRowContainer = new FlowLayoutWidget(); bottomRowContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; bottomRowContainer.Margin = new BorderDouble(0, 3); bottomRowContainer.AddChild(sendCommand); bottomRowContainer.AddChild(clearConsoleButton); bottomRowContainer.AddChild(exportConsoleTextButton); bottomRowContainer.AddChild(new HorizontalSpacer()); if (showInWindow) { bottomRowContainer.AddChild(closeButton); } manualEntryTopToBottomLayout.AddChild(bottomRowContainer); manualEntryTopToBottomLayout.AnchorAll(); topLeftToRightLayout.AddChild(manualEntryTopToBottomLayout); } AddChild(topLeftToRightLayout); this.AnchorAll(); }
public CreateFolderWindow(Action <CreateFolderReturnInfo> functionToCallToCreateNamedFolder) : base(480, 180) { Title = "MatterControl - Create Folder"; AlwaysOnTopOfMain = true; this.functionToCallToCreateNamedFolder = functionToCallToCreateNamedFolder; FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.AnchorAll(); topToBottom.Padding = new BorderDouble(3, 0, 3, 5); // Creates Header FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight); headerRow.HAnchor = HAnchor.ParentLeftRight; headerRow.Margin = new BorderDouble(0, 3, 0, 0); headerRow.Padding = new BorderDouble(0, 3, 0, 3); BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; //Creates Text and adds into header { string createFolderLabel = "Create New Folder:".Localize(); TextWidget elementHeader = new TextWidget(createFolderLabel, pointSize: 14); elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; elementHeader.HAnchor = HAnchor.ParentLeftRight; elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom; headerRow.AddChild(elementHeader); topToBottom.AddChild(headerRow); this.AddChild(topToBottom); } //Creates container in the middle of window FlowLayoutWidget middleRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); { middleRowContainer.HAnchor = HAnchor.ParentLeftRight; middleRowContainer.VAnchor = VAnchor.ParentBottomTop; middleRowContainer.Padding = new BorderDouble(5); middleRowContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; } string fileNameLabel = "Folder Name".Localize(); TextWidget textBoxHeader = new TextWidget(fileNameLabel, pointSize: 12); textBoxHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; textBoxHeader.Margin = new BorderDouble(5); textBoxHeader.HAnchor = HAnchor.ParentLeft; //Adds text box and check box to the above container textToAddWidget = new MHTextEditWidget("", pixelWidth: 300, messageWhenEmptyAndNotSelected: "Enter a Folder Name Here".Localize()); textToAddWidget.HAnchor = HAnchor.ParentLeftRight; textToAddWidget.Margin = new BorderDouble(5); middleRowContainer.AddChild(textBoxHeader); middleRowContainer.AddChild(textToAddWidget); middleRowContainer.AddChild(new HorizontalSpacer()); topToBottom.AddChild(middleRowContainer); //Creates button container on the bottom of window FlowLayoutWidget buttonRow = new FlowLayoutWidget(FlowDirection.LeftToRight); { BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Padding = new BorderDouble(0, 3); } Button createFolderButton = textImageButtonFactory.Generate("Create".Localize(), centerText: true); createFolderButton.Visible = true; createFolderButton.Cursor = Cursors.Hand; buttonRow.AddChild(createFolderButton); createFolderButton.Click += new EventHandler(createFolderButton_Click); textToAddWidget.ActualTextEditWidget.EnterPressed += new KeyEventHandler(ActualTextEditWidget_EnterPressed); //Adds Create and Close Button to button container buttonRow.AddChild(new HorizontalSpacer()); Button cancelButton = textImageButtonFactory.Generate("Cancel".Localize(), centerText: true); cancelButton.Visible = true; cancelButton.Cursor = Cursors.Hand; buttonRow.AddChild(cancelButton); cancelButton.Click += (sender, e) => { CloseOnIdle(); }; topToBottom.AddChild(buttonRow); ShowAsSystemWindow(); }
private FlowLayoutWidget GetManualMoveBar() { FlowLayoutWidget manualMoveBar = new FlowLayoutWidget(); manualMoveBar.HAnchor = HAnchor.ParentLeftRight; manualMoveBar.Margin = new BorderDouble(3, 0, 3, 6); manualMoveBar.Padding = new BorderDouble(0); TextWidget xMoveLabel = new TextWidget("X:"); xMoveLabel.Margin = new BorderDouble(0, 0, 6, 0); xMoveLabel.VAnchor = VAnchor.ParentCenter; MHTextEditWidget xMoveEdit = new MHTextEditWidget("0"); xMoveEdit.Margin = new BorderDouble(0, 0, 6, 0); xMoveEdit.VAnchor = VAnchor.ParentCenter; TextWidget yMoveLabel = new TextWidget("Y:"); yMoveLabel.Margin = new BorderDouble(0, 0, 6, 0); yMoveLabel.VAnchor = VAnchor.ParentCenter; MHTextEditWidget yMoveEdit = new MHTextEditWidget("0"); yMoveEdit.Margin = new BorderDouble(0, 0, 6, 0); yMoveEdit.VAnchor = VAnchor.ParentCenter; TextWidget zMoveLabel = new TextWidget("Z:"); zMoveLabel.Margin = new BorderDouble(0, 0, 6, 0); zMoveLabel.VAnchor = VAnchor.ParentCenter; MHTextEditWidget zMoveEdit = new MHTextEditWidget("0"); zMoveEdit.Margin = new BorderDouble(0, 0, 6, 0); zMoveEdit.VAnchor = VAnchor.ParentCenter; manualMove = textImageButtonFactory.Generate("MOVE TO"); manualMove.Margin = new BorderDouble(0, 0, 6, 0); manualMove.Click += new ButtonBase.ButtonEventHandler(disableMotors_Click); GuiWidget spacer = new GuiWidget(); spacer.HAnchor = HAnchor.ParentLeftRight; manualMoveBar.AddChild(xMoveLabel); manualMoveBar.AddChild(xMoveEdit); manualMoveBar.AddChild(yMoveLabel); manualMoveBar.AddChild(yMoveEdit); manualMoveBar.AddChild(zMoveLabel); manualMoveBar.AddChild(zMoveEdit); manualMoveBar.AddChild(manualMove); manualMoveBar.AddChild(spacer); return manualMoveBar; }