Example #1
0
 public Type(Pokedex pokedex, int id, LocalizedString name, DamageClass damage_class)
     : base(pokedex)
 {
     ID = id;
     Name = name;
     DamageClass = damage_class;
 }
Example #2
0
 public ItemLoading(int id, String name)
 {
     ID = id;
     Name = name;
     Value3 = Value4 = Value5 = Value6 = null;
     NameLocalized = null;
 }
        public LocalizedStringContract(LocalizedString str)
        {
            ParamIs.NotNull(() => str);

            Language = str.Language;
            Value = str.Value;
        }
 public Ability(Pokedex pokedex, int value, LocalizedString name)
     : base(pokedex)
 {
     Value = value;
     Name = name;
     // todo: Nice description text
 }
        public void LocalizedStringTest_Is_Implicitly_String()
        {
            //Arrange
            var s = new LocalizedString("Hello World");
            //Act

            //Assert
            Assert.IsTrue(s == "Hello World");
        }
        public void LocalizedStringTest_Concattination_Operator_Works()
        {
            //Arrange
            var s = new LocalizedString("Hello");
            //Act

            //Assert
            Assert.IsTrue((s + " World") == "Hello World");
        }
        public void LocalizedStringTest_Current_Culture_Stored()
        {
            //Arrange
            var s = new LocalizedString("Hello World");
            //Act

            //Assert
            Assert.IsTrue(s.GetValue(Thread.CurrentThread.CurrentCulture) == "Hello World");
        }
        public void LocalizedStringTest_Not_Equals_Operator_Works()
        {
            //Arrange
            var s = new LocalizedString("Hello World");
            //Act

            //Assert
            Assert.IsTrue(s != "Twitter");
        }
 public void SetTextString(LocalizedString newString)
 {
     text.SetTextString(newString);
     textID = newString.ID;
     if (textID == "")
     {
         textID = newString.Text;
     }
     SetName(newString + " Clickable Text");
 }
Example #10
0
 public ContentType(string @alias, LocalizedString name, IEnumerable<FieldDefinition> definitions)
 {
     Alias = alias;
     Name = name;
     Definitions = definitions;
     foreach (var fieldDefinition in Definitions)
     {
         fieldDefinition.ContentType = this;
     }
 }
 public void SetTextString(LocalizedString newString)
 {
     if (mesh == null)
     {
         InitalizeMesh();
     }
     mesh.text = newString.Text;
     currentText = newString.Text;
     SetMaxBounds(maxWidth, maxHeight);
 }
Example #12
0
 public Item(Pokedex pokedex, int id, int ? value3, int ? value4, 
     int ? value5, int ? value6, int price, LocalizedString name)
     : base(pokedex)
 {
     ID = id;
     // todo: Since ID numbers stopped moving around in Gen 4 -> 5, we
     // only need to store value3, value4 and a minGenerationRequired field
     Value3 = value3;
     Value4 = value4;
     Value5 = value5;
     Value6 = value6;
     Price = price;
     Name = name;
 }
 public void AddMenuItem(LocalizedString text, System.Action clickAction)
 {
     if (contextBackground == null)
     {
         contextBackground = Load("Prefabs/Menu Background", transform, new Vector3(contextOffset.x, contextOffset.y, -2.4f)) as GameObject;
         contextBackground.renderer.enabled = false;
     }
     GameObject go = Load("Prefabs/Menu Text", contextBackground.transform, new Vector3(0.0f, 0.0f, -0.1f), text + " Display") as GameObject;
     Transform[] tfms = go.GetComponentsInChildren<Transform>();
     GameObject textObj = tfms[1].gameObject; // This gets the first child
     ClickableText cText = textObj.AddComponent<ClickableText>();
     cText.SetLeftClickAction(clickAction);
     cText.SetTextString(text);
     AddMenuItem(cText);
 }
        public void LocalizedStringTest_Non_Set_Culture_Returns_Null()
        {
            //Arrange
            var threadCulture = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-AU");

            var s = new LocalizedString("Hello World");
            var culture = new System.Globalization.CultureInfo("es-ES");
            //Act

            //Assert
            Assert.IsNull(s.GetValue(culture));

            Thread.CurrentThread.CurrentCulture = threadCulture;
        }
Example #15
0
        public Form(Pokedex pokedex, int id, int species_id, byte value,
            LocalizedString name, String suffix, int height, int weight, int experience)
            : base(pokedex)
        {
            m_species_pair = Species.CreatePair(m_pokedex);
            m_lazy_pairs.Add(m_species_pair);

            ID = id;
            m_species_pair.Key = species_id;
            Value = value;
            Name = name;
            Suffix = suffix;
            Height = height;
            Weight = weight;
            Experience = experience;
        }
        public void LocalizedStringTest_New_Cultures_Can_Be_Added()
        {
            //Arrange
            var threadCulture = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-AU");

            var s = new LocalizedString("Hello World");
            var culture = new CultureInfo("es-ES");
            s.Add(culture, "Hola a todos");
            //Act

            //Assert
            Assert.IsNotNull(s.GetValue(culture));
            Assert.IsNotNull(s.GetValue(Thread.CurrentThread.CurrentCulture));

            Thread.CurrentThread.CurrentCulture = threadCulture;
        }
Example #17
0
 public Ribbon(Pokedex pokedex, int id, LocalizedString name, 
     LocalizedString description,
     int ? position3, int ? position4, int ? position5, int ? position6,
     int ? value3, int ? value4, int ? value5, int ? value6)
     : base(pokedex)
 {
     ID = id;
     Name = name;
     Description = description;
     Position3 = position3;
     Position4 = position4;
     Position5 = position5;
     Position6 = position6;
     Value3 = value3;
     Value4 = value4;
     Value5 = value5;
     Value6 = value6;
 }
Example #18
0
        public Location(Pokedex pokedex, int id, int region_id, int ? value3,
            int ? value_colo, int ? value_xd, int ? value4, int ? value5,
            int ? value6, LocalizedString name)
            : base(pokedex)
        {
            m_region_pair = Region.CreatePair(m_pokedex);
            m_lazy_pairs.Add(m_region_pair);

            ID = id;
            m_region_pair.Key = region_id;
            Value3 = value3;
            ValueColo = value_colo;
            ValueXd = value_xd;
            Value4 = value4;
            Value5 = value5;
            Value6 = value6;
            Name = name;
        }
Example #19
0
        public Move(Pokedex pokedex, int id, int type_id, LocalizedString name,
            DamageClass damage_class, int damage, int pp, int accuracy, int priority,
            BattleTargets target)
            : base(pokedex)
        {
            m_type_pair = Type.CreatePair(m_pokedex);
            m_lazy_pairs.Add(m_type_pair);

            ID = id;
            m_type_pair.Key = type_id;
            Name = name;
            DamageClass = damage_class;
            Damage = damage;
            PP = pp;
            Accuracy = accuracy;
            Priority = priority;
            Target = target;
            // todo: Nice description text
        }
Example #20
0
        private void OutputException(TextWriter output, LocalizedString title, Exception exception)
        {
            // Display header
            output.WriteLine();
            output.WriteLine(T("{0}", title));

            // Push exceptions in a stack so we display from inner most to outer most
            var errors = new Stack<Exception>();
            for (var scan = exception; scan != null; scan = scan.InnerException)
            {
                errors.Push(scan);
            }

            // Display inner most exception details
            exception = errors.Peek();
            output.WriteLine(T("--------------------------------------------------------------------------------"));
            output.WriteLine();
            output.WriteLine(T("{0}", exception.Message));
            output.WriteLine();

            if (!((exception is OrchardException ||
                exception is OrchardCoreException) &&
                exception.InnerException == null))
            {
                output.WriteLine(T("Exception Details: {0}: {1}", exception.GetType().FullName, exception.Message));
                output.WriteLine();
                output.WriteLine(T("Stack Trace:"));
                output.WriteLine();

                // Display exceptions from inner most to outer most
                foreach (var error in errors)
                {
                    output.WriteLine(T("[{0}: {1}]", error.GetType().Name, error.Message));
                    output.WriteLine(T("{0}", error.StackTrace));
                    output.WriteLine();
                }
            }

            // Display footer
            output.WriteLine("--------------------------------------------------------------------------------");
            output.WriteLine();
        }
 public static LocalizedString LocalizedStringFromReader(IDataReader reader, String prefix)
 {
     // fixme: share this field with CreateLocalizedStringQueryPieces
     String[] langs = new String[] { "JA", "EN", "FR", "IT", "DE", "ES", "KO" };
     LocalizedString result = new LocalizedString();
     foreach (String lang in langs)
     {
         try
         {
             int ordinal = reader.GetOrdinal(prefix + lang);
             if (reader.IsDBNull(ordinal)) continue;
             result.Add(lang, reader.GetString(ordinal));
         }
         catch (IndexOutOfRangeException)
         {
             continue;
         }
     }
     return result;
 }
Example #22
0
 public UpdatePublicFolderMailboxResult(LocalizedString msg)
 {
     this.Message = msg;
 }
 public ChangeNameAction(LocalizedString name)
 {
     this.Action = "changeName";
     this.Name   = name;
 }
Example #24
0
 public void SetSettingField(int paginationCount, int selectedPaginationIndex, string selectedOption, LocalizedString fieldTitle, SettingFieldType fieldType)
 {
     _fieldType = fieldType;
     _pagination.SetPagination(paginationCount, selectedPaginationIndex);
     _currentSelectedOption.text = selectedOption;
     _title.StringReference      = fieldTitle;
 }
Example #25
0
 public OrchardException(LocalizedString message)
     : base(message)
 {
     _localizedMessage = message;
 }
 public AuditLogException(LocalizedString message, Exception innerException) : base(message, innerException)
 {
 }
Example #27
0
 private void CreateMainButton(ref Button button, FlowLayoutWidget buttonBar, string text)
 {
     button = textImageButtonFactory.Generate(LocalizedString.Get(text));
     buttonBar.AddChild(button);
 }
        public StyledMessageBox(Action <bool> callback, String message, string windowTitle, MessageType messageType, GuiWidget[] extraWidgetsToAdd, double width, double height, string yesOk, string no)
            : base(width, height)
        {
            if (UserSettings.Instance.IsTouchScreen)
            {
                extraTextScaling = 1.33333;
            }

            textImageButtonFactory.fontSize = extraTextScaling * textImageButtonFactory.fontSize;
            if (yesOk == "")
            {
                if (messageType == MessageType.OK)
                {
                    yesOk = "Ok".Localize();
                }
                else
                {
                    yesOk = "Yes".Localize();
                }
            }
            if (no == "")
            {
                no = "No".Localize();
            }

            responseCallback = callback;
            unwrappedMessage = message;
            FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            topToBottom.AnchorAll();
            if (UserSettings.Instance.IsTouchScreen)
            {
                topToBottom.Padding = new BorderDouble(12, 12, 13, 8);
            }
            else
            {
                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
            {
                TextWidget elementHeader = new TextWidget(windowTitle, pointSize: 14 * extraTextScaling);
                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
            middleRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
            {
                middleRowContainer.HAnchor = HAnchor.ParentLeftRight;
                middleRowContainer.VAnchor = VAnchor.ParentBottomTop;
                // normally the padding for the middle container should be just (5) all around. The has extra top space
                middleRowContainer.Padding         = new BorderDouble(5, 5, 5, 15);
                middleRowContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            }

            messageContainer = new TextWidget(message, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 12 * extraTextScaling);
            messageContainer.AutoExpandBoundsToText = true;
            messageContainer.HAnchor = Agg.UI.HAnchor.ParentLeft;
            middleRowContainer.AddChild(messageContainer);

            if (extraWidgetsToAdd != null)
            {
                foreach (GuiWidget widget in extraWidgetsToAdd)
                {
                    middleRowContainer.AddChild(widget);
                }
            }

            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);
            }


            switch (messageType)
            {
            case MessageType.YES_NO:
            {
                Title = "MatterControl - " + "Please Confirm".Localize();
                Button yesButton = textImageButtonFactory.Generate(yesOk, centerText: true);
                yesButton.Click += new EventHandler(okButton_Click);
                yesButton.Cursor = Cursors.Hand;
                buttonRow.AddChild(yesButton);

                buttonRow.AddChild(new HorizontalSpacer());

                Button noButton = textImageButtonFactory.Generate(no, centerText: true);
                noButton.Click += new EventHandler(noButton_Click);
                noButton.Cursor = Cursors.Hand;
                buttonRow.AddChild(noButton);
            }
            break;

            case MessageType.OK:
            {
                Title = "MatterControl - " + "Alert".Localize();
                Button okButton = textImageButtonFactory.Generate(LocalizedString.Get("Ok"), centerText: true);
                okButton.Name   = "Ok Button";
                okButton.Cursor = Cursors.Hand;
                okButton.Click += new EventHandler(okButton_Click);
                buttonRow.AddChild(okButton);
            }
            break;

            default:
                throw new NotImplementedException();
            }

            topToBottom.AddChild(buttonRow);
            this.AddChild(topToBottom);

            IsModal = true;
            AdjustTextWrap();
        }
        public void CanSerializeLocalizedString()
        {
            var testString = new LocalizedString("myvalue");

            var result = SerializationService.ToJson(testString);

            Assert.IsNotNullOrEmpty(result);

            var reHydrate = SerializationService.FromJson<LocalizedString>(result);

            Assert.NotNull(reHydrate);

            Assert.That(reHydrate.Value, Is.EqualTo(testString.Value));
            CollectionAssert.AreEquivalent(testString.Values, reHydrate.Values);
        }
        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 * TextWidget.GlobalPointSizeScaleRatio;

            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);

                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(LocalizedString.Get("Max Temp."), 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();
            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);
        }
        public QueueDataWidget(QueueDataView queueDataView)
        {
            this.queueDataView = queueDataView;

            SetDisplayAttributes();

            textImageButtonFactory.normalTextColor   = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.hoverTextColor    = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.pressedTextColor  = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.borderWidth       = 0;

            editButtonFactory.normalTextColor   = ActiveTheme.Instance.PrimaryTextColor;
            editButtonFactory.hoverTextColor    = ActiveTheme.Instance.PrimaryTextColor;
            editButtonFactory.disabledTextColor = ActiveTheme.Instance.TabLabelUnselected;
            editButtonFactory.disabledFillColor = new RGBA_Bytes();
            editButtonFactory.pressedTextColor  = ActiveTheme.Instance.PrimaryTextColor;
            editButtonFactory.borderWidth       = 0;
            editButtonFactory.Margin            = new BorderDouble(10, 0);
            editButtonFactory.Margin           *= TextWidget.GlobalPointSizeScaleRatio;

            FlowLayoutWidget allControls = new FlowLayoutWidget(FlowDirection.TopToBottom);

            {
                enterEditModeButton             = editButtonFactory.Generate("Edit".Localize(), centerText: true);
                enterEditModeButton.Name        = "Queue Edit Button";
                enterEditModeButton.ToolTipText = "Enter Multi Select mode".Localize();
                enterEditModeButton.Click      += enterEditModeButtonClick;

                leaveEditModeButton        = editButtonFactory.Generate("Done".Localize(), centerText: true);
                leaveEditModeButton.Name   = "Queue Done Button";
                leaveEditModeButton.Click += leaveEditModeButtonClick;

                // make sure the buttons are the same size even when localized
                if (leaveEditModeButton.Width < enterEditModeButton.Width)
                {
                    editButtonFactory.FixedWidth = enterEditModeButton.Width;
                    leaveEditModeButton          = editButtonFactory.Generate("Done".Localize(), centerText: true);
                    leaveEditModeButton.Click   += leaveEditModeButtonClick;
                }
                else
                {
                    editButtonFactory.FixedWidth = leaveEditModeButton.Width;
                    enterEditModeButton          = editButtonFactory.Generate("Edit".Localize(), centerText: true);
                    enterEditModeButton.Click   += enterEditModeButtonClick;
                }

                CreateEditBarButtons();
                leaveEditModeButton.Visible = false;

                FlowLayoutWidget topBarContainer = new FlowLayoutWidget();
                topBarContainer.BackgroundColor = ActiveTheme.Instance.TransparentDarkOverlay;
                topBarContainer.HAnchor         = HAnchor.ParentLeftRight;
                topBarContainer.Padding         = new BorderDouble(0);

                topBarContainer.AddChild(enterEditModeButton);

                topBarContainer.AddChild(leaveEditModeButton);
                topBarContainer.AddChild(new HorizontalSpacer());
                topBarContainer.AddChild(itemOperationButtons);

                // put in the itme edit menu
                {
                    moreMenu                   = new DropDownMenu("More".Localize() + "... ");
                    moreMenu.NormalColor       = new RGBA_Bytes();
                    moreMenu.BorderWidth       = 1;
                    moreMenu.BorderColor       = ActiveTheme.Instance.SecondaryTextColor;
                    moreMenu.MenuAsWideAsItems = false;
                    moreMenu.VAnchor           = VAnchor.ParentBottomTop;
                    moreMenu.Margin            = new BorderDouble(3, 3);
                    moreMenu.AlignToRightEdge  = true;

                    topBarContainer.AddChild(moreMenu);
                    SetMenuItems(moreMenu);
                    moreMenu.SelectionChanged += new EventHandler(ItemMenu_SelectionChanged);
                }

                allControls.AddChild(topBarContainer);

                {
                    // Ensure the form opens with no rows selected.
                    //ActiveQueueList.Instance.ClearSelected();

                    allControls.AddChild(queueDataView);
                }

                FlowLayoutWidget buttonPanel1 = new FlowLayoutWidget();
                buttonPanel1.HAnchor     = HAnchor.ParentLeftRight;
                buttonPanel1.Padding     = new BorderDouble(0, 3);
                buttonPanel1.MinimumSize = new Vector2(0, 46);
                {
                    addToQueueButton             = textImageButtonFactory.Generate(LocalizedString.Get("Add"), "icon_circle_plus.png");
                    addToQueueButton.ToolTipText = "Add an .stl, .amf, .gcode or .zip file to the Queue".Localize();
                    buttonPanel1.AddChild(addToQueueButton);
                    addToQueueButton.Margin = new BorderDouble(0, 0, 3, 0);
                    addToQueueButton.Click += new EventHandler(addToQueueButton_Click);

                    // put in the creator button
                    {
                        createButton             = textImageButtonFactory.Generate(LocalizedString.Get("Create"), "icon_creator_white_32x32.png");
                        createButton.ToolTipText = "Choose a Create Tool to generate custom designs".Localize();
                        createButton.Name        = "Design Tool Button";
                        buttonPanel1.AddChild(createButton);
                        createButton.Margin = new BorderDouble(0, 0, 3, 0);
                        createButton.Click += (sender, e) =>
                        {
                            OpenPluginChooserWindow();
                        };
                    }

                    bool touchScreenMode = ActiveTheme.Instance.IsTouchScreen;

                    if (!touchScreenMode)
                    {
                        if (OemSettings.Instance.ShowShopButton)
                        {
                            shopButton             = textImageButtonFactory.Generate(LocalizedString.Get("Buy Materials"), "icon_shopping_cart_32x32.png");
                            shopButton.ToolTipText = "Shop online for printing materials".Localize();
                            shopButton.Name        = "Buy Materials Button";
                            buttonPanel1.AddChild(shopButton);
                            shopButton.Margin = new BorderDouble(0, 0, 3, 0);
                            shopButton.Click += (sender, e) =>
                            {
                                double activeFilamentDiameter = 0;
                                if (ActivePrinterProfile.Instance.ActivePrinter != null)
                                {
                                    activeFilamentDiameter = 3;
                                    if (ActiveSliceSettings.Instance.FilamentDiameter < 2)
                                    {
                                        activeFilamentDiameter = 1.75;
                                    }
                                }

                                MatterControlApplication.Instance.LaunchBrowser("http://www.matterhackers.com/mc/store/redirect?d={0}&clk=mcs&a={1}".FormatWith(activeFilamentDiameter, OemSettings.Instance.AffiliateCode));
                            };
                        }
                    }

                    buttonPanel1.AddChild(new HorizontalSpacer());

                    queueMenuContainer         = new FlowLayoutWidget();
                    queueMenuContainer.VAnchor = Agg.UI.VAnchor.ParentBottomTop;
                    queueMenu = new QueueOptionsMenu();
                    queueMenuContainer.AddChild(queueMenu.MenuDropList);
                    if (!touchScreenMode)
                    {
                        buttonPanel1.AddChild(queueMenuContainer);
                    }

                    ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent((object sender, EventArgs e) =>
                    {
                        queueMenuContainer.RemoveAllChildren();
                        // the printer changed reload the queueMenue
                        queueMenu = new QueueOptionsMenu();
                        queueMenuContainer.AddChild(queueMenu.MenuDropList);
                    }, ref unregisterEvents);
                }
                allControls.AddChild(buttonPanel1);
            }
            allControls.AnchorAll();

            this.AddChild(allControls);
            AddHandlers();
            SetEditButtonsStates();

            //enterEditModeButtonClick(null, null);
        }
Example #32
0
 private void Log(EventTypeEnumeration type, TestFederationTrust.TestFederationTrustEventId id, LocalizedString message)
 {
     this.events.Add(new TestFederationTrust.ResultEvent
     {
         Id      = id,
         Type    = type,
         Message = message
     });
 }
Example #33
0
        private X509Certificate2[] GetStsCertificates(FederationTrust federationTrust)
        {
            bool            flag     = federationTrust.TokenIssuerCertificate != null && TestFederationTrust.IsExpiredCertificate(federationTrust.TokenIssuerCertificate);
            bool            flag2    = federationTrust.TokenIssuerPrevCertificate != null && TestFederationTrust.IsExpiredCertificate(federationTrust.TokenIssuerPrevCertificate);
            LocalizedString message  = flag ? Strings.CertificateExpired("TokenIssuerCertificate") : Strings.CertificateValid("TokenIssuerCertificate");
            LocalizedString message2 = flag2 ? Strings.CertificateExpired("TokenIssuerPrevCertificate") : Strings.CertificateValid("TokenIssuerPrevCertificate");

            if (!flag && !flag2)
            {
                base.WriteVerbose(new LocalizedString(string.Concat(new string[]
                {
                    Environment.NewLine,
                    "Both STS trust certificates [current <",
                    federationTrust.TokenIssuerCertificate.Thumbprint,
                    "> and previous <",
                    federationTrust.TokenIssuerPrevCertificate.Thumbprint,
                    ">] are valid."
                })));
            }
            else if (!flag && flag2)
            {
                base.WriteVerbose(new LocalizedString(string.Concat(new string[]
                {
                    Environment.NewLine,
                    "The current STS trust certificate <",
                    federationTrust.TokenIssuerCertificate.Thumbprint,
                    "> is valid, but the previous STS trust certificate <",
                    federationTrust.TokenIssuerPrevCertificate.Thumbprint,
                    "> has expired."
                })));
            }
            else if (flag && !flag2)
            {
                base.WriteVerbose(new LocalizedString(string.Concat(new string[]
                {
                    Environment.NewLine,
                    "The current STS trust certificate <",
                    federationTrust.TokenIssuerCertificate.Thumbprint,
                    "> has expired. The previous STS trust certificate <",
                    federationTrust.TokenIssuerPrevCertificate.Thumbprint,
                    "> is still valid."
                })));
            }
            if (flag && flag2)
            {
                base.WriteVerbose(new LocalizedString(string.Concat(new string[]
                {
                    Environment.NewLine,
                    "Both STS trust certificates [current <",
                    federationTrust.TokenIssuerCertificate.Thumbprint,
                    "> and previous <",
                    federationTrust.TokenIssuerPrevCertificate.Thumbprint,
                    ">] have expired."
                })));
                if (federationTrust.TokenIssuerCertificate != null)
                {
                    this.Log(EventTypeEnumeration.Error, TestFederationTrust.TestFederationTrustEventId.StsCertificate, message);
                }
                if (federationTrust.TokenIssuerPrevCertificate != null)
                {
                    this.Log(EventTypeEnumeration.Error, TestFederationTrust.TestFederationTrustEventId.StsPreviousCertificate, message2);
                }
                return(null);
            }
            if (federationTrust.TokenIssuerCertificate != null)
            {
                this.Log(flag ? EventTypeEnumeration.Warning : EventTypeEnumeration.Success, TestFederationTrust.TestFederationTrustEventId.StsCertificate, message);
            }
            if (federationTrust.TokenIssuerPrevCertificate != null)
            {
                this.Log(flag2 ? EventTypeEnumeration.Warning : EventTypeEnumeration.Success, TestFederationTrust.TestFederationTrustEventId.StsPreviousCertificate, message2);
            }
            List <X509Certificate2> list = new List <X509Certificate2>(2);

            if (federationTrust.TokenIssuerCertificate != null && !flag)
            {
                list.Add(federationTrust.TokenIssuerCertificate);
            }
            if (federationTrust.TokenIssuerPrevCertificate != null && !flag2)
            {
                list.Add(federationTrust.TokenIssuerPrevCertificate);
            }
            return(list.ToArray());
        }
Example #34
0
 public LocalizedException(LocalizedString localizedString, System.Exception innerException)
     : base(localizedString, innerException)
 {
     this.LocalizedString = localizedString;
     LocalizedException.TraceException("Created LocalizedException({0}, innerException)", (object) localizedString);
 }
Example #35
0
        public EePromMarlinWindow()
            : base(700, 480)
        {
            AlwaysOnTopOfMain = true;
            Title             = LocalizedString.Get("Marlin Firmware EEPROM Settings");

            currentEePromSettings             = new EePromMarlinSettings();
            currentEePromSettings.eventAdded += SetUiToPrinterSettings;

            FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);

            mainContainer.VAnchor         = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;
            mainContainer.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
            mainContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
            mainContainer.Padding         = new BorderDouble(3, 0);

            FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            topToBottom.VAnchor         = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;
            topToBottom.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
            topToBottom.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            topToBottom.Padding         = new BorderDouble(top: 3);

            // the top button bar
            {
                FlowLayoutWidget topButtonBar = new FlowLayoutWidget();
                topButtonBar.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
                topButtonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

                topButtonBar.Margin = new BorderDouble(0, 3);

                CreateMainButton(ref buttonSetToFactorySettings, topButtonBar, "Reset to Factory Defaults");
                buttonSetToFactorySettings.Click += SetToFactorySettings;

                mainContainer.AddChild(topButtonBar);
            }

            topToBottom.AddChild(Create4FieldSet("Steps per mm:",
                                                 "X:", ref stepsPerMmX,
                                                 "Y:", ref stepsPerMmY,
                                                 "Z:", ref stepsPerMmZ,
                                                 "E:", ref stepsPerMmE));

            topToBottom.AddChild(Create4FieldSet("Maximum feedrates [mm/s]:",
                                                 "X:", ref maxFeedrateMmPerSX,
                                                 "Y:", ref maxFeedrateMmPerSY,
                                                 "Z:", ref maxFeedrateMmPerSZ,
                                                 "E:", ref maxFeedrateMmPerSE));

            topToBottom.AddChild(Create4FieldSet("Maximum Acceleration [mm/s²]:",
                                                 "X:", ref maxAccelerationMmPerSSqrdX,
                                                 "Y:", ref maxAccelerationMmPerSSqrdY,
                                                 "Z:", ref maxAccelerationMmPerSSqrdZ,
                                                 "E:", ref maxAccelerationMmPerSSqrdE));

            topToBottom.AddChild(CreateField("Acceleration:", ref acceleration));
            topToBottom.AddChild(CreateField("Retract Acceleration:", ref retractAcceleration));

            topToBottom.AddChild(Create3FieldSet("PID settings:",
                                                 "P:", ref pidP,
                                                 "I:", ref pidI,
                                                 "D:", ref pidD));

            topToBottom.AddChild(Create3FieldSet("Homing Offset:",
                                                 "X:", ref homingOffsetX,
                                                 "Y:", ref homingOffsetY,
                                                 "Z:", ref homingOffsetZ));

            topToBottom.AddChild(CreateField("Min feedrate [mm/s]:", ref minFeedrate));
            topToBottom.AddChild(CreateField("Min travel feedrate [mm/s]:", ref minTravelFeedrate));
            topToBottom.AddChild(CreateField("Minimum segment time [ms]:", ref minSegmentTime));
            topToBottom.AddChild(CreateField("Maximum X-Y jerk [mm/s]:", ref maxXYJerk));
            topToBottom.AddChild(CreateField("Maximum Z jerk [mm/s]:", ref maxZJerk));

            GuiWidget topBottomSpacer = new GuiWidget(1, 1);

            topBottomSpacer.VAnchor = VAnchor.ParentBottomTop;
            topToBottom.AddChild(topBottomSpacer);

            mainContainer.AddChild(topToBottom);

            // the bottom button bar
            {
                FlowLayoutWidget bottomButtonBar = new FlowLayoutWidget();
                bottomButtonBar.HAnchor         = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
                bottomButtonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
                bottomButtonBar.Margin          = new BorderDouble(0, 3);

                CreateMainButton(ref buttonSave, bottomButtonBar, "Save to EEProm");
                buttonSave.Click += buttonSave_Click;

                CreateSpacer(bottomButtonBar);

                CreateMainButton(ref buttonAbort, bottomButtonBar, "Close");
                buttonAbort.Click += buttonAbort_Click;

                mainContainer.AddChild(bottomButtonBar);
            }

            PrinterConnectionAndCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents);

#if __ANDROID__
            TerminalWidget terminalWidget = new TerminalWidget(true);
            this.AddChild(new SoftKeyboardContentOffset(mainContainer, SoftKeyboardContentOffset.AndroidKeyboardOffset));
            //mainContainer.Closed += (sender, e) => { Close(); };
#else
            AddChild(mainContainer);
#endif

            ShowAsSystemWindow();

            // and ask the printer to send the settings
            currentEePromSettings.Update();

            foreach (GuiWidget widget in leftStuffToSize)
            {
                widget.Width = maxWidthOfLeftStuff;
            }
        }
        /// <summary>
        /// Sets the value of a string for a given language.
        /// </summary>
        /// <param name="str">The string.</param>
        /// <param name="language">The language.</param>
        /// <param name="newValue">The new value. Can be <c>null</c>.</param>
        public void SetString(LocalizedString str, GameLanguage language, string newValue)
        {
            // Replace the string
            var offset = str.Offsets[(int)language];
            if (offset < 0 || offset >= Data.Length)
                offset = Data.Length; // Add the string at the end
            var oldLength = GetStringLength(offset);
            var bytes = (newValue != null) ? Encoding.UTF8.GetBytes(newValue) : new byte[0];
            if (bytes.Length > 0 && offset == Data.Length)
            {
                // If it's a new string, null-terminate it
                var nullTerminated = new byte[bytes.Length + 1];
                Buffer.BlockCopy(bytes, 0, nullTerminated, 0, bytes.Length);
                bytes = nullTerminated;
            }
            Data = ArrayUtil.Replace(Data, offset, oldLength, bytes);

            // Update string offsets
            str.Offsets[(int)language] = (bytes.Length > 0) ? offset : -1;
            var sizeDelta = bytes.Length - oldLength;
            foreach (var adjustStr in Strings)
            {
                for (var i = 0; i < adjustStr.Offsets.Length; i++)
                {
                    if (adjustStr.Offsets[i] > offset)
                        adjustStr.Offsets[i] += sizeDelta;
                }
            }
        }
Example #37
0
 internal void SetErrorTestResult(EventId eventId, LocalizedString strMessage)
 {
     this.SetResult(false, -1.0);
     this.Error = strMessage;
     this.DetailEvents.Add(new MonitoringEvent("MSExchange Monitoring ExchangeSearch", (int)eventId, EventTypeEnumeration.Error, strMessage, this.Database));
 }
Example #38
0
 public TransientException(LocalizedString localizedString)
     : this(localizedString, null)
 {
 }
Example #39
0
 public QueryInProgressException(LocalizedString message, Exception innerException) : base(message, innerException)
 {
 }
Example #40
0
 void IUpdateModel.AddModelError(string key, LocalizedString errorMessage)
 {
     ModelState.AddModelError(key, errorMessage.ToString());
 }
Example #41
0
 public OrchardException(LocalizedString message, Exception innerException)
     : base(message, innerException)
 {
     _localizedMessage = message;
 }
 private void onMouseEnterBoundsPrintQueueLink(Object sender, EventArgs e)
 {
     HelpTextWidget.Instance.ShowHoverText(LocalizedString.Get("View Queue and Library"));
 }
 public ImpersonationDeniedException(LocalizedString message, Exception innerException) : base(message, innerException)
 {
 }
 public AuditLogException(LocalizedString message) : base(message)
 {
 }
 public ImpersonationDeniedException(LocalizedString message) : base(message)
 {
 }
Example #46
0
 // Token: 0x06007EFE RID: 32510 RVA: 0x001A3CD6 File Offset: 0x001A1ED6
 public NameConversionException(LocalizedString message, Exception innerException) : base(message, innerException)
 {
 }
Example #47
0
 public void Save(CultureInfo culture, string textKey, string source, string text, string translatedText)
 {
     var value = new LocalizedString()
         {
             Culture =  culture.Name,
             Key = textKey,
             Source = source,
             Text = text,
             TranslatedText = translatedText
         };
     var key = new Tuple<string, int>(textKey, culture.LCID);
     _strings.Remove(key);
     _strings.Add(key, value);
     Save();
 }
Example #48
0
 // Token: 0x06007EFD RID: 32509 RVA: 0x001A3CCD File Offset: 0x001A1ECD
 public NameConversionException(LocalizedString message) : base(message)
 {
 }
        public void OrDefault_ReturnsDefaultIfNull()
        {
            var def = new LocalizedString("test");

            Assert.That(((string)null).OrDefault(def).Text, Is.SameAs("test"));
        }
Example #50
0
        public PrinterChooser(string selectedMake = null)
        {
            string defaultManufacturerLabel     = LocalizedString.Get("Select Make");
            string defaultManufacturerLabelFull = string.Format("- {0} -", defaultManufacturerLabel);

            ManufacturerDropList = new StyledDropDownList(defaultManufacturerLabelFull, maxHeight: 200);
            bool addOther = false;

            string[] printerWhiteListStrings = OemSettings.Instance.PrinterWhiteList.ToArray();
            string   pathToManufacturers     = "PrinterSettings";

            if (StaticData.Instance.DirectoryExists(pathToManufacturers))
            {
                int index          = 0;
                int preselectIndex = -1;
                foreach (string manufacturerDirectory in StaticData.Instance.GetDirectories(pathToManufacturers))
                {
                    string folderName = Path.GetFileName(manufacturerDirectory.TrimEnd(new[] { '/', '\\' }));

                    if (printerWhiteListStrings.Contains(folderName))
                    {
                        string manufacturer = Path.GetFileName(manufacturerDirectory);
                        if (manufacturer == "Other")
                        {
                            addOther = true;
                        }
                        else
                        {
                            ManufacturerDropList.AddItem(manufacturer);
                            if (selectedMake != null)
                            {
                                if (manufacturer == selectedMake)
                                {
                                    preselectIndex = index;
                                }
                            }

                            index++;
                        }
                        countOfMakes += 1;
                    }
                }
                if (addOther)
                {
                    if (selectedMake != null && preselectIndex == -1)
                    {
                        preselectIndex = index;
                    }
                    ManufacturerDropList.AddItem(LocalizedString.Get("Other"));
                }
                if (preselectIndex != -1)
                {
                    ManufacturerDropList.SelectedIndex = preselectIndex;
                }
            }

            if (ManufacturerDropList.MenuItems.Count == 1)
            {
                ManufacturerDropList.SelectedIndex = 0;
            }

            AddChild(ManufacturerDropList);

            HAnchor = HAnchor.FitToChildren;
            VAnchor = VAnchor.FitToChildren;
        }
 /// <summary>
 /// Creates a ClickableText out of a ClickableObject and a string to display.
 /// The options are assumed to be the same as the Left Click option for the ClickableObject.
 /// </summary>
 /// <param name="text"></param>
 /// <param name="menuItem"></param>
 public void AddMenuItem(LocalizedString text, ClickableObject menuItem)
 {
     AddMenuItem(text, menuItem._LeftClicked);
 }
        public void OrDefault_ReturnsString()
        {
            var def = new LocalizedString("test");

            Assert.That("bar".OrDefault(def).Text, Is.SameAs("bar"));
        }
Example #53
0
 public LocalizedException(LocalizedString localizedString)
     : this(localizedString, null)
 {
     LocalizedException.TraceException("Created LocalizedException({0})", (object) localizedString);
 }
        private FlowLayoutWidget CreateActivePrinterInfoWidget()
        {
            FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);

            container.Margin  = new BorderDouble(6, 0, 6, 0);
            container.HAnchor = HAnchor.ParentLeftRight;
            container.VAnchor = VAnchor.ParentCenter;
            container.Height  = 80;

            FlowLayoutWidget topRow = new FlowLayoutWidget();

            topRow.Name    = "PrintStatusRow.ActivePrinterInfo.TopRow";
            topRow.HAnchor = HAnchor.ParentLeftRight;

            string nextPrintLabel     = LocalizedString.Get("Next Print");
            string nextPrintLabelFull = string.Format("{0}:", nextPrintLabel);

            activePrintLabel         = getPrintStatusLabel(nextPrintLabelFull, pointSize: 11);
            activePrintLabel.VAnchor = VAnchor.ParentTop;

            topRow.AddChild(activePrintLabel);

            FlowLayoutWidget bottomRow = new FlowLayoutWidget();

            activePrintPreviewImage         = new PartThumbnailWidget(null, "part_icon_transparent_100x100.png", "building_thumbnail_100x100.png", PartThumbnailWidget.ImageSizes.Size50x50);
            activePrintPreviewImage.VAnchor = VAnchor.ParentTop;
            activePrintPreviewImage.Padding = new BorderDouble(0);
            activePrintPreviewImage.HoverBackgroundColor = new RGBA_Bytes();
            activePrintPreviewImage.BorderWidth          = 3;

            FlowLayoutWidget labelContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);

            labelContainer.VAnchor |= VAnchor.ParentTop;
            labelContainer.Margin   = new BorderDouble(8, 0, 0, 4);
            {
                activePrintName = getPrintStatusLabel("this is the biggest name we will allow", pointSize: 14);
                activePrintName.AutoExpandBoundsToText = false;

                activePrintStatus = getPrintStatusLabel("this is the biggest label we will allow - bigger", pointSize: 11);
                activePrintStatus.AutoExpandBoundsToText = false;
                activePrintStatus.Text   = "";
                activePrintStatus.Margin = new BorderDouble(top: 3);

                activePrintInfo = getPrintStatusLabel("", pointSize: 11);
                activePrintInfo.AutoExpandBoundsToText = true;

                labelContainer.AddChild(activePrintName);
                labelContainer.AddChild(activePrintStatus);
            }

            bottomRow.AddChild(activePrintPreviewImage);
            bottomRow.AddChild(labelContainer);

            //PrintActionRow printActionRow = new PrintActionRow(queueDataView);

            container.AddChild(topRow);
            container.AddChild(bottomRow);
            //container.AddChild(activePrintInfo);
            //container.AddChild(printActionRow);
            //container.AddChild(new VerticalSpacer());
            //container.AddChild(new MessageActionRow());

            return(container);
        }
        /// <summary>
        /// Gets the value of a string in a given language.
        /// </summary>
        /// <param name="str">The string.</param>
        /// <param name="language">The language.</param>
        /// <returns>The value of the string, or <c>null</c> if the string is not available.</returns>
        public string GetString(LocalizedString str, GameLanguage language)
        {
            var offset = str.Offsets[(int)language];
            if (offset < 0 || offset >= Data.Length)
                return null; // String not available

            var length = GetStringLength(offset);
            return Encoding.UTF8.GetString(Data, offset, length);
        }
        private void UpdatePrintStatus()
        {
            if (PrinterConnectionAndCommunication.Instance.ActivePrintItem != null)
            {
                int totalSecondsInPrint = PrinterConnectionAndCommunication.Instance.TotalSecondsInPrint;

                int totalHoursInPrint   = (int)(totalSecondsInPrint / (60 * 60));
                int totalMinutesInPrint = (int)(totalSecondsInPrint / 60 - totalHoursInPrint * 60);
                totalSecondsInPrint = totalSecondsInPrint % 60;

                string totalTimeLabel   = LocalizedString.Get("Est. Print Time");
                string calculatingLabel = LocalizedString.Get("Calculating...");
                string totalPrintTimeText;

                if (totalSecondsInPrint > 0)
                {
                    if (totalHoursInPrint > 0)
                    {
                        totalPrintTimeText = string.Format("{3} {0}h {1:00}m {2:00}s",
                                                           totalHoursInPrint,
                                                           totalMinutesInPrint,
                                                           totalSecondsInPrint,
                                                           totalTimeLabel);
                    }
                    else
                    {
                        totalPrintTimeText = string.Format("{2} {0}m {1:00}s",
                                                           totalMinutesInPrint,
                                                           totalSecondsInPrint,
                                                           totalTimeLabel);
                    }
                }
                else
                {
                    if (totalSecondsInPrint < 0)
                    {
                        totalPrintTimeText = string.Format("{0}", LocalizedString.Get("Streaming GCode..."));
                    }
                    else
                    {
                        totalPrintTimeText = string.Format("{0}: {1}", totalTimeLabel, calculatingLabel);
                    }
                }

                //GC.WaitForFullGCComplete();

                string printPercentRemainingText;
                string printPercentCompleteText = LocalizedString.Get("complete");
                printPercentRemainingText = string.Format("{0:0.0}% {1}", PrinterConnectionAndCommunication.Instance.PercentComplete, printPercentCompleteText);

                switch (PrinterConnectionAndCommunication.Instance.CommunicationState)
                {
                case PrinterConnectionAndCommunication.CommunicationStates.PreparingToPrint:
                    string preparingPrintLabel     = LocalizedString.Get("Preparing To Print");
                    string preparingPrintLabelFull = string.Format("{0}:", preparingPrintLabel);
                    activePrintLabel.Text = preparingPrintLabelFull;
                    //ActivePrintStatusText = ""; // set by slicer
                    activePrintInfo.Text = "";
                    break;

                case PrinterConnectionAndCommunication.CommunicationStates.Printing:
                {
                    activePrintLabel.Text = PrinterConnectionAndCommunication.Instance.PrintingStateString;
                    ActivePrintStatusText = totalPrintTimeText;
                }
                break;

                case PrinterConnectionAndCommunication.CommunicationStates.Paused:
                {
                    string activePrintLabelText     = LocalizedString.Get("Printing Paused");
                    string activePrintLabelTextFull = string.Format("{0}:", activePrintLabelText);
                    activePrintLabel.Text = activePrintLabelTextFull;
                    ActivePrintStatusText = totalPrintTimeText;
                }
                break;

                case PrinterConnectionAndCommunication.CommunicationStates.FinishedPrint:
                    string donePrintingText     = LocalizedString.Get("Done Printing");
                    string donePrintingTextFull = string.Format("{0}:", donePrintingText);
                    activePrintLabel.Text = donePrintingTextFull;
                    ActivePrintStatusText = totalPrintTimeText;
                    break;

                default:
                    string nextPrintLabelActive     = LocalizedString.Get("Next Print");
                    string nextPrintLabelActiveFull = string.Format("{0}: ", nextPrintLabelActive);

                    activePrintLabel.Text = nextPrintLabelActiveFull;
                    ActivePrintStatusText = getConnectionMessage();
                    break;
                }
            }
            else
            {
                string nextPrintLabel     = LocalizedString.Get("Next Print");
                string nextPrintLabelFull = string.Format("{0}:", nextPrintLabel);

                activePrintLabel.Text = nextPrintLabelFull;
                ActivePrintStatusText = string.Format(LocalizedString.Get("Press 'Add' to choose an item to print"));
            }
        }
Example #57
0
 public TransientException(LocalizedString localizedString, System.Exception innerException)
     : base(localizedString, innerException)
 {
     this.LocalizedString = localizedString;
 }
        public ChooseConnectionWidget(ConnectionWindow windowController, SystemWindow container, bool editMode = false)
            : base(windowController, container)
        {
            {
                this.editMode = editMode;

                textImageButtonFactory.normalTextColor   = ActiveTheme.Instance.PrimaryTextColor;
                textImageButtonFactory.hoverTextColor    = ActiveTheme.Instance.PrimaryTextColor;
                textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
                textImageButtonFactory.pressedTextColor  = ActiveTheme.Instance.PrimaryTextColor;
                textImageButtonFactory.borderWidth       = 0;

                editButtonFactory.normalTextColor   = ActiveTheme.Instance.SecondaryAccentColor;
                editButtonFactory.hoverTextColor    = RGBA_Bytes.White;
                editButtonFactory.disabledTextColor = ActiveTheme.Instance.SecondaryAccentColor;
                editButtonFactory.pressedTextColor  = RGBA_Bytes.White;
                editButtonFactory.borderWidth       = 0;
                editButtonFactory.FixedWidth        = 60 * TextWidget.GlobalPointSizeScaleRatio;

                this.AnchorAll();
                this.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
                this.Padding         = new BorderDouble(0); //To be re-enabled once native borders are turned off

                GuiWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
                mainContainer.AnchorAll();
                mainContainer.Padding         = new BorderDouble(3, 0, 3, 5);
                mainContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

                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, 0);

                {
                    string chooseThreeDPrinterConfigLabel = LocalizedString.Get("Choose a 3D Printer Configuration");
                    string chooseThreeDPrinterConfigFull  = string.Format("{0}:", chooseThreeDPrinterConfigLabel);

                    TextWidget elementHeader = new TextWidget(string.Format(chooseThreeDPrinterConfigFull), pointSize: 14);
                    elementHeader.TextColor = this.defaultTextColor;
                    elementHeader.HAnchor   = HAnchor.ParentLeftRight;
                    elementHeader.VAnchor   = Agg.UI.VAnchor.ParentCenter;

                    headerRow.AddChild(elementHeader);
                }

                FlowLayoutWidget editButtonRow = new FlowLayoutWidget(FlowDirection.LeftToRight);
                editButtonRow.BackgroundColor = ActiveTheme.Instance.TransparentDarkOverlay;
                editButtonRow.HAnchor         = HAnchor.ParentLeftRight;
                editButtonRow.Margin          = new BorderDouble(0, 3, 0, 0);
                editButtonRow.Padding         = new BorderDouble(0, 3, 0, 0);


                Button enterLeaveEditModeButton;
                if (!this.editMode)
                {
                    enterLeaveEditModeButton        = editButtonFactory.Generate(LocalizedString.Get("Edit"), centerText: true);
                    enterLeaveEditModeButton.Click += EditModeOnLink_Click;
                }
                else
                {
                    enterLeaveEditModeButton        = editButtonFactory.Generate(LocalizedString.Get("Done"), centerText: true);
                    enterLeaveEditModeButton.Click += EditModeOffLink_Click;
                }

                editButtonRow.AddChild(enterLeaveEditModeButton);

                //To do - replace with scrollable widget
                FlowLayoutWidget printerListContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
                //ListBox printerListContainer = new ListBox();
                {
                    printerListContainer.HAnchor         = HAnchor.ParentLeftRight;
                    printerListContainer.VAnchor         = VAnchor.ParentBottomTop;
                    printerListContainer.Padding         = new BorderDouble(3);
                    printerListContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;

                    //Get a list of printer records and add them to radio button list
                    foreach (Printer printer in GetAllPrinters())
                    {
                        PrinterListItem printerListItem;
                        if (this.editMode)
                        {
                            printerListItem = new PrinterListItemEdit(printer, this.windowController);
                        }
                        else
                        {
                            printerListItem = new PrinterListItemView(printer, this.windowController);
                        }

                        printerListContainer.AddChild(printerListItem);
                    }
                }

                FlowLayoutWidget buttonContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
                buttonContainer.HAnchor = HAnchor.ParentLeft | HAnchor.ParentRight;
                buttonContainer.Margin  = new BorderDouble(0, 3);
                {
                    closeButton = textImageButtonFactory.Generate(LocalizedString.Get("Close"));

                    Button addPrinterButton = textImageButtonFactory.Generate(LocalizedString.Get("Add"), "icon_circle_plus.png");
                    addPrinterButton.Click += new EventHandler(AddConnectionLink_Click);

                    Button refreshListButton = textImageButtonFactory.Generate(LocalizedString.Get("Refresh"));
                    refreshListButton.Click += new EventHandler(EditModeOffLink_Click);

                    GuiWidget spacer = new GuiWidget();
                    spacer.HAnchor = HAnchor.ParentLeftRight;

                    //Add buttons to ButtonContainer
                    buttonContainer.AddChild(addPrinterButton);

                    if (!this.editMode)
                    {
                        buttonContainer.AddChild(refreshListButton);
                    }


                    buttonContainer.AddChild(spacer);
                    buttonContainer.AddChild(closeButton);
                }

                mainContainer.AddChild(headerRow);
                mainContainer.AddChild(editButtonRow);
                mainContainer.AddChild(printerListContainer);
                mainContainer.AddChild(buttonContainer);

                this.AddChild(mainContainer);

                BindCloseButtonClick();
            }
        }
 private void onMouseEnterBoundsAdvancedControlsLink(Object sender, EventArgs e)
 {
     HelpTextWidget.Instance.ShowHoverText(LocalizedString.Get("View Manual Printer Controls and Slicing Settings"));
 }
 public ClassificationRuleCollectionIllegalScopeException(LocalizedString message, Exception innerException) : base(message, innerException)
 {
 }