07/03/08

Permalink 09:13:25 pm, by Jayson Rawlins Email , 767 words, 75 views   English (US)
Categories: Arcobjects In C#, Tutorial

Add Layer Using SharpDevelop In C#

This tutorial will show you how to create a class in .NET (C#) that will employ ESRI.ArcGIS.ADF.BaseClasses.BaseCommand interface and will add a .lyr file into an ArcMap session

Create New Class Library

1.) Open SharpDevelop.
2.) Click File, then New, then Solution.
3.) In the New Solution Dialog, select C#.

New Solution Dialog

4.) Select Class Library in the right-hand pane.
5.) Name the project Practice.Tools.AddLayer, and browse to the location you wish to save the solution.
6.) Now click OK, and the new solution will be created for you.

Reference the ESRI object libraries

You will need to add a reference to the ESRI object libraries to your C# solution.

1.) Right Click on References in the Projects Window, and select Add Reference.

Add References

2.) In the upper components list, select the components (hold Control key down for selecting multiple components at a time) named ESRI.ArcGIS.ADF, ESRI.ArcGIS.ArcMapUI and ESRI.ArcGIS.Carto and then click Select. Do the same for the rest until you have all of the components shown below.

Reference Components

3.) Click OK to dismiss the dialog box.

Create add layer command.

1.) In the Solution Explorer, right-click the project, click Add, and then click Add New Item.

2.) In the Add New Item dialog box, select Class in the right-hand pane, and then in the Textbox below, name the Class AddLayer.cs. Click Create.

Add Layer Class

3.) In the Solution Explorer, right-click the existing class (MyClass.cs), and then click Delete.

MyClass

Here is code for AddLayer.cs:

//Using directives

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using ESRI.ArcGIS.ArcMapUI;
using ESRI.ArcGIS.ADF.CATIDs;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.Catalog;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Framework;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.SystemUI;
using System.Runtime.InteropServices;

namespace Practice.Tools.AddLayer
{

[ClassInterface(ClassInterfaceType.None)]
//Use GUID generator to create new GUID
[Guid("Put your GUID here")]
/*Custom program id*/
[ProgId("Practice.Tools.AddLayer")]

/*:BaseCommand to implement BaseCommand*/

public sealed class AddLayer:BaseCommand
{

private IApplication myApp;
private IMxDocument myMxDoc;
private IGxLayer gxLayer;
private IGxFile gxFile;

/*This region is for defining functions that register and unregister the AddLayer Class to the ESRI Mx Commands component category using the categories utility.
*/


#region Component Category Registration

[ComRegisterFunction()]
[ComVisible(false)]
static void RegisterFunction(string regKey)
{
MxCommands.Register(regKey);
}

[ComUnregisterFunction()]
[ComVisible(false)]
static void UnregisterFunction(string regKey)
{
MxCommands.Unregister(regKey);
}

#endregion#

/*Constructor*/

public AddLayer()
{
base.m_category = “Practice Tools";
base.m_caption = “Add A Layer";
base.m_message = “Add A Layer";
base.m_toolTip = “Add A Layer";
base.m_name = “Add A Layers";

/*Code for adding image to the command button face*/

string[] res = GetType().Assembly.GetManifestResourceNames();
if (res.GetLength(0) > 0)
{
base.m_bitmap = new System.Drawing.Bitmap(GetType().Assembly.GetManifestResourceStream(res[0]));
}
}

/*This is actually where you add the override methods by having your cursor below the constructor and pressing the Alt and Insert keys simultaneously*/

Override Methods

public override void OnClick()
{
try{
string layerLocation = @"C:\GISHOME\DNC_LINKS.lyr";
gxLayer = new GxLayerClass();
gxFile = (IGxFile) gxLayer;
gxFile.Path = layerLocation;
myMxDoc = (IMxDocument) myApp.Document;
gxLayer.Layer.Visible=false;
myMxDoc.FocusMap.AddLayer(gxLayer.Layer);

}catch
{
MessageBox.Show("Unable to add layer", “ERROR!",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}

}

public override void OnCreate(object hook)
{
if (hook != null)
{
if (hook is IMxApplication)
{
myApp = (IApplication) hook;
}
}
}
}
}

At this point, if you have the above code in your AddLayer.cs then you are well on your way. There are a few things left that need to be done before the tool will work in Arcmap.

Add the button icon file.

You will now add an existing bitmap file to your project, and use this file as an icon on the AddLayer command’s button face.

1. In the Solution Explorer window, right-click the Practice.Tools.AddLayer project, click Add, then click Add Existing Item.

Bitmap

2.) In the Add Existing Item dialog, click the Files of Type pull down and select All Files.

Layer_0

3.) Browse to the \Bin\Icons directory of your ArcGIS install, and select layer_9.bmp, then click OK to copy it to your project directory.

4.) In the Solution Explorer window, make sure you’ve selected the new bitmap, and in the Properties window below change the Build Action property to Embedded Resource.

Embedded Resource

Expose the AddLayer class to COM

1.) In the Solution Explorer window, right-click the Practice.Tools.AddLayer project, and click Properties.

2.) In the Project Properties Windows, select Compiling; and then check the Register For COM Interop Check Box.

3.) Now, one last thing and you are ready to compile. In the AssemblyInfo.cs, set ComVisible to true.

ComVisible

Well, thats it and now you have a program that will add a layer to your ArcMap session.

04/16/08

Permalink 08:34:38 pm, by Jayson Rawlins Email , 148 words, 116 views   English (US)
Categories: Economics

George W. Bush On Economics

Now if you listen closely, Bush actually believes that our economy is suffering because of we built too many houses and it doesn’t have anything to do with the national deficit caused by the Iraq war.

Now, I often will say that I can’t stand Bush when around conservatives in order to shock people. In reality, I just don’t think Bush, nor his advisers are wise.

I’m not a supporter for expensive entitlement policies (i.e. Medicare, Medicaid, social security etc.) Granted, I’m glad that these policies have benefited folks; however, I think that these kinds of programs work better in the private domain. Capitalism works! Yet, with the amount of money spent on this damn war everybody could have had free health care for years.

We really need to go back to a more free market and move towards a non-interventionist foreign policy.

02/23/08

Permalink 09:08:38 pm, by Jayson Rawlins Email , 395 words, 104 views   English (US)
Categories: Announcements

Evolution Taught As Fact In Florida Public Schools

Here is a link to the article: Orlandosentinel On Evolution In Public Schools

Evolution As Fact

“Evolution has been a cornerstone of biology for more than 100 years,…..”

This statement is amazing to me! I am not a big biology buff so I can’t know first hand how important it is know evolution in order to do biology but this sounds like a huge jump in reasoning. Why would I need to know where genetic matter came from in order to learn how it works? In other words, are they suggesting that until they learned that humans came from chimpanzees that we were completely helpless in understanding the human dna? Am I really to understand that? I’m sorry but that sounds stupid to me!

Obviously I object to the kind of evolution that is being taught because of religious reasons. If I were an atheist, I’d probably be pretty happy about it! I think the bible is clear that man was created from the ground and the animals were created “after their kind” (Gen. 1:20-25). I think this explicitly contradicts the standard evolutionary explanation which tells us that the various animals evolved from simpler organisms and specifically that man has evolved from chimpanzees. They believe this because of how similar the dna is between chimpanzees and humans (something like 96%www.genome.gov/15515096).

I don’t find this convincing. Here is a simple Modus Tollens for why I don’t believe the kind of evolution that is being pro ported these days:

1.) If macro-evolution is true, then there would be huge numbers of intermediate species.
2.) It is not the case that there are huge numbers of intermediate species.
3.) Therefore, macro-evolution is false.

Why would I think there should be huge numbers of intermediate species? Well, I find it a low probably that every single intermediate species became extinct. After all, humans survived and chimps survived. Why didn’t any of the intermediate species which would have been plentiful with over million of years of evolution.

I’m sorry but before folks can get me on board they are going to have to give me some names of ‘humanzees’. Find me an animal that is between chimps and humans having the dna make up of 97% and then we can talk but to suggest that not one intermediate species between humans and chimps survived and then call evolution a fact is simply stupid!

Permalink 08:46:45 pm, by Jayson Rawlins Email , 0 words, 45 views   English (US)
Categories: Recommended Blogs

John Porter's Blog

Permalink 04:44:44 pm, by Jayson Rawlins Email , 470 words, 45 views   English (US)
Categories: Apologetics

Reasons For My Faith

Law Of Non Contradiction
First, I must begin with a couple of arguments concerning rationality. Firstly, logic requires that A must be A and it can’t be A and B. In other words, contradictions are not acceptable. God either exists or He doesn’t. While this may seem simple and rather obvious, there are relativists out there who like to talk about religion in relative terms. My parents for example tend to think of religion as being truth and knowledge to the person believing. Often I remember hearing, “God becomes truth because you believe it.” I do not accept this as rational thinking. My belief that God as true and somebody else’s belief that God is not true can not be both correct. Somebody must be mistaken! Consequently, I take for granted the Law of non contradiction http://en.wikipedia.org/wiki/Law_of_noncontradiction”.

Acceptable Arguments
Within Christian circles there are a number of views on how a person goes about proving the existence of God (see for a basic list of methods www.theopedia.com/Apologetics
In my opinion, I think the bible uses all sorts methods:

  1. Luke uses a journalistic/lawyer approach counting on eyewitness accounts so that

    Theophilus,…..you may know the certainty of the things you have been taught.

    Luke 1:1-4.
  2. God instructed Moses to use the miraculous nature of prophecy to separate the fakes from the genuine men of God speaking God’s word (Deuteronomy 18:22). And the apostles frequently appealed to prophecy when arguing against the Jews.
  3. The apostle Paul appeals to creation in Romans 1:19-20 as being such clear revelation of God that men have no excuse.
  4. Jesus appealed to His works as an evidence of His words (John 14:11).

On the other hand, I do think that presuppositional apologetics is generally the most biblical apologetic method due to its accounting of presuppositions and the lack of neutrality in arguing with an unbeliever; in contrast, traditional arguments don’t alway appear to include scripture as part of their arguments as though they were trying to argue on neutral ground.

That doesn’t mean that the arguments aren’t useful. I just think they yield too much to the unbeliever.

So, here is a summary of my argument for the existence of the Christian God (not detailed):

1.) The Christian God (through revelation) provides the necessary preconditions of ethics, science, and laws of reasoning.
2.) Revelation is evidenced by its supernatural ability to predict the future.
3.) History demonstrates the inexplicable way in which so many people believed that Jesus Christ was raised from the dead even though this idea would have contradicted the philosophy of the day.
4.) My personal experiences with the Christian God also evidences the truth of Christ.
5.) My feelings also support my thinking that the Christian God is true.

Each of these points will be addressed in separate posts…

:: Next Page >>

Musings of Jayson Rawlins

About me:


My name is Jayson Rawlins. I have many interests but my biggest will always be my faith in Christ. Other interests are: fitness, martial arts, GIS programming, ethics, and philosophy. I also enjoy music and art but I can't sing worth a crap and don't know jack about art.

| Next >

November 2008
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            

Search

Linkblog

Musings

Recommended Blogs

  • Craig Sowder's Blog

    My roommates blog…He writes very well and covers many interesting topics.

    Permalink
  • John Porter's Blog Permalink
  • Triablog

    These guys are brilliant! I know Paul Manata and that guy keeps getting smarter and smarter. Highly recommended.

    Permalink

XML Feeds

What is RSS?

Who's Online?

  • Guest Users: 1

powered by b2evolution free blog software