Esempio n. 1
0
    protected object listElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        CMSGridActionButton btn;

        switch (sourceName.ToLowerInvariant())
        {
        // Delete action
        case "delete":
            btn = (CMSGridActionButton)sender;
            btn.OnClientClick = "if(!confirm(" + ScriptHelper.GetString(String.Format(ResHelper.GetString("autoMenu.RemoveStateConfirmation"), HTMLHelper.HTMLEncode(TypeHelper.GetNiceObjectTypeName(ContactInfo.OBJECT_TYPE).ToLowerCSafe()))) + ")) { return false; }" + btn.OnClientClick;
            if (!WorkflowStepInfoProvider.CanUserRemoveAutomationProcess(CurrentUser, SiteContext.CurrentSiteName))
            {
                if (btn != null)
                {
                    btn.Enabled = false;
                }
            }
            break;

        // Process status column
        case "statestatus":
            return(AutomationHelper.GetProcessStatus((ProcessStatusEnum)ValidationHelper.GetInteger(parameter, 0)));
        }

        return(null);
    }
Esempio n. 2
0
        protected override void Execute(NativeActivityContext context)
        {
            var relativelement = Element.Get(context);
            var match          = relativelement.Rectangle;

            match.X     += OffsetX.Get(context);
            match.Y     += OffsetY.Get(context);
            match.Width  = Width.Get(context);
            match.Height = Height.Get(context);
            var imageelement = relativelement as ImageElement;

            if (imageelement != null)
            {
                var processname = imageelement.Processname;
                if (!string.IsNullOrEmpty(processname))
                {
                    var _element = AutomationHelper.GetFromPoint(match.X, match.Y);
                    if (_element.ProcessId < 1)
                    {
                        throw new ElementNotFoundException("Failed locating Image, expected " + processname + " but found nothing");
                    }
                    var p = System.Diagnostics.Process.GetProcessById(_element.ProcessId);
                    if (p.ProcessName != processname)
                    {
                        throw new ElementNotFoundException("Failed locating Image, expected " + processname + " but found " + p.ProcessName);
                    }
                }
            }
            var b = Interfaces.Image.Util.Screenshot(match);
            //Interfaces.Image.Util.SaveImageStamped(b, "c:\\temp", "GetImage-result");
            var v = new ImageElement(match, b);

            context.SetValue(Result, v);
            context.ScheduleAction(Body, v, OnBodyComplete);
        }
Esempio n. 3
0
    /// <summary>
    /// External history binding.
    /// </summary>
    protected object gridState_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName.ToLowerCSafe())
        {
        case "stepname":
            return(HTMLHelper.HTMLEncode(GetStep(parameter).StepDisplayName));

        case "processname":
            return(HTMLHelper.HTMLEncode(GetProcess(parameter).WorkflowDisplayName));

        case "status":
            return(AutomationHelper.GetProcessStatus((ProcessStatusEnum)ValidationHelper.GetInteger(parameter, 0)));

        case "delete":
            ImageButton btn = (ImageButton)sender;
            btn.OnClientClick = "if(!confirm(" + ScriptHelper.GetString(string.Format(ResHelper.GetString("autoMenu.RemoveStateConfirmation"), HTMLHelper.HTMLEncode(ResHelper.GetString(TypeHelper.GetObjectTypeResourceKey(PredefinedObjectType.CONTACT)).ToLowerCSafe()))) + ")) { return false; }";
            if (!WorkflowStepInfoProvider.CanUserRemoveAutomationProcess(CurrentUser, SiteInfoProvider.GetSiteName(contactSiteId)))
            {
                btn.Enabled = false;
                btn.Attributes.Add("src", GetImageUrl("Design/Controls/UniGrid/Actions/DeleteDisabled.png"));
            }
            break;
        }

        return(parameter);
    }
Esempio n. 4
0
        protected void WaitMessage(string message, string button = "ОК")
        {
            var window = WaitDialog("АналитФАРМАЦИЯ: Внимание");

            Assert.AreEqual(message, AutomationHelper.ToText(window));
            ClickByName(button, window);
        }
Esempio n. 5
0
        protected void AssertUpdate(string result)
        {
            var update = WaitDialog("Обмен данными");

            Assert.AreEqual("Обмен данными", update.Current.Name, AutomationHelper.ToText(update));
            var dialog = Opened.Timeout(UpdateTimeout).First();

            if (dialog.Current.Name == "Обмен данными")
            {
                dialog = Opened.Timeout(UpdateTimeout).First();
            }

            //может быть простое уведомление а может быть уведомление о новых документах
            var text = AutomationHelper.ToText(dialog);

            if (text == result)
            {
                Assert.AreEqual(result, text);
                ClickByName("Закрыть", dialog);
            }
            else
            {
                Assert.That(text, Does.Contain(result));
                Click("TryClose", dialog);
            }
        }
Esempio n. 6
0
        private void InitializeExpandableElementForUIAutomation(IFrameworkInputElement element)
        {
            this.Dispatcher.BeginInvoke((Action)(() =>
            {
                AutomationElement automationElement;
                lock (automationRootElementLock)
                {
                    if (this.mainAutomationWindow == null)
                    {
                        this.mainAutomationWindow = AutomationElement.RootElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.AutomationIdProperty, this.Name));
                    }

                    automationElement = this.mainAutomationWindow?.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, element.Name));
                }

                if (automationElement != null)
                {
                    AutomationPattern automationPatternFromElement = AutomationHelper.GetSpecifiedPattern(automationElement, "ExpandCollapsePatternIdentifiers.Pattern");
                    if (automationElement.GetCurrentPattern(automationPatternFromElement) is ExpandCollapsePattern expandCollapsePattern)
                    {
                        expandCollapsePattern.Expand();
                        expandCollapsePattern.Collapse();

                        this.General.Focus();
                    }
                }
            }));
        }
Esempio n. 7
0
        public MainViewModel()
        {
            ////if (IsInDesignMode)
            ////{
            ////    // Code runs in Blend --> create design time data.
            ////}
            ////else
            ////{
            ////    // Code runs "for real"
            ////}
            ///



            AutomationHelper            automationHelper            = AutomationHelper.Instance;
            AutomationElement           root                        = automationHelper.RootElement();
            AutomationElementCollection automationElementCollection = root.FindAll(TreeScope.Children, Condition.TrueCondition);

            foreach (AutomationElement elem in automationElementCollection)
            {
                lst.Add(elem.Current.Name);
            }

            App = new AppInfo()
            {
                AppNames = lst
            };
        }
    protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName.ToLowerCSafe())
        {
        case "condition":
            return(MacroRuleTree.GetRuleText(ValidationHelper.GetString(parameter, String.Empty)));

        case "type":
            DataRowView row = parameter as DataRowView;
            if (row != null)
            {
                ObjectWorkflowTriggerInfo trigger = new ObjectWorkflowTriggerInfo(row.Row);
                if (!string.IsNullOrEmpty(trigger.TriggerTargetObjectType))
                {
                    return(GetTriggerDescription(trigger));
                }
                else
                {
                    return(AutomationHelper.GetTriggerName(trigger.TriggerType, trigger.TriggerObjectType));
                }
            }
            return(parameter);

        case "delete":
            if (!WorkflowStepInfoProvider.CanUserManageAutomationProcesses(CurrentUser, CurrentSiteName))
            {
                CMSGridActionButton btn = (CMSGridActionButton)sender;
                btn.Enabled = false;
            }
            return(parameter);

        default:
            return(parameter);
        }
    }
Esempio n. 9
0
    /// <summary>
    /// Adds item to drop-down list of trigger types.
    /// </summary>
    /// <param name="type">Type of trigger</param>
    /// <param name="objectType">Object type</param>
    private void AddDdlTypeListItem(WorkflowTriggerTypeEnum type, string objectType)
    {
        string text  = AutomationHelper.GetTriggerName(type, objectType);
        string value = GetDdlTypeFormatedValue(type, objectType);

        ddlType.Items.Add(new ListItem(text, value));
    }
Esempio n. 10
0
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that threw event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void gridProcesses_OnAction(string actionName, object actionArgument)
    {
        int processId = Convert.ToInt32(actionArgument);

        switch (actionName)
        {
        case "edit":
            var url = UIContextHelper.GetElementUrl(ModuleName.ONLINEMARKETING, "EditProcess");
            url = URLHelper.AddParameterToUrl(url, "displayTitle", "false");
            url = URLHelper.AddParameterToUrl(url, "objectId", processId.ToString());
            URLHelper.Redirect(AddSiteQuery(url, null));
            break;

        case "delete":
            if (AutomationHelper.CheckProcessDependencies(processId))
            {
                ShowError(GetString("MA.process.CannotDeleteUsed"));

                return;
            }

            if (!WorkflowStepInfoProvider.CanUserManageAutomationProcesses(CurrentUser, CurrentSiteName))
            {
                RedirectToAccessDenied(ModuleName.ONLINEMARKETING, "ManageProcesses");
            }

            // Delete the workflow
            WorkflowInfoProvider.DeleteWorkflowInfo(processId);
            break;
        }
    }
Esempio n. 11
0
    /// <summary>
    /// External history binding.
    /// </summary>
    protected object gridState_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName.ToLowerCSafe())
        {
        case "stepname":
            return(HTMLHelper.HTMLEncode(GetStep(parameter).StepDisplayName));

        case "processname":
            return(HTMLHelper.HTMLEncode(GetProcess(parameter).WorkflowDisplayName));

        case "status":
            return(AutomationHelper.GetProcessStatus((ProcessStatusEnum)ValidationHelper.GetInteger(parameter, 0)));

        case "delete":
            CMSGridActionButton btn = (CMSGridActionButton)sender;
            var confirmationMessage = string.Format(ResHelper.GetString("autoMenu.RemoveStateConfirmation"), HTMLHelper.HTMLEncode(TypeHelper.GetNiceObjectTypeName(PredefinedObjectType.CONTACT).ToLowerCSafe()));
            var confirmationScript  = "if(!confirm(" + ScriptHelper.GetString(confirmationMessage) + ")) { return false; } ";

            // In OnClientClick is JS code to call Unigrid's OnAction, we need to add this code to the end of new JS code to preserve it
            btn.OnClientClick = confirmationScript + btn.OnClientClick;

            if (!WorkflowStepInfoProvider.CanUserRemoveAutomationProcess(CurrentUser, SiteInfoProvider.GetSiteName(contactSiteId)))
            {
                btn.Enabled = false;
            }
            break;
        }

        return(parameter);
    }
Esempio n. 12
0
        private void RaiseOnMouseUp(InputEventArgs e)
        {
            if (OnMouseUp == null)
            {
                return;
            }
            try
            {
                if (Element == null)
                {
                    Element = AutomationHelper.GetFromPoint(e.X, e.Y);
                }
            }
            catch (Exception)
            {
            }

            try
            {
                e.Element = Element;
                if (e.Element != null)
                {
                    e.Element.Refresh();
                }
                // if (e.Element != null && e.Element.ProcessId == currentprocessid) return;
                OnMouseUp?.Invoke(e);
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
        }
Esempio n. 13
0
        protected AutomationElement WaitDialog(string name, TimeSpan timeout)
        {
            var observable = Opened.Take(1).PublishLast();

            using (observable.Connect())
                return(AutomationHelper.FindWindow(name, Process.Id) ?? observable.Timeout(timeout).First());
        }
Esempio n. 14
0
        private void WaitForMessage(string message)
        {
            var window = WaitWindow();
            var text   = AutomationHelper.ToText(window);

            Assert.That(text, Does.Contain(message));
            ClickByName("ОК", window);
        }
Esempio n. 15
0
        public void Version_update()
        {
            Uninstall();

            var currentVersion = new Version(FileVersionInfo.GetVersionInfo(setupBin).ProductVersion);
            var prev           = GetPrevVersion(currentVersion);
            var prevVersion    = new Version(FileVersionInfo.GetVersionInfo(prev).ProductVersion);

            Install(prev);

            Activate();
            WaitMessage("Для начала работы с программой необходимо заполнить учетные данные", "ОК");
            Assert.That(AutomationHelper.ToText(MainWindow), Does.Contain(prevVersion.ToString()));

            Type("Settings_UserName", testUserName);
            Type("Password", testPassword);

            var dialog = WaitDialog("Настройка");

            Click("Save", dialog);
            WaitMessage("База данных программы не заполнена. Выполнить обновление?", "НЕТ");

            WaitIdle();
            Click("Update", MainWindow);
            AssertUpdate("Получена новая версия программы. Сейчас будет выполнено обновление.");

            FilterByProcess = false;
            var update = Opened.Timeout(Timeout).First();

            try {
                AssertText(update, "Внимание! Происходит обновление программы.");
            } catch (ElementNotAvailableException) {
                //предполагаем что окно закрылось быстрее чем смог считаться данные и обновление прошло успешно
            }

            update = Opened.Where(e => e.Current.Name == "Обмен данными").Timeout(30.Second()).First();
            AssertText(update, "Производится обмен данными");
            Process         = Process.GetProcessById(update.Current.ProcessId);
            FilterByProcess = true;
            MainWindow      = AutomationElement.RootElement.FindFirst(TreeScope.Children, new AndCondition(
                                                                          new PropertyCondition(AutomationElement.ProcessIdProperty, Process.Id),
                                                                          new PropertyCondition(AutomationElement.NameProperty, "АналитФАРМАЦИЯ - Новости")));
            if (MainWindow == null)
            {
                var windows = AutomationElement.RootElement.FindAll(TreeScope.Children, new AndCondition(
                                                                        new PropertyCondition(AutomationElement.ProcessIdProperty, Process.Id),
                                                                        new PropertyCondition(AutomationElement.IsWindowPatternAvailableProperty, true)))
                              .OfType <AutomationElement>()
                              .Implode(x => x.Current.Name);
                Assert.Fail($"Не удалось найти главное окно с заголовком 'АналитФАРМАЦИЯ' у процесса {Process.Id} есть следующие окна {windows}");
            }

            var message = Opened.Timeout(UpdateTimeout).First();

            AssertText(message, "Обновление завершено успешно.");
            Assert.That(AutomationHelper.ToText(MainWindow), Does.Contain(currentVersion.ToString()));
            ClickByName("ОК", message);
        }
Esempio n. 16
0
        private void Init()
        {
            _automation = new UIA3Automation();
            // Initialize TreeWalker
            _treeWalker  = _automation.TreeWalkerFactory.GetControlViewWalker();
            _rootElement = _automation.GetDesktop();

            _elementFinder = new AutomationHelper(_automation);
            _elementFinder.ControlReleasedOverElement += ControlReleasedOverElement;
        }
Esempio n. 17
0
        private void DisposeAutomationObjects()
        {
            _elementFinder.ControlReleasedOverElement += ControlReleasedOverElement;
            _elementFinder.ControlReleasedOverElement -= ControlReleasedOverElement;

            _rootElement   = null;
            _treeWalker    = null;
            _automation    = null;
            _elementFinder = null;
        }
Esempio n. 18
0
        public static AutomationHelper Setup(RuntimeDefinedParameterDictionary parameterDictionary)
        {
            AutomationHelper automationHelper = new AutomationHelper();
            string           server           = (string)parameterDictionary.Values.Where(v => v.Name.Equals("Server")).Select(s => s.Value).FirstOrDefault();
            int port = (int)parameterDictionary.Values.Where(v => v.Name.Equals("Port")).Select(s => s.Value).FirstOrDefault();

            automationHelper.SetPort(port);
            automationHelper.SetServer(server);
            return(automationHelper);
        }
Esempio n. 19
0
        private async void btn_Select(object sender, RoutedEventArgs e)
        {
            Interfaces.GenericTools.Minimize();

            var       limit = ModelItem.GetValue <Rectangle>("Limit");
            Rectangle rect  = Rectangle.Empty;

            Log.Information(limit.ToString());
            using (Interfaces.Overlay.OverlayWindow _overlayWindow = new Interfaces.Overlay.OverlayWindow(true))
            {
                _overlayWindow.BackColor = System.Drawing.Color.Blue;
                var tip = new Interfaces.Overlay.TooltipWindow("Select area to look for");
                if (limit != Rectangle.Empty)
                {
                    _overlayWindow.Visible = true;
                    _overlayWindow.Bounds  = limit;
                    _overlayWindow.TopMost = true;
                    _overlayWindow.Opacity = 0.3;
                    tip.setText("Select area to look for within the blue area");
                }
                rect = await getrectangle.GetitAsync();

                tip.Close();
                tip = null;
            }

            if (limit != Rectangle.Empty)
            {
                if (!limit.Contains(rect))
                {
                    Log.Error(rect.ToString() + " is not within process limit of " + limit.ToString());
                    Interfaces.GenericTools.Restore();
                    return;
                }
            }

            var _image   = new System.Drawing.Bitmap(rect.Width, rect.Height);
            var graphics = System.Drawing.Graphics.FromImage(_image as System.Drawing.Image);

            graphics.CopyFromScreen(rect.X, rect.Y, 0, 0, _image.Size);
            ModelItem.Properties["Image"].SetValue(Interfaces.Image.Util.Bitmap2Base64(_image));
            NotifyPropertyChanged("Image");
            var element = AutomationHelper.GetFromPoint(rect.X, rect.Y);

            if (element != null)
            {
                using (var p = System.Diagnostics.Process.GetProcessById(element.ProcessId))
                {
                    var Processname = p.ProcessName;

                    ModelItem.Properties["Processname"].SetValue(new System.Activities.InArgument <string>(Processname));
                }
            }
            Interfaces.GenericTools.Restore();
        }
Esempio n. 20
0
        protected void Click(string id, AutomationElement element = null)
        {
            var launchButton = FindById(id, element);

            if (launchButton == null)
            {
                throw new Exception($"Не могу найти кнопку {id}, форма {AutomationHelper.ToText(element)}");
            }

            launchButton.Invoke();
        }
 // private bool mouseDownWaiting = false;
 private void RaiseOnMouseMove(InputEventArgs e)
 {
     try
     {
         e.Element = AutomationHelper.GetFromPoint(e.X, e.Y);
     }
     catch (Exception ex)
     {
         Log.Error(ex, "");
     }
     Element = e.Element;
     OnMouseMove(e);
 }
Esempio n. 22
0
        private void RefreshApp()
        {
            lst.Clear();
            AutomationHelper            automationHelper            = AutomationHelper.Instance;
            AutomationElement           root                        = automationHelper.RootElement();
            AutomationElementCollection automationElementCollection = root.FindAll(TreeScope.Children, Condition.TrueCondition);

            foreach (AutomationElement elem in automationElementCollection)
            {
                lst.Add(elem.Current.Name);
            }

            App.AppNames = lst;
        }
Esempio n. 23
0
        static void Main(string[] args)
        {
            string _iFilePath, _bType, _nThreads, _nWLinks;

            //args[0] => Input filename
            if (!string.IsNullOrEmpty(args[0]) && args[0] != "null")
            {
                _iFilePath = args[0];
                MovieNames = GetInputFromFile(_iFilePath);
            }

            //args[1] => Browser Type (gui, headless)
            if (!string.IsNullOrEmpty(args[1]) && args[1] != "null")
            {
                _bType      = args[1];
                browserType = GetBrowserType(_bType);
            }

            //args[2] => Max no of threads
            if (!string.IsNullOrEmpty(args[2]) && args[2] != "null")
            {
                _nThreads = args[2];
                Int32.TryParse(_nThreads, out maxNoOfThreads);
            }

            //args[3] => Max no of wiki links
            if (!string.IsNullOrEmpty(args[3]) && args[3] != "null")
            {
                _nWLinks = args[3];
                Int32.TryParse(_nWLinks, out noOfWikiLinks);
            }

            //args[4] => Output folder
            if (!string.IsNullOrEmpty(args[4]) && args[4] != "null")
            {
                outputDirectory = args[4];
            }

            Console.WriteLine("Starting job");

            Console.WriteLine(args);

            string           reportDirectory = AutomationUtility.GetOutputDirectory(outputDirectory);
            AutomationHelper helper          = new AutomationHelper();

            helper.GetWikiLinks(MovieNames, browserType, reportDirectory, noOfWikiLinks);
            helper.Automate(MovieNames, browserType, reportDirectory, maxNoOfThreads);

            Console.WriteLine("Completed job");
        }
Esempio n. 24
0
 private void RaiseOnMouseDown(InputEventArgs e)
 {
     try
     {
         Element = AutomationHelper.GetFromPoint(e.X, e.Y);
     }
     catch (Exception ex)
     {
         Log.Error(ex, "");
     }
     e.Element = Element;
     // if (e.Element != null && e.Element.ProcessId == currentprocessid) return;
     OnMouseDown(e);
 }
Esempio n. 25
0
 private void ExecuteCreateAction(int templateId)
 {
     if (templateId == CREATE_FROM_SCRATCH_ID)
     {
         mWorkflow = AutomationHelper.CreateEmptyWorkflow();
     }
     else
     {
         var template = AutomationTemplateInfo.Provider.Get(templateId);
         if (template != null)
         {
             mWorkflow = AutomationTemplateManager.CreateAutomationProcessFromTemplate(template, MacroIdentityOption.FromUserInfo(CurrentUser));
         }
     }
 }
Esempio n. 26
0
    protected object listElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        CMSGridActionButton btn;

        switch (sourceName.ToLowerCSafe())
        {
        // Delete action
        case "delete":
            int siteId = SiteID;

            if (SiteID == UniSelector.US_GLOBAL_AND_SITE_RECORD)
            {
                DataRowView drv           = (parameter as GridViewRow).DataItem as DataRowView;
                int         contactSiteId = ValidationHelper.GetInteger(drv["StateSiteID"], 0);
                if (contactSiteId > 0)
                {
                    siteId = contactSiteId;
                }
            }

            btn = (CMSGridActionButton)sender;
            btn.OnClientClick = "if(!confirm(" + ScriptHelper.GetString(string.Format(ResHelper.GetString("autoMenu.RemoveStateConfirmation"), HTMLHelper.HTMLEncode(TypeHelper.GetNiceObjectTypeName(ContactInfo.OBJECT_TYPE).ToLowerCSafe()))) + ")) { return false; }" + btn.OnClientClick;
            if (!WorkflowStepInfoProvider.CanUserRemoveAutomationProcess(CurrentUser, SiteInfoProvider.GetSiteName(siteId)))
            {
                if (btn != null)
                {
                    btn.Enabled = false;
                }
            }
            break;

        case "view":
            btn = (CMSGridActionButton)sender;
            // Ensure accountID parameter value;
            var objectID = ValidationHelper.GetInteger(btn.CommandArgument, 0);
            // Contact detail URL
            string contactURL = UIContextHelper.GetElementDialogUrl(ModuleName.ONLINEMARKETING, "EditContact", objectID, "isSiteManager=" + ContactHelper.IsSiteManager);
            // Add modal dialog script to onClick action
            btn.OnClientClick = ScriptHelper.GetModalDialogScript(contactURL, "ContactDetail");
            break;

        // Process status column
        case "statestatus":
            return(AutomationHelper.GetProcessStatus((ProcessStatusEnum)ValidationHelper.GetInteger(parameter, 0)));
        }

        return(null);
    }
Esempio n. 27
0
 private void RaiseOnMouseDown(InputEventArgs e)
 {
     if (OnMouseDown == null)
     {
         return;
     }
     try
     {
         Element = AutomationHelper.GetFromPoint(e.X, e.Y);
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
     }
     e.Element = Element;
     // if (e.Element != null && e.Element.ProcessId == currentprocessid) return;
     OnMouseDown?.Invoke(e);
 }
Esempio n. 28
0
        public void Arrange(UIComponents components)
        {
            //使用下拉框显示主区域。
            var control = components.Main;

            if (control != null)
            {
                this._mainView = control.MainView as ListLogicalView;
                this._mainView.Control.RemoveFromParent();

                ////选中数据的第一行。
                ////由于模板都会自动获取数据,而UI线程一直在构造界面,所以这里直接监听数据到达函数就可以了。
                //view.DataLoader.ListenDataChangedOnce(() =>
                //{
                //    if (view.Data.Count > 0)
                //    {
                //        view.CurrentObject = view.Data[0] as Entity;
                //    }
                //});

                var cmbList = ControlHelper.CreateComboListControl(this._mainView);
                AutomationHelper.SetEditingElement(cmbList);

                main.Content = cmbList;
            }
            else
            {
                main.RemoveFromParent();
            }

            var toolBar = components.CommandsContainer;

            if (toolBar != null)
            {
                toolBarContainer.Content = toolBar.Control;
            }
            else
            {
                toolBarContainer.RemoveFromParent();
            }

            //Children
            components.ArrangeChildrenByTabControl(childrenTab);
        }
Esempio n. 29
0
        private async void btn_Select(object sender, RoutedEventArgs e)
        {
            Interfaces.GenericTools.minimize(Interfaces.GenericTools.mainWindow);
            var rect = await getrectangle.GetitAsync();

            var _image   = new System.Drawing.Bitmap(rect.Width, rect.Height);
            var graphics = System.Drawing.Graphics.FromImage(_image as System.Drawing.Image);

            graphics.CopyFromScreen(rect.X, rect.Y, 0, 0, _image.Size);
            ModelItem.Properties["Image"].SetValue(Interfaces.Image.Util.Bitmap2Base64(_image));
            NotifyPropertyChanged("Image");
            var element = AutomationHelper.GetFromPoint(rect.X, rect.Y);

            if (element != null)
            {
                var p           = System.Diagnostics.Process.GetProcessById(element.ProcessId);
                var Processname = p.ProcessName;
                ModelItem.Properties["Processname"].SetValue(new System.Activities.InArgument <string>(Processname));
            }
            Interfaces.GenericTools.restore();
        }
    protected object listElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName.ToLowerCSafe())
        {
        // Delete action
        case "delete":
            int siteId = SiteID;

            if (SiteID == UniSelector.US_GLOBAL_OR_SITE_RECORD)
            {
                DataRowView drv           = (parameter as GridViewRow).DataItem as DataRowView;
                int         contactSiteId = ValidationHelper.GetInteger(drv["StateSiteID"], 0);
                if (contactSiteId > 0)
                {
                    siteId = contactSiteId;
                }
            }

            ImageButton btn = (ImageButton)sender;
            btn.OnClientClick = "if(!confirm(" + ScriptHelper.GetString(string.Format(ResHelper.GetString("autoMenu.RemoveStateConfirmation"), HTMLHelper.HTMLEncode(ResHelper.GetString(TypeHelper.GetObjectTypeResourceKey(PredefinedObjectType.CONTACT)).ToLowerCSafe()))) + ")) { return false; }";
            if (!WorkflowStepInfoProvider.CanUserRemoveAutomationProcess(CurrentUser, SiteInfoProvider.GetSiteName(siteId)))
            {
                if (btn != null)
                {
                    btn.Enabled = false;
                    btn.Attributes.Add("src", GetImageUrl("Design/Controls/UniGrid/Actions/DeleteDisabled.png"));
                }
            }
            break;

        // Process status column
        case "statestatus":
            return(AutomationHelper.GetProcessStatus((ProcessStatusEnum)ValidationHelper.GetInteger(parameter, 0)));
        }

        return(null);
    }