Ejemplo n.º 1
0
        /// <summary>
        /// Create a new macro
        /// </summary>
        /// <param name="type">Type of the macro : Permanent, Temporary, Stream</param>
        /// <param name="id">ID of the macro</param>
        public Macro(MacroType type, byte id)
        {
            if (type != MacroType.Permanent)
                _id = (byte)type;
            else
                _id = id;

            _type = type;
            _flags = 0x00;
            //_extFlags = 0x00;

            Commands = new List<MacroCommand>();
        }
        public MacroDeclarationStatementNode(string identifier, IEnumerable<MacroFormalParameterNode> formalParameters, BlockStatementNode body, MacroType macroType)
            : base(identifier)
        {
            if (body == null)
                ThrowHelper.ThrowArgumentNullException(() => body);

            if (formalParameters == null)
                ThrowHelper.ThrowArgumentNullException(() => formalParameters);

            if (body == null)
                ThrowHelper.ThrowArgumentNullException(() => body);

            FormalParameters = formalParameters.ToArray();
            Body = body;
            MacroType = macroType;

            AddChildren(Body);
        }
Ejemplo n.º 3
0
 public Macro(MacroType type, string value)
     : this(type)
 {
     m_ValueString = value;
     m_ValueType   = ValueTypes.String;
 }
Ejemplo n.º 4
0
 public Macro(MacroType type)
 {
     Type = type;
 }
Ejemplo n.º 5
0
        public List <LogInfo> LoadMacroDict(MacroType type, ScriptSection section, IEnumerable <string> lines, bool append)
        {
            Dictionary <string, string> dict = IniReadWriter.ParseIniLinesIniStyle(lines);

            return(LoadMacroDict(type, section, dict, append));
        }
Ejemplo n.º 6
0
 public Macro(MacroType type, string value)
     : this(type)
 {
     m_ValueString = value;
     m_ValueType = ValueTypes.String;
 }
Ejemplo n.º 7
0
 public Macro(MacroType type)
 {
     Type = type;
 }
Ejemplo n.º 8
0
 public MacroDefinition(string name, MacroType type)
 {
     Name  = name;
     Type  = type;
     Index = 0;
 }
Ejemplo n.º 9
0
        private void CreateCombobox(MacroObject obj)
        {
            Combobox box = new Combobox(0, 0, 200, Enum.GetNames(typeof(MacroType)), (int)obj.Code, 300);

            box.OnOptionSelected += (sender, e) =>
            {
                Combobox b = (Combobox)sender;

                if (b.SelectedIndex == 0) // MacroType.None
                {
                    MacroObject m = (MacroObject)b.Tag;

                    if (Macro.FirstNode == m)
                    {
                        Macro.FirstNode = m.Right;
                    }

                    if (m.Right != null)
                    {
                        m.Right.Left = m.Left;
                    }

                    if (m.Left != null)
                    {
                        m.Left.Right = m.Right;
                    }

                    m.Left  = null;
                    m.Right = null;

                    b.Tag = null;

                    b.Parent.Dispose();
                    _comboboxes.Remove(b);

                    if (_comboboxes.Count == 0 || _comboboxes.All(s => s.IsDisposed))
                    {
                        Macro.FirstNode = Macro.Create(MacroType.None);
                        CreateCombobox(Macro.FirstNode);
                    }
                }
                else
                {
                    MacroType t = (MacroType)b.SelectedIndex;

                    MacroObject m        = (MacroObject)b.Tag;
                    MacroObject newmacro = Macro.Create(t);

                    MacroObject left  = m.Left;
                    MacroObject right = m.Right;

                    if (left != null)
                    {
                        left.Right = newmacro;
                    }

                    if (right != null)
                    {
                        right.Left = newmacro;
                    }

                    newmacro.Left  = left;
                    newmacro.Right = right;

                    b.Tag = newmacro;

                    if (Macro.FirstNode == m)
                    {
                        Macro.FirstNode = newmacro;
                    }


                    b.Parent.Children
                    .Where(s => s != b)
                    .ToList()
                    .ForEach(s => s.Dispose());

                    switch (newmacro.HasSubMenu)
                    {
                    case 1:     // another combo
                        int count  = 0;
                        int offset = 0;

                        Macro.GetBoundByCode(t, ref count, ref offset);

                        Combobox subBox = new Combobox(20, b.Height + 2, 180, Enum.GetNames(typeof(MacroSubType))
                                                       .Skip(offset)
                                                       .Take(count)
                                                       .ToArray(), 0, 300);


                        subBox.OnOptionSelected += (ss, ee) =>
                        {
                            Macro.GetBoundByCode(newmacro.Code, ref count, ref offset);
                            MacroSubType subType = (MacroSubType)(offset + ee);
                            newmacro.SubCode = subType;
                        };

                        b.Parent.Add(subBox);
                        b.Parent.WantUpdateSize = true;

                        break;

                    case 2:     // string

                        b.Parent.Add(new ResizePic(0x0BB8)
                        {
                            X      = 18,
                            Y      = b.Height + 2,
                            Width  = 240,
                            Height = b.Height * 2 + 4
                        });

                        TextBox textbox = new TextBox(new TextEntry(0xFF, 80, 0, 236, true, FontStyle.BlackBorder), true)
                        {
                            X      = 20,
                            Y      = b.Height + 5,
                            Height = b.Height * 2
                        };
                        textbox.TxEntry.SetHeight(b.Height * 2);

                        textbox.TextChanged += (sss, eee) =>
                        {
                            if (newmacro.HasString())
                            {
                                ((MacroObjectString)newmacro).Text = ((TextBox)sss).Text;
                            }
                        };

                        b.Parent.Add(textbox);
                        b.Parent.WantUpdateSize = true;

                        break;
                    }
                }
            };

            box.Tag = obj;
            _scrollArea.Add(box);
            _comboboxes.Add(box);


            if (obj.Code != MacroType.None)
            {
                switch (obj.HasSubMenu)
                {
                case 1:
                    int count  = 0;
                    int offset = 0;

                    Macro.GetBoundByCode(obj.Code, ref count, ref offset);

                    Combobox subBox = new Combobox(20, box.Height + 2, 180, Enum.GetNames(typeof(MacroSubType))
                                                   .Skip(offset)
                                                   .Take(count)
                                                   .ToArray(), (int)(obj.SubCode - offset), 300);


                    subBox.OnOptionSelected += (ss, ee) =>
                    {
                        Macro.GetBoundByCode(obj.Code, ref count, ref offset);
                        MacroSubType subType = (MacroSubType)(offset + ee);
                        obj.SubCode = subType;
                    };

                    box.Parent.Add(subBox);
                    box.Parent.WantUpdateSize = true;

                    break;

                case 2:

                    box.Parent.Add(new ResizePic(0x0BB8)
                    {
                        X      = 18,
                        Y      = box.Height + 2,
                        Width  = 240,
                        Height = box.Height * 2 + 4
                    });

                    TextBox textbox = new TextBox(new TextEntry(0xFF, 80, 0, 236, true, FontStyle.BlackBorder), true)
                    {
                        X      = 20,
                        Y      = box.Height + 5,
                        Height = box.Height * 2
                    };
                    textbox.TxEntry.SetHeight(box.Height * 2);
                    textbox.SetText(obj.HasString() ? ((MacroObjectString)obj).Text : string.Empty);
                    textbox.TextChanged += (sss, eee) =>
                    {
                        if (obj.HasString())
                        {
                            ((MacroObjectString)obj).Text = ((TextBox)sss).Text;
                        }
                    };

                    box.Parent.Add(textbox);
                    box.Parent.WantUpdateSize = true;

                    break;
                }
            }
        }
Ejemplo n.º 10
0
 internal FormulaMacro(MacroType type, Formula formula)
 {
     this._type    = type;
     this._formula = formula ?? throw new ArgumentNullException(nameof(formula));
 }
Ejemplo n.º 11
0
Archivo: Macro.cs Proyecto: jmclain/Nmp
		///////////////////////////////////////////////////////////////////////////////
		//
		//public Macro( string name, MacroType macroType, CreateHandlerInstance createHandler, object netObj, string text, NmpStringList argNames )
		//	: this( name )
		//{
		//	MacroType = macroType;
		//
		//	//MacroHandler
		//	CreateHandler = createHandler;
		//
		//	MacroObject = netObj;
		//	MacroText = string.IsNullOrEmpty(text) ? string.Empty : text;
		//	ArgumentNames = null == argNames ? new NmpStringList() : argNames;
		//}
		//

		/////////////////////////////////////////////////////////////////////////////

		public Macro(	string name, 
									MacroType macroType, 
									IMacroHandler mh, 
									object netObj, 
									string text, 
									IList<string> argNames,
									IMacroProcessor mp
								)
			: this( name )
		{
			// ******
			MacroType = macroType;
			MacroHandler = mh;

			// ******
			if( null != MacroHandler ) {
				IsBlockMacro = MacroHandler.HandlesBlocks;
			}

			// ******
			MacroObject = netObj;
			MacroText = string.IsNullOrEmpty(text) ? string.Empty : text;
			
			// ******
			ArgumentNames = null == argNames ? new NmpStringList() : argNames;

			for( int i = 0; i < ArgumentNames.Count; i++ ) {
				ArgumentNames[ i ] = ArgumentNames[ i ].Trim();
			}

			// ******
			MacroProcessor = mp;

			// ******
			//
			// only do this if MacroProcessor is initialized - if it's not
			// we may be generating a macro for tooling, not when an actual
			// instance of NMP is running
			//
			if( null != MacroProcessor ) {
				//if( ThreadContext.PushbackResult ) {
				if( mp.GrandCentral.PushbackResult ) {
					Flags = MacroFlags.Pushback;
				}

				if( MacroType.Text == macroType ) {

					if( mp.GrandCentral.ExpandAndScan ) {
						Flags |= MacroFlags.FwdExpand;
					}
				}
			}

			// ******
			PrivateData = null;
		}
Ejemplo n.º 12
0
 protected static string SerializeMacro(string macroName, string note, MacroType type, string macroOptions)
 {
     // Appends all macro information with a delimiter in between values
     return($"{macroName}{SerializeDelimiter}{note}{SerializeDelimiter}" +
            $"{type}{SerializeDelimiter}{macroOptions}");
 }
Ejemplo n.º 13
0
 private void Keyboard_Click(object sender,EventArgs e) {
     Button button=(Button)sender;
     switch(formtype) {
         case MacroFormType.Editor:
             // Select function type for new macros, the most commonly used type
             savedMacroType = Statics.Macros[GetCode(button)].Type;
             if(savedMacroType == MacroType.Unused)
                 Statics.Macros[GetCode(button)].Type = MacroType.Graphics;
             StartMacro(GetCode(button));
             return;
         case MacroFormType.Press:case MacroFormType.Trigger:
             Active[GetCode(button)]=!Active[GetCode(button)];
             if(Active[GetCode(button)])
                 button.BackColor=Color.LightBlue;
             else
                 button.BackColor=SystemColors.Control;
             return;
         case MacroFormType.Console:
             if(ConsoleCommand.Count>=255) {
             	MessageBox.Show(strings["CommandLengthExceeded"],Statics.strings["Error"]);
                 break;
             }
             if(rbDown.Checked) {
                 ConsoleCommand.Add(new KeyPress((byte)GetCode(button),true));
             } else if(rbUp.Checked) {
                 ConsoleCommand.Add(new KeyPress((byte)GetCode(button),false));
             } else {
                 ConsoleCommand.Add(new KeyPress((byte)GetCode(button),true));
                 ConsoleCommand.Add(new KeyPress((byte)GetCode(button),false));
             }
             tbCLen.Text=ConsoleCommand.Count.ToString();
             return;
         default:
             MessageBox.Show(strings["KeyboardError"],Statics.strings["Error"]);
             return;
     }
 }
Ejemplo n.º 14
0
 public MacroDefinition(String n, KeySequenceEntry[] keys, MacroType type)
 {
     name = n;
     sequence = keys;
     macroType = type;
 }
Ejemplo n.º 15
0
 public MacroDefinition(string name, MacroType type, int index)
 {
     Name = name;
     Type = type;
     Index = index;
 }
Ejemplo n.º 16
0
 public ExArg(MacroType MacroType, int No)
 {
     MType    = MacroType;
     ModuleNo = No;
 }
Ejemplo n.º 17
0
        public MacroDeclarationStatementNode Macro(string identifier, IEnumerable<MacroFormalParameterNode> formalParameters, BlockStatementNode body, MacroType type)
        {
            if (string.IsNullOrWhiteSpace(identifier))
                ThrowHelper.ThrowException("The identifier is blank!");

            if (formalParameters == null)
                ThrowHelper.ThrowArgumentNullException(() => formalParameters);

            if (body == null)
                ThrowHelper.ThrowArgumentNullException(() => body);

            return new MacroDeclarationStatementNode(identifier, formalParameters, body, type);
        }
Ejemplo n.º 18
0
 public MacroDefinition(string name, MacroType type, int index)
 {
     Name  = name;
     Type  = type;
     Index = index;
 }
Ejemplo n.º 19
0
        public static void GetBoundByCode(MacroType code, ref int count, ref int offset)
        {
            switch (code)
            {
            case MacroType.Walk:
                offset = (int)MacroSubType.NW;
                count  = MacroSubType.Configuration - MacroSubType.NW;

                break;

            case MacroType.Open:
            case MacroType.Close:
            case MacroType.Minimize:
            case MacroType.Maximize:
                offset = (int)MacroSubType.Configuration;
                count  = MacroSubType.Anatomy - MacroSubType.Configuration;

                break;

            case MacroType.UseSkill:
                offset = (int)MacroSubType.Anatomy;
                count  = MacroSubType.LeftHand - MacroSubType.Anatomy;

                break;

            case MacroType.ArmDisarm:
                offset = (int)MacroSubType.LeftHand;
                count  = MacroSubType.Honor - MacroSubType.LeftHand;

                break;

            case MacroType.InvokeVirtue:
                offset = (int)MacroSubType.Honor;
                count  = MacroSubType.Clumsy - MacroSubType.Honor;

                break;

            case MacroType.CastSpell:
                offset = (int)MacroSubType.Clumsy;
                count  = MacroSubType.Hostile - MacroSubType.Clumsy;

                break;

            case MacroType.SelectNext:
            case MacroType.SelectPrevious:
            case MacroType.SelectNearest:
                offset = (int)MacroSubType.Hostile;
                count  = MacroSubType.MscTotalCount - MacroSubType.Hostile;

                break;

            case MacroType.MovePlayer:
                offset = (int)MacroSubType.Top;
                count  = 4;

                break;

            case MacroType.UsePotion:
                offset = (int)MacroSubType.ConfusionBlastPotion;
                count  = MacroSubType.ExplosionPotion - MacroSubType.ConfusionBlastPotion;
                break;
            }
        }
 public MacroDefinition(String n, KeySequenceEntry[] keys, MacroType type)
 {
     name      = n;
     sequence  = keys;
     macroType = type;
 }
Ejemplo n.º 21
0
        public bool ScmRunExcelMacro(MacroType m, int FileNo, string outdir)
        {
            int OperType = (int)m;

            try
            {
                if (RunExcelMacro(OperType, outdir, FileNo, FileNo) != 0)
                {
                    log.WriteLog("����excelʧ��");
                    return false;
                }
            }
            catch (Exception ex)
            {
                MAConf.instance.WriteLog("����excel�쳣��" + ex.Message);
                return false;
            }

            return true;
        }
Ejemplo n.º 22
0
 public Macro(MacroType type, int value)
     : this(type)
 {
     m_ValueInteger = value;
     m_ValueType = ValueTypes.Integer;
 }
Ejemplo n.º 23
0
 public ExArg(MacroType MacroType, int No)
 {
     MType = MacroType;
     ModuleNo = No;
 }
Ejemplo n.º 24
0
        private void onClickOpenList(AControl control, int x, int y, MouseButton button)
        {
            //for macro options
            int id = control.GumpLocalID;
            int controlValueIndex = -1;

            for (int i = 0; i < Parent.Children.Count; i++)
            {
                if (Parent.Children[i].GumpLocalID == (id + 1000))
                {
                    controlValueIndex = i;
                    break;
                }
            }

            int indexOver = getOpenListIndexFromPoint(x, y);

            if (indexOver != -1)
            {
                Index = indexOver + (m_openScrollBar == null ? 0 : m_openScrollBar.Value);
            }
            closeOpenList();

            //for macro options
            if (controlValueIndex != -1)
            {
                if (indexOver == -1)
                {
                    return;
                }

                MacroType mType = Macros.Types[Index].Type;

                // background image:
                if (!(Parent.Children[controlValueIndex] as MacroDropDownList).IsFirstvisible)
                {
                    (Parent.Children[controlValueIndex] as MacroDropDownList).CreateVisual();
                }

                // clear and show dropdown/text entry:
                (Parent.Children[controlValueIndex] as MacroDropDownList).Items.Clear();
                (Parent.Children[controlValueIndex] as MacroDropDownList).ScrollButton.IsVisible = true; //easy way for visible dropdown list
                (Parent.Children[controlValueIndex] as MacroDropDownList).IsVisible = true;              //easy way for visible dropdown list
                (Parent.Children[controlValueIndex + 1] as TextEntry).Text          = string.Empty;


                switch (mType)
                {
                case MacroType.UseSkill:
                    foreach (MacroDefinition def in Macros.Skills)
                    {
                        (Parent.Children[controlValueIndex] as MacroDropDownList).Items.Add(def.Name);
                    }
                    (Parent.Children[controlValueIndex + 1] as TextEntry).IsEditable = false;    //textentry disabled because i need dropdownlist
                    break;

                case MacroType.CastSpell:
                    foreach (MacroDefinition def in Macros.Spells)
                    {
                        (Parent.Children[controlValueIndex] as MacroDropDownList).Items.Add(def.Name);
                    }
                    (Parent.Children[controlValueIndex + 1] as TextEntry).IsEditable = false;    //textentry disabled because i need dropdownlist
                    break;

                case MacroType.OpenGump:
                case MacroType.CloseGump:
                    foreach (MacroDefinition def in Macros.Gumps)
                    {
                        (Parent.Children[controlValueIndex] as MacroDropDownList).Items.Add(def.Name);
                    }
                    (Parent.Children[controlValueIndex + 1] as TextEntry).IsEditable = false;    //textentry disabled because i need dropdownlist
                    break;

                case MacroType.Move:
                    foreach (MacroDefinition def in Macros.Moves)
                    {
                        (Parent.Children[controlValueIndex] as MacroDropDownList).Items.Add(def.Name);
                    }
                    (Parent.Children[controlValueIndex + 1] as TextEntry).IsEditable = false;    //textentry disabled because i need dropdownlist
                    break;

                case MacroType.ArmDisarm:
                    foreach (MacroDefinition def in Macros.ArmDisarms)
                    {
                        (Parent.Children[controlValueIndex] as MacroDropDownList).Items.Add(def.Name);
                    }
                    (Parent.Children[controlValueIndex + 1] as TextEntry).IsEditable = false;    //textentry disabled because i need dropdownlist
                    break;

                case MacroType.Say:
                case MacroType.Emote:
                case MacroType.Whisper:
                case MacroType.Yell:
                    //(Parent.Children[controlValueIndex] as MacroDropDownList).m_scrollButton.IsVisible = false; //as you wish
                    (Parent.Children[controlValueIndex + 1] as TextEntry).IsEditable = true;    //textentry activated
                    break;



                case MacroType.None:
                    (Parent.Children[controlValueIndex] as MacroDropDownList).ScrollButton.IsVisible = false; //i dont need any control :)
                    (Parent.Children[controlValueIndex + 1] as TextEntry).IsEditable    = false;              //i dont need any control :)
                    (Parent.Children[controlValueIndex] as MacroDropDownList).IsVisible = false;              //i dont need any control :)
                    break;

                default:
                    //unnecessary
                    break;
                }
            }
        }
Ejemplo n.º 25
0
        private void InitializeList()
        {
            Tlp_Arguments.SuspendLayout();
            Tlp_Arguments.RowCount = 0;
            Tlp_Arguments.RowStyles.Clear();

            string[]        SelecterNames = new string[2];
            Label[]         Labels        = new Label[] { Lbl_Selecter1, Lbl_Selecter2 };
            List <string[]> SelecterItems = new List <string[]>();

            ComboBox[] Selecters = new ComboBox[] { Cb_Selecter1, Cb_Selecter2 };

            if (MacroName == "UE_LOG")
            {
                SelecterItems.Add(SettingsFunctionLibrary.GetLogCategory());
                SelecterItems.Add(XmlFunctionLibrary.GetLogVerbosity());
                SelecterNames[0]      = "CategoryName";
                SelecterNames[1]      = "Verbosity";
                Lbl_Input.Text        = "Format";
                Tb_Input.TextChanged += new EventHandler(OnTextChanged);

                Cb_Selecter1.SelectedText = "LogTemp";
                Cb_Selecter2.SelectedText = "Log";
            }
            else
            {
                var Verbosities = XmlFunctionLibrary.GetLogVerbosity();
                SelecterItems.Add(Verbosities);
                SelecterItems.Add(Verbosities);
                SelecterNames[0]          = "DefaultVerbosity";
                SelecterNames[1]          = "CompileTimeVerbosity";
                Cb_Selecter1.SelectedText = "Log";
                Cb_Selecter2.SelectedText = "All";
                Lbl_Input.Text            = "CategoryName";
                Lbl_Arguments.Text        = "MacroType";

                string[]      MacroTypes    = XmlFunctionLibrary.GetMacroTypes(false, false, true);
                List <string> LogMacroTypes = new List <string>();
                foreach (var MacroType in MacroTypes)
                {
                    if (MacroType.Contains("LOG_CATEGORY"))
                    {
                        LogMacroTypes.Add(MacroType);
                    }
                }

                ComboBox Type = new ComboBox();
                Type.Items.AddRange(LogMacroTypes.ToArray());
                Type.Width = 300;
                Type.SelectedIndexChanged += new EventHandler(OnMacroTypeChanged);

                if (!string.IsNullOrEmpty(EditTarget))
                {
                    Type.Text = MacroName;
                }
                else
                {
                    Type.SelectedIndex = 0;
                    MacroName          = Type.Text;
                }

                Tlp_Arguments.Controls.Add(Type);
            }

            for (int Index = 0; Index < Selecters.Length; Index++)
            {
                if (!string.IsNullOrEmpty(SelecterNames[Index]))
                {
                    Labels[Index].Text = SelecterNames[Index];
                    Selecters[Index].Items.AddRange(SelecterItems[Index]);
                }
                else
                {
                    Labels[Index].Visible    = false;
                    Selecters[Index].Visible = false;
                }
            }

            Tlp_Arguments.Dock         = DockStyle.Top;
            Tlp_Arguments.AutoSize     = true;
            Tlp_Arguments.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            Tlp_Arguments.Padding      = new Padding(0, 0, SystemInformation.VerticalScrollBarWidth, 0);

            Tlp_Arguments.ResumeLayout();
        }
Ejemplo n.º 26
0
        private List <LogInfo> LoadMacroDict(MacroType type, ScriptSection section, Dictionary <string, string> newDict, bool append)
        {
            List <LogInfo> logs = new List <LogInfo>();

            // Select proper macroDict
            Dictionary <string, CodeCommand> macroDict;

            switch (type)
            {
            case MacroType.Global:
                macroDict = GlobalDict;
                break;

            case MacroType.Local:
                macroDict = LocalDict;
                break;

            default:
                throw new CriticalErrorException($"Invalid MacroType {type}");
            }

            // Do not clear macroDict in the append mode
            if (!append)
            {
                macroDict.Clear();
            }

            // If the newDict is empty, skip the rest
            if (newDict.Keys.Count == 0)
            {
                return(logs);
            }

            // Parse and register commands to the macroDict
            int        count  = 0;
            CodeParser parser = new CodeParser(section, Global.Setting, section.Project.Compat);

            logs.Add(new LogInfo(LogState.Info, $"Import {type} Macro from [{section.Name}]", 0));
            foreach (var kv in newDict)
            {
                try
                {
                    // Macro Name Validation
                    if (!Regex.Match(kv.Key, MacroNameRegex, RegexOptions.Compiled | RegexOptions.CultureInvariant).Success)
                    {
                        logs.Add(new LogInfo(LogState.Error, $"Invalid macro name [{kv.Key}]"));
                        continue;
                    }

                    CodeCommand macroCmd = parser.ParseStatement(kv.Value);
                    macroDict[kv.Key] = macroCmd;
                    logs.Add(new LogInfo(LogState.Success, $"{type} macro [{kv.Key}] set to [{kv.Value}]", 1));
                    count += 1;
                }
                catch (Exception e)
                {
                    logs.Add(new LogInfo(LogState.Error, e));
                }
            }
            logs.Add(new LogInfo(LogState.Info, $"Imported {count} {type} Macro", 0));
            logs.Add(new LogInfo(LogState.None, Logger.LogSeparator, 0));

            return(logs);
        }
Ejemplo n.º 27
0
 public MacroData(string _csvString)
 {
     string[] fields = _csvString.Split(char.Parse(fieldSeperator));
     this.id = int.Parse(fields[0]);
     this.key = fields[1];
     this.description = fields[2];
     this.type = (MacroType)Enum.Parse(typeof(MacroType), fields[3]);
     this.code = fields[4];
 }
Ejemplo n.º 28
0
 public Macro(MacroType type, int value)
     : this(type)
 {
     m_ValueInteger = value;
     m_ValueType    = ValueTypes.Integer;
 }
Ejemplo n.º 29
0
 public MacroData(int _id, string _key, string _description,MacroType _type,string _code)
 {
     this.id = _id;
     this.key = _key;
     this.description = _description;
     this.type = _type;
     this.code = _code;
 }
Ejemplo n.º 30
0
 public MacroDefinition(string name, MacroType type)
 {
     Name = name;
     Type = type;
     Index = 0;
 }
Ejemplo n.º 31
0
 public MacroObjectString(MacroType code, MacroSubType sub, string str = "") : base(code, sub)
 {
     Text = str;
 }
Ejemplo n.º 32
0
            private void AddMacroForAttachment(MacroType macro, string fileName)
            {
                PerformActionWithRetry(() =>
                {
                    _driver.FindElementById("editPageLink").Click();
                });

                PerformActionWithRetry(() =>
                {
                    _driver.SwitchTo().Frame("wysiwygTextarea_ifr");
                });

                var textarea = _driver.FindElementById("tinymce");
                textarea.Click();
                textarea.SendKeys(Keys.Control + Keys.End);
                _driver.SwitchTo().ParentFrame();

                _driver.FindElementById("rte-button-insert").Click();

                _driver.FindElementById("rte-insert-macro").Click();

                _driver.FindElementById("macro-browser-search").SendKeys(macro.ToString());
                if (macro == MacroType.Pdf)
                {
                    _driver.FindElementById("macro-viewpdf").Click();
                }
                else if(macro == MacroType.Excel)
                {
                    _driver.FindElementById("macro-viewxls").Click();
                }
                else
                {
                    _driver.FindElementById("macro-viewppt").Click();
                }
                PerformActionWithRetry(() =>
                {
                    if(_driver.FindElementById("macro-param-name").Text == "No appropriate attachments")
                    {
                        throw new Exception("Throw an exception to try again");
                    }
                });
                Thread.Sleep(5000);
                _driver.FindElementByCssSelector(".button-panel-button.ok").Click();

                _driver.SwitchTo().Frame("wysiwygTextarea_ifr");

                PerformActionWithRetry(() =>
                {
                    _driver.FindElementByClassName("editor-inline-macro");
                });
                _driver.SwitchTo().ParentFrame();
                PublishPage();
            }
Ejemplo n.º 33
0
        static StiReport MakeReport(DBGrid grid, ReportCreateParam param)
        {
            JMXSchema schema   = grid.Schema;
            DataTable dt       = grid.BaseTable;
            double    top      = 0;
            float     fontSize = param.FontSize;

            string    tableName = TableAliasDefault;;
            StiReport report    = new StiReport
            {
                ScriptLanguage = StiReportLanguageType.CSharp,
                ReportName     = schema.Name
            };

            //report.RegData(tableName, dt);
            report.RegData(tableName, grid.GetBindingSource());
            report.Dictionary.Synchronize();
            report.Dictionary.DataSources[0].Name  = tableName;
            report.Dictionary.DataSources[0].Alias = tableName;

            StiPage page = report.Pages.Items[0];

            page.Margins.Left  = 1;
            page.Margins.Right = 1;
            page.AlignToGrid();


            //ReportTitle
            bool titleOnPage             = param.TitleOnPage;
            StiReportTitleBand titleBand = new StiReportTitleBand
            {
                Height  = 0.5f,
                CanGrow = true,
                Name    = "TitleBand"
            };

            page.Components.Add(titleBand);

            //Period
            bool period = param.Period;

            if (period)
            {
                StiText periodText = new StiText(new RectangleD(0, 0, page.Width, 0.5f));
                periodText.Text.Value   = rth.Za();
                periodText.HorAlignment = StiTextHorAlignment.Right;
                periodText.Name         = "periodText";
                periodText.Border.Side  = StiBorderSides.None;
                //periodText.DockStyle = StiDockStyle.Right;
                periodText.Font = new Font(grid.Font.FontFamily.Name, fontSize, FontStyle.Bold);
                titleBand.Components.Add(periodText);
                top += periodText.Height;
            }

            //Title
            StiText titleText = new StiText(new RectangleD(0, period ? 0.5f : 0, page.Width, 1f));

            titleText.Text.Value   = grid.Schema.Name;
            titleText.HorAlignment = StiTextHorAlignment.Center;
            titleText.Name         = "titleText";
            titleText.Border.Side  = StiBorderSides.None;
            titleText.Font         = new Font(grid.Font.FontFamily.Name, 12f, FontStyle.Bold);
            titleText.WordWrap     = true;
            titleText.CanGrow      = true;
            titleBand.Components.Add(titleText);
            top += titleText.Height;

            //Create HeaderBand
            StiBand       headBand;
            StiHeaderBand headerBand = new StiHeaderBand
            {
                Height = 0.5f,
                Name   = "HeaderBand"
            };

            if (titleOnPage)
            {
                page.Components.Add(headerBand);
                headBand = headerBand;
            }
            else
            {
                headBand = titleBand;
            }


            //Create Databand
            StiDataBand dataBand = new StiDataBand
            {
                DataSourceName = tableName,
                Height         = 0.5f,
                Name           = "DataBand"
            };

            page.Components.Add(dataBand);

            //Create FooterBand
            StiFooterBand footerBand = new StiFooterBand
            {
                Height   = 0.5f,
                CanGrow  = true,
                Name     = "FooterBand",
                CanBreak = false
            };

            page.Components.Add(footerBand);

            Double         pos        = 0;
            int            nameIndex  = 1;
            int            i          = 0;
            bool           multiLine  = param.MultiLine;
            int            border     = param.Border;
            bool           totals     = false;
            List <StiText> footerList = new List <StiText>();

            foreach (DataGridViewColumn column in grid.Columns)
            {
                bool visible = (column.Visible && column.Width > 1);

                if (visible)
                {
                    Double columnWidth = StiAlignValue.AlignToMinGrid(column.Width / 33, 0.03, true);

                    //Create text on header
                    StiText headerText = new StiText(new RectangleD(pos, titleOnPage ?  0: top, columnWidth, 0.5f));
                    headerText.Text.Value   = column.HeaderText;
                    headerText.HorAlignment = StiTextHorAlignment.Center;
                    headerText.Name         = "HeaderText" + nameIndex.ToString();
                    if (border == 0)
                    {
                        headerText.Border.Side = StiBorderSides.Top | StiBorderSides.Bottom;
                    }
                    else
                    {
                        headerText.Border.Side = StiBorderSides.All;
                    }
                    headerText.CanGrow      = true;
                    headerText.GrowToHeight = true;
                    headerText.WordWrap     = multiLine;
                    headerText.Font         = new Font(grid.ColumnHeadersDefaultCellStyle.Font.FontFamily.Name, fontSize);
                    headBand.Components.Add(headerText);

                    MacroType tt     = DBGridBase.GetMacroType(schema.Attributes[i].DataType);
                    string    format = column.DefaultCellStyle.Format;
                    if (string.IsNullOrEmpty(format) && tt == MacroType.date)
                    {
                        format = vbo.DateFormat;
                    }

                    StiTextHorAlignment horAlign;
                    switch (column.DefaultCellStyle.Alignment)
                    {
                    case DataGridViewContentAlignment.MiddleRight:
                        horAlign = StiTextHorAlignment.Right;
                        break;

                    case DataGridViewContentAlignment.MiddleLeft:
                        horAlign = StiTextHorAlignment.Left;
                        break;

                    default:
                        horAlign = StiTextHorAlignment.Center;
                        break;
                    }

                    //Create text on Data Band
                    StiText dataText = new StiText(new RectangleD(pos, 0, columnWidth, 0.5f));
                    string  field    = tableName + "." + Stimulsoft.Report.CodeDom.StiCodeDomSerializator.ReplaceSymbols(column.DataPropertyName);
                    if (AccntFormat.ValidFormat(format))
                    {
                        dataText.Text.Value = "{Substring(" + field + ",0,5)+" + "-".Qt() +
                                              "+Substring(" + field + ",5,3)+" + "-".Qt() +
                                              "+Substring(" + field + ",8,1)+" + "-".Qt() +
                                              "+Substring(" + field + ",9,4)+" + "-".Qt() +
                                              "+Substring(" + field + ",13,7)" + "}";
                    }
                    else
                    {
                        dataText.Text.Value = "{" + field + "}";
                    }
                    dataText.Name         = "DataText" + nameIndex.ToString();
                    dataText.CanGrow      = true;
                    dataText.GrowToHeight = true;
                    dataText.WordWrap     = multiLine;
                    dataText.HorAlignment = horAlign;
                    //dataText.VertAlignment = StiVertAlignment.Center;
                    if (border == 0)
                    {
                        dataText.Border.Side = StiBorderSides.None;
                    }
                    else if (border == 1)
                    {
                        dataText.Border.Side = StiBorderSides.Bottom;
                    }
                    else
                    {
                        dataText.Border.Side = StiBorderSides.All;
                    }
                    if (grid.RowsDefaultCellStyle.Font == null)
                    {
                        dataText.Font = new Font(grid.Font.FontFamily.Name, fontSize);
                    }
                    else
                    {
                        dataText.Font = new Font(grid.RowsDefaultCellStyle.Font.FontFamily.Name, fontSize);
                    }

                    dataText.TextFormat = ParseFormat(format);
                    if (tt == MacroType.num)
                    {
                        dataText.ExcelValue.Value = "{" + field + "}";
                    }
                    dataBand.Components.Add(dataText);

                    //Create text on footer
                    string summary = schema.Attributes[i].Agregate.ToLower();
                    if (summary == "sum")
                    {
                        summary = "Sum(" + field + ")";
                    }
                    else if (summary == "rcnt")
                    {
                        summary = "Count()";
                    }
                    else if (summary == "ave")
                    {
                        summary = "Avg(" + field + ")";
                    }
                    else if (summary == "min")
                    {
                        summary = "Min(" + field + ")";
                    }
                    else if (summary == "max")
                    {
                        summary = "Max(" + field + ")";
                    }
                    else
                    {
                        summary = string.Empty;
                    }
                    bool summaryEmpty = string.IsNullOrEmpty(summary);

                    int footerIndex = i;
                    //if (!string.IsNullOrEmpty(grid.FooterText(footerIndex)))
                    if (!summaryEmpty)
                    {
                        totals = true;
                    }

                    StiText footerText = new StiText(new RectangleD(pos, 0, columnWidth, 0.5f));
                    if (footerIndex == 0 && summaryEmpty)
                    {
                        footerText.Text.Value = grid.FooterCaption;
                    }
                    else if (footerIndex == 0)
                    {
                        footerText.Text.Value = "{" + (grid.FooterCaption + vbo.vbTab).Qt() + "+" + summary + "}";
                    }
                    else if (!summaryEmpty)
                    {
                        footerText.Text.Value       = "{" + summary + "}";
                        footerText.ExcelValue.Value = "{" + summary + "}";
                    }
                    else
                    {
                        footerText.Text.Value = grid.FooterText(footerIndex);
                    }

                    footerText.Name = "FooterText" + nameIndex.ToString();
                    if (border == 0)
                    {
                        footerText.Border.Side = StiBorderSides.Top | StiBorderSides.Bottom;
                    }
                    else
                    {
                        footerText.Border.Side = StiBorderSides.All;
                    }

                    if (!summaryEmpty && summary != "Count()")
                    {
                        footerText.TextFormat = (StiFormatService)dataText.TextFormat.Clone();
                    }

                    footerText.HorAlignment = horAlign;
                    //footerText.VertAlignment = StiVertAlignment.Center;
                    footerText.Font = new Font(grid.Font.FontFamily.Name, fontSize);
                    footerList.Add(footerText);

                    pos += columnWidth;

                    nameIndex++;
                }
                i++;
            }
            if (totals)
            {
                footerBand.Components.AddRange(footerList.ToArray());
            }

            if ((pos - page.Width) < 1.6f)
            {
                page.Margins.Right = 0;
                page.Margins.Left /= 2;
            }
            else if (pos > page.Width)
            {
                page.Orientation = StiPageOrientation.Landscape;
                titleText.Width  = page.Width;
                if (period)
                {
                    titleBand.Components[titleBand.Components.IndexOf("periodText")].Width = page.Width;
                }
                if (pos > page.Width)
                {
                    page.Margins.Right = 0;
                    page.Margins.Left /= 2;
                }
                if (pos > page.Width)
                {
                    page.Width = pos;
                }
            }

            if (param.Sign)
            {
                footerList.Clear();
                //StiText footerText = new StiText(new RectangleD(0, 0.5f, page.Width, 0.5f));
                //footerList.Add(footerText);
                //footerText = new StiText(new RectangleD(0, 1f, page.Width / 2, 0.5f));
                //footerText.Text.Value = "{CSetup.Setup.Properties(" + vbo.Qt("President") + ", " + vbo.Qt("") + ")}";
                //footerText.HorAlignment = StiTextHorAlignment.Right;
                //footerText.Font = new Font(grid.ColumnHeadersDefaultCellStyle.Font.FontFamily.Name, 10);
                //footerList.Add(footerText);
                //footerText = new StiText(new RectangleD(page.Width / 2, 1f, page.Width / 4, 0.5f));
                //footerList.Add(footerText);
                //footerText = new StiText(new RectangleD(page.Width * 3 / 4, 1f, page.Width / 4, 0.5f));
                //footerText.Text.Value = "{CSetup.Setup.Properties(" + vbo.Qt("PresidentName") + ", " + vbo.Qt("") + ")}";
                //footerText.HorAlignment = StiTextHorAlignment.Left;
                //footerText.Font = new Font(grid.ColumnHeadersDefaultCellStyle.Font.FontFamily.Name, 10);
                //footerList.Add(footerText);
                //footerText = new StiText(new RectangleD(0, 1.5f, page.Width, 0.5f));
                //footerList.Add(footerText);
                //footerText = new StiText(new RectangleD(0, 2f, page.Width / 2, 0.5f));
                //footerText.Text.Value = "{CSetup.Setup.Properties(" + vbo.Qt("ChifAccount") + ", " + vbo.Qt("") + ")}";
                //footerText.HorAlignment = StiTextHorAlignment.Right;
                //footerText.Font = new Font(grid.ColumnHeadersDefaultCellStyle.Font.FontFamily.Name, 10);
                //footerList.Add(footerText);
                //footerText = new StiText(new RectangleD(page.Width / 2, 2f, page.Width / 4, 0.5f));
                //footerList.Add(footerText);
                //footerText = new StiText(new RectangleD(page.Width * 3 / 4, 2f, page.Width / 4, 0.5f));
                //footerText.Text.Value = "{CSetup.Setup.Properties(" + vbo.Qt("ChifAccountName") + ", " + vbo.Qt("") + ")}";
                //footerText.HorAlignment = StiTextHorAlignment.Left;
                //footerText.Font = new Font(grid.ColumnHeadersDefaultCellStyle.Font.FontFamily.Name, 10);
                //footerList.Add(footerText);
                //footerBand.Height = 2.5f;
                //footerBand.Components.AddRange(footerList.ToArray());
            }
            return(report);
        }