Example #1
0
        void ReleaseDesignerOutlets()
        {
            if (ButtonButton != null)
            {
                ButtonButton.Dispose();
                ButtonButton = null;
            }

            if (ButtonLabel != null)
            {
                ButtonLabel.Dispose();
                ButtonLabel = null;
            }

            if (TextButton != null)
            {
                TextButton.Dispose();
                TextButton = null;
            }

            if (TextLabel != null)
            {
                TextLabel.Dispose();
                TextLabel = null;
            }

            if (UserInterfaceLabel != null)
            {
                UserInterfaceLabel.Dispose();
                UserInterfaceLabel = null;
            }
        }
Example #2
0
        protected void Initialize()
        {
            Flex.SetBinding(FlexLayout.DirectionProperty, new Binding(nameof(Direction), source: this));
            ButtonImage.SetBinding(Image.SourceProperty, new Binding(nameof(ImageSource), source: this));
            ButtonLabel.SetBinding(Label.FontSizeProperty, new Binding(nameof(FontSize), source: this));
            ButtonLabel.SetBinding(Label.FontFamilyProperty, new Binding(nameof(FontFamily), source: this));
            ButtonLabel.SetBinding(Label.FontAttributesProperty, new Binding(nameof(FontAttributes), source: this));
            ButtonLabel.SetBinding(Label.TextProperty, new Binding(nameof(Text), source: this));
            ButtonLabel.SetBinding(Label.TextColorProperty, new Binding(nameof(TextColor), source: this));
            ButtonLabel.SetBinding(Label.VerticalTextAlignmentProperty, new Binding(nameof(VerticalTextAlignment), source: this));
            ButtonLabel.SetBinding(Label.HorizontalTextAlignmentProperty, new Binding(nameof(HorizontalTextAlignment), source: this));

            this.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() =>
                {
                    this.Tapped?.Invoke(this, EventArgs.Empty);

                    if (Command != null)
                    {
                        if (Command.CanExecute(CommandParameter))
                        {
                            Command.Execute(CommandParameter);
                        }
                    }
                }),
            });
        }
Example #3
0
        private void PersonLeaveAnimation()
        {
            ButtonLabel.Text = "Empezar";
            ButtonLabel.SetValue(Grid.RowProperty, 3);
            ButtonLabel.Visibility = Visibility.Collapsed;
            StartButton.SetValue(Grid.RowProperty, 3);
            StartButton.Visibility     = Visibility.Collapsed;
            BottomPanel.Visibility     = Visibility.Collapsed;
            BottomPanelText.Visibility = Visibility.Collapsed;
            BottomPanelText.Text       = "Ubícate para que tu cabeza se alinee con la imagen. Presiona continuar cuando hayas terminado.";
            SmallLabel.Text            = "Levanta tu mano y presiona el boton para empezar.";
            SmallLabel.Visibility      = Visibility.Collapsed;
            MainLabel.Text             = "¿Quieres ayudar a crear un algoritmo de identificación facial?";
            MainLabel.Visibility       = Visibility.Visible;
            VideoCapture.Visibility    = Visibility.Collapsed;
            ImgReference.Visibility    = Visibility.Collapsed;
            ImgReferenceBG.Visibility  = Visibility.Collapsed;
            Timer.Visibility           = Visibility.Collapsed;
            TimerBG.Visibility         = Visibility.Collapsed;
            TemplateImage.Visibility   = Visibility.Visible;

            string[] fromGradient = { "#ffd52941", "#ffe45f42", "#ffee894c", "#fff6b061", "#fffcd581" };
            string[] toGradient   = { "#ff1f719b", "#ff238aad", "#ff33a3bc", "#ff4cbcc9", "#ff6bd5d3" };
            UIAnimations.GradientAnimation(1.0, fromGradient, toGradient, BGCanvas);
        }
Example #4
0
        public void UpdateTranslation(GTResp gtr)
        {
            foreach (Control ct in pan_Translations.Controls)
            {
                var         ind = GTRs.IndexOf(gtr);
                var         pan = pan_Translations.Controls["PN_LINE_" + gtr.src_lang + ".to." + gtr.targ_lang];
                var         slt = pan.Controls[0];
                var         txt = pan.Controls[1];
                var         ab  = (pan.Controls[2] is ButtonLabel);
                ButtonLabel btn = (ButtonLabel)(ab ? pan.Controls[2] : pan.Controls[3]);
                btn.gtr = gtr;
//				Debug.WriteLine("updating speech url to "+gtr.speech_url);
                slt.Text = gtr.targ_lang + ":";
                var g    = CreateGraphics();
                var size = g.MeasureString(slt.Text, slt.Font);
                g.Dispose();
                slt.Width = (int)size.Width;
                if (ind != -1)
                {
                    GTRs.RemoveAt(ind);
                    GTRs.Insert(ind, gtr);
                }
                //			SPs.RemoveAt(i);
                //			SPs.Insert(i, getSP());
                txt.Text = gtr.translation;
                int abw = 0;
                if (!ab)
                {
                    var txttrc = (MahouUI.TextBoxCA)pan.Controls[2];
                    abw = txttrc.Width;
                }
                txt.Width = pan.Width - slt.Width - 2 - btn.Width - 2 - abw;
            }
        }
        public void UpdateButton(string text, bool buttonEnabled = true)
        {
            if (!string.IsNullOrEmpty(text))
            {
                ButtonLabel.SetText(text);
            }

            EnableButton(buttonEnabled);
        }
Example #6
0
        public override void WriteXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (Header != null)
            {
                ele.TryPathTo("Header", true, out subEle);
                Header.WriteXML(subEle, master);
            }
            if (EffectData != null)
            {
                ele.TryPathTo("EffectData", true, out subEle);
                EffectData.WriteXML(subEle, master);
            }
            if (Conditions != null)
            {
                ele.TryPathTo("Conditions", true, out subEle);
                foreach (var entry in Conditions)
                {
                    XElement newEle = new XElement("Condition");
                    entry.WriteXML(newEle, master);
                    subEle.Add(newEle);
                }
            }
            if (EntryPointFunctionType != null)
            {
                ele.TryPathTo("EntryPoint/FunctionType", true, out subEle);
                EntryPointFunctionType.WriteXML(subEle, master);
            }
            if (EntryPointFunctionData != null)
            {
                ele.TryPathTo("EntryPoint/FunctionData", true, out subEle);
                EntryPointFunctionData.WriteXML(subEle, master);
            }
            if (ButtonLabel != null)
            {
                ele.TryPathTo("ButtonLabel", true, out subEle);
                ButtonLabel.WriteXML(subEle, master);
            }
            if (RunImmediately != null)
            {
                ele.TryPathTo("RunImmediately", true, out subEle);
                RunImmediately.WriteXML(subEle, master);
            }
            if (Script != null)
            {
                ele.TryPathTo("Script", true, out subEle);
                Script.WriteXML(subEle, master);
            }
            if (EndMarker != null)
            {
                ele.TryPathTo("EndMarker", true, out subEle);
                EndMarker.WriteXML(subEle, master);
            }
        }
Example #7
0
        public void UpdateApperence(Color back, Color fore, int opacity, Font font)
        {
            foreach (Control ct in pan_Translations.Controls)
            {
                if (ct.Name.Contains("PN_LINE"))
                {
                    var txt = ct.Controls[1] as TextBox;
                    ct.Controls[0].BackColor = back;
                    txt.BackColor            = back;
                    var         ab = (ct.Controls[2] is ButtonLabel);
                    ButtonLabel bl = (ButtonLabel)(ab ? ct.Controls[2] : ct.Controls[3]);
                    if (!ab)
                    {
                        var txttrc = (MahouUI.TextBoxCA)ct.Controls[2];
                        txttrc.ForeColor = fore;
                        txttrc.BackColor = back;
                        txt.Font         = MahouUI.TrText;
                    }
                    bl.origin_bg             = bl.BackColor = ControlPaint.Light(back, (float)0.4);
                    ct.Controls[0].ForeColor = fore;
                    txt.ForeColor            = fore;
                    bl.origin_fg             = bl.ForeColor = fore;
//					ct.Controls[0].Font = font;
//					txt.Font = font;
                    ct.Controls[0].Font = txt.Font = MahouUI.TrText;
                }
            }
            txt_Source.BackColor       = back;
            txt_Source.ForeColor       = fore;
            txt_Source.Font            = MahouUI.TrText;
            X.BackColor                = back;
            X._original_color          = X.ForeColor = fore;
            pan_Translations.ForeColor = fore;
            pan_Translations.BackColor = back;
            TITLE.BackColor            = back;
            TITLE.ForeColor            = fore;
            BackColor       = back;
            txt_Source.Font = new Font(txt_Source.Font, FontStyle.Underline | FontStyle.Bold);
            if (this.Controls.ContainsKey(txtstrc))
            {
                var txt = (TextBox)this.Controls[txtstrc];
                txt.Font        = txt_Source.Font;
                txt.BackColor   = txt_Source.BackColor;
                txt.ForeColor   = txt_Source.ForeColor;
                txt.TabStop     = false;
                txt.BorderStyle = BorderStyle.None;
                txt.ReadOnly    = true;
            }
            Opacity = (double)opacity / 100;
            Invalidate();
        }
Example #8
0
        void ReleaseDesignerOutlets()
        {
            if (RemoteView != null)
            {
                RemoteView.Dispose();
                RemoteView = null;
            }

            if (ButtonLabel != null)
            {
                ButtonLabel.Dispose();
                ButtonLabel = null;
            }
        }
 public ButtonAction Invoke(BombSettings settings, Color color, ButtonLabel label)
 {
     // If the button is blue and the button says "Abort", hold the button and refer to "Releasing a Held Button".
     if (color == Color.Blue && label == ButtonLabel.Abort)
     {
         return ButtonAction.Hold;
     }
     else if (settings.BatteryCount.HasValue == false)
     {
         throw new NeedBatteryCountException();
     }
     // If there is more than one battery on the bomb and the button says "Detonate", press and immediately release the button.
     else if (settings.BatteryCount.Value > 1 && label == ButtonLabel.Detonate)
     {
         return ButtonAction.Tap;
     }
     else if (settings.IndicatorCAR.HasValue == false)
     {
         throw new NeedIndicatorCARException();
     }
     // If the button is white and there is a lit indicator with label CAR, hold the button and refer to "Releasing a Held Button".
     else if (color == Color.White && settings.IndicatorCAR.Value == true)
     {
         return ButtonAction.Hold;
     }
     else if (settings.IndicatorFRK.HasValue == false)
     {
         throw new NeedIndicatorFRKException();
     }
     // If there are more than 2 batteries on the bomb and there is a lit indicator with label FRK, press and immediately release the button.
     else if (settings.BatteryCount.Value > 2 && settings.IndicatorFRK.Value == true)
     {
         return ButtonAction.Tap;
     }
     // If the button is yellow, hold the button and refere to "Releasing a Held Button".
     else if (color == Color.Yellow)
     {
         return ButtonAction.Hold;
     }
     // If the button is red and the button says "Hold", press and immediately release the button.
     else if (color == Color.Red && label == ButtonLabel.Hold)
     {
         return ButtonAction.Tap;
     }
     // If none of the above apply, hold the button and refer to "Releasing a Held Button".
     else
     {
         return ButtonAction.Hold;
     }
 }
        void ReleaseDesignerOutlets()
        {
            if (ButtonLabel != null)
            {
                ButtonLabel.Dispose();
                ButtonLabel = null;
            }

            if (SegmentControll != null)
            {
                SegmentControll.Dispose();
                SegmentControll = null;
            }
        }
 private void StandardTopBorder_Load(object sender, EventArgs e)
 {
     pb_Logo.Image        = MiMFa_Convert.ToImage(this.ParentForm.Icon);
     FORMMOVE.MainControl = this.ParentForm;
     if (!LockState && string.IsNullOrEmpty(ButtonLabel.Text) && this.ParentForm != null)
     {
         ButtonLabel.Font = l_Text.Font;
         ButtonLabel.Text = this.ParentForm.CompanyName + " " + this.ParentForm.ProductName + " v" + this.ParentForm.ProductVersion;
         ButtonLabel.Refresh();
     }
     if (!LockState && string.IsNullOrEmpty(l_Text.Text) && this.ParentForm != null)
     {
         l_Text.Text = this.ParentForm.Text;
     }
 }
Example #12
0
        private void OnStartButton(object sender, RoutedEventArgs e)
        {
            if (stage == CaptureStage.Tracking)
            {
                stage            = CaptureStage.Agreement;
                ButtonLabel.Text = "Aceptar";
                MainLabel.Text   = "Vamos a tomar una serie de fotos que ayudaran a entrenar el algoritmo";
                SmallLabel.Text  = "Debes aceptar darnos permiso de usar las imágenes capturadas en el entrenamiento del algoritmo. \n * Estas imágenes no serán publicadas ni mostradas en ninguna parte.";
            }
            else if (stage == CaptureStage.Agreement)
            {
                stage = CaptureStage.Alignment;
                SmallLabel.Visibility = Visibility.Collapsed;
                StartButton.SetValue(Grid.RowProperty, 2);
                ButtonLabel.SetValue(Grid.RowProperty, 2);
                ButtonLabel.Text           = "Continuar";
                BottomPanel.Visibility     = Visibility.Visible;
                BottomPanelText.Visibility = Visibility.Visible;
                VideoCapture.Visibility    = Visibility.Visible;
                TemplateImage.Visibility   = Visibility.Visible;
                MainLabel.Visibility       = Visibility.Collapsed;
            }
            else if (stage == CaptureStage.Alignment)
            {
                stage = CaptureStage.Demo;
                capture.NewSubject();
                CaptureData(0);
                currentCapture            = 1;
                TemplateImage.Visibility  = Visibility.Collapsed;
                BottomPanelText.Text      = "Imagenes de guia apareceran en la pantalla, por cada una intenta imitar la orientación de la cabeza mostrada en la imagen. Presiona continuar para empezar las capturas.";
                ImgReference.Visibility   = Visibility.Visible;
                ImgReferenceBG.Visibility = Visibility.Visible;
                DemoReel();
            }
            else if (stage == CaptureStage.Demo)
            {
                stage = CaptureStage.ImageCaptures;
                StartButton.Visibility     = Visibility.Collapsed;
                ButtonLabel.Visibility     = Visibility.Collapsed;
                BottomPanel.Visibility     = Visibility.Collapsed;
                BottomPanelText.Visibility = Visibility.Collapsed;
                ImgReference.Source        = (ImageSource)FindResource("Ref_1");

                Task.Delay(3000).ContinueWith(t => NextCapture());
            }
        }
Example #13
0
 public override void WriteBinary(ESPWriter writer)
 {
     if (Header != null)
     {
         Header.WriteBinary(writer);
     }
     if (EffectData != null)
     {
         EffectData.WriteBinary(writer);
     }
     if (Conditions != null)
     {
         foreach (var item in Conditions)
         {
             item.WriteBinary(writer);
         }
     }
     if (EntryPointFunctionType != null)
     {
         EntryPointFunctionType.WriteBinary(writer);
     }
     if (EntryPointFunctionData != null)
     {
         EntryPointFunctionData.WriteBinary(writer);
     }
     if (ButtonLabel != null)
     {
         ButtonLabel.WriteBinary(writer);
     }
     if (RunImmediately != null)
     {
         RunImmediately.WriteBinary(writer);
     }
     if (Script != null)
     {
         Script.WriteBinary(writer);
     }
     if (EndMarker != null)
     {
         EndMarker.WriteBinary(writer);
     }
 }
Example #14
0
        public override void ReadBinary(ESPReader reader)
        {
            List <string> readTags = new List <string>();

            while (reader.BaseStream.Position < reader.BaseStream.Length)
            {
                string subTag = reader.PeekTag();

                switch (subTag)
                {
                case "PRKE":
                    if (readTags.Contains("PRKE"))
                    {
                        return;
                    }
                    Header.ReadBinary(reader);
                    break;

                case "DATA":
                    if (readTags.Contains("DATA"))
                    {
                        return;
                    }

                    switch (Header.Type)
                    {
                    case PerkType.QuestStage:
                        EffectData = new PerkQuestStageData();
                        break;

                    case PerkType.Ability:
                        EffectData = new PerkAbilityData();
                        break;

                    case PerkType.EntryPoint:
                        EffectData = new PerkEntryPointData();
                        break;
                    }

                    EffectData.ReadBinary(reader);
                    break;

                case "PRKC":
                    if (Conditions == null)
                    {
                        Conditions = new List <PerkCondition>();
                    }

                    PerkCondition tempPRKC = new PerkCondition();
                    tempPRKC.ReadBinary(reader);
                    Conditions.Add(tempPRKC);
                    break;

                case "EPFT":
                    if (readTags.Contains("EPFT"))
                    {
                        return;
                    }
                    if (EntryPointFunctionType == null)
                    {
                        EntryPointFunctionType = new SimpleSubrecord <EntryPointFunctionType>();
                    }

                    EntryPointFunctionType.ReadBinary(reader);
                    break;

                case "EPFD":
                    if (readTags.Contains("EPFD"))
                    {
                        return;
                    }
                    switch (EntryPointFunctionType.Value)
                    {
                    case Enums.EntryPointFunctionType.None:
                        EntryPointFunctionData = new SimpleSubrecord <byte[]>();
                        break;

                    case Enums.EntryPointFunctionType.Float:
                        EntryPointFunctionData = new SimpleSubrecord <float>();
                        break;

                    case Enums.EntryPointFunctionType.FloatFloat:
                        EntryPointFunctionData = new EntryPointRandRange();
                        break;

                    case Enums.EntryPointFunctionType.LeveledItem:
                        EntryPointFunctionData = new RecordReference();
                        break;

                    case Enums.EntryPointFunctionType.Script:
                        EntryPointFunctionData = new SimpleSubrecord <byte[]>();
                        break;

                    case Enums.EntryPointFunctionType.ActorValueMult:
                        EntryPointFunctionData = new EntryPointActorValMult();
                        break;
                    }

                    EntryPointFunctionData.ReadBinary(reader);
                    break;

                case "EPF2":
                    if (readTags.Contains("EPF2"))
                    {
                        return;
                    }
                    if (ButtonLabel == null)
                    {
                        ButtonLabel = new SimpleSubrecord <String>();
                    }

                    ButtonLabel.ReadBinary(reader);
                    break;

                case "EPF3":
                    if (readTags.Contains("EPF3"))
                    {
                        return;
                    }
                    if (RunImmediately == null)
                    {
                        RunImmediately = new SimpleSubrecord <NoYesShort>();
                    }

                    RunImmediately.ReadBinary(reader);
                    break;

                case "SCHR":
                    if (readTags.Contains("SCHR"))
                    {
                        return;
                    }
                    if (Script == null)
                    {
                        Script = new EmbeddedScript();
                    }

                    Script.ReadBinary(reader);
                    break;

                case "PRKF":
                    if (readTags.Contains("PRKF"))
                    {
                        return;
                    }
                    if (EndMarker == null)
                    {
                        EndMarker = new SubMarker();
                    }

                    EndMarker.ReadBinary(reader);
                    break;

                default:
                    return;
                }

                readTags.Add(subTag);
            }
        }
Example #15
0
        public ExplodeView(IGlobal global)
        {
            m_Global = global;
            //Pass m_Global to DebugMethod class so it can print to the listener
            DebugMethods.SetGlobal(m_Global);

            //Create UI elements:
            m_MaxForm = new MaxFormEx
            {
                Size            = new Size(302, 500),
                Text            = "Explode",
                BackColor       = Color.FromArgb(68, 68, 68),
                FormBorderStyle = FormBorderStyle.None
            };

            var treeviewManager = new TreeviewManager();

            //Create Controller
            m_Controller = new Controller(this, treeviewManager);

            //give treeview a controller
            treeviewManager.Controller = m_Controller;

            //Hook up event
            m_Controller.ExplodeChanged   += m_Controller_ExplodeChanged;
            m_Controller.DebugTextChanged += m_Controller_DebugTextChanged;

            //Create UI
            m_HelpPanel = new HelpPanel
            {
                Location = new Point(1, 306),
            };

            var addButton = new ButtonLabel
            {
                Size              = new Size(125, 25),
                Location          = new Point(10, 327),
                BackColor         = Color.FromArgb(90, 90, 90),
                ForeColor         = Color.FromArgb(220, 220, 220),
                Text              = "Add LP",
                TextAlign         = ContentAlignment.MiddleCenter,
                MouseDownProperty = false
            };

            addButton.MouseUp += addButton_MouseUp;

            var addHPButton = new ButtonLabel
            {
                Size              = new Size(125, 25),
                Location          = new Point(151, 327),
                BackColor         = Color.FromArgb(90, 90, 90),
                ForeColor         = Color.FromArgb(220, 220, 220),
                Text              = "Add HP",
                TextAlign         = ContentAlignment.MiddleCenter,
                MouseDownProperty = false
            };

            addHPButton.MouseUp += addHPButton_MouseUp;

            var explodeButton = new ButtonLabel
            {
                Size              = new Size(125, 25),
                Location          = new Point(10, 377),
                BackColor         = Color.FromArgb(90, 90, 90),
                ForeColor         = Color.FromArgb(220, 220, 220),
                Text              = "Explode",
                TextAlign         = ContentAlignment.MiddleCenter,
                MouseDownProperty = false
            };

            explodeButton.MouseUp += explodeButton_MouseUp;

            var exportButton = new ButtonLabel
            {
                Size              = new Size(125, 25),
                Location          = new Point(151, 377),
                BackColor         = Color.FromArgb(90, 90, 90),
                ForeColor         = Color.FromArgb(220, 220, 220),
                Text              = "Export",
                TextAlign         = ContentAlignment.MiddleCenter,
                MouseDownProperty = false
            };

            exportButton.MouseUp += exportButton_MouseUp;

            m_ExplodeAndExportButton = new ButtonLabel
            {
                Size              = new Size(266, 25),
                Location          = new Point(10, 409),
                BackColor         = Color.FromArgb(90, 90, 90),
                ForeColor         = Color.FromArgb(220, 220, 220),
                Text              = "Explode & Export",
                TextAlign         = ContentAlignment.MiddleCenter,
                MouseDownProperty = false
            };
            m_ExplodeAndExportButton.MouseUp += explodeAndExportButton_MouseUp;

            //Add Controls
            m_MaxForm.Controls.Add(treeviewManager);
            m_MaxForm.Controls.Add(m_HelpPanel);
            m_MaxForm.Controls.Add(addButton);
            m_MaxForm.Controls.Add(addHPButton);
            m_MaxForm.Controls.Add(explodeButton);
            m_MaxForm.Controls.Add(exportButton);
            m_MaxForm.Controls.Add(m_ExplodeAndExportButton);

            //Show form
            IntPtr maxHandle = global.COREInterface.MAXHWnd;

            m_MaxForm.Show(new ArbitraryWindow(maxHandle));


#if DEBUG
            Form debugForm = new Form();
            debugForm.Size = new Size(300, 300);
            debugForm.Show(new ArbitraryWindow(maxHandle));
            debugForm.Closing += debugForm_Closing;

            Button button = new Button();
            button.Size     = new Size(200, 25);
            button.Location = new Point(10, 10);
            button.Text     = "Create BB for Parent Node";
            button.Click   += button_Click;

            Button movebutton = new Button();
            movebutton.Size     = new Size(200, 25);
            movebutton.Location = new Point(10, 90);
            movebutton.Text     = "movesomething";
            movebutton.Click   += movebutton_Click;

            Button getVertInfoFromID = new Button();
            getVertInfoFromID.Size     = new Size(200, 25);
            getVertInfoFromID.Location = new Point(10, 50);
            getVertInfoFromID.Text     = "Close";
            getVertInfoFromID.Click   += getVertInfoFromID_Click;

            debugForm.Controls.Add(button);
            debugForm.Controls.Add(getVertInfoFromID);
            debugForm.Controls.Add(movebutton);
#endif
        }
Example #16
0
 public static extern IntPtr imaqLoadImagePopup([MarshalAs(UnmanagedType.LPStr)] string defaultDirectory, [MarshalAs(UnmanagedType.LPStr)] string defaultFileSpec, [MarshalAs(UnmanagedType.LPStr)] string fileTypeList, [MarshalAs(UnmanagedType.LPStr)] string title, int allowMultiplePaths, ButtonLabel buttonLabel, int restrictDirectory, int restrictExtension, int allowCancel, int allowMakeDirectory, ref int cancelled, ref int numPaths);
Example #17
0
        public void SetOptimalWidth()
        {
            SuspendLayout();
            Width  = pan_Translations.Width = 0;            // Minify
            pant_y = txt_Source.Height = 0;
            // 1st find max width
            var g = CreateGraphics();

            SetAboveTitleWidth();
            var s  = g.MeasureString(txt_Source.Text, txt_Source.Font);
            var sw = Convert.ToInt32(s.Width);

            txt_Source.Width = sw + 4;
            var     pan_h = new int[pan_Translations.Controls.Count + 1];
            TextBox txtS  = null;

            if (TRANSCRIPTION)
            {
                if (this.Controls.ContainsKey(txtstrc))
                {
                    txtS = (TextBox)this.Controls[txtstrc];
                    var s2  = g.MeasureString(txtS.Text, txtS.Font);
                    var sw2 = Convert.ToInt32(s2.Width);
                    txtS.Width = sw2;
                    var lef = txt_Source.Location.X + txt_Source.Width + 4;
                    sw           += lef + sw2;
                    txtS.Location = new Point(lef, txt_Source.Location.Y);
                }
            }
            if (sw > Width)
            {
                Width = sw + 20 + 2;
            }
            var mod = Math.Ceiling((float)sw / Width);

//				Debug.WriteLine("Height[mod]x[H] " + mod +"x"+s.Height);
            if (mod > 1)
            {
                txt_Source.Height = (int)(s.Height * mod);
                if (txtS != null)
                {
                    txtS.Height = (int)(s.Height * mod);
                }
            }
            else
            {
                txt_Source.Height = (int)s.Height;
                if (txtS != null)
                {
                    txtS.Height = (int)s.Height;
                }
            }
            if (txtS != null)
            {
                txtS.Width = Width - txtS.Location.X - 2;
                if (txt_Source.Width > txtS.Width)
                {
                    var mw = Width - txt_Source.Location.X - X.Width - 14;
                    txt_Source.Width = txtS.Width = mw / 2;
                    var x = g.MeasureString(txt_Source.Text, txt_Source.Font, txt_Source.Width);
                    pant_y            = (int)x.Height;
                    txt_Source.Height = (int)x.Height + txt_Source.Font.Height;
                    x           = g.MeasureString(txtS.Text, txtS.Font, txtS.Width);
                    txtS.Height = (int)x.Height + txtS.Font.Height;
                    var panty = (int)x.Height;
                    if (panty > pant_y)
                    {
                        pant_y = panty;
                    }
                    txtS.Location = new     Point(txt_Source.Location.X + txt_Source.Width, txt_Source.Location.Y);
                }
            }
            else
            {
                txt_Source.Width = Width;
            }
            int c = 0;

            foreach (Control ct in pan_Translations.Controls)
            {
                var         pan    = ct;
                var         slt    = pan.Controls[0];
                var         txt    = pan.Controls[1] as TextBox;
                var         ab     = (pan.Controls[2] is ButtonLabel);
                ButtonLabel btn    = (ButtonLabel)(ab ? pan.Controls[2] : pan.Controls[3]);
                var         size   = g.MeasureString(slt.Text, slt.Font);
                var         trsize = g.MeasureString(txt.Text, txt.Font);
                slt.Width  = (int)size.Width;
                txt.Width  = (int)trsize.Width;
                mod        = Math.Ceiling(trsize.Width / Width);
                txt.Height = (int)(Math.Floor(trsize.Height) * mod);
                var panh = (int)trsize.Height;
                if (pan_h[c] < panh)
                {
                    pan_h[c] = panh;
                }
                int abw = 0;
                if (!ab)
                {
                    var txttrc = (MahouUI.TextBoxCA)pan.Controls[2];
                    var strc   = g.MeasureString(txttrc.Text, txttrc.Font);
                    abw           = txttrc.Width = (int)strc.Width;
                    mod           = Math.Ceiling(strc.Width / Width);
                    txttrc.Height = (int)(Math.Floor(strc.Height) * mod);
                    panh          = (int)strc.Height;
                    if (pan_h[c] < panh)
                    {
                        pan_h[c] = panh;
                    }
                }
                var longest = (slt.Width + txt.Width + btn.Width + 4 + abw);
                if (longest > Width)
                {
                    Width = longest;
                }
                if (!ab)
                {
                    var txttrc   = (MahouUI.TextBoxCA)pan.Controls[2];
                    var txttrcsz = g.MeasureString(txttrc.Text, txttrc.Font);
                    txttrc.Width  = Width - slt.Width - txt.Width - btn.Width - 4 - 4;
                    txttrc.Height = (int)(Math.Ceiling(txttrcsz.Width / txttrc.Width) * txttrcsz.Height);
                    if (txt.Width > txttrc.Width && longest > Width)
                    {
                        var mw = Width - txt.Location.X - slt.Width - btn.Width - 4 - 4;
                        txt.Width = txttrc.Width = mw / 2;
                        var x = g.MeasureString(txt.Text, txt.Font, txt.Width);
                        txt.Height    = (int)x.Height + txt.Font.Height;
                        x             = g.MeasureString(txttrc.Text, txttrc.Font, txttrc.Width);
                        txttrc.Height = (int)x.Height + txttrc.Font.Height;
                        panh          = (int)x.Height;
                        if (pan_h[c] < panh)
                        {
                            pan_h[c] = panh;
                        }
                    }
                }
                c++;
            }
            g.Dispose();
            pan_Translations.Width = Width - 2;
            // 2nd set right positions
            c = 0;
            foreach (Control ct in pan_Translations.Controls)
            {
                var         pan = ct;
                var         slt = pan.Controls[0];
                var         txt = pan.Controls[1];
                var         ab  = (pan.Controls[2] is ButtonLabel);
                ButtonLabel btn = (ButtonLabel)(ab ? pan.Controls[2] : pan.Controls[3]);
                if (!ab)
                {
                    var txttrc = (MahouUI.TextBoxCA)pan.Controls[2];
                    txttrc.Location = new Point(txt.Location.X + txt.Width, txt.Location.Y);
                }
                pan.Width = pan_Translations.Width - 2;
                Debug.WriteLine("PAN_H[" + c + "] = " + pan_h[c]);
                pan.Height   = pan_h[c] + 2;
                btn.Location = new Point(pan.Width - 14 - 1, 1);
//				txt.Width = pan.Width-slt.Width-2-btn.Width-2-abw;
                txt.Location = new Point(slt.Width + 2, 1);
                Prepare();
                c++;
            }
            UpdateHeight();
            ResumeLayout(false);
        }
Example #18
0
        public override void ReadXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (ele.TryPathTo("Header", false, out subEle))
            {
                if (Header == null)
                {
                    Header = new PerkEffectHeader();
                }

                Header.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("EffectData", false, out subEle))
            {
                switch (Header.Type)
                {
                case PerkType.QuestStage:
                    EffectData = new PerkQuestStageData();
                    break;

                case PerkType.Ability:
                    EffectData = new PerkAbilityData();
                    break;

                case PerkType.EntryPoint:
                    EffectData = new PerkEntryPointData();
                    break;
                }

                EffectData.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Conditions", false, out subEle))
            {
                if (Conditions == null)
                {
                    Conditions = new List <PerkCondition>();
                }

                foreach (XElement e in subEle.Elements())
                {
                    PerkCondition temp = new PerkCondition();
                    temp.ReadXML(e, master);
                    Conditions.Add(temp);
                }
            }
            if (ele.TryPathTo("EntryPoint/FunctionType", false, out subEle))
            {
                if (EntryPointFunctionType == null)
                {
                    EntryPointFunctionType = new SimpleSubrecord <EntryPointFunctionType>();
                }

                EntryPointFunctionType.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("EntryPoint/FunctionData", false, out subEle))
            {
                switch (EntryPointFunctionType.Value)
                {
                case Enums.EntryPointFunctionType.None:
                    EntryPointFunctionData = new SimpleSubrecord <byte[]>();
                    break;

                case Enums.EntryPointFunctionType.Float:
                    EntryPointFunctionData = new SimpleSubrecord <float>();
                    break;

                case Enums.EntryPointFunctionType.FloatFloat:
                    EntryPointFunctionData = new EntryPointRandRange();
                    break;

                case Enums.EntryPointFunctionType.LeveledItem:
                    EntryPointFunctionData = new RecordReference();
                    break;

                case Enums.EntryPointFunctionType.Script:
                    EntryPointFunctionData = new SimpleSubrecord <byte[]>();
                    break;

                case Enums.EntryPointFunctionType.ActorValueMult:
                    EntryPointFunctionData = new EntryPointActorValMult();
                    break;
                }

                EntryPointFunctionData.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("ButtonLabel", false, out subEle))
            {
                if (ButtonLabel == null)
                {
                    ButtonLabel = new SimpleSubrecord <String>();
                }

                ButtonLabel.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("RunImmediately", false, out subEle))
            {
                if (RunImmediately == null)
                {
                    RunImmediately = new SimpleSubrecord <NoYesShort>();
                }

                RunImmediately.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Script", false, out subEle))
            {
                if (Script == null)
                {
                    Script = new EmbeddedScript();
                }

                Script.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("EndMarker", false, out subEle))
            {
                if (EndMarker == null)
                {
                    EndMarker = new SubMarker();
                }

                EndMarker.ReadXML(subEle, master);
            }
        }
Example #19
0
        public void AddTranslation(GTResp gtr)
        {
            txt_Source.Text = gtr.source;
            if (TRANSCRIPTION)
            {
                if (!string.IsNullOrEmpty(gtr.src_transcr))
                {
                    var txt = new MahouUI.TextBoxCA();
                    txt.Name      = txtstrc;
                    txt.Multiline = true;
                    if (this.Controls.ContainsKey(txtstrc))
                    {
                        txt = (MahouUI.TextBoxCA) this.Controls[txtstrc];
                    }
                    else
                    {
                        this.Controls.Add(txt);
                    }
                    txt.Text = "[" + MahouUI.UnescapeUnicode(gtr.src_transcr) + "]";
                }
                else
                {
                    if (this.Controls.ContainsKey(txtstrc))
                    {
                        this.Controls.Remove(this.Controls[txtstrc]);
                    }
                }
            }
            pan_Translations.Width = Width - 2;
            bool exist = false;

            if (GTRs.Count == 0)
            {
                pan_Translations.Height = 0;
            }
            if (!String.IsNullOrEmpty(MahouUI.AutoCopyTranslation))
            {
                if (MahouUI.AutoCopyTranslation.ToLower() == gtr.targ_lang.ToLower())
                {
                    Debug.WriteLine("AutoCopyTranslation: " + gtr.targ_lang);
                    KMHook.RestoreClipBoard(gtr.translation);
                    MahouUI.ACT_Match++;
                }
            }
            foreach (Control ct in pan_Translations.Controls)
            {
                if (ct.Name == "PN_LINE_" + gtr.src_lang + ".to." + gtr.targ_lang)
                {
                    exist = true;
                    break;
                }
            }
            if (exist)
            {
                UpdateTranslation(gtr);
            }
            else
            {
                GTRs.Add(gtr);
                var ind = GTRs.IndexOf(gtr);
                var pan = new Panel();
                pan.Width  = pan_Translations.Width - 2;
                pan.Height = MahouUI.TrText.Height * 2;
                Debug.WriteLine("Pan height: " + pan.Height);
                pan.Name     = "PN_LINE_" + gtr.src_lang + ".to." + gtr.targ_lang;
                pan.Location = new Point(1, pan_Translations.Height + 1);
                var slt = new MahouUI.TextBoxCA();
                var txt = new MahouUI.TextBoxCA();
                slt.ReadOnly    = txt.ReadOnly = true;
                slt.TabStop     = txt.TabStop = false;
                slt.Name        = "SL_TXT" + gtr.targ_lang;
                slt.BorderStyle = txt.BorderStyle = 0;
                slt.Location    = new Point(1, 0);
                slt.Text        = (gtr.auto_detect ? "" : gtr.src_lang + "/") + gtr.targ_lang + ":";
                var g    = CreateGraphics();
                var size = g.MeasureString(slt.Text, slt.Font);
                slt.Width = (int)size.Width;
                txt.Name  = "TR_TXT" + gtr.targ_lang;
                txt.Text  = MahouUI.UnescapeUnicode(gtr.translation);
                var btn = new ButtonLabel();
                btn.Text   = "♫";
                btn.gtr    = gtr;
                btn.Name   = "LBBT_SP" + gtr.targ_lang;
                btn.Width  = 14;
                btn.Height = 14;
                pan.Controls.Add(slt);
                pan.Controls.Add(txt);
                var trcw = 0;
                if (TRANSCRIPTION)
                {
                    if (!String.IsNullOrEmpty(gtr.targ_transcr))
                    {
                        MahouUI.TextBoxCA txttrc = new MahouUI.TextBoxCA();
                        txttrc.ReadOnly    = true;
                        txttrc.TabStop     = false;
                        txttrc.BorderStyle = 0;
                        txttrc.Multiline   = true;
                        txttrc.Font        = MahouUI.TrText;
                        txttrc.Name        = "TRC_TXT" + gtr.targ_lang;
                        txttrc.Text        = "[" + MahouUI.UnescapeUnicode(gtr.targ_transcr) + "]";
                        var si = g.MeasureString(txttrc.Text, txttrc.Font);
                        trcw            = txttrc.Width = (int)si.Width;
                        txttrc.Location = new Point(txt.Location.X + pan.Width - slt.Width - 2 - btn.Width - 2 - trcw, txt.Location.Y);
                        pan.Controls.Add(txttrc);
                    }
                }
                g.Dispose();
                btn.Location = new Point(pan.Width - 14 - 1, 1);
                pan.Controls.Add(btn);
                txt.Width     = pan.Width - slt.Width - 2 - btn.Width - 2 - trcw;
                txt.Multiline = true;
                txt.Location  = new Point(slt.Width + 2, 1);
                btn.BackColor = slt.BackColor = txt.BackColor = pan_Translations.BackColor;
                btn.ForeColor = slt.ForeColor = txt.ForeColor = pan_Translations.ForeColor;
                pan_Translations.Controls.Add(pan);
                txt_Source.Font = slt.Font = txt.Font = MahouUI.TrText;
                UpdateHeight();
            }
            SetOptimalWidth();
            SetOptimalWidth();
        }
Example #20
0
        public void AddTranslation(GTResp gtr)
        {
            txt_Source.Text        = gtr.source;
            pan_Translations.Width = Width - 2;
            bool exist = false;

            if (GTRs.Count == 0)
            {
                pan_Translations.Height = 0;
            }
            foreach (Control ct in pan_Translations.Controls)
            {
                if (ct.Name == "PN_LINE_" + gtr.src_lang + ".to." + gtr.targ_lang)
                {
                    exist = true;
                    break;
                }
            }
            if (exist)
            {
                UpdateTranslation(gtr);
            }
            else
            {
                GTRs.Add(gtr);
                var ind = GTRs.IndexOf(gtr);
                var pan = new Panel();
                pan.Width  = pan_Translations.Width - 2;
                pan.Height = MahouUI.TrText.Height * 2;
                Debug.WriteLine("Pan height: " + pan.Height);
                pan.Name     = "PN_LINE_" + gtr.src_lang + ".to." + gtr.targ_lang;
                pan.Location = new Point(1, pan_Translations.Height + 1);
                var slt = new TextBox();
                var txt = new TextBox();
                slt.ReadOnly    = txt.ReadOnly = true;
                slt.TabStop     = txt.TabStop = false;
                slt.Name        = "SL_TXT" + gtr.targ_lang;
                slt.BorderStyle = txt.BorderStyle = 0;
                slt.Location    = new Point(1, 0);
                slt.Text        = (gtr.auto_detect ? "" : gtr.src_lang + "/") + gtr.targ_lang + ":";
                var g    = CreateGraphics();
                var size = g.MeasureString(slt.Text, slt.Font);
                g.Dispose();
                slt.Width = (int)size.Width;
                txt.Name  = "TR_TXT" + gtr.targ_lang;
                txt.Text  = gtr.translation;
                var btn = new ButtonLabel();
                btn.Text     = "♫";
                btn.gtr      = gtr;
                btn.Name     = "LBBT_SP" + gtr.targ_lang;
                btn.Width    = 14;
                btn.Height   = 14;
                btn.Location = new Point(pan.Width - 14 - 1, 1);
                pan.Controls.Add(slt);
                pan.Controls.Add(txt);
                pan.Controls.Add(btn);
                txt.Width     = pan.Width - slt.Width - 2 - btn.Width - 2;
                txt.Location  = new Point(slt.Width + 2, 1);
                btn.BackColor = slt.BackColor = txt.BackColor = pan_Translations.BackColor;
                btn.ForeColor = slt.ForeColor = txt.ForeColor = pan_Translations.ForeColor;
                pan_Translations.Controls.Add(pan);
                txt_Source.Font = slt.Font = txt.Font = MahouUI.TrText;
                UpdateHeight();
            }
            SetOptimalWidth();
            SetOptimalWidth();
        }
Example #21
0
        public Menu(ViewRoot parent)
            : base(parent)
        {
            var families = ContentLoadAuto.Get<Menu, DMI>("Planet").Families;
            var planet = new PanelImage(this, families["planet"].Directions[0].Image(0));
            planet.Size = new Vector2(527, 495);
            planet.Position = new Vector2(50, 100);

            _pnlEntries = new PanelList(this);
            _lblTitle   = new Label(this, "Marooned", ContentLoadAuto.Get<Menu, SpriteFont>("Minecraftia_big"));
            _pnlCredits = new Credits(this);

            /// \note Assume mono-spaced font.
            var btnNewGame = new ButtonLabel(_pnlEntries, "  New Game", ContentLoadAuto.Get<Menu, SpriteFont>("Minecraftia"));
            var btnOptions = new ButtonLabel(_pnlEntries, "Options ", ContentLoadAuto.Get<Menu, SpriteFont>("Minecraftia"));
            var btnCredits = new ButtonLabel(_pnlEntries, "Credits ", ContentLoadAuto.Get<Menu, SpriteFont>("Minecraftia"));
            var btnExit = new ButtonLabel(_pnlEntries, "Exit       ", ContentLoadAuto.Get<Menu, SpriteFont>("Minecraftia"));

            btnNewGame.ContentsEncompass(); btnNewGame.ColourHovered.ValueActive = Color.Orange;
            btnOptions.ContentsEncompass(); btnOptions.ColourHovered.ValueActive = Color.Orange;
            btnCredits.ContentsEncompass(); btnCredits.ColourHovered.ValueActive = Color.Orange;
            btnExit   .ContentsEncompass(); btnExit   .ColourHovered.ValueActive = Color.Red;

            btnOptions.InputEnabledMouse = false;

            _lblTitle.ContentsEncompass();
            _pnlEntries.Size = new Vector2(_pnlEntries.Select(p => p.Size.X).Max()
                                          ,_pnlEntries.Sum   (p => p.Size.Y));

            btnNewGame.OnClicked += (eButton) => { if (eButton != Buttons.A) return;
                                                   parent.Game = new GameInfo();
                                                   Visible = false; };
            btnExit   .OnClicked += (eButton) => { if (eButton != Buttons.A) return;
                                                   Marooned.Instance.Exit(); };
            btnCredits.OnClicked       += (eButton) => { ItsGameOverManGameOver(Credits.PlayType.GameOver); };
            btnCredits.OnClickedDouble += (eButton) => { ItsGameOverManGameOver(Credits.PlayType.Success ); };

                   OnResize += () => LayoutInvalidate();
            parent.OnResize += () => Size = parent.Size;

            OnVisibilityChanged += () => {
                if (Visible)
                {
                    CellActive = null;
                    if (parent.Game == null) return;
                    CellActive = parent.Game.World.ActiveCell;
                    parent.Game.World.ActiveCell = null;
                }
                else
                    parent.Game.World.ActiveCell = CellActive ?? parent.Game.World.ActiveCell;
            };

            OnInputKey += (eKey, bRelease) => {
                if (!bRelease          ) return;
                if (eKey != Keys.Escape) return;

                if (_pnlCredits.Play != Credits.PlayType.None)
                {
                    _pnlCredits.Play = Credits.PlayType.None;
                    return;
                }

                if (parent.Game == null) return;
                Visible = false;
            };
        }
    public override void Start()
    {
        base.Start();
        string name = string.Format("{0} #{1}", Connector.KMBombModule.ModuleDisplayName, Connector.ModuleID);

        _gameInfo = GetComponent <KMGameInfo>();
        _bombInfo = GetComponent <KMBombInfo>();

        _translation = GetComponent <TranslatedTheButton> ();
        _translation.GenerateLanguage(name);
        LanguageTheButton language = _translation.Language;

        // Sets the appearance of the button
        Connector.SetColour(_color = (ButtonColour)Random.Range(0, 4));

        _label = (ButtonLabel)Random.Range(0, 4);
        if (_translation.Language.DisplayMethod == LanguageTheButton.DisplayMethods.CustomTextMesh)
        {
            Connector.SetLabel(language.GetLabelFromEnglishName(_label.ToString()), language.Font, language.FontMaterial, language.GetSizeFromEnglishName(_label.ToString()));
        }
        else
        {
            Connector.SetLabel(language.GetLabelFromEnglishName(_label.ToString()));
        }

        LogFormat(language.RuleColorIs, language.GetLogFromEnglishName(_color.ToString()));
        LogFormat(language.RuleLabelIs, language.GetLogFromEnglishName(_label.ToString()));
        LogFormat(language.RuleButtonShouldBe, (ShouldBeHeld() ? language.RuleHeld : language.RulePressed));

        // Register button hold and released events
        Connector.Held     += Button_In;
        Connector.Released += Button_Out;

        // todo: this seems not needed anymore. Maybe for sprites.
        // Hide our custom text mesh/sprite in the dark.
        //if (_translation.Language.DisplayMethod != LanguageTheButton.DisplayMethods.Default) {
        //	if (_color == ButtonColour.Blue || _color == ButtonColour.Red) {
        //		_gameInfo.OnLightsChange += Connector.ToggleLabel;
        //		Connector.ToggleLabel(false);
        //	}
        //}

        TwitchHelpMessage = string.Format("{1}, {2} - !{0} tap | !{0} hold | !{0} release 7 (releases when there's a 7 in the timer)", "{0}", _translation.Language.NativeName, _translation.Language.Name);

        // Stuff regarding the cover
        var moduleSelectable = GetComponent <KMSelectable>();

        _buttonSelectable            = moduleSelectable.Children[0];
        moduleSelectable.OnHighlight = () => { if (OpenCoverOnSelection)
                                               {
                                                   Connector.OpenCover();
                                               }
        };
        _buttonSelectable.OnHighlight = () => { if (OpenCoverOnSelection)
                                                {
                                                    Connector.OpenCover();
                                                }
        };
        moduleSelectable.OnHighlightEnded = () => { if (OpenCoverOnSelection)
                                                    {
                                                        Connector.CloseCover();
                                                    }
        };
        _buttonSelectable.OnHighlightEnded = () => { if (OpenCoverOnSelection)
                                                     {
                                                         Connector.CloseCover();
                                                     }
        };
        moduleSelectable.OnCancel = () => { Connector.CloseCover(); return(true); };         // Twitch Plays
        if (Application.isEditor)
        {
            // Things work a bit differently in the test harness from the actual game.
            // TODO: There is currently an issue whereby going from one module to another does not call any event.
            moduleSelectable.OnInteract = () => { if (!OpenCoverOnSelection)
                                                  {
                                                      Connector.OpenCover();
                                                  }
                                                  return(true); };
        }
        else
        {
            OpenCoverOnSelection     = Connector.ShouldOpenCoverOnSelection;
            moduleSelectable.OnFocus = () => { if (!OpenCoverOnSelection)
                                               {
                                                   Connector.OpenCover();
                                               }
            };
            moduleSelectable.OnDefocus = () => Connector.CloseCover();
        }
    }