Writing on SMath canvas using plugin codes

Writing on SMath canvas using plugin codes - Сообщения

#1 Опубликовано: 04.08.2023 04:55:33
muiz

muiz

15 сообщений из 22 понравились пользователям.

Группа: User

Hello everyone,

I would like to ask if anyone knows examples or ways to write SMath command on SMath canvas itself via plugin. I want to implement a feature where the user can click a button (from a plugin form), and then some SMath command is written on the canvas. However, I'm not sure which class is responsible for this action.

Best regards,

Faiz
#2 Опубликовано: 04.08.2023 06:41:01
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Hi Faiz. XMCD import plugin? Here.

Best regards.
Alvaro.

#3 Опубликовано: 04.08.2023 10:38:06
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

AFAIK, you can't command the canvas from over the canvas itself.
Plug your demand the region above the canvas, display result(s) over the canvas.
Highlight the graph of the X,Y ... +, dot, o
#4 Опубликовано: 04.08.2023 10:53:31
muiz

muiz

15 сообщений из 22 понравились пользователям.

Группа: User

I am looking for is something like the toolbox, where you can click on the button (item) in the toolbox and the function/text is written on the canvas automatically. But instead of doing this via the toolbox, I want to do this using a windows form that I created within the plugin that I am working on. I am not sure if this can be access via the SMath.Core or it is only available for the toolbox.

Regards,

Faiz
#5 Опубликовано: 04.08.2023 11:06:50
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Hi. Like Insert Field then.

Clipboard01.png

Best regards.
Alvaro.
#6 Опубликовано: 04.08.2023 11:12:38
muiz

muiz

15 сообщений из 22 понравились пользователям.

Группа: User

Wrote

Hi. Like Insert Field then.

Clipboard01.png

Best regards.
Alvaro.



Hi Alvaro,

which plugin is this?

Regards,

Faiz
#7 Опубликовано: 04.08.2023 11:29:56
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Wrote

... which plugin is this? ...



Ups. It's not a plugin, it is in SMath.UI.Accessories.dll.

Best regards.
Alvaro.

#8 Опубликовано: 04.08.2023 12:12:17
⚜ Kenny Lemens, P.E. ᵂᴵ

⚜ Kenny Lemens, P.E. ᵂᴵ

74 сообщений из 164 понравились пользователям.

Группа: User

Greetings,

For starters, you cannot use SMath.Manager.IPluginToolboxGroups (i.e., the Toolbar) because it only supports a action that will be inserted into the worksheet. The question becomes: how am I able to interact with the worksheet? Please reference this thread: https://en.smath.com/forum/yaf_postst23224_Plugin-Development--GUI---SMath-Interface.aspx

If you are creating your own region, you would want to utilize IPluginCustomRegion.

With regards to your intent, it appears as though you may want to utilize IPluginMenuExtender; you can choose if you want it in the File, View, Tools, Help, or Context Menu (ie., a button click)

The following code is a quick example in VB.NET, on how you can create a button that you can click, and it can perform an action akin to the toolbar (i.e., insert a region at the current cursor location)


   Public Function GetMenuItem(sessionProfile As SessionProfile) As MenuButton() Implements IPluginMenuExtender.GetMenuItem
...
      Dim btnMenu_01b_tools8 = New MenuButton("Minus Plus (∓)", AddressOf Me.OnClick_InsertMinusPlus)
      btnMenu_01b_tools8.Behavior = MenuButtonBehavior.AlwaysEnabled
      btnMenu_01b_tools8.ShortcutKey = InputKeys.Control Or InputKeys.Subtract ' https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.keys?view=windowsdesktop-7.0
...
      Return (New MenuButton() {btnMenu_01c, btnMenu_01d, btnMenu_01g, btnMenu_01h, btnMenu_01_tools})
   End Function

   Public Sub OnClick_InsertMinusPlus(_args As MenuButtonArgs)
      Try
         If IsNothing(_args.CurrentRegion) Then
            Dim Lourdes As SMath.Controls.MathRegion = New SMath.Controls.MathRegion(_args.SessionProfile)
            Dim expr = New List(Of SMath.Manager.Term) 'As SMath.Manager.Term() ' = {} '
            expr.Add(New SMath.Manager.Term("#", SMath.Manager.TermType.Operand, 0))
            expr.Add(New SMath.Manager.Term("∓", SMath.Manager.TermType.Operator, 1))

            Lourdes.Terms = expr.ToArray

            Dim Avignon As SMath.Controls.RegionsEnumerator = New SMath.Controls.RegionsEnumerator(New List(Of SMath.Controls.RegionBase)({Lourdes}), 0)
            _args.Worksheet.CreateRegions(Avignon, 0, 0, , )
         Else
            _args.CurrentRegion.OnCommandSend("∓"
         End If
      Catch ex As Exception
         MsgBox(ex.ToString())
      End Try
   End Sub


On that note, you can copy and paste my full code (VB.NET) from this forum thread (NOTE: you will need to expand the "SPOILER" tags to see/access the code)
https://en.smath.com/forum/yaf_postsm79990_SMath-Keyboard-Shortcuts.aspx#post79990


May this be of Good Help;
⚜ Kenny Lemens, P.E. ᵂᴵ
"No matter where you go, there you are." -Buckaroo BanzaiHotkeys: https://en.smath.com/forum/resource.ashx?a=45771&b=2
#9 Опубликовано: 05.08.2023 08:00:19
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

I would like to ask if anyone knows examples or ways to write SMath command on SMath canvas itself via plugin.


No need for plugin, it comes from native Studio as well Solver 30405.
Collect all the plotting arguments plot:={
Put that collect on the left of the plot, at same level.
Now, you have full command of the canvas.
Formatted Label will do as well.
Perfect example from Alvaro latest Timosenko.

#10 Опубликовано: 06.08.2023 08:15:02
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

Formatted Label will do as well.


Bad luck ... Formatted Label not included Solver 30405
It survives from Studio versions.


  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений