Пример #1
0
        protected override void OnDropDown(EventArgs e)
        {
            base.OnDropDown(e);

            Items.Clear();
            Items.AddRange(AdapterService.GetAdapters());
        }
Пример #2
0
        protected override void OnClick(EventArgs e)
        {
            base.OnClick(e);
            Debug.WriteLine(this.GetType().Namespace + "." + this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()");

            if (Enabled)
            {
                if (!_storage.IsSaved)
                {
                    /*Prject még soha nem volt mentve, itt az idő hogy megtegye a felhasználó*/
                    var sps = new ShowingParameters();
                    if (sps.Show())
                    {
                        _storage.Parameters.ProductName    = sps.ProudctName;
                        _storage.Parameters.ProductVersion = sps.ProductVersion;
                        _storage.Parameters.ProductCode    = sps.ProcutCode;
                        _storage.Parameters.CustomerName   = sps.CustomerName;
                        _storage.Parameters.CustomerCode   = sps.CustomerCode;
                        _storage.SaveAs(sps.Path);
                        _adapter.Play();
                    }
                }
                else
                {
                    /*Ha nincs vadapater kiválasztva akkor kényszerítjük  felhsználót hogy vállaszon valamit.*/
                    if (!AdapterService.GetAdapters().Contains(_storage.Parameters.DeviceName))
                    {
                        IAdapterSelectForm selector = new SelectAdapterForm();
                        selector.ShowDialog();
                        _storage.Parameters.DeviceName = selector.SelectedAdapter;
                    }
                    _adapter.Play();
                }
            }
        }
Пример #3
0
 /// <summary>
 ///
 /// </summary>
 private void listView1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listView1.SelectedItems.Count != 0)
     {
         SelectedAdapter = AdapterService.GetAdapters()[listView1.SelectedItems[0].Index];
     }
 }
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            var textView = AdapterService.GetWpfTextView(textViewAdapter);

            textView?.Properties.GetOrCreateSingletonProperty(() => new SignatureHelpCommandHandler(textViewAdapter,
                                                                                                    textView,
                                                                                                    NavigatorService.GetTextStructureNavigator(textView.TextBuffer),
                                                                                                    SignatureHelpBroker));
        }
Пример #5
0
        /// <summary>
        /// Called when a <see cref="T:Microsoft.VisualStudio.TextManager.Interop.IVsTextView"/> adapter has been created and initialized.
        /// </summary>
        /// <param name="textViewAdapter">The newly created and initialized text view
        ///             adapter.</param>
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            IWpfTextView wpfTextView = AdapterService.GetWpfTextView(textViewAdapter);

            if (wpfTextView == null)
            {
                return;
            }
            wpfTextView.Properties.GetOrCreateSingletonProperty(GetFactory(textViewAdapter, wpfTextView));
        }
Пример #6
0
        //[Import]
        //internal ISignatureHelpBroker SignatureHelpBroker { get; set; }

        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            ITextView textView = AdapterService.GetWpfTextView(textViewAdapter);

            if (textView == null)
            {
                return;
            }

            textView.Properties.GetOrCreateSingletonProperty(() => new CompletionController(textViewAdapter, textView, this));//, SignatureHelpBroker));
        }
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            ITextView textView = AdapterService.GetWpfTextView(textViewAdapter);

            InsertMatchingCommandHandler CreateCommandHandler()
            {
                return(new InsertMatchingCommandHandler(textViewAdapter, textView, this));
            }

            textView.Properties.GetOrCreateSingletonProperty(CreateCommandHandler);
        }
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            IWpfTextView textView = AdapterService.GetWpfTextView(textViewAdapter);

            if (textView != null)
            {
                var textNavigator = NavigatorService.GetTextStructureNavigator(textView.TextBuffer);

                textView.Properties.GetOrCreateSingletonProperty(() =>
                                                                 new CommandFilter(textViewAdapter, textView, textNavigator, SignatureHelpBroker));
            }
        }
Пример #9
0
        public void VsTextViewCreated(IVsTextView textView)
        {
            var wpfTextView = AdapterService.GetWpfTextView(textView);

            if (wpfTextView == null)
            {
                return;
            }

            Func <AutoCompletionHandler> autoCompletionHandler = () => new AutoCompletionHandler(textView, wpfTextView, this);

            wpfTextView.Properties.GetOrCreateSingletonProperty(autoCompletionHandler);
        }
Пример #10
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            ITextView textView = AdapterService.GetWpfTextView(textViewAdapter);

            if (textView == null)
            {
                return;
            }

            Func <CrmCompletionCommandHandler> createCommandHandler = delegate() { return(new CrmCompletionCommandHandler(textViewAdapter, textView, this)); };

            textView.Properties.GetOrCreateSingletonProperty(createCommandHandler);
        }
Пример #11
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            ITextView textView = AdapterService.GetWpfTextView(textViewAdapter);

            if (textView == null)
            {
                return;
            }

            textView.Properties.GetOrCreateSingletonProperty(
                () => new RainbowCommandHandler(this, textViewAdapter, textView)
                );
        }
Пример #12
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            ITextView textView = AdapterService.GetWpfTextView(textViewAdapter);

            if (textView == null)
            {
                return;
            }

            Func <XmlGoToDefinitionCommandHandler> createCommandHandler = () => new XmlGoToDefinitionCommandHandler(textViewAdapter, textView, this);

            textView.Properties.GetOrCreateSingletonProperty(createCommandHandler);
        }
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            IWpfTextView textView = AdapterService.GetWpfTextView(textViewAdapter);

            if (textView == null)
            {
                return;
            }

            Func <RustCompletionCommandHandler> createCommandHandler =
                () => new RustCompletionCommandHandler(textViewAdapter, textView, CompletionBroker);

            textView.Properties.GetOrCreateSingletonProperty(createCommandHandler);
        }
Пример #14
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            IWpfTextView textView = AdapterService.GetWpfTextView(textViewAdapter);

            if (textView == null)
            {
                return;
            }

            textView.Properties.GetOrCreateSingletonProperty(() => new RustCompletionCommandHandler(textViewAdapter, textView, CompletionBroker));
            textView.Properties.GetOrCreateSingletonProperty(() => new RustCommentSelectionCommandHandler(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty(() => new RustF1HelpCommandHandler(textViewAdapter, textView));
            // TODO: also handle FormatDocument and GoToDefiniton here in a similar way
        }
Пример #15
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            IWpfTextView textView = AdapterService.GetWpfTextView(textViewAdapter);

            if (textView == null)
            {
                return;
            }

            textView.Properties.GetOrCreateSingletonProperty(() => new RustCompletionCommandHandler(textViewAdapter, textView, CompletionBroker));
            textView.Properties.GetOrCreateSingletonProperty(() => new RustCommentSelectionCommandHandler(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty(() => new RustF1HelpCommandHandler(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty(() => new RustGoToDefinitionCommandHandler(ServiceProvider, textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty(() => new RustPrettyPrintCommandHandler(textViewAdapter, textView));
        }
Пример #16
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            ITextView textView = AdapterService.GetWpfTextView(textViewAdapter);

            if (textView == null)
            {
                return;
            }

            textView.Properties.GetOrCreateSingletonProperty(
                () => new ProbeSignatureHelpCommandHandler(textViewAdapter,
                                                           textView,
                                                           NavigatorService.GetTextStructureNavigator(textView.TextBuffer),
                                                           SignatureHelpBroker,
                                                           this));
        }
Пример #17
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            IWpfTextView textView = AdapterService.GetWpfTextView(textViewAdapter);

            if (textView == null)
            {
                return;
            }

            textView.Properties.GetOrCreateSingletonProperty(() => new CommentSelectionCommandHandler(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty(() => new FormatDocumentHandler(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty(() => new GoToBraceCommandHandler(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty(() => new BraceCompletionCommandHandler(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty(() => new AngularQuotesCommandHandler(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty(() => new BackspaceCommandHandler(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty(() => new GoToDefinitionCommandHandler(textViewAdapter, textView));
        }
Пример #18
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            var textView = AdapterService.GetWpfTextView(textViewAdapter);

            if (textView == null)
            {
                return;
            }

            OpenedBuffers.VsTextViewCreated(textViewAdapter, textView);

            textView.ObtainOrAttachProperty(() => new CommentSelection(textViewAdapter, textView));
            textView.ObtainOrAttachProperty(() => new FormatDocument(textViewAdapter, textView));
            textView.ObtainOrAttachProperty(() => new GoToBrace(textViewAdapter, textView));
            textView.ObtainOrAttachProperty(() => new BraceCompletion(textViewAdapter, textView));
            textView.ObtainOrAttachProperty(() => new Guillemets.AngularQuotes(textViewAdapter, textView));
            textView.ObtainOrAttachProperty(() => new Guillemets.Backspace(textViewAdapter, textView));
            textView.ObtainOrAttachProperty(() => new GoToDefinition(textViewAdapter, textView));
        }
Пример #19
0
        private static void PerformAdapterPattern()
        {
            Android android = new Android();

            Iphone iPhone = new Iphone();

            AdapterService.RechargeMicroUsbPhone(android);
            Console.WriteLine("Recharging android with MicroUsb ...");

            AdapterService.RechargeLightningPhone(iPhone);
            Console.WriteLine("Recharging iPhone with Lightning ...");

            LightningToMircroUsbAdapter lightingPhoneAdaptee = new LightningToMircroUsbAdapter(iPhone);

            AdapterService.RechargeMicroUsbPhone(lightingPhoneAdaptee);
            Console.WriteLine("Recharging iPhone with MicroUsb");

            Console.ReadKey();
        }
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            ITextView textView = AdapterService.GetWpfTextView(textViewAdapter);

            if (textView == null)
            {
                return;
            }

            Dispatcher.CurrentDispatcher.InvokeAsync(() =>
            {
                textView.Properties.GetOrCreateSingletonProperty(() => new DothtmlCompletionCommandHandler(textViewAdapter, textView, this));
                textView.Properties.GetOrCreateSingletonProperty(() => new DothtmlFormatCommandHandler(textViewAdapter, textView, this));

                var tempSession = CompletionBroker.CreateCompletionSession(textView, textView.TextSnapshot.CreateTrackingPoint(0, Microsoft.VisualStudio.Text.PointTrackingMode.Negative), true);
                tempSession.Start();
                tempSession.Dismiss();
            }, DispatcherPriority.ApplicationIdle);
        }
Пример #21
0
        /// <summary>
        ///
        /// </summary>
        public AdapterComboBox()
        {
            DropDownStyle = ComboBoxStyle.DropDownList;
            AutoToolTip   = true;
            Items.AddRange(AdapterService.GetAdapters());
            Size = new System.Drawing.Size(200, 25);

            EventAggregator.Instance.Subscribe <StorageAppEvent>(e =>
            {
                if (e.Details.DataObjects == DataObjects.ParameterProperty &&
                    e.Details.PropertyDescriptor.Name == PropertyPlus.GetPropertyName(() => e.Storage.Parameters.DeviceName))
                {
                    _parmeters   = e.Storage.Parameters;
                    SelectedItem = e.Storage.Parameters.DeviceName;
                }
            });

            EventAggregator.Instance.Subscribe <StopAppEvent>(e => Enabled = true);
            EventAggregator.Instance.Subscribe <PlayAppEvent>(e => Enabled = false);
        }
Пример #22
0
    // Start is called before the first frame update
    void Start()
    {
        AdapterService ass = gameObject.AddComponent <AdapterService>();

        ass.GetAuthToken();
        lifxOptions = GameObject.Find(deviceName + "OptionToggle");
        lifxSwitch  = GameObject.Find(deviceName + "SwitchToggle");

        //find colors
        lifxRed   = GameObject.Find(deviceName + "Red");
        lifxGreen = GameObject.Find(deviceName + "Green");
        lifxBlue  = GameObject.Find(deviceName + "Blue");

        lifxSwitch.GetComponent <Renderer>().enabled = false;

        lifxOptionsOR = lifxOptions.transform.rotation;
        lifxSwitchOR  = lifxSwitch.transform.rotation;


        testBtn.onClick.AddListener(SetSwitchToggle);
    }
Пример #23
0
        /// <summary>
        ///
        /// </summary>
        private void AdaptersListRefresh()
        {
            var adapters = AdapterService.GetAdapters();

            listView1.Items.Clear();
            foreach (var name in adapters)
            {
                ListViewItem item = new ListViewItem();

                if (name.Contains("Virtual"))
                {
                    item.ImageKey = @"virtual_adapter";
                    item.Text     = name;
                    listView1.Items.Add(item);
                }
                else
                {
                    item.ImageKey = @"adapter";
                    item.Text     = @"Serial Number: " + name;
                    listView1.Items.Add(item);
                }
            }
        }
Пример #24
0
        /// <summary>
        /// When redirecting the add operation, find the parent to add the new control to.
        /// </summary>
        /// <param name="adapterService">Adapter service.</param>
        /// <param name="parent">The parent item.</param>
        /// <param name="childType">The type of child item.</param>
        /// <param name="index">Index of the last child of the parent.</param>
        /// <returns>The parent to add the new control to.</returns>
        private static ModelItem FindSuitableParent(AdapterService adapterService, ModelItem parent, Type childType, int index)
        {
            ModelItem suitableParent = null;

            if (adapterService != null)
            {
                ParentAdapter parentAdapter = adapterService.GetAdapter <ParentAdapter>(parent.Content.Collection[index].ItemType);
                Debug.Assert(parentAdapter != null, "Parent Adapter cannot be null");
                List <ModelItem> parentList       = new List <ModelItem>();
                ModelItem        targetParent     = parent.Content.Collection[index];
                ModelItem        redirectedParent = parentAdapter.RedirectParent(parent.Content.Collection[index], childType);
                parentList.Add(targetParent);
                parentList.Add(redirectedParent);
                while (redirectedParent != targetParent)
                {
                    targetParent  = redirectedParent;
                    parentAdapter = adapterService.GetAdapter <ParentAdapter>(targetParent.ItemType);
                    Debug.Assert(parentAdapter != null, "Parent Adapter for Redirected Parent cannot be null");
                    redirectedParent = parentAdapter.RedirectParent(targetParent, childType);
                    if (parentList.Contains(redirectedParent))
                    {
                        break; // To avoid recursion
                    }
                    else
                    {
                        parentList.Add(redirectedParent);
                    }
                }

                if (parentAdapter.CanParent(targetParent, childType))
                {
                    suitableParent = targetParent;
                }
            }

            return(suitableParent);
        }
Пример #25
0
    public void SetColor(string color)
    {
        AdapterService ass = gameObject.AddComponent <AdapterService>();

        ass.SetColor(color, deviceName);
    }
Пример #26
0
    public void SetSwitch(string toggleState)
    {
        AdapterService ass = gameObject.AddComponent <AdapterService>();

        ass.SetSwitch(toggleState, deviceName);
    }
Пример #27
0
 public Adapter(AdapterService adapterService)
 {
     _adapterService = adapterService;
 }
Пример #28
0
        /// <summary>
        /// If the control being added is TabItem then add it as sibling of existing TabItems;
        /// otherwise redirect the add to the active TabItem.
        /// </summary>
        /// <param name="parent">The parent item.</param>
        /// <param name="childType">The type of child item.</param>
        /// <returns>A redirected parent.</returns>
        public override ModelItem RedirectParent(ModelItem parent, Type childType)
        {
            _canParent = true;
            if (parent == null)
            {
                throw new ArgumentNullException("parent");
            }
            if (childType == null)
            {
                throw new ArgumentNullException("childType");
            }

            // if the control being pasted is tabItem then add it as sibling of existing tabItems;
            // else redirect it to active tabItem.
            if (ModelFactory.ResolveType(parent.Context, MyPlatformTypes.TabItem.TypeId).IsAssignableFrom(childType))
            {
                return(parent); // TabControl acts as parent of this tabItem being parented.
            }
            else
            {
                _canParent = false;

                if (parent.Context != null)
                {
                    Tool tool = parent.Context.Items.GetValue <Tool>();
                    if (tool != null && tool.FocusedTask == null)
                    {
                        if (parent.Content != null && parent.Content.Collection.Count > 0)
                        {
                            // TabControl has tabItem(s) in it
                            int index = TabControlDesignModeValueProvider.GetDesignTimeSelectedIndex(parent); // get hold of active tab
                            if (index == -1)
                            {
                                // TabControl has tabItems, but no selection. Select first TabItem.
                                TabControlDesignModeValueProvider.SetDesignTimeSelectedIndex(parent, 0); // select first tabItem
                                index = 0;
                            }

                            // Check if the active TabItem is capable of parenting the control.
                            // If not, we need to inject a TabItem with Grid in it,
                            // and this new tabItem will take care of parenting the concerned control(childType).

                            AdapterService adapterService = parent.Context.Services.GetService <AdapterService>();
                            if (adapterService != null)
                            {
                                ModelItem targetParent = FindSuitableParent(adapterService, parent, childType, index);
                                if (targetParent != null)
                                {
                                    return(targetParent);
                                }
                                else
                                {
                                    _canParent = true;
                                    return(parent); // return TabControl. If the active tab is not capable of parenting the new control, we'll inject another tabItem with Grid in TabControl
                                }
                            }
                        }
                        else
                        {
                            if (parent.Content.Collection.Count == 0)
                            {
                                // tabControl is empty. Inject a TabItem with Grid in it
                                _canParent = true;
                                return(parent); // return TabControl
                            }
                        }
                    }
                    else
                    {
                        // Task is going on
                        if (parent.Content != null && parent.Content.Collection.Count > 0)
                        {
                            int index = TabControlDesignModeValueProvider.GetDesignTimeSelectedIndex(parent);
                            if (index == -1)
                            {
                                // TabControl has tabItems, but no selection ..so select
                                TabControlDesignModeValueProvider.SetDesignTimeSelectedIndex(parent, 0);
                                index = 0;
                            }
                            return(parent.Content.Collection[index]);
                        }
                        else
                        {
                            // TabControl has no TabItems in it. Cannot parent
                            return(parent);
                        }
                    }
                }
            }
            return(base.RedirectParent(parent, childType));
        }
        /// <summary>
        /// When redirecting the add operation, find the parent to add the new control to.
        /// </summary>
        /// <param name="adapterService">Adapter service.</param>
        /// <param name="parent">The parent item.</param>
        /// <param name="childType">The type of child item.</param>
        /// <param name="index">Index of the last child of the parent.</param>
        /// <returns>The parent to add the new control to.</returns>
        private static ModelItem FindSuitableParent(AdapterService adapterService, ModelItem parent, Type childType, int index)
        {
            ModelItem suitableParent = null;

            if (adapterService != null)
            {
                ParentAdapter parentAdapter = adapterService.GetAdapter<ParentAdapter>(parent.Content.Collection[index].ItemType);
                Debug.Assert(parentAdapter != null, "Parent Adapter cannot be null");
                List<ModelItem> parentList = new List<ModelItem>();
                ModelItem targetParent = parent.Content.Collection[index];
                ModelItem redirectedParent = parentAdapter.RedirectParent(parent.Content.Collection[index], childType);
                parentList.Add(targetParent);
                parentList.Add(redirectedParent);
                while (redirectedParent != targetParent)
                {
                    targetParent = redirectedParent;
                    parentAdapter = adapterService.GetAdapter<ParentAdapter>(targetParent.ItemType);
                    Debug.Assert(parentAdapter != null, "Parent Adapter for Redirected Parent cannot be null");
                    redirectedParent = parentAdapter.RedirectParent(targetParent, childType);
                    if (parentList.Contains(redirectedParent))
                    {
                        break; // To avoid recursion 
                    }
                    else
                    {
                        parentList.Add(redirectedParent);
                    }
                }

                if (parentAdapter.CanParent(targetParent, childType))
                {
                    suitableParent = targetParent;
                }
            }

            return suitableParent;
        }
Пример #30
0
        /// <summary>
        /// Parent the given control into the TabControl.
        /// </summary>
        /// <param name="parent">The new parent item for child.</param>
        /// <param name="child">The child item.</param>
        public override void Parent(ModelItem parent, ModelItem child)
        {
            if (parent == null)
            {
                throw new ArgumentNullException("parent");
            }
            if (child == null)
            {
                throw new ArgumentNullException("child");
            }

            // Clear existing property values that we don't want to apply to the new container.
            child.Properties[MyPlatformTypes.FrameworkElement.MarginProperty].ClearValue();
            child.Properties[MyPlatformTypes.FrameworkElement.HorizontalAlignmentProperty].ClearValue();
            child.Properties[MyPlatformTypes.FrameworkElement.VerticalAlignmentProperty].ClearValue();

            bool childIsTabItem = child.IsItemOfType(MyPlatformTypes.TabItem.TypeId);

            // We always accept parenting in TabControl if there is not active focused Task.
            // If the control being pasted is not TabItem and TabControl is empty (doesnt have any TabItem(s) in it)
            // then we inject a TabItem with Grid in TabControl and paste the control under consideration in TabItem.
            // We inject a TabItem also in cases when active TabItem is not capable of parenting concerned control
            if (!childIsTabItem)
            {
                // Based on evaluation done in RedirectParent(),
                // if any control other than TabItem is being parented to Control in this Parent() call
                // then we need to add a new Tabitem with Grid in it

                try
                {
                    ModelItem newTabItem = ModelFactory.CreateItem(parent.Context, MyPlatformTypes.TabItem.TypeId, CreateOptions.InitializeDefaults);
                    parent.Content.Collection.Add(newTabItem);

                    // activate the newly added tabItem
                    TabItemDesignModeValueProvider.SetDesignTimeIsSelected(newTabItem, true);

                    int index = parent.Content.Collection.Count - 1;
                    // Find a suitable parent for control to be pasted.
                    // Since we always accept parenting for TabControl when there is no active focused task,
                    // we better make sure this works.
                    AdapterService adapterService = parent.Context.Services.GetService <AdapterService>();
                    if (adapterService != null)
                    {
                        ModelItem targetParent = FindSuitableParent(adapterService, parent, child.ItemType, index);
                        if (targetParent != null)
                        {
                            ParentAdapter parentAdapter = adapterService.GetAdapter <ParentAdapter>(targetParent.ItemType);
                            parentAdapter.Parent(targetParent, child);
                        }
                        else
                        {
                            Debug.Assert(targetParent != null, "Parenting failed!");
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw new InvalidOperationException("Parenting Failed", ex.InnerException);
                }
            }
            else
            {
                // child being added is a TabItem;
                child.Properties[MyPlatformTypes.TabItem.IsSelectedProperty].ClearValue();
                parent.Content.Collection.Add(child);
                TabItemDesignModeValueProvider.SetDesignTimeIsSelected(child, true);       // Activate the newly added tabItem
            }
        }