Beispiel #1
0
        public override bool DoFillWork(object state)
        {
            string fileName = state as string;

            ApiSetter.SetText(this.fileName, fileName);
            ApiSetter.ClickButton(okButton, base.HWnd, null, null);
            return(true);
        }
Beispiel #2
0
        public override bool DoFillWork(object fileName)
        {
            FillValue3C value = fileName as FillValue3C;

            if (value == null || value.Value == null || _editHandle == IntPtr.Zero || _okButtonHandle == IntPtr.Zero)
            {
                return(false);
            }
            ApiSetter.SetText(_editHandle, value.Value);
            return(ApiSetter.ClickButton(_okButtonHandle, base.HWnd, null, null));
        }
Beispiel #3
0
        public static bool CheckCheckBox(IntPtr _parent, Main_3C owner, string note, List <string> values)
        {
            StringBuilder text       = new StringBuilder(256);
            IntPtr        saveButton = IntPtr.Zero;
            bool          result     = NativeApi.EnumChildWindows(_parent, (handle, lParam) =>
            {
                text.Clear();
                NativeApi.GetClassName(handle, text, 255);
                if (text.ToString().StartsWith(CCCFillManager.EditClassName))
                {
                    ApiSetter.SetText(handle, note);
                    return(true);
                }
                else if (text.ToString().StartsWith(CCCFillManager.ButtonClassName))
                {
                    text.Clear();
                    NativeApi.GetWindowText(handle, text, 255);
                    int index = values.IndexOf(text.ToString());
                    if (index != -1)
                    {
                        IntPtr hwndParent = new IntPtr((int)NativeApi.GetWindowLong(_parent, -8));
                        NativeApi.SendMessage(handle, WMMSG.WM_SETFOCUS, 0, 0);
                        ApiSetter.ClickButton(handle, hwndParent, null, null);
                        values.RemoveAt(index);
                    }
                    else if (text.ToString() == "保存")
                    {
                        saveButton = handle;
                    }
                }
                return(true);
            }, IntPtr.Zero);

            if (saveButton != IntPtr.Zero)
            {
                owner.ClickSaveButton(saveButton);
            }
            return(true);
        }
Beispiel #4
0
        public override bool DoFillWork(object state)
        {
            FillValue3C fillValue = state as FillValue3C;

            if (fillValue == null || fillValue.Value == null || fillValue.Separators == null || fillValue.Separators.Length < 1)
            {
                return(false);
            }
            string[] values = fillValue.Value.Split(fillValue.Separators[0]);
            if (values == null || values.Length == 0)
            {
                return(true);
            }
            List <IntPtr> list = ControlSorter.SortContainer(_container);

            if (list == null)
            {
                return(false);
            }
            StringBuilder className = new StringBuilder(256);

            for (int i = 0; i < values.Length && i < list.Count; i++)
            {
                className.Clear();
                NativeApi.GetClassName(list[i], className, 255);
                string classNameStr = className.ToString();
                if (classNameStr.StartsWith(CCCFillManager.EditClassName))
                {
                    ApiSetter.SetText(list[i], values[i]);
                }
                else if (classNameStr.StartsWith(CCCFillManager.ComboBoxClassName))
                {
                    ApiSetter.SetComboBoxSelected(base.HWnd, list[i], values[i]);
                }
            }
            ApiSetter.ClickButton(_finishButton, base.HWnd, null, null);
            return(true);
        }
Beispiel #5
0
        private bool FillValue(string className, ref int index, IntPtr handle, FillValue3C value)
        {
            _asyncHandle.Wait();
            string parameterValue = null;

            if (value == null)
            {
                return(false);
            }
            FillParameter3C parameter = _fillParameters[value.Key] as FillParameter3C;

            if (index == -1)
            {
                parameterValue = value.Value;
            }
            else
            {
                string[] values = value.Value == null ? null : value.Value.Split(parameter.Separators[0]);
                parameterValue = (values == null || values.Length <= index) ?
                                 (string.IsNullOrEmpty(value.Note) ? "" : value.Note) : values[index];
            }
            StringBuilder text = null;

            switch (className)
            {
            case CCCFillManager.EditClassName:
                if (ApiSetter.IsEditable(handle, _handle) == false)
                {
                    index--;
                    break;
                }
                ApiSetter.SetText(handle, parameterValue);
                break;

            case CCCFillManager.ComboBoxClassName:
                if (ApiSetter.IsEditable(handle, _handle) == false)
                {
                    index--;
                    break;
                }
                ApiSetter.SetComboBoxSelected(_handle, handle, parameterValue, parameter.IsComboBoxPreciseMatch);
                break;

            case CCCFillManager.ButtonClassName:
                value.Separators = parameter.Separators;
                text             = new StringBuilder(256);
                NativeApi.GetWindowText(handle, text, 255);
                if (text.ToString() == "附件" && value != null && string.IsNullOrEmpty(value.AttachFile) == false)
                {
                    return(ApiSetter.ClickButton(handle, _handle, ListenAttachWindow, value));
                }
                else if (text.ToString() == "编辑")
                {
                    if (string.IsNullOrEmpty(value.OriginString))
                    {
                        return(false);
                    }
                    if (string.IsNullOrEmpty(parameter.EditType))
                    {
                        parameter.EditType = "add";
                    }
                    switch (parameter.EditType.ToLower())
                    {
                    case "add":
                        return(ApiSetter.ClickButton(handle, _handle, ListenAddWindow, value));

                    case "radio":
                        return(ApiSetter.ClickButton(handle, _handle, ListenRadioWindow, value));

                    case "select":
                        return(ApiSetter.ClickButton(handle, _handle, ListenListBoxWindow, value));

                    case "multiselect":
                        value.DoubleClick = true;
                        return(ApiSetter.ClickButton(handle, _handle, ListenListBoxWindow, value));

                    case "text":
                        return(ApiSetter.ClickButton(handle, _handle, ListenTextWindow, value));

                    case "column":
                        return(ApiSetter.ClickButton(handle, _handle, ListenColumnWindow, value));

                    case "multinote":
                        return(ApiSetter.ClickButton(handle, _handle, ListenMultiValueAndNoteWindow, value));

                    default:
                        return(false);
                    }
                }
                else
                {
                }
                break;
            }
            return(true);
        }
Beispiel #6
0
        public override bool DoFillWork(object state)
        {
            FillValue3C fillValue = state as FillValue3C;

            if (fillValue == null || fillValue.Value == null || fillValue.Separators == null || fillValue.Separators.Length < 2 || inputCount == 0)
            {
                return(false);
            }

            foreach (char c in fillValue.Separators)
            {
                fillValue.Value = fillValue.Value.Replace(c, ',');
            }
            List <string[]> values = new List <string[]>();

            string[] array = fillValue.Value.Split(new char[] { ',' }, StringSplitOptions.None);
            string[] group = null;
            for (int i = 0; i < array.Length; i++)
            {
                int mod = (i % inputCount);
                if (mod == 0)
                {
                    group = new string[inputCount];
                    values.Add(group);
                }
                group[mod] = array[i];
            }
            //List<string[]> values = new List<string[]>();
            //foreach (var item in fillValue.Value.Split(fillValue.Separators[1]))
            //{
            //    values.Add(item.Split(fillValue.Separators[0]));
            //}
            bool          result    = true;
            StringBuilder className = new StringBuilder(256);

            for (int index = 0; index < values.Count && current != IntPtr.Zero; index++)
            {
                List <IntPtr> sorted = ControlSorter.SortContainer(current);
                if (sorted != null)
                {
                    string[] parametrValues = values[index];
                    for (int i = 0; i < sorted.Count && parametrValues.Length > i; i++)
                    {
                        NativeApi.GetClassName(sorted[i], className, 255);
                        string classNameStr = className.ToString();
                        if (classNameStr.StartsWith(CCCFillManager.EditClassName))
                        {
                            ApiSetter.SetText(sorted[i], parametrValues[i]);
                        }
                        else if (classNameStr.StartsWith(CCCFillManager.ComboBoxClassName))
                        {
                            ApiSetter.SetComboBoxSelected(base.HWnd, sorted[i], parametrValues[i]);
                        }
                    }
                }
                if (index < values.Count - 1)
                {
                    ApiSetter.ClickButton(addButton, base.HWnd, null, null);
                }
                current = NativeApi.FindWindowEx(container, current, null, null);
            }
            return(result && ApiSetter.ClickButton(saveButton, base.HWnd, null, null));
        }