Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline TheWizEd  
#1 Posted : 11 January 2012 04:43:21(UTC)
TheWizEd


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2010(UTC)
Posts: 178
Man
United States

Was thanked: 19 time(s) in 13 post(s)
Andrey,

How do you want to handle plugins? I have two that I will migrate to 0.9 this weekend. One has the MathCad equivalent financial functions and the other a way to store and pass data between SMath files.

Ed

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline Andrey Ivashov  
#2 Posted : 11 January 2012 12:57:53(UTC)
Andrey Ivashov


Rank: Administration

Groups: Developers, Registered, Knovel Developers, Administrators, Advanced Member
Joined: 11/07/2008(UTC)
Posts: 1,616
Man
Russian Federation

Was thanked: 1978 time(s) in 666 post(s)
Hello Ed.

The best way to handle plugins is to create some plugins register here on the site. I plan to do it in future.

But for now... Is it possible for you to upload the sources you've created to project's shared (visible for all under the green Code button on the top of the forum's pages) or to my closed (you and me will be the only people who will have access to it; I can remove the code after reviewing and compiling it if you want) SVN repository. It is preferred for me because I need to check any sources for the danger code and compile it myself before introducing resulting binaries to the community. Hope you'll understand me well. I think this will provide the best protection of users computers and data while plugins register is not created yet.

Please check How to create plugins for SMath Studio topic regarding shared repository details (to have write permissions request for the login/pass via PM or e-mail to me). If you need any help about SVN, please just inform me.

P.S.: If you will agree to share sources with me, I will update them in case of interfaces (api) changed after every next release.

Thank you for your offer! It's a pleasure.

Best regards, Andrey Ivashov.

Edited by user 11 January 2012 13:01:49(UTC)  | Reason: Not specified

Offline TheWizEd  
#3 Posted : 13 January 2012 06:00:41(UTC)
TheWizEd


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2010(UTC)
Posts: 178
Man
United States

Was thanked: 19 time(s) in 13 post(s)
Do we still compile for .NET Framework 2.0?
Ed
Offline Andrey Ivashov  
#4 Posted : 13 January 2012 07:01:37(UTC)
Andrey Ivashov


Rank: Administration

Groups: Developers, Registered, Knovel Developers, Administrators, Advanced Member
Joined: 11/07/2008(UTC)
Posts: 1,616
Man
Russian Federation

Was thanked: 1978 time(s) in 666 post(s)
  • The most preferable is .Net Compact Framework 2.0 if you want to create a plugin for both Desktop and Handheld versions of SMath Studio (I can help you with it).
  • To meet SMath Studio Desktop system requirement only you need to use .Net Framework 2.0 (plugin will work only on the desktops).
  • You can use any .Net version you want, but you need to inform users about requirements they should follow. Though this is not recommended.


Regards.
Offline TheWizEd  
#5 Posted : 14 January 2012 07:54:31(UTC)
TheWizEd


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2010(UTC)
Posts: 178
Man
United States

Was thanked: 19 time(s) in 13 post(s)
Andrey,

A couple of questions.

First I'm not able to upload source code for the financial functions using TortoiseSVN. I may need some access permissions?

Second, I took the CheckBox plugin and converted to Visual Basic. I can insert a checkbox to the SMath desktop but when I click on it SMath shuts down. Could you take a look at my source code and see where I made my mistake? One thing I noticed is where does args come from in InsertCheckbox? Thanks.


Code removed by TheWizEd see following post

Edited by user 15 January 2012 12:15:16(UTC)  | Reason: Not specified

Ed
Offline Andrey Ivashov  
#6 Posted : 14 January 2012 10:34:44(UTC)
Andrey Ivashov


Rank: Administration

Groups: Developers, Registered, Knovel Developers, Administrators, Advanced Member
Joined: 11/07/2008(UTC)
Posts: 1,616
Man
Russian Federation

Was thanked: 1978 time(s) in 666 post(s)
TheWizEd wrote:
First I'm not able to upload source code for the financial functions using TortoiseSVN. I may need some access permissions?

I've sent your login and password to SVN via private messages.

TheWizEd wrote:
Could you take a look at my source code and see where I made my mistake?

I don't see the following line in your code (it should be inside the OnCommandSend method:
Code:
RequestForEvaluation(CalculateType.Numeric, this, false);

Note that code for CheckBoxRegion compilable for SMath Studio 0.90 you can find in repository under revision 79 only! Revision 80 has changes made specifically for the new version of the program.

Regards.
Offline TheWizEd  
#7 Posted : 14 January 2012 12:15:57(UTC)
TheWizEd


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2010(UTC)
Posts: 178
Man
United States

Was thanked: 19 time(s) in 13 post(s)
Okay, I uploaded the code to plugins. I'll look in to my omission after the NFL playoff games today. Thanks for your help.
Ed
Offline TheWizEd  
#8 Posted : 15 January 2012 09:26:12(UTC)
TheWizEd


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2010(UTC)
Posts: 178
Man
United States

Was thanked: 19 time(s) in 13 post(s)
Opps, I meant to go back to that but forgot. I've included the request for evaluation and can place a checkbox but as soon as I click on the desktop SMath shuts down.

Code removed by TheWizED see following post.

What I'm not clear on does InsertCheckBox have to implement anything and where does the args parameter come from?

Edited by user 15 January 2012 12:15:51(UTC)  | Reason: Not specified

Ed
Offline TheWizEd  
#9 Posted : 15 January 2012 12:18:37(UTC)
TheWizEd


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2010(UTC)
Posts: 178
Man
United States

Was thanked: 19 time(s) in 13 post(s)
Okay I finally got it to work.

In the AddDefinition the last argument should be Nothing unless the definition is a function.

Code:

Imports System
Imports System.Collections.Generic
Imports System.Text

Imports SMath.Manager
Imports SMath.Control

Public Class Implementer : Implements IPluginCustomRegion
    Dim assemblyInfos() As AssemblyInfo
    Dim menuButtons() As MenuButton
    Dim dragDropFileTypes() As DragAndDropFileType

    Public Function CreateNew() As SMath.Control.RegionBase Implements SMath.Control.IPluginCustomRegion.CreateNew
        Return New CheckBox()
    End Function

    Public ReadOnly Property DragAndDropFileTypes As SMath.Control.DragAndDropFileType() Implements SMath.Control.IPluginCustomRegion.DragAndDropFileTypes
        Get
            ' No Drag'n'Drop files supported
            Return Me.dragDropFileTypes
        End Get
    End Property

    Public Function GetContextMenuItems(region As SMath.Control.RegionBase) As SMath.Control.MenuButton() Implements SMath.Control.IPluginCustomRegion.GetContextMenuItems
        Return New MenuButton() {New MenuButton("xxx")}
    End Function

    Public ReadOnly Property IsCurrentClipboardSupported As Boolean Implements SMath.Control.IPluginCustomRegion.IsCurrentClipboardSupported
        Get
            ' No external clipboard data supported
            Return False
        End Get
    End Property

    Public ReadOnly Property MenuItems As SMath.Control.MenuButton() Implements SMath.Control.IPluginCustomRegion.MenuItems
        Get
            Return Me.menuButtons
        End Get
    End Property

    Public ReadOnly Property Dependences As SMath.Manager.AssemblyInfo() Implements SMath.Manager.IPlugin.Dependences
        Get
            Return Me.assemblyInfos
        End Get
    End Property

    Public Sub InsertCheckbox(args As MenuButtonArgs)
        args.CurrentRegion = New CheckBox()
    End Sub

    Public Sub Initialize() Implements SMath.Manager.IPlugin.Initialize
        Me.assemblyInfos = New AssemblyInfo() {New AssemblyInfo("SMath Studio", New Version(0, 90), New Guid("a37cba83-b69c-4c71-9992-55ff666763bd"))}
        Me.dragDropFileTypes = New DragAndDropFileType() {New DragAndDropFileType(Nothing, Nothing)}
        Me.menuButtons = New MenuButton() {New MenuButton("CheckBox", AddressOf Me.InsertCheckbox)}
    End Sub

#Region "IDisposable Support"
    Private disposedValue As Boolean ' To detect redundant calls

    ' IDisposable
    Protected Overridable Sub Dispose(disposing As Boolean)
        If Not Me.disposedValue Then
            If disposing Then
                ' TODO: dispose managed state (managed objects).
            End If

            ' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below.
            ' TODO: set large fields to null.
        End If
        Me.disposedValue = True
    End Sub

    ' TODO: override Finalize() only if Dispose(ByVal disposing As Boolean) above has code to free unmanaged resources.
    'Protected Overrides Sub Finalize()
    '    ' Do not change this code.  Put cleanup code in Dispose(ByVal disposing As Boolean) above.
    '    Dispose(False)
    '    MyBase.Finalize()
    'End Sub

    ' This code added by Visual Basic to correctly implement the disposable pattern.
    Public Sub Dispose() Implements IDisposable.Dispose
        ' Do not change this code.  Put cleanup code in Dispose(ByVal disposing As Boolean) above.
        Dispose(True)
        GC.SuppressFinalize(Me)
    End Sub
#End Region

End Class


Code:

Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Xml

Imports SMath.Manager
Imports SMath.Control

Public Class CheckBox : Inherits SMath.Control.RegionEvaluable
    Dim bChecked As Boolean

    Public Sub New()
        MyBase.New()
        Me.bChecked = False
        MyBase.Terms = New Term() {New Term("checked", TermType.Operand, 0)}
        MyBase.Size = New Size(22, 22)
    End Sub

    Public Sub New(region As CheckBox)
        MyBase.New(region)
        Me.bChecked = region.Checked
    End Sub

    Public Overrides Sub Evaluate(store As SMath.Math.Store)
        If (MyBase.Terms.Length = 1) And (MyBase.Terms(0).Type = TermType.Operand) Then
            If bChecked Then
                store.AddDefinition(MyBase.Terms(0).Text, New Term() {New Term("1", TermType.Operand, 0)}, Nothing)
            Else
                store.AddDefinition(MyBase.Terms(0).Text, New Term() {New Term("0", TermType.Operand, 0)}, Nothing)
            End If
        End If
    End Sub

    Public Overrides Function Clone() As SMath.Control.RegionBase
        Return New CheckBox(Me)
    End Function

    Public Overrides Sub FromXml(reader As System.Xml.XmlTextReader, parsingContext As SMath.Control.FileParsingContext)
        Me.bChecked = Convert.ToBoolean(reader.GetAttribute("checked"))
    End Sub

    Public Overrides Sub ToXml(writer As System.Xml.XmlTextWriter, parsingContext As SMath.Control.FileParsingContext)
        writer.WriteAttributeString("checked", Me.bChecked.ToString.ToLower)
    End Sub

    Public Overrides Sub OnCommandSend(s As String)
        If s = " " Then
            Me.Focused = True
            Me.InDate = False
            bChecked = Not bChecked
            ' Request evaluation as soon as value changes
            RequestForEvaluation(CalculateType.Numeric, Me, False)
        End If
        MyBase.OnCommandSend(s)
    End Sub

    Public Overrides Sub OnPaint(e As PaintEventArgs)
        MyBase.OnPaint(e)
        If bChecked Then
            e.Graphics.FillRectangle(Brushes.Black, e.ClipRectangle.X + 1, e.ClipRectangle.Y + 1, e.ClipRectangle.Width - 2, e.ClipRectangle.Height - 2)
        Else
            e.Graphics.FillRectangle(Brushes.LightGray, e.ClipRectangle.X + 1, e.ClipRectangle.Y + 1, e.ClipRectangle.Width - 2, e.ClipRectangle.Height - 2)
        End If
    End Sub

    Public Overrides Sub OnMouseDown(e As MouseEventArgs)
        MyBase.OnMouseDown(e)
        OnCommandSend(" ")
    End Sub

    Public Property Checked()
        Get
            Return bChecked
        End Get
        Set(value)
            bChecked = value
        End Set
    End Property

End Class
Ed
Offline TheWizEd  
#10 Posted : 21 January 2012 17:03:46(UTC)
TheWizEd


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2010(UTC)
Posts: 178
Man
United States

Was thanked: 19 time(s) in 13 post(s)
Toying with controls, I changed the name of the class from CheckBox to SMCheckBox. I can insert a new SMCheckBox and toggle it. It gets saved to the sm file but won't read back in. What might I be doing wrong?
Ed
Offline Andrey Ivashov  
#11 Posted : 21 January 2012 18:33:20(UTC)
Andrey Ivashov


Rank: Administration

Groups: Developers, Registered, Knovel Developers, Administrators, Advanced Member
Joined: 11/07/2008(UTC)
Posts: 1,616
Man
Russian Federation

Was thanked: 1978 time(s) in 666 post(s)
Ed, did you try to debug?

Regards, Andrey Ivashov.
Offline TheWizEd  
#12 Posted : 21 January 2012 20:47:19(UTC)
TheWizEd


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2010(UTC)
Posts: 178
Man
United States

Was thanked: 19 time(s) in 13 post(s)
Sort of. Until today I've been using Msgbox to communicate but today I switched to Debug. Much better. What I found is FromXML never gets called nor does CreateNew. I believe these two are used to create a check box from the sm file.

Code:

  <region id="0" left="126" top="108" width="22" height="22" border="true" color="#000000" background-color="#ffffff">
    <smcheckbox name="cbCheckBox1" checked="false">
      <input>
        <e type="operand">cbCheckBox1</e>
      </input>
    </smcheckbox>
  </region>


Code:

    Public Overrides Sub FromXml(reader As System.Xml.XmlTextReader, parsingContext As SMath.Control.FileParsingContext)
        Me.sName = Convert.ToString(reader.GetAttribute("name"))
        Me.bChecked = Convert.ToBoolean(reader.GetAttribute("checked"))
        MsgBox("FromXml")
    End Sub

    Public Overrides Sub ToXml(writer As System.Xml.XmlTextWriter, parsingContext As SMath.Control.FileParsingContext)
        writer.WriteAttributeString("name", Me.sName)
        writer.WriteAttributeString("checked", Me.bChecked.ToString.ToLower)
        MsgBox("ToXml")
    End Sub
Ed
Offline Andrey Ivashov  
#13 Posted : 21 January 2012 22:04:03(UTC)
Andrey Ivashov


Rank: Administration

Groups: Developers, Registered, Knovel Developers, Administrators, Advanced Member
Joined: 11/07/2008(UTC)
Posts: 1,616
Man
Russian Federation

Was thanked: 1978 time(s) in 666 post(s)
Ok. Fact is that tag of the region in result XML (.sm file) composing according to plugin DLL name. F.e. PlotRegion.dll will create tag "<plot />", CheckBoxRegion.dll - "<checkbox />". I recommend you also to name the class same as you've named a DLL file.
Offline TheWizEd  
#14 Posted : 22 January 2012 00:32:27(UTC)
TheWizEd


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2010(UTC)
Posts: 178
Man
United States

Was thanked: 19 time(s) in 13 post(s)
I was thinking of creating several controls, Button, CheckBox, ComboBox. The menu item is Controls with Button, CheckBox, ComboBox as sub MenuItems. I know the ComboBox will be difficult to paint now that I understand the process better. But what are weekends for. The ContextMenuItem would bring up a dialog so the user could edit the properties of the control. So Implementer would control all Controls.

Looks like not possible at this time. I'll continue to work on each seperately.

Thanks for the advise.

Ed
Offline TheWizEd  
#15 Posted : 23 January 2012 22:33:52(UTC)
TheWizEd


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2010(UTC)
Posts: 178
Man
United States

Was thanked: 19 time(s) in 13 post(s)
In fact I've been able to come up with a solution to have multiple controls in one DLL. I created a class called ControlsRegion. Within the class there can be several control types. Each class method uses a switch to determine for each type what to do. I've got it working for a button and a checkbox. I'm working on the context menu item to edit the properties of the control from the SMath desktop. Next will be combobox and option button.

The controls I've developed so far have a unique name and a caption. The controls get saved to the sm file and read back in okay.
Ed
thanks 1 user thanked TheWizEd for this useful post.
on 24/01/2012(UTC)
Offline Davide Carpi  
#16 Posted : 28 August 2012 04:38:53(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,647
Man
Italy
Location: Italy

Was thanked: 1329 time(s) in 875 post(s)
Hi,

I tried to create a small plugin, which returns the maximum and minimum values ​​from a list of values...

I need a little help... how I can handle the items of MDA?

Code:

		public Term[] getMax(Term[] val1, Term[] val2, Store store)
		{
			List<Term> gmResult = new List<Term>();
			
			gmResult.AddRange(val1);

			if (val1[val1.Length-1].ToString().StartsWith("mat("))
			{
				gmResult.Add(new Term(Functions.Max, TermType.Function, 1));
				if (val2 != null)
				{
					gmResult.AddRange(val2);
					gmResult.Add(new Term(Operators.BooleanMoreOrEqual, TermType.Operator, 2));
					gmResult.AddRange(val1);
					gmResult.Add(new Term(Functions.Max, TermType.Function, 1));
					gmResult.AddRange(val2);
					gmResult.Add(new Term(Functions.If, TermType.Function, 3));
				}
			}
			else
			{
				if (val2 != null)
				{
					gmResult.AddRange(val2);
					gmResult.Add(new Term(Operators.BooleanMoreOrEqual, TermType.Operator, 2));
					gmResult.AddRange(val1);
					gmResult.AddRange(val2);
					gmResult.Add(new Term(Functions.If, TermType.Function, 3));
				}
			}
			return Decision.Preprocessing(gmResult.ToArray(), ref store);
		}


edit: solved with Symbolic plugin Clap


regards,

w3b5urf3r


attachments updated: Max() and Min() arguments now can be also vector, matrices an systems (not nested)

Edited by user 03 September 2012 19:38:52(UTC)  | Reason: Not specified

File Attachment(s):
customFunctions.dll.zip (4kb) downloaded 40 time(s).
Davide Carpi attached the following image(s):
Max&Min.png
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
thanks 2 users thanked Davide Carpi for this useful post.
on 28/08/2012(UTC),  on 03/09/2012(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.