Tuesday, 17 May 2016

Changing the coordinate system of canvas WPF

                    <Canvas.LayoutTransform>
                        <ScaleTransform ScaleX="1" ScaleY="-1" CenterX=".5" CenterY=".5" />

                    </Canvas.LayoutTransform>

Call User control event from parent window WPF c#

//In userControl

public event EventHandler HelpButtonUpdated;

        public Header()
        {
            InitializeComponent();
        }

        private void Image_MouseDown(object sender, MouseButtonEventArgs e)
        {
            //Null check makes sure the main page is attached to the event
            if (this.HelpButtonUpdated != null)
                this.HelpButtonUpdated(new object(), new EventArgs());

        }



Main Window
  header.HelpButtonUpdated += new EventHandler(MyEventHandlerFunction_HelpButtonUpdated);
public void MyEventHandlerFunction_HelpButtonUpdated(object sender, EventArgs e)
        {
            PopupHelp.IsOpen = true;
            Opacity = 0.5;          
        }


Auto Timer setup c# WPF

DispatcherTimer AutoSaveTimer; // Auto saver data to file
        TimeSpan auto_save_increment = new TimeSpan(0, 0, 10);  // time in between saves.
       
           //  AutoSaveTimer setup
            AutoSaveTimer = new System.Windows.Threading.DispatcherTimer();
            AutoSaveTimer.Tick += new EventHandler(AutoSaverTimer_Tick);
            AutoSaveTimer.Interval = auto_save_increment;
            AutoSaveTimer.Start();
        


        // Method to perform autosave work
        private void AutoSaverTimer_Tick(object sender, EventArgs e)
        {
          
        }


Altering the Keyboard functionality WPF


    <Window.Resources>
         <!--UI commands.-->
        <RoutedUICommand x:Key="Commands.ZoomOut" />
        <RoutedUICommand x:Key="Commands.ZoomIn" />
    </Window.Resources>

    <Window.InputBindings>       
        <!--Bind keys to commands.-->       
        <KeyBinding
                                                Key="Minus"
                                                Command="{StaticResource Commands.ZoomOut}"
                                                />
        <KeyBinding
                                                Key="Plus"
                                                Command="{StaticResource Commands.ZoomIn}"
                                                />
        <KeyBinding
                                                Key="Space"
                                                Command="{StaticResource Commands.ZoomIn}"
                                                />
     
    </Window.InputBindings>

    <Window.CommandBindings>
       
        <!--Bind commands to event handlers.-->
       
        <CommandBinding
            Command="{StaticResource Commands.ZoomOut}"
            Executed="ZoomOut_Executed"
            />
        <CommandBinding
            Command="{StaticResource Commands.ZoomIn}"
            Executed="ZoomIn_Executed"
            />

    </Window.CommandBindings>

Monday, 10 August 2015

Cerate Responsive Map on Web

<style>
            .google-maps {
                position: relative;
                padding-bottom: 35%;
                height: 0;
                overflow: hidden;
            }

                .google-maps iframe {
                    position: absolute;
                    top: 0;
                    left: 0;
                    width: 100% !important;
                    height: 90% !important;
                }
        </style>

        <div class="google-maps">

            <iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3163.234829846082!2d-12.9254090000003!3d37.54953079999999!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x808fc09a8c2e3fdb%3A0x9b2d61bcc663088f!2s!5e0!3m2!1sen!2sus!4v1439237247915" width="600" height="450" frameborder="0" style="border: 0" allowfullscreen></iframe>



        </div>

Saturday, 28 February 2015