Announcement

Collapse
No announcement yet.

Why Mono Is Desirable For Linux

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reflection tip

    I know that System.Xaml is a key technology that is not working with Gtk#.
    In my free time, I tried to make possible Gtk#/Xaml like feeling, and the final code looks like following:

    Initialize xml/C# objects initial mapping is:
    Code:
    static void Init()
    {
                GtkDynamic.Setup();
                BindInstance.AddBindMapping<ComboTexts>("ActiveText", "Changed");
    }
    After this, Xml code is like following for a window:
    HTML Code:
    <Window Title="Create New Image"
            WindowPosition = "Center"
            Modal="true"
            xmlns:Controls="clr-namespace:SmartDraw.Views.Controls">
      <VBox>
        <HBox>
          <Label Text="Template" />
          <ComboTexts Namespace="SmartDraw.Views.Controls" DefaultWidth="200" ActiveText="{BindTo=Text;At=Changed}">
            <ComboItem Text="640x480" />
            <ComboItem Text="800x600" />
            <ComboItem Text="1024x768" />
          </ComboTexts>
        </HBox>
        <Label Text="Image Size" />
        <HBox>
          <Label Width="100" Text="Width" />
          <SpinButton Min="1" Max="30000" Value="{BindTwoWays=dWidth}"/>
        </HBox>
        <HBox>
          <Label Width="100" Text="Height" />
          <SpinButton Min="1" Max="30000" Value="{BindTwoWays=dHeight}"/>
        </HBox>
        <HBox Pack="End" >
          <Button Text="OK" Clicked="OnOk" />
          <Button Text="Cancel" Clicked="OnCancel" />
        </HBox>
      </VBox>
    </Window>
    and the C# code looks like this:

    Code:
        
        internal class NewFileDialog : Window
        {
            public NewFileDialog():base(string.Empty)
            {
                this.SetXml(); //here the widget is built based on XML definition
            }
                (...)
    
            private void OnOk(object sender, EventArgs e)
            {
                // (OK button logic)
                Destroy();
            }
    
            private void OnCancel(object sender, EventArgs e)
            {
                Destroy();
            }
    A trained eye will notice that Gtk# Widget has the property WidthRequest but not Width, also, the method that sets Width, has to be called with other method, none named Width.
    So the idea behind is that the xml mapping will go with properties, excluding some cases when are virtual properties.
    An UI made with it is this one:
    How it looks: http://picpaste.com/ui_program-ZHMePJcI.png


    You may ask: but why you show the picture, does the gradient over Cairo in the left side has anything to do with Xml? The short answer is: yes, almost all declarative items are defined with xml.
    Is it this program free/opensource?
    Yes, the entire software alpha quality (the XML library/Reflection is good enough, I can say releasable), and for curious, can be found here: https://bitbucket.org/ciplogic/sharpdrawer/ (Mercurial repository, I recommend TortoiseHg to work with it)

    Which features bring this Xml library:
    - Xaml like mapping
    - ways to override the constructors, for example if there is no constructor (look inside code for SmartWidget) or constructors need to take a specific parameter sometimes. The entire node is exposed to constructor so it can add/remove properties
    - way to override the children addition
    - Gtk#/Cairo operations mapping is done on top of the library, so for someone wanting xml mapping over other logical domains, can do it by looking how Gtk did the mapping. Also the mappings can be set after the fact
    - Property binding. The code written previously:
    Code:
                BindInstance.AddBindMapping<ComboTexts>("ActiveText", "Changed");
    Will notify the miniframework that if you listen to Changed event and will update ActiveText.
    - it is a superset of Xaml in some places, in the idea that it supports both Xaml mapping of namespaces, assemblies, but it has extra tags to set them to not write them over and over. The behavior is per context. Is great if you import an external library for a section of the Xaml
    - it supports inline code binding (just Boo), I should use the C# REPL evaluator for future, but I did not had the time yet, so very simple events can be written inline and Boo will compile them on dialog startup, at the end the user will have native performance for this inline code (Xaml requires that the logic to be set into references to code behind, but no way to write right away the code)

    For haters: screenshot is on Windows, but it works just fine on Ubuntu 64bit, Fedora and OpenSuse. (I did not made any packaging, I will ask maybe in future to directhex)

    I wanted with this post to show something that is practically untouchable by a single person doing this in his/her free time in some low level languages (I talk here about C++).
    Last edited by ciplogic; 25 September 2012, 03:40 AM.

    Comment


    • Originally posted by o247492 View Post
      So women can't have butt-sex too, it can only be a gay reference?
      Nice backpedal. Except you were applying it to two men, so that's yet more disingenuous bullshit.


      Some nice Orwellian double-speak there, Microsoft is far more of a cult that the alleged secret society of Linux geeks conspiring against poor old Mono... I've been to an invite-only Microsoft jobs fair at one of their campuses, where I've seen first hand what a bunch of nut-jobs the employees of Microsoft really are. They definitely value blind loyalty to Microsoft, and the ability to answer useless trivia questions about proprietary Microsoft technology over actual talent... That was actually what caused me to get out of the Windoze business for good...
      Wait, you've been to invite-only Microsoft job fairs, yet I'm the shill?

      Seriously though, a cult? Like we fancy ourselves to be a bunch of evil, satanic witches attempting to destroy Mono using open-sorcery, because Mono is the only godly piece of software in the otherwise godless Linux universe.
      You know Mono is Free Software, right?

      Comment


      • Originally posted by o247492 View Post
        Seriously though, a cult?
        Extremly religious people tend to have an oversimplified view of the world with a clearly defined concept of good and evil and they tend to be immune to rational arguments and facts. They also have the urge to tell other people what they can and can't do. So when it comes to Mono it goes like this:

        C# developer: 'C# is a great language. There's no reason not to use it as long as it fits your requirements and acommodates your personal taste of programming.'

        Anti mono extremist: 'Blasphemy! Don't you see that M$ is evil? You MUST NOT EVER use anything related in any way to M$ (except in cases where I say it's ok).'
        Last edited by Tinitus; 25 September 2012, 05:34 AM.

        Comment


        • Originally posted by entropy View Post
          tl;dr

          Anyone volunteer for a short summary of this thread?

          Comment


          • Originally posted by o247492 View Post
            Welcome to the forums! It's interesting that your grammar and writing style are so similar to ciplogic's... Come to think of it, ciplogic's isn't that different than directhex, but it's dissimilar enough that they probably aren't the same person, they just work together and share a flat together... Or maybe they're just lovers...

            Comment


            • This thread is another M$ epic fail! Muahahahahaha!
              I would say I almost roll on the floor laughing. LOL!
              If somebody ask me why mono is 'desirable' for Linux I would probably say 'Yes, to not to stop laughing!!!'
              Last edited by peperoni; 25 September 2012, 08:55 AM.

              Comment


              • Originally posted by entropy View Post
                tl;dr

                Anyone volunteer for a short summary of this thread?
                A handful of bitter old farts arguing about politics.

                Comment


                • Originally posted by BO$$ View Post
                  MONO is shit and should be banned from linux because we can't have linux core programs written in C# and thus be made dependent on Microsoft. They can always fuck us over so don't give them the opportunity. Basically don't start writing new apps in C# or convert existing ones to C#. Unless you want to bend over and take it from Mr. I can't program but I am the CEO of a software company Ballmer.
                  Meanwhile, another Mono-based game has been added to Humble Indie Bundle 6.

                  Basically BO$$ hates Linux games.

                  Comment


                  • I'm getting this error while trying to run Wizorb 64:

                    Missing method .ctor in assembly /opt/wizorb/MonoGame.Framework.Linux.dll, type System.Runtime.CompilerServices.ExtensionAttribute
                    Can't find custom attr constructor image: /opt/wizorb/MonoGame.Framework.Linux.dll mtoken: 0x0a0003a9

                    Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies.
                    File name: 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
                    at Paris.Paris..ctor () [0x00000] in <filename unknown>:0
                    at Paris.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
                    [ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies.
                    File name: 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
                    at Paris.Paris..ctor () [0x00000] in <filename unknown>:0
                    at Paris.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0

                    Does anyone knows what it means?

                    Comment


                    • Originally posted by narciso View Post
                      I'm getting this error while trying to run Wizorb 64:

                      Missing method .ctor in assembly /opt/wizorb/MonoGame.Framework.Linux.dll, type System.Runtime.CompilerServices.ExtensionAttribute
                      Can't find custom attr constructor image: /opt/wizorb/MonoGame.Framework.Linux.dll mtoken: 0x0a0003a9

                      Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies.
                      File name: 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
                      at Paris.Paris..ctor () [0x00000] in <filename unknown>:0
                      at Paris.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
                      [ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies.
                      File name: 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
                      at Paris.Paris..ctor () [0x00000] in <filename unknown>:0
                      at Paris.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0

                      Does anyone knows what it means?
                      The stack can be read from bottom to top, so it seems that the first thing that Paris namespace/class does it tries to call the constructor, and in constructor is a System.Core call (like Linq call) that fails to load the assembly.
                      In a similar note it seems to fail on loading System.Runtime.CompilerServices.ExtensionAttribute runtime.

                      I cannot say what eventually leads to it, but if you have a 64 bit machine, try to install just install it in a 32 bit Linux and I think that the issues will be solved.
                      If it fixes, is most likely that this game embeds the Mono engine and didn't set all assemblies to be ANY CPU, but they set them as Intel 32 bit ones (x86). As Mono is packaged, in some 64 bit distros may have set some assemblies (here System.Core) with AMD64 flag, which will make to fail loading applications in 32 bit context.
                      Last edited by ciplogic; 25 September 2012, 05:37 PM.

                      Comment

                      Working...
                      X